openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
123 lines (122 loc) • 6.33 kB
JavaScript
import { r as GatewayErrorDetailCodes } from "./gateway-error-details-DIefe7Zy.mjs";
//#region src/gateway/github-publication-failure.ts
const identityNextAction = "Reconnect My GitHub or System GitHub in Settings → Profile → GitHub connections (agent overrides: Agents → Tools), then request publication again.";
/** An owner observed a definitive outcome; an unavailable probe is not this failure. */
var GitHubPublicationKnownFailure = class extends Error {
constructor(message, failure, rejection) {
super(message);
this.failure = failure;
this.rejection = rejection;
}
};
function rejectGitHubPublicationSelection(message, preparation) {
let rejection;
try {
if (preparation && !preparation.hasRequest()) rejection = {
code: GatewayErrorDetailCodes.GITHUB_PUBLICATION_SELECTION_REJECTED,
idempotencyKey: preparation.idempotencyKey
};
} catch {}
throw new GitHubPublicationKnownFailure(message, {
code: "identity_changed",
nextAction: identityNextAction
}, rejection);
}
var GitHubPublicationWorkspaceChangedError = class extends GitHubPublicationKnownFailure {
constructor(message) {
super(message, {
code: "workspace_changed",
nextAction: "Inspect the reconciled workspace and any recorded GitHub effects, then request a new publication after reviewing the changes."
});
}
};
var GitHubPublicationBranchChangedError = class extends GitHubPublicationKnownFailure {
constructor() {
super("GitHub publication cannot safely extend the published branch.", {
code: "push_rejected",
nextAction: "Preserve your local work and inspect the published head. To refresh the existing PR, apply the intended changes on top of that head without rewriting its history; 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."
});
}
};
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: "Your saved changes are intact. Ask a maintainer with full write access to publish the GitHub workflow changes, or restore the workflow definitions and request publication again."
});
}
};
function resolveGitHubPublicationFailure(error) {
if (error instanceof GitHubPublicationKnownFailure) return error.failure;
const message = error instanceof Error ? error.message : "";
if (message.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 (message.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 (message.includes("identity")) return {
code: message.includes("changed") ? "identity_changed" : "identity_unavailable",
nextAction: identityNextAction
};
if (message.includes("session") || message.includes("worktree owner")) return {
code: "session_changed",
nextAction: "Open the current session worktree and request publication again."
};
if (message.includes("transport configuration") || message.includes("replacement metadata")) return {
code: "workspace_changed",
nextAction: "Remove the unsupported Git transport or replacement configuration from the session worktree, then retry."
};
if (message.includes("workspace") || message.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 (message.includes("not a git")) return {
code: "not_git",
nextAction: "Use a session-owned Git worktree to publish."
};
if (message.includes("GitHub remote")) return {
code: "not_github",
nextAction: "Use a GitHub repository remote to publish."
};
if (message.includes("push")) return {
code: "push_rejected",
nextAction: "Check repository write access and branch drift, then retry without force-pushing."
};
if (message.includes("pull request") || message.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."
};
}
//#endregion
export { GitHubPublicationSessionChangedError as a, rejectGitHubPublicationSelection as c, GitHubPublicationRequesterUnavailableError as i, resolveGitHubPublicationFailure as l, GitHubPublicationCreditChangedError as n, GitHubPublicationWorkflowChangesError as o, GitHubPublicationKnownFailure as r, GitHubPublicationWorkspaceChangedError as s, GitHubPublicationBranchChangedError as t };