@kitman-sh/cli 0.10.52 → 0.10.54

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.
Files changed (31) hide show
  1. package/dist/{chunk-x9dhxfts.js → chunk-148mjppg.js} +5 -5
  2. package/dist/{chunk-mej2bx5n.js → chunk-19aqk325.js} +4 -4
  3. package/dist/{chunk-jafetf7z.js → chunk-3d6abgjh.js} +2 -2
  4. package/dist/{chunk-pp1p3g6e.js → chunk-4kssrezn.js} +6 -1
  5. package/dist/{chunk-ctasxxz5.js → chunk-5j3cxsnp.js} +10 -10
  6. package/dist/{chunk-7thnf14y.js → chunk-5y5axze6.js} +609 -6
  7. package/dist/{chunk-mbctzx7e.js → chunk-61k67vxh.js} +76 -1389
  8. package/dist/{chunk-arvwar2c.js → chunk-7evwar6b.js} +1 -1
  9. package/dist/{chunk-dre9z977.js → chunk-c0wrcam4.js} +31 -32
  10. package/dist/{chunk-eg8f5ncv.js → chunk-dkpqwk0q.js} +7 -7
  11. package/dist/{chunk-r8p3nxcp.js → chunk-eerh2t20.js} +10 -10
  12. package/dist/chunk-g7vk5tjp.js +1109 -0
  13. package/dist/{chunk-vjmz23rs.js → chunk-gwcqz1bj.js} +1 -1
  14. package/dist/{chunk-wh1pa2aa.js → chunk-m32wb6t0.js} +245 -108
  15. package/dist/{chunk-3bj7sc3v.js → chunk-mmetyep8.js} +7 -7
  16. package/dist/{chunk-30397r95.js → chunk-mtgkvbk4.js} +4 -4
  17. package/dist/{chunk-jagzz148.js → chunk-my987gxf.js} +20 -24
  18. package/dist/{chunk-dzh9e6n2.js → chunk-q0yna8sw.js} +52 -35
  19. package/dist/{chunk-6vns3ej0.js → chunk-rjfxnk05.js} +5 -5
  20. package/dist/{chunk-g5bs3f6z.js → chunk-twp7aprz.js} +4 -6
  21. package/dist/{chunk-x0b92bjb.js → chunk-vtn088tq.js} +6 -6
  22. package/dist/{chunk-b6thzgc9.js → chunk-wczs5vrq.js} +2 -2
  23. package/dist/{chunk-11p4wf6n.js → chunk-xgwjcq4z.js} +3 -3
  24. package/dist/{chunk-fpmwm9bp.js → chunk-y48wz1sa.js} +157 -33
  25. package/dist/index.js +4 -4
  26. package/package.json +1 -1
  27. package/dist/chunk-1mc9vgcr.js +0 -39
  28. package/dist/chunk-jfvq7s24.js +0 -145
  29. package/dist/chunk-txwt6r25.js +0 -1731
  30. package/dist/chunk-vyv0p5eq.js +0 -3183
  31. package/dist/chunk-z821b2gp.js +0 -164
