@kitman-sh/cli 0.45.0 → 0.47.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.
@@ -1,4 +1,10 @@
1
1
  // @bun
2
+ import {
3
+ FileSystem,
4
+ Path,
5
+ optionalEnv,
6
+ tempDirectoryScoped
7
+ } from "./chunk-xajmb07d.js";
2
8
  import {
3
9
  Reference,
4
10
  TaggedError,
@@ -26,20 +32,14 @@ import {
26
32
  encodePrettyJsonString,
27
33
  decodeJsonStringSync
28
34
  } from "./chunk-k462v2v7.js";
29
- import {
30
- FileSystem,
31
- Path,
32
- optionalEnv,
33
- tempDirectoryScoped
34
- } from "./chunk-5smh4dp2.js";
35
35
  import {
36
36
  AgentHarnessIds,
37
37
  sha2562,
38
38
  runCommand2
39
- } from "./chunk-69y8j7fs.js";
39
+ } from "./chunk-qvvph24z.js";
40
40
  import {
41
41
  NpmRegistry
42
- } from "./chunk-es6rnmyw.js";
42
+ } from "./chunk-e2dszepq.js";
43
43
 
44
44
  // packages/agent-runtime/src/config-convergence.ts
45
45
  var writeAgentEnvironmentConfigFile2 = fnUntraced(function* (file, content, keep = {}) {
@@ -9,7 +9,7 @@ import {
9
9
  } from "./chunk-k462v2v7.js";
10
10
  import {
11
11
  runForEach
12
- } from "./chunk-5smh4dp2.js";
12
+ } from "./chunk-xajmb07d.js";
13
13
  import {
14
14
  WebSocketConstructor,
15
15
  layerWebSocketConstructorGlobal,
@@ -19,13 +19,13 @@ import {
19
19
  RunnerReplicaRpcs,
20
20
  RunnerRunFileRpcs,
21
21
  ProgramRpcs
22
- } from "./chunk-69y8j7fs.js";
22
+ } from "./chunk-qvvph24z.js";
23
23
  import {
24
24
  layerJson,
25
25
  make3,
26
26
  withHeaders,
27
27
  layerProtocolSocket
28
- } from "./chunk-f957cxrx.js";
28
+ } from "./chunk-dh7ewhqd.js";
29
29
 
30
30
  // packages/live/src/rpc/runner-client.ts
