@scarn/sdk 0.8.0 → 0.8.2

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.
@@ -3,7 +3,7 @@ import {
3
3
  ScarnClient,
4
4
  TaskRuns,
5
5
  createClient
6
- } from "./chunk-vfeytkqx.js";
6
+ } from "./chunk-8pyhrdgy.js";
7
7
  // src/task-plane-client.ts
8
8
  function unwrap(result) {
9
9
  if (result.error)
@@ -878,6 +878,9 @@ class Projects extends HeyApiClient {
878
878
  }
879
879
  });
880
880
  }
881
+ listProjectMembers(options) {
882
+ return (options.client ?? this.client).get({ url: "/api/projects/{projectId}/members", ...options });
883
+ }
881
884
  updateProjectDefaultPipelineAssignment(options) {
882
885
  return (options.client ?? this.client).put({
883
886
  url: "/api/projects/{projectId}/default-pipeline-assignment",
@@ -956,12 +959,18 @@ class Tasks extends HeyApiClient {
956
959
  }
957
960
  });
958
961
  }
962
+ cancelTask(options) {
963
+ return (options.client ?? this.client).post({ url: "/api/tasks/{taskId}/cancel", ...options });
964
+ }
959
965
  getTask(options) {
960
966
  return (options.client ?? this.client).get({ url: "/api/tasks/{taskId}", ...options });
961
967
  }
962
968
  getTaskRuns(options) {
963
969
  return (options.client ?? this.client).get({ url: "/api/tasks/{taskId}/runs", ...options });
964
970
  }
971
+ listProjectTasks(options) {
972
+ return (options.client ?? this.client).get({ url: "/api/projects/{projectId}/tasks", ...options });
973
+ }
965
974
  }
966
975
 
967
976
  class TaskRuns extends HeyApiClient {
@@ -1050,6 +1059,16 @@ class TaskRuns extends HeyApiClient {
1050
1059
  }
1051
1060
  });
1052
1061
  }
1062
+ readTaskRunWorkItem(options) {
1063
+ return (options.client ?? this.client).post({
1064
+ url: "/api/task-runs/{taskRunId}/work-item-reads",
1065
+ ...options,
1066
+ headers: {
1067
+ "Content-Type": "application/json",
1068
+ ...options.headers
1069
+ }
1070
+ });
1071
+ }
1053
1072
  createArtifactUploadUrl(options) {
1054
1073
  return (options.client ?? this.client).post({
1055
1074
  url: "/api/task-runs/{taskRunId}/artifact-upload-url",
@@ -1152,6 +1171,16 @@ class PipelineExecutions extends HeyApiClient {
1152
1171
  rerunPipelineExecutionVisit(options) {
1153
1172
  return (options.client ?? this.client).post({ url: "/api/pipeline-executions/{pipelineExecutionId}/visits/{visitId}/rerun", ...options });
1154
1173
  }
1174
+ answerQuestion(options) {
1175
+ return (options.client ?? this.client).post({
1176
+ url: "/api/pipeline-executions/{pipelineExecutionId}/questions/{questionId}/answer",
1177
+ ...options,
1178
+ headers: {
1179
+ "Content-Type": "application/json",
1180
+ ...options.headers
1181
+ }
1182
+ });
1183
+ }
1155
1184
  continueWithoutReply(options) {
1156
1185
  return (options.client ?? this.client).post({ url: "/api/pipeline-executions/{pipelineExecutionId}/questions/{questionId}/continue", ...options });
1157
1186
  }
@@ -1282,6 +1311,16 @@ class WorkItems extends HeyApiClient {
1282
1311
  }
1283
1312
  });
1284
1313
  }
1314
+ setWorkItemState(options) {
1315
+ return (options.client ?? this.client).put({
1316
+ url: "/api/work-items/{workItemId}/state",
1317
+ ...options,
1318
+ headers: {
1319
+ "Content-Type": "application/json",
1320
+ ...options.headers
1321
+ }
1322
+ });
1323
+ }
1285
1324
  }
