@north-light/cli 0.3.531 → 0.3.533
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/client.d.ts +6 -3
- package/dist/api/client.js +1 -1
- package/dist/api/contract.d.ts +1 -1
- package/dist/api/contract.js +1 -1
- package/dist/api/dto/canvas.d.ts +2 -0
- package/dist/api/dto/crons.d.ts +2 -0
- package/dist/builtin-memory/crouter-sdk/release-notes.md +8 -0
- package/dist/builtin-memory/northlight-apps/providers/README.md +2 -0
- package/dist/builtin-memory/northlight-apps/providers/sms.md +2 -0
- package/dist/clients/attach/chrome/inbox-strip.d.ts +6 -1
- package/dist/clients/attach/chrome/inbox-strip.js +1 -1
- package/dist/clients/attach/chrome/roster.js +1 -1
- package/dist/clients/attach/session/chrome-refresh.d.ts +12 -3
- package/dist/clients/attach/session/chrome-refresh.js +1 -1
- package/dist/clients/attach/session/document-links.js +1 -1
- package/dist/clients/attach/viewer.js +586 -587
- package/dist/commands/api-client.js +3 -3
- package/dist/commands/node/inspect.js +6 -6
- package/dist/commands/sys/context/expose.js +2 -2
- package/dist/commands/sys/db.d.ts +1 -0
- package/dist/commands/sys/db.js +1 -0
- package/dist/commands/sys.js +1 -1
- package/dist/core/bash-guard.js +9 -3
- package/dist/core/canvas/canvas.d.ts +12 -2
- package/dist/core/canvas/canvas.js +23 -20
- package/dist/core/canvas/daemon-actions.d.ts +0 -3
- package/dist/core/canvas/daemon-actions.js +7 -24
- package/dist/core/canvas/daemon-owner.d.ts +3 -0
- package/dist/core/canvas/daemon-owner.js +1 -6
- package/dist/core/canvas/db.d.ts +28 -20
- package/dist/core/canvas/db.js +4 -3
- package/dist/core/canvas/deliveries.d.ts +5 -0
- package/dist/core/canvas/deliveries.js +25 -30
- package/dist/core/canvas/export-sqlite.d.ts +14 -0
- package/dist/core/canvas/export-sqlite.js +3 -0
- package/dist/core/canvas/import-sqlite.d.ts +44 -0
- package/dist/core/canvas/import-sqlite.js +7 -0
- package/dist/core/canvas/node-tokens.js +3 -3
- package/dist/core/canvas/outcome-actions.js +4 -4
- package/dist/core/canvas/recovery.js +1 -1
- package/dist/core/canvas/schema-pg.sql +1022 -0
- package/dist/core/canvas/schema-version.d.ts +4 -0
- package/dist/core/canvas/schema-version.js +1 -0
- package/dist/core/canvas/sessions.js +3 -3
- package/dist/core/canvas/structured-requests.js +2 -2
- package/dist/core/canvas/tree.js +6 -6
- package/dist/core/canvas/waits.js +1 -1
- package/dist/core/feed/inbox.js +1 -1
- package/dist/core/feed/messages.js +5 -5
- package/dist/core/feed/reports.js +2 -2
- package/dist/core/grants/mirror.js +2 -2
- package/dist/core/graph/access.js +7 -7
- package/dist/core/graph/custom.js +10 -10
- package/dist/core/graph/deletion.js +6 -6
- package/dist/core/graph/documents.d.ts +1 -1
- package/dist/core/graph/documents.js +9 -9
- package/dist/core/graph/edges.d.ts +3 -3
- package/dist/core/graph/edges.js +3 -1
- package/dist/core/graph/events.js +7 -7
- package/dist/core/graph/exposures.d.ts +8 -8
- package/dist/core/graph/jobs.d.ts +1 -1
- package/dist/core/graph/jobs.js +2 -2
- package/dist/core/graph/kinds/custom.js +1 -1
- package/dist/core/graph/kinds/document.js +4 -4
- package/dist/core/graph/kinds/dto.js +1 -1
- package/dist/core/graph/kinds/job.js +2 -2
- package/dist/core/graph/kinds/kind.d.ts +2 -2
- package/dist/core/graph/kinds/kind.js +1 -1
- package/dist/core/graph/kinds/live-read.d.ts +5 -0
- package/dist/core/graph/kinds/live-read.js +1 -0
- package/dist/core/graph/kinds/node.js +5 -5
- package/dist/core/graph/kinds/owner.js +2 -2
- package/dist/core/graph/names.js +3 -3
- package/dist/core/graph/objects.d.ts +5 -5
- package/dist/core/graph/objects.js +10 -10
- package/dist/core/graph/package-docs.js +6 -5
- package/dist/core/graph/reader.d.ts +1 -1
- package/dist/core/graph/reader.js +2 -2
- package/dist/core/graph/receivers.js +4 -5
- package/dist/core/graph/repo-sync/exchange.js +2 -2
- package/dist/core/graph/repo-sync/repos.js +3 -3
- package/dist/core/graph/repo-sync/sync.js +1 -1
- package/dist/core/graph/rules.d.ts +3 -4
- package/dist/core/graph/rules.js +3 -3
- package/dist/core/graph/spaces/app.js +1 -1
- package/dist/core/graph/spaces/index.d.ts +1 -1
- package/dist/core/graph/spaces/index.js +1 -1
- package/dist/core/graph/spaces/own-memory.js +1 -1
- package/dist/core/graph/spaces/person.js +3 -3
- package/dist/core/graph/spaces/repo.d.ts +1 -1
- package/dist/core/graph/spaces/repo.js +1 -1
- package/dist/core/graph/types.d.ts +4 -3
- package/dist/core/graph/watches.d.ts +2 -2
- package/dist/core/graph/watches.js +17 -17
- package/dist/core/human/page-schema.js +5 -4
- package/dist/core/human/requests.d.ts +1 -1
- package/dist/core/human/requests.js +20 -23
- package/dist/core/llm/run.js +2 -2
- package/dist/core/peer/home.d.ts +6 -0
- package/dist/core/peer/home.js +2 -2
- package/dist/core/peer/ingest.js +1 -1
- package/dist/core/peer/receiver.js +1 -1
- package/dist/core/peer/stubs.js +1 -1
- package/dist/core/providers/receipts.js +3 -2
- package/dist/core/review/comments.js +5 -4
- package/dist/core/runs/activity.js +4 -5
- package/dist/core/runs/confinement.d.ts +1 -1
- package/dist/core/runs/confinement.js +2 -2
- package/dist/core/runs/events.d.ts +1 -1
- package/dist/core/runs/events.js +5 -5
- package/dist/core/runs/operations.js +6 -4
- package/dist/core/runtime/close.d.ts +3 -0
- package/dist/core/runtime/close.js +1 -1
- package/dist/core/runtime/host.d.ts +5 -1
- package/dist/core/runtime/host.js +3 -3
- package/dist/core/runtime/launch.js +2 -2
- package/dist/core/runtime/ledger.js +3 -3
- package/dist/core/runtime/lifecycle.d.ts +9 -0
- package/dist/core/runtime/lifecycle.js +2 -2
- package/dist/core/runtime/nodes.d.ts +1 -1
- package/dist/core/runtime/nodes.js +1 -1
- package/dist/core/runtime/roadmap.js +1 -1
- package/dist/core/spaces/stop.d.ts +1 -0
- package/dist/core/spaces/stop.js +2 -2
- package/dist/core/statements.d.ts +17 -0
- package/dist/core/statements.js +2 -0
- package/dist/core/substrate/delivery/corpus.js +3 -3
- package/dist/core/substrate/delivery/deliver.js +5 -5
- package/dist/core/substrate/delivery/listings.js +1 -1
- package/dist/core/substrate/delivery/match.d.ts +2 -2
- package/dist/core/substrate/delivery/match.js +1 -1
- package/dist/core/substrate/delivery/plan.js +3 -3
- package/dist/core/substrate/delivery/render-boot.js +5 -5
- package/dist/core/substrate/delivery/render-event.js +6 -6
- package/dist/core/usage/ledger.js +8 -8
- package/dist/daemon/api/bridge.js +4 -4
- package/dist/daemon/api/document-listener.js +1 -1
- package/dist/daemon/api/handlers/broker-ops.js +1 -1
- package/dist/daemon/api/handlers/canvas.js +1 -1
- package/dist/daemon/api/handlers/crons.js +1 -1
- package/dist/daemon/api/handlers/custom-objects.js +3 -3
- package/dist/daemon/api/handlers/docs.js +1 -1
- package/dist/daemon/api/handlers/inbox.js +1 -1
- package/dist/daemon/api/handlers/memory.js +7 -7
- package/dist/daemon/api/handlers/messages.js +1 -1
- package/dist/daemon/api/handlers/nodes.js +1 -1
- package/dist/daemon/api/handlers/objects.js +3 -3
- package/dist/daemon/api/handlers/reviews.js +1 -1
- package/dist/daemon/api/handlers/structured-requests.js +1 -1
- package/dist/daemon/api/reader.js +1 -1
- package/dist/daemon/broker-signals/bus.d.ts +14 -6
- package/dist/daemon/broker-signals/bus.js +1 -10
- package/dist/daemon/crtrd-cli.js +1 -1
- package/dist/daemon/crtrd.js +12 -11
- package/dist/daemon/due.js +1 -1
- package/dist/daemon/export-sqlite-run.d.ts +1 -0
- package/dist/daemon/export-sqlite-run.js +4 -0
- package/dist/daemon/fleet.d.ts +1 -0
- package/dist/daemon/fleet.js +3 -3
- package/dist/daemon/human/settle.js +1 -1
- package/dist/daemon/manage.d.ts +10 -0
- package/dist/daemon/manage.js +3 -2
- package/dist/daemon/peer/forward.d.ts +7 -0
- package/dist/daemon/peer/forward.js +1 -1
- package/dist/daemon/postgres/binary.d.ts +17 -0
- package/dist/daemon/postgres/binary.js +2 -0
- package/dist/daemon/postgres/cluster.d.ts +37 -0
- package/dist/daemon/postgres/cluster.js +6 -0
- package/dist/daemon/postgres/index.d.ts +2 -0
- package/dist/daemon/postgres/index.js +1 -0
- package/dist/daemon/postgres/pins.d.ts +7 -0
- package/dist/daemon/postgres/pins.js +1 -0
- package/dist/daemon/postgres/supervisor.d.ts +95 -0
- package/dist/daemon/postgres/supervisor.js +2 -0
- package/dist/daemon/reconcilers/bash-deadline.js +2 -2
- package/dist/daemon/reconcilers/delivery-lane.js +2 -2
- package/dist/daemon/reconcilers/node-lifecycle/freeze-lane.d.ts +7 -3
- package/dist/daemon/reconcilers/node-lifecycle/freeze-lane.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/tick.js +1 -1
- package/dist/daemon/reconcilers/storage-maintenance.d.ts +0 -6
- package/dist/daemon/reconcilers/storage-maintenance.js +1 -8
- package/dist/daemon/runs/observer.js +5 -4
- package/dist/migrations/004-canvas-documents/index.js +1 -1
- package/dist/pi-extensions/canvas-doc-substrate.d.ts +2 -0
- package/dist/pi-extensions/canvas-doc-substrate.js +6 -6
- package/dist/pi-extensions/envelope-merge.d.ts +3 -2
- package/dist/pi-extensions/envelope-merge.js +9 -8
- package/dist/shared/env.d.ts +3 -0
- package/dist/shared/env.js +2 -2
- package/docs/apps/providers/README.md +2 -0
- package/docs/apps/providers/sms.md +2 -0
- package/docs/public-api.md +11 -2
- package/docs/sdk/release-notes.md +8 -0
- package/package.json +6 -6
- package/packages/crouter-identity/package.json +1 -1
- package/runtime.lock.json +13 -26
- package/scripts/install-runtime.mjs +53 -3
- package/scripts/lib/isolation-env.mjs +3 -1
package/dist/api/client.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ import type { ChatInventoryDTO, ProspectiveChatInventoryDTO, ProspectiveChatInve
|
|
|
28
28
|
import type { CredentialRemovalResultDTO, CredentialResultDTO, InstallCredentialRequest, CompleteModelAuthFlowRequest, ModelAuthFlowCompletedDTO, ModelAuthFlowDTO, ModelAuthFlowStartedDTO, ModelAuthListDTO, ModelAuthReadinessDTO, ModelAuthReadinessQuery, StartModelAuthFlowRequest } from './dto/modelauth.js';
|
|
29
29
|
import type { CancelReviewRequest, CreateReviewRequest, ListReviewsQuery, ReviewCancelResultDTO, ReviewDocumentBaseDTO, ReviewDTO, ReviewListDTO, ReviewSubmitResultDTO } from './dto/reviews.js';
|
|
30
30
|
import type { CreateReviewCommentRequest, EditReviewCommentRequest, ListReviewCommentsQuery, ReadReviewCommentEventsQuery, ReviewCommentActionRequest, ReviewCommentDetailDTO, ReviewCommentEventsDTO, ReviewCommentForkDTO, ReviewCommentListDTO, ReviewCommentMutationDTO, ReviewCommentRangeBatchRequest, ReviewCommentRangeBatchResultDTO } from './dto/review-comments.js';
|
|
31
|
-
import type { CancelInboxTicketRequest, CanceledTicketResultDTO, InboxListDTO, InboxPageDTO, InboxPageHistoryDTO, InboxPageResponseDTO, InboxTicketIdDTO, PageFeedbackResolutionDTO, PageResponsesDTO, PageTicketResultDTO, RespondInboxPageRequest } from './dto/inbox.js';
|
|
31
|
+
import type { CancelInboxTicketRequest, CanceledTicketResultDTO, InboxListDTO, InboxPageDTO, InboxPageHistoryDTO, PageTicketSummaryDTO, InboxPageResponseDTO, InboxTicketIdDTO, PageFeedbackResolutionDTO, PageResponsesDTO, PageTicketResultDTO, RespondInboxPageRequest } from './dto/inbox.js';
|
|
32
32
|
import type { CreateHumanRequestDTO, CreateHumanRequestRequest, HumanRequestDTO, HumanRequestIdDTO, ReplaceHumanRequestRequest, RespondHumanRequestRequest, SettleHumanRequestRequest, PageComponentListDTO } from './dto/human-requests.js';
|
|
33
33
|
import type { AttentionCountsDTO, AttentionDTO, DashboardDTO, DashboardQuery, HistoryGrepQuery, HistoryGrepResultDTO, HistoryReadQuery, HistoryStatsQuery, HistoryStatsResultDTO, HistoryReadResultDTO, HistorySearchQuery, HistorySearchResultDTO, GraphDTO, PruneRequest, PruneResultDTO, LiveRootsDTO, RosterDTO, SnapshotDTO } from './dto/canvas.js';
|
|
34
34
|
import type { AbandonWorktreeRequest, AbandonWorktreeResultDTO, CloseWorktreeResultDTO, QuarantinedWorktreeDTO, SpaceListDTO } from './dto/worktree.js';
|
|
@@ -377,8 +377,11 @@ export declare class CrtrClient {
|
|
|
377
377
|
/** Read one page ticket by its opaque ticket id (pending, resolved, or canceled). */
|
|
378
378
|
getHumanInboxPage(ticketId: InboxTicketIdDTO): Promise<InboxPageDTO>;
|
|
379
379
|
/** All page tickets, oldest first (pending, resolved, or canceled) —
|
|
380
|
-
* home-wide, or narrowed to one raising node when `nodeId` is given
|
|
381
|
-
|
|
380
|
+
* home-wide, or narrowed to one raising node when `nodeId` is given, and to
|
|
381
|
+
* one ticket state when `opts.state` is given. */
|
|
382
|
+
getInboxHistory(nodeId?: string, opts?: {
|
|
383
|
+
state?: PageTicketSummaryDTO['state'];
|
|
384
|
+
}): Promise<InboxPageHistoryDTO>;
|
|
382
385
|
/** Submit responses for a page ticket. Single-assignment server-side: a competing
|
|
383
386
|
* resolution races to `ticket_already_resolved`. */
|
|
384
387
|
respondHumanInboxPage(ticketId: InboxTicketIdDTO, request: RespondInboxPageRequest): Promise<PageTicketResultDTO>;
|
package/dist/api/client.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
var A=Object.defineProperty;var a=(o,e)=>A(o,"name",{value:e,configurable:!0});import{ApiError as m,isErrorBody as D}from"./errors.js";import{routes as r}from"./routes.js";import{isSafeNodeId as y}from"./dto/common.js";import{isSafeBashJobId as N}from"./dto/bash-jobs.js";import{isSafeCronId as x}from"./dto/crons.js";const B=3e4,L=Symbol.for("@north-light/api/local-socket-fetch"),I=1e4,F=200;async function $({windowMs:o,probe:e,initialError:t,pollIntervalMs:n=F,retry:s=a(()=>!0,"retry"),now:i=Date.now,sleep:d=M}){const c=i()+o;let h=t;for(;;){const f=c-i();if(f<=0)throw h??new Error("crtrd availability window expired without a probe failure");try{await e(f);return}catch(P){if(h=P,!s(P))throw P}const l=c-i();if(l<=0)throw h;await d(Math.min(n,l))}}a($,"waitForDaemonAvailability");const p=2147483647;function E(o,e="elapsed",t){const n=e==="retry_after"?`the server asked to retry after ${t}s, which is later than the call's deadline (${new Date(o).toISOString()}); not waiting`:`the call's deadline (${new Date(o).toISOString()}) passed`;return new m(504,"deadline_exceeded",n,{deadline_at:o,reason:e,...t===void 0?{}:{retry_after_s:t}})}a(E,"deadlineExceeded");const S=a(o=>E(o??Date.now()),"budgetExhausted");class Y{static{a(this,"CrtrClient")}baseUrl;fetch;headers;autostart;timeoutMs;maxRetries;localSocketTransport;onColdSocket;coldStartDiagnostic;coldStartFailure;coldStartPollWindowMs;startupFailureReported=!1;coldStartAttempted=!1;constructor(e){if(e.baseUrl==="")throw new TypeError("CrtrClient requires baseUrl");this.baseUrl=new URL(e.baseUrl),this.fetch=e.fetch??globalThis.fetch,this.headers={...e.headers},this.autostart=e.autostart??!1,this.timeoutMs=e.timeoutMs??B,this.maxRetries=e.maxRetries??2,this.localSocketTransport=this.fetch[L]===!0,e.onColdSocket!==void 0&&(this.onColdSocket=e.onColdSocket),e.coldStartDiagnostic!==void 0&&(this.coldStartDiagnostic=e.coldStartDiagnostic),e.coldStartFailure!==void 0&&(this.coldStartFailure=e.coldStartFailure),this.coldStartPollWindowMs=e.coldStartPollWindowMs??I}healthz(){return this.request("GET",r.healthz())}async probeHealthz(e){const t=await this.transport("GET",r.healthz(),void 0,{timeout:e});if(t.status===503)try{const n=await t.clone().json();if(typeof n.startup_blocked=="string")return n}catch{}return q(t)}async ready(){const e=await this.transport("GET",r.ready(),void 0,{});if(e.status===503)try{const t=await e.clone().json();if(t.ready===!1)return t}catch{}return q(e)}status(){return this.request("GET",r.status())}due(){return this.request("GET",r.due())}restartDaemon(){return this.request("POST",r.daemonRestart())}admitDaemon(){return this.request("POST",r.daemonAdmit())}migrateState(e){return this.request("POST",r.daemonMigrate(),e)}appendNodeLog(e,t){return this.request("POST",r.nodeLog(this.nodePath(e)),t)}async putNodeTelemetry(e,t){await this.request("PUT",r.nodeTelemetry(this.nodePath(e)),t)}async putNodeRecap(e,t){await this.request("PUT",r.nodeRecap(this.nodePath(e)),t)}readNodeInboxReport(e,t,n){return this.request("GET",u(r.nodeInboxReport(this.nodePath(e)),{ref:t,execution_id:n}))}readNodePassiveMessage(e,t){return this.request("GET",u(r.nodePassiveMessage(this.nodePath(e)),{ref:t}))}nodePushedFinal(e,t){return this.request("POST",r.nodePushedFinal(this.nodePath(e)),t)}createNode(e){return this.request("POST",r.nodes(),e)}listNodes(e){return this.request("GET",u(r.nodes(),e))}getNode(e){return this.request("GET",r.node(this.nodePath(e)))}getNodeOutcome(e,{waitSeconds:t}={}){if(t!==void 0&&(!Number.isInteger(t)||t<0||t>25))throw new RangeError("waitSeconds must be an integer between 0 and 25");return this.request("GET",u(r.nodeOutcome(this.nodePath(e)),{wait:t}),void 0,{timeout:(t??0)*1e3+this.timeoutMs})}getNodeEvents(e,t={},n={}){if(t.after!==void 0&&(!Number.isSafeInteger(t.after)||t.after<0))throw new RangeError("after must be a non-negative safe integer");return this.transport("GET",u(r.nodeEvents(this.nodePath(e)),t),void 0,{...n,headers:{accept:"text/event-stream",...n.headers??{}},timeout:0})}async*getBrokerSignals(e,t,n={}){const s=await this.send("GET",u(r.nodeBrokerSignals(this.nodePath(e)),{execution_id:t}),void 0,{...n,headers:{accept:"application/x-ndjson",...n.headers??{}},timeout:0});if(!s.ok){await q(s);return}if(s.body===null)throw new m(s.status,"invalid_response","broker signal stream has no body");const i=s.body.getReader(),d=new TextDecoder;let c="";try{for(;;){const{done:h,value:f}=await i.read();if(h)break;c+=d.decode(f,{stream:!0});let l;for(;(l=c.indexOf(`
|
|
2
|
-
`))!==-1;){const P=c.slice(0,l);c=c.slice(l+1),P!==""&&(yield JSON.parse(P))}}if(c+=d.decode(),c.trim()!=="")throw new m(502,"invalid_response","broker signal stream ended mid-line")}finally{await i.cancel().catch(()=>{})}}createStructuredRequest(e,t){return e.mode==="sync"?this.sendOnce("POST","/v1/structured-requests",e,t):this.request("POST","/v1/structured-requests",e,t)}getStructuredRequest(e,{wait:t=0,budgetMs:n}={}){if(!Number.isInteger(t)||t<0||t>25)throw new RangeError("wait must be an integer between 0 and 25");return this.request("GET",u(`/v1/structured-requests/${this.requestPath(e)}`,{wait:t}),void 0,{budgetMs:n})}cancelStructuredRequest(e,t){return this.request("POST",`/v1/structured-requests/${this.requestPath(e)}/cancel`,{},t)}registerOutcomeDelivery(e,t){return this.request("PUT",r.nodeOutcomeDelivery(this.nodePath(e)),t)}getOutcomeDelivery(e){return this.request("GET",r.nodeOutcomeDelivery(this.nodePath(e)))}async disarmOutcomeDelivery(e){await this.request("DELETE",r.nodeOutcomeDelivery(this.nodePath(e)))}listBashJobs(e){return this.request("GET",r.nodeJobs(this.nodePath(e)))}stopBashJob(e,t){return this.request("DELETE",r.nodeJob(this.nodePath(e),this.jobPath(t)))}sendMessage(e,t){return this.request("POST",r.nodeMessages(this.nodePath(e)),t)}interruptNode(e){return this.request("POST",r.nodeInterrupt(this.nodePath(e)),{})}pushReport(e,t){return this.request("POST",r.nodeReports(this.nodePath(e)),t)}submitResult(e,t){return this.request("POST",r.nodeResult(this.nodePath(e)),t)}forkNode(e){return this.request("POST",r.nodeFork(this.nodePath(e)),{})}reviveNode(e,t){return this.request("POST",r.nodeRevive(this.nodePath(e)),t??{})}relaunchRoot(e){return this.request("POST",r.nodeRelaunchRoot(this.nodePath(e)),{})}bindBrokerSession(e,t){return this.request("POST",r.nodeBrokerSessionBound(this.nodePath(e)),t)}settleBroker(e,t){return this.request("POST",r.nodeBrokerSettle(this.nodePath(e)),t)}completeBrokerPark(e,t){return this.request("POST",r.nodeBrokerParkComplete(this.nodePath(e)),t)}recordBrokerParkActivity(e,t){return this.request("POST",r.nodeBrokerParkActivity(this.nodePath(e)),t)}async recordBrokerTelemetry(e,t){await this.request("POST",r.nodeBrokerTelemetry(this.nodePath(e)),t)}claimNodeMail(e,t){return this.request("POST",r.nodeMailClaim(this.nodePath(e)),t)}acknowledgeNodeMail(e,t){return this.request("POST",r.nodeMailAcknowledge(this.nodePath(e)),t)}recordBrokerTurn(e,t){return this.request("POST",r.brokerTurn(this.nodePath(e)),t)}mutateBrokerProviderRetry(e,t){return this.request("POST",r.brokerProviderRetry(this.nodePath(e)),t)}mutateBrokerFault(e,t){return this.request("POST",r.brokerFault(this.nodePath(e)),t)}getBrokerRecovery(e,t){return this.request("GET",`${r.brokerRecovery(this.nodePath(e))}?expected_execution_id=${encodeURIComponent(t)}`)}recordNodeFault(e,t){return this.request("POST",r.nodeFault(this.nodePath(e)),t)}clearNodeFault(e,t={}){const n=new URLSearchParams;t.link!==void 0&&n.set("link",t.link),t.preserve_episode!==void 0&&n.set("preserve_episode",String(t.preserve_episode));const s=n.size===0?"":`?${n.toString()}`;return this.request("DELETE",`${r.nodeFault(this.nodePath(e))}${s}`)}commitBrokerModel(e,t){return this.request("POST",r.nodeBrokerModel(this.nodePath(e)),t)}brokerExtensionState(e){return this.request("GET",r.nodeBrokerExtensionState(this.nodePath(e)))}commitBrokerGeneratedName(e,t){return this.request("POST",r.nodeBrokerGeneratedName(this.nodePath(e)),t)}commitBrokerPersonaAck(e,t){return this.request("POST",r.nodeBrokerPersonaAck(this.nodePath(e)),t)}closeNode(e,t){return this.request("POST",r.nodeClose(this.nodePath(e)),t??{})}async markNodeRead(e){await this.request("POST",r.nodeRead(this.nodePath(e)),{})}recycleNode(e){return this.request("POST",r.nodeRecycle(this.nodePath(e)),{})}demoteNode(e){return this.request("POST",r.nodeDemote(this.nodePath(e)),{})}promoteNode(e,t){return this.request("POST",r.nodePromote(this.nodePath(e)),t)}yieldNode(e,t){return this.request("POST",r.nodeYield(this.nodePath(e)),t)}waitNode(e,t){return this.request("POST",r.nodeWait(this.nodePath(e)),t)}listKinds(){return this.request("GET",r.kinds())}patchConfig(e,t){return this.request("PATCH",r.nodeConfig(this.nodePath(e)),t,t.model!==void 0?{timeout:45e3+this.timeoutMs}:void 0)}closeWorktree(e){return this.request("POST",r.nodeWorktreeClose(this.nodePath(e)),{})}abandonWorktree(e,t){return this.request("POST",r.nodeWorktreeAbandon(this.nodePath(e)),t)}retryDelivery(e){return this.request("POST",r.deliveryRetry(e),{})}listQuarantinedWorktrees(){return this.request("GET",r.quarantinedWorktrees())}showLimits(){return this.request("GET",r.limits())}setAppLimits(e,t){return this.request("PUT",r.limitsApp(e),t)}removeAppLimits(e,t){return this.request("DELETE",u(r.limitsApp(e),{fields:t.join(",")}))}listSpaces(){return this.request("GET",r.spaces())}subscribe(e,t){return this.request("POST",r.nodeSubscriptions(this.nodePath(e)),t)}listFocuses(){return this.request("GET",r.focuses())}focusOf(e){return this.request("GET",u(r.focusByNode(),{node_id:e}))}focusByPane(e){return this.request("GET",u(r.focusByPane(),{pane:e}))}registerFocus(e){return this.request("POST",r.focuses(),e)}async setFocusPane(e,t){await this.request("PATCH",r.focus(e),t)}async closeFocus(e){await this.request("DELETE",r.focus(e))}async unsubscribe(e,t){await this.request("DELETE",r.nodeSubscription(this.nodePath(e),this.nodePath(t)))}armCron(e){return this.request("POST",r.crons(),e)}listCrons(e){return this.request("GET",u(r.crons(),e))}showCron(e,t){return this.request("GET",u(r.cron(this.cronPath(e)),t))}pauseCron(e,t){return this.request("POST",u(r.cronPause(this.cronPath(e)),t),{})}resumeCron(e,t){return this.request("POST",u(r.cronResume(this.cronPath(e)),t),{})}runCron(e,t){return this.request("POST",u(r.cronRun(this.cronPath(e)),t),{})}async cancelCron(e,t){await this.request("DELETE",u(r.cron(this.cronPath(e)),t))}pokeCrons(){return this.request("POST",r.cronsPoke(),{})}ensureAttach(e,t){return this.request("POST",r.nodeAttach(this.nodePath(e)),t??{})}getReports(e,t){return this.request("GET",u(r.nodeReports(this.nodePath(e)),t))}getTranscript(e,t){return this.request("GET",u(r.nodeTranscript(this.nodePath(e)),t))}getSnapshot(e){return this.request("GET",r.nodeSnapshot(this.nodePath(e)))}nodeSubject(e){return this.request("GET",r.nodeSubject(this.nodePath(e)))}getNodeMessages(e,t){return this.request("GET",u(r.nodeMessages(this.nodePath(e)),t))}getSession(e){return this.request("GET",r.nodeSession(this.nodePath(e)))}getChatInventory(e){return this.request("GET",r.nodeChatInventory(this.nodePath(e)))}getProspectiveChatInventory(e){return this.request("GET",u(r.prospectiveChatInventory(),e))}getContext(e){return this.request("GET",r.nodeContext(this.nodePath(e)))}peekFile(e,t,n){return this.request("GET",u(r.filePeek(),{path:e,encoding:t}),void 0,n)}writeFile(e,t,n,s){return this.request("POST",r.fileWrite(),{path:e,content:t,encoding:n},s)}listFiles(e,t,n){return this.request("GET",u(r.fileList(),{path:e,limit:t}),void 0,n)}runBash(e,t){return this.request("POST",r.bash(),e,t)}objects={read:a((e,t)=>this.request("GET",u(r.object(e),t)),"read"),list:a(e=>this.request("GET",u(r.objects(),e)),"list"),search:a(e=>this.request("POST",r.objectsSearch(),e),"search"),watch:a((e,t={})=>this.request("POST",r.objectWatch(e),t),"watch"),unwatch:a((e,t)=>this.request("DELETE",u(r.objectWatch(e),t)),"unwatch"),edges:a((e,t)=>this.request("GET",u(r.objectEdges(e),t)),"edges")};docs={write:a(e=>this.request("POST",r.docs(),e),"write"),edit:a((e,t)=>this.request("PATCH",r.doc(e),t),"edit"),move:a((e,t)=>this.request("POST",r.docMove(e),t),"move"),delete:a(e=>this.request("DELETE",r.doc(e)),"delete"),history:a((e,t)=>this.request("GET",u(r.docHistory(e),t)),"history"),lint:a((e={})=>this.request("POST",r.docsLint(),e),"lint")};documents={browserAccess:a(()=>this.request("GET",r.documentsBrowserAccess()),"browserAccess"),reconcilePackages:a(()=>this.request("POST",r.documentsReconcilePackages()),"reconcilePackages")};plugins={appToken:a(e=>this.request("GET",r.pluginAppToken(e)),"appToken"),callHeaders:a((e,t)=>this.request("POST",r.pluginCallHeaders(e),t),"callHeaders")};nodeDelivery(e,t){return this.request("POST",r.nodeDelivery(this.nodePath(e)),t)}deliveryDryRun(e){return this.request("POST",r.deliveryDryRun(),e)}recordBackgroundedJob(e,t,n){return this.request("POST",r.nodeJobBackground(this.nodePath(e),this.jobPath(t)),n)}ensureProfile(e,t){return this.request("PUT",r.profile(e),t??{})}createProfile(e){return this.request("POST",r.profiles(),e)}listProfiles(){return this.request("GET",r.profiles())}updateProfile(e,t){return this.request("PATCH",r.profile(e),t)}listAppEnv(){return this.request("GET",r.appEnv())}setAppEnv(e,t){return this.request("PUT",r.appEnvVar(e),{value:t})}removeAppEnv(e){return this.request("DELETE",r.appEnvVar(e))}listProfileEnv(e){return this.request("GET",r.profileEnv(e))}setProfileEnv(e,t,n){return this.request("PUT",r.profileEnvVar(e,t),{value:n})}removeProfileEnv(e,t){return this.request("DELETE",r.profileEnvVar(e,t))}getProfile(e){return this.request("GET",r.profile(e))}pauseProfile(e){return this.request("POST",r.profilePause(e),{})}resumeProfile(e){return this.request("POST",r.profileResume(e),{})}updateProfileMetadata(e,t){return this.request("PATCH",r.profileMetadata(e),t)}deleteProfile(e,t){return this.request("DELETE",r.profile(e),t)}listModelAuth(){return this.request("GET",r.modelAuths())}getModelAuthReadiness(e){return this.request("GET",u(r.modelAuthReadiness(),e))}installCredential(e,t){return this.request("PUT",r.modelAuth(e),t)}removeCredential(e){return this.request("DELETE",r.modelAuth(e))}startModelAuth(e){return this.request("POST",r.modelAuthFlows(),e,{timeout:3e4+this.timeoutMs})}completeModelAuth(e,t){return this.request("POST",r.modelAuthFlowComplete(e),t,{timeout:35e3+this.timeoutMs})}cancelModelAuth(e){return this.request("POST",r.modelAuthFlowCancel(e),{})}getModelAuthFlow(e,t){return this.request("GET",u(r.modelAuthFlow(e),{wait:t}),void 0,{timeout:(t??0)*1e3+this.timeoutMs})}createReview(e){return this.request("POST",r.humanReviews(),e)}listReviews(e){return this.request("GET",u(r.humanReviews(),e))}getReview(e){return this.request("GET",r.humanReview(this.reviewPath(e)))}submitReview(e){return this.request("POST",r.humanReviewSubmit(this.reviewPath(e)),{})}cancelReview(e,t={}){return this.request("POST",r.humanReviewCancel(this.reviewPath(e)),t)}getReviewDocumentBase(e){return this.request("GET",r.humanReviewDocument(this.reviewPath(e)))}createReviewComment(e,t){const n=e===void 0?"self":this.reviewPath(e);return this.request("POST",r.humanReviewComments(n),t)}listReviewComments(e,t){const n=e===void 0?"self":this.reviewPath(e);return this.request("GET",u(r.humanReviewComments(n),t))}readReviewCommentEvents(e,t){return this.request("GET",u(r.humanReviewCommentEvents(this.reviewPath(e)),t))}updateReviewCommentRanges(e,t){return this.request("POST",r.humanReviewCommentRanges(this.reviewPath(e)),t)}getReviewComment(e){return this.request("GET",r.humanComment(this.commentPath(e)))}editReviewComment(e,t){return this.request("POST",r.humanCommentEdit(this.commentPath(e)),t)}resolveReviewComment(e,t={}){return this.request("POST",r.humanCommentResolve(this.commentPath(e)),t)}reopenReviewComment(e,t={}){return this.request("POST",r.humanCommentReopen(this.commentPath(e)),t)}deleteReviewComment(e,t={}){return this.request("POST",r.humanCommentDelete(this.commentPath(e)),t)}forkReviewComment(e){return this.request("POST",r.humanCommentFork(this.commentPath(e)),{})}listHumanInbox(){return this.request("GET",r.humanInbox())}getHumanInboxPage(e){return this.request("GET",r.humanInboxTicket(this.ticketId(e)))}getInboxHistory(e){if(e===void 0)return this.request("GET",r.humanInbox()+"/history");if(typeof e!="string"||e==="")throw new TypeError(`invalid node id: ${JSON.stringify(e)}`);return this.request("GET",u(r.humanInbox()+"/history",{node_id:e}))}respondHumanInboxPage(e,t){return this.request("POST",r.humanInboxRespond(this.ticketId(e)),t)}postInboxProgress(e,t){return this.request("POST",r.humanInboxProgress(this.ticketId(e)),{responses:t})}getInboxResponse(e){return this.request("GET",r.humanInboxResponse(this.ticketId(e)))}cancelHumanInboxTicket(e,t){return this.request("POST",r.humanInboxCancel(this.ticketId(e)),t??{})}createHumanRequest(e){return this.request("POST",r.humanRequests(),e)}listPageComponents(){return this.request("GET",r.humanComponents())}getHumanRequest(e){return this.request("GET",r.humanRequest(this.requestPath(e)))}replaceHumanRequest(e,t){return this.request("POST",r.humanRequestReplace(this.requestPath(e)),t)}respondHumanRequest(e,t){return this.request("POST",r.humanRequestRespond(this.requestPath(e)),t)}dismissHumanRequest(e,t={}){return this.request("POST",r.humanRequestDismiss(this.requestPath(e)),t)}cancelHumanRequest(e,t={}){return this.request("POST",r.humanRequestCancel(this.requestPath(e)),t)}resolvePageFeedbackComment(e,t,n){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(t))throw new TypeError(`invalid feedback comment id: ${JSON.stringify(t)}`);return this.request("POST",r.humanInboxFeedbackResolve(this.ticketId(e),t),{node_id:n})}async dashboard(e){const t=e?.under!==void 0?{under:e.under}:void 0,[n,s]=await Promise.all([this.listNodes(t),this.status()]);return{nodes:n,counts:s.node_counts,generated_at:new Date().toISOString()}}attention(){return this.request("GET",r.canvasAttention())}attentionCounts(e){const t={node_ids:e};return this.request("POST",r.canvasAttentionCounts(),t)}historySearch(e){return this.request("POST",r.canvasHistorySearch(),e)}historyGrep(e){return this.request("POST",r.canvasHistoryGrep(),e)}historyRead(e){return this.request("GET",u(r.canvasHistoryRead(),e))}historyStats(e){return this.request("POST",r.canvasHistoryStats(),e)}canvasSnapshot(){return this.request("GET",r.canvasSnapshot())}analytics(e){return this.request("GET",u(r.canvasAnalytics(),e),void 0,{timeout:6e4})}async recordMemoryReads(e,t){await this.request("POST",r.nodeMemoryReads(this.nodePath(e)),t)}liveRoots(e={}){return this.request("GET",u(r.canvasLiveRoots(),e))}canvasRoster(){return this.request("GET",r.canvasRoster())}async canvasBrowseCompressed(){const e=await this.send("GET",r.canvasBrowse());return e.ok||await q(e),new Uint8Array(await e.arrayBuffer())}canvasGraph(){return this.request("GET",r.canvasGraph())}prune(e){return this.request("POST",r.canvasPrune(),e)}async request(e,t,n,s){try{const i=s===void 0?void 0:this.resolveBudget(s),d=await this.send(e,t,n,i);return await q(d,i?.deadlineAt)}catch(i){throw T(i,s?.signal)}}async rawResponse(e,t,n){try{return await this.send(e,t,void 0,n)}catch(s){throw T(s,n?.signal)}}async send(e,t,n,s={}){const i=this.resolveBudget(s),d=e==="GET"||e==="HEAD"||e==="DELETE",c=i.maxRetries??this.maxRetries;for(let h=0;;h++){let f;try{f=await this.transport(e,t,n,i)}catch(l){if(this.isColdSocketError(l))try{await this.handleColdSocket(l,i.deadlineAt),f=await this.transport(e,t,n,i)}catch(P){throw i.deadlineAt!==void 0&&Date.now()>=i.deadlineAt&&!G(P,i.signal)?E(i.deadlineAt):T(P,i.signal)}else{if(this.isInterruptedSocketError(l)&&this.localSocketTransport&&(!d||h<c))return await this.rideOutInterruptedRequest(e,t,n,i);if(d&&h<c&&!G(l,i.signal)&&(!this.localSocketTransport||!this.isInterruptedSocketError(l))){await _(C(h+1),i);continue}else throw T(l,i.signal)}}if(d&&h<c&&H(f.status)){await k(f,i.deadlineAt),await _(C(h+1),i,j(f));continue}return f}}resolveBudget(e){const{budgetMs:t,deadlineAt:n,...s}=e;if(t===void 0&&n===void 0)return s;if(t!==void 0&&(!Number.isFinite(t)||t<=0||t>p))throw new RangeError(`budgetMs must be a positive finite number of at most ${p}`);if(n!==void 0&&(!Number.isFinite(n)||n-Date.now()>p))throw new RangeError(`deadlineAt must be a finite epoch-millisecond instant at most ${p} ms from now`);return{...s,deadlineAt:Math.min(n??1/0,t===void 0?1/0:Date.now()+t)}}async awaitWithinBudget(e,t){if(t===void 0)return e;const n=t-Date.now();if(n<=0)throw S(t);let s;try{return await Promise.race([e,new Promise((i,d)=>{s=setTimeout(()=>d(S(t)),n)})])}finally{s!==void 0&&clearTimeout(s)}}async sendOnce(e,t,n,s={}){const i=this.resolveBudget(s);try{return await q(await this.transport(e,t,n,i))}catch(d){throw T(d,i.signal)}}nodePath(e){if(!y(e))throw new m(400,"invalid_node_id",`invalid node id: ${JSON.stringify(e)}`);return e}jobPath(e){if(!N(e))throw new m(400,"invalid_job_id",`invalid background job id: ${JSON.stringify(e)}`);return e}cronPath(e){if(!x(e))throw new m(400,"invalid_cron_id",`invalid cron id: ${JSON.stringify(e)}`);return e}requestPath(e){if(!y(e))throw new m(400,"invalid_request_id",`invalid request id: ${JSON.stringify(e)}`);return e}ticketId(e){if(!/^[a-f0-9]{64}$/.test(e))throw new TypeError(`invalid inbox ticket id: ${JSON.stringify(e)}`);return e}reviewPath(e){if(!y(e))throw new m(400,"invalid_review_id",`invalid review id: ${JSON.stringify(e)}`);return e}commentPath(e){if(!/^[a-f0-9]{32}$/.test(e))throw new m(400,"invalid_comment_id",`invalid comment id: ${JSON.stringify(e)}`);return e}transport(e,t,n,s={}){const i=s.deadlineAt===void 0?void 0:s.deadlineAt-Date.now();if(i!==void 0&&i<=0)return Promise.reject(S(s.deadlineAt));const d=n===void 0?void 0:JSON.stringify(n),c={accept:"application/json",...this.headers,...s.headers};d!==void 0&&(c["content-type"]="application/json");const h=s.timeout??this.timeoutMs,f=i===void 0?h:h>0?Math.min(h,i):i,l=new AbortController,P=i!==void 0&&(h<=0||i<=h),g=f>0?setTimeout(()=>l.abort(P?S(s.deadlineAt):new DOMException("request timed out","TimeoutError")),f):void 0,w=s.signal,O=a(()=>l.abort(w?.reason),"onExternalAbort");w!==void 0&&(w.aborted?l.abort(w.reason):w.addEventListener("abort",O,{once:!0}));const R=a(()=>{g!==void 0&&clearTimeout(g),w?.removeEventListener("abort",O)},"finish");return W(this.fetch(new URL(t,this.baseUrl),{method:e,headers:c,body:d,signal:l.signal}),l.signal).then(v=>this.retainRequestLifetime(v,R,()=>l.signal.aborted?l.signal.reason:void 0),v=>{throw R(),v})}retainRequestLifetime(e,t,n){if(e.body===null)return t(),e;const s=e.body.getReader();let i=!1;const d=a(()=>{i||(i=!0,t())},"close"),c=new ReadableStream({async pull(h){try{const{done:f,value:l}=await s.read();f?(d(),h.close()):h.enqueue(l)}catch(f){d(),h.error(n()??f)}},async cancel(h){d(),await s.cancel(h)}});return new Response(c,{status:e.status,statusText:e.statusText,headers:e.headers})}isColdSocketError(e){const t=b(e);return t==="ECONNREFUSED"||t==="ENOENT"||t==="ENOTSOCK"}isInterruptedSocketError(e){const t=b(e);return t==="ECONNRESET"||t==="EPIPE"}async rideOutInterruptedRequest(e,t,n,s={}){try{await this.awaitAvailability(void 0,s.deadlineAt)}catch(i){throw T(i,s.signal)}if(e!=="GET"&&e!=="HEAD")throw new m(503,"daemon_request_interrupted",`crtrd connection ended before this ${e} response; the request may or may not have been applied.`);try{return await this.transport(e,t,n,s)}catch(i){throw T(i,s.signal)}}async awaitAvailability(e,t){const n=t===void 0?void 0:t-Date.now();if(n!==void 0&&n<=0)throw S(t);let s;try{await $({windowMs:Math.min(this.coldStartPollWindowMs,n??this.coldStartPollWindowMs),initialError:e,retry:a(i=>i!==s,"retry"),probe:a(async i=>{const d=this.coldStartFailure?.();if(d!==void 0)throw s=new m(503,"daemon_unavailable",`crtrd failed to start: ${d}`),s;const c=await this.transport("GET",r.healthz(),void 0,{timeout:i});if(c.status>=200&&c.status<300){await k(c);return}const h=await c.text();try{if(typeof JSON.parse(h).startup_blocked=="string")return}catch{}throw new m(c.status,"daemon_health_unavailable",`crtrd health check returned HTTP ${c.status}: ${h.slice(0,500)}`)},"probe")})}catch(i){throw i===s&&(this.startupFailureReported=!0),i}}async handleColdSocket(e,t){const n=this.autostart&&this.onColdSocket!==void 0&&!this.coldStartAttempted;n&&(this.coldStartAttempted=!0,await this.awaitWithinBudget(this.onColdSocket(),t));try{await this.awaitAvailability(e,t)}catch(s){if(n&&!this.startupFailureReported){const i=J(this.coldStartDiagnostic);if(i!==void 0){const d=T(s);throw new m(d.status,d.code,`${d.message}
|
|
2
|
+
`))!==-1;){const P=c.slice(0,l);c=c.slice(l+1),P!==""&&(yield JSON.parse(P))}}if(c+=d.decode(),c.trim()!=="")throw new m(502,"invalid_response","broker signal stream ended mid-line")}finally{await i.cancel().catch(()=>{})}}createStructuredRequest(e,t){return e.mode==="sync"?this.sendOnce("POST","/v1/structured-requests",e,t):this.request("POST","/v1/structured-requests",e,t)}getStructuredRequest(e,{wait:t=0,budgetMs:n}={}){if(!Number.isInteger(t)||t<0||t>25)throw new RangeError("wait must be an integer between 0 and 25");return this.request("GET",u(`/v1/structured-requests/${this.requestPath(e)}`,{wait:t}),void 0,{budgetMs:n})}cancelStructuredRequest(e,t){return this.request("POST",`/v1/structured-requests/${this.requestPath(e)}/cancel`,{},t)}registerOutcomeDelivery(e,t){return this.request("PUT",r.nodeOutcomeDelivery(this.nodePath(e)),t)}getOutcomeDelivery(e){return this.request("GET",r.nodeOutcomeDelivery(this.nodePath(e)))}async disarmOutcomeDelivery(e){await this.request("DELETE",r.nodeOutcomeDelivery(this.nodePath(e)))}listBashJobs(e){return this.request("GET",r.nodeJobs(this.nodePath(e)))}stopBashJob(e,t){return this.request("DELETE",r.nodeJob(this.nodePath(e),this.jobPath(t)))}sendMessage(e,t){return this.request("POST",r.nodeMessages(this.nodePath(e)),t)}interruptNode(e){return this.request("POST",r.nodeInterrupt(this.nodePath(e)),{})}pushReport(e,t){return this.request("POST",r.nodeReports(this.nodePath(e)),t)}submitResult(e,t){return this.request("POST",r.nodeResult(this.nodePath(e)),t)}forkNode(e){return this.request("POST",r.nodeFork(this.nodePath(e)),{})}reviveNode(e,t){return this.request("POST",r.nodeRevive(this.nodePath(e)),t??{})}relaunchRoot(e){return this.request("POST",r.nodeRelaunchRoot(this.nodePath(e)),{})}bindBrokerSession(e,t){return this.request("POST",r.nodeBrokerSessionBound(this.nodePath(e)),t)}settleBroker(e,t){return this.request("POST",r.nodeBrokerSettle(this.nodePath(e)),t)}completeBrokerPark(e,t){return this.request("POST",r.nodeBrokerParkComplete(this.nodePath(e)),t)}recordBrokerParkActivity(e,t){return this.request("POST",r.nodeBrokerParkActivity(this.nodePath(e)),t)}async recordBrokerTelemetry(e,t){await this.request("POST",r.nodeBrokerTelemetry(this.nodePath(e)),t)}claimNodeMail(e,t){return this.request("POST",r.nodeMailClaim(this.nodePath(e)),t)}acknowledgeNodeMail(e,t){return this.request("POST",r.nodeMailAcknowledge(this.nodePath(e)),t)}recordBrokerTurn(e,t){return this.request("POST",r.brokerTurn(this.nodePath(e)),t)}mutateBrokerProviderRetry(e,t){return this.request("POST",r.brokerProviderRetry(this.nodePath(e)),t)}mutateBrokerFault(e,t){return this.request("POST",r.brokerFault(this.nodePath(e)),t)}getBrokerRecovery(e,t){return this.request("GET",`${r.brokerRecovery(this.nodePath(e))}?expected_execution_id=${encodeURIComponent(t)}`)}recordNodeFault(e,t){return this.request("POST",r.nodeFault(this.nodePath(e)),t)}clearNodeFault(e,t={}){const n=new URLSearchParams;t.link!==void 0&&n.set("link",t.link),t.preserve_episode!==void 0&&n.set("preserve_episode",String(t.preserve_episode));const s=n.size===0?"":`?${n.toString()}`;return this.request("DELETE",`${r.nodeFault(this.nodePath(e))}${s}`)}commitBrokerModel(e,t){return this.request("POST",r.nodeBrokerModel(this.nodePath(e)),t)}brokerExtensionState(e){return this.request("GET",r.nodeBrokerExtensionState(this.nodePath(e)))}commitBrokerGeneratedName(e,t){return this.request("POST",r.nodeBrokerGeneratedName(this.nodePath(e)),t)}commitBrokerPersonaAck(e,t){return this.request("POST",r.nodeBrokerPersonaAck(this.nodePath(e)),t)}closeNode(e,t){return this.request("POST",r.nodeClose(this.nodePath(e)),t??{})}async markNodeRead(e){await this.request("POST",r.nodeRead(this.nodePath(e)),{})}recycleNode(e){return this.request("POST",r.nodeRecycle(this.nodePath(e)),{})}demoteNode(e){return this.request("POST",r.nodeDemote(this.nodePath(e)),{})}promoteNode(e,t){return this.request("POST",r.nodePromote(this.nodePath(e)),t)}yieldNode(e,t){return this.request("POST",r.nodeYield(this.nodePath(e)),t)}waitNode(e,t){return this.request("POST",r.nodeWait(this.nodePath(e)),t)}listKinds(){return this.request("GET",r.kinds())}patchConfig(e,t){return this.request("PATCH",r.nodeConfig(this.nodePath(e)),t,t.model!==void 0?{timeout:45e3+this.timeoutMs}:void 0)}closeWorktree(e){return this.request("POST",r.nodeWorktreeClose(this.nodePath(e)),{})}abandonWorktree(e,t){return this.request("POST",r.nodeWorktreeAbandon(this.nodePath(e)),t)}retryDelivery(e){return this.request("POST",r.deliveryRetry(e),{})}listQuarantinedWorktrees(){return this.request("GET",r.quarantinedWorktrees())}showLimits(){return this.request("GET",r.limits())}setAppLimits(e,t){return this.request("PUT",r.limitsApp(e),t)}removeAppLimits(e,t){return this.request("DELETE",u(r.limitsApp(e),{fields:t.join(",")}))}listSpaces(){return this.request("GET",r.spaces())}subscribe(e,t){return this.request("POST",r.nodeSubscriptions(this.nodePath(e)),t)}listFocuses(){return this.request("GET",r.focuses())}focusOf(e){return this.request("GET",u(r.focusByNode(),{node_id:e}))}focusByPane(e){return this.request("GET",u(r.focusByPane(),{pane:e}))}registerFocus(e){return this.request("POST",r.focuses(),e)}async setFocusPane(e,t){await this.request("PATCH",r.focus(e),t)}async closeFocus(e){await this.request("DELETE",r.focus(e))}async unsubscribe(e,t){await this.request("DELETE",r.nodeSubscription(this.nodePath(e),this.nodePath(t)))}armCron(e){return this.request("POST",r.crons(),e)}listCrons(e){return this.request("GET",u(r.crons(),e))}showCron(e,t){return this.request("GET",u(r.cron(this.cronPath(e)),t))}pauseCron(e,t){return this.request("POST",u(r.cronPause(this.cronPath(e)),t),{})}resumeCron(e,t){return this.request("POST",u(r.cronResume(this.cronPath(e)),t),{})}runCron(e,t){return this.request("POST",u(r.cronRun(this.cronPath(e)),t),{})}async cancelCron(e,t){await this.request("DELETE",u(r.cron(this.cronPath(e)),t))}pokeCrons(){return this.request("POST",r.cronsPoke(),{})}ensureAttach(e,t){return this.request("POST",r.nodeAttach(this.nodePath(e)),t??{})}getReports(e,t){return this.request("GET",u(r.nodeReports(this.nodePath(e)),t))}getTranscript(e,t){return this.request("GET",u(r.nodeTranscript(this.nodePath(e)),t))}getSnapshot(e){return this.request("GET",r.nodeSnapshot(this.nodePath(e)))}nodeSubject(e){return this.request("GET",r.nodeSubject(this.nodePath(e)))}getNodeMessages(e,t){return this.request("GET",u(r.nodeMessages(this.nodePath(e)),t))}getSession(e){return this.request("GET",r.nodeSession(this.nodePath(e)))}getChatInventory(e){return this.request("GET",r.nodeChatInventory(this.nodePath(e)))}getProspectiveChatInventory(e){return this.request("GET",u(r.prospectiveChatInventory(),e))}getContext(e){return this.request("GET",r.nodeContext(this.nodePath(e)))}peekFile(e,t,n){return this.request("GET",u(r.filePeek(),{path:e,encoding:t}),void 0,n)}writeFile(e,t,n,s){return this.request("POST",r.fileWrite(),{path:e,content:t,encoding:n},s)}listFiles(e,t,n){return this.request("GET",u(r.fileList(),{path:e,limit:t}),void 0,n)}runBash(e,t){return this.request("POST",r.bash(),e,t)}objects={read:a((e,t)=>this.request("GET",u(r.object(e),t)),"read"),list:a(e=>this.request("GET",u(r.objects(),e)),"list"),search:a(e=>this.request("POST",r.objectsSearch(),e),"search"),watch:a((e,t={})=>this.request("POST",r.objectWatch(e),t),"watch"),unwatch:a((e,t)=>this.request("DELETE",u(r.objectWatch(e),t)),"unwatch"),edges:a((e,t)=>this.request("GET",u(r.objectEdges(e),t)),"edges")};docs={write:a(e=>this.request("POST",r.docs(),e),"write"),edit:a((e,t)=>this.request("PATCH",r.doc(e),t),"edit"),move:a((e,t)=>this.request("POST",r.docMove(e),t),"move"),delete:a(e=>this.request("DELETE",r.doc(e)),"delete"),history:a((e,t)=>this.request("GET",u(r.docHistory(e),t)),"history"),lint:a((e={})=>this.request("POST",r.docsLint(),e),"lint")};documents={browserAccess:a(()=>this.request("GET",r.documentsBrowserAccess()),"browserAccess"),reconcilePackages:a(()=>this.request("POST",r.documentsReconcilePackages()),"reconcilePackages")};plugins={appToken:a(e=>this.request("GET",r.pluginAppToken(e)),"appToken"),callHeaders:a((e,t)=>this.request("POST",r.pluginCallHeaders(e),t),"callHeaders")};nodeDelivery(e,t){return this.request("POST",r.nodeDelivery(this.nodePath(e)),t)}deliveryDryRun(e){return this.request("POST",r.deliveryDryRun(),e)}recordBackgroundedJob(e,t,n){return this.request("POST",r.nodeJobBackground(this.nodePath(e),this.jobPath(t)),n)}ensureProfile(e,t){return this.request("PUT",r.profile(e),t??{})}createProfile(e){return this.request("POST",r.profiles(),e)}listProfiles(){return this.request("GET",r.profiles())}updateProfile(e,t){return this.request("PATCH",r.profile(e),t)}listAppEnv(){return this.request("GET",r.appEnv())}setAppEnv(e,t){return this.request("PUT",r.appEnvVar(e),{value:t})}removeAppEnv(e){return this.request("DELETE",r.appEnvVar(e))}listProfileEnv(e){return this.request("GET",r.profileEnv(e))}setProfileEnv(e,t,n){return this.request("PUT",r.profileEnvVar(e,t),{value:n})}removeProfileEnv(e,t){return this.request("DELETE",r.profileEnvVar(e,t))}getProfile(e){return this.request("GET",r.profile(e))}pauseProfile(e){return this.request("POST",r.profilePause(e),{})}resumeProfile(e){return this.request("POST",r.profileResume(e),{})}updateProfileMetadata(e,t){return this.request("PATCH",r.profileMetadata(e),t)}deleteProfile(e,t){return this.request("DELETE",r.profile(e),t)}listModelAuth(){return this.request("GET",r.modelAuths())}getModelAuthReadiness(e){return this.request("GET",u(r.modelAuthReadiness(),e))}installCredential(e,t){return this.request("PUT",r.modelAuth(e),t)}removeCredential(e){return this.request("DELETE",r.modelAuth(e))}startModelAuth(e){return this.request("POST",r.modelAuthFlows(),e,{timeout:3e4+this.timeoutMs})}completeModelAuth(e,t){return this.request("POST",r.modelAuthFlowComplete(e),t,{timeout:35e3+this.timeoutMs})}cancelModelAuth(e){return this.request("POST",r.modelAuthFlowCancel(e),{})}getModelAuthFlow(e,t){return this.request("GET",u(r.modelAuthFlow(e),{wait:t}),void 0,{timeout:(t??0)*1e3+this.timeoutMs})}createReview(e){return this.request("POST",r.humanReviews(),e)}listReviews(e){return this.request("GET",u(r.humanReviews(),e))}getReview(e){return this.request("GET",r.humanReview(this.reviewPath(e)))}submitReview(e){return this.request("POST",r.humanReviewSubmit(this.reviewPath(e)),{})}cancelReview(e,t={}){return this.request("POST",r.humanReviewCancel(this.reviewPath(e)),t)}getReviewDocumentBase(e){return this.request("GET",r.humanReviewDocument(this.reviewPath(e)))}createReviewComment(e,t){const n=e===void 0?"self":this.reviewPath(e);return this.request("POST",r.humanReviewComments(n),t)}listReviewComments(e,t){const n=e===void 0?"self":this.reviewPath(e);return this.request("GET",u(r.humanReviewComments(n),t))}readReviewCommentEvents(e,t){return this.request("GET",u(r.humanReviewCommentEvents(this.reviewPath(e)),t))}updateReviewCommentRanges(e,t){return this.request("POST",r.humanReviewCommentRanges(this.reviewPath(e)),t)}getReviewComment(e){return this.request("GET",r.humanComment(this.commentPath(e)))}editReviewComment(e,t){return this.request("POST",r.humanCommentEdit(this.commentPath(e)),t)}resolveReviewComment(e,t={}){return this.request("POST",r.humanCommentResolve(this.commentPath(e)),t)}reopenReviewComment(e,t={}){return this.request("POST",r.humanCommentReopen(this.commentPath(e)),t)}deleteReviewComment(e,t={}){return this.request("POST",r.humanCommentDelete(this.commentPath(e)),t)}forkReviewComment(e){return this.request("POST",r.humanCommentFork(this.commentPath(e)),{})}listHumanInbox(){return this.request("GET",r.humanInbox())}getHumanInboxPage(e){return this.request("GET",r.humanInboxTicket(this.ticketId(e)))}getInboxHistory(e,t={}){if(e!==void 0&&(typeof e!="string"||e===""))throw new TypeError(`invalid node id: ${JSON.stringify(e)}`);return this.request("GET",u(r.humanInbox()+"/history",{node_id:e,state:t.state}))}respondHumanInboxPage(e,t){return this.request("POST",r.humanInboxRespond(this.ticketId(e)),t)}postInboxProgress(e,t){return this.request("POST",r.humanInboxProgress(this.ticketId(e)),{responses:t})}getInboxResponse(e){return this.request("GET",r.humanInboxResponse(this.ticketId(e)))}cancelHumanInboxTicket(e,t){return this.request("POST",r.humanInboxCancel(this.ticketId(e)),t??{})}createHumanRequest(e){return this.request("POST",r.humanRequests(),e)}listPageComponents(){return this.request("GET",r.humanComponents())}getHumanRequest(e){return this.request("GET",r.humanRequest(this.requestPath(e)))}replaceHumanRequest(e,t){return this.request("POST",r.humanRequestReplace(this.requestPath(e)),t)}respondHumanRequest(e,t){return this.request("POST",r.humanRequestRespond(this.requestPath(e)),t)}dismissHumanRequest(e,t={}){return this.request("POST",r.humanRequestDismiss(this.requestPath(e)),t)}cancelHumanRequest(e,t={}){return this.request("POST",r.humanRequestCancel(this.requestPath(e)),t)}resolvePageFeedbackComment(e,t,n){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(t))throw new TypeError(`invalid feedback comment id: ${JSON.stringify(t)}`);return this.request("POST",r.humanInboxFeedbackResolve(this.ticketId(e),t),{node_id:n})}async dashboard(e){const t=e?.under!==void 0?{under:e.under}:void 0,[n,s]=await Promise.all([this.listNodes(t),this.status()]);return{nodes:n,counts:s.node_counts,generated_at:new Date().toISOString()}}attention(){return this.request("GET",r.canvasAttention())}attentionCounts(e){const t={node_ids:e};return this.request("POST",r.canvasAttentionCounts(),t)}historySearch(e){return this.request("POST",r.canvasHistorySearch(),e)}historyGrep(e){return this.request("POST",r.canvasHistoryGrep(),e)}historyRead(e){return this.request("GET",u(r.canvasHistoryRead(),e))}historyStats(e){return this.request("POST",r.canvasHistoryStats(),e)}canvasSnapshot(){return this.request("GET",r.canvasSnapshot())}analytics(e){return this.request("GET",u(r.canvasAnalytics(),e),void 0,{timeout:6e4})}async recordMemoryReads(e,t){await this.request("POST",r.nodeMemoryReads(this.nodePath(e)),t)}liveRoots(e={}){return this.request("GET",u(r.canvasLiveRoots(),e))}canvasRoster(){return this.request("GET",r.canvasRoster())}async canvasBrowseCompressed(){const e=await this.send("GET",r.canvasBrowse());return e.ok||await q(e),new Uint8Array(await e.arrayBuffer())}canvasGraph(){return this.request("GET",r.canvasGraph())}prune(e){return this.request("POST",r.canvasPrune(),e)}async request(e,t,n,s){try{const i=s===void 0?void 0:this.resolveBudget(s),d=await this.send(e,t,n,i);return await q(d,i?.deadlineAt)}catch(i){throw T(i,s?.signal)}}async rawResponse(e,t,n){try{return await this.send(e,t,void 0,n)}catch(s){throw T(s,n?.signal)}}async send(e,t,n,s={}){const i=this.resolveBudget(s),d=e==="GET"||e==="HEAD"||e==="DELETE",c=i.maxRetries??this.maxRetries;for(let h=0;;h++){let f;try{f=await this.transport(e,t,n,i)}catch(l){if(this.isColdSocketError(l))try{await this.handleColdSocket(l,i.deadlineAt),f=await this.transport(e,t,n,i)}catch(P){throw i.deadlineAt!==void 0&&Date.now()>=i.deadlineAt&&!G(P,i.signal)?E(i.deadlineAt):T(P,i.signal)}else{if(this.isInterruptedSocketError(l)&&this.localSocketTransport&&(!d||h<c))return await this.rideOutInterruptedRequest(e,t,n,i);if(d&&h<c&&!G(l,i.signal)&&(!this.localSocketTransport||!this.isInterruptedSocketError(l))){await _(C(h+1),i);continue}else throw T(l,i.signal)}}if(d&&h<c&&H(f.status)){await k(f,i.deadlineAt),await _(C(h+1),i,j(f));continue}return f}}resolveBudget(e){const{budgetMs:t,deadlineAt:n,...s}=e;if(t===void 0&&n===void 0)return s;if(t!==void 0&&(!Number.isFinite(t)||t<=0||t>p))throw new RangeError(`budgetMs must be a positive finite number of at most ${p}`);if(n!==void 0&&(!Number.isFinite(n)||n-Date.now()>p))throw new RangeError(`deadlineAt must be a finite epoch-millisecond instant at most ${p} ms from now`);return{...s,deadlineAt:Math.min(n??1/0,t===void 0?1/0:Date.now()+t)}}async awaitWithinBudget(e,t){if(t===void 0)return e;const n=t-Date.now();if(n<=0)throw S(t);let s;try{return await Promise.race([e,new Promise((i,d)=>{s=setTimeout(()=>d(S(t)),n)})])}finally{s!==void 0&&clearTimeout(s)}}async sendOnce(e,t,n,s={}){const i=this.resolveBudget(s);try{return await q(await this.transport(e,t,n,i))}catch(d){throw T(d,i.signal)}}nodePath(e){if(!y(e))throw new m(400,"invalid_node_id",`invalid node id: ${JSON.stringify(e)}`);return e}jobPath(e){if(!N(e))throw new m(400,"invalid_job_id",`invalid background job id: ${JSON.stringify(e)}`);return e}cronPath(e){if(!x(e))throw new m(400,"invalid_cron_id",`invalid cron id: ${JSON.stringify(e)}`);return e}requestPath(e){if(!y(e))throw new m(400,"invalid_request_id",`invalid request id: ${JSON.stringify(e)}`);return e}ticketId(e){if(!/^[a-f0-9]{64}$/.test(e))throw new TypeError(`invalid inbox ticket id: ${JSON.stringify(e)}`);return e}reviewPath(e){if(!y(e))throw new m(400,"invalid_review_id",`invalid review id: ${JSON.stringify(e)}`);return e}commentPath(e){if(!/^[a-f0-9]{32}$/.test(e))throw new m(400,"invalid_comment_id",`invalid comment id: ${JSON.stringify(e)}`);return e}transport(e,t,n,s={}){const i=s.deadlineAt===void 0?void 0:s.deadlineAt-Date.now();if(i!==void 0&&i<=0)return Promise.reject(S(s.deadlineAt));const d=n===void 0?void 0:JSON.stringify(n),c={accept:"application/json",...this.headers,...s.headers};d!==void 0&&(c["content-type"]="application/json");const h=s.timeout??this.timeoutMs,f=i===void 0?h:h>0?Math.min(h,i):i,l=new AbortController,P=i!==void 0&&(h<=0||i<=h),g=f>0?setTimeout(()=>l.abort(P?S(s.deadlineAt):new DOMException("request timed out","TimeoutError")),f):void 0,w=s.signal,O=a(()=>l.abort(w?.reason),"onExternalAbort");w!==void 0&&(w.aborted?l.abort(w.reason):w.addEventListener("abort",O,{once:!0}));const R=a(()=>{g!==void 0&&clearTimeout(g),w?.removeEventListener("abort",O)},"finish");return W(this.fetch(new URL(t,this.baseUrl),{method:e,headers:c,body:d,signal:l.signal}),l.signal).then(v=>this.retainRequestLifetime(v,R,()=>l.signal.aborted?l.signal.reason:void 0),v=>{throw R(),v})}retainRequestLifetime(e,t,n){if(e.body===null)return t(),e;const s=e.body.getReader();let i=!1;const d=a(()=>{i||(i=!0,t())},"close"),c=new ReadableStream({async pull(h){try{const{done:f,value:l}=await s.read();f?(d(),h.close()):h.enqueue(l)}catch(f){d(),h.error(n()??f)}},async cancel(h){d(),await s.cancel(h)}});return new Response(c,{status:e.status,statusText:e.statusText,headers:e.headers})}isColdSocketError(e){const t=b(e);return t==="ECONNREFUSED"||t==="ENOENT"||t==="ENOTSOCK"}isInterruptedSocketError(e){const t=b(e);return t==="ECONNRESET"||t==="EPIPE"}async rideOutInterruptedRequest(e,t,n,s={}){try{await this.awaitAvailability(void 0,s.deadlineAt)}catch(i){throw T(i,s.signal)}if(e!=="GET"&&e!=="HEAD")throw new m(503,"daemon_request_interrupted",`crtrd connection ended before this ${e} response; the request may or may not have been applied.`);try{return await this.transport(e,t,n,s)}catch(i){throw T(i,s.signal)}}async awaitAvailability(e,t){const n=t===void 0?void 0:t-Date.now();if(n!==void 0&&n<=0)throw S(t);let s;try{await $({windowMs:Math.min(this.coldStartPollWindowMs,n??this.coldStartPollWindowMs),initialError:e,retry:a(i=>i!==s,"retry"),probe:a(async i=>{const d=this.coldStartFailure?.();if(d!==void 0)throw s=new m(503,"daemon_unavailable",`crtrd failed to start: ${d}`),s;const c=await this.transport("GET",r.healthz(),void 0,{timeout:i});if(c.status>=200&&c.status<300){await k(c);return}const h=await c.text();try{if(typeof JSON.parse(h).startup_blocked=="string")return}catch{}throw new m(c.status,"daemon_health_unavailable",`crtrd health check returned HTTP ${c.status}: ${h.slice(0,500)}`)},"probe")})}catch(i){throw i===s&&(this.startupFailureReported=!0),i}}async handleColdSocket(e,t){const n=this.autostart&&this.onColdSocket!==void 0&&!this.coldStartAttempted;n&&(this.coldStartAttempted=!0,await this.awaitWithinBudget(this.onColdSocket(),t));try{await this.awaitAvailability(e,t)}catch(s){if(n&&!this.startupFailureReported){const i=J(this.coldStartDiagnostic);if(i!==void 0){const d=T(s);throw new m(d.status,d.code,`${d.message}
|
|
3
3
|
${i}`)}}throw s}}}function u(o,e){if(e===void 0)return o;const t=new URLSearchParams;for(const[s,i]of Object.entries(e))i!=null&&t.set(s,String(i));const n=t.toString();return n===""?o:`${o}?${n}`}a(u,"withQuery");async function q(o,e){const t=o.status>=200&&o.status<300,n=(await U(o,e)).trim();let s;if(n!=="")try{s=JSON.parse(n)}catch{if(t)return;throw new m(o.status,"invalid_response",n.slice(0,500),void 0,o.headers)}if(t)return s;throw D(s)?new m(o.status,s.error.code,s.error.message,s.error.details,o.headers,s.error):new m(o.status,"internal",`request failed with status ${o.status}`,void 0,o.headers)}a(q,"parse");function H(o){return o===429||o>=500}a(H,"isRetryableStatus");async function k(o,e){const t=(async()=>{try{await o.body?.cancel()}catch{}})();if(e===void 0)return t;let n;try{await Promise.race([t,new Promise(s=>{n=setTimeout(s,Math.max(0,e-Date.now()))})])}finally{n!==void 0&&clearTimeout(n)}}a(k,"drainResponseBody");async function U(o,e){if(e===void 0)return o.text();const t=e-Date.now(),n=o.text();if(n.catch(()=>{}),t<=0)throw o.body?.cancel().catch(()=>{}),E(e);let s;try{return await Promise.race([n,new Promise((i,d)=>{s=setTimeout(()=>{o.body?.cancel().catch(()=>{}),d(E(e))},t)})])}finally{s!==void 0&&clearTimeout(s)}}a(U,"readTextWithin");function C(o){return Math.min(2e3,250*2**(o-1))}a(C,"retryDelayMs");function b(o){if(typeof o!="object"||o===null)return;const e=o.code;if(typeof e=="string")return e;const t=o.cause;if(typeof t=="object"&&t!==null){const n=t.code;if(typeof n=="string")return n}}a(b,"transportErrorCode");function G(o,e){return e?.aborted?!0:o instanceof DOMException&&(o.name==="AbortError"||o.name==="TimeoutError")}a(G,"isAbortError");function T(o,e){if(e?.aborted)return new m(0,"request_aborted","request aborted by caller signal");if(o instanceof m)return o;if(o instanceof DOMException&&o.name==="TimeoutError")return new m(504,"request_timeout",`crtrd request timed out: ${o.message}`);if(o instanceof DOMException&&o.name==="AbortError")return new m(0,"request_aborted","request aborted by caller signal");const t=b(o),n=o instanceof Error?o.message:String(o);return t==="ECONNREFUSED"||t==="ENOENT"||t==="ENOTSOCK"?new m(503,"daemon_unavailable",`crtrd is not reachable: ${n}`):t==="ETIMEDOUT"?new m(504,"request_timeout",`crtrd request timed out: ${n}`):new m(503,"transport_error",n)}a(T,"toTransportApiError");function j(o){const e=Number(o.headers.get("retry-after"));return Number.isFinite(e)&&e>0?e:void 0}a(j,"retryAfterHeaderS");async function _(o,e,t,n){const{deadlineAt:s,signal:i}=e;if(i?.aborted)throw new m(0,"request_aborted","request aborted by caller signal");const d=s!==void 0&&t!==void 0?t*1e3:void 0,c=Math.max(o,d??0);if(s!==void 0&&Date.now()+c>=s){const h=E(s,d!==void 0&&d>=o?"retry_after":"elapsed",d===void 0?void 0:t);throw n!==void 0&&Object.defineProperty(h,"cause",{value:n,configurable:!0,writable:!0}),h}if(i===void 0)return M(c);await new Promise((h,f)=>{const l=a(()=>{clearTimeout(P),i.removeEventListener("abort",l),f(new m(0,"request_aborted","request aborted by caller signal"))},"onAbort"),P=setTimeout(()=>{i.removeEventListener("abort",l),h()},c);i.addEventListener("abort",l,{once:!0})})}a(_,"sleepWithin");function W(o,e){return new Promise((t,n)=>{const s=a(()=>n(e.reason),"onAbort");e.aborted?s():e.addEventListener("abort",s,{once:!0}),o.then(i=>{e.removeEventListener("abort",s),e.aborted?i.body?.cancel().catch(()=>{}):t(i)},i=>{e.removeEventListener("abort",s),n(i)})})}a(W,"abortable");function M(o){return new Promise(e=>setTimeout(e,o))}a(M,"sleepMs");function J(o){if(o!==void 0)try{return o()}catch{return}}a(J,"safeColdStartDiagnostic");export{Y as CrtrClient,p as MAX_TIMER_MS,E as deadlineExceeded,J as safeColdStartDiagnostic,_ as sleepWithin,$ as waitForDaemonAvailability};
|
package/dist/api/contract.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** The contract level this build serves and requires. Written by `scripts/contract.mjs release`; never edit by hand. */
|
|
2
|
-
export declare const CONTRACT_LEVEL = "1.
|
|
2
|
+
export declare const CONTRACT_LEVEL = "1.26";
|
|
3
3
|
/** Request header naming the one contract level the caller needs, e.g. `1.3`. Optional: absent means no check. */
|
|
4
4
|
export declare const REQUIRED_CONTRACT_HEADER = "Crouter-Required-Contract";
|
|
5
5
|
/** Response header listing the contract levels the server serves, comma-separated, one per major, e.g. `1.3`. */
|
package/dist/api/contract.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var c=Object.defineProperty;var e=(r,t)=>c(r,"name",{value:t,configurable:!0});const f="1.
|
|
1
|
+
var c=Object.defineProperty;var e=(r,t)=>c(r,"name",{value:t,configurable:!0});const f="1.26",i="Crouter-Required-Contract",p="Crouter-Contract";function l(r){const t=/^(\d+)\.(\d+)$/.exec(r.trim());return t===null?null:{major:Number(t[1]),minor:Number(t[2])}}e(l,"parseContractLevel");function a(r){return r==null?[]:r.split(",").map(t=>l(t)).filter(t=>t!==null)}e(a,"parseServedContracts");function s(r,t){const n=l(r);return n===null?!1:(typeof t=="string"||t===null||t===void 0?a(t):t).some(u=>u.major===n.major&&u.minor>=n.minor)}e(s,"contractSatisfies");function C(r,t,n={}){if(r===void 0)return null;if(l(r)===null)return{status:400,code:"invalid_request",param:i,message:`${i} must be a contract level like 1.0.`};if(s(r,t))return null;const o=r.trim();return{status:426,code:"runtime_version_unsupported",message:t===null||a(t).length===0?`The runtime did not name its contract level; the caller requires contract ${o} or later. Roll the runtime forward.`:`The runtime serves contract ${t}; the caller requires contract ${o} or later within the same major. Roll the runtime forward, or pin an SDK whose crouterContract the runtime serves.`,details:{sdk_version:(n.legacyMinimum??"").trim(),runtime_version:n.runtimeVersion??null,required_contract:o,runtime_contract:t}}}e(C,"contractRefusal");export{p as CONTRACT_HEADER,f as CONTRACT_LEVEL,i as REQUIRED_CONTRACT_HEADER,C as contractRefusal,s as contractSatisfies,l as parseContractLevel,a as parseServedContracts};
|
package/dist/api/dto/canvas.d.ts
CHANGED
|
@@ -257,6 +257,8 @@ export interface RosterNodeDTO {
|
|
|
257
257
|
enterable: boolean;
|
|
258
258
|
parent: NodeIdDTO | null;
|
|
259
259
|
created: IsoTime;
|
|
260
|
+
/** The node's one-line description, the label for an unnamed node. Absent from daemons older than this field. */
|
|
261
|
+
description?: string | null;
|
|
260
262
|
}
|
|
261
263
|
/** One `subscribes_to` edge in the roster's topology half. Every edge is kept
|
|
262
264
|
* (passive + multiple per node) — never collapsed to one edge per node. */
|
package/dist/api/dto/crons.d.ts
CHANGED
|
@@ -83,6 +83,8 @@ export interface CronDTO {
|
|
|
83
83
|
* boundary between profiles, not a security boundary. */
|
|
84
84
|
export interface ListCronsQuery {
|
|
85
85
|
profile?: string;
|
|
86
|
+
/** Only the crons this node armed (`CronDTO.created_by`). */
|
|
87
|
+
created_by?: string;
|
|
86
88
|
}
|
|
87
89
|
/** Caller identity for the per-cron routes (show/pause/resume/run/cancel).
|
|
88
90
|
* Same rule as `ListCronsQuery`: a cron outside the caller's scope is 404,
|
|
@@ -9,6 +9,14 @@ when-and-why-to-read: When you need Release notes, this knowledge should be read
|
|
|
9
9
|
|
|
10
10
|
Changes to `@north-light/sdk` that can change what an existing app sees. Newest first.
|
|
11
11
|
|
|
12
|
+
## 0.3.533
|
|
13
|
+
|
|
14
|
+
Three reads take optional narrowing. Additive: no request or response an existing app sends or reads changes.
|
|
15
|
+
|
|
16
|
+
- `GET /v1/canvas/roster` node rows carry an optional `description`. A runtime that predates the field omits it.
|
|
17
|
+
- `GET /v1/crons` accepts `created_by=<node id>` and returns only the crons that node armed. An empty value is 400 `invalid_request`. An older runtime ignores the parameter and returns every cron, so filter on `created_by` yourself if you may talk to one.
|
|
18
|
+
- `GET /v1/human/inbox/history` accepts `state=pending|resolved|canceled|passive` and returns only page tickets in that state. Any other value is 400 `invalid_request`. An older runtime ignores the parameter and returns every state.
|
|
19
|
+
|
|
12
20
|
## 0.3.527
|
|
13
21
|
|
|
14
22
|
`POST /v1/nodes/:id/jobs/start` accepts a job prepared as already backgrounded. Additive: no request or response an existing app sends or reads changes.
|
|
@@ -17,6 +17,8 @@ A provider is a service the person's runtime calls for your app. Your app asks t
|
|
|
17
17
|
| `context` | Ask about the person from their memory, and look up public profiles | `context:<group>` | [[northlight-apps/providers/context]] |
|
|
18
18
|
| `device` | The person's Mac: browser, files, Messages and shell | `device:<group>` | [[northlight-apps/providers/device]] |
|
|
19
19
|
|
|
20
|
+
> **Want your app to have its own number and text its users?** The `sms` provider texts only the signed-in person's own phone. For your own number, use Comms: [the Comms guide for coding agents](https://comms.northlight.ai/llms.txt), and the SDK [`@north-light/comms`](https://www.npmjs.com/package/@north-light/comms) on npm.
|
|
21
|
+
|
|
20
22
|
## Where names come from
|
|
21
23
|
|
|
22
24
|
- **Scope strings** come from the console's **What it asks for → Add permissions** list. A scope is `<provider id>:<group>`. Do not guess them.
|
|
@@ -7,6 +7,8 @@ when-and-why-to-read: When you need Texting (sms), this knowledge should be read
|
|
|
7
7
|
|
|
8
8
|
# Texting (sms)
|
|
9
9
|
|
|
10
|
+
> **Want your app to have its own number and text its users?** The `sms` provider cannot: it texts only the signed-in person's own phone. Use Comms instead: [the Comms guide for coding agents](https://comms.northlight.ai/llms.txt) covers fake mode, testers and production, and the SDK is [`@north-light/comms`](https://www.npmjs.com/package/@north-light/comms) on npm.
|
|
11
|
+
|
|
10
12
|
The `sms` provider sends a text from Northlight's number to the verified phone of the person who signed in to your app. It has no recipient argument, so an app cannot text anyone else.
|
|
11
13
|
|
|
12
14
|
## Scopes
|
|
@@ -13,11 +13,16 @@ export interface InboxStripHooks {
|
|
|
13
13
|
* so the strip's own rows hide rather than duplicate the flag. */
|
|
14
14
|
suppressed: () => boolean;
|
|
15
15
|
setNotice: (msg: string) => void;
|
|
16
|
+
/** A failed rescan. The strip keeps the rows it already shows; the viewer's
|
|
17
|
+
* chrome refresh owns how the failure is presented and retried. */
|
|
18
|
+
onRefreshFailure: (cause: unknown) => void;
|
|
16
19
|
}
|
|
17
20
|
export interface InboxStrip {
|
|
18
21
|
/** Mounted into the frame's single header container, below the recap. */
|
|
19
22
|
readonly component: Container;
|
|
20
|
-
/** Rescan the subtree's pending tickets and repaint.
|
|
23
|
+
/** Rescan the subtree's pending tickets and repaint. Never rejects: most
|
|
24
|
+
* callers fire it from inbox activity with nobody awaiting it, so a daemon
|
|
25
|
+
* failure goes to `onRefreshFailure` and the last rows stay on screen. */
|
|
21
26
|
refresh(): Promise<void>;
|
|
22
27
|
/** Strip key routing, called BEFORE the editor sees the key. */
|
|
23
28
|
handleKey(data: string): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var L=Object.defineProperty;var o=(f,c)=>L(f,"name",{value:c,configurable:!0});import{Container as F,Text as $,decodeKittyPrintable as K,matchesKey as x}from"@earendil-works/pi-tui";import{DynamicBorder as O}from"@earendil-works/pi-coding-agent";import{byNewestFirst as W,inboxRowFromDTO as R}from"../../inbox/dto-adapt.js";import{cliClient as q}from"../../../commands/api-client.js";import{fillBar as A,fillWidth as B,navLabel as H,stripSgr as P,truncate as j,REVERSE as V,YELLOW as X,RESET as Y}from"../../../core/canvas/nav-render.js";const y=3;function z(f){return f.kind==="page"?f.emittedAt:f.blockedSince}o(z,"ticketTime");function G(f){const c=Date.now()-Date.parse(f);if(!Number.isFinite(c)||c<0)return"now";const u=Math.floor(c/6e4);if(u<1)return"now";if(u<60)return`${u}m`;const p=Math.floor(u/60);return p<24?`${p}h`:`${Math.floor(p/24)}d`}o(G,"ageLabel");function ie(f,c){const{nodeId:u,remote:p,canvasSource:M,tui:k,pal:I}=f,h=new F;let i=[],b=new Map,r,l=0;const S=o(e=>{const t=e.source.nodeId,d=t!==void 0&&t!==u?` \xB7 ${H(b.get(t)??null,t)}`:"";return j(` ${X}\u2691${Y} ${e.title}${I.faint(` \xB7 ${G(z(e))}${d}`)}`)},"rowLine"),w=o(()=>{if(c.syncCursor(),h.clear(),i.length>0&&!c.suppressed()){const e=r===void 0?-1:i.findIndex(d=>d.dir===r);e>=0&&(l=Math.min(Math.max(l,e-y+1),e)),l=Math.max(0,Math.min(l,Math.max(0,i.length-y)));for(const d of i.slice(l,l+y)){const a=S(d);h.addChild(new $(d.dir===r?A(P(a),B(),V):a,1,0))}const t=i.length-Math.min(y,i.length-l);t>0&&h.addChild(new $(I.faint(` +${t} more`),1,0)),h.addChild(new O(I.border))}k.requestRender()},"paint"),C=o(async()=>{const e=await M.panelRoster?.(),t=e===void 0?await M.listNodes():e.nodes.map(n=>({node_id:n.node_id,name:n.name,kind:n.kind,status:n.status,...n.description?{description:n.description}:{}})),d=new Map(t.map(n=>[n.node_id,n])),a=new Map,m=o(async n=>{if(a.has(n))return;const s=d.get(n)??null;if(n!==u&&s?.kind==="human")return;a.set(n,s);const v=await M.subscriptionsOf(n).catch(()=>[]);for(const D of v)await m(D.node_id)},"visit");return await m(u),a},"subtreeNodes"),E=o(async()=>{try{await N()}catch(e){c.onRefreshFailure(e)}},"refresh"),N=o(async()=>{if(p)return;const e=await C(),t=q(),[d,a]=await Promise.all([t.listHumanInbox(),t.getInboxHistory(void 0,{state:"pending"})]);b=e;const m=new Map;for(const n of d.tickets){const s=R(n);m.set(s.dir,s)}for(const n of a.tickets){const s=R(n);s.kind==="page"&&(s.source.nodeId===void 0||!b.has(s.source.nodeId)||s.state!=="pending"||!s.awaitsResponse||s.inbox||m.has(s.dir)||m.set(s.dir,s))}i=[...m.values()].filter(n=>n.source.nodeId!==void 0&&b.has(n.source.nodeId)).sort(W),r!==void 0&&!i.some(n=>n.dir===r)&&(r=void 0),w()},"rescan"),g=o(()=>{r!==void 0&&(r=void 0,w())},"exit"),T=o(()=>{if(!p){if(r!==void 0){g();return}if(i.length===0){c.setNotice("No pending human requests in this subtree");return}c.exitRoster(),r=i[0].dir,l=0,w()}},"toggle"),_=o(()=>{const e=i.find(t=>t.dir===r);e!==void 0&&(g(),c.openTicket(e))},"openSelected");return{component:h,refresh:E,handleKey:o(e=>{if(r===void 0)return!1;const t=i.findIndex(a=>a.dir===r),d=K(e)??(e.length===1?e:void 0);return x(e,"up")||d==="k"?(t>0&&(r=i[t-1].dir,w()),!0):x(e,"down")||d==="j"?(t>=0&&t<i.length-1?(r=i[t+1].dir,w()):g(),!0):x(e,"enter")?(_(),!0):x(e,"escape")?(g(),!0):(g(),!1)},"handleKey"),toggle:T,active:o(()=>r!==void 0,"active"),pendingTickets:o(()=>[...i],"pendingTickets")}}o(ie,"createInboxStrip");export{ie as createInboxStrip};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var q=Object.defineProperty;var o=(m,n)=>q(m,"name",{value:n,configurable:!0});import{execFile as _}from"node:child_process";import{Text as O,decodeKittyPrintable as k,matchesKey as R}from"@earendil-works/pi-tui";import{cliClient as w}from"../../../commands/api-client.js";import{focusNode as D}from"../../../core/runtime/focus-viewer.js";import{daemonErrorMessage as H}from"../../inbox/resolve.js";import{activeBackgroundBashJobs as j}from"../../../core/bash-jobs.js";import{contextDir as U}from"../../../core/canvas/paths.js";import{fillBar as J,fillWidth as X,stripSgr as F,REVERSE as L}from"../../../core/canvas/nav-render.js";import{buildCanvasPanelLines as V}from"./canvas-panels.js";const W=15e3;function se(m,n){const{editor:x,tui:S,pal:E,nodeId:f,remote:a,role:C,canvasSource:K}=m,N=o(()=>U(f,m.meta.grantee),"nodeContextDir"),I=m.containers.reports;let c=[],r,g=process.env.CRTR_ATTACH_ROSTER;g!==void 0&&delete process.env.CRTR_ATTACH_ROSTER;let l,v;const b=o(()=>{n.syncCursor(),I.clear();for(const e of c){const t=e.key===r;I.addChild(new O(t?J(F(e.line),X(),L):e.line,1,0))}S.requestRender()},"paint"),$=o(async()=>{const e=a?[]:(await w().listCrons()).filter(i=>i.created_by===f),t=a?[]:j(N()),d=a?[]:(await w().listReviews({state:"open",origin_node_id:f})).reviews;if(c=(await V(f,n.asks(),E,K,e,t,d)).items,g!==void 0){const i=g;g=void 0;const p=c.find(h=>h.kind==="node"&&h.nodeId===i);p!==void 0&&(r=p.key)}r!==void 0&&!c.some(i=>i.key===r)&&(r=void 0),l!==void 0&&!t.some(i=>i.jobId===l?.jobId)&&y(!0),b()},"refresh"),y=o(e=>{v!==void 0&&(clearTimeout(v),v=void 0),l!==void 0&&(l=void 0,e&&n.setNotice(""))},"disarmKill"),u=o(()=>{y(!0),r!==void 0&&(r=void 0,b())},"exit"),T=o(e=>k(e)??(e.length===1?e:void 0),"typed"),A=o((e,t=40)=>{const d=(e.split(`
|
|
1
|
+
var q=Object.defineProperty;var o=(m,n)=>q(m,"name",{value:n,configurable:!0});import{execFile as _}from"node:child_process";import{Text as O,decodeKittyPrintable as k,matchesKey as R}from"@earendil-works/pi-tui";import{cliClient as w}from"../../../commands/api-client.js";import{focusNode as D}from"../../../core/runtime/focus-viewer.js";import{daemonErrorMessage as H}from"../../inbox/resolve.js";import{activeBackgroundBashJobs as j}from"../../../core/bash-jobs.js";import{contextDir as U}from"../../../core/canvas/paths.js";import{fillBar as J,fillWidth as X,stripSgr as F,REVERSE as L}from"../../../core/canvas/nav-render.js";import{buildCanvasPanelLines as V}from"./canvas-panels.js";const W=15e3;function se(m,n){const{editor:x,tui:S,pal:E,nodeId:f,remote:a,role:C,canvasSource:K}=m,N=o(()=>U(f,m.meta.grantee),"nodeContextDir"),I=m.containers.reports;let c=[],r,g=process.env.CRTR_ATTACH_ROSTER;g!==void 0&&delete process.env.CRTR_ATTACH_ROSTER;let l,v;const b=o(()=>{n.syncCursor(),I.clear();for(const e of c){const t=e.key===r;I.addChild(new O(t?J(F(e.line),X(),L):e.line,1,0))}S.requestRender()},"paint"),$=o(async()=>{const e=a?[]:(await w().listCrons({created_by:f})).filter(i=>i.created_by===f),t=a?[]:j(N()),d=a?[]:(await w().listReviews({state:"open",origin_node_id:f})).reviews;if(c=(await V(f,n.asks(),E,K,e,t,d)).items,g!==void 0){const i=g;g=void 0;const p=c.find(h=>h.kind==="node"&&h.nodeId===i);p!==void 0&&(r=p.key)}r!==void 0&&!c.some(i=>i.key===r)&&(r=void 0),l!==void 0&&!t.some(i=>i.jobId===l?.jobId)&&y(!0),b()},"refresh"),y=o(e=>{v!==void 0&&(clearTimeout(v),v=void 0),l!==void 0&&(l=void 0,e&&n.setNotice(""))},"disarmKill"),u=o(()=>{y(!0),r!==void 0&&(r=void 0,b())},"exit"),T=o(e=>k(e)??(e.length===1?e:void 0),"typed"),A=o((e,t=40)=>{const d=(e.split(`
|
|
2
2
|
`)[0]??"").replace(/\s+/g," ").trim();return d.length>t?`${d.slice(0,t-1)}\u2026`:d},"commandHead"),B=o(()=>{if(C!=="controller"){n.setNotice("Read-only observer attach \u2014 cannot stop background jobs");return}const e=j(N());if(e.length===0){n.setNotice("Background job already finished"),n.requestChromeRefresh();return}if(e.length>1){n.setNotice(`${e.length} background jobs \u2014 press \u21B5 to pick one in the Inspector`);return}const t=e[0];l={jobId:t.jobId,label:A(t.command)},n.setNotice(`Stop \u201C${l.label}\u201D? Press y to confirm.`,{sticky:!0}),v=setTimeout(()=>y(!0),W)},"armKill"),M=o(()=>{const e=l;e!==void 0&&(y(!1),n.setNotice(`Stopping \u201C${e.label}\u201D\u2026`),_("crtr",["node","bash","kill",e.jobId,"--node",f],t=>{n.setNotice(t===null?`Stopped \u201C${e.label}\u201D.`:`Could not stop the job: ${t.message.split(`
|
|
3
3
|
`)[0]}`),n.requestChromeRefresh()}))},"confirmKill");x.onCursorDownAtBottom=a?void 0:()=>{r!==void 0||c.length===0||(r=c[0].key,b())};const P=o(()=>{const e=c.find(s=>s.key===r);if(e===void 0||a)return;if(e.kind==="crons"){u(),n.openInspector("schedule");return}if(e.kind==="review"){if(C!=="controller"){n.setNotice("Read-only observer attach \u2014 cannot open the review companion");return}u();const s=process.env.TMUX_PANE;if(s===void 0||s===""){n.setNotice("Could not open the companion: no tmux pane");return}(async()=>{const i=w(),p=await i.getNode(e.companionNodeId);(await D(i,p,{pane:s})).focused||n.setNotice("Could not open the companion")})().catch(i=>n.setNotice(`Could not open the companion: ${H(i).split(`
|
|
4
4
|
`)[0]}`));return}if(e.kind==="bash"){if(j(N()).length===0){n.setNotice("Background job already finished"),n.requestChromeRefresh();return}u(),n.openInspector("jobs");return}if(e.kind==="object-wait"){u(),n.openObject(e.objectId);return}const t=e.nodeId;if(t===f){u();return}if(C!=="controller"){n.setNotice("Read-only observer attach \u2014 cannot focus nodes");return}const d=process.env.TMUX_PANE;if(d===void 0||d===""){n.setNotice("cannot swap \u2014 no tmux pane");return}_("tmux",["run-shell","-b",`crtr surface node focus ${t} --pane ${d} --in-place >/dev/null 2>&1`],()=>{})},"openSelected");return{refresh:$,handleKey:o(e=>{if(a)return!1;const t=R(e,"down"),d=R(e,"up");if(r===void 0)return!1;const s=c.findIndex(p=>p.key===r),i=c[s];if(l!==void 0){if(T(e)==="y")return M(),!0;y(!0)}return i?.kind==="bash"&&T(e)==="x"?(B(),!0):d?(s<=0?u():(r=c[s-1].key,b()),!0):t?(s>=0&&s<c.length-1&&(r=c[s+1].key,b()),!0):R(e,"enter")?(P(),!0):R(e,"escape")?(u(),!0):(u(),!1)},"handleKey"),active:o(()=>r!==void 0,"active"),exit:u}}o(se,"createRoster");export{se as createRoster};
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type { AttachSession } from './context.js';
|
|
2
|
+
/** The sticky status-line text while crtrd is not answering chrome reads. */
|
|
3
|
+
export declare const DAEMON_STALLED_NOTICE = "crtrd not responding \u2014 retrying";
|
|
4
|
+
/** A failure that says crtrd is slow, restarting or gone — not that the request
|
|
5
|
+
* was wrong. The viewer keeps its last chrome and retries; it never exits. */
|
|
6
|
+
export declare function isTransientDaemonFailure(error: unknown): boolean;
|
|
2
7
|
export interface ChromeRefreshHooks {
|
|
3
8
|
/** True once teardown has begun — stops both the loop and a re-arm. */
|
|
4
9
|
isTornDown: () => boolean;
|
|
5
10
|
/** The viewer's transient notice slot — the ONLY failure channel here. */
|
|
6
|
-
setNotice: (msg: string
|
|
11
|
+
setNotice: (msg: string, opts?: {
|
|
12
|
+
sticky?: boolean;
|
|
13
|
+
}) => void;
|
|
7
14
|
/** Repaint the relationship roster (chrome/roster.ts refresh). */
|
|
8
15
|
refreshRoster: () => Promise<void>;
|
|
9
16
|
/** Repaint the graph overlay if open. */
|
|
@@ -32,9 +39,11 @@ export interface ChromeRefresh {
|
|
|
32
39
|
* failure (e.g. a stale viewer generation talking to a newer crtrd) is
|
|
33
40
|
* diagnosable from the pane. */
|
|
34
41
|
reportFailure: (label: string, cause?: unknown) => void;
|
|
35
|
-
/**
|
|
42
|
+
/** True while crtrd is failing chrome reads with a transient error. */
|
|
43
|
+
daemonStalled: () => boolean;
|
|
44
|
+
/** Run the initial poll and arm the poll timer. Call once, after `tui.start()`. */
|
|
36
45
|
start: () => void;
|
|
37
|
-
/** Clear the
|
|
46
|
+
/** Clear the poll timer. Called from teardown's `stopLocal`. */
|
|
38
47
|
stop: () => void;
|
|
39
48
|
}
|
|
40
49
|
export declare function createChromeRefresh(ctx: Pick<AttachSession, 'nodeId' | 'canvasSource'>, hooks: ChromeRefreshHooks): ChromeRefresh;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var M=Object.defineProperty;var r=(s,e)=>M(s,"name",{value:e,configurable:!0});import{APIError as N,isDaemonTransportApiError as O}from"../../../api/errors.js";const u=5e3,v=6e4,I="crtrd not responding \u2014 retrying";function L(s){return O(s)||s instanceof N&&s.status>=500}r(L,"isTransientDaemonFailure");function C(s,e){const{nodeId:w,canvasSource:g}=s;let m={},a,p=!1,i=0,h=0;const _=r(()=>{i===0&&e.setNotice(I,{sticky:!0}),i=Math.min(i+1,16)},"markStalled"),D=r(()=>{i!==0&&(i=0,e.setNotice("crtrd responding again"),E(u))},"markHealthy"),c=r((t,n)=>{if(h++,L(n)){_();return}const o=(n instanceof Error?n.message:n===void 0?"":String(n)).replace(/\s+/g," ").trim().slice(0,120);e.setNotice(o===""?`${t} delayed`:`${t} delayed \u2014 ${o}`)},"reportFailure");let y=!1,f=!1;const l=r(()=>{f=!0,!y&&(y=!0,(async()=>{try{for(;f&&!e.isTornDown();){f=!1;const t=h;try{await e.refreshRoster(),h===t&&D()}catch(n){c("canvas panel refresh",n)}e.refreshGraph()}}finally{y=!1,f&&!e.isTornDown()&&l()}})().catch(t=>c("canvas chrome refresh",t)))},"refresh"),F=r(async t=>{let n=t;const o=new Set([n]);for(;;){const d=(await g.subscribersOf(n).catch(()=>[]))[0]?.node_id;if(d===void 0||o.has(d))break;o.add(d),n=d}return n},"climbRootFromSource"),T=r(()=>{l(),e.refreshIdentity(),e.renderExtensionWidgets(),e.pollGit(),e.refreshInFlightTools(),e.renderFooter(),(async()=>{const t=await F(w),n=await g.ticketCountsForView(t);JSON.stringify(n)!==JSON.stringify(m)&&(m=n,l(),e.renderFooter())})().catch(t=>c("canvas attention refresh",t))},"pollChrome"),A=r(()=>i===0?u:Math.min(u*2**i,v),"nextDelay");function E(t){p||a===void 0||(clearTimeout(a),S(t))}r(E,"rearm");function S(t){a=setTimeout(()=>{p||e.isTornDown()||(T(),S(A()))},t),typeof a.unref=="function"&&a.unref()}return r(S,"schedule"),{refresh:l,asks:r(()=>m,"asks"),reportFailure:c,daemonStalled:r(()=>i>0,"daemonStalled"),start:r(()=>{T(),S(u)},"start"),stop:r(()=>{p=!0,a!==void 0&&clearTimeout(a)},"stop")}}r(C,"createChromeRefresh");export{I as DAEMON_STALLED_NOTICE,C as createChromeRefresh,L as isTransientDaemonFailure};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var h=Object.defineProperty;var o=(e,t)=>h(e,"name",{value:t,configurable:!0});import{noteDocLinksChanged as a,setDocLinkContext as l}from"../render/doc-links.js";function L(e){const t=new Map;let r=!1,s=!1,d;e.remote||e.fetchSecret().then(n=>{d=n,a(),s||e.refresh()},e.onSecretError);const u=o(()=>{if(r)return;r=!0;const n=e.canvasSource;(n.panelRoster?n.panelRoster().then(c=>c.nodes):n.listNodes()).then(c=>{for(const f of c)t.set(f.node_id,f.name);a(),s||e.refresh()},()=>{r=!1})},"loadRoster"),m={selfNodeId:e.selfNodeId,nodeName:o(n=>{const i=t.get(n);return i===void 0&&u(),i},"nodeName"),urlFor:o(n=>e.remote||d===void 0?void 0:`http://127.0.0.1:${e.port}/r/${n.split("/").map(encodeURIComponent).join("/")}?t=${d}`,"urlFor")};return l(m),{dispose(){s=!0,l(void 0)}}}o(L,"createDocumentLinks");export{L as createDocumentLinks};
|