unfazed 0.2.0 → 0.4.0

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.
@@ -144,3 +144,45 @@ export declare const ListAppEnvDocument: import("./index.js").TypedDocumentStrin
144
144
  workspaceID: string | number;
145
145
  alias: string;
146
146
  }>;
147
+ /** Run fields the SDK returns everywhere. */
148
+ export declare const RunFieldsFragment: import("./index.js").TypedDocumentString<import("./index.js").RunFieldsFragment, unknown>;
149
+ export declare const CreateRunDocument: import("./index.js").TypedDocumentString<import("./index.js").SdkCreateRunMutation, {
150
+ input: import("./index.js").CreateRunInput;
151
+ }>;
152
+ export declare const GetRunDocument: import("./index.js").TypedDocumentString<import("./index.js").SdkGetRunQuery, {
153
+ id: string | number;
154
+ }>;
155
+ /**
156
+ * The poll document, deliberately narrow — see {@link PollDeploymentDocument}
157
+ * for why: this runs every few seconds for potentially up to an hour.
158
+ */
159
+ export declare const PollRunDocument: import("./index.js").TypedDocumentString<import("./index.js").SdkPollRunQuery, {
160
+ id: string | number;
161
+ }>;
162
+ export declare const ListRunsDocument: import("./index.js").TypedDocumentString<import("./index.js").SdkListRunsQuery, {
163
+ input?: import("./index.js").ListRunsInput | null | undefined;
164
+ }>;
165
+ export declare const CancelRunDocument: import("./index.js").TypedDocumentString<import("./index.js").SdkCancelRunMutation, {
166
+ id: string | number;
167
+ }>;
168
+ export declare const RunEventsDocument: import("./index.js").TypedDocumentString<import("./index.js").SdkRunEventsQuery, {
169
+ runID: string | number;
170
+ limit?: number | null | undefined | undefined;
171
+ }>;
172
+ /** The live console tail of a RUNNING run. Empty with `running: false` once settled. */
173
+ export declare const RunConsoleDocument: import("./index.js").TypedDocumentString<import("./index.js").SdkRunConsoleQuery, {
174
+ id: string | number;
175
+ tailBytes?: number | null | undefined | undefined;
176
+ }>;
177
+ /** The bounded end of a finished run's stored transcript. */
178
+ export declare const RunTranscriptDocument: import("./index.js").TypedDocumentString<import("./index.js").SdkRunTranscriptQuery, {
179
+ id: string | number;
180
+ tailBytes?: number | null | undefined | undefined;
181
+ }>;
182
+ export declare const AnswerRunDocument: import("./index.js").TypedDocumentString<import("./index.js").SdkAnswerRunMutation, {
183
+ id: string | number;
184
+ answer: string;
185
+ }>;
186
+ export declare const FollowUpRunDocument: import("./index.js").TypedDocumentString<import("./index.js").SdkFollowUpRunMutation, {
187
+ input: import("./index.js").FollowUpRunInput;
188
+ }>;
@@ -467,4 +467,159 @@ export const ListAppEnvDocument = graphql(`
467
467
  }
468
468
  }
469
469
  `);