1286
1325
 
1287
1326
  class Conversations extends HeyApiClient {
@@ -1430,6 +1469,15 @@ class UserNotifications extends HeyApiClient {
1430
1469
  }
1431
1470
  }
1432
1471
 
1472
+ class Inbox extends HeyApiClient {
1473
+ listProjectInboxWaits(options) {
1474
+ return (options.client ?? this.client).get({ url: "/api/projects/{projectId}/inbox/waits", ...options });
1475
+ }
1476
+ getProjectInboxSummary(options) {
1477
+ return (options.client ?? this.client).get({ url: "/api/projects/{projectId}/inbox/summary", ...options });
1478
+ }
1479
+ }
1480
+
1433
1481
  class NotificationRules extends HeyApiClient {
1434
1482
  listNotificationRules(options) {
1435
1483
  return (options.client ?? this.client).get({ url: "/api/projects/{projectId}/notification-rules", ...options });
@@ -1446,25 +1494,6 @@ class NotificationRules extends HeyApiClient {
1446
1494
  }
1447
1495
  }
1448
1496
 
1449
- class StepDefinitionTemplates extends HeyApiClient {
1450
- listStepDefinitionTemplates(options) {
1451
- return (options?.client ?? this.client).get({ url: "/api/step-definition-templates", ...options });
1452
- }
1453
- getStepDefinitionTemplate(options) {
1454
- return (options.client ?? this.client).get({ url: "/api/step-definition-templates/{stepDefinitionTemplateId}", ...options });
1455
- }
1456
- instantiateStepDefinitionTemplate(options) {
1457
- return (options.client ?? this.client).post({
1458
- url: "/api/step-definition-templates/{stepDefinitionTemplateId}/instantiate",
1459
- ...options,
1460
- headers: {
1461
- "Content-Type": "application/json",
1462
- ...options.headers
1463
- }
1464
- });
1465
- }
1466
- }
1467
-
1468
1497
  class ProjectIntegrations extends HeyApiClient {
1469
1498
  listProjectIntegrations(options) {
1470
1499
  return (options.client ?? this.client).get({ url: "/api/projects/{projectId}/integrations", ...options });
@@ -1650,14 +1679,14 @@ class ScarnClient extends HeyApiClient {
1650
1679
  get userNotifications() {
1651
1680
  return this._userNotifications ??= new UserNotifications({ client: this.client });
1652
1681
  }
1682
+ _inbox;
1683
+ get inbox() {
1684
+ return this._inbox ??= new Inbox({ client: this.client });
1685
+ }
1653
1686
  _notificationRules;
1654
1687
  get notificationRules() {
1655
1688
  return this._notificationRules ??= new NotificationRules({ client: this.client });
1656
1689
  }
1657
- _stepDefinitionTemplates;
1658
- get stepDefinitionTemplates() {
1659
- return this._stepDefinitionTemplates ??= new StepDefinitionTemplates({ client: this.client });
1660
- }
1661
1690
  _projectIntegrations;
1662
1691
  get projectIntegrations() {
1663
1692
  return this._projectIntegrations ??= new ProjectIntegrations({ client: this.client });
@@ -1684,4 +1713,4 @@ class ScarnClient extends HeyApiClient {
1684
1713
  }
1685
1714
  }
1686
1715
 
1687
- export { createClient, Api, Projects, StepDefinitions, Tasks, TaskRuns, PipelineDefinitions, PipelineExecutions, WorkItems, Conversations, WorkItemComments, WorkItemCommentDrafts, WorkItemBlocks, ProjectArtifacts, UserNotifications, NotificationRules, StepDefinitionTemplates, ProjectIntegrations, GitHubIntegrations, ProjectInvites, Billing, Username, Secrets, ScarnClient };
1716
+ export { createClient, Api, Projects, StepDefinitions, Tasks, TaskRuns, PipelineDefinitions, PipelineExecutions, WorkItems, Conversations, WorkItemComments, WorkItemCommentDrafts, WorkItemBlocks, ProjectArtifacts, UserNotifications, Inbox, NotificationRules, ProjectIntegrations, GitHubIntegrations, ProjectInvites, Billing, Username, Secrets, ScarnClient };
@@ -9,7 +9,10 @@ var BUILT_IN_ERRORS = [
9
9
  "Scarn.MaxRunsExceeded",
10
10
  "Scarn.MaxTurnsExceeded",
11
11
  "Scarn.ConditionError",
12
- "Scarn.ArgsError"
12
+ "Scarn.ArgsError",
13
+ "Scarn.LogArchiveFailed",
14
+ "Scarn.WorkItemChangesInvalid",
15
+ "Scarn.WorkItemNotNative"
13
16
  ];
14
17
  var WAIT_ERRORS = [
15
18
  "Scarn.All",
@@ -24,7 +24,7 @@ import {
24
24
  REPLY_INPUT_SCHEMA,
25
25
  REPLY_RESULT_SCHEMA,
26
26
  decisionResultSchema
27
- } from "./chunk-dp86pa6m.js";
27
+ } from "./chunk-nb0nkt71.js";
28
28
  import {
29
29
  toJSONSchema
30
30
  } from "./chunk-skzxcba3.js";
@@ -919,6 +919,11 @@ var workItem = {
919
919
  return rootPlaceholder("workItem.title", {
920
920
  type: "string"
921
921
  });
922
+ },
923
+ get description() {
924
+ return rootPlaceholder("workItem.description", {
925
+ type: ["string", "null"]
926
+ });
922
927
  }
923
928
  };
924
929
  function workItemField(alias, label) {
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  PipelineDefinitions,
4
4
  createClient
5
- } from "./chunk-vfeytkqx.js";
5
+ } from "./chunk-8pyhrdgy.js";
6
6
  import {
7
7
  exports_external
8
8
  } from "./chunk-skzxcba3.js";
@@ -1,4 +1,8 @@
1
1
  // @bun
2
+ import {
3
+ stepHealthChecksInputSchema,
4
+ toolHealthCheckSchema
5
+ } from "./chunk-63f90zky.js";
2
6
  import {
3
7
  makeHandle,
4
8
  stepCall,
@@ -28,9 +32,9 @@ import {
28
32
  openCodeMcpRemoteConfigSchema
29
33
  } from "./chunk-e1h021kq.js";
30
34
  import {
31
- stepHealthChecksInputSchema,
32
- toolHealthCheckSchema
33
- } from "./chunk-63f90zky.js";
35
+ StepDefinitions,
36
+ createClient
37
+ } from "./chunk-8pyhrdgy.js";
34
38
  import {
35
39
  buildArtifactMarker
36
40
  } from "./chunk-ngy1fdcx.js";
@@ -39,11 +43,7 @@ import {
39
43
  } from "./chunk-y2pv8d6a.js";
40
44
  import {
41
45
  BUILT_IN_ERRORS
42
- } from "./chunk-dp86pa6m.js";
43
- import {
44
- StepDefinitions,
45
- createClient
46
- } from "./chunk-vfeytkqx.js";
46
+ } from "./chunk-nb0nkt71.js";
47
47
  import {
48
48
  $brand,
49
49
  $input,
@@ -1174,6 +1174,12 @@ function compileStepRetry(stepKey, retry, errors) {
1174
1174
  return { on: [...entry.on], maxAttempts: entry.maxAttempts };
1175
1175
  });
1176
1176
  }
