UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 2.59 kB
import{n as sha256Hex}from"./node-crypto-DPk8agfR.mjs";import{h as SessionGitHubPublicationFailedSchema}from"./session-github-publication-BWfce2xy.mjs"; //!src/gateway/github-publication-receipt.ts const PUBLICATION_FAILURE_CODES=new Set(SessionGitHubPublicationFailedSchema.properties.code.anyOf.map(e=>e.const));function publicationFailureCode(e){return PUBLICATION_FAILURE_CODES.has(e)?e:`unavailable`}function matchesGitHubPublicationIdentityRow(e,t){return e.identity_source===t.source&&e.identity_profile_id===(t.profileId??null)&&e.identity_account_id===t.account.accountId&&e.identity_login.toLowerCase()===t.account.login.toLowerCase()}function digestGitHubPublicationRequest(e){return sha256Hex(JSON.stringify({sessionId:e.sessionId,idempotencyKey:e.idempotencyKey,title:e.title??null,body:e.body??null,...e.draft!==void 0?{draft:e.draft}:{}}))}function projectGitHubPublicationResult(e){const t=(e.last_effect===`push`||e.last_effect===`pull_request`)&&(e.effect_state===`dispatched`||e.effect_state===`observed`)?{effect:{kind:e.last_effect,status:e.effect_state,...e.head_commit?{headCommit:e.head_commit}:{},...e.pull_request_url?{url:e.pull_request_url}:{}}}:{};const n={requestId:e.request_id,publisher:{source:e.identity_source===`personal`||e.identity_source===`agent-override`||e.identity_source===`system-configured`?e.identity_source:`system-detected`,accountId:e.identity_account_id,login:e.identity_login},...t};if(e.status===`published`&&e.pull_request_url&&e.repository&&e.branch)return{...n,status:`published`,url:e.pull_request_url,repository:e.repository,branch:e.branch,headCommit:e.head_commit??`unknown`};if(e.status===`failed`&&e.error_code&&e.next_action)return{...n,status:`failed`,code:publicationFailureCode(e.error_code),message:`GitHub publication failed.`,nextAction:e.next_action};if(e.status===`needs_confirmation`)return{...n,status:`needs_confirmation`,message:`Confirm the original My GitHub account, target, and workspace to continue this interrupted publication. Already-dispatched GitHub effects may have completed; confirmation checks them before retrying.`};return{...n,status:e.status===`publishing`?`publishing`:`requested`,message:e.status===`publishing`?`The Gateway is publishing the reconciled workspace.`:e.identity_source===`personal`?`My GitHub publication was accepted for the selected account and workspace.`:`Publication was accepted. Finish the turn so the Gateway can reconcile and publish the workspace.`}}export{matchesGitHubPublicationIdentityRow as n,projectGitHubPublicationResult as r,digestGitHubPublicationRequest as t};