31
31
  var proxiedWebSocket = (proxy) => succeed5(WebSocketConstructor)((target) => {
@@ -122,7 +122,11 @@ import {
122
122
  withDefault,
123
123
  option,
124
124
  String2
125
- } from "./chunk-5smh4dp2.js";
125
+ } from "./chunk-xajmb07d.js";
126
+ import {
127
+ ChildProcessSpawner,
128
+ make2
129
+ } from "./chunk-zr1kvjzj.js";
126
130
  import {
127
131
  SecureRandom,
128
132
  layerWebCrypto,
@@ -160,6 +164,7 @@ import {
160
164
  outlineText,
161
165
  outlineMermaid,
162
166
  runOutlineText,
167
+ answerAccepts,
163
168
  RunDisplayStates,
164
169
  RunnerExecutionBackend,
165
170
  PinnedImage,
@@ -252,11 +257,7 @@ import {
252
257
  harnessNames,
253
258
  herdrRunnerCapabilities2,
254
259
  declaredChecks
255
- } from "./chunk-69y8j7fs.js";
256
- import {
257
- ChildProcessSpawner,
258
- make2
259
- } from "./chunk-fqh4pj6b.js";
260
+ } from "./chunk-qvvph24z.js";
260
261
  import {
261
262
  Id,
262
263
  Timestamp
@@ -1328,10 +1329,10 @@ var sandboxMissing = (sandbox, missing) => ({
1328
1329
  var personalCheckBackend = (agentSandbox, dockerAvailable) => agentSandbox === "srt" || agentSandbox === "docker" && dockerAvailable ? agentSandbox : undefined;
1329
1330
  var herdrCoreSession = (runnerId, personal) => personal ? undefined : `kitman-${sha2562(runnerId).slice(0, 16)}`;
1330
1331
  var OpenHerdrCore = Reference("kitman/cli/OpenHerdrCore", {
1331
- defaultValue: () => (options) => flatMap3(promise(() => import("./chunk-k7eh8tac.js")), ({ HerdrCore, herdrCoreLayer }) => provide3(service(HerdrCore), herdrCoreLayer(options)))
1332
+ defaultValue: () => (options) => flatMap3(promise(() => import("./chunk-c3m48dge.js")), ({ HerdrCore, herdrCoreLayer }) => provide3(service(HerdrCore), herdrCoreLayer(options)))
1332
1333
  });
1333
1334
  var UpdateHerdrCore = Reference("kitman/cli/UpdateHerdrCore", {
1334
- defaultValue: () => (options) => flatMap3(promise(() => import("./chunk-k7eh8tac.js")), (module) => module.updateHerdrCore(options))
1335
+ defaultValue: () => (options) => flatMap3(promise(() => import("./chunk-c3m48dge.js")), (module) => module.updateHerdrCore(options))
1335
1336
  });
1336
1337
  var herdrCoreMissing = (error) => {
1337
1338
  if (isTagged(error, "HerdrCoreMissing"))
@@ -1798,7 +1799,7 @@ var syncTargets = (harness) => gen(function* () {
1798
1799
  });
1799
1800
  var syncKits = (input) => gen(function* () {
1800
1801
  const fs = yield* FileSystem;
1801
- const { syncKitSetup } = yield* promise(() => import("./chunk-zx86g3dw.js"));
1802
+ const { syncKitSetup } = yield* promise(() => import("./chunk-nsw1wykj.js"));
1802
1803
  const harnesses = yield* syncTargets(input.harness);
1803
1804
  const chain = yield* input.client.getKitChain(input.workspaceId);
1804
1805
  for (const { name, problem } of chain.skipped)
@@ -2007,13 +2008,14 @@ var questionLines = (question) => {
2007
2008
  }),
2008
2009
  ...recommended !== undefined && !options.includes(recommended) ? [` Recommended: ${recommended}`, ...reason === undefined ? [] : [indent(`Why: ${reason}`, " ")]] : [],
2009
2010
  ...question.informationOnly === true && reason !== undefined ? [` No recommendation: ${reason}`] : [],
2010
- ...options.length > 0 && question.freeText === true ? [" Or answer in your own words."] : []
2011
+ ...options.length > 0 && question.freeText === true ? [" Or answer in your own words."] : [],
2012
+ ...question.answerSchema === undefined ? [] : [indent(`Answer in JSON: ${answerAccepts(question.answerSchema)}`, " ")]
2011
2013
  ];
2012
2014
  };
2013
2015
  var answerPrompt = (question) => {
2014
2016
  const count = question.options?.length ?? 0;
2015
- const choices = count === 0 ? "Your answer" : `Answer 1${count === 1 ? "" : `-${count}`}`;
2016
2017
  const recommended = enterAnswer(question);
2018
+ const choices = count > 0 ? `Answer 1${count === 1 ? "" : `-${count}`}` : question.answerSchema === undefined ? "Your answer" : "Your answer, in JSON";
2017
2019
  return `${choices}${recommended === undefined ? "" : `, Enter for ${recommended}`}: `;
2018
2020
  };
2019
2021
  var readReply = (question, typed) => {
@@ -3293,7 +3295,7 @@ var shipped_steps_generated_default = {
3293
3295
  };
3294
3296
 
3295
3297
  // apps/cli/src/scaffold-files.ts
3296
- var cliVersion = "0.45.0";
3298
+ var cliVersion = "0.47.0";
3297
3299
  var shippedLoopSteps = new Map(Object.entries(shipped_steps_generated_default));
3298
3300
  var loopSteps = (loop) => shippedLoopSteps.get(loop) ?? [];
3299
3301
  var replacedStep = (loop) => loopSteps(loop).find((step) => step.from === defaultKitName && step.exported?.startsWith("steps.") === true);
@@ -3558,7 +3560,7 @@ var scaffoldKit = (directory, scaffold = {}) => gen(function* () {
3558
3560
 
3559
3561
  // apps/cli/src/commands.ts
3560
3562
  var ClientId = "kitman-cli";
3561
- var agentRuntime = promise(() => import("./chunk-tx9aey19.js"));
3563
+ var agentRuntime = promise(() => import("./chunk-6k9tx4pd.js"));
3562
3564
  var TuiLauncher = Reference("kitman/cli/TuiLauncher", {
3563
3565
  defaultValue: () => gen(function* () {
3564
3566
  const tui = yield* tryPromise({
@@ -5097,7 +5099,7 @@ var SandboxHostProbe = Reference("kitman/cli/SandboxHostProbe", {
5097
5099
  });
5098
5100
  var OpenRunnerRpc = Reference("kitman/cli/OpenRunnerRpc", {
5099
5101
  defaultValue: () => (options) => gen(function* () {
5100
- const { makeRunnerRpcClient, runnerRpcUrl, runnerWebSocketProtocol } = yield* promise(() => import("./chunk-yyz9xrc1.js"));
5102
+ const { makeRunnerRpcClient, runnerRpcUrl, runnerWebSocketProtocol } = yield* promise(() => import("./chunk-8qvgey5g.js"));
5101
5103
  return yield* makeRunnerRpcClient({
5102
5104
  runnerId: options.runnerId,
5103
5105
  bearer: options.bearer,
@@ -5709,7 +5711,7 @@ function mcpCommand(args) {
5709
5711
  if (command.action === "run") {
5710
5712
  if (command.args.length > 0)
5711
5713
  return yield* new CliError({ message: `Unknown command: ${args.join(" ")}` });
5712
- const { runMcpServerCommand } = yield* promise(() => import("./chunk-fmvdwf5h.js"));
5714
+ const { runMcpServerCommand } = yield* promise(() => import("./chunk-jadpg7nn.js"));
5713
5715
  return yield* runMcpServerCommand({ flags: command.flags });
5714
5716
  }
5715
5717
  if (command.action !== "setup")
@@ -6209,7 +6211,7 @@ function programLoopCommand(command) {
6209
6211
  return yield* new CliError({ message: `Unknown loop command: ${command.action}` });
6210
6212
  });
6211
6213
  }
6212
- var docsModule = promise(() => import("./chunk-e3dv8hzy.js"));
6214
+ var docsModule = promise(() => import("./chunk-vnfyq39n.js"));
6213
6215
  function docsCommand(args) {
6214
6216
  return gen(function* () {
6215
6217
  const command = parseCommand(args);
@@ -6454,18 +6456,25 @@ var launchContext = (flags) => gen(function* () {
6454
6456
  };
6455
6457
  });
6456
6458
  var questionLines2 = (questions) => questions.flatMap(questionLines);
6459
+ var refusedReplies = new Set(["answer_not_accepted", "answer_not_offered"]);
6457
6460
  var answerInTerminal = (client, runId, questions) => forEach(questions, (question, index) => gen(function* () {
6458
6461
  const progress = questions.length > 1 ? [`(${index + 1} of ${questions.length})`] : [];
6459
6462
  yield* forEach([...progress, ...questionLines(question)], (line) => log(line), {
6460
6463
  discard: true
6461
6464
  });
6462
- let reply = readReply(question, yield* promptLine(answerPrompt(question)));
6463
- while ("retry" in reply) {
6464
- yield* log(` ${reply.retry}`);
6465
- reply = readReply(question, yield* promptLine(answerPrompt(question)));
6465
+ for (;; ) {
6466
+ let reply = readReply(question, yield* promptLine(answerPrompt(question)));
6467
+ while ("retry" in reply) {
6468
+ yield* log(` ${reply.retry}`);
6469
+ reply = readReply(question, yield* promptLine(answerPrompt(question)));
6470
+ }
6471
+ const key = yield* idempotencyKey(undefined, "run-answer");
6472
+ const { answer } = reply;
6473
+ const refused = yield* client.answerRun(runId, { value: answer, question: question.id, idempotencyKey: key }).pipe(andThen2(log(`Answered ${question.stepKey}: ${answer}`)), as(undefined), catchIf((error) => error instanceof KitmanClientError && error.code === "question_not_open", (error) => log(`Not answered: ${question.stepKey} was settled while it waited here. ${error.responseMessage ?? error.message}`).pipe(as(undefined))), catchIf((error) => error instanceof KitmanClientError && refusedReplies.has(error.code ?? ""), (error) => succeed6(error instanceof KitmanClientError ? error.responseMessage ?? error.message : "")));
6474
+ if (refused === undefined)
6475
+ return;
6476
+ yield* log(` ${refused}`);
6466
6477
  }
6467
- const key = yield* idempotencyKey(undefined, "run-answer");
6468
- yield* client.answerRun(runId, { value: reply.answer, question: question.id, idempotencyKey: key }).pipe(andThen2(log(`Answered ${question.stepKey}: ${reply.answer}`)), catchIf((error) => error instanceof KitmanClientError && error.code === "question_not_open", (error) => log(`Not answered: ${question.stepKey} was settled while it waited here. ${error.responseMessage ?? error.message}`)));
6469
6478
  }), { discard: true });
6470
6479
  var claimLines = (step) => step.output === undefined ? [] : isJsonObject(toJsonValue(step.output)) ? Object.entries(toJsonObject(step.output)).map(([field, value]) => ` Claim ${field}: ${isString2(value) ? value : encodeJsonStringSync(value)}`) : [` Claim: ${encodeJsonStringSync(toJsonValue(step.output))}`];
6471
6480
  var evidenceLines = (evidence) => evidence.flatMap((entry) => {
@@ -7213,7 +7222,7 @@ function changeRequestCommand(args) {
7213
7222
  yield* log(command.action === "approve" ? `Approved ${short} of ${changeRequest.title}. A Run waiting on approval of ${short} resumes; one waiting on another head does not.` : `Requested changes to ${short} of ${changeRequest.title}`);
7214
7223
  });
7215
7224
  }
7216
- var readOutlines = (directory) => flatMap3(promise(() => import("./chunk-tqv14b4c.js")), (build) => build.readOutlines(directory)).pipe(mapError2((error) => new CliError({ message: error.message })));
7225
+ var readOutlines = (directory) => flatMap3(promise(() => import("./chunk-tf1ctv78.js")), (build) => build.readOutlines(directory)).pipe(mapError2((error) => new CliError({ message: error.message })));
7217
7226
  var loopOutline = (command) => gen(function* () {
7218
7227
  const path = yield* Path;
7219
7228
  const loop = requiredArg(command, "a Loop id");
@@ -7233,9 +7242,9 @@ var loopOutline = (command) => gen(function* () {
7233
7242
  `).pipe(mapError2((error) => new CliError({ message: error.message })));
7234
7243
  yield* log(`Wrote the outline of ${loop} to ${out}`);
7235
7244
  });
7236
- var KitWriter = map9(promise(() => import("./chunk-tqv14b4c.js")), (build) => build.writeKit);
7245
+ var KitWriter = map9(promise(() => import("./chunk-tf1ctv78.js")), (build) => build.writeKit);
7237
7246
  var KitBuilder = Reference("kitman/cli/KitBuilder", {
7238
- defaultValue: () => (directory) => flatMap3(promise(() => import("./chunk-tqv14b4c.js")), (build) => build.buildKit(directory))
7247
+ defaultValue: () => (directory) => flatMap3(promise(() => import("./chunk-tf1ctv78.js")), (build) => build.buildKit(directory))
7239
7248
  });
7240
7249
  var uploadKit = (client, workspaceId, built) => gen(function* () {
7241
7250
  yield* client.uploadKitBundle(workspaceId, built.digest, { bundle: encode2(built.bundle) });
@@ -187,6 +187,57 @@ import {
187
187
  encodeUnknownJsonStringSync,
188
188
  storable
189
189
  } from "./chunk-k462v2v7.js";
190
+ import {
191
+ empty2,
192
+ currentTimeMillis,
193
+ join,
194
+ interrupt,
195
+ interruptAll,
196
+ unbounded,
197
+ publishUnsafe,
198
+ unbounded2,
199
+ offer,
200
+ makeUnsafe3,
201
+ make10,
202
+ fromQueue,
203
+ fromPubSub,
204
+ map2,
205
+ filter,
206
+ take2,
207
+ mapAccum,
208
+ decodeText,
209
+ encodeText,
210
+ splitLines,
211
+ run,
212
+ runCollect,
213
+ runFold,
214
+ runHead,
215
+ runForEach,
216
+ FileSystem,
217
+ Path,
218
+ embeddedFile,
219
+ extractEmbeddedFile,
220
+ withDefault,
221
+ String2,
222
+ optionalEnv,
223
+ operatorConfigHome,
224
+ tempDirectoryScoped,
225
+ harnessesUnsupportedInSrt2,
226
+ harnessesUnsupportedInDocker2,
227
+ compiled2,
228
+ pinnedSrtCommand2,
229
+ pinnedSrtStepCommand2,
230
+ runSrtCli2,
231
+ kitmanCacheDirectory2,
232
+ srtSettings2,
233
+ srtCacheEnvironment2,
234
+ srtInheritedEnv2,
235
+ inheritedEnvironment2,
236
+ withOnlyEnvironment2,
237
+ writeSrtSettings2,
238
+ srtStepArgv2,
239
+ srtArgv2
240
+ } from "./chunk-xajmb07d.js";
190
241
  import {
191
242
  SecureRandom,
192
243
  layerWebCrypto,
@@ -276,58 +327,7 @@ import {
276
327
  checkServicesFile,
277
328
  checkServices,
278
329
  serviceChecks
279
- } from "./chunk-69y8j7fs.js";
280
- import {
281
- empty2,
282
- currentTimeMillis,
283
- join,
284
- interrupt,
285
- interruptAll,
286
- unbounded,
287
- publishUnsafe,
288
- unbounded2,
289
- offer,
290
- makeUnsafe3,
291
- make10,
292
- fromQueue,
293
- fromPubSub,
294
- map2,
295
- filter,
296
- take2,
297
- mapAccum,
298
- decodeText,
299
- encodeText,
300
- splitLines,
301
- run,
302
- runCollect,
303
- runFold,
304
- runHead,
305
- runForEach,
306
- FileSystem,
307
- Path,
308
- embeddedFile,
309
- extractEmbeddedFile,
310
- withDefault,
311
- String2,
312
- optionalEnv,
313
- operatorConfigHome,
314
- tempDirectoryScoped,
315
- harnessesUnsupportedInSrt2,
316
- harnessesUnsupportedInDocker2,
317
- compiled2,
318
- pinnedSrtCommand2,
319
- pinnedSrtStepCommand2,
320
- runSrtCli2,
321
- kitmanCacheDirectory2,
322
- srtSettings2,
323
- srtCacheEnvironment2,
324
- srtInheritedEnv2,
325
- inheritedEnvironment2,
326
- withOnlyEnvironment2,
327
- writeSrtSettings2,
328
- srtStepArgv2,
329
- srtArgv2
330
- } from "./chunk-5smh4dp2.js";
330
+ } from "./chunk-qvvph24z.js";
331
331
  import {
332
332
  writeAgentEnvironmentConfigFile2,
333
333
  readManifestSkillPaths2,
@@ -343,8 +343,12 @@ import {
343
343
  applyAgentEnvironmentMaterialization2,
344
344
  isPathWithin2,
345
345
  skillIdentity2
346
- } from "./chunk-g26y214g.js";
347
- import"./chunk-es6rnmyw.js";
346
+ } from "./chunk-0hb5d4rz.js";
347
+ import"./chunk-e2dszepq.js";
348
+ import {
349
+ ChildProcessSpawner,
350
+ make2
351
+ } from "./chunk-zr1kvjzj.js";
348
352
  import {
349
353
  egressAllowed,
350
354
  writeSecretRegistry,
@@ -364,24 +368,20 @@ import {
364
368
  lookAtOpencode2,
365
369
  readOpencode2,
366
370
  databaseStamp2
367
- } from "./chunk-8gkrs473.js";
371
+ } from "./chunk-6ne389p2.js";
368
372
  import {
369
373
  uploadRunFile,
370
374
  programLease,
371
375
  rpcRunFiles,
372
376
  programHostsEnv,
373
377
  undeclaredHostsEnv
374
- } from "./chunk-5gbt1vhm.js";
375
- import"./chunk-0dfg674z.js";
378
+ } from "./chunk-cps0774f.js";
379
+ import"./chunk-0n9f624b.js";
376
380
  import {
377
381
  nextInt
378
382
  } from "./chunk-04wqa07j.js";
379
383
  import"./chunk-9ykh05hz.js";
380
- import {
381
- ChildProcessSpawner,
382
- make2
383
- } from "./chunk-fqh4pj6b.js";
384
- import"./chunk-f957cxrx.js";
384
+ import"./chunk-dh7ewhqd.js";
385
385
  import {
386
386
  Id,
387
387
  secretReference,
@@ -1,4 +1,12 @@
1
1
  // @bun
2
+ import {
3
+ currentTimeMillis,
4
+ make10,
5
+ runForEach,
6
+ toPull,
7
+ FileSystem,
8
+ compiled2
9
+ } from "./chunk-xajmb07d.js";
2
10
  import {
3
11
  isSome,
4
12
  getOrElse,
@@ -36,18 +44,10 @@ import {
36
44
  isString2,
37
45
  encodeUnknownJsonStringSync
38
46
  } from "./chunk-k462v2v7.js";
39
- import {
40
- currentTimeMillis,
41
- make10,
42
- runForEach,
43
- toPull,
44
- FileSystem,
45
- compiled2
46
- } from "./chunk-5smh4dp2.js";
47
47
  import {
48
48
  ChildProcessSpawner,
49
49
  make2
50
- } from "./chunk-fqh4pj6b.js";
50
+ } from "./chunk-zr1kvjzj.js";
51
51
 
52
52
  // packages/agent-runtime/src/opencode-store.ts
53
53
  import { lstatSync, readFileSync, realpathSync, writeSync } from "fs";
@@ -4,11 +4,11 @@ import {
4
4
  runnerRpcUrl2,
5
5
  makeRunnerRpcClient2,
6
6
  makeProgramRpcClient2
7
- } from "./chunk-0dfg674z.js";
8
- import"./chunk-f957cxrx.js";
9
- import"./chunk-69y8j7fs.js";
7
+ } from "./chunk-0n9f624b.js";
8
+ import"./chunk-dh7ewhqd.js";
9
+ import"./chunk-qvvph24z.js";
10
10
  import"./chunk-4vxbxjf8.js";
11
- import"./chunk-5smh4dp2.js";
11
+ import"./chunk-xajmb07d.js";
12
12
  import"./chunk-k462v2v7.js";
13
13
  export {
14
14
  makeProgramRpcClient2 as makeProgramRpcClient,
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-fqh4pj6b.js";
2
+ import"./chunk-zr1kvjzj.js";
3
3
  import {
4
4
  HERDR_CORE_GENERATION2,
5
5
  HERDR_CORE_INSTALL_COMMAND2,
@@ -12,8 +12,8 @@ import {
12
12
  herdrCoreLayer2,
13
13
  herdrCoreTransportLayer2,
14
14
  updateHerdrCore2
15
- } from "./chunk-69y8j7fs.js";
16
- import"./chunk-5smh4dp2.js";
15
+ } from "./chunk-qvvph24z.js";
16
+ import"./chunk-xajmb07d.js";
17
17
  import"./chunk-k462v2v7.js";
18
18
  export {
19
19
  HERDR_CORE_GENERATION2 as HERDR_CORE_GENERATION,
@@ -137,8 +137,15 @@ import {
137
137
  TaggedError2,
138
138
  toJsonSchemaDocument,
139
139
  toCodecJson,
140
- Json
140
+ Json,
141
+ encodeUnknownJsonStringSync
141
142
  } from "./chunk-k462v2v7.js";
143
+ import {
144
+ currentTimeMillis,
145
+ getCurrent,
146
+ runForEach,
147
+ FileSystem
148
+ } from "./chunk-xajmb07d.js";
142
149
  import {
143
150
  WebCrypto,
144
151
  makeUnsafe,
@@ -146,7 +153,11 @@ import {
146
153
  RepoBindingProvider,
147
154
  releaseVersion,
148
155
  ReleaseScope,
156
+ decodeAnswerSchema,
157
+ answerProblem,
158
+ answerValue,
149
159
  recommendedDefault,
160
+ isLoopSafeText,
150
161
  DeliveryMode,
151
162
  ProgramWorkUnit,
152
163
  MeasureEvidence,
@@ -175,13 +186,7 @@ import {
175
186
  StepManifest,
176
187
  KitSetup,
177
188
  RunnerRpcError
178
- } from "./chunk-69y8j7fs.js";
179
- import {
180
- currentTimeMillis,
181
- getCurrent,
182
- runForEach,
183
- FileSystem
184
- } from "./chunk-5smh4dp2.js";
189
+ } from "./chunk-qvvph24z.js";
185
190
  import {
186
191
  splitQuestionOptions,
187
192
  recommendationProblem,
@@ -1103,6 +1108,11 @@ var noteInBranches = (take) => map9(FirstBranches, (branches) => branches.forEac
1103
1108
  var agentDeferredNamed = (deferredName) => make2(deferredName, { success: Json, error: StepFailed });
1104
1109
  var syncDeferred = (step) => agentDeferredNamed(`sync/${step}`);
1105
1110
  var answerDeferred = (step) => make2(`ask/${step}`, { success: String4, error: StepFailed });
1111
+ var AnswerTakenBy = Literals(["person", "default", "auto"]);
1112
+ var structuredAnswerDeferred = (step) => make2(`ask/${step}`, {
1113
+ success: Struct({ answer: String4, by: AnswerTakenBy }),
1114
+ error: StepFailed
1115
+ });
1106
1116
  var eventDeferred = (step) => make2(`wait_for/${step}`, { success: LoopEvent, error: WaitTimedOut });
1107
1117
  var verifyDeferred = (step) => make2(`verify/${step}`, { success: VerifyResult, error: StepFailed });
1108
1118
  var recordStep = (name, kind, exit) => {
@@ -1184,14 +1194,22 @@ var submittedBy = (step, deferred, options) => gen(function* () {
1184
1194
  });
1185
1195
  var decodeOutput = (step, schema, submitted) => decodeEffect(toCodecJson(schema))(submitted).pipe(mapError2((error) => new OutputInvalid({ step, message: error.message })));
1186
1196
  var agentWorkAs = (deferredOf, name, options) => takeStep(name, "agent_work", "agent_work", (step) => flatMap3(submittedBy(step, deferredOf(step), options), (submitted) => decodeOutput(step, options.output, submitted)));
1187
- var ask = (name, question) => takeStep(name, "ask", "ask", (name) => gen(function* () {
1188
- const deferred = answerDeferred(name);
1189
- const offered = "options" in question ? splitQuestionOptions(question.options) : undefined;
1190
- const options = offered?.options;
1191
- const recommended = "recommended" in question ? question.recommended : undefined;
1192
- const informationOnly = "informationOnly" in question ? question.informationOnly : undefined;
1197
+ class Words {
1198
+ text;
1199
+ constructor(text) {
1200
+ this.text = text;
1201
+ }
1202
+ get blank() {
1203
+ return this.text.trim() === "";
1204
+ }
1205
+ toString() {
1206
+ return this.text;
1207
+ }
1208
+ }
1209
+ var putQuestion = (name, question, deferred) => gen(function* () {
1210
+ const { options, recommended, informationOnly } = question;
1193
1211
  const advice = questionAdvice({
1194
- ...offered,
1212
+ ...question.optionDescriptions === undefined ? undefined : { optionDescriptions: question.optionDescriptions },
1195
1213
  ...recommended === undefined ? undefined : { recommended },
1196
1214
  recommendationReason: question.recommendationReason,
1197
1215
  ...informationOnly === undefined ? undefined : { informationOnly }
@@ -1210,6 +1228,7 @@ var ask = (name, question) => takeStep(name, "ask", "ask", (name) => gen(functio
1210
1228
  step: name,
1211
1229
  prompt: question.prompt,
1212
1230
  ...options === undefined ? undefined : { options },
1231
+ ...question.answerSchema === undefined ? undefined : { answerSchema: question.answerSchema },
1213
1232
  ...advice,
1214
1233
  ...fallback === undefined ? undefined : { default: fallback },
1215
1234
  ...question.auto === undefined ? undefined : { auto: question.auto },
@@ -1218,15 +1237,62 @@ var ask = (name, question) => takeStep(name, "ask", "ask", (name) => gen(functio
1218
1237
  ...question.timeout === undefined ? undefined : { timeoutMillis: toMillis(fromInputUnsafe(question.timeout)) },
1219
1238
  token: token2
1220
1239
  }));
1221
- const answer = yield* await_(deferred);
1222
- if (options === undefined) {
1223
- return answer;
1224
- }
1225
- const offeredAnswer = options.find((option) => option === answer);
1226
- if (offeredAnswer === undefined)
1240
+ return yield* await_(deferred);
1241
+ });
1242
+ var askOptions = (name, question) => gen(function* () {
1243
+ const { options, optionDescriptions } = splitQuestionOptions(question.options);
1244
+ const answer = yield* putQuestion(name, { ...question, options, ...optionDescriptions === undefined ? undefined : { optionDescriptions } }, answerDeferred(name));
1245
+ if (!options.includes(answer))
1227
1246
  return yield* new QuestionRefused({ step: name, answer, options });
1228
- return offeredAnswer;
1229
- }));
1247
+ return answer;
1248
+ });
1249
+ var askStructured = (name, question) => gen(function* () {
1250
+ const read = decodeAnswerSchema(question.answer);
1251
+ if ("problem" in read)
1252
+ return yield* new StepFailed({ step: name, reason: read.problem });
1253
+ const { schema } = read;
1254
+ const declared = (what, value, stored) => {
1255
+ const answer = encodeUnknownJsonStringSync(value);
1256
+ const problem = stored && !isLoopSafeText(answer) ? "it is too long, or holds a credential" : answerProblem(schema, answer);
1257
+ return problem === undefined ? succeed6(answer) : fail7(new StepFailed({ step: name, reason: `The ${what} is refused: ${problem}` }));
1258
+ };
1259
+ const taken = yield* putQuestion(name, {
1260
+ prompt: question.prompt,
1261
+ answerSchema: schema,
1262
+ recommended: yield* declared("recommended answer", question.recommended, false),
1263
+ recommendationReason: question.recommendationReason,
1264
+ ...question.default === undefined ? undefined : { default: question.default === null ? null : yield* declared("default", question.default, true) },
1265
+ ...question.auto === undefined ? undefined : { auto: yield* declared("full-auto answer", question.auto, true) },
1266
+ ...question.unattendedAuto === undefined ? undefined : { unattendedAuto: yield* declared("full-auto answer", question.unattendedAuto, true) },
1267
+ ...question.evidence === undefined ? undefined : { evidence: question.evidence },
1268
+ ...question.timeout === undefined ? undefined : { timeout: question.timeout }
1269
+ }, structuredAnswerDeferred(name));
1270
+ const decoded = answerValue(schema, taken.answer);
1271
+ if (decoded === undefined)
1272
+ return yield* new QuestionRefused({ step: name, answer: taken.answer, options: [] });
1273
+ return { answer: decoded.value, by: taken.by };
1274
+ });
1275
+ function ask(name, question) {
1276
+ return takeStep(name, "ask", "ask", (name) => {
1277
+ const modes = [
1278
+ "options" in question && question.options !== undefined ? "options" : [],
1279
+ "answer" in question && question.answer !== undefined ? "answer" : [],
1280
+ "freeText" in question && question.freeText !== undefined ? "freeText" : []
1281
+ ].flat();
1282
+ if (modes.length === 1) {
1283
+ if ("options" in question && question.options !== undefined)
1284
+ return askOptions(name, question);
1285
+ if ("answer" in question && question.answer !== undefined)
1286
+ return askStructured(name, question);
1287
+ if ("freeText" in question && question.freeText === true)
1288
+ return map9(putQuestion(name, question, answerDeferred(name)), (text) => new Words(text));
1289
+ }
1290
+ return fail7(new StepFailed({
1291
+ step: name,
1292
+ reason: `A Question declares exactly one of options, answer or freeText: true; this one declares ${modes.length === 0 ? "none" : modes.join(" and ")}`
1293
+ }));
1294
+ });
1295
+ }
1230
1296
  var waitFor = (name, wait) => takeStep(name, "wait_for", undefined, (name) => gen(function* () {
1231
1297
  const deferred = eventDeferred(name);
1232
1298
  const timeoutMillis = toMillis(fromInputUnsafe(wait.timeout));
@@ -109,7 +109,7 @@ import {
109
109
  shutdownUnsafe,
110
110
  fromQueue,
111
111
  unwrap
112
- } from "./chunk-5smh4dp2.js";
112
+ } from "./chunk-xajmb07d.js";
113
113
  import {
114
114
  empty,
115
115
  fromInput,
@@ -123,7 +123,7 @@ import {
123
123
  ParseOptions,
124
124
  RpcClientDefect,
125
125
  RpcClientError
126
- } from "./chunk-69y8j7fs.js";
126
+ } from "./chunk-qvvph24z.js";
127
127
 
128
128
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/workers/Transferable.js
129
129
  class Collector extends (/* @__PURE__ */ Service2()("effect/workers/Transferable/Collector")) {
@@ -28,7 +28,7 @@ import {
28
28
  import {
29
29
  withDefault,
30
30
  String2
31
- } from "./chunk-5smh4dp2.js";
31
+ } from "./chunk-xajmb07d.js";
32
32
  import {
33
33
  newerKitmanVersion,
34
34
  digestSha256,
@@ -39,7 +39,7 @@ import {
39
39
  get2,
40
40
  layer4,
41
41
  KitDigest
42
- } from "./chunk-69y8j7fs.js";
42
+ } from "./chunk-qvvph24z.js";
43
43
 
44
44
  // packages/core/src/npm-registry.ts
45
45
  var KitManifest = Struct({