1177
+ function compileStepMaxTurns(stepKey, maxTurns) {
1178
+ if (!Number.isInteger(maxTurns) || maxTurns <= 0) {
1179
+ throw new Error(`Step "${stepKey}": maxTurns must be a positive integer.`);
1180
+ }
1181
+ return maxTurns;
1182
+ }
1177
1183
  function toStepHandle(spec) {
1178
1184
  const node = stepNode(spec);
1179
1185
  const call = stepCall(node);
@@ -1242,14 +1248,16 @@ ${feature._promptAddition}` : feature._promptAddition;
1242
1248
  devcontainerConfigPath,
1243
1249
  ...managedRuntime !== null ? { managedRuntime } : {},
1244
1250
  prompt: effectivePrompt,
1245
- inputSchemaJson: config2.additionalInput ? toJSONSchema(config2.additionalInput) : null,
1251
+ inputSchemaJson: config2.input ? toJSONSchema(config2.input) : null,
1246
1252
  resultSchemaJson,
1247
1253
  opencodeMcpJson: mcpFields.opencodeMcpJson,
1248
1254
  healthChecksJson: mcpFields.healthChecksJson,
1249
1255
  envJson: mcpFields.envJson,
1250
1256
  ...repo !== undefined ? { repo } : {},
1251
1257
  errors: compileStepErrors(config2.key, config2.errors),
1252
- retryJson: compileStepRetry(config2.key, config2.retry, config2.errors ?? [])
1258
+ retryJson: compileStepRetry(config2.key, config2.retry, config2.errors ?? []),
1259
+ ...config2.maxTurns !== undefined ? { maxTurns: compileStepMaxTurns(config2.key, config2.maxTurns) } : {},
1260
+ ...config2.workItemPermissions !== undefined ? { workItemPermissions: [...config2.workItemPermissions] } : {}
1253
1261
  };
1254
1262
  return toStepHandle(spec);
1255
1263
  }
@@ -1343,6 +1351,8 @@ var buildStepDefinitionsClient = (stepDefinitions) => {
1343
1351
  on: [...entry.on],
1344
1352
  maxAttempts: entry.maxAttempts
1345
1353
  })),
1354
+ maxTurns: spec.maxTurns ?? null,
1355
+ workItemPermissions: [...spec.workItemPermissions ?? []],
1346
1356
  status: spec.status,
1347
1357
  projectId
1348
1358
  };
@@ -1453,4 +1463,4 @@ var Notify = {
1453
1463
  [NOTIFICATION_RESULT_KEY]: fragments.flatMap((fragment) => fragment[NOTIFICATION_RESULT_KEY])
1454
1464
  })
1455
1465
  };
1456
- export { ARTIFACT_BRAND, ArtifactTypes, normalizeArtifactAccept, artifact, Artifact, exports_z, createPromptInputProxy, createPromptTemplateContext, renderPromptTemplate, isSecretLookingEnvName, Env, normalizeEnv, Repo, compileRepo, Runtime, compileEnvironment, isMcpHandle, defineMcp, resolveMcpChecks, compileMcps, compileStepErrors, compileStepRetry, toStepHandle, toStepSpec, defineStep, codeStep, createStepDefinitionsClient, Features, Notify };
1466
+ export { ARTIFACT_BRAND, ArtifactTypes, normalizeArtifactAccept, artifact, Artifact, exports_z, createPromptInputProxy, createPromptTemplateContext, renderPromptTemplate, isSecretLookingEnvName, Env, normalizeEnv, Repo, compileRepo, Runtime, compileEnvironment, isMcpHandle, defineMcp, resolveMcpChecks, compileMcps, compileStepErrors, compileStepRetry, compileStepMaxTurns, toStepHandle, toStepSpec, defineStep, codeStep, createStepDefinitionsClient, Features, Notify };
package/dist/client.js CHANGED
@@ -2,12 +2,13 @@
2
2
  import {
3
3
  createScarnClient,
4
4
  createTaskPlaneClient
5
- } from "./chunk-700xe701.js";
5
+ } from "./chunk-2fn95pdd.js";
6
6
  import {
7
7
  Api,
8
8
  Billing,
9
9
  Conversations,
10
10
  GitHubIntegrations,
11
+ Inbox,
11
12
  NotificationRules,
12
13
  PipelineDefinitions,
13
14
  PipelineExecutions,
@@ -17,7 +18,6 @@ import {
17
18
  Projects,
18
19
  ScarnClient,
19
20
  Secrets,
20
- StepDefinitionTemplates,
21
21
  StepDefinitions,
22
22
  TaskRuns,
23
23
  Tasks,
@@ -27,13 +27,14 @@ import {
27
27
  WorkItemCommentDrafts,
28
28
  WorkItemComments,
29
29
  WorkItems
30
- } from "./chunk-vfeytkqx.js";
30
+ } from "./chunk-8pyhrdgy.js";
31
31
  import"./chunk-y64skrwp.js";
32
32
  export {
33
33
  Api,
34
34
  Billing,
35
35
  Conversations,
36
36
  GitHubIntegrations,
37
+ Inbox,
37
38
  NotificationRules,
38
39
  PipelineDefinitions,
39
40
  PipelineExecutions,
@@ -43,7 +44,6 @@ export {
43
44
  Projects,
44
45
  ScarnClient,
45
46
  Secrets,
46
- StepDefinitionTemplates,
47
47
  StepDefinitions,
48
48
  TaskRuns,
49
49
  Tasks,
@@ -3,7 +3,7 @@
3
3
  * the input a `reply` wait takes, and caught errors.
4
4
  */
5
5
  import type { JsonSchema } from "./json";
6
- export declare const BUILT_IN_ERRORS: readonly ["Scarn.All", "Scarn.StepFailed", "Scarn.HealthCheckFailed", "Scarn.Timeout", "Scarn.HeartbeatTimeout", "Scarn.MaxRunsExceeded", "Scarn.MaxTurnsExceeded", "Scarn.ConditionError", "Scarn.ArgsError"];
6
+ export declare const BUILT_IN_ERRORS: readonly ["Scarn.All", "Scarn.StepFailed", "Scarn.HealthCheckFailed", "Scarn.Timeout", "Scarn.HeartbeatTimeout", "Scarn.MaxRunsExceeded", "Scarn.MaxTurnsExceeded", "Scarn.ConditionError", "Scarn.ArgsError", "Scarn.LogArchiveFailed", "Scarn.WorkItemChangesInvalid", "Scarn.WorkItemNotNative"];
7
7
  /** The errors a wait node can raise, so the only names its `catch` may use. */
8
8
  export declare const WAIT_ERRORS: readonly ["Scarn.All", "Scarn.MaxRunsExceeded", "Scarn.ArgsError"];
9
9
  /**
@@ -47,7 +47,7 @@ import {
47
47
  REPLY_RESULT_SCHEMA,
48
48
  WAIT_ERRORS,
49
49
  decisionResultSchema
50
- } from "../../chunk-dp86pa6m.js";
50
+ } from "../../chunk-nb0nkt71.js";
51
51
  import"../../chunk-skzxcba3.js";
52
52
  import"../../chunk-y64skrwp.js";
53
53
  export {
@@ -0,0 +1,45 @@
1
+ export declare const WORK_ITEM_CHANGES_RELATIVE_PATH = ".scarn/work-item-changes.json";
2
+ /** At most this many items created in one run; the server checks it too. */
3
+ export declare const MAX_WORK_ITEMS_CREATED_PER_RUN = 10;
4
+ export declare const WORK_ITEM_CLOSE_REASONS: readonly ["completed", "out_of_scope", "superseded"];
5
+ export type WorkItemCloseReason = (typeof WORK_ITEM_CLOSE_REASONS)[number];
6
+ export type WorkItemChange = {
7
+ kind: "create";
8
+ workItemId: string;
9
+ title: string;
10
+ description: string;
11
+ fields?: Record<string, unknown>;
12
+ blockedBy?: string[];
13
+ } | {
14
+ kind: "block";
15
+ blockedWorkItemId: string;
16
+ blockingWorkItemId: string;
17
+ remove?: boolean;
18
+ } | {
19
+ kind: "describe";
20
+ workItemId: string;
21
+ description: string;
22
+ descriptionVersion: number;
23
+ } | {
24
+ kind: "comment";
25
+ workItemId: string;
26
+ body: string;
27
+ } | {
28
+ kind: "close";
29
+ workItemId: string;
30
+ reason: WorkItemCloseReason;
31
+ resolution?: string | null;
32
+ } | {
33
+ kind: "startTask";
34
+ workItemId: string;
35
+ stepKey: string;
36
+ };
37
+ export declare function buildWorkItemChangesPath(workspacePath: string): string;
38
+ /** The changes recorded so far; a missing file means none. */
39
+ export declare function readWorkItemChanges(workspacePath: string): Promise<WorkItemChange[]>;
40
+ export declare function appendWorkItemChange(workspacePath: string, change: WorkItemChange): Promise<WorkItemChange[]>;
41
+ /**
42
+ * Deletes the file. Called when a run's workspace is set up, so changes
43
+ * committed on an earlier step's branch are never sent again.
44
+ */
45
+ export declare function removeWorkItemChanges(workspacePath: string): Promise<void>;
@@ -0,0 +1,67 @@
1
+ // @bun
2
+ import {
3
+ exports_external
4
+ } from "../chunk-skzxcba3.js";
5
+ import"../chunk-y64skrwp.js";
6
+
7
+ // src/contracts/work-item-changes.ts
8
+ import { mkdir, readFile, rm, writeFile } from "fs/promises";
9
+ import path from "path";
10
+ var WORK_ITEM_CHANGES_RELATIVE_PATH = ".scarn/work-item-changes.json";
11
+ var MAX_WORK_ITEMS_CREATED_PER_RUN = 10;
12
+ var WORK_ITEM_CLOSE_REASONS = [
13
+ "completed",
14
+ "out_of_scope",
15
+ "superseded"
16
+ ];
17
+ var workItemChangesFileSchema = exports_external.object({
18
+ changes: exports_external.array(exports_external.looseObject({
19
+ kind: exports_external.enum([
20
+ "create",
21
+ "block",
22
+ "describe",
23
+ "comment",
24
+ "close",
25
+ "startTask"
26
+ ])
27
+ }))
28
+ });
29
+ function buildWorkItemChangesPath(workspacePath) {
30
+ return path.join(workspacePath, WORK_ITEM_CHANGES_RELATIVE_PATH);
31
+ }
32
+ async function readWorkItemChanges(workspacePath) {
33
+ let raw;
34
+ try {
35
+ raw = await readFile(buildWorkItemChangesPath(workspacePath), "utf8");
36
+ } catch (error) {
37
+ if (error.code === "ENOENT") {
38
+ return [];
39
+ }
40
+ throw error;
41
+ }
42
+ const parsed = workItemChangesFileSchema.safeParse(JSON.parse(raw));
43
+ if (!parsed.success) {
44
+ throw new Error(`${WORK_ITEM_CHANGES_RELATIVE_PATH} is malformed: ${parsed.error.message}`);
45
+ }
46
+ return parsed.data.changes;
47
+ }
48
+ async function appendWorkItemChange(workspacePath, change) {
49
+ const changes = [...await readWorkItemChanges(workspacePath), change];
50
+ const filePath = buildWorkItemChangesPath(workspacePath);
51
+ await mkdir(path.dirname(filePath), { recursive: true });
52
+ await writeFile(filePath, `${JSON.stringify({ changes }, null, 2)}
53
+ `, "utf8");
54
+ return changes;
55
+ }
56
+ async function removeWorkItemChanges(workspacePath) {
57
+ await rm(buildWorkItemChangesPath(workspacePath), { force: true });
58
+ }
59
+ export {
60
+ MAX_WORK_ITEMS_CREATED_PER_RUN,
61
+ WORK_ITEM_CHANGES_RELATIVE_PATH,
62
+ WORK_ITEM_CLOSE_REASONS,
63
+ appendWorkItemChange,
64
+ buildWorkItemChangesPath,
65
+ readWorkItemChanges,
66
+ removeWorkItemChanges
67
+ };
@@ -4,8 +4,8 @@ import {
4
4
  } from "../chunk-rt9tq4j6.js";
5
5
  import {
6
6
  createScarnClient
7
- } from "../chunk-700xe701.js";
8
- import"../chunk-vfeytkqx.js";
7
+ } from "../chunk-2fn95pdd.js";
8
+ import"../chunk-8pyhrdgy.js";
9
9
  import"../chunk-y64skrwp.js";
10
10
 
11
11
  // src/defaults/auth-file.ts
@@ -9,8 +9,8 @@ import {
9
9
  isDefaultPipelineAssignmentSpec,
10
10
  resolveWorkItemFieldPath,
11
11
  serializeDefaultPipelineAssignment
12
- } from "../../chunk-zm72ksz0.js";
13
- import"../../chunk-vfeytkqx.js";
12
+ } from "../../chunk-ra53p0v8.js";
13
+ import"../../chunk-8pyhrdgy.js";
14
14
  import"../../chunk-skzxcba3.js";
15
15
  import"../../chunk-y64skrwp.js";
16
16
  export {
@@ -9,6 +9,7 @@ import type { EnvRecord, PromptEnvContext } from "./env";
9
9
  import { type StepEnvironment } from "./runtime";
10
10
  import type { McpHandle } from "./define-mcp";
11
11
  import type { BuiltInError, ConversationResult } from "../../pipelines/types";
12
+ import type { PutApiStepDefinitionsData } from "../../generated/types.gen";
12
13
  import { type StepHandle } from "./step-handle";
13
14
  type Prettify<T> = {
14
15
  [K in keyof T]: T[K];
@@ -26,7 +27,7 @@ export type DefineStepInput<TInput extends ZodType = ZodType, TResult extends Zo
26
27
  */
27
28
  environment?: StepEnvironment<TInput["_output"], TEnv, TResult["_output"]>;
28
29
  agentPrompt: string | ((context: PromptTemplateContext<TInput["_output"], PromptEnvContext<TEnv>>) => string);
29
- additionalInput?: TInput;
30
+ input?: TInput;
30
31
  result?: TResult;
31
32
  features?: AnyStepFeature[];
32
33
  /**
@@ -53,7 +54,17 @@ export type DefineStepInput<TInput extends ZodType = ZodType, TResult extends Zo
53
54
  * step uses its node's `.retry(...)` instead.
54
55
  */
55
56
  retry?: readonly StepRetryEntry[];
57
+ /**
58
+ * How many times a standalone Task of this step may hand over. Omitted
59
+ * means the server default. A pipeline step uses its node's
60
+ * `.settings({ maxTurns })` instead.
61
+ */
62
+ maxTurns?: number;
63
+ /** Work item permissions the step's Tasks get on top of `self`. */
64
+ workItemPermissions?: readonly WorkItemPermission[];
56
65
  };
66
+ /** A work item permission a step's Tasks may be granted. */
67
+ export type WorkItemPermission = NonNullable<PutApiStepDefinitionsData["body"]["workItemPermissions"]>[number];
57
68
  /** One `retry` entry: the same shape as a pipeline node's `retry`. */
58
69
  export type StepRetryEntry = {
59
70
  on: readonly string[];
@@ -104,6 +115,10 @@ export type StepDefinitionSpec = {
104
115
  * the handle's pipeline chain method.
105
116
  */
106
117
  retryJson?: StepRetryEntry[];
118
+ /** How many times a standalone Task of this step may hand over; omitted means the server default. */
119
+ maxTurns?: number;
120
+ /** Work item permissions the step's Tasks get on top of `self`. */
121
+ workItemPermissions?: readonly WorkItemPermission[];
107
122
  /**
108
123
  * `kind === "code"` only: the live function of a spec produced by
109
124
  * `codeStep()`. Code-step discovery (`findCodeStepInModule`) reads it to
@@ -14,6 +14,7 @@ import {
14
14
  compileMcps,
15
15
  compileRepo,
16
16
  compileStepErrors,
17
+ compileStepMaxTurns,
17
18
  compileStepRetry,
18
19
  createPromptInputProxy,
19
20
  createPromptTemplateContext,
@@ -29,18 +30,18 @@ import {
29
30
  resolveMcpChecks,
30
31
  toStepHandle,
31
32
  toStepSpec
32
- } from "../../chunk-3ctaaseb.js";
33
+ } from "../../chunk-x9788y82.js";
34
+ import"../../chunk-63f90zky.js";
33
35
  import"../../chunk-mz53r914.js";
34
36
  import"../../chunk-5zsavw98.js";
35
37
  import"../../chunk-4ggr8af6.js";
36
38
  import"../../chunk-k4y5qt4y.js";
37
39
  import"../../chunk-cdanncng.js";
38
40
  import"../../chunk-e1h021kq.js";
39
- import"../../chunk-63f90zky.js";
41
+ import"../../chunk-8pyhrdgy.js";
40
42
  import"../../chunk-ngy1fdcx.js";
41
43
  import"../../chunk-y2pv8d6a.js";
42
- import"../../chunk-dp86pa6m.js";
43
- import"../../chunk-vfeytkqx.js";
44
+ import"../../chunk-nb0nkt71.js";
44
45
  import"../../chunk-skzxcba3.js";
45
46
  import"../../chunk-y64skrwp.js";
46
47
  export {
@@ -58,6 +59,7 @@ export {
58
59
  compileMcps,
59
60
  compileRepo,
60
61
  compileStepErrors,
62
+ compileStepMaxTurns,
61
63
  compileStepRetry,
62
64
  createPromptInputProxy,
63
65
  createPromptTemplateContext,
@@ -32,6 +32,8 @@ declare const buildStepDefinitionsClient: (stepDefinitions: StepDefinitions) =>
32
32
  on: Array<string>;
33
33
  maxAttempts: number;
34
34
  }>;
35
+ workItemPermissions: Array<"self" | "children">;
36
+ maxTurns: number | unknown;
35
37
  opencodeMcpJson: {
36
38
  [key: string]: {
37
39
  type: string;
@@ -158,6 +160,8 @@ declare const buildStepDefinitionsClient: (stepDefinitions: StepDefinitions) =>
158
160
  on: Array<string>;
159
161
  maxAttempts: number;
160
162
  }>;
163
+ workItemPermissions: Array<"self" | "children">;
164
+ maxTurns: number | unknown;
161
165
  opencodeMcpJson: {
162
166
  [key: string]: {
163
167
  type: string;
@@ -294,6 +298,8 @@ declare const buildStepDefinitionsClient: (stepDefinitions: StepDefinitions) =>
294
298
  on: Array<string>;
295
299
  maxAttempts: number;
296
300
  }>;
301
+ workItemPermissions: Array<"self" | "children">;
302
+ maxTurns: number | unknown;
297
303
  opencodeMcpJson: {
298
304
  [key: string]: {
299
305
  type: string;
@@ -12,6 +12,8 @@ export declare function compileStepErrors(stepKey: string, errors: readonly stri
12
12
  * is a positive integer.
13
13
  */
14
14
  export declare function compileStepRetry(stepKey: string, retry: readonly StepRetryEntry[] | undefined, errors: readonly string[]): StepRetryEntry[];
15
+ /** Checks a step's `maxTurns` the way the server does on upsert: a positive integer. */
16
+ export declare function compileStepMaxTurns(stepKey: string, maxTurns: number): number;
15
17
  /**
16
18
  * Wraps a compiled spec in a callable handle. `name` is set with
17
19
  * `Object.defineProperty` because a function's own `name` is read-only. The