@@ -0,0 +1,1109 @@
1
+ // @bun
2
+ import {
3
+ dual,
4
+ getOrElse,
5
+ Service2,
6
+ empty3,
7
+ add,
8
+ getOrUndefined2,
9
+ merge3,
10
+ TaggedClass,
11
+ TaggedError,
12
+ encode,
13
+ isSuccess2,
14
+ addFinalizerExit,
15
+ effectDiscard,
16
+ forEach,
17
+ promise,
18
+ tryPromise,
19
+ suspend3,
20
+ sync2,
21
+ void_3,
22
+ gen,
23
+ die3,
24
+ flatMap3,
25
+ andThen2,
26
+ tap2,
27
+ map8,
28
+ orDie,
29
+ context,
30
+ contextWith,
31
+ provideContext2,
32
+ provideService,
33
+ scoped,
34
+ acquireUseRelease,
35
+ uninterruptibleMask2,
36
+ annotateCurrentSpan,
37
+ withSpan,
38
+ fnUntraced,
39
+ makeFormatterStandardSchemaV1,
40
+ transform,
41
+ declare,
42
+ is,
43
+ encodeEffect,
44
+ isSchema,
45
+ optionalKey,
46
+ optional,
47
+ Literal,
48
+ Never,
49
+ Null,
50
+ String4,
51
+ Boolean2,
52
+ Void,
53
+ Struct,
54
+ Record,
55
+ ArraySchema,
56
+ NonEmptyArray,
57
+ Union,
58
+ Literals,
59
+ decodeTo2,
60
+ tag,
61
+ TaggedStruct,
62
+ makeFilter,
63
+ isPattern,
64
+ Finite,
65
+ isGreaterThanOrEqualTo,
66
+ isLessThanOrEqualTo,
67
+ Int,
68
+ isMinLength,
69
+ isMaxLength,
70
+ Defect,
71
+ fromJsonString,
72
+ Cause,
73
+ Class2,
74
+ TaggedError2,
75
+ toEquivalence,
76
+ toCodecJson,
77
+ Json
78
+ } from "./chunk-61k67vxh.js";
79
+ import {
80
+ guard
81
+ } from "./chunk-4kssrezn.js";
82
+ import {
83
+ currentTimeMillis,
84
+ WebCrypto,
85
+ SafeJson,
86
+ AgentSandboxNetwork,
87
+ AgentEfforts,
88
+ AgentCapabilities,
89
+ LoopDataSchemaRef,
90
+ LoopVersion,
91
+ ProgramLoop,
92
+ AgentFallback,
93
+ ProgramWorkUnit,
94
+ MeasureEvidence,
95
+ CatchUp,
96
+ RunFileRefused,
97
+ runFileContentType,
98
+ sha256Hasher,
99
+ put,
100
+ setHeaders,
101
+ bodyUint8Array,
102
+ filterStatusOk,
103
+ HttpClient,
104
+ KitName,
105
+ KitDigest,
106
+ KitSetup,
107
+ RunnerRpcError
108
+ } from "./chunk-m32wb6t0.js";
109
+ import {
110
+ runForEach,
111
+ FileSystem
112
+ } from "./chunk-xgwjcq4z.js";
113
+
114
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/crypto/internal/webCrypto.js
115
+ var subtleUnavailable = () => new Error("crypto.subtle is unavailable; browsers expose it only in secure contexts");
116
+
117
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/crypto/internal/digest.js
118
+ var webCryptoDigest = (crypto, algorithm, data) => {
119
+ const implementation = algorithm.implementation;
120
+ if (implementation !== undefined) {
121
+ return sync2(() => implementation(data));
122
+ }
123
+ return suspend3(() => {
124
+ const subtle = crypto?.subtle;
125
+ if (subtle === undefined)
126
+ return die3(subtleUnavailable());
127
+ return promise(async () => new Uint8Array(await subtle.digest(algorithm.name, data)));
128
+ });
129
+ };
130
+
131
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/crypto/Digest.js
132
+ var sha256 = {
133
+ name: "SHA-256",
134
+ outputLength: 32,
135
+ implementation: undefined
136
+ };
137
+
138
+ // packages/core/src/schedule.ts
139
+ var ScheduleFrequency = ["daily", "weekly"];
140
+ var ScheduleMisfirePolicies = ["skip", "fire_once", "catch_up"];
141
+ var ScheduleOverlapPolicies = ["allow", "skip", "coalesce"];
142
+ var ScheduleVersionStatuses = ["draft", "published", "disabled", "archived"];
143
+ var ScheduleCalendarRule = Struct({
144
+ frequency: Literals(ScheduleFrequency),
145
+ hour: Int.check(isGreaterThanOrEqualTo(0), isLessThanOrEqualTo(23)),
146
+ minute: Int.check(isGreaterThanOrEqualTo(0), isLessThanOrEqualTo(59)),
147
+ second: optionalKey(Int.check(isGreaterThanOrEqualTo(0), isLessThanOrEqualTo(59))),
148
+ daysOfWeek: optionalKey(ArraySchema(Int.check(isGreaterThanOrEqualTo(0), isLessThanOrEqualTo(6))).check(isMinLength(1), isMaxLength(7)))
149
+ });
150
+ var ScheduleCronRule = Struct({
151
+ cron: String4.check(isMinLength(9), isMaxLength(200), isPattern(new RegExp("^[0-9*,/-]+( [0-9*,/-]+){4}$", "u")))
152
+ });
153
+ var ScheduleRule = Union([ScheduleCalendarRule, ScheduleCronRule]);
154
+ var cronBounds = [
155
+ [0, 59],
156
+ [0, 23],
157
+ [1, 31],
158
+ [1, 12],
159
+ [0, 7]
160
+ ];
161
+ function cronField(field, [min, max]) {
162
+ const values = new Set;
163
+ for (const part of field.split(",")) {
164
+ const match = /^(\*|(\d+)(?:-(\d+))?)(?:\/(\d+))?$/.exec(part);
165
+ if (match === null)
166
+ return;
167
+ const from = match[1] === "*" ? min : Number(match[2]);
168
+ const to = match[1] === "*" ? max : match[3] === undefined ? match[4] === undefined ? from : max : Number(match[3]);
169
+ const step = match[4] === undefined ? 1 : Number(match[4]);
170
+ if (from < min || to > max || from > to || step < 1)
171
+ return;
172
+ for (let value = from;value <= to; value += step)
173
+ values.add(value);
174
+ }
175
+ return values;
176
+ }
177
+ function parseCron(cron) {
178
+ const fields = cron.split(" ");
179
+ const [minutes, hours, days, months, weekdays] = fields.map((field, index) => cronField(field, cronBounds[index] ?? [0, 0]));
180
+ if (fields.length !== 5 || !minutes || !hours || !days || !months || !weekdays)
181
+ return;
182
+ return {
183
+ minutes,
184
+ hours,
185
+ days,
186
+ months,
187
+ weekdays: new Set([...weekdays].map((value) => value % 7)),
188
+ dayRestricted: !(fields[2] ?? "").startsWith("*"),
189
+ weekdayRestricted: !(fields[4] ?? "").startsWith("*")
190
+ };
191
+ }
192
+ function isScheduleRule(value) {
193
+ return guard(ScheduleRule)(value) && (!("cron" in value) || parseCron(value.cron) !== undefined);
194
+ }
195
+ var ScheduleVersion = Struct({
196
+ contractVersion: Literal("schedule.v1"),
197
+ id: String4.check(isMinLength(1)),
198
+ scheduleId: String4.check(isMinLength(1)),
199
+ workspaceId: String4.check(isMinLength(1)),
200
+ teamId: optionalKey(String4.check(isMinLength(1))),
201
+ loopId: optionalKey(String4.check(isMinLength(1))),
202
+ name: optionalKey(String4.check(isMinLength(1), isMaxLength(200))),
203
+ version: Int.check(isGreaterThanOrEqualTo(1)),
204
+ status: Literals(ScheduleVersionStatuses),
205
+ timezone: String4.check(isMinLength(1), isMaxLength(80)),
206
+ rule: ScheduleRule,
207
+ misfirePolicy: Literals(ScheduleMisfirePolicies),
208
+ overlapPolicy: Literals(ScheduleOverlapPolicies),
209
+ maxCatchUp: Int.check(isGreaterThanOrEqualTo(0), isLessThanOrEqualTo(200)),
210
+ misfireGraceSeconds: optionalKey(Int.check(isGreaterThanOrEqualTo(0), isLessThanOrEqualTo(604800))),
211
+ inputSchemaRef: optionalKey(LoopDataSchemaRef),
212
+ input: optionalKey(SafeJson),
213
+ createdAt: String4.check(isMinLength(1))
214
+ });
215
+ var zones = new Map;
216
+ var resolvedLocalDateTimes = new Map;
217
+
218
+ // packages/core/src/kit-declarations.ts
219
+ var LoopCapabilities = [
220
+ "agent_work",
221
+ "ask",
222
+ "call",
223
+ "verify",
224
+ "change_request",
225
+ "write_back",
226
+ "post_comment",
227
+ "create_tasks",
228
+ "merge_change_request",
229
+ "approve_change_request",
230
+ "publish_release",
231
+ "read_transcripts",
232
+ "read_change_request",
233
+ "measure",
234
+ "claim",
235
+ "propose",
236
+ "read_project",
237
+ "draft_update"
238
+ ];
239
+ var JsonObject = Record(String4, Json);
240
+ var SecretName = String4.check(isPattern(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/));
241
+ var EventFilterValue = Union([String4, Finite, Boolean2, Null]);
242
+ var LoopManifest = Struct({
243
+ id: String4,
244
+ title: String4,
245
+ version: optionalKey(LoopVersion),
246
+ input: JsonObject,
247
+ output: JsonObject,
248
+ outcome: optionalKey(Literals(["feature", "bug", "refactor", "investigation", "docs", "migration", "performance"])),
249
+ agents: Record(String4, String4),
250
+ checkout: Literals(["none", "read", "write"]),
251
+ when: ArraySchema(Struct({
252
+ event: String4,
253
+ filter: optionalKey(Record(String4, Union([EventFilterValue, ArraySchema(EventFilterValue)]))),
254
+ input: Record(String4, String4),
255
+ values: optionalKey(JsonObject)
256
+ })),
257
+ offers: ArraySchema(Struct({
258
+ id: String4,
259
+ title: String4,
260
+ loop: String4,
261
+ from: optionalKey(String4)
262
+ })),
263
+ capabilities: ArraySchema(Literals(LoopCapabilities)),
264
+ secrets: optionalKey(ArraySchema(SecretName)),
265
+ network: optionalKey(AgentSandboxNetwork),
266
+ schedule: optionalKey(Struct({ rule: ScheduleRule, timezone: String4 }))
267
+ });
268
+ var LoopDetail = Struct({
269
+ id: String4,
270
+ resolved: optionalKey(Struct({
271
+ ...ProgramLoop.fields,
272
+ agents: LoopManifest.fields.agents,
273
+ when: LoopManifest.fields.when,
274
+ schedule: optionalKey(Struct({
275
+ rule: ScheduleRule,
276
+ timezone: String4,
277
+ on: Boolean2,
278
+ nextRunAt: optionalKey(String4)
279
+ }))
280
+ }))
281
+ });
282
+ var AgentDeclaration = Struct({
283
+ extends: optionalKey(String4),
284
+ instructions: optionalKey(String4),
285
+ harness: optionalKey(String4),
286
+ model: optionalKey(String4),
287
+ effort: optionalKey(Literals(AgentEfforts)),
288
+ fallbacks: optionalKey(ArraySchema(AgentFallback)),
289
+ tools: optionalKey(ArraySchema(Literals(AgentCapabilities))),
290
+ skills: optionalKey(ArraySchema(String4.check(isMinLength(1)))),
291
+ network: optionalKey(Union([Struct({ hosts: ArraySchema(String4) }), Literal("open")])),
292
+ sandbox: optionalKey(Literal("docker"))
293
+ });
294
+ var scheduleFields = {
295
+ name: String4.check(isMinLength(1)),
296
+ loop: String4,
297
+ team: optionalKey(String4),
298
+ input: optionalKey(JsonObject),
299
+ timezone: String4,
300
+ misfire: optionalKey(Literals(ScheduleMisfirePolicies)),
301
+ overlap: optionalKey(Literals(ScheduleOverlapPolicies))
302
+ };
303
+ var ScheduleDeclaration = Union([
304
+ Struct({
305
+ ...scheduleFields,
306
+ cron: String4.check(makeFilter((cron) => isScheduleRule({ cron }) || "five cron fields, each within its range"))
307
+ }),
308
+ Struct({
309
+ ...scheduleFields,
310
+ rule: declare((value) => isScheduleRule(value), {
311
+ expected: "a Schedule rule: frequency daily or weekly, hour, minute, and optionally second and daysOfWeek"
312
+ })
313
+ })
314
+ ]);
315
+ var CarriedKit = Struct({
316
+ name: KitName,
317
+ version: String4.check(isMinLength(1)),
318
+ setup: KitDigest,
319
+ loops: ArraySchema(String4),
320
+ agents: ArraySchema(String4)
321
+ });
322
+ var KitDeclarations = Struct({
323
+ loops: ArraySchema(LoopManifest),
324
+ agents: Record(String4, AgentDeclaration),
325
+ schedules: optionalKey(Record(String4, ScheduleDeclaration)),
326
+ carried: optionalKey(ArraySchema(CarriedKit))
327
+ });
328
+ var sameLoop = toEquivalence(LoopManifest);
329
+ var sameAgent = toEquivalence(AgentDeclaration);
330
+
331
+ // packages/sdk/src/loop/define.ts
332
+ var LoopOutcome = Literals([
333
+ "feature",
334
+ "bug",
335
+ "refactor",
336
+ "investigation",
337
+ "docs",
338
+ "migration",
339
+ "performance"
340
+ ]);
341
+ class ManifestInvalid extends TaggedError2()("ManifestInvalid", {
342
+ loop: String4,
343
+ message: String4
344
+ }) {
345
+ }
346
+ var JsonObjectSchema = Record(String4, Json);
347
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/workflow/internal/crypto.js
348
+ var encoder = /* @__PURE__ */ new TextEncoder;
349
+ var makeHashDigest = (original) => WebCrypto.use((crypto) => map8(webCryptoDigest(crypto, sha256, encoder.encode(original)), (bytes) => encode(bytes).slice(0, 32)));
350
+
351
+ // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/workflow/Workflow.js
352
+ var TypeId = "~effect/workflow/Workflow";
353
+ var EngineTag = /* @__PURE__ */ Service2("effect/workflow/WorkflowEngine");
354
+ var InstanceTag = /* @__PURE__ */ Service2("effect/workflow/WorkflowEngine/WorkflowInstance");
355
+ var makeExecutionIdFromPayload = (self, payload) => makeHashDigest(`${self._tag.length}:${self._tag}:${self.idempotencyKey(payload)}`);
356
+ var Proto = {
357
+ [TypeId]: TypeId,
358
+ annotate(tag, value) {
359
+ return makeProto({
360
+ _tag: this._tag,
361
+ payloadSchema: this.payloadSchema,
362
+ successSchema: this.successSchema,
363
+ errorSchema: this.errorSchema,
364
+ annotations: add(this.annotations, tag, value),
365
+ idempotencyKey: this.idempotencyKey,
366
+ suspendedRetrySchedule: this.suspendedRetrySchedule
367
+ });
368
+ },
369
+ annotateMerge(context) {
370
+ return makeProto({
371
+ _tag: this._tag,
372
+ payloadSchema: this.payloadSchema,
373
+ successSchema: this.successSchema,
374
+ errorSchema: this.errorSchema,
375
+ annotations: merge3(this.annotations, context),
376
+ idempotencyKey: this.idempotencyKey,
377
+ suspendedRetrySchedule: this.suspendedRetrySchedule
378
+ });
379
+ },
380
+ execute(fields, opts) {
381
+ return suspend3(() => {
382
+ const payload = this.payloadSchema.make(fields);
383
+ const run = flatMap3(EngineTag, (engine) => flatMap3(makeExecutionIdFromPayload(this, payload), (executionId) => andThen2(annotateCurrentSpan({
384
+ executionId
385
+ }), engine.execute(this, {
386
+ executionId,
387
+ payload,
388
+ discard: opts?.discard,
389
+ detached: opts?.detached,
390
+ suspendedRetrySchedule: this.suspendedRetrySchedule
391
+ }))));
392
+ return opts?.discard ? run : withPendingActivity(run);
393
+ }).pipe(withSpan(`${this._tag}.execute`, {}, {
394
+ captureStackTrace: false
395
+ }));
396
+ },
397
+ poll(executionId) {
398
+ return flatMap3(EngineTag, (engine) => engine.poll(this, executionId)).pipe(withSpan(`${this._tag}.poll`, {
399
+ attributes: {
400
+ executionId
401
+ }
402
+ }, {
403
+ captureStackTrace: false
404
+ }));
405
+ },
406
+ interrupt(executionId) {
407
+ return flatMap3(EngineTag, (engine) => engine.interrupt(this, executionId)).pipe(withSpan(`${this._tag}.interrupt`, {
408
+ attributes: {
409
+ executionId
410
+ }
411
+ }, {
412
+ captureStackTrace: false
413
+ }));
414
+ },
415
+ resume(executionId) {
416
+ return flatMap3(EngineTag, (engine) => engine.resume(this, executionId)).pipe(withSpan(`${this._tag}.resume`, {
417
+ attributes: {
418
+ executionId
419
+ }
420
+ }, {
421
+ captureStackTrace: false
422
+ }));
423
+ },
424
+ toLayer(execute) {
425
+ return effectDiscard(flatMap3(EngineTag, (engine) => engine.register(this, execute)));
426
+ },
427
+ executionId(payload) {
428
+ return flatMap3(orDie(this.payloadSchema.makeEffect(payload)), (payload) => makeExecutionIdFromPayload(this, payload));
429
+ },
430
+ withCompensation: (...args) => withCompensation(...args)
431
+ };
432
+ var makeProto = (options) => {
433
+ function Workflow() {}
434
+ Object.setPrototypeOf(Workflow, Proto);
435
+ Object.assign(Workflow, options);
436
+ return Workflow;
437
+ };
438
+ var make = (tag, options) => makeProto({
439
+ _tag: tag,
440
+ payloadSchema: isSchema(options.payload) ? options.payload : Struct(options.payload),
441
+ successSchema: options.success ?? Void,
442
+ errorSchema: options.error ?? Never,
443
+ annotations: options.annotations ?? empty3(),
444
+ idempotencyKey: options.idempotencyKey,
445
+ suspendedRetrySchedule: options.suspendedRetrySchedule
446
+ });
447
+ var ResultTypeId = "~effect/workflow/Workflow/Result";
448
+ class Suspended extends (/* @__PURE__ */ Class2("effect/workflow/Workflow/Suspended")({
449
+ _tag: /* @__PURE__ */ tag("Suspended"),
450
+ cause: /* @__PURE__ */ optional(/* @__PURE__ */ Cause(Never, /* @__PURE__ */ Defect())),
451
+ failed: /* @__PURE__ */ optional(Boolean2)
452
+ })) {
453
+ [ResultTypeId] = ResultTypeId;
454
+ }
455
+ var PendingActivityRegistration = /* @__PURE__ */ Service2("effect/workflow/Workflow/PendingActivityRegistration");
456
+ var registerActivityUnsafe = (instance) => {
457
+ const state = instance.activityState;
458
+ if (state.count === 0)
459
+ state.latch.closeUnsafe();
460
+ state.count++;
461
+ return {
462
+ instance,
463
+ state: "pending"
464
+ };
465
+ };
466
+ var releaseActivityUnsafe = (registration) => {
467
+ if (registration.state === "released")
468
+ return;
469
+ registration.state = "released";
470
+ const state = registration.instance.activityState;
471
+ state.count--;
472
+ if (state.count === 0)
473
+ state.latch.openUnsafe();
474
+ };
475
+ var withPendingActivity = (effect) => contextWith((context) => {
476
+ const instance = getOrUndefined2(context, InstanceTag);
477
+ if (!instance)
478
+ return effect;
479
+ return acquireUseRelease(sync2(() => registerActivityUnsafe(instance)), (registration) => provideService(effect, PendingActivityRegistration, registration), (registration) => sync2(() => releaseActivityUnsafe(registration)));
480
+ });
481
+ var addFinalizer = /* @__PURE__ */ fnUntraced(function* (f) {
482
+ const instance = yield* InstanceTag;
483
+ const services = yield* context();
484
+ yield* addFinalizerExit(instance.scope, (exit) => instance.abandoned ? void_3 : provideContext2(f(exit), services));
485
+ });
486
+ var withCompensation = /* @__PURE__ */ dual(2, (effect, compensation) => uninterruptibleMask2((restore) => tap2(restore(effect), (value) => addFinalizer((exit) => isSuccess2(exit) ? void_3 : compensation(value, exit.cause)))));
487
+ // packages/sdk/src/loop/evidence.ts
488
+ var EvidenceCheck = Struct({
489
+ name: String4,
490
+ command: String4,
491
+ status: Literals(["passed", "failed"]),
492
+ preExisting: Boolean2,
493
+ durationMs: Finite,
494
+ evidenceId: String4,
495
+ outputTail: optionalKey(String4),
496
+ suggested: optionalKey(Boolean2)
497
+ });
498
+ var VerifyResult = Struct({
499
+ revision: String4,
500
+ tree: String4,
501
+ passed: Boolean2,
502
+ unchanged: optionalKey(Boolean2),
503
+ checks: ArraySchema(EvidenceCheck)
504
+ });
505
+
506
+ // packages/sdk/src/loop/steps.ts
507
+ class StepFailed extends TaggedError2()("StepFailed", {
508
+ step: String4,
509
+ reason: String4
510
+ }) {
511
+ get message() {
512
+ return `Step "${this.step}" failed: ${this.reason}`;
513
+ }
514
+ }
515
+
516
+ class OutputInvalid extends TaggedError2()("OutputInvalid", {
517
+ step: String4,
518
+ message: String4
519
+ }) {
520
+ }
521
+
522
+ class QuestionRefused extends TaggedError2()("QuestionRefused", {
523
+ step: String4,
524
+ answer: String4,
525
+ options: ArraySchema(String4)
526
+ }) {
527
+ }
528
+
529
+ class WaitTimedOut extends TaggedError2()("WaitTimedOut", {
530
+ step: String4,
531
+ event: String4
532
+ }) {
533
+ }
534
+
535
+ class ChangeRequestClosed extends TaggedError2()("ChangeRequestClosed", {
536
+ step: String4,
537
+ merged: Boolean2
538
+ }) {
539
+ }
540
+
541
+ class ChildFailed extends TaggedError2()("ChildFailed", {
542
+ step: String4,
543
+ loop: String4,
544
+ reason: String4
545
+ }) {
546
+ get message() {
547
+ return `Child Run of "${this.loop}" for Step "${this.step}" failed: ${this.reason}`;
548
+ }
549
+ }
550
+
551
+ class CapabilityDenied extends TaggedError2()("CapabilityDenied", {
552
+ step: String4,
553
+ capability: Literals(LoopCapabilities),
554
+ secret: optionalKey(String4)
555
+ }) {
556
+ get message() {
557
+ return this.secret === undefined ? `Step "${this.step}" needs the "${this.capability}" capability, which this Run was not granted` : `Step "${this.step}" names the Secret "${this.secret}", which its Loop does not declare`;
558
+ }
559
+ }
560
+
561
+ class DuplicateStep extends TaggedError2()("DuplicateStep", {
562
+ step: String4
563
+ }) {
564
+ }
565
+
566
+ class InputInvalid extends TaggedError2()("InputInvalid", {
567
+ loop: String4,
568
+ message: String4
569
+ }) {
570
+ }
571
+ var LoopEvent = Struct({ type: String4, payload: Record(String4, Json) });
572
+
573
+ class LoopRun extends Service2()("@kitman-sh/sdk/loop/LoopRun") {
574
+ }
575
+
576
+ class LoopHost extends Service2()("@kitman-sh/sdk/loop/LoopHost") {
577
+ }
578
+ // packages/sdk/src/loop/plan.ts
579
+ var PlanTicket = Struct({
580
+ key: String4,
581
+ title: String4,
582
+ body: String4,
583
+ acceptanceCriteria: ArraySchema(String4),
584
+ repoBindingId: optional(String4),
585
+ blockedBy: ArraySchema(String4),
586
+ outcome: optional(LoopOutcome)
587
+ });
588
+ var cycleMessage = (keys) => `These tickets block each other in a cycle, so none can start: ${keys.join(", ")}`;
589
+ var ticketsProblem = (tickets) => {
590
+ const keys = new Set;
591
+ for (const ticket of tickets) {
592
+ if (keys.has(ticket.key))
593
+ return `Two tickets have the key "${ticket.key}"`;
594
+ keys.add(ticket.key);
595
+ }
596
+ for (const ticket of tickets)
597
+ for (const blocker of ticket.blockedBy)
598
+ if (!keys.has(blocker))
599
+ return `Ticket "${ticket.key}" is blocked by "${blocker}", which is not a ticket`;
600
+ const { blocked } = wavesOf(tickets);
601
+ return blocked.length === 0 ? undefined : cycleMessage(blocked);
602
+ };
603
+ var PlanTickets = ArraySchema(PlanTicket).check(makeFilter((tickets) => ticketsProblem(tickets) ?? true));
604
+
605
+ class BlockingCycle extends TaggedError2()("BlockingCycle", {
606
+ tickets: ArraySchema(String4)
607
+ }) {
608
+ get message() {
609
+ return cycleMessage(this.tickets);
610
+ }
611
+ }
612
+ var byRepoBinding = (left, right) => (left.repoBindingId ?? "").localeCompare(right.repoBindingId ?? "");
613
+ function wavesOf(tickets) {
614
+ const placed = new Set;
615
+ const waves = [];
616
+ let left = tickets;
617
+ while (left.length > 0) {
618
+ const ready = left.filter((ticket) => ticket.blockedBy.every((blocker) => placed.has(blocker)));
619
+ if (ready.length === 0)
620
+ break;
621
+ for (const ticket of ready)
622
+ placed.add(ticket.key);
623
+ waves.push(ready.toSorted(byRepoBinding));
624
+ left = left.filter((ticket) => !placed.has(ticket.key));
625
+ }
626
+ return { waves, blocked: left.map((ticket) => ticket.key) };
627
+ }
628
+
629
+ // packages/sdk/src/loop/activities.ts
630
+ var ChangeRequestRequest = Struct({
631
+ title: String4,
632
+ body: String4,
633
+ integration: optional(String4)
634
+ });
635
+ var ChangeRequestResult = Struct({ id: String4, number: String4, url: String4 });
636
+ var WriteBackMilestones = ["started", "change_request_opened", "merged", "failed"];
637
+ var WriteBackRequest = Struct({
638
+ milestone: optional(Literals(WriteBackMilestones)),
639
+ changeRequestUrl: optional(String4)
640
+ });
641
+ var RunFile = Struct({ runFile: String4 }).pipe(decodeTo2(Struct({ id: String4 }), transform({
642
+ decode: ({ runFile }) => ({ id: runFile }),
643
+ encode: ({ id }) => ({ runFile: id })
644
+ })));
645
+ var FileRequest = Struct({ path: String4, caption: optional(String4) });
646
+ var ArtifactRequest = Struct({
647
+ kind: String4,
648
+ title: String4,
649
+ text: String4,
650
+ data: optional(Json),
651
+ files: optional(ArraySchema(RunFile))
652
+ });
653
+ var ArtifactResult = Struct({ artifactId: String4 });
654
+ var NoteRequest = Struct({ text: String4, artifactId: optional(String4) });
655
+ var CreateTasksRequest = Struct({
656
+ tickets: ArraySchema(PlanTicket),
657
+ projectId: optionalKey(String4)
658
+ });
659
+ var CreateTasksResult = Struct({
660
+ tasks: ArraySchema(Struct({ key: String4, taskId: String4 }))
661
+ });
662
+ var AlertTaskRequest = Struct({
663
+ fingerprint: String4.check(isMinLength(1), isMaxLength(400)),
664
+ title: String4,
665
+ windowHours: Int.check(isGreaterThanOrEqualTo(0), isLessThanOrEqualTo(720)),
666
+ resolved: optionalKey(Boolean2),
667
+ priority: optionalKey(Literals(["urgent", "high", "medium", "low"]))
668
+ });
669
+ var AlertTaskResult = Struct({
670
+ taskId: optionalKey(String4),
671
+ created: Boolean2,
672
+ resolved: optionalKey(Boolean2),
673
+ joined: optionalKey(Struct({ kind: Literals(["run", "recent"]), runId: String4 }))
674
+ });
675
+ var IntegrationBranchRequest = Struct({ repoBindingId: optional(String4) });
676
+ var IntegrationBranch = Struct({
677
+ repoBindingId: String4,
678
+ branch: String4,
679
+ revision: String4
680
+ });
681
+ var MergeChangeRequestRequest = Struct({
682
+ changeRequestId: String4,
683
+ head: optionalKey(String4)
684
+ });
685
+ var MergeResult = Union([
686
+ Struct({ status: Literal("merged"), revision: String4 }),
687
+ Struct({ status: Literal("conflict") }),
688
+ Struct({ status: Literal("moved"), head: String4 })
689
+ ]);
690
+ var ApproveChangeRequestRequest = Struct({
691
+ changeRequestId: String4,
692
+ head: String4,
693
+ summary: String4,
694
+ review: optionalKey(String4),
695
+ carries: optionalKey(String4)
696
+ });
697
+ var ApproveChangeRequestResult = Union([
698
+ Struct({ approved: Literal(true), reviewId: String4 }),
699
+ Struct({ approved: Literal(false), reason: String4 })
700
+ ]);
701
+ var CloseChangeRequestRequest = Struct({
702
+ number: String4,
703
+ head: String4,
704
+ note: String4
705
+ });
706
+ var CloseChangeRequestResult = Struct({
707
+ closed: Boolean2,
708
+ head: optionalKey(String4)
709
+ });
710
+ var RerunPipelineRequest = Union([
711
+ Struct({ changeRequestId: String4 }),
712
+ Struct({ ref: String4, all: optionalKey(Boolean2) })
713
+ ]);
714
+ var RerunPipelineResult = Struct({ head: String4, pipelines: Int });
715
+ var ReportPipelineRequest = Struct({ changeRequestId: String4, verification: String4 });
716
+ var ReportPipelineResult = Struct({
717
+ head: String4,
718
+ status: Literals(["success", "failed"])
719
+ });
720
+ var CommentRequest = Struct({
721
+ changeRequestId: String4,
722
+ body: String4,
723
+ threadId: optionalKey(String4),
724
+ summary: optionalKey(String4),
725
+ anchors: optionalKey(ArraySchema(Struct({
726
+ file: String4,
727
+ line: Int.check(isGreaterThanOrEqualTo(1)),
728
+ body: String4.check(isMinLength(1))
729
+ })))
730
+ });
731
+ var ReleaseRequest = Struct({
732
+ tag: String4,
733
+ revision: optional(String4),
734
+ title: String4,
735
+ notes: String4
736
+ });
737
+ var ReleaseResult = Struct({ tag: String4, revision: String4, url: String4 });
738
+ var ChangeRequestReadRequest = Struct({ changeRequestId: String4 });
739
+ var PipelineJob = Struct({
740
+ name: String4,
741
+ status: Literals(["running", "success", "failed", "skipped"]),
742
+ url: optional(String4),
743
+ logTail: optional(String4)
744
+ });
745
+ var PipelineStatus = Struct({
746
+ head: String4,
747
+ status: Literals(["none", "running", "success", "failed", "canceled"]),
748
+ source: Literals(["forge", "reported"]),
749
+ jobs: ArraySchema(PipelineJob),
750
+ readAt: optionalKey(String4),
751
+ runnerChecks: optionalKey(ArraySchema(String4))
752
+ });
753
+ var ReviewThread = Struct({
754
+ id: String4,
755
+ path: optional(String4),
756
+ line: optional(Int),
757
+ outdated: optional(Boolean2),
758
+ comments: ArraySchema(Struct({ author: optional(String4), body: String4 }))
759
+ });
760
+ var ReviewThreads = Struct({ threads: ArraySchema(ReviewThread) });
761
+ var OpenChangeRequestsRequest = Struct({ authors: NonEmptyArray(String4) });
762
+ var OpenChangeRequest = Struct({
763
+ number: String4,
764
+ title: String4,
765
+ body: String4,
766
+ url: String4,
767
+ author: String4,
768
+ sourceBranch: String4,
769
+ head: String4
770
+ });
771
+ var OpenChangeRequests = Struct({ changeRequests: ArraySchema(OpenChangeRequest) });
772
+ var OwnChangeRequest = Struct({
773
+ id: String4,
774
+ number: String4,
775
+ url: String4,
776
+ title: String4,
777
+ sourceBranch: String4,
778
+ body: String4
779
+ });
780
+ var OwnChangeRequests = Struct({ changeRequests: ArraySchema(OwnChangeRequest) });
781
+ var TranscriptPoint = Struct({
782
+ runId: String4,
783
+ stepAttemptId: String4,
784
+ sequence: Int
785
+ });
786
+ var TranscriptsRequest = Struct({
787
+ days: Int.check(isGreaterThanOrEqualTo(1), isLessThanOrEqualTo(31))
788
+ });
789
+ var TranscriptsResult = Struct({
790
+ runs: ArraySchema(Struct({
791
+ runId: String4,
792
+ loopId: String4,
793
+ status: optional(Literals(["completed", "failed", "canceled", "expired"])),
794
+ teamId: optional(String4),
795
+ failure: optional(String4),
796
+ retried: optional(Boolean2),
797
+ entries: ArraySchema(Struct({ stepAttemptId: String4, sequence: Int, kind: String4, text: String4 }))
798
+ }))
799
+ });
800
+ var Citations = NonEmptyArray(TranscriptPoint);
801
+ var ProposeRequest = Union([
802
+ Struct({
803
+ kind: Literal("memory"),
804
+ teamId: String4,
805
+ content: String4,
806
+ citations: Citations
807
+ }),
808
+ Struct({
809
+ kind: Literal("task"),
810
+ title: String4,
811
+ description: String4,
812
+ teamId: optional(String4),
813
+ key: optionalKey(String4.check(isPattern(/^[a-z0-9]+(?:-[a-z0-9]+)*$/), isMaxLength(80))),
814
+ citations: Citations
815
+ })
816
+ ]);
817
+ var ProposeResult = Struct({
818
+ kind: Literals(["memory", "task"]),
819
+ id: String4,
820
+ matched: optionalKey(Boolean2)
821
+ });
822
+ var Health = Literals(["on_track", "at_risk", "off_track"]);
823
+ var ProjectActivityRequest = Struct({ projectId: String4 });
824
+ var ProjectActivityResult = Struct({
825
+ project: Struct({ id: String4, name: String4 }),
826
+ health: optional(Health),
827
+ since: optional(String4),
828
+ runs: ArraySchema(Struct({
829
+ runId: String4,
830
+ loopId: String4,
831
+ status: String4,
832
+ taskKey: optional(String4),
833
+ taskTitle: optional(String4),
834
+ summary: optional(String4),
835
+ entries: ArraySchema(Struct({ stepAttemptId: String4, sequence: Int, kind: String4, text: String4 }))
836
+ })),
837
+ taskChanges: ArraySchema(Struct({ taskKey: String4, title: String4, change: String4, at: String4 }))
838
+ });
839
+ var DraftUpdateRequest = Struct({
840
+ projectId: String4,
841
+ health: Health,
842
+ note: String4,
843
+ writtenFrom: Struct({
844
+ runs: Int,
845
+ taskChanges: Int,
846
+ since: optional(String4)
847
+ })
848
+ });
849
+ var DraftUpdateResult = Struct({ id: String4 });
850
+
851
+ class ChangeRequestActivity extends Service2()("@kitman-sh/sdk/loop/ChangeRequestActivity") {
852
+ }
853
+
854
+ class WriteBackActivity extends Service2()("@kitman-sh/sdk/loop/WriteBackActivity") {
855
+ }
856
+
857
+ class ArtifactActivity extends Service2()("@kitman-sh/sdk/loop/ArtifactActivity") {
858
+ }
859
+
860
+ class FileActivity extends Service2()("@kitman-sh/sdk/loop/FileActivity") {
861
+ }
862
+
863
+ class NoteActivity extends Service2()("@kitman-sh/sdk/loop/NoteActivity") {
864
+ }
865
+
866
+ class CommentActivity extends Service2()("@kitman-sh/sdk/loop/CommentActivity") {
867
+ }
868
+
869
+ class CreateTasksActivity extends Service2()("@kitman-sh/sdk/loop/CreateTasksActivity") {
870
+ }
871
+
872
+ class AlertTaskActivity extends Service2()("@kitman-sh/sdk/loop/AlertTaskActivity") {
873
+ }
874
+
875
+ class IntegrationBranchActivity extends Service2()("@kitman-sh/sdk/loop/IntegrationBranchActivity") {
876
+ }
877
+
878
+ class MergeChangeRequestActivity extends Service2()("@kitman-sh/sdk/loop/MergeChangeRequestActivity") {
879
+ }
880
+
881
+ class ReleaseActivity extends Service2()("@kitman-sh/sdk/loop/ReleaseActivity") {
882
+ }
883
+
884
+ class TranscriptsActivity extends Service2()("@kitman-sh/sdk/loop/TranscriptsActivity") {
885
+ }
886
+
887
+ class ProposeActivity extends Service2()("@kitman-sh/sdk/loop/ProposeActivity") {
888
+ }
889
+
890
+ class ProjectActivityActivity extends Service2()("@kitman-sh/sdk/loop/ProjectActivityActivity") {
891
+ }
892
+
893
+ class DraftUpdateActivity extends Service2()("@kitman-sh/sdk/loop/DraftUpdateActivity") {
894
+ }
895
+
896
+ class ChangeRequestReadActivity extends Service2()("@kitman-sh/sdk/loop/ChangeRequestReadActivity") {
897
+ }
898
+ // packages/sdk/src/loop/measure.ts
899
+ var MetricStats = Struct({
900
+ samples: Finite,
901
+ median: Finite,
902
+ mean: Finite,
903
+ min: Finite,
904
+ max: Finite,
905
+ stdev: Finite
906
+ });
907
+ var MeasureVerdict = Literals(["gain", "no_gain", "guardrail_regressed", "too_noisy"]);
908
+ var Measurement = Struct({
909
+ verdict: MeasureVerdict,
910
+ reason: String4,
911
+ metrics: ArraySchema(Struct({
912
+ name: String4,
913
+ role: Literals(["primary", "guardrail"]),
914
+ direction: Literals(["lower", "higher"]),
915
+ base: MetricStats,
916
+ head: MetricStats,
917
+ change: Finite,
918
+ noise: Finite
919
+ })),
920
+ suggestion: optional(String4),
921
+ evidence: MeasureEvidence
922
+ });
923
+ var floors = new WeakMap;
924
+
925
+ // packages/sdk/src/loop/test-loop.ts
926
+ var LoopJournal = Struct({
927
+ activities: Record(String4, Json),
928
+ deferreds: Record(String4, Json)
929
+ });
930
+
931
+ class ScriptedFailure extends TaggedClass("ScriptedFailure") {
932
+ }
933
+ // packages/sdk/src/loop/review.ts
934
+ var Severity = Literals(["blocker", "major", "minor"]);
935
+ var Finding = Struct({
936
+ severity: Severity,
937
+ file: String4,
938
+ line: Int,
939
+ detail: String4
940
+ });
941
+ var MergedFinding = Struct({
942
+ id: String4,
943
+ ...Finding.fields,
944
+ seats: ArraySchema(String4)
945
+ });
946
+ var Rebuttal = Struct({ findingId: String4, reason: String4 });
947
+ var RebuttalVerdict = Struct({ findingId: String4, accepted: Boolean2 });
948
+ var ScopeJudgement = Struct({ met: Boolean2, unmet: ArraySchema(String4) });
949
+ // packages/sdk/src/loop/check.ts
950
+ class CheckFailed extends TaggedError2()("CheckFailed", {
951
+ loop: String4,
952
+ check: String4,
953
+ reason: String4
954
+ }) {
955
+ get detail() {
956
+ return `Check "${this.check}": ${this.reason}`;
957
+ }
958
+ get message() {
959
+ return `Loop "${this.loop}": ${this.detail}`;
960
+ }
961
+ }
962
+
963
+ class StepNamedTwice extends TaggedError2()("StepNamedTwice", {
964
+ loop: String4,
965
+ check: String4,
966
+ step: String4
967
+ }) {
968
+ get detail() {
969
+ return `Check "${this.check}": Step "${this.step}" is named twice`;
970
+ }
971
+ get message() {
972
+ return `Loop "${this.loop}": ${this.detail}`;
973
+ }
974
+ }
975
+
976
+ class ReplayDiverged extends TaggedError2()("ReplayDiverged", {
977
+ loop: String4,
978
+ check: String4,
979
+ first: ArraySchema(String4),
980
+ replay: ArraySchema(String4),
981
+ rerun: ArraySchema(String4)
982
+ }) {
983
+ get detail() {
984
+ const steps = (names) => names.join(", ") || "no Steps";
985
+ return `Check "${this.check}": its replay from the journal diverged; it took ${steps(this.first)} and then ${steps(this.replay)}${this.rerun.length > 0 ? `, running ${this.rerun.join(", ")} again` : ""}. Keep effects and randomness inside Activities.`;
986
+ }
987
+ get message() {
988
+ return `Loop "${this.loop}": ${this.detail}`;
989
+ }
990
+ }
991
+ var LoopCheckError = Union([CheckFailed, StepNamedTwice, ReplayDiverged]);
992
+ // packages/sdk/src/loop/sync.ts
993
+ var UpToDate = Struct({ status: Literal("up_to_date") });
994
+ var Conflict = Struct({
995
+ status: Literal("conflict"),
996
+ files: NonEmptyArray(String4),
997
+ reason: String4
998
+ });
999
+ var merged = {
1000
+ status: Literal("merged"),
1001
+ settled: ArraySchema(String4)
1002
+ };
1003
+ var SyncAnswer = Union([UpToDate, Struct(merged), Conflict]);
1004
+ var BaseSync = Union([
1005
+ UpToDate,
1006
+ Struct({ ...merged, catchUp: optionalKey(CatchUp) }),
1007
+ Conflict
1008
+ ]);
1009
+ // packages/sdk/src/loop/continuing.ts
1010
+ var Continuing = Struct({
1011
+ changeRequestId: String4,
1012
+ number: String4,
1013
+ url: String4,
1014
+ branch: String4,
1015
+ targetBranch: String4,
1016
+ revision: optional(String4),
1017
+ lastRunId: optional(String4),
1018
+ lastRunStatus: optional(String4),
1019
+ lastRunSummary: optional(String4)
1020
+ });
1021
+ // packages/sdk/src/program/engine.ts
1022
+ class JournalWriteFailed extends TaggedError("JournalWriteFailed") {
1023
+ get message() {
1024
+ return `Journal write failed: ${this.cause.message}`;
1025
+ }
1026
+ }
1027
+ var JournalEntries = Record(String4, Json);
1028
+ var isSuspended = is(Suspended);
1029
+ var emptyWorkflow = make("kitman-loop/none", { payload: {}, idempotencyKey: () => "none" });
1030
+ var replayStatuses = new Set([401, 403, 409, 429]);
1031
+ var isRunnerRpcError = is(RunnerRpcError);
1032
+ var isRunFileRefused = is(RunFileRefused);
1033
+ var issues = makeFormatterStandardSchemaV1();
1034
+ var put2 = (target, contentType, body) => gen(function* () {
1035
+ const response = yield* (yield* HttpClient).execute(put(target.url).pipe(bodyUint8Array(body, contentType), setHeaders(target.headers ?? {})));
1036
+ return (yield* filterStatusOk(response)).headers.etag ?? "";
1037
+ });
1038
+ var readRange = (path, offset, size) => scoped(gen(function* () {
1039
+ const file = yield* (yield* FileSystem).open(path);
1040
+ return getOrElse(yield* file.readAlloc(size, { position: BigInt(offset) }), () => new Uint8Array);
1041
+ }));
1042
+ var partUrlMarginMillis = 60000;
1043
+ var uploadParts = (files, path, contentType, fileId, upload) => forEach(upload.parts, (part) => gen(function* () {
1044
+ const now = yield* currentTimeMillis;
1045
+ const fresh = Date.parse(part.expiresAt) - now > partUrlMarginMillis ? part : (yield* files.runFileParts({ fileId, partNumbers: [part.partNumber] }))[0] ?? part;
1046
+ const body = yield* readRange(path, (part.partNumber - 1) * upload.partSize, upload.partSize);
1047
+ return { partNumber: part.partNumber, etag: yield* put2(fresh, contentType, body) };
1048
+ }));
1049
+ var uploadRunFile = (files, file) => gen(function* () {
1050
+ const fs = yield* FileSystem;
1051
+ const contentType = runFileContentType(file.name);
1052
+ const byteSize = Number((yield* fs.stat(file.path)).size);
1053
+ const hash = sha256Hasher();
1054
+ yield* runForEach(fs.stream(file.path), (chunk) => sync2(() => hash.update(chunk)));
1055
+ const { file: slotted, upload } = yield* files.createRunFile({
1056
+ step: file.step,
1057
+ name: file.name,
1058
+ ...file.caption === undefined ? undefined : { caption: file.caption },
1059
+ contentType,
1060
+ byteSize,
1061
+ sha256: hash.digest("hex")
1062
+ });
1063
+ if (upload === undefined)
1064
+ return slotted;
1065
+ return yield* upload.kind === "single" ? readRange(file.path, 0, byteSize).pipe(flatMap3((body) => put2(upload, contentType, body)), andThen2(files.completeRunFile({ fileId: slotted.id }))) : flatMap3(uploadParts(files, file.path, contentType, slotted.id, upload), (parts) => files.completeRunFile({ fileId: slotted.id, parts }));
1066
+ });
1067
+ var programLease = (work) => ({
1068
+ workUnitId: work.id,
1069
+ leaseOwnerId: work.lease.leaseOwnerId,
1070
+ runnerReplicaId: work.lease.runnerReplicaId,
1071
+ leaseId: work.lease.leaseId,
1072
+ attempt: work.lease.attempt,
1073
+ fencingToken: work.lease.fencingToken,
1074
+ capacitySlot: work.lease.capacitySlot
1075
+ });
1076
+ var rpcRunFiles = (rpc, lease) => ({
1077
+ createRunFile: (file) => rpc.createRunFile({ lease, ...file }),
1078
+ runFileParts: (request) => map8(rpc.runFileParts({ lease, ...request, partNumbers: [...request.partNumbers] }), ({ parts }) => parts),
1079
+ completeRunFile: ({ parts, ...request }) => rpc.completeRunFile({ lease, ...request, ...parts === undefined ? undefined : { parts: [...parts] } })
1080
+ });
1081
+
1082
+ // packages/sdk/src/program/host.ts
1083
+ var describeFlag = "--kitman-describe";
1084
+ var DescribedKit = Struct({
1085
+ name: String4,
1086
+ version: String4,
1087
+ loops: ArraySchema(LoopManifest),
1088
+ agents: Record(String4, Json),
1089
+ schedules: optionalKey(Record(String4, Json)),
1090
+ setup: optionalKey(KitSetup)
1091
+ });
1092
+ var Described = Union([
1093
+ TaggedStruct("Described", { kits: ArraySchema(DescribedKit) }),
1094
+ TaggedStruct("Refused", { error: Union([ManifestInvalid, LoopCheckError]) })
1095
+ ]);
1096
+ var encodeDescribed = encodeEffect(fromJsonString(toCodecJson(Described)));
1097
+
1098
+ class ProgramRefused extends TaggedError2()("ProgramRefused", { reason: String4 }) {
1099
+ get message() {
1100
+ return this.reason;
1101
+ }
1102
+ }
1103
+ var programHostsEnv = "KITMAN_PROGRAM_HOSTS";
1104
+ var undeclaredHostsEnv = "KITMAN_UNDECLARED_HOSTS";
1105
+ var redirectStatuses = new Set([301, 302, 303, 307, 308]);
1106
+ var readStdin = tryPromise(() => Bun.stdin.text());
1107
+ var isWorkUnit = guard(ProgramWorkUnit);
1108
+
1109
+ export { AgentDeclaration, KitDeclarations, uploadRunFile, programLease, rpcRunFiles, describeFlag, Described, programHostsEnv, undeclaredHostsEnv };