470
+ /* -------------------------------------------------------------------------
471
+ * Agent runs
472
+ *
473
+ * A run is the past-tense counterpart to a deployment: "boot a fresh VM,
474
+ * hand it a prompt, let a harness work, keep the transcript, record what it
475
+ * cost, reap the VM". `createRun` returns once the VM has started
476
+ * (RUNNING) or FAILED with `error` when it could not boot — unlike
477
+ * `createDeployment`, a FAILED run is a normal return value, not something
478
+ * that only shows up later in a poll.
479
+ * ---------------------------------------------------------------------- */
480
+ /** Run fields the SDK returns everywhere. */
481
+ export const RunFieldsFragment = graphql(`
482
+ fragment RunFields on Run {
483
+ id
484
+ workspaceID
485
+ ownerId
486
+ status
487
+ rawStatus
488
+ command
489
+ harness
490
+ prompt
491
+ setup
492
+ skills
493
+ verify
494
+ approval
495
+ mode
496
+ parentRunID
497
+ depth
498
+ question {
499
+ id
500
+ text
501
+ options
502
+ askedAt
503
+ }
504
+ memoryMiB
505
+ maxSeconds
506
+ metadata
507
+ error
508
+ exitCode
509
+ result {
510
+ status
511
+ detail
512
+ text
513
+ }
514
+ verifyExitCode
515
+ vmID
516
+ transcriptAvailable
517
+ usage {
518
+ vmSeconds
519
+ memoryMiB
520
+ mibSeconds
521
+ }
522
+ createdAt
523
+ startedAt
524
+ settledAt
525
+ }
526
+ `);
527
+ export const CreateRunDocument = graphql(`
528
+ mutation SdkCreateRun($input: CreateRunInput!) {
529
+ createRun(input: $input) {
530
+ ...RunFields
531
+ }
532
+ }
533
+ `);
534
+ export const GetRunDocument = graphql(`
535
+ query SdkGetRun($id: ID!) {
536
+ run(id: $id) {
537
+ ...RunFields
538
+ }
539
+ }
540
+ `);
541
+ /**
542
+ * The poll document, deliberately narrow — see {@link PollDeploymentDocument}
543
+ * for why: this runs every few seconds for potentially up to an hour.
544
+ */
545
+ export const PollRunDocument = graphql(`
546
+ query SdkPollRun($id: ID!) {
547
+ run(id: $id) {
548
+ id
549
+ status
550
+ error
551
+ exitCode
552
+ }
553
+ }
554
+ `);
555
+ export const ListRunsDocument = graphql(`
556
+ query SdkListRuns($input: ListRunsInput) {
557
+ runs(input: $input) {
558
+ items {
559
+ ...RunFields
560
+ }
561
+ total
562
+ limit
563
+ offset
564
+ hasMore
565
+ nextOffset
566
+ }
567
+ }
568
+ `);
569
+ export const CancelRunDocument = graphql(`
570
+ mutation SdkCancelRun($id: ID!) {
571
+ cancelRun(id: $id) {
572
+ ...RunFields
573
+ }
574
+ }
575
+ `);
576
+ export const RunEventsDocument = graphql(`
577
+ query SdkRunEvents($runID: ID!, $limit: Int) {
578
+ runEvents(runID: $runID, limit: $limit) {
579
+ id
580
+ runID
581
+ type
582
+ severity
583
+ message
584
+ metadata
585
+ createdAt
586
+ }
587
+ }
588
+ `);
589
+ /** The live console tail of a RUNNING run. Empty with `running: false` once settled. */
590
+ export const RunConsoleDocument = graphql(`
591
+ query SdkRunConsole($id: ID!, $tailBytes: Int) {
592
+ runConsole(id: $id, tailBytes: $tailBytes) {
593
+ runID
594
+ running
595
+ text
596
+ }
597
+ }
598
+ `);
599
+ /** The bounded end of a finished run's stored transcript. */
600
+ export const RunTranscriptDocument = graphql(`
601
+ query SdkRunTranscript($id: ID!, $tailBytes: Int) {
602
+ runTranscript(id: $id, tailBytes: $tailBytes) {
603
+ runID
604
+ available
605
+ text
606
+ totalBytes
607
+ truncated
608
+ }
609
+ }
610
+ `);
611
+ export const AnswerRunDocument = graphql(`
612
+ mutation SdkAnswerRun($id: ID!, $answer: String!) {
613
+ answerRun(id: $id, answer: $answer) {
614
+ ...RunFields
615
+ }
616
+ }
617
+ `);
618
+ export const FollowUpRunDocument = graphql(`
619
+ mutation SdkFollowUpRun($input: FollowUpRunInput!) {
620
+ followUpRun(input: $input) {
621
+ ...RunFields
622
+ }
623
+ }
624
+ `);
470
625
  //# sourceMappingURL=operations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"operations.js","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;CA0B/C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;CAyBrC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,CAAC;;;;;;;;;;;;;CAa9C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAC;;;;;;;;;;;CAW7C,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,CAAC;;;;;;CAM9C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;;;;;;;;;;;;CAY5C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,CAAC;;;;;;;;;;;;;;CAc9C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC;;;;;;;;;;;;;;;;;CAiBxC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC;;;;;;;;;;;;;;;;;;CAkBvC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CAAC;;;;;;CAMzC,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AAO,CAAC;;;;;;;;;;;;;;CAc9C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAAC;;;;;;;;;;;;;;CAcjD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAAC;;;;;;CAMjD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAAG,OAAO,CAAC;;;;;;;;;;;;CAY/C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC;;;;;;;;;;;;;;CAcxC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;;;;;;;;;;;;;;CAc3C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,OAAO,CAAC;;;;;;CAM3C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;;;;;;CAM5C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CAAC;;;;;;;;;;;;CAYzC,CAAC,CAAC","sourcesContent":["/**\n * Every GraphQL document the workflow layer sends.\n *\n * These are wrapped in `graphql(...)` so graphql-codegen validates them\n * against the vendored schema at codegen time and emits exact result/variable\n * types. A field that stops existing server-side turns into a compile error\n * here rather than a runtime surprise in an agent's script.\n *\n * The one document NOT defined here is the batched file write: it has a\n * variable number of aliased root fields, so it is assembled at runtime in\n * `unfazed.ts`. See the comment there.\n */\nimport { graphql } from \"./generated/gql.js\";\n\n/**\n * Deployment fields the SDK returns everywhere.\n *\n * `id` + `aliasRevision` + `aliasHeld` are the rollback compare-and-swap\n * triple; `previewUrl` is the immutable by-id URL you can verify BEFORE the\n * alias moves; `error` carries the build failure text when status is FAILED.\n */\nexport const DeploymentFieldsFragment = graphql(`\n fragment DeploymentFields on Deployment {\n id\n workspaceID\n kind\n runtime\n alias\n serviceMode\n healthPath\n cronSchedule\n cronPath\n url\n previewUrl\n sshCommand\n aliasHeld\n aliasRevision\n status\n error\n filesCount\n sizeBytes\n size\n spaMode\n gitRepo\n gitCommit\n createdAt\n }\n`);\n\nexport const WhoamiDocument = graphql(`\n query SdkWhoami {\n whoami {\n kind\n userID\n name\n agentID\n agentName\n claimed\n claimedBy\n scopes\n expiresAt\n usage {\n month\n requests\n limit\n }\n resources {\n workspaces\n workspaceLimit\n services\n serviceLimit\n }\n }\n }\n`);\n\nexport const CreateWorkspaceDocument = graphql(`\n mutation SdkCreateWorkspace($name: String!) {\n createWorkspace(input: { name: $name }) {\n workspace {\n id\n name\n ownerId\n projectId\n createdAt\n updatedAt\n }\n }\n }\n`);\n\nexport const ListWorkspacesDocument = graphql(`\n query SdkListWorkspaces {\n workspaces {\n id\n name\n ownerId\n projectId\n createdAt\n updatedAt\n }\n }\n`);\n\n/**\n * Deleting a workspace, with the deployment cascade made explicit.\n *\n * `withDeployments` is not decoration: without it the server REFUSES while the\n * workspace has any deployment history at all — including FAILED records —\n * with `workspace %q still has deployments; delete them first`. A workspace\n * that was ever deployed is therefore undeletable through the bare mutation,\n * so the SDK always sends the flag and lets the caller choose the value.\n */\nexport const DeleteWorkspaceDocument = graphql(`\n mutation SdkDeleteWorkspace($workspaceID: ID!, $withDeployments: Boolean) {\n deleteWorkspace(input: { workspaceID: $workspaceID, withDeployments: $withDeployments }) {\n ok\n }\n }\n`);\n\nexport const WriteTextFileDocument = graphql(`\n mutation SdkWriteTextFile($workspaceID: ID!, $path: String!, $text: String!) {\n writeWorkspaceTextFile(input: { workspaceID: $workspaceID, path: $path, text: $text }) {\n file {\n path\n sizeBytes\n size\n sha256\n updatedAt\n }\n }\n }\n`);\n\nexport const WriteBase64FileDocument = graphql(`\n mutation SdkWriteBase64File($workspaceID: ID!, $path: String!, $contentBase64: String!) {\n writeWorkspaceBase64File(\n input: { workspaceID: $workspaceID, path: $path, contentBase64: $contentBase64 }\n ) {\n file {\n path\n sizeBytes\n size\n sha256\n updatedAt\n }\n }\n }\n`);\n\nexport const ListFilesDocument = graphql(`\n query SdkListFiles($input: ListWorkspaceFilesInput!) {\n workspaceFilesPage(input: $input) {\n items {\n path\n sizeBytes\n size\n sha256\n updatedAt\n }\n total\n limit\n offset\n hasMore\n nextOffset\n }\n }\n`);\n\nexport const ReadFileDocument = graphql(`\n query SdkReadFile($input: ReadWorkspaceFileInput!) {\n readWorkspaceFile(input: $input) {\n text\n offset\n limit\n totalBytes\n truncated\n nextOffset\n file {\n path\n sizeBytes\n size\n sha256\n updatedAt\n }\n }\n }\n`);\n\nexport const DeleteFileDocument = graphql(`\n mutation SdkDeleteFile($workspaceID: ID!, $path: String!) {\n deleteWorkspaceFile(input: { workspaceID: $workspaceID, path: $path }) {\n ok\n }\n }\n`);\n\nexport const CreateDeploymentDocument = graphql(`\n mutation SdkCreateDeployment($input: CreateDeploymentInput!) {\n createDeployment(input: $input) {\n deployment {\n ...DeploymentFields\n }\n }\n }\n`);\n\nexport const DeployWorkspaceDocument = graphql(`\n mutation SdkDeployWorkspace($input: DeployWorkspaceInput!) {\n deployWorkspace(input: $input) {\n deployment {\n ...DeploymentFields\n }\n }\n }\n`);\n\nexport const GetDeploymentDocument = graphql(`\n query SdkGetDeployment($id: ID!) {\n deployment(id: $id) {\n ...DeploymentFields\n }\n }\n`);\n\n/**\n * The poll document, deliberately narrow.\n *\n * Waiting can run for minutes at a few seconds per tick; selecting the full\n * fragment every time would cost the server (and an agent's rate limit) far\n * more than the four fields the state machine actually reads.\n */\nexport const PollDeploymentDocument = graphql(`\n query SdkPollDeployment($id: ID!) {\n deployment(id: $id) {\n id\n status\n error\n aliasHeld\n url\n previewUrl\n }\n }\n`);\n\nexport const GetDeploymentByAliasDocument = graphql(`\n query SdkGetDeploymentByAlias($alias: String!) {\n deploymentByAlias(alias: $alias) {\n ...DeploymentFields\n }\n }\n`);\n\nexport const ListDeploymentsDocument = graphql(`\n query SdkListDeployments($input: ListDeploymentsInput) {\n deploymentsPage(input: $input) {\n items {\n ...DeploymentFields\n }\n total\n limit\n offset\n hasMore\n nextOffset\n }\n }\n`);\n\nexport const ListReleasesDocument = graphql(`\n query SdkListReleases($alias: String!) {\n deploymentReleases(alias: $alias) {\n ...DeploymentFields\n }\n }\n`);\n\nexport const RollbackDocument = graphql(`\n mutation SdkRollback(\n $deploymentID: ID!\n $expectedCurrentDeploymentID: ID!\n $expectedCurrentAliasRevision: String!\n ) {\n rollbackDeployment(\n input: {\n deploymentID: $deploymentID\n expectedCurrentDeploymentID: $expectedCurrentDeploymentID\n expectedCurrentAliasRevision: $expectedCurrentAliasRevision\n }\n ) {\n ...DeploymentFields\n }\n }\n`);\n\nexport const ServiceStatusDocument = graphql(`\n query SdkServiceStatus($deploymentID: ID!) {\n serviceStatus(deploymentID: $deploymentID) {\n deploymentID\n alias\n serviceMode\n running\n health\n vmID\n inFlight\n alwaysOn\n memSizeMiB\n startedAt\n lastUsedAt\n lastStoppedAt\n restartCount\n lastError\n }\n }\n`);\n\nexport const ServiceLogsDocument = graphql(`\n query SdkServiceLogs($deploymentID: ID!, $tailBytes: Int) {\n serviceLogs(deploymentID: $deploymentID, tailBytes: $tailBytes) {\n deploymentID\n stdout\n stderr\n truncated\n stdoutBytes\n stderrBytes\n tailBytes\n }\n }\n`);\n\nexport const DeploymentEventsDocument = graphql(`\n query SdkDeploymentEvents($deploymentID: ID!, $limit: Int) {\n deploymentEvents(deploymentID: $deploymentID, limit: $limit) {\n id\n deploymentID\n type\n rawType\n severity\n message\n vmID\n createdAt\n }\n }\n`);\n\nexport const RestartServiceDocument = graphql(`\n mutation SdkRestartService($deploymentID: ID!) {\n restartService(input: { deploymentID: $deploymentID }) {\n deploymentID\n running\n health\n vmID\n restartCount\n lastError\n }\n }\n`);\n\nexport const StopServiceDocument = graphql(`\n mutation SdkStopService($deploymentID: ID!) {\n stopService(input: { deploymentID: $deploymentID }) {\n deploymentID\n running\n health\n vmID\n restartCount\n lastError\n }\n }\n`);\n\nexport const DeleteDeploymentDocument = graphql(`\n mutation SdkDeleteDeployment($deploymentID: ID!) {\n deleteDeployment(input: { deploymentID: $deploymentID }) {\n ok\n }\n }\n`);\n\n/* -------------------------------------------------------------------------\n * Env & secrets\n *\n * Workspace-scoped values are SERVICE defaults for every app in the source;\n * app-scoped values override them for one alias. Both are snapshotted into a\n * release at deploy time, so a change only reaches a running app after a\n * redeploy — the workflow layer's doc comments repeat this where it matters.\n * ---------------------------------------------------------------------- */\n\nexport const SetWorkspaceEnvDocument = graphql(`\n mutation SdkSetWorkspaceEnv($workspaceID: ID!, $name: String!, $value: String!) {\n setWorkspaceEnv(input: { workspaceID: $workspaceID, name: $name, value: $value }) {\n env {\n name\n value\n secret\n alias\n inherited\n masked\n updatedAt\n }\n }\n }\n`);\n\nexport const SetWorkspaceSecretDocument = graphql(`\n mutation SdkSetWorkspaceSecret($workspaceID: ID!, $name: String!, $value: String!) {\n setWorkspaceSecret(input: { workspaceID: $workspaceID, name: $name, value: $value }) {\n env {\n name\n value\n secret\n alias\n inherited\n masked\n updatedAt\n }\n }\n }\n`);\n\nexport const DeleteWorkspaceEnvDocument = graphql(`\n mutation SdkDeleteWorkspaceEnv($workspaceID: ID!, $name: String!) {\n deleteWorkspaceEnv(input: { workspaceID: $workspaceID, name: $name }) {\n ok\n }\n }\n`);\n\nexport const ListWorkspaceEnvDocument = graphql(`\n query SdkListWorkspaceEnv($workspaceID: ID!) {\n workspaceEnv(workspaceID: $workspaceID) {\n name\n value\n secret\n alias\n inherited\n masked\n updatedAt\n }\n }\n`);\n\nexport const SetAppEnvDocument = graphql(`\n mutation SdkSetAppEnv($workspaceID: ID!, $alias: String!, $name: String!, $value: String!) {\n setAppEnv(input: { workspaceID: $workspaceID, alias: $alias, name: $name, value: $value }) {\n env {\n name\n value\n secret\n alias\n inherited\n masked\n updatedAt\n }\n }\n }\n`);\n\nexport const SetAppSecretDocument = graphql(`\n mutation SdkSetAppSecret($workspaceID: ID!, $alias: String!, $name: String!, $value: String!) {\n setAppSecret(input: { workspaceID: $workspaceID, alias: $alias, name: $name, value: $value }) {\n env {\n name\n value\n secret\n alias\n inherited\n masked\n updatedAt\n }\n }\n }\n`);\n\nexport const RemoveAppEnvDocument = graphql(`\n mutation SdkRemoveAppEnv($workspaceID: ID!, $alias: String!, $name: String!) {\n removeAppEnv(input: { workspaceID: $workspaceID, alias: $alias, name: $name }) {\n ok\n }\n }\n`);\n\nexport const InheritAppEnvDocument = graphql(`\n mutation SdkInheritAppEnv($workspaceID: ID!, $alias: String!, $name: String!) {\n inheritAppEnv(input: { workspaceID: $workspaceID, alias: $alias, name: $name }) {\n ok\n }\n }\n`);\n\nexport const ListAppEnvDocument = graphql(`\n query SdkListAppEnv($workspaceID: ID!, $alias: String!) {\n appEnv(workspaceID: $workspaceID, alias: $alias) {\n name\n value\n secret\n alias\n inherited\n masked\n updatedAt\n }\n }\n`);\n"]}
