unfazed 0.2.0 → 0.3.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.
@@ -467,4 +467,152 @@ 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
+ approval
494
+ mode
495
+ parentRunID
496
+ depth
497
+ question {
498
+ id
499
+ text
500
+ options
501
+ askedAt
502
+ }
503
+ memoryMiB
504
+ maxSeconds
505
+ metadata
506
+ error
507
+ exitCode
508
+ vmID
509
+ transcriptAvailable
510
+ usage {
511
+ vmSeconds
512
+ memoryMiB
513
+ mibSeconds
514
+ }
515
+ createdAt
516
+ startedAt
517
+ settledAt
518
+ }
519
+ `);
520
+ export const CreateRunDocument = graphql(`
521
+ mutation SdkCreateRun($input: CreateRunInput!) {
522
+ createRun(input: $input) {
523
+ ...RunFields
524
+ }
525
+ }
526
+ `);
527
+ export const GetRunDocument = graphql(`
528
+ query SdkGetRun($id: ID!) {
529
+ run(id: $id) {
530
+ ...RunFields
531
+ }
532
+ }
533
+ `);
534
+ /**
535
+ * The poll document, deliberately narrow — see {@link PollDeploymentDocument}
536
+ * for why: this runs every few seconds for potentially up to an hour.
537
+ */
538
+ export const PollRunDocument = graphql(`
539
+ query SdkPollRun($id: ID!) {
540
+ run(id: $id) {
541
+ id
542
+ status
543
+ error
544
+ exitCode
545
+ }
546
+ }
547
+ `);
548
+ export const ListRunsDocument = graphql(`
549
+ query SdkListRuns($input: ListRunsInput) {
550
+ runs(input: $input) {
551
+ items {
552
+ ...RunFields
553
+ }
554
+ total
555
+ limit
556
+ offset
557
+ hasMore
558
+ nextOffset
559
+ }
560
+ }
561
+ `);
562
+ export const CancelRunDocument = graphql(`
563
+ mutation SdkCancelRun($id: ID!) {
564
+ cancelRun(id: $id) {
565
+ ...RunFields
566
+ }
567
+ }
568
+ `);
569
+ export const RunEventsDocument = graphql(`
570
+ query SdkRunEvents($runID: ID!, $limit: Int) {
571
+ runEvents(runID: $runID, limit: $limit) {
572
+ id
573
+ runID
574
+ type
575
+ severity
576
+ message
577
+ metadata
578
+ createdAt
579
+ }
580
+ }
581
+ `);
582
+ /** The live console tail of a RUNNING run. Empty with `running: false` once settled. */
583
+ export const RunConsoleDocument = graphql(`
584
+ query SdkRunConsole($id: ID!, $tailBytes: Int) {
585
+ runConsole(id: $id, tailBytes: $tailBytes) {
586
+ runID
587
+ running
588
+ text
589
+ }
590
+ }
591
+ `);
592
+ /** The bounded end of a finished run's stored transcript. */
593
+ export const RunTranscriptDocument = graphql(`
594
+ query SdkRunTranscript($id: ID!, $tailBytes: Int) {
595
+ runTranscript(id: $id, tailBytes: $tailBytes) {
596
+ runID
597
+ available
598
+ text
599
+ totalBytes
600
+ truncated
601
+ }
602
+ }
603
+ `);
604
+ export const AnswerRunDocument = graphql(`
605
+ mutation SdkAnswerRun($id: ID!, $answer: String!) {
606
+ answerRun(id: $id, answer: $answer) {
607
+ ...RunFields
608
+ }
609
+ }
610
+ `);
611
+ export const FollowUpRunDocument = graphql(`
612
+ mutation SdkFollowUpRun($input: FollowUpRunInput!) {
613
+ followUpRun(input: $input) {
614
+ ...RunFields
615
+ }
616
+ }
617
+ `);
470
618
  //# sourceMappingURL=operations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"operations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C,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,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;;;;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AO,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 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 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,78 @@ 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
+ /** VM memory. Omit for the platform default. */
171
+ memoryMiB?: number;
172
+ /** Wall-clock cap in seconds. Omit for the platform default; capped at 3600. */
173
+ maxSeconds?: number;
174
+ /** Up to 20 immutable labels for your own correlation (a ticket id, a PR). Echoed back on every read. */
175
+ metadata?: unknown;
176
+ /** Copy the workspace's files into `/work`. Default true. */
177
+ includeFiles?: boolean;
178
+ /**
179
+ * `"human"` routes the harness's guarded actions (permission prompts) to
180
+ * the run's owner: the run shows BLOCKED with the question until it is
181
+ * answered ({@link Unfazed.answerRun}, the dashboard). Omit for the
182
+ * harness's own defaults.
183
+ */
184
+ approval?: "human";
185
+ /**
186
+ * `"plan"` asks the harness to research and write a plan WITHOUT acting
187
+ * (Claude Code runs in `--permission-mode plan`); the plan is the run's
188
+ * transcript. Approve it with {@link Unfazed.followUpRun}. Omit to do the task.
189
+ */
190
+ mode?: "plan";
191
+ /** The run this one continues. Usually set for you by {@link Unfazed.followUpRun}. */
192
+ parentRunId?: string;
193
+ /**
194
+ * Block until the run reaches a terminal status.
195
+ *
196
+ * `createRun` itself already returns RUNNING or — on a boot failure —
197
+ * FAILED with `error` set; `wait: true` additionally polls a RUNNING run
198
+ * through to SUCCEEDED/FAILED/CANCELLED. Either way this resolves with the
199
+ * run, never throws for FAILED: see {@link Unfazed.waitForRun}.
200
+ */
201
+ wait?: boolean;
202
+ /** Backoff/timeout knobs used when `wait` is true. */
203
+ waitOptions?: WaitOptions;
204
+ signal?: AbortSignal;
205
+ }
206
+ /** Options for {@link Unfazed.followUpRun}. */
207
+ export interface FollowUpRunOptions {
208
+ /** What to do next. For a plan run: the go-ahead (and any changes to the plan). */
209
+ prompt: string;
210
+ /** `"plan"` to plan again instead of executing; omit to execute. */
211
+ mode?: "plan";
212
+ /** Override the parent's approval; omit to inherit it. */
213
+ approval?: "human" | "";
214
+ /** Override the parent's wall clock (seconds). */
215
+ maxSeconds?: number;
216
+ metadata?: unknown;
217
+ /** As for {@link CreateRunOptions.wait}. */
218
+ wait?: boolean;
219
+ waitOptions?: WaitOptions;
220
+ signal?: AbortSignal;
221
+ }
222
+ /** Filter/paging for {@link Unfazed.listRuns}. */
223
+ export interface ListRunsFilter {
224
+ workspaceId?: string;
225
+ status?: RunStatus;
226
+ limit?: number;
227
+ offset?: number;
228
+ }
155
229
  export interface UnfazedOptions extends ClientOptions {
156
230
  /** Use an existing core client instead of constructing one. */
157
231
  client?: UnfazedClient;
@@ -650,4 +724,163 @@ export declare class Unfazed {
650
724
  * run fails loudly instead of silently undoing the first.
651
725
  */
652
726
  rollback(options: RollbackOptions): Promise<Deployment>;
727
+ /**
728
+ * Starts an agent run.
729
+ *
730
+ * Resolves once the VM has started (status RUNNING) — or, on a boot
731
+ * failure, once the run has already settled FAILED with `error` set. A
732
+ * boot failure is a normal return value here, not a thrown error, with or
733
+ * without `wait`.
734
+ *
735
+ * ```ts
736
+ * const run = await unfazed.createRun({
737
+ * workspaceId: ws.id,
738
+ * harness: "claude-code",
739
+ * prompt: "Fix the failing test in test/foo.test.ts and open a PR.",
740
+ * wait: true,
741
+ * });
742
+ * console.log(run.status, run.usage.mibSeconds);
743
+ * ```
744
+ *
745
+ * With `wait: true` this additionally polls a RUNNING run through to a
746
+ * terminal status — see {@link waitForRun} for exactly what "terminal"
747
+ * means and how a timeout is reported.
748
+ */
749
+ createRun(options: CreateRunOptions): Promise<Run>;
750
+ /**
751
+ * Polls a run until it leaves QUEUED/RUNNING, throwing only on timeout.
752
+ *
753
+ * Terminal is defined negatively — anything that is not QUEUED or RUNNING —
754
+ * matching the platform's own status machine, so an unknown future status
755
+ * still ends the wait instead of looping forever. **SUCCEEDED, FAILED and
756
+ * CANCELLED are all returned normally**: a run that executed and exited
757
+ * non-zero is a completed answer (read `run.error` / `run.exitCode`), not
758
+ * an exception the way a FAILED deployment is. Only running out of time
759
+ * throws, as {@link UnfazedRunError} with `reason: "TIMEOUT"`.
760
+ */
761
+ waitForRun(runId: string, waitOptions?: WaitOptions): Promise<Run>;
762
+ /** Reads one run by id. Throws if it does not exist or is not visible to you. */
763
+ getRun(runId: string, options?: RequestOptions): Promise<Run>;
764
+ /** Your agent runs, newest first, optionally filtered by workspace/status. */
765
+ listRuns(filter?: ListRunsFilter, options?: RequestOptions): Promise<{
766
+ total: number;
767
+ limit: number;
768
+ offset: number;
769
+ hasMore: boolean;
770
+ nextOffset: number | null;
771
+ items: Array<{
772
+ id: string;
773
+ workspaceID: string;
774
+ ownerId: string;
775
+ status: RunStatus;
776
+ rawStatus: string;
777
+ command: string | null;
778
+ harness: string | null;
779
+ prompt: string | null;
780
+ setup: Array<string>;
781
+ skills: Array<string>;
782
+ approval: string;
783
+ mode: string;
784
+ parentRunID: string | null;
785
+ depth: number;
786
+ memoryMiB: number;
787
+ maxSeconds: number;
788
+ metadata: unknown;
789
+ error: string | null;
790
+ exitCode: number | null;
791
+ vmID: string | null;
792
+ transcriptAvailable: boolean;
793
+ createdAt: string;
794
+ startedAt: string | null;
795
+ settledAt: string | null;
796
+ question: {
797
+ id: string;
798
+ text: string;
799
+ options: Array<string>;
800
+ askedAt: string;
801
+ } | null;
802
+ usage: {
803
+ vmSeconds: number;
804
+ memoryMiB: number;
805
+ mibSeconds: number;
806
+ };
807
+ }>;
808
+ }>;
809
+ /**
810
+ * Stops a run: a QUEUED run is cancelled at once, a RUNNING run's VM is
811
+ * killed and the run settles CANCELLED shortly after (`waitForRun` to
812
+ * observe it). Idempotent on an already-CANCELLED run; a run that has
813
+ * already SUCCEEDED or FAILED cannot be cancelled and the server rejects
814
+ * the call (thrown as {@link UnfazedGraphQLError}) — check `status` first
815
+ * when that is a routine case for you.
816
+ */
817
+ cancelRun(runId: string, options?: RequestOptions): Promise<Run>;
818
+ /**
819
+ * Continues a FINISHED run with a new instruction: a new run in the same
820
+ * workspace that inherits the parent's harness (or command), setup, skills
821
+ * and approval, with the parent's task, outcome and the end of its
822
+ * transcript prepended to `prompt` as context. This is how a plan is
823
+ * approved — `createRun({ mode: "plan" })` writes the plan, `followUpRun`
824
+ * with the go-ahead executes it — and how work continues after a run
825
+ * exited. The new run carries `parentRunID` and `depth`; chains are capped
826
+ * server-side. A live run cannot be followed up (the server refuses):
827
+ * answer it or wait for it.
828
+ *
829
+ * ```ts
830
+ * const plan = await unfazed.createRun({ workspaceId, harness: "claude-code", prompt: "plan the migration", mode: "plan", wait: true });
831
+ * const done = await unfazed.followUpRun(plan.id, { prompt: "go ahead", wait: true });
832
+ * ```
833
+ */
834
+ followUpRun(runId: string, options: FollowUpRunOptions): Promise<Run>;
835
+ /**
836
+ * Answers a BLOCKED run's pending question (`run.question`); the run
837
+ * resumes with the text. For a question with `options`, answer with one
838
+ * of them. Only a BLOCKED run accepts an answer — anything else is
839
+ * refused by the server.
840
+ *
841
+ * A run blocks when the agent inside calls `request_human_input`, or when
842
+ * it was created with `approval: "human"` and its harness asks permission
843
+ * for a guarded action. `waitForRun` keeps waiting through BLOCKED (it is
844
+ * not terminal); poll `getRun` and look at `question` to notice one.
845
+ */
846
+ answerRun(runId: string, answer: string, options?: RequestOptions): Promise<Run>;
847
+ /** A run's own history, oldest first (started, cancel requested, settled). */
848
+ runEvents(runId: string, input?: {
849
+ limit?: number;
850
+ }, options?: RequestOptions): Promise<{
851
+ id: string;
852
+ runID: string;
853
+ type: string;
854
+ severity: import("./index.js").DeploymentEventSeverity;
855
+ message: string;
856
+ metadata: unknown;
857
+ createdAt: string;
858
+ }[]>;
859
+ /**
860
+ * The live tail of a RUNNING run's console. Once the run has settled this
861
+ * comes back empty with `running: false` — read {@link runTranscript}
862
+ * instead, which is the stored, durable copy.
863
+ */
864
+ runConsole(runId: string, input?: {
865
+ tailBytes?: number;
866
+ }, options?: RequestOptions): Promise<{
867
+ runID: string;
868
+ running: boolean;
869
+ text: string;
870
+ }>;
871
+ /**
872
+ * The bounded end of a finished run's stored transcript (secrets
873
+ * redacted). `available` is false until the run settles and the transcript
874
+ * is copied out of the VM's console file — check `run.transcriptAvailable`
875
+ * or poll this after {@link waitForRun} resolves.
876
+ */
877
+ runTranscript(runId: string, input?: {
878
+ tailBytes?: number;
879
+ }, options?: RequestOptions): Promise<{
880
+ runID: string;
881
+ available: boolean;
882
+ text: string;
883
+ totalBytes: number;
884
+ truncated: boolean;
885
+ }>;
653
886
  }