@kitman-sh/cli 0.14.8 → 0.15.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.
Files changed (30) hide show
  1. package/dist/{chunk-y0y2gg8d.js → chunk-0ws25xvg.js} +2 -2
  2. package/dist/{chunk-b009hdm0.js → chunk-39ykbhq8.js} +5 -5
  3. package/dist/{chunk-eytzmdna.js → chunk-3n99j4z0.js} +471 -234
  4. package/dist/{chunk-bbf0jzsc.js → chunk-3ns4sbfb.js} +1 -1
  5. package/dist/{chunk-q0x3c0dh.js → chunk-4x7a1qkj.js} +7 -7
  6. package/dist/{chunk-ya4z1n5p.js → chunk-4zc1g45m.js} +7 -7
  7. package/dist/{chunk-6dj39qtt.js → chunk-58hehm8d.js} +1133 -115
  8. package/dist/{chunk-9avbsbvk.js → chunk-5hkdgzh4.js} +1 -1
  9. package/dist/{chunk-xfs1nf75.js → chunk-8393zths.js} +1626 -388
  10. package/dist/{chunk-bpx2zjh7.js → chunk-8wpg3rph.js} +2 -2
  11. package/dist/{chunk-6x43ntsx.js → chunk-b16qxawc.js} +1 -1
  12. package/dist/chunk-cf1hxp43.js +3080 -0
  13. package/dist/chunk-csxxwscf.js +39 -0
  14. package/dist/{chunk-dq21ab8w.js → chunk-djp6t2g6.js} +21 -21
  15. package/dist/{chunk-zpp4jg4a.js → chunk-dx792s4w.js} +1455 -100
  16. package/dist/{chunk-5wrhj4cj.js → chunk-fv2zpgh0.js} +7 -7
  17. package/dist/{chunk-ctpgfdzf.js → chunk-fzaecdgv.js} +3 -3
  18. package/dist/{chunk-79g5zh2p.js → chunk-k2wd9r6t.js} +4 -4
  19. package/dist/chunk-mrkrt2hg.js +4345 -0
  20. package/dist/{chunk-721qyd1a.js → chunk-qkt77rtj.js} +6 -6
  21. package/dist/{chunk-drp4zdwq.js → chunk-rt0qfdtg.js} +15 -7
  22. package/dist/{chunk-cf723a2y.js → chunk-snwjv2sd.js} +678 -40
  23. package/dist/{chunk-bdd62njv.js → chunk-vg78dz3w.js} +259 -57
  24. package/dist/{chunk-wszvkzg8.js → chunk-vq7caqt2.js} +1828 -130
  25. package/dist/{chunk-63m3r0k4.js → chunk-wfz64h9p.js} +4 -4
  26. package/dist/{chunk-hz4t408c.js → chunk-xx711t5r.js} +4 -4
  27. package/dist/index.js +4 -4
  28. package/package.json +2 -1
  29. package/dist/chunk-1rwaetnm.js +0 -526
  30. package/dist/chunk-hrtr5wfq.js +0 -1166