1
+ {"version":3,"file":"operations.js","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;CA0B/C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;CAyBrC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,CAAC;;;;;;;;;;;;;CAa9C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAC;;;;;;;;;;;CAW7C,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,CAAC;;;;;;CAM9C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;;;;;;;;;;;;CAY5C,CAAC,CAAC;AAEH,M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C;;;;;;CAMxC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;;;;;;CAMrC,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,OAAO,CAAC;;;;;;;;;CAStC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC;;;;;;;;;;;;;CAavC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC;;;;;;CAMxC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC;;;;;;;;;;;;CAYxC,CAAC,CAAC;AAEH,wFAAwF;AACxF,MAAM,CAAC,MAAM,kBAAkB,GAAG,OAAO,CAAC;;;;;;;;CAQzC,CAAC,CAAC;AAEH,6DAA6D;AAC7D,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC;;;;;;;;;;CAU5C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC;;;;;;CAMxC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAC;;;;;;CAM1C,CAAC,CAAC","sourcesContent":["/**\n * Every GraphQL document the workflow layer sends.\n *\n * These are wrapped in `graphql(...)` so graphql-codegen validates them\n * against the vendored schema at codegen time and emits exact result/variable\n * types. A field that stops existing server-side turns into a compile error\n * here rather than a runtime surprise in an agent's script.\n *\n * The one document NOT defined here is the batched file write: it has a\n * variable number of aliased root fields, so it is assembled at runtime in\n * `unfazed.ts`. See the comment there.\n */\nimport { graphql } from \"./generated/gql.js\";\n\n/**\n * Deployment fields the SDK returns everywhere.\n *\n * `id` + `aliasRevision` + `aliasHeld` are the rollback compare-and-swap\n * triple; `previewUrl` is the immutable by-id URL you can verify BEFORE the\n * alias moves; `error` carries the build failure text when status is FAILED.\n */\nexport const DeploymentFieldsFragment = graphql(`\n fragment DeploymentFields on Deployment {\n id\n workspaceID\n kind\n runtime\n alias\n serviceMode\n healthPath\n cronSchedule\n cronPath\n url\n previewUrl\n sshCommand\n aliasHeld\n aliasRevision\n status\n error\n filesCount\n sizeBytes\n size\n spaMode\n gitRepo\n gitCommit\n createdAt\n }\n`);\n\nexport const WhoamiDocument = graphql(`\n query SdkWhoami {\n whoami {\n kind\n userID\n name\n agentID\n agentName\n claimed\n claimedBy\n scopes\n expiresAt\n usage {\n month\n requests\n limit\n }\n resources {\n workspaces\n workspaceLimit\n services\n serviceLimit\n }\n }\n }\n`);\n\nexport const CreateWorkspaceDocument = graphql(`\n mutation SdkCreateWorkspace($name: String!) {\n createWorkspace(input: { name: $name }) {\n workspace {\n id\n name\n ownerId\n projectId\n createdAt\n updatedAt\n }\n }\n }\n`);\n\nexport const ListWorkspacesDocument = graphql(`\n query SdkListWorkspaces {\n workspaces {\n id\n name\n ownerId\n projectId\n createdAt\n updatedAt\n }\n }\n`);\n\n/**\n * Deleting a workspace, with the deployment cascade made explicit.\n *\n * `withDeployments` is not decoration: without it the server REFUSES while the\n * workspace has any deployment history at all — including FAILED records —\n * with `workspace %q still has deployments; delete them first`. A workspace\n * that was ever deployed is therefore undeletable through the bare mutation,\n * so the SDK always sends the flag and lets the caller choose the value.\n */\nexport const DeleteWorkspaceDocument = graphql(`\n mutation SdkDeleteWorkspace($workspaceID: ID!, $withDeployments: Boolean) {\n deleteWorkspace(input: { workspaceID: $workspaceID, withDeployments: $withDeployments }) {\n ok\n }\n }\n`);\n\nexport const WriteTextFileDocument = graphql(`\n mutation SdkWriteTextFile($workspaceID: ID!, $path: String!, $text: String!) {\n writeWorkspaceTextFile(input: { workspaceID: $workspaceID, path: $path, text: $text }) {\n file {\n path\n sizeBytes\n size\n sha256\n updatedAt\n }\n }\n }\n`);\n\nexport const WriteBase64FileDocument = graphql(`\n mutation SdkWriteBase64File($workspaceID: ID!, $path: String!, $contentBase64: String!) {\n writeWorkspaceBase64File(\n input: { workspaceID: $workspaceID, path: $path, contentBase64: $contentBase64 }\n ) {\n file {\n path\n sizeBytes\n size\n sha256\n updatedAt\n }\n }\n }\n`);\n\nexport const ListFilesDocument = graphql(`\n query SdkListFiles($input: ListWorkspaceFilesInput!) {\n workspaceFilesPage(input: $input) {\n items {\n path\n sizeBytes\n size\n sha256\n updatedAt\n }\n total\n limit\n offset\n hasMore\n nextOffset\n }\n }\n`);\n\nexport const ReadFileDocument = graphql(`\n query SdkReadFile($input: ReadWorkspaceFileInput!) {\n readWorkspaceFile(input: $input) {\n text\n offset\n limit\n totalBytes\n truncated\n nextOffset\n file {\n path\n sizeBytes\n size\n sha256\n updatedAt\n }\n }\n }\n`);\n\nexport const DeleteFileDocument = graphql(`\n mutation SdkDeleteFile($workspaceID: ID!, $path: String!) {\n deleteWorkspaceFile(input: { workspaceID: $workspaceID, path: $path }) {\n ok\n }\n }\n`);\n\nexport const CreateDeploymentDocument = graphql(`\n mutation SdkCreateDeployment($input: CreateDeploymentInput!) {\n createDeployment(input: $input) {\n deployment {\n ...DeploymentFields\n }\n }\n }\n`);\n\nexport const DeployWorkspaceDocument = graphql(`\n mutation SdkDeployWorkspace($input: DeployWorkspaceInput!) {\n deployWorkspace(input: $input) {\n deployment {\n ...DeploymentFields\n }\n }\n }\n`);\n\nexport const GetDeploymentDocument = graphql(`\n query SdkGetDeployment($id: ID!) {\n deployment(id: $id) {\n ...DeploymentFields\n }\n }\n`);\n\n/**\n * The poll document, deliberately narrow.\n *\n * Waiting can run for minutes at a few seconds per tick; selecting the full\n * fragment every time would cost the server (and an agent's rate limit) far\n * more than the four fields the state machine actually reads.\n */\nexport const PollDeploymentDocument = graphql(`\n query SdkPollDeployment($id: ID!) {\n deployment(id: $id) {\n id\n status\n error\n aliasHeld\n url\n previewUrl\n }\n }\n`);\n\nexport const GetDeploymentByAliasDocument = graphql(`\n query SdkGetDeploymentByAlias($alias: String!) {\n deploymentByAlias(alias: $alias) {\n ...DeploymentFields\n }\n }\n`);\n\nexport const ListDeploymentsDocument = graphql(`\n query SdkListDeployments($input: ListDeploymentsInput) {\n deploymentsPage(input: $input) {\n items {\n ...DeploymentFields\n }\n total\n limit\n offset\n hasMore\n nextOffset\n }\n }\n`);\n\nexport const ListReleasesDocument = graphql(`\n query SdkListReleases($alias: String!) {\n deploymentReleases(alias: $alias) {\n ...DeploymentFields\n }\n }\n`);\n\nexport const RollbackDocument = graphql(`\n mutation SdkRollback(\n $deploymentID: ID!\n $expectedCurrentDeploymentID: ID!\n $expectedCurrentAliasRevision: String!\n ) {\n rollbackDeployment(\n input: {\n deploymentID: $deploymentID\n expectedCurrentDeploymentID: $expectedCurrentDeploymentID\n expectedCurrentAliasRevision: $expectedCurrentAliasRevision\n }\n ) {\n ...DeploymentFields\n }\n }\n`);\n\nexport const ServiceStatusDocument = graphql(`\n query SdkServiceStatus($deploymentID: ID!) {\n serviceStatus(deploymentID: $deploymentID) {\n deploymentID\n alias\n serviceMode\n running\n health\n vmID\n inFlight\n alwaysOn\n memSizeMiB\n startedAt\n lastUsedAt\n lastStoppedAt\n restartCount\n lastError\n }\n }\n`);\n\nexport const ServiceLogsDocument = graphql(`\n query SdkServiceLogs($deploymentID: ID!, $tailBytes: Int) {\n serviceLogs(deploymentID: $deploymentID, tailBytes: $tailBytes) {\n deploymentID\n stdout\n stderr\n truncated\n stdoutBytes\n stderrBytes\n tailBytes\n }\n }\n`);\n\nexport const DeploymentEventsDocument = graphql(`\n query SdkDeploymentEvents($deploymentID: ID!, $limit: Int) {\n deploymentEvents(deploymentID: $deploymentID, limit: $limit) {\n id\n deploymentID\n type\n rawType\n severity\n message\n vmID\n createdAt\n }\n }\n`);\n\nexport const RestartServiceDocument = graphql(`\n mutation SdkRestartService($deploymentID: ID!) {\n restartService(input: { deploymentID: $deploymentID }) {\n deploymentID\n running\n health\n vmID\n restartCount\n lastError\n }\n }\n`);\n\nexport const StopServiceDocument = graphql(`\n mutation SdkStopService($deploymentID: ID!) {\n stopService(input: { deploymentID: $deploymentID }) {\n deploymentID\n running\n health\n vmID\n restartCount\n lastError\n }\n }\n`);\n\nexport const DeleteDeploymentDocument = graphql(`\n mutation SdkDeleteDeployment($deploymentID: ID!) {\n deleteDeployment(input: { deploymentID: $deploymentID }) {\n ok\n }\n }\n`);\n\n/* -------------------------------------------------------------------------\n * Env & secrets\n *\n * Workspace-scoped values are SERVICE defaults for every app in the source;\n * app-scoped values override them for one alias. Both are snapshotted into a\n * release at deploy time, so a change only reaches a running app after a\n * redeploy — the workflow layer's doc comments repeat this where it matters.\n * ---------------------------------------------------------------------- */\n\nexport const SetWorkspaceEnvDocument = graphql(`\n mutation SdkSetWorkspaceEnv($workspaceID: ID!, $name: String!, $value: String!) {\n setWorkspaceEnv(input: { workspaceID: $workspaceID, name: $name, value: $value }) {\n env {\n name\n value\n secret\n alias\n inherited\n masked\n updatedAt\n }\n }\n }\n`);\n\nexport const SetWorkspaceSecretDocument = graphql(`\n mutation SdkSetWorkspaceSecret($workspaceID: ID!, $name: String!, $value: String!) {\n setWorkspaceSecret(input: { workspaceID: $workspaceID, name: $name, value: $value }) {\n env {\n name\n value\n secret\n alias\n inherited\n masked\n updatedAt\n }\n }\n }\n`);\n\nexport const DeleteWorkspaceEnvDocument = graphql(`\n mutation SdkDeleteWorkspaceEnv($workspaceID: ID!, $name: String!) {\n deleteWorkspaceEnv(input: { workspaceID: $workspaceID, name: $name }) {\n ok\n }\n }\n`);\n\nexport const ListWorkspaceEnvDocument = graphql(`\n query SdkListWorkspaceEnv($workspaceID: ID!) {\n workspaceEnv(workspaceID: $workspaceID) {\n name\n value\n secret\n alias\n inherited\n masked\n updatedAt\n }\n }\n`);\n\nexport const SetAppEnvDocument = graphql(`\n mutation SdkSetAppEnv($workspaceID: ID!, $alias: String!, $name: String!, $value: String!) {\n setAppEnv(input: { workspaceID: $workspaceID, alias: $alias, name: $name, value: $value }) {\n env {\n name\n value\n secret\n alias\n inherited\n masked\n updatedAt\n }\n }\n }\n`);\n\nexport const SetAppSecretDocument = graphql(`\n mutation SdkSetAppSecret($workspaceID: ID!, $alias: String!, $name: String!, $value: String!) {\n setAppSecret(input: { workspaceID: $workspaceID, alias: $alias, name: $name, value: $value }) {\n env {\n name\n value\n secret\n alias\n inherited\n masked\n updatedAt\n }\n }\n }\n`);\n\nexport const RemoveAppEnvDocument = graphql(`\n mutation SdkRemoveAppEnv($workspaceID: ID!, $alias: String!, $name: String!) {\n removeAppEnv(input: { workspaceID: $workspaceID, alias: $alias, name: $name }) {\n ok\n }\n }\n`);\n\nexport const InheritAppEnvDocument = graphql(`\n mutation SdkInheritAppEnv($workspaceID: ID!, $alias: String!, $name: String!) {\n inheritAppEnv(input: { workspaceID: $workspaceID, alias: $alias, name: $name }) {\n ok\n }\n }\n`);\n\nexport const ListAppEnvDocument = graphql(`\n query SdkListAppEnv($workspaceID: ID!, $alias: String!) {\n appEnv(workspaceID: $workspaceID, alias: $alias) {\n name\n value\n secret\n alias\n inherited\n masked\n updatedAt\n }\n }\n`);\n\n/* -------------------------------------------------------------------------\n * Agent runs\n *\n * A run is the past-tense counterpart to a deployment: \"boot a fresh VM,\n * hand it a prompt, let a harness work, keep the transcript, record what it\n * cost, reap the VM\". `createRun` returns once the VM has started\n * (RUNNING) or FAILED with `error` when it could not boot — unlike\n * `createDeployment`, a FAILED run is a normal return value, not something\n * that only shows up later in a poll.\n * ---------------------------------------------------------------------- */\n\n/** Run fields the SDK returns everywhere. */\nexport const RunFieldsFragment = graphql(`\n fragment RunFields on Run {\n id\n workspaceID\n ownerId\n status\n rawStatus\n command\n harness\n prompt\n setup\n skills\n verify\n approval\n mode\n parentRunID\n depth\n question {\n id\n text\n options\n askedAt\n }\n memoryMiB\n maxSeconds\n metadata\n error\n exitCode\n result {\n status\n detail\n text\n }\n verifyExitCode\n vmID\n transcriptAvailable\n usage {\n vmSeconds\n memoryMiB\n mibSeconds\n }\n createdAt\n startedAt\n settledAt\n }\n`);\n\nexport const CreateRunDocument = graphql(`\n mutation SdkCreateRun($input: CreateRunInput!) {\n createRun(input: $input) {\n ...RunFields\n }\n }\n`);\n\nexport const GetRunDocument = graphql(`\n query SdkGetRun($id: ID!) {\n run(id: $id) {\n ...RunFields\n }\n }\n`);\n\n/**\n * The poll document, deliberately narrow — see {@link PollDeploymentDocument}\n * for why: this runs every few seconds for potentially up to an hour.\n */\nexport const PollRunDocument = graphql(`\n query SdkPollRun($id: ID!) {\n run(id: $id) {\n id\n status\n error\n exitCode\n }\n }\n`);\n\nexport const ListRunsDocument = graphql(`\n query SdkListRuns($input: ListRunsInput) {\n runs(input: $input) {\n items {\n ...RunFields\n }\n total\n limit\n offset\n hasMore\n nextOffset\n }\n }\n`);\n\nexport const CancelRunDocument = graphql(`\n mutation SdkCancelRun($id: ID!) {\n cancelRun(id: $id) {\n ...RunFields\n }\n }\n`);\n\nexport const RunEventsDocument = graphql(`\n query SdkRunEvents($runID: ID!, $limit: Int) {\n runEvents(runID: $runID, limit: $limit) {\n id\n runID\n type\n severity\n message\n metadata\n createdAt\n }\n }\n`);\n\n/** The live console tail of a RUNNING run. Empty with `running: false` once settled. */\nexport const RunConsoleDocument = graphql(`\n query SdkRunConsole($id: ID!, $tailBytes: Int) {\n runConsole(id: $id, tailBytes: $tailBytes) {\n runID\n running\n text\n }\n }\n`);\n\n/** The bounded end of a finished run's stored transcript. */\nexport const RunTranscriptDocument = graphql(`\n query SdkRunTranscript($id: ID!, $tailBytes: Int) {\n runTranscript(id: $id, tailBytes: $tailBytes) {\n runID\n available\n text\n totalBytes\n truncated\n }\n }\n`);\n\nexport const AnswerRunDocument = graphql(`\n mutation SdkAnswerRun($id: ID!, $answer: String!) {\n answerRun(id: $id, answer: $answer) {\n ...RunFields\n }\n }\n`);\n\nexport const FollowUpRunDocument = graphql(`\n mutation SdkFollowUpRun($input: FollowUpRunInput!) {\n followUpRun(input: $input) {\n ...RunFields\n }\n }\n`);\n"]}
package/dist/unfazed.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  import { UnfazedClient, type ClientOptions, type RequestOptions } from "./client.js";
2
- import type { CreateDeploymentInput, DeploymentFieldsFragment, ListDeploymentsInput, ServiceMode, ServiceRuntime, SdkCreateWorkspaceMutation } from "./generated/graphql.js";
2
+ import type { CreateDeploymentInput, DeploymentFieldsFragment, ListDeploymentsInput, RunFieldsFragment, RunStatus, ServiceMode, ServiceRuntime, SdkCreateWorkspaceMutation } from "./generated/graphql.js";
3
3
  import { type WaitOptions } from "./wait.js";
