UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 10.5 kB
import{a as extractErrorCode}from"./error-coercion-DlKnt6w-.mjs";import{a as asOptionalRecord}from"./record-coerce-BTbqdJ3-.mjs";import"./errors-D37BJTfI.mjs";import{t as createSubsystemLogger}from"./subsystem-DLCDFvCH.mjs";import{n as GatewayErrorDetailCodes}from"./gateway-error-details-CMG6VuUF.mjs";import{t as createCommandError}from"./command-error-B187dN8z.mjs";import{a as NODE_WORKSPACE_PUBLICATION_CONFLICT_CODE,l as NodeWorkerWorkspaceTransferError}from"./node-workspace-transfer-protocol-BFfyPciA.mjs";import{s as WORKSPACE_RESULT_LIMIT_ERROR_CODE}from"./workspace-inventory-limits-BmPI7yuU.mjs"; //!src/gateway/github-publication-failure.ts const identityNextAction=`Reconnect My GitHub, the shared agent account, or the agent’s own account in Settings → Profile → GitHub accounts, then request publication again.`;var GitHubPublicationKnownFailure=class extends Error{constructor(e,t,n){super(e);this.failure=t;this.rejection=n}};var GitHubPublicationApiError=class extends Error{constructor(e,t){const n=createCommandError(`GitHub API command`,{...e,stdout:Buffer.alloc(0),stderr:Buffer.alloc(0),error:void 0},{timeoutMs:t}).message;const r=/\(HTTP ([1-5]\d{2})\)/u.exec(e.stderr.toString(`utf8`))?.[1];super(`${n}${r?`; HTTP ${r}`:``}.`)}};function gitHubPublicationWorkerReadFailure(e){if(e instanceof GitHubPublicationApiError&&/HTTP 403/u.test(e.message))return new GitHubPublicationKnownFailure(`Worker repository read is unavailable (HTTP 403).`,{code:`unavailable`,nextAction:`GitHub may be rate-limiting this read. Wait before retrying; if the refusal persists, verify the normal worker execution account's repository access. The personal publisher connection is separate.`});if(e instanceof GitHubPublicationApiError&&/HTTP 404/u.test(e.message))return new GitHubPublicationKnownFailure(`Worker execution identity cannot read the publication repositories.`,{code:`identity_unavailable`,nextAction:`The normal worker GitHub execution account could not read the source or target repository. Review its existing access, then explicitly request publication again. This failed request and checkpoint remain saved; the personal publisher connection is separate.`});return e}function rejectGitHubPublicationSelection(e,t){let n;try{if(t&&!t.hasRequest())n={code:GatewayErrorDetailCodes.GITHUB_PUBLICATION_SELECTION_REJECTED,idempotencyKey:t.idempotencyKey}}catch{}throw new GitHubPublicationKnownFailure(e,{code:`identity_changed`,nextAction:identityNextAction},n)}var GitHubPublicationWorkspaceChangedError=class extends GitHubPublicationKnownFailure{constructor(e){super(e,{code:`workspace_changed`,nextAction:`Inspect the reconciled workspace and any recorded GitHub effects, then request a new publication after reviewing the changes.`})}};var GitHubPublicationSessionBranchMismatchError=class extends GitHubPublicationKnownFailure{constructor(e){const{session:t,checkedOut:n}=e;super(`The session worktree has branch ${n} checked out, but this session publishes branch ${t}.`,{code:`workspace_changed`,nextAction:`In the session worktree, rename the branch back with \`git branch -m ${n} ${t}\`, or switch to it with \`git switch ${t}\` if it still exists, then request publication again. Publication only pushes the session branch.`})}};var GitHubPublicationBranchChangedError=class extends GitHubPublicationKnownFailure{constructor(e={}){super(`GitHub publication cannot safely extend the published branch.`,{code:`push_rejected`,nextAction:e.originalPullRequest?`The PR head changed after this workspace last integrated it. Your local work is saved: call prepare_pr with this PR's URL to merge its newer head into that work, resolve any returned conflicts, then publish again. Do not create a replacement PR or redirect publication to another branch.`:`Preserve your local work and inspect the published head. If this conversation published the PR from its managed workspace, call prepare_pr with its URL to merge the newer head into the saved work, then publish again; otherwise publish from a new session branch and open a replacement PR. Repository-only checkpoints cannot adopt external branch changes; use a new session branch for those. Do not merge old history merely to make a rebased branch pushable. The broker never rewrites published history.`})}};function gitHubPublicationPushFailure(e,t,{login:n,pushRepository:r}){if(!t||e.code===0||e.signal!==null||e.killed)return/* @__PURE__ */ new Error(e.code===0?`GitHub push verification failed.`:`GitHub push was rejected.`);return new GitHubPublicationKnownFailure(`GitHub rejected the push to ${r}.`,{code:`push_rejected`,nextAction:`Nothing was pushed as @${n}. Give @${n} write access (or point the worktree's origin at a fork it owns) and check the repository's branch rules, then request publication again.`})}var GitHubPublicationSessionChangedError=class extends GitHubPublicationKnownFailure{constructor(){super(`GitHub publication session lifecycle changed.`,{code:`session_changed`,nextAction:`Review any recorded GitHub effects, then request publication from the current session.`})}};var GitHubPublicationRequesterUnavailableError=class extends GitHubPublicationKnownFailure{constructor(){super(`The original GitHub publication requester is no longer authorized.`,{code:`identity_changed`,nextAction:`Review any recorded or unconfirmed GitHub effects, then request publication again from an authorized session. Saved work and existing pull requests are retained.`})}};var GitHubPublicationCreditChangedError=class extends GitHubPublicationKnownFailure{constructor(){super(`GitHub publication contributor credit changed.`,{code:`identity_changed`,nextAction:`Review contributor credit and any recorded GitHub effects, reconcile unpushed prepared commits, then request a new publication. Already published commits and pull requests are retained.`})}};var GitHubPublicationWorkflowChangesError=class extends GitHubPublicationKnownFailure{constructor(){super(`Publishing GitHub workflow changes requires full operator write permission.`,{code:`github_rejected`,nextAction:`OpenClaw requires the requester's full operator write authority for these workflow changes; this is not a GitHub token scope failure. Your saved changes are intact. Ask a maintainer with full write access to publish, or remove only unintended workflow edits after reviewing the accepted diff.`})}};function recordGitHubPublicationFailure(e,t){const n=resolveGitHubPublicationFailure(e);if(!(e instanceof GitHubPublicationKnownFailure))try{createSubsystemLogger(`gateway/github-publication`).warn(`Repository publication failed`,{requestId:t.request_id,sessionId:t.session_id,failureCode:n.code,errorCode:extractErrorCode(e)})}catch{}return n}function resolveGitHubPublicationFailure(e){if(extractErrorCode(e)===`PUBLICATION_CONFLICT`)return{code:`workspace_changed`,nextAction:`The accepted checkpoint conflicts with the current publication base. Your saved work is retained; resolve the conflicts before requesting a new publication.`};if(e instanceof NodeWorkerWorkspaceTransferError){const t=/Publication integration [a-z-]{1,48} failed \((?:exit|error|timeout|signal|no-output-timeout|output-limit); exit (?:null|-?\d+)\)\./u.exec(e.message)?.[0]??/\b(?:ECONNRESET|ECONNREFUSED|ETIMEDOUT|ENOTFOUND|EAI_AGAIN|HTTP [1-5]\d{2}|gateway returned [1-5]\d{2})\b/u.exec(e.message)?.[0];return{code:`unavailable`,nextAction:`${t?`${t} `:``}Worker publication transfer failed. Restore worker and repository connectivity, then retry the same request.`}}if(e instanceof GitHubPublicationApiError)return{code:`unavailable`,nextAction:`${e.message} Retry after the Gateway and GitHub are available.`};if(e instanceof GitHubPublicationKnownFailure){const t=/[.!?]$/u.test(e.message)?e.message:`${e.message}.`;return{code:e.failure.code,nextAction:`${t} ${e.failure.nextAction}`}}const t=e instanceof Error?e.message:``;if(t&&asOptionalRecord(e)?.code===`WORKSPACE_RESULT_LIMIT`)return{code:`workspace_changed`,nextAction:t};if(t.includes(`publication workspace base`))return{code:`unavailable`,nextAction:`The pull request base or its Git history could not be verified. Check repository read access, connectivity, and local Git objects before retrying publication.`};if(t.includes(`publication remote branch could not be verified`))return{code:`unavailable`,nextAction:`Restore repository read access or connectivity, then verify the published branch before retrying. An unavailable observation does not prove the branch is absent or safe to overwrite.`};if(t.includes(`identity`))return{code:t.includes(`changed`)?`identity_changed`:`identity_unavailable`,nextAction:identityNextAction};if(t.includes(`session`)||t.includes(`worktree owner`))return{code:`session_changed`,nextAction:`Open the current session worktree and request publication again.`};if(t.includes(`transport configuration`)||t.includes(`replacement metadata`))return{code:`workspace_changed`,nextAction:`Remove the unsupported Git transport or replacement configuration from the session worktree, then retry.`};if(t.includes(`workspace`)||t.includes(`branch changed`))return{code:`workspace_changed`,nextAction:`Inspect the reconciled workspace and any recorded GitHub effects, then request a new publication after reviewing the changes.`};if(t.includes(`not a git`))return{code:`not_git`,nextAction:`Use a session-owned Git worktree to publish.`};if(t.includes(`GitHub remote`))return{code:`not_github`,nextAction:`Use a GitHub repository remote to publish.`};if(t.includes(`push`))return{code:`push_rejected`,nextAction:`Check repository write access and branch drift, then retry without force-pushing.`};if(t.includes(`pull request`)||t.includes(`GitHub`))return{code:`github_rejected`,nextAction:`Check pull-request permission for the effective account, then retry.`};return{code:`unavailable`,nextAction:`Retry after the Gateway and GitHub are available.`}}export{GitHubPublicationRequesterUnavailableError as a,GitHubPublicationWorkflowChangesError as c,gitHubPublicationWorkerReadFailure as d,recordGitHubPublicationFailure as f,GitHubPublicationKnownFailure as i,GitHubPublicationWorkspaceChangedError as l,resolveGitHubPublicationFailure as m,GitHubPublicationBranchChangedError as n,GitHubPublicationSessionBranchMismatchError as o,rejectGitHubPublicationSelection as p,GitHubPublicationCreditChangedError as r,GitHubPublicationSessionChangedError as s,GitHubPublicationApiError as t,gitHubPublicationPushFailure as u};