@@ -1,1166 +0,0 @@
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-zpp4jg4a.js";
79
- import {
80
- WebCrypto,
81
- SafeJson,
82
- AgentSandboxNetwork,
83
- AgentEfforts,
84
- AgentCapabilities,
85
- LoopDataSchemaRef,
86
- LoopVersion,
87
- ProgramLoop,
88
- AgentFallback,
89
- ProgramWorkUnit,
90
- MeasureEvidence,
91
- CatchUp,
92
- RunFileRefused,
93
- runFileContentType,
94
- sha256Hasher,
95
- put,
96
- setHeaders,
97
- bodyUint8Array,
98
- filterStatusOk,
99
- HttpClient,
100
- KitName,
101
- KitDigest,
102
- KitSetup,
103
- RunnerRpcError
104
- } from "./chunk-xfs1nf75.js";
105
- import {
106
- currentTimeMillis,
107
- runForEach,
108
- FileSystem
109
- } from "./chunk-bdd62njv.js";
110
- import {
111
- guard
112
- } from "./chunk-9avbsbvk.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 WhenClause = Struct({
243
- event: String4,
244
- filter: optionalKey(Record(String4, Union([EventFilterValue, ArraySchema(EventFilterValue)]))),
245
- input: Record(String4, String4),
246
- values: optionalKey(JsonObject),
247
- optIn: optionalKey(Boolean2),
248
- description: optionalKey(String4)
249
- });
250
- var LoopManifest = Struct({
251
- id: String4,
252
- title: String4,
253
- version: optionalKey(LoopVersion),
254
- input: JsonObject,
255
- output: JsonObject,
256
- outcome: optionalKey(Literals(["feature", "bug", "refactor", "investigation", "docs", "migration", "performance"])),
257
- agents: Record(String4, String4),
258
- checkout: Literals(["none", "read", "write"]),
259
- when: ArraySchema(WhenClause),
260
- offers: ArraySchema(Struct({
261
- id: String4,
262
- title: String4,
263
- loop: String4,
264
- from: optionalKey(String4)
265
- })),
266
- capabilities: ArraySchema(Literals(LoopCapabilities)),
267
- ownCapabilities: optionalKey(ArraySchema(Literals(LoopCapabilities))),
268
- secrets: optionalKey(ArraySchema(SecretName)),
269
- network: optionalKey(AgentSandboxNetwork),
270
- schedule: optionalKey(Struct({ rule: ScheduleRule, timezone: String4 }))
271
- });
272
- var LoopDetail = Struct({
273
- id: String4,
274
- resolved: optionalKey(Struct({
275
- ...ProgramLoop.fields,
276
- agents: LoopManifest.fields.agents,
277
- when: ArraySchema(Struct({ ...WhenClause.fields, on: optionalKey(Boolean2) })),
278
- schedule: optionalKey(Struct({
279
- rule: ScheduleRule,
280
- timezone: String4,
281
- on: Boolean2,
282
- nextRunAt: optionalKey(String4)
283
- }))
284
- }))
285
- });
286
- var AgentDeclaration = Struct({
287
- extends: optionalKey(String4),
288
- instructions: optionalKey(String4),
289
- harness: optionalKey(String4),
290
- model: optionalKey(String4),
291
- effort: optionalKey(Literals(AgentEfforts)),
292
- fallbacks: optionalKey(ArraySchema(AgentFallback)),
293
- tools: optionalKey(ArraySchema(Literals(AgentCapabilities))),
294
- skills: optionalKey(ArraySchema(String4.check(isMinLength(1)))),
295
- network: optionalKey(Union([Struct({ hosts: ArraySchema(String4) }), Literal("open")])),
296
- sandbox: optionalKey(Literal("docker"))
297
- });
298
- var scheduleFields = {
299
- name: String4.check(isMinLength(1)),
300
- loop: String4,
301
- team: optionalKey(String4),
302
- input: optionalKey(JsonObject),
303
- timezone: String4,
304
- misfire: optionalKey(Literals(ScheduleMisfirePolicies)),
305
- overlap: optionalKey(Literals(ScheduleOverlapPolicies))
306
- };
307
- var ScheduleDeclaration = Union([
308
- Struct({
309
- ...scheduleFields,
310
- cron: String4.check(makeFilter((cron) => isScheduleRule({ cron }) || "five cron fields, each within its range"))
311
- }),
312
- Struct({
313
- ...scheduleFields,
314
- rule: declare((value) => isScheduleRule(value), {
315
- expected: "a Schedule rule: frequency daily or weekly, hour, minute, and optionally second and daysOfWeek"
316
- })
317
- })
318
- ]);
319
- var CarriedKit = Struct({
320
- name: KitName,
321
- version: String4.check(isMinLength(1)),
322
- setup: KitDigest,
323
- loops: ArraySchema(String4),
324
- agents: ArraySchema(String4)
325
- });
326
- var KitDeclarations = Struct({
327
- loops: ArraySchema(LoopManifest),
328
- agents: Record(String4, AgentDeclaration),
329
- schedules: optionalKey(Record(String4, ScheduleDeclaration)),
330
- carried: optionalKey(ArraySchema(CarriedKit))
331
- });
332
- var sameLoop = toEquivalence(LoopManifest);
333
- var sameAgent = toEquivalence(AgentDeclaration);
334
-
335
- // packages/sdk/src/loop/define.ts
336
- var LoopOutcome = Literals([
337
- "feature",
338
- "bug",
339
- "refactor",
340
- "investigation",
341
- "docs",
342
- "migration",
343
- "performance"
344
- ]);
345
- class ManifestInvalid extends TaggedError2()("ManifestInvalid", {
346
- loop: String4,
347
- message: String4
348
- }) {
349
- }
350
- var JsonObjectSchema = Record(String4, Json);
351
- // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/workflow/internal/crypto.js
352
- var encoder = /* @__PURE__ */ new TextEncoder;
353
- var makeHashDigest = (original) => WebCrypto.use((crypto) => map8(webCryptoDigest(crypto, sha256, encoder.encode(original)), (bytes) => encode(bytes).slice(0, 32)));
354
-
355
- // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/workflow/Workflow.js
356
- var TypeId = "~effect/workflow/Workflow";
357
- var EngineTag = /* @__PURE__ */ Service2("effect/workflow/WorkflowEngine");
358
- var InstanceTag = /* @__PURE__ */ Service2("effect/workflow/WorkflowEngine/WorkflowInstance");
359
- var makeExecutionIdFromPayload = (self, payload) => makeHashDigest(`${self._tag.length}:${self._tag}:${self.idempotencyKey(payload)}`);
360
- var Proto = {
361
- [TypeId]: TypeId,
362
- annotate(tag, value) {
363
- return makeProto({
364
- _tag: this._tag,
365
- payloadSchema: this.payloadSchema,
366
- successSchema: this.successSchema,
367
- errorSchema: this.errorSchema,
368
- annotations: add(this.annotations, tag, value),
369
- idempotencyKey: this.idempotencyKey,
370
- suspendedRetrySchedule: this.suspendedRetrySchedule
371
- });
372
- },
373
- annotateMerge(context) {
374
- return makeProto({
375
- _tag: this._tag,
376
- payloadSchema: this.payloadSchema,
377
- successSchema: this.successSchema,
378
- errorSchema: this.errorSchema,
379
- annotations: merge3(this.annotations, context),
380
- idempotencyKey: this.idempotencyKey,
381
- suspendedRetrySchedule: this.suspendedRetrySchedule
382
- });
383
- },
384
- execute(fields, opts) {
385
- return suspend3(() => {
386
- const payload = this.payloadSchema.make(fields);
387
- const run = flatMap3(EngineTag, (engine) => flatMap3(makeExecutionIdFromPayload(this, payload), (executionId) => andThen2(annotateCurrentSpan({
388
- executionId
389
- }), engine.execute(this, {
390
- executionId,
391
- payload,
392
- discard: opts?.discard,
393
- detached: opts?.detached,
394
- suspendedRetrySchedule: this.suspendedRetrySchedule
395
- }))));
396
- return opts?.discard ? run : withPendingActivity(run);
397
- }).pipe(withSpan(`${this._tag}.execute`, {}, {
398
- captureStackTrace: false
399
- }));
400
- },
401
- poll(executionId) {
402
- return flatMap3(EngineTag, (engine) => engine.poll(this, executionId)).pipe(withSpan(`${this._tag}.poll`, {
403
- attributes: {
404
- executionId
405
- }
406
- }, {
407
- captureStackTrace: false
408
- }));
409
- },
410
- interrupt(executionId) {
411
- return flatMap3(EngineTag, (engine) => engine.interrupt(this, executionId)).pipe(withSpan(`${this._tag}.interrupt`, {
412
- attributes: {
413
- executionId
414
- }
415
- }, {
416
- captureStackTrace: false
417
- }));
418
- },
419
- resume(executionId) {
420
- return flatMap3(EngineTag, (engine) => engine.resume(this, executionId)).pipe(withSpan(`${this._tag}.resume`, {
421
- attributes: {
422
- executionId
423
- }
424
- }, {
425
- captureStackTrace: false
426
- }));
427
- },
428
- toLayer(execute) {
429
- return effectDiscard(flatMap3(EngineTag, (engine) => engine.register(this, execute)));
430
- },
431
- executionId(payload) {
432
- return flatMap3(orDie(this.payloadSchema.makeEffect(payload)), (payload) => makeExecutionIdFromPayload(this, payload));
433
- },
434
- withCompensation: (...args) => withCompensation(...args)
435
- };
436
- var makeProto = (options) => {
437
- function Workflow() {}
438
- Object.setPrototypeOf(Workflow, Proto);
439
- Object.assign(Workflow, options);
440
- return Workflow;
441
- };
442
- var make = (tag, options) => makeProto({
443
- _tag: tag,
444
- payloadSchema: isSchema(options.payload) ? options.payload : Struct(options.payload),
445
- successSchema: options.success ?? Void,
446
- errorSchema: options.error ?? Never,
447
- annotations: options.annotations ?? empty3(),
448
- idempotencyKey: options.idempotencyKey,
449
- suspendedRetrySchedule: options.suspendedRetrySchedule
450
- });
451
- var ResultTypeId = "~effect/workflow/Workflow/Result";
452
- class Suspended extends (/* @__PURE__ */ Class2("effect/workflow/Workflow/Suspended")({
453
- _tag: /* @__PURE__ */ tag("Suspended"),
454
- cause: /* @__PURE__ */ optional(/* @__PURE__ */ Cause(Never, /* @__PURE__ */ Defect())),
455
- failed: /* @__PURE__ */ optional(Boolean2)
456
- })) {
457
- [ResultTypeId] = ResultTypeId;
458
- }
459
- var PendingActivityRegistration = /* @__PURE__ */ Service2("effect/workflow/Workflow/PendingActivityRegistration");
460
- var registerActivityUnsafe = (instance) => {
461
- const state = instance.activityState;
462
- if (state.count === 0)
463
- state.latch.closeUnsafe();
464
- state.count++;
465
- return {
466
- instance,
467
- state: "pending"
468
- };
469
- };
470
- var releaseActivityUnsafe = (registration) => {
471
- if (registration.state === "released")
472
- return;
473
- registration.state = "released";
474
- const state = registration.instance.activityState;
475
- state.count--;
476
- if (state.count === 0)
477
- state.latch.openUnsafe();
478
- };
479
- var withPendingActivity = (effect) => contextWith((context) => {
480
- const instance = getOrUndefined2(context, InstanceTag);
481
- if (!instance)
482
- return effect;
483
- return acquireUseRelease(sync2(() => registerActivityUnsafe(instance)), (registration) => provideService(effect, PendingActivityRegistration, registration), (registration) => sync2(() => releaseActivityUnsafe(registration)));
484
- });
485
- var addFinalizer = /* @__PURE__ */ fnUntraced(function* (f) {
486
- const instance = yield* InstanceTag;
487
- const services = yield* context();
488
- yield* addFinalizerExit(instance.scope, (exit) => instance.abandoned ? void_3 : provideContext2(f(exit), services));
489
- });
490
- var withCompensation = /* @__PURE__ */ dual(2, (effect, compensation) => uninterruptibleMask2((restore) => tap2(restore(effect), (value) => addFinalizer((exit) => isSuccess2(exit) ? void_3 : compensation(value, exit.cause)))));
491
- // packages/sdk/src/loop/evidence.ts
492
- var EvidenceCheck = Struct({
493
- name: String4,
494
- command: String4,
495
- status: Literals(["passed", "failed"]),
496
- preExisting: Boolean2,
497
- durationMs: Finite,
498
- evidenceId: String4,
499
- outputTail: optionalKey(String4),
500
- failedTests: optionalKey(ArraySchema(String4)),
501
- suggested: optionalKey(Boolean2),
502
- skippedSinceBaseline: optionalKey(ArraySchema(String4)),
503
- newNotRun: optionalKey(ArraySchema(String4)),
504
- environmentFailure: optionalKey(Struct({
505
- failedTests: optionalKey(ArraySchema(String4)),
506
- exitCode: optionalKey(Int),
507
- outputTail: optionalKey(String4),
508
- retryFailedTests: optionalKey(ArraySchema(String4))
509
- }))
510
- });
511
- var VerifyResult = Struct({
512
- revision: String4,
513
- tree: String4,
514
- passed: Boolean2,
515
- unchanged: optionalKey(Boolean2),
516
- checks: ArraySchema(EvidenceCheck)
517
- });
518
-
519
- // packages/sdk/src/loop/steps.ts
520
- class StepFailed extends TaggedError2()("StepFailed", {
521
- step: String4,
522
- reason: String4,
523
- code: optional(String4)
524
- }) {
525
- get message() {
526
- return `Step "${this.step}" failed: ${this.reason}`;
527
- }
528
- }
529
- class OutputInvalid extends TaggedError2()("OutputInvalid", {
530
- step: String4,
531
- message: String4
532
- }) {
533
- }
534
-
535
- class QuestionRefused extends TaggedError2()("QuestionRefused", {
536
- step: String4,
537
- answer: String4,
538
- options: ArraySchema(String4)
539
- }) {
540
- }
541
-
542
- class WaitTimedOut extends TaggedError2()("WaitTimedOut", {
543
- step: String4,
544
- event: String4
545
- }) {
546
- }
547
-
548
- class ChangeRequestClosed extends TaggedError2()("ChangeRequestClosed", {
549
- step: String4,
550
- merged: Boolean2
551
- }) {
552
- }
553
-
554
- class ChildFailed extends TaggedError2()("ChildFailed", {
555
- step: String4,
556
- loop: String4,
557
- reason: String4
558
- }) {
559
- get message() {
560
- return `Child Run of "${this.loop}" for Step "${this.step}" failed: ${this.reason}`;
561
- }
562
- }
563
-
564
- class CapabilityDenied extends TaggedError2()("CapabilityDenied", {
565
- step: String4,
566
- capability: Literals(LoopCapabilities),
567
- secret: optionalKey(String4)
568
- }) {
569
- get message() {
570
- 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`;
571
- }
572
- }
573
-
574
- class DuplicateStep extends TaggedError2()("DuplicateStep", {
575
- step: String4
576
- }) {
577
- }
578
-
579
- class InputInvalid extends TaggedError2()("InputInvalid", {
580
- loop: String4,
581
- message: String4
582
- }) {
583
- }
584
- var LoopEvent = Struct({ type: String4, payload: Record(String4, Json) });
585
-
586
- class LoopRun extends Service2()("@kitman-sh/sdk/loop/LoopRun") {
587
- }
588
-
589
- class LoopHost extends Service2()("@kitman-sh/sdk/loop/LoopHost") {
590
- }
591
- // packages/sdk/src/loop/plan.ts
592
- var PlanTicket = Struct({
593
- key: String4,
594
- title: String4,
595
- body: String4,
596
- acceptanceCriteria: ArraySchema(String4),
597
- promise: optional(String4),
598
- outOfScope: optional(ArraySchema(String4)),
599
- repoBindingId: optional(String4),
600
- blockedBy: ArraySchema(String4),
601
- outcome: optional(LoopOutcome)
602
- });
603
- var cycleMessage = (keys) => `These tickets block each other in a cycle, so none can start: ${keys.join(", ")}`;
604
- var ticketsProblem = (tickets) => {
605
- const keys = new Set;
606
- for (const ticket of tickets) {
607
- if (keys.has(ticket.key))
608
- return `Two tickets have the key "${ticket.key}"`;
609
- keys.add(ticket.key);
610
- }
611
- for (const ticket of tickets)
612
- for (const blocker of ticket.blockedBy)
613
- if (!keys.has(blocker))
614
- return `Ticket "${ticket.key}" is blocked by "${blocker}", which is not a ticket`;
615
- const { blocked } = wavesOf(tickets);
616
- return blocked.length === 0 ? undefined : cycleMessage(blocked);
617
- };
618
- var planTicketsOf = (ticket) => ArraySchema(ticket).check(makeFilter((tickets) => ticketsProblem(tickets) ?? true));
619
- var PlanTickets = planTicketsOf(PlanTicket);
620
-
621
- class BlockingCycle extends TaggedError2()("BlockingCycle", {
622
- tickets: ArraySchema(String4)
623
- }) {
624
- get message() {
625
- return cycleMessage(this.tickets);
626
- }
627
- }
628
- var byRepoBinding = (left, right) => (left.repoBindingId ?? "").localeCompare(right.repoBindingId ?? "");
629
- function wavesOf(tickets) {
630
- const placed = new Set;
631
- const waves = [];
632
- let left = tickets;
633
- while (left.length > 0) {
634
- const ready = left.filter((ticket) => ticket.blockedBy.every((blocker) => placed.has(blocker)));
635
- if (ready.length === 0)
636
- break;
637
- for (const ticket of ready)
638
- placed.add(ticket.key);
639
- waves.push(ready.toSorted(byRepoBinding));
640
- left = left.filter((ticket) => !placed.has(ticket.key));
641
- }
642
- return { waves, blocked: left.map((ticket) => ticket.key) };
643
- }
644
-
645
- // packages/sdk/src/loop/activities.ts
646
- var ChangeRequestRequest = Struct({
647
- title: String4,
648
- body: String4,
649
- integration: optional(String4)
650
- });
651
- var ChangeRequestResult = Struct({ id: String4, number: String4, url: String4 });
652
- var WriteBackMilestones = ["started", "change_request_opened", "merged", "failed", "blocked"];
653
- var WriteBackRequest = Struct({
654
- milestone: optional(Literals(WriteBackMilestones)),
655
- changeRequestUrl: optional(String4)
656
- });
657
- var RunFile = Struct({ runFile: String4 }).pipe(decodeTo2(Struct({ id: String4 }), transform({
658
- decode: ({ runFile }) => ({ id: runFile }),
659
- encode: ({ id }) => ({ runFile: id })
660
- })));
661
- var FileRequest = Struct({ path: String4, caption: optional(String4) });
662
- var ArtifactRequest = Struct({
663
- kind: String4,
664
- title: String4,
665
- text: String4,
666
- data: optional(Json),
667
- files: optional(ArraySchema(RunFile))
668
- });
669
- var ArtifactResult = Struct({ artifactId: String4 });
670
- var NoteRequest = Struct({
671
- text: String4,
672
- artifactId: optional(String4),
673
- kind: optional(Literals(["note", "blocker"]))
674
- });
675
- var CreateTasksRequest = Struct({
676
- tickets: ArraySchema(PlanTicket),
677
- projectId: optionalKey(String4),
678
- builds: optionalKey(Boolean2),
679
- releases: optionalKey(Boolean2),
680
- planReviewed: optionalKey(Boolean2)
681
- });
682
- var CreateTasksResult = Struct({
683
- tasks: ArraySchema(Struct({ key: String4, taskId: String4 }))
684
- });
685
- var AlertTaskRequest = Struct({
686
- fingerprint: String4.check(isMinLength(1), isMaxLength(400)),
687
- title: String4,
688
- windowHours: Int.check(isGreaterThanOrEqualTo(0), isLessThanOrEqualTo(720)),
689
- resolved: optionalKey(Boolean2),
690
- priority: optionalKey(Literals(["urgent", "high", "medium", "low"]))
691
- });
692
- var AlertTaskResult = Struct({
693
- taskId: optionalKey(String4),
694
- created: Boolean2,
695
- resolved: optionalKey(Boolean2),
696
- joined: optionalKey(Struct({ kind: Literals(["run", "recent"]), runId: String4 }))
697
- });
698
- var IntegrationBranchRequest = Struct({
699
- repoBindingId: optional(String4),
700
- base: optional(Boolean2)
701
- });
702
- var IntegrationBranch = Struct({
703
- repoBindingId: String4,
704
- branch: String4,
705
- revision: String4
706
- });
707
- var MergeChangeRequestRequest = Struct({
708
- changeRequestId: String4,
709
- head: optionalKey(String4),
710
- rebase: optionalKey(Boolean2)
711
- });
712
- var MergeResult = Union([
713
- Struct({ status: Literal("merged"), revision: String4 }),
714
- Struct({
715
- status: Literal("conflict"),
716
- reason: optionalKey(Literals(["conflicts", "behind", "not_ready"]))
717
- }),
718
- Struct({ status: Literal("moved"), head: String4 })
719
- ]);
720
- var ApproveChangeRequestRequest = Struct({
721
- changeRequestId: String4,
722
- head: String4,
723
- summary: String4,
724
- review: optionalKey(String4),
725
- carries: optionalKey(String4),
726
- reuses: optionalKey(String4)
727
- });
728
- var ApproveChangeRequestResult = Union([
729
- Struct({ approved: Literal(true), reviewId: String4 }),
730
- Struct({ approved: Literal(false), reason: String4 })
731
- ]);
732
- var CloseChangeRequestRequest = Struct({
733
- number: String4,
734
- head: String4,
735
- note: String4
736
- });
737
- var CloseChangeRequestResult = Struct({
738
- closed: Boolean2,
739
- head: optionalKey(String4)
740
- });
741
- var RerunPipelineRequest = Union([
742
- Struct({ changeRequestId: String4 }),
743
- Struct({ ref: String4, all: optionalKey(Boolean2) })
744
- ]);
745
- var RerunPipelineResult = Struct({ head: String4, pipelines: Int });
746
- var ReportPipelineRequest = Struct({ changeRequestId: String4, verification: String4 });
747
- var ReportPipelineResult = Struct({
748
- head: String4,
749
- status: Literals(["success", "failed"])
750
- });
751
- var CommentRequest = Struct({
752
- changeRequestId: String4,
753
- body: String4,
754
- threadId: optionalKey(String4),
755
- summary: optionalKey(String4),
756
- anchors: optionalKey(ArraySchema(Struct({
757
- file: String4,
758
- line: Int.check(isGreaterThanOrEqualTo(1)),
759
- body: String4.check(isMinLength(1))
760
- })))
761
- });
762
- var ReleaseRequest = Struct({
763
- tag: String4,
764
- revision: optional(String4),
765
- title: String4,
766
- notes: String4
767
- });
768
- var ReleaseResult = Struct({ tag: String4, revision: String4, url: String4 });
769
- var ChangeRequestReadRequest = Struct({ changeRequestId: String4 });
770
- var PipelineJob = Struct({
771
- name: String4,
772
- status: Literals(["running", "success", "failed", "skipped"]),
773
- url: optional(String4),
774
- logTail: optional(String4)
775
- });
776
- var PipelineStatus = Struct({
777
- head: String4,
778
- status: Literals(["none", "running", "success", "failed", "canceled"]),
779
- source: Literals(["forge", "reported"]),
780
- jobs: ArraySchema(PipelineJob),
781
- readAt: optionalKey(String4),
782
- runnerChecks: optionalKey(ArraySchema(String4)),
783
- targetChecks: optionalKey(ArraySchema(String4)),
784
- approved: optionalKey(String4),
785
- reviewed: optionalKey(Struct({ review: String4, notRun: optionalKey(ArraySchema(String4)) })),
786
- repository: optionalKey(String4),
787
- sourceBranch: optionalKey(String4),
788
- targetBranch: optionalKey(String4),
789
- conflicts: optionalKey(Boolean2),
790
- needsRebase: optionalKey(Boolean2),
791
- target: optionalKey(Struct({ branch: String4, head: String4, jobs: ArraySchema(PipelineJob) }))
792
- });
793
- var ReviewThread = Struct({
794
- id: String4,
795
- path: optional(String4),
796
- line: optional(Int),
797
- outdated: optional(Boolean2),
798
- comments: ArraySchema(Struct({ author: optional(String4), body: String4 }))
799
- });
800
- var ReviewThreads = Struct({ threads: ArraySchema(ReviewThread) });
801
- var OpenChangeRequestsRequest = Struct({ authors: NonEmptyArray(String4) });
802
- var OpenChangeRequest = Struct({
803
- number: String4,
804
- title: String4,
805
- body: String4,
806
- url: String4,
807
- author: String4,
808
- sourceBranch: String4,
809
- head: String4
810
- });
811
- var OpenChangeRequests = Struct({ changeRequests: ArraySchema(OpenChangeRequest) });
812
- var OwnChangeRequest = Struct({
813
- id: String4,
814
- number: String4,
815
- url: String4,
816
- title: String4,
817
- sourceBranch: String4,
818
- body: String4
819
- });
820
- var OwnChangeRequests = Struct({ changeRequests: ArraySchema(OwnChangeRequest) });
821
- var TranscriptPoint = Struct({
822
- runId: String4,
823
- stepAttemptId: String4,
824
- sequence: Int
825
- });
826
- var TranscriptsRequest = Struct({
827
- days: Int.check(isGreaterThanOrEqualTo(1), isLessThanOrEqualTo(31)),
828
- teamId: optionalKey(String4),
829
- projectId: optionalKey(String4),
830
- fileIntoProjectId: optionalKey(String4)
831
- });
832
- var TranscriptsResult = Struct({
833
- runs: ArraySchema(Struct({
834
- runId: String4,
835
- loopId: String4,
836
- rootRunId: optional(String4),
837
- status: optional(Literals(["completed", "failed", "canceled", "expired"])),
838
- teamId: optional(String4),
839
- failure: optional(String4),
840
- retried: optional(Boolean2),
841
- entries: ArraySchema(Struct({ stepAttemptId: String4, sequence: Int, kind: String4, text: String4 })),
842
- omitted: optional(Int)
843
- })),
844
- artifactId: optional(String4),
845
- findings: optional(ArraySchema(Struct({
846
- key: String4,
847
- title: String4,
848
- taskId: optional(String4),
849
- taskKey: optional(String4)
850
- })))
851
- });
852
- var Citations = NonEmptyArray(TranscriptPoint);
853
- var ProposeRequest = Union([
854
- Struct({
855
- kind: Literal("memory"),
856
- teamId: String4,
857
- content: String4,
858
- citations: Citations
859
- }),
860
- Struct({
861
- kind: Literal("task"),
862
- title: String4,
863
- description: String4,
864
- teamId: optional(String4),
865
- projectId: optionalKey(String4),
866
- key: optionalKey(String4.check(isPattern(/^[a-z0-9]+(?:-[a-z0-9]+)*$/), isMaxLength(80))),
867
- citations: Citations
868
- })
869
- ]);
870
- var ProposeResult = Struct({
871
- kind: Literals(["memory", "task"]),
872
- id: String4,
873
- matched: optionalKey(Boolean2),
874
- task: optionalKey(Struct({ id: String4, active: Boolean2 }))
875
- });
876
- var Health = Literals(["on_track", "at_risk", "off_track"]);
877
- var ProjectActivityRequest = Struct({ projectId: String4 });
878
- var ProjectActivityResult = Struct({
879
- project: Struct({ id: String4, name: String4 }),
880
- health: optional(Health),
881
- since: optional(String4),
882
- runs: ArraySchema(Struct({
883
- runId: String4,
884
- loopId: String4,
885
- status: String4,
886
- taskKey: optional(String4),
887
- taskTitle: optional(String4),
888
- summary: optional(String4),
889
- entries: ArraySchema(Struct({ stepAttemptId: String4, sequence: Int, kind: String4, text: String4 }))
890
- })),
891
- taskChanges: ArraySchema(Struct({ taskKey: String4, title: String4, change: String4, at: String4 }))
892
- });
893
- var DraftUpdateRequest = Struct({
894
- projectId: String4,
895
- health: Health,
896
- note: String4,
897
- writtenFrom: Struct({
898
- runs: Int,
899
- taskChanges: Int,
900
- since: optional(String4)
901
- })
902
- });
903
- var DraftUpdateResult = Struct({ id: String4 });
904
-
905
- class ChangeRequestActivity extends Service2()("@kitman-sh/sdk/loop/ChangeRequestActivity") {
906
- }
907
-
908
- class WriteBackActivity extends Service2()("@kitman-sh/sdk/loop/WriteBackActivity") {
909
- }
910
-
911
- class ArtifactActivity extends Service2()("@kitman-sh/sdk/loop/ArtifactActivity") {
912
- }
913
-
914
- class FileActivity extends Service2()("@kitman-sh/sdk/loop/FileActivity") {
915
- }
916
-
917
- class NoteActivity extends Service2()("@kitman-sh/sdk/loop/NoteActivity") {
918
- }
919
-
920
- class CommentActivity extends Service2()("@kitman-sh/sdk/loop/CommentActivity") {
921
- }
922
-
923
- class CreateTasksActivity extends Service2()("@kitman-sh/sdk/loop/CreateTasksActivity") {
924
- }
925
-
926
- class AlertTaskActivity extends Service2()("@kitman-sh/sdk/loop/AlertTaskActivity") {
927
- }
928
-
929
- class IntegrationBranchActivity extends Service2()("@kitman-sh/sdk/loop/IntegrationBranchActivity") {
930
- }
931
-
932
- class MergeChangeRequestActivity extends Service2()("@kitman-sh/sdk/loop/MergeChangeRequestActivity") {
933
- }
934
-
935
- class ReleaseActivity extends Service2()("@kitman-sh/sdk/loop/ReleaseActivity") {
936
- }
937
-
938
- class TranscriptsActivity extends Service2()("@kitman-sh/sdk/loop/TranscriptsActivity") {
939
- }
940
-
941
- class ProposeActivity extends Service2()("@kitman-sh/sdk/loop/ProposeActivity") {
942
- }
943
-
944
- class ProjectActivityActivity extends Service2()("@kitman-sh/sdk/loop/ProjectActivityActivity") {
945
- }
946
-
947
- class DraftUpdateActivity extends Service2()("@kitman-sh/sdk/loop/DraftUpdateActivity") {
948
- }
949
-
950
- class ChangeRequestReadActivity extends Service2()("@kitman-sh/sdk/loop/ChangeRequestReadActivity") {
951
- }
952
- // packages/sdk/src/loop/measure.ts
953
- var MetricStats = Struct({
954
- samples: Finite,
955
- median: Finite,
956
- mean: Finite,
957
- min: Finite,
958
- max: Finite,
959
- stdev: Finite
960
- });
961
- var MeasureVerdict = Literals(["gain", "no_gain", "guardrail_regressed", "too_noisy"]);
962
- var Measurement = Struct({
963
- verdict: MeasureVerdict,
964
- reason: String4,
965
- metrics: ArraySchema(Struct({
966
- name: String4,
967
- role: Literals(["primary", "guardrail"]),
968
- direction: Literals(["lower", "higher"]),
969
- base: MetricStats,
970
- head: MetricStats,
971
- change: Finite,
972
- noise: Finite
973
- })),
974
- suggestion: optional(String4),
975
- evidence: MeasureEvidence
976
- });
977
- var floors = new WeakMap;
978
-
979
- // packages/sdk/src/loop/test-loop.ts
980
- var LoopJournal = Struct({
981
- activities: Record(String4, Json),
982
- deferreds: Record(String4, Json)
983
- });
984
-
985
- class ScriptedFailure extends TaggedClass("ScriptedFailure") {
986
- }
987
- // packages/sdk/src/loop/review.ts
988
- var Severity = Literals(["blocker", "major", "minor"]);
989
- var Finding = Struct({
990
- severity: Severity,
991
- file: String4,
992
- line: Int,
993
- detail: String4
994
- });
995
- var MergedFinding = Struct({
996
- id: String4,
997
- ...Finding.fields,
998
- seats: ArraySchema(String4),
999
- blockingSeats: optionalKey(ArraySchema(String4))
1000
- });
1001
- var Rebuttal = Struct({ findingId: String4, reason: String4 });
1002
- var RebuttalVerdict = Struct({ findingId: String4, accepted: Boolean2 });
1003
- var ScopeJudgement = Struct({ met: Boolean2, unmet: ArraySchema(String4) });
1004
- // packages/sdk/src/loop/check.ts
1005
- class CheckFailed extends TaggedError2()("CheckFailed", {
1006
- loop: String4,
1007
- check: String4,
1008
- reason: String4
1009
- }) {
1010
- get detail() {
1011
- return `Check "${this.check}": ${this.reason}`;
1012
- }
1013
- get message() {
1014
- return `Loop "${this.loop}": ${this.detail}`;
1015
- }
1016
- }
1017
-
1018
- class StepNamedTwice extends TaggedError2()("StepNamedTwice", {
1019
- loop: String4,
1020
- check: String4,
1021
- step: String4
1022
- }) {
1023
- get detail() {
1024
- return `Check "${this.check}": Step "${this.step}" is named twice`;
1025
- }
1026
- get message() {
1027
- return `Loop "${this.loop}": ${this.detail}`;
1028
- }
1029
- }
1030
-
1031
- class ReplayDiverged extends TaggedError2()("ReplayDiverged", {
1032
- loop: String4,
1033
- check: String4,
1034
- first: ArraySchema(String4),
1035
- replay: ArraySchema(String4),
1036
- rerun: ArraySchema(String4)
1037
- }) {
1038
- get detail() {
1039
- const steps = (names) => names.join(", ") || "no Steps";
1040
- 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.`;
1041
- }
1042
- get message() {
1043
- return `Loop "${this.loop}": ${this.detail}`;
1044
- }
1045
- }
1046
- var LoopCheckError = Union([CheckFailed, StepNamedTwice, ReplayDiverged]);
1047
- // packages/sdk/src/loop/sync.ts
1048
- var UpToDate = Struct({ status: Literal("up_to_date") });
1049
- var Conflict = Struct({
1050
- status: Literal("conflict"),
1051
- files: NonEmptyArray(String4),
1052
- reason: String4
1053
- });
1054
- var merged = {
1055
- status: Literal("merged"),
1056
- settled: ArraySchema(String4)
1057
- };
1058
- var SyncAnswer = Union([UpToDate, Struct(merged), Conflict]);
1059
- var reported = { base: optionalKey(String4) };
1060
- var BaseSync = Union([
1061
- Struct({ ...UpToDate.fields, ...reported }),
1062
- Struct({ ...merged, catchUp: optionalKey(CatchUp), ...reported }),
1063
- Struct({ ...Conflict.fields, ...reported })
1064
- ]);
1065
- // packages/sdk/src/loop/continuing.ts
1066
- var Continuing = Struct({
1067
- changeRequestId: String4,
1068
- number: String4,
1069
- url: String4,
1070
- branch: String4,
1071
- targetBranch: String4,
1072
- defaultBranch: optional(String4),
1073
- revision: optional(String4),
1074
- lastRunId: optional(String4),
1075
- lastRunStatus: optional(String4),
1076
- lastRunSummary: optional(String4)
1077
- });
1078
- // packages/sdk/src/program/engine.ts
1079
- class JournalWriteFailed extends TaggedError("JournalWriteFailed") {
1080
- get message() {
1081
- return `Journal write failed: ${this.cause.message}`;
1082
- }
1083
- }
1084
- var JournalEntries = Record(String4, Json);
1085
- var isSuspended = is(Suspended);
1086
- var emptyWorkflow = make("kitman-loop/none", { payload: {}, idempotencyKey: () => "none" });
1087
- var replayStatuses = new Set([401, 403, 409, 429]);
1088
- var isRunnerRpcError = is(RunnerRpcError);
1089
- var isRunFileRefused = is(RunFileRefused);
1090
- var issues = makeFormatterStandardSchemaV1();
1091
- var put2 = (target, contentType, body) => gen(function* () {
1092
- const response = yield* (yield* HttpClient).execute(put(target.url).pipe(bodyUint8Array(body, contentType), setHeaders(target.headers ?? {})));
1093
- return (yield* filterStatusOk(response)).headers.etag ?? "";
1094
- });
1095
- var readRange = (path, offset, size) => scoped(gen(function* () {
1096
- const file = yield* (yield* FileSystem).open(path);
1097
- return getOrElse(yield* file.readAlloc(size, { position: BigInt(offset) }), () => new Uint8Array);
1098
- }));
1099
- var partUrlMarginMillis = 60000;
1100
- var uploadParts = (files, path, contentType, fileId, upload) => forEach(upload.parts, (part) => gen(function* () {
1101
- const now = yield* currentTimeMillis;
1102
- const fresh = Date.parse(part.expiresAt) - now > partUrlMarginMillis ? part : (yield* files.runFileParts({ fileId, partNumbers: [part.partNumber] }))[0] ?? part;
1103
- const body = yield* readRange(path, (part.partNumber - 1) * upload.partSize, upload.partSize);
1104
- return { partNumber: part.partNumber, etag: yield* put2(fresh, contentType, body) };
1105
- }));
1106
- var uploadRunFile = (files, file) => gen(function* () {
1107
- const fs = yield* FileSystem;
1108
- const contentType = runFileContentType(file.name);
1109
- const byteSize = Number((yield* fs.stat(file.path)).size);
1110
- const hash = sha256Hasher();
1111
- yield* runForEach(fs.stream(file.path), (chunk) => sync2(() => hash.update(chunk)));
1112
- const { file: slotted, upload } = yield* files.createRunFile({
1113
- step: file.step,
1114
- name: file.name,
1115
- ...file.caption === undefined ? undefined : { caption: file.caption },
1116
- contentType,
1117
- byteSize,
1118
- sha256: hash.digest("hex")
1119
- });
1120
- if (upload === undefined)
1121
- return slotted;
1122
- 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 }));
1123
- });
1124
- var programLease = (work) => ({
1125
- workUnitId: work.id,
1126
- leaseOwnerId: work.lease.leaseOwnerId,
1127
- runnerReplicaId: work.lease.runnerReplicaId,
1128
- leaseId: work.lease.leaseId,
1129
- attempt: work.lease.attempt,
1130
- fencingToken: work.lease.fencingToken,
1131
- capacitySlot: work.lease.capacitySlot
1132
- });
1133
- var rpcRunFiles = (rpc, lease) => ({
1134
- createRunFile: (file) => rpc.createRunFile({ lease, ...file }),
1135
- runFileParts: (request) => map8(rpc.runFileParts({ lease, ...request, partNumbers: [...request.partNumbers] }), ({ parts }) => parts),
1136
- completeRunFile: ({ parts, ...request }) => rpc.completeRunFile({ lease, ...request, ...parts === undefined ? undefined : { parts: [...parts] } })
1137
- });
1138
-
1139
- // packages/sdk/src/program/host.ts
1140
- var describeFlag = "--kitman-describe";
1141
- var DescribedKit = Struct({
1142
- name: String4,
1143
- version: String4,
1144
- loops: ArraySchema(LoopManifest),
1145
- agents: Record(String4, Json),
1146
- schedules: optionalKey(Record(String4, Json)),
1147
- setup: optionalKey(KitSetup)
1148
- });
1149
- var Described = Union([
1150
- TaggedStruct("Described", { kits: ArraySchema(DescribedKit) }),
1151
- TaggedStruct("Refused", { error: Union([ManifestInvalid, LoopCheckError]) })
1152
- ]);
1153
- var encodeDescribed = encodeEffect(fromJsonString(toCodecJson(Described)));
1154
-
1155
- class ProgramRefused extends TaggedError2()("ProgramRefused", { reason: String4 }) {
1156
- get message() {
1157
- return this.reason;
1158
- }
1159
- }
1160
- var programHostsEnv = "KITMAN_PROGRAM_HOSTS";
1161
- var undeclaredHostsEnv = "KITMAN_UNDECLARED_HOSTS";
1162
- var redirectStatuses = new Set([301, 302, 303, 307, 308]);
1163
- var readStdin = tryPromise(() => Bun.stdin.text());
1164
- var isWorkUnit = guard(ProgramWorkUnit);
1165
-
1166
- export { AgentDeclaration, KitDeclarations, uploadRunFile, programLease, rpcRunFiles, describeFlag, Described, programHostsEnv, undeclaredHostsEnv };