4
4
  /** A deployment as the workflow layer returns it. */
5
5
  export type Deployment = DeploymentFieldsFragment;
6
+ /** An agent run as the workflow layer returns it. */
7
+ export type Run = RunFieldsFragment;
6
8
  /**
7
9
  * A workspace as {@link Unfazed.createWorkspace} and
8
10
  * {@link Unfazed.ensureWorkspace} return it.
@@ -152,6 +154,87 @@ export interface RollbackOptions {
152
154
  expectedCurrentId?: string;
153
155
  signal?: AbortSignal;
154
156
  }
157
+ /** Options for {@link Unfazed.createRun}. */
158
+ export interface CreateRunOptions {
159
+ workspaceId: string;
160
+ /** Delivered to the guest as `/work/prompt.md` and `$UNFZ_RUN_PROMPT` (max 64 KiB). */
161
+ prompt?: string;
162
+ /** A named preset from the image's `/etc/unfazed/harnesses.json`. Mutually exclusive in effect with `command` — set one. */
163
+ harness?: string;
164
+ /** Runs anything else with `sh -c`, instead of a named `harness`. */
165
+ command?: string;
166
+ /** Up to 20 single-line shell commands run in `/work` before the harness; the first failure fails the run. */
167
+ setup?: string[];
168
+ /** Up to 10 `owner/repo:path` GitHub references, cloned into `/work/.claude/skills/<name>` first. */
169
+ skills?: string[];
170
+ /**
171
+ * Up to 20 shell commands run in `/work` AFTER the harness exited 0 —
172
+ * tests, a build, `test -f out.txt`. The first failure FAILS the run
173
+ * (`error` "verification failed", `verifyExitCode`). Without `verify`,
174
+ * SUCCEEDED only means the harness exited cleanly: an agent that answered
175
+ * "I could not do this" still succeeds — read `run.result.text` in that
176
+ * case. Skipped in plan mode.
177
+ */
178
+ verify?: string[];
179
+ /** VM memory. Omit for the platform default. */
180
+ memoryMiB?: number;
181
+ /** Wall-clock cap in seconds. Omit for the platform default; capped at 3600. */
182
+ maxSeconds?: number;
183
+ /** Up to 20 immutable labels for your own correlation (a ticket id, a PR). Echoed back on every read. */
184
+ metadata?: unknown;
185
+ /** Copy the workspace's files into `/work`. Default true. */
186
+ includeFiles?: boolean;
187
+ /**
188
+ * `"human"` routes the harness's guarded actions (permission prompts) to
189
+ * the run's owner: the run shows BLOCKED with the question until it is
190
+ * answered ({@link Unfazed.answerRun}, the dashboard). Omit for the
191
+ * harness's own defaults.
192
+ */
193
+ approval?: "human";
194
+ /**
195
+ * `"plan"` asks the harness to research and write a plan WITHOUT acting
196
+ * (Claude Code runs in `--permission-mode plan`); the plan is the run's
197
+ * transcript. Approve it with {@link Unfazed.followUpRun}. Omit to do the task.
198
+ */
199
+ mode?: "plan";
200
+ /** The run this one continues. Usually set for you by {@link Unfazed.followUpRun}. */
201
+ parentRunId?: string;
202
+ /**
203
+ * Block until the run reaches a terminal status.
204
+ *
205
+ * `createRun` itself already returns RUNNING or — on a boot failure —
206
+ * FAILED with `error` set; `wait: true` additionally polls a RUNNING run
207
+ * through to SUCCEEDED/FAILED/CANCELLED. Either way this resolves with the
208
+ * run, never throws for FAILED: see {@link Unfazed.waitForRun}.
209
+ */
210
+ wait?: boolean;
211
+ /** Backoff/timeout knobs used when `wait` is true. */
212
+ waitOptions?: WaitOptions;
213
+ signal?: AbortSignal;
214
+ }
215
+ /** Options for {@link Unfazed.followUpRun}. */
216
+ export interface FollowUpRunOptions {
217
+ /** What to do next. For a plan run: the go-ahead (and any changes to the plan). */
218
+ prompt: string;
219
+ /** `"plan"` to plan again instead of executing; omit to execute. */
220
+ mode?: "plan";
221
+ /** Override the parent's approval; omit to inherit it. */
222
+ approval?: "human" | "";
223
+ /** Override the parent's wall clock (seconds). */
224
+ maxSeconds?: number;
225
+ metadata?: unknown;
226
+ /** As for {@link CreateRunOptions.wait}. */
227
+ wait?: boolean;
228
+ waitOptions?: WaitOptions;
229
+ signal?: AbortSignal;
230
+ }
231
+ /** Filter/paging for {@link Unfazed.listRuns}. */
232
+ export interface ListRunsFilter {
233
+ workspaceId?: string;
234
+ status?: RunStatus;
235
+ limit?: number;
236
+ offset?: number;
237
+ }
155
238
  export interface UnfazedOptions extends ClientOptions {
156
239
  /** Use an existing core client instead of constructing one. */
157
240
  client?: UnfazedClient;
@@ -650,4 +733,170 @@ export declare class Unfazed {
650
733
  * run fails loudly instead of silently undoing the first.
651
734
  */
652
735
  rollback(options: RollbackOptions): Promise<Deployment>;
736
+ /**
737
+ * Starts an agent run.
738
+ *
739
+ * Resolves once the VM has started (status RUNNING) — or, on a boot
740
+ * failure, once the run has already settled FAILED with `error` set. A
741
+ * boot failure is a normal return value here, not a thrown error, with or
742
+ * without `wait`.
743
+ *
744
+ * ```ts
745
+ * const run = await unfazed.createRun({
746
+ * workspaceId: ws.id,
747
+ * harness: "claude-code",
748
+ * prompt: "Fix the failing test in test/foo.test.ts and open a PR.",
749
+ * wait: true,
750
+ * });
751
+ * console.log(run.status, run.usage.mibSeconds);
752
+ * ```
753
+ *
754
+ * With `wait: true` this additionally polls a RUNNING run through to a
755
+ * terminal status — see {@link waitForRun} for exactly what "terminal"
756
+ * means and how a timeout is reported.
757
+ */
758
+ createRun(options: CreateRunOptions): Promise<Run>;
759
+ /**
760
+ * Polls a run until it leaves QUEUED/RUNNING, throwing only on timeout.
761
+ *
762
+ * Terminal is defined negatively — anything that is not QUEUED or RUNNING —
763
+ * matching the platform's own status machine, so an unknown future status
764
+ * still ends the wait instead of looping forever. **SUCCEEDED, FAILED and
765
+ * CANCELLED are all returned normally**: a run that executed and exited
766
+ * non-zero is a completed answer (read `run.error` / `run.exitCode`), not
767
+ * an exception the way a FAILED deployment is. Only running out of time
768
+ * throws, as {@link UnfazedRunError} with `reason: "TIMEOUT"`.
769
+ */
770
+ waitForRun(runId: string, waitOptions?: WaitOptions): Promise<Run>;
771
+ /** Reads one run by id. Throws if it does not exist or is not visible to you. */
772
+ getRun(runId: string, options?: RequestOptions): Promise<Run>;
773
+ /** Your agent runs, newest first, optionally filtered by workspace/status. */
774
+ listRuns(filter?: ListRunsFilter, options?: RequestOptions): Promise<{
775
+ total: number;
776
+ limit: number;
777
+ offset: number;
778
+ hasMore: boolean;
779
+ nextOffset: number | null;
780
+ items: Array<{
781
+ id: string;
782
+ workspaceID: string;
783
+ ownerId: string;
784
+ status: RunStatus;
785
+ rawStatus: string;
786
+ command: string | null;
787
+ harness: string | null;
788
+ prompt: string | null;
789
+ setup: Array<string>;
790
+ skills: Array<string>;
791
+ verify: Array<string>;
792
+ approval: string;
793
+ mode: string;
794
+ parentRunID: string | null;
795
+ depth: number;
796
+ memoryMiB: number;
797
+ maxSeconds: number;
798
+ metadata: unknown;
799
+ error: string | null;
800
+ exitCode: number | null;
801
+ verifyExitCode: number | null;
802
+ vmID: string | null;
803
+ transcriptAvailable: boolean;
804
+ createdAt: string;
805
+ startedAt: string | null;
806
+ settledAt: string | null;
807
+ question: {
808
+ id: string;
809
+ text: string;
810
+ options: Array<string>;
811
+ askedAt: string;
812
+ } | null;
813
+ result: {
814
+ status: string;
815
+ detail: string | null;
816
+ text: string | null;
817
+ } | null;
818
+ usage: {
819
+ vmSeconds: number;
820
+ memoryMiB: number;
821
+ mibSeconds: number;
822
+ };
823
+ }>;
824
+ }>;
825
+ /**
826
+ * Stops a run: a QUEUED run is cancelled at once, a RUNNING run's VM is
827
+ * killed and the run settles CANCELLED shortly after (`waitForRun` to
828
+ * observe it). Idempotent on an already-CANCELLED run; a run that has
829
+ * already SUCCEEDED or FAILED cannot be cancelled and the server rejects
830
+ * the call (thrown as {@link UnfazedGraphQLError}) — check `status` first
831
+ * when that is a routine case for you.
832
+ */
833
+ cancelRun(runId: string, options?: RequestOptions): Promise<Run>;
834
+ /**
835
+ * Continues a FINISHED run with a new instruction: a new run in the same
836
+ * workspace that inherits the parent's harness (or command), setup, skills
837
+ * and approval, with the parent's task, outcome and the end of its
838
+ * transcript prepended to `prompt` as context. This is how a plan is
839
+ * approved — `createRun({ mode: "plan" })` writes the plan, `followUpRun`
840
+ * with the go-ahead executes it — and how work continues after a run
841
+ * exited. The new run carries `parentRunID` and `depth`; chains are capped
842
+ * server-side. A live run cannot be followed up (the server refuses):
843
+ * answer it or wait for it.
844
+ *
845
+ * ```ts
846
+ * const plan = await unfazed.createRun({ workspaceId, harness: "claude-code", prompt: "plan the migration", mode: "plan", wait: true });
847
+ * const done = await unfazed.followUpRun(plan.id, { prompt: "go ahead", wait: true });
848
+ * ```
849
+ */
850
+ followUpRun(runId: string, options: FollowUpRunOptions): Promise<Run>;
851
+ /**
852
+ * Answers a BLOCKED run's pending question (`run.question`); the run
853
+ * resumes with the text. For a question with `options`, answer with one
854
+ * of them. Only a BLOCKED run accepts an answer — anything else is
855
+ * refused by the server.
856
+ *
857
+ * A run blocks when the agent inside calls `request_human_input`, or when
858
+ * it was created with `approval: "human"` and its harness asks permission
859
+ * for a guarded action. `waitForRun` keeps waiting through BLOCKED (it is
860
+ * not terminal); poll `getRun` and look at `question` to notice one.
861
+ */
862
+ answerRun(runId: string, answer: string, options?: RequestOptions): Promise<Run>;
863
+ /** A run's own history, oldest first (started, cancel requested, settled). */
864
+ runEvents(runId: string, input?: {
865
+ limit?: number;
866
+ }, options?: RequestOptions): Promise<{
867
+ id: string;
868
+ runID: string;
869
+ type: string;
870
+ severity: import("./index.js").DeploymentEventSeverity;
871
+ message: string;
872
+ metadata: unknown;
873
+ createdAt: string;
874
+ }[]>;
875
+ /**
876
+ * The live tail of a RUNNING run's console. Once the run has settled this
877
+ * comes back empty with `running: false` — read {@link runTranscript}
878
+ * instead, which is the stored, durable copy.
879
+ */
880
+ runConsole(runId: string, input?: {
881
+ tailBytes?: number;
882
+ }, options?: RequestOptions): Promise<{
883
+ runID: string;
884
+ running: boolean;
885
+ text: string;
886
+ }>;
887
+ /**
888
+ * The bounded end of a finished run's stored transcript (secrets
889
+ * redacted). `available` is false until the run settles and the transcript
890
+ * is copied out of the VM's console file — check `run.transcriptAvailable`
891
+ * or poll this after {@link waitForRun} resolves.
892
+ */
893
+ runTranscript(runId: string, input?: {
894
+ tailBytes?: number;
895
+ }, options?: RequestOptions): Promise<{
896
+ runID: string;
897
+ available: boolean;
898
+ text: string;
899
+ totalBytes: number;
900
+ truncated: boolean;
901
+ }>;
653
902
  }