@kitman-sh/sdk 0.7.5 → 0.8.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.
- package/dist/build/index.js +10 -11
- package/dist/{chunk-72z6zbfz.js → chunk-160ww64c.js} +668 -185
- package/dist/{chunk-8byx9rx2.js → chunk-36jhc745.js} +195 -76
- package/dist/loop/index.js +43 -1
- package/dist/program/index.js +7 -3
- package/package.json +3 -1
- package/types/packages/core/src/agent-capabilities.d.ts +68 -74
- package/types/packages/core/src/agent-environment.d.ts +26 -26
- package/types/packages/core/src/agent-launch-snapshot.d.ts +1 -1
- package/types/packages/core/src/agent-sandbox-policy.d.ts +15 -0
- package/types/packages/core/src/approval-queue.d.ts +4 -4
- package/types/packages/core/src/audit.d.ts +1 -1
- package/types/packages/core/src/change-delivery.d.ts +1 -1
- package/types/packages/core/src/change-request-review.d.ts +199 -7
- package/types/packages/core/src/change-request.d.ts +43 -12
- package/types/packages/core/src/connection.d.ts +1 -1
- package/types/packages/core/src/context-feedback.d.ts +8 -8
- package/types/packages/core/src/context-pack.d.ts +8 -8
- package/types/packages/core/src/crypto.d.ts +5 -0
- package/types/packages/core/src/data-lifecycle.d.ts +12 -12
- package/types/packages/core/src/decision.d.ts +2 -2
- package/types/packages/core/src/delivery-policy.d.ts +3 -3
- package/types/packages/core/src/enterprise-forge.d.ts +19 -0
- package/types/packages/core/src/epic-delivery.d.ts +1 -1
- package/types/packages/core/src/external-effect.d.ts +2 -2
- package/types/packages/core/src/global-search.d.ts +1 -1
- package/types/packages/core/src/index.d.ts +8 -2
- package/types/packages/core/src/integration.d.ts +58 -57
- package/types/packages/core/src/kit.d.ts +47 -47
- package/types/packages/core/src/live.d.ts +684 -781
- package/types/packages/core/src/loop-layers.d.ts +1 -1
- package/types/packages/core/src/loop-version.d.ts +1 -1
- package/types/packages/core/src/loop.d.ts +73 -67
- package/types/packages/core/src/marketplace.d.ts +127 -0
- package/types/packages/core/src/memory.d.ts +17 -12
- package/types/packages/core/src/my-teams.d.ts +65 -32
- package/types/packages/core/src/notification.d.ts +73 -12
- package/types/packages/core/src/owner.d.ts +15 -0
- package/types/packages/core/src/package-declarations.d.ts +73 -32
- package/types/packages/core/src/package.d.ts +22 -22
- package/types/packages/core/src/personal-development-profile.d.ts +2 -2
- package/types/packages/core/src/proposal.d.ts +25 -25
- package/types/packages/core/src/redaction.d.ts +2 -1
- package/types/packages/core/src/repo-binding.d.ts +19 -10
- package/types/packages/core/src/run-display.d.ts +1 -1
- package/types/packages/core/src/run-file.d.ts +190 -0
- package/types/packages/core/src/run-launch.d.ts +7 -5
- package/types/packages/core/src/run.d.ts +9 -9
- package/types/packages/core/src/runner-eligibility.d.ts +4 -4
- package/types/packages/core/src/runner.d.ts +339 -111
- package/types/packages/core/src/schedule.d.ts +2 -2
- package/types/packages/core/src/scope-directory.d.ts +5 -5
- package/types/packages/core/src/secret.d.ts +9 -9
- package/types/packages/core/src/session.d.ts +2 -2
- package/types/packages/core/src/step-brief.d.ts +10 -3
- package/types/packages/core/src/storage.d.ts +49 -0
- package/types/packages/core/src/sync-kit.d.ts +25 -25
- package/types/packages/core/src/task-detail.d.ts +20 -13
- package/types/packages/core/src/task-execution-record.d.ts +6 -6
- package/types/packages/core/src/task.d.ts +52 -16
- package/types/packages/core/src/team-context.d.ts +33 -0
- package/types/packages/core/src/transcript.d.ts +230 -0
- package/types/packages/core/src/trigger-dispatch.d.ts +2 -2
- package/types/packages/core/src/trust-panel.d.ts +27 -0
- package/types/packages/core/src/work-unit.d.ts +44 -18
- package/types/packages/core/src/workspace.d.ts +77 -6
- package/types/packages/live/src/rpc/runner-client.d.ts +586 -15
- package/types/packages/live/src/rpc/runner-group.d.ts +623 -267
- package/types/packages/sdk/src/loop/activities.d.ts +208 -1
- package/types/packages/sdk/src/loop/config.d.ts +1 -1
- package/types/packages/sdk/src/loop/define.d.ts +8 -2
- package/types/packages/sdk/src/loop/plan.d.ts +2 -2
- package/types/packages/sdk/src/loop/steps.d.ts +2 -2
- package/types/packages/sdk/src/loop/test-loop.d.ts +6 -1
- package/types/packages/sdk/src/program/engine.d.ts +71 -3
- package/types/packages/sdk/src/program/host.d.ts +13 -1
- package/types/packages/core/src/enterprise-code-host.d.ts +0 -18
- package/types/packages/core/src/project.d.ts +0 -66
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
AgentSandboxNetwork,
|
|
4
|
+
Numeric,
|
|
5
|
+
isWholeNumber,
|
|
4
6
|
guard,
|
|
5
7
|
Id,
|
|
6
8
|
Timestamp,
|
|
@@ -19,15 +21,14 @@ import {
|
|
|
19
21
|
executeLoop2,
|
|
20
22
|
LoopCheckError2,
|
|
21
23
|
checkLoop2
|
|
22
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-36jhc745.js";
|
|
23
25
|
// packages/core/src/repo-binding.ts
|
|
24
26
|
import * as Schema from "effect/Schema";
|
|
27
|
+
var ForgeKinds = ["github", "gitlab", "forgejo", "gitea", "gitee", "bitbucket", "azure-devops"];
|
|
28
|
+
var ForgeKind = Schema.Literals(ForgeKinds);
|
|
29
|
+
var RepoBindingProviders = [...ForgeKinds, "generic_git"];
|
|
25
30
|
var RepoBindingPathPrefixPattern = "^(?!/)(?!.*\\\\)(?!.*(?:^|/)\\.\\.?(?:/|$))(?!.*//)\\S+$";
|
|
26
|
-
var RepoBindingProvider = Schema.
|
|
27
|
-
Schema.Literal("github"),
|
|
28
|
-
Schema.Literal("gitlab"),
|
|
29
|
-
Schema.Literal("generic_git")
|
|
30
|
-
]);
|
|
31
|
+
var RepoBindingProvider = Schema.Literals(RepoBindingProviders);
|
|
31
32
|
var RepoBindingStatus = Schema.Union([Schema.Literal("active"), Schema.Literal("disabled")]);
|
|
32
33
|
var RepoBindingCredentialProviderType = Schema.Union([
|
|
33
34
|
Schema.Literal("env"),
|
|
@@ -52,7 +53,7 @@ var RepoBindingCredentialRef = Schema.Union([
|
|
|
52
53
|
var RepoBinding = Schema.Struct({
|
|
53
54
|
id: Id,
|
|
54
55
|
workspaceId: Id,
|
|
55
|
-
|
|
56
|
+
teamId: Schema.optionalKey(Id),
|
|
56
57
|
provider: RepoBindingProvider,
|
|
57
58
|
host: Schema.String.check(Schema.isMinLength(1)),
|
|
58
59
|
owner: Schema.String.check(Schema.isMinLength(1)),
|
|
@@ -65,13 +66,14 @@ var RepoBinding = Schema.Struct({
|
|
|
65
66
|
credentialRefs: Schema.Array(RepoBindingCredentialRef),
|
|
66
67
|
status: RepoBindingStatus,
|
|
67
68
|
webhook: Schema.optionalKey(Schema.Struct({
|
|
68
|
-
status: Schema.Literals(["active", "missing"]),
|
|
69
|
+
status: Schema.Literals(["active", "missing", "unavailable"]),
|
|
69
70
|
message: Schema.optionalKey(Schema.String.check(Schema.isMaxLength(240)))
|
|
70
71
|
})),
|
|
71
72
|
createdAt: Timestamp,
|
|
72
73
|
updatedAt: Timestamp
|
|
73
74
|
});
|
|
74
75
|
var RepoBindingCreate = Schema.Struct({
|
|
76
|
+
teamId: Schema.optionalKey(Id),
|
|
75
77
|
provider: RepoBindingProvider,
|
|
76
78
|
host: Schema.String.check(Schema.isMinLength(1)),
|
|
77
79
|
owner: Schema.String.check(Schema.isMinLength(1)),
|
|
@@ -96,6 +98,7 @@ var RunnerRepoBindingCapability = Schema.Struct({
|
|
|
96
98
|
authenticated: Schema.Boolean,
|
|
97
99
|
canPush: Schema.optionalKey(Schema.Boolean)
|
|
98
100
|
});
|
|
101
|
+
|
|
99
102
|
// packages/core/src/work-unit.ts
|
|
100
103
|
import * as Schema2 from "effect/Schema";
|
|
101
104
|
import * as Struct3 from "effect/Struct";
|
|
@@ -142,10 +145,11 @@ var WorkUnitStatus = Schema2.Union([
|
|
|
142
145
|
Schema2.Literal("expired")
|
|
143
146
|
]);
|
|
144
147
|
var LoopCheckout = Schema2.Union([Schema2.Literal("none"), Schema2.Literal("read"), Schema2.Literal("write")]);
|
|
148
|
+
var StorageOrigin = Schema2.optionalKey(Schema2.String.check(Schema2.isMinLength(1), Schema2.isMaxLength(2048)));
|
|
145
149
|
var AgentStepWorkUnit = Schema2.Struct({
|
|
146
150
|
kind: Schema2.Literal("agent_step"),
|
|
147
151
|
id: Id,
|
|
148
|
-
|
|
152
|
+
teamId: Schema2.optionalKey(Id),
|
|
149
153
|
runId: Id,
|
|
150
154
|
stepKey: Schema2.String.check(Schema2.isMinLength(1), Schema2.isMaxLength(240)),
|
|
151
155
|
attempt: Schema2.Int.check(Schema2.isGreaterThanOrEqualTo(1)),
|
|
@@ -159,7 +163,8 @@ var AgentStepWorkUnit = Schema2.Struct({
|
|
|
159
163
|
network: Schema2.optionalKey(AgentSandboxNetwork),
|
|
160
164
|
sandbox: Schema2.optionalKey(Schema2.Literal("docker")),
|
|
161
165
|
secrets: Schema2.optionalKey(Schema2.Record(Schema2.String, Schema2.String)),
|
|
162
|
-
runBaseRevision: Schema2.optionalKey(Schema2.String.check(Schema2.isMinLength(1)))
|
|
166
|
+
runBaseRevision: Schema2.optionalKey(Schema2.String.check(Schema2.isMinLength(1))),
|
|
167
|
+
storageOrigin: StorageOrigin
|
|
163
168
|
});
|
|
164
169
|
var RunJournal = Schema2.Struct({
|
|
165
170
|
activities: Schema2.Record(Schema2.String, Schema2.Unknown),
|
|
@@ -168,7 +173,7 @@ var RunJournal = Schema2.Struct({
|
|
|
168
173
|
var OrchestrationWorkUnit = Schema2.Struct({
|
|
169
174
|
kind: Schema2.Literal("orchestration"),
|
|
170
175
|
id: Id,
|
|
171
|
-
|
|
176
|
+
teamId: Schema2.optionalKey(Id),
|
|
172
177
|
runId: Id,
|
|
173
178
|
loopDigest: Schema2.String.check(Schema2.isMinLength(64), Schema2.isMaxLength(64), Schema2.isPattern(new RegExp("^[a-f0-9]{64}$", "u"))),
|
|
174
179
|
input: Schema2.Unknown,
|
|
@@ -176,6 +181,7 @@ var OrchestrationWorkUnit = Schema2.Struct({
|
|
|
176
181
|
lease: WorkUnitLease,
|
|
177
182
|
journal: RunJournal,
|
|
178
183
|
network: Schema2.optionalKey(AgentSandboxNetwork),
|
|
184
|
+
storageOrigin: StorageOrigin,
|
|
179
185
|
program: Schema2.Struct({
|
|
180
186
|
loopId: Schema2.String.check(Schema2.isMinLength(1)),
|
|
181
187
|
credential: Schema2.String.check(Schema2.isMinLength(1))
|
|
@@ -190,18 +196,19 @@ var ApprovedCheck = Schema2.Struct({
|
|
|
190
196
|
var VerificationWorkUnit = Schema2.Struct({
|
|
191
197
|
kind: Schema2.Literal("verification"),
|
|
192
198
|
id: Id,
|
|
193
|
-
|
|
199
|
+
teamId: Schema2.optionalKey(Id),
|
|
194
200
|
runId: Id,
|
|
195
201
|
stepKey: Schema2.String.check(Schema2.isMinLength(1), Schema2.isMaxLength(240)),
|
|
196
202
|
lease: WorkUnitLease,
|
|
197
203
|
repoBinding: WorkUnitRepoBinding,
|
|
198
204
|
revision: Schema2.String.check(Schema2.isMinLength(1), Schema2.isMaxLength(240)),
|
|
199
|
-
checks: Schema2.Array(ApprovedCheck).check(Schema2.isMinLength(1), Schema2.isMaxLength(50))
|
|
205
|
+
checks: Schema2.Array(ApprovedCheck).check(Schema2.isMinLength(1), Schema2.isMaxLength(50)),
|
|
206
|
+
storageOrigin: StorageOrigin
|
|
200
207
|
});
|
|
201
208
|
var WorkUnit = Schema2.Union([OrchestrationWorkUnit, AgentStepWorkUnit, VerificationWorkUnit]);
|
|
202
209
|
var WorkUnitClaimResult = Schema2.Struct({ workUnit: Schema2.optionalKey(WorkUnit) });
|
|
203
210
|
var WorkUnitClaimInput = Schema2.Struct({
|
|
204
|
-
|
|
211
|
+
teamId: Schema2.optionalKey(Id),
|
|
205
212
|
runnerReplicaId: Id,
|
|
206
213
|
capacitySlot: Schema2.String.check(Schema2.isMinLength(1), Schema2.isMaxLength(240)),
|
|
207
214
|
idempotencyKey: Schema2.String.check(Schema2.isMinLength(1), Schema2.isMaxLength(240)),
|
|
@@ -226,7 +233,8 @@ var CheckEvidence = Schema2.Struct({
|
|
|
226
233
|
status: Schema2.Union([Schema2.Literal("passed"), Schema2.Literal("failed")]),
|
|
227
234
|
exitCode: Schema2.optionalKey(Schema2.Int),
|
|
228
235
|
durationMs: Schema2.Int.check(Schema2.isGreaterThanOrEqualTo(0)),
|
|
229
|
-
outputTail: Schema2.String.check(Schema2.isMaxLength(8000))
|
|
236
|
+
outputTail: Schema2.String.check(Schema2.isMaxLength(8000)),
|
|
237
|
+
fileIds: Schema2.optionalKey(Schema2.Array(Schema2.String).check(Schema2.isMaxLength(51)))
|
|
230
238
|
});
|
|
231
239
|
var TreeEvidence = Schema2.Struct({
|
|
232
240
|
revision: Schema2.String.check(Schema2.isMinLength(1), Schema2.isMaxLength(240)),
|
|
@@ -265,43 +273,292 @@ var WorkUnitCompletion = Schema2.Struct({
|
|
|
265
273
|
idempotencyKey: Schema2.String.check(Schema2.isMinLength(1), Schema2.isMaxLength(240)),
|
|
266
274
|
outcome: WorkUnitOutcome
|
|
267
275
|
});
|
|
276
|
+
// packages/core/src/run-file.ts
|
|
277
|
+
import * as Schema4 from "effect/Schema";
|
|
278
|
+
|
|
279
|
+
// packages/core/src/storage.ts
|
|
280
|
+
import * as Schema3 from "effect/Schema";
|
|
281
|
+
var units = ["B", "KiB", "MiB", "GiB", "TiB"];
|
|
282
|
+
var formatBytes = (bytes) => {
|
|
283
|
+
const exponent = Math.min(units.length - 1, Math.floor(Math.log(Math.max(bytes, 1)) / Math.log(1024)));
|
|
284
|
+
return `${Number((bytes / 1024 ** exponent).toFixed(1))} ${units[exponent]}`;
|
|
285
|
+
};
|
|
286
|
+
var storageLimitWords = {
|
|
287
|
+
quota: (quotaBytes) => `${formatBytes(quotaBytes)} in all`,
|
|
288
|
+
file: (fileBytes) => `${formatBytes(fileBytes)} per file`,
|
|
289
|
+
run: (filesPerRun) => `${filesPerRun} files per Run`
|
|
290
|
+
};
|
|
291
|
+
var maxRunFileRetentionDays = 3650;
|
|
292
|
+
var RunFileRetentionDays = Schema3.NullOr(Schema3.Int.check(Schema3.isGreaterThanOrEqualTo(1), Schema3.isLessThanOrEqualTo(maxRunFileRetentionDays)));
|
|
293
|
+
var WorkspaceStorageSettings = Schema3.Struct({
|
|
294
|
+
usedBytes: Schema3.Int,
|
|
295
|
+
quotaBytes: Schema3.Int,
|
|
296
|
+
byPurpose: Schema3.Struct({ runFile: Schema3.Int, taskAsset: Schema3.Int, checkpoint: Schema3.Int }),
|
|
297
|
+
limits: Schema3.Struct({ fileBytes: Schema3.Int, filesPerRun: Schema3.Int }),
|
|
298
|
+
runFileRetentionDays: RunFileRetentionDays
|
|
299
|
+
});
|
|
300
|
+
var WorkspaceStorageUpdate = Schema3.Struct({ runFileRetentionDays: RunFileRetentionDays });
|
|
301
|
+
var WorkspaceStorageSaved = Schema3.Struct({ ...WorkspaceStorageSettings.fields, willExpire: Schema3.Int });
|
|
302
|
+
|
|
303
|
+
// packages/core/src/run-file.ts
|
|
304
|
+
var RunFileRefusalReasons = ["type", "too_large", "too_many", "quota", "name_taken"];
|
|
305
|
+
var runFileRefusalWords = (refusal) => {
|
|
306
|
+
switch (refusal.reason) {
|
|
307
|
+
case "type":
|
|
308
|
+
return "Kitman keeps images, videos, HTML, text, logs, PDFs and archives as Run Files; return structured data in an Output or an artifact";
|
|
309
|
+
case "too_large":
|
|
310
|
+
return `Over ${storageLimitWords.file(refusal.limit ?? 0)}: ${formatBytes(refusal.actual ?? 0)}`;
|
|
311
|
+
case "too_many":
|
|
312
|
+
return `Over ${storageLimitWords.run(refusal.limit ?? 0)}: this would be file ${refusal.actual}`;
|
|
313
|
+
case "quota":
|
|
314
|
+
return `Over the Workspace's ${storageLimitWords.quota(refusal.limit ?? 0)}: it would hold ${formatBytes(refusal.actual ?? 0)}`;
|
|
315
|
+
case "name_taken":
|
|
316
|
+
return "The Step already kept a different file under this name";
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
class RunFileRefused extends Schema4.TaggedError()("RunFileRefused", {
|
|
321
|
+
reason: Schema4.Literals(RunFileRefusalReasons),
|
|
322
|
+
limit: Schema4.optionalKey(Schema4.Int),
|
|
323
|
+
actual: Schema4.optionalKey(Schema4.Int)
|
|
324
|
+
}) {
|
|
325
|
+
get message() {
|
|
326
|
+
return runFileRefusalWords(this);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
var contentTypes = new Map([
|
|
330
|
+
["png", "image/png"],
|
|
331
|
+
["jpg", "image/jpeg"],
|
|
332
|
+
["jpeg", "image/jpeg"],
|
|
333
|
+
["webp", "image/webp"],
|
|
334
|
+
["gif", "image/gif"],
|
|
335
|
+
["webm", "video/webm"],
|
|
336
|
+
["mp4", "video/mp4"],
|
|
337
|
+
["html", "text/html"],
|
|
338
|
+
["htm", "text/html"],
|
|
339
|
+
["txt", "text/plain"],
|
|
340
|
+
["log", "text/x-log"],
|
|
341
|
+
["pdf", "application/pdf"],
|
|
342
|
+
["zip", "application/zip"],
|
|
343
|
+
["gz", "application/gzip"],
|
|
344
|
+
["tgz", "application/gzip"],
|
|
345
|
+
["tar", "application/x-tar"],
|
|
346
|
+
["json", "application/json"]
|
|
347
|
+
]);
|
|
348
|
+
var runFileContentType = (name) => contentTypes.get(name.split(".").at(-1)?.toLowerCase() ?? "") ?? "application/octet-stream";
|
|
349
|
+
var RunFileKinds = ["image", "video", "html", "text", "other"];
|
|
350
|
+
var RunFileStatuses = [
|
|
351
|
+
"uploading",
|
|
352
|
+
"available",
|
|
353
|
+
"rejected",
|
|
354
|
+
"refused",
|
|
355
|
+
"removing",
|
|
356
|
+
"removed",
|
|
357
|
+
"expired"
|
|
358
|
+
];
|
|
359
|
+
var RunFileRecord = Schema4.Struct({
|
|
360
|
+
id: Schema4.String,
|
|
361
|
+
runId: Schema4.String,
|
|
362
|
+
step: Schema4.String,
|
|
363
|
+
name: Schema4.String,
|
|
364
|
+
caption: Schema4.optionalKey(Schema4.String),
|
|
365
|
+
contentType: Schema4.String,
|
|
366
|
+
kind: Schema4.Literals(RunFileKinds),
|
|
367
|
+
byteSize: Schema4.Int,
|
|
368
|
+
sha256: Schema4.String,
|
|
369
|
+
status: Schema4.Literals(RunFileStatuses)
|
|
370
|
+
});
|
|
371
|
+
var RunFileMakers = ["program", "agent", "check"];
|
|
372
|
+
var RunFileView = Schema4.Struct({
|
|
373
|
+
id: Schema4.String,
|
|
374
|
+
runId: Schema4.String,
|
|
375
|
+
step: Schema4.String,
|
|
376
|
+
stepAttemptId: Schema4.optionalKey(Schema4.String),
|
|
377
|
+
verificationId: Schema4.optionalKey(Schema4.String),
|
|
378
|
+
madeBy: Schema4.Literals(RunFileMakers),
|
|
379
|
+
name: Schema4.String,
|
|
380
|
+
caption: Schema4.optionalKey(Schema4.String),
|
|
381
|
+
kind: Schema4.Literals(RunFileKinds),
|
|
382
|
+
contentType: Schema4.String,
|
|
383
|
+
byteSize: Schema4.Int,
|
|
384
|
+
sha256: Schema4.String,
|
|
385
|
+
status: Schema4.Literals(RunFileStatuses),
|
|
386
|
+
reason: Schema4.optionalKey(Schema4.String),
|
|
387
|
+
limit: Schema4.optionalKey(Schema4.Int),
|
|
388
|
+
actual: Schema4.optionalKey(Schema4.Int),
|
|
389
|
+
removedBy: Schema4.optionalKey(Schema4.String),
|
|
390
|
+
removedAt: Schema4.optionalKey(Timestamp),
|
|
391
|
+
createdAt: Timestamp
|
|
392
|
+
});
|
|
393
|
+
var RunFileList = Schema4.Union([
|
|
394
|
+
Schema4.Struct({ files: Schema4.Array(RunFileView) }),
|
|
395
|
+
Schema4.Struct({ count: Schema4.Int })
|
|
396
|
+
]);
|
|
397
|
+
var RunFileUrlsRequest = Schema4.Struct({
|
|
398
|
+
ids: Schema4.Array(Id).check(Schema4.isMinLength(1), Schema4.isMaxLength(200)),
|
|
399
|
+
use: Schema4.Literals(["view", "download"])
|
|
400
|
+
});
|
|
401
|
+
var RunFileRemoveRequest = Schema4.Struct({
|
|
402
|
+
note: Schema4.optionalKey(Schema4.String.check(Schema4.isMaxLength(500)))
|
|
403
|
+
});
|
|
404
|
+
var RunFileUrl = Schema4.Struct({ id: Schema4.String, url: Schema4.String, expiresAt: Timestamp });
|
|
405
|
+
var RunFileUrls = Schema4.Struct({ urls: Schema4.Array(RunFileUrl) });
|
|
406
|
+
var PresignedRequest = {
|
|
407
|
+
url: Schema4.String,
|
|
408
|
+
headers: Schema4.optionalKey(Schema4.Record(Schema4.String, Schema4.String)),
|
|
409
|
+
expiresAt: Schema4.String
|
|
410
|
+
};
|
|
411
|
+
var RunFilePartUrl = Schema4.Struct({ partNumber: Schema4.Int, ...PresignedRequest });
|
|
412
|
+
var RunFileUpload = Schema4.Union([
|
|
413
|
+
Schema4.Struct({ kind: Schema4.Literal("single"), ...PresignedRequest }),
|
|
414
|
+
Schema4.Struct({ kind: Schema4.Literal("multipart"), partSize: Schema4.Int, parts: Schema4.Array(RunFilePartUrl) })
|
|
415
|
+
]);
|
|
416
|
+
var UploadedRunFilePart = Schema4.Struct({ partNumber: Schema4.Int, etag: Schema4.String });
|
|
417
|
+
var StepRunFileRequest = Schema4.Struct({
|
|
418
|
+
name: Schema4.String.check(Schema4.isMinLength(1), Schema4.isMaxLength(255)),
|
|
419
|
+
caption: Schema4.optionalKey(Schema4.String.check(Schema4.isMaxLength(1000))),
|
|
420
|
+
contentType: Schema4.String.check(Schema4.isMinLength(1), Schema4.isMaxLength(255)),
|
|
421
|
+
byteSize: Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(0)),
|
|
422
|
+
sha256: Schema4.String.check(Schema4.isPattern(/^[0-9a-f]{64}$/))
|
|
423
|
+
});
|
|
424
|
+
var RunFileSlotted = Schema4.Struct({ file: RunFileRecord, upload: Schema4.optionalKey(RunFileUpload) });
|
|
425
|
+
// packages/core/src/crypto.ts
|
|
426
|
+
import { createHash, createHmac, createSign, randomBytes, timingSafeEqual } from "crypto";
|
|
427
|
+
function digestSha256(data, encoding) {
|
|
428
|
+
const hash = createHash("sha256");
|
|
429
|
+
for (const part of [data].flat())
|
|
430
|
+
hash.update(part);
|
|
431
|
+
return hash.digest(encoding);
|
|
432
|
+
}
|
|
433
|
+
function sha256Hasher() {
|
|
434
|
+
const hash = createHash("sha256");
|
|
435
|
+
return {
|
|
436
|
+
update: (data) => {
|
|
437
|
+
hash.update(data);
|
|
438
|
+
},
|
|
439
|
+
digest: (encoding) => hash.digest(encoding)
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
// packages/core/src/transcript.ts
|
|
443
|
+
import * as Schema5 from "effect/Schema";
|
|
444
|
+
var Text = Schema5.String.check(Schema5.isMaxLength(200000));
|
|
445
|
+
var AgentEvent = Schema5.Union([
|
|
446
|
+
Schema5.Struct({ kind: Schema5.Literal("message"), role: Schema5.Literals(["assistant", "user"]), text: Text }),
|
|
447
|
+
Schema5.Struct({
|
|
448
|
+
kind: Schema5.Literal("tool_call"),
|
|
449
|
+
callId: Schema5.String,
|
|
450
|
+
name: Schema5.String.check(Schema5.isMinLength(1), Schema5.isMaxLength(240)),
|
|
451
|
+
arguments: Schema5.Json
|
|
452
|
+
}),
|
|
453
|
+
Schema5.Struct({
|
|
454
|
+
kind: Schema5.Literal("tool_result"),
|
|
455
|
+
callId: Schema5.String,
|
|
456
|
+
output: Text,
|
|
457
|
+
isError: Schema5.optionalKey(Schema5.Boolean)
|
|
458
|
+
}),
|
|
459
|
+
Schema5.Struct({
|
|
460
|
+
kind: Schema5.Literal("file"),
|
|
461
|
+
path: Schema5.String.check(Schema5.isMinLength(1), Schema5.isMaxLength(4096)),
|
|
462
|
+
change: Schema5.Literals(["read", "changed"])
|
|
463
|
+
}),
|
|
464
|
+
Schema5.Struct({ kind: Schema5.Literal("question"), text: Text }),
|
|
465
|
+
Schema5.Struct({
|
|
466
|
+
kind: Schema5.Literal("answer"),
|
|
467
|
+
callId: Schema5.optionalKey(Schema5.String),
|
|
468
|
+
questionId: Schema5.optionalKey(Schema5.String),
|
|
469
|
+
text: Text
|
|
470
|
+
}),
|
|
471
|
+
Schema5.Struct({ kind: Schema5.Literal("steer"), messageId: Id, text: Text }),
|
|
472
|
+
Schema5.Struct({
|
|
473
|
+
kind: Schema5.Literal("lifecycle"),
|
|
474
|
+
state: Schema5.Literals(["started", "resumed", "finished", "failed", "canceled"])
|
|
475
|
+
})
|
|
476
|
+
]);
|
|
477
|
+
var TranscriptAppendEntry = Schema5.Struct({
|
|
478
|
+
sequence: Schema5.Int.check(Schema5.isGreaterThanOrEqualTo(1)),
|
|
479
|
+
event: AgentEvent
|
|
480
|
+
});
|
|
481
|
+
var TranscriptEntry = Schema5.Struct({
|
|
482
|
+
stepAttemptId: Id,
|
|
483
|
+
sequence: Schema5.Int.check(Schema5.isGreaterThanOrEqualTo(1)),
|
|
484
|
+
event: AgentEvent,
|
|
485
|
+
createdAt: Timestamp
|
|
486
|
+
});
|
|
487
|
+
var TranscriptPage = Schema5.Struct({
|
|
488
|
+
items: Schema5.Array(TranscriptEntry),
|
|
489
|
+
next: Schema5.optionalKey(Schema5.Int),
|
|
490
|
+
previous: Schema5.optionalKey(Schema5.Int)
|
|
491
|
+
});
|
|
492
|
+
var TranscriptRetention = Schema5.Struct({
|
|
493
|
+
days: Schema5.NullOr(Schema5.Int.check(Schema5.isGreaterThanOrEqualTo(1)))
|
|
494
|
+
});
|
|
495
|
+
var MaxTranscriptSearchLimit = 50;
|
|
496
|
+
var TranscriptSearchQuery = Schema5.Struct({
|
|
497
|
+
q: Schema5.String.check(Schema5.isMinLength(1), Schema5.isMaxLength(200)),
|
|
498
|
+
limit: Schema5.optionalKey(Numeric.check(isWholeNumber, Schema5.isGreaterThanOrEqualTo(1), Schema5.isLessThanOrEqualTo(MaxTranscriptSearchLimit)))
|
|
499
|
+
});
|
|
500
|
+
var TranscriptSearchHit = Schema5.Struct({
|
|
501
|
+
runId: Id,
|
|
502
|
+
loop: Schema5.String,
|
|
503
|
+
task: Schema5.optionalKey(Schema5.Struct({ id: Id, key: Schema5.String, title: Schema5.String })),
|
|
504
|
+
stepAttemptId: Id,
|
|
505
|
+
node: Schema5.optionalKey(Schema5.String),
|
|
506
|
+
step: Schema5.String,
|
|
507
|
+
attempt: Schema5.Int,
|
|
508
|
+
agent: Schema5.optionalKey(Schema5.String),
|
|
509
|
+
ranAt: Timestamp,
|
|
510
|
+
sequence: Schema5.Int,
|
|
511
|
+
matches: Schema5.Int,
|
|
512
|
+
excerpt: Schema5.String
|
|
513
|
+
});
|
|
514
|
+
var TranscriptSearchResult = Schema5.Struct({
|
|
515
|
+
items: Schema5.Array(TranscriptSearchHit),
|
|
516
|
+
total: Schema5.Int
|
|
517
|
+
});
|
|
268
518
|
// packages/core/src/run-journal.ts
|
|
269
519
|
import * as Effect from "effect/Effect";
|
|
270
520
|
import * as Exit from "effect/Exit";
|
|
271
|
-
import * as
|
|
521
|
+
import * as Schema6 from "effect/Schema";
|
|
272
522
|
var journalEntryMaxBytes = 256 * 1024;
|
|
273
|
-
var JournalExit =
|
|
274
|
-
var encodeJournalExit = (exit) =>
|
|
275
|
-
var decodeJournalExit =
|
|
276
|
-
var JournalStepFailed =
|
|
277
|
-
var JournalChildFailed =
|
|
278
|
-
step:
|
|
279
|
-
loop:
|
|
280
|
-
reason:
|
|
523
|
+
var JournalExit = Schema6.toCodecJson(Schema6.Exit(Schema6.Json, Schema6.Json, Schema6.Defect()));
|
|
524
|
+
var encodeJournalExit = (exit) => Schema6.encodeUnknownEffect(JournalExit)(Exit.map(exit, (value) => value ?? null));
|
|
525
|
+
var decodeJournalExit = Schema6.decodeUnknownEffect(JournalExit);
|
|
526
|
+
var JournalStepFailed = Schema6.TaggedStruct("StepFailed", { step: Schema6.String, reason: Schema6.String });
|
|
527
|
+
var JournalChildFailed = Schema6.TaggedStruct("ChildFailed", {
|
|
528
|
+
step: Schema6.String,
|
|
529
|
+
loop: Schema6.String,
|
|
530
|
+
reason: Schema6.String
|
|
281
531
|
});
|
|
282
|
-
var JournalWaitTimedOut =
|
|
532
|
+
var JournalWaitTimedOut = Schema6.TaggedStruct("WaitTimedOut", { step: Schema6.String, event: Schema6.String });
|
|
283
533
|
var journalEntryBytes = (entry) => new TextEncoder().encode(JSON.stringify(entry)).byteLength;
|
|
284
534
|
// packages/sdk/src/program/engine.ts
|
|
285
535
|
import * as Cause from "effect/Cause";
|
|
536
|
+
import * as Clock from "effect/Clock";
|
|
286
537
|
import * as Data from "effect/Data";
|
|
287
538
|
import * as Duration from "effect/Duration";
|
|
288
539
|
import * as Effect2 from "effect/Effect";
|
|
289
540
|
import * as Exit3 from "effect/Exit";
|
|
290
541
|
import * as Fiber from "effect/Fiber";
|
|
542
|
+
import * as FileSystem from "effect/FileSystem";
|
|
291
543
|
import * as Layer from "effect/Layer";
|
|
292
544
|
import * as Option from "effect/Option";
|
|
293
|
-
import
|
|
545
|
+
import { isPlatformError } from "effect/PlatformError";
|
|
546
|
+
import * as Schema8 from "effect/Schema";
|
|
547
|
+
import * as Stream from "effect/Stream";
|
|
548
|
+
import * as HttpClient from "effect/http/HttpClient";
|
|
549
|
+
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
550
|
+
import * as HttpClientResponse from "effect/http/HttpClientResponse";
|
|
294
551
|
|
|
295
552
|
// packages/live/src/rpc/runner-group.ts
|
|
296
|
-
import * as
|
|
553
|
+
import * as Schema7 from "effect/Schema";
|
|
297
554
|
import { Rpc, RpcGroup, RpcMiddleware } from "effect/rpc";
|
|
298
555
|
var RunnerHeaders = { runnerId: "x-kitman-runner-id", protocolVersion: "x-kitman-rpc-protocol" };
|
|
299
|
-
var RunnerRpcProtocolVersion =
|
|
556
|
+
var RunnerRpcProtocolVersion = 4;
|
|
300
557
|
|
|
301
|
-
class RunnerRpcError extends
|
|
302
|
-
code:
|
|
303
|
-
message:
|
|
304
|
-
status:
|
|
558
|
+
class RunnerRpcError extends Schema7.TaggedError()("RunnerRpcError", {
|
|
559
|
+
code: Schema7.String,
|
|
560
|
+
message: Schema7.String,
|
|
561
|
+
status: Schema7.Finite
|
|
305
562
|
}) {
|
|
306
563
|
}
|
|
307
564
|
|
|
@@ -309,55 +566,68 @@ class RunnerAuthentication extends RpcMiddleware.Service()("RunnerAuthentication
|
|
|
309
566
|
error: RunnerRpcError
|
|
310
567
|
}) {
|
|
311
568
|
}
|
|
312
|
-
var EventFilterValue =
|
|
313
|
-
var WorkAvailable =
|
|
314
|
-
var LeaseRevoked =
|
|
315
|
-
var Settled =
|
|
316
|
-
var Canceled =
|
|
317
|
-
var RunSettled =
|
|
318
|
-
var Steer =
|
|
319
|
-
workUnitId:
|
|
320
|
-
messageId:
|
|
321
|
-
text:
|
|
569
|
+
var EventFilterValue = Schema7.Union([Schema7.String, Schema7.Finite, Schema7.Boolean, Schema7.Null]);
|
|
570
|
+
var WorkAvailable = Schema7.TaggedStruct("WorkAvailable", {});
|
|
571
|
+
var LeaseRevoked = Schema7.TaggedStruct("LeaseRevoked", { workUnitId: Schema7.String });
|
|
572
|
+
var Settled = Schema7.TaggedStruct("Settled", { workUnitId: Schema7.String });
|
|
573
|
+
var Canceled = Schema7.TaggedStruct("Canceled", { workUnitId: Schema7.String });
|
|
574
|
+
var RunSettled = Schema7.TaggedStruct("RunSettled", { runId: Schema7.String });
|
|
575
|
+
var Steer = Schema7.TaggedStruct("Steer", {
|
|
576
|
+
workUnitId: Schema7.String,
|
|
577
|
+
messageId: Schema7.String,
|
|
578
|
+
text: Schema7.String
|
|
322
579
|
});
|
|
323
|
-
var SessionUpdated =
|
|
324
|
-
var
|
|
580
|
+
var SessionUpdated = Schema7.TaggedStruct("SessionUpdated", { workUnitId: Schema7.String });
|
|
581
|
+
var UpdateAvailable = Schema7.TaggedStruct("UpdateAvailable", { version: Schema7.String });
|
|
582
|
+
var RunnerSignal = Schema7.Union([
|
|
325
583
|
WorkAvailable,
|
|
326
584
|
LeaseRevoked,
|
|
327
585
|
Settled,
|
|
328
586
|
Canceled,
|
|
329
587
|
RunSettled,
|
|
330
588
|
Steer,
|
|
331
|
-
SessionUpdated
|
|
589
|
+
SessionUpdated,
|
|
590
|
+
UpdateAvailable
|
|
332
591
|
]);
|
|
333
|
-
var ProgramLease =
|
|
334
|
-
workUnitId:
|
|
335
|
-
leaseOwnerId:
|
|
336
|
-
runnerReplicaId:
|
|
337
|
-
leaseId:
|
|
338
|
-
attempt:
|
|
339
|
-
fencingToken:
|
|
340
|
-
capacitySlot:
|
|
592
|
+
var ProgramLease = Schema7.Struct({
|
|
593
|
+
workUnitId: Schema7.String,
|
|
594
|
+
leaseOwnerId: Schema7.String,
|
|
595
|
+
runnerReplicaId: Schema7.String,
|
|
596
|
+
leaseId: Schema7.String,
|
|
597
|
+
attempt: Schema7.Int,
|
|
598
|
+
fencingToken: Schema7.String,
|
|
599
|
+
capacitySlot: Schema7.String
|
|
341
600
|
});
|
|
342
|
-
var CheckpointSession =
|
|
343
|
-
harness:
|
|
344
|
-
id:
|
|
345
|
-
name:
|
|
346
|
-
|
|
601
|
+
var CheckpointSession = Schema7.Struct({
|
|
602
|
+
harness: Schema7.String,
|
|
603
|
+
id: Schema7.String,
|
|
604
|
+
name: Schema7.String,
|
|
605
|
+
fileId: Schema7.String
|
|
347
606
|
});
|
|
348
|
-
var StepCheckpoint =
|
|
349
|
-
ref:
|
|
350
|
-
revision:
|
|
351
|
-
session:
|
|
607
|
+
var StepCheckpoint = Schema7.Struct({
|
|
608
|
+
ref: Schema7.optionalKey(Schema7.String),
|
|
609
|
+
revision: Schema7.optionalKey(Schema7.String),
|
|
610
|
+
session: Schema7.optionalKey(CheckpointSession)
|
|
352
611
|
});
|
|
353
|
-
var
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
612
|
+
var ResumedCheckpoint = Schema7.Struct({
|
|
613
|
+
ref: Schema7.optionalKey(Schema7.String),
|
|
614
|
+
revision: Schema7.optionalKey(Schema7.String),
|
|
615
|
+
session: Schema7.optionalKey(Schema7.Struct({
|
|
616
|
+
harness: Schema7.String,
|
|
617
|
+
id: Schema7.String,
|
|
618
|
+
name: Schema7.String,
|
|
619
|
+
url: Schema7.String,
|
|
620
|
+
headers: Schema7.optionalKey(Schema7.Record(Schema7.String, Schema7.String))
|
|
621
|
+
}))
|
|
622
|
+
});
|
|
623
|
+
var SuggestedVerification = Schema7.Struct({
|
|
624
|
+
name: Schema7.String,
|
|
625
|
+
command: Schema7.String,
|
|
626
|
+
workingDirectory: Schema7.optional(Schema7.String)
|
|
357
627
|
});
|
|
358
|
-
var ProgramOutcome =
|
|
359
|
-
|
|
360
|
-
|
|
628
|
+
var ProgramOutcome = Schema7.Union([
|
|
629
|
+
Schema7.Struct({ status: Schema7.Literal("completed"), output: Schema7.Json }),
|
|
630
|
+
Schema7.Struct({ status: Schema7.Literal("failed"), failureSummary: Schema7.String })
|
|
361
631
|
]);
|
|
362
632
|
|
|
363
633
|
class RunnerRpcs extends RpcGroup.make(Rpc.make("Claim", {
|
|
@@ -375,185 +645,299 @@ class RunnerRpcs extends RpcGroup.make(Rpc.make("Claim", {
|
|
|
375
645
|
payload: WorkUnitReleaseInput,
|
|
376
646
|
error: RunnerRpcError
|
|
377
647
|
}), Rpc.make("RecordActivity", {
|
|
378
|
-
payload: { lease: ProgramLease, name:
|
|
648
|
+
payload: { lease: ProgramLease, name: Schema7.String, attempt: Schema7.Int, exit: Schema7.Json },
|
|
379
649
|
error: RunnerRpcError
|
|
380
650
|
}), Rpc.make("DeferredDone", {
|
|
381
|
-
payload: { lease: ProgramLease, name:
|
|
651
|
+
payload: { lease: ProgramLease, name: Schema7.String, exit: Schema7.Json },
|
|
382
652
|
error: RunnerRpcError
|
|
383
653
|
}), Rpc.make("ScheduleClock", {
|
|
384
|
-
payload: { lease: ProgramLease, name:
|
|
654
|
+
payload: { lease: ProgramLease, name: Schema7.String, deferredName: Schema7.String, durationMillis: Schema7.Int },
|
|
385
655
|
error: RunnerRpcError
|
|
386
656
|
}), Rpc.make("PutQuestion", {
|
|
387
657
|
payload: {
|
|
388
658
|
lease: ProgramLease,
|
|
389
|
-
step:
|
|
390
|
-
prompt:
|
|
391
|
-
options:
|
|
392
|
-
verification:
|
|
393
|
-
deferredName:
|
|
659
|
+
step: Schema7.String,
|
|
660
|
+
prompt: Schema7.String,
|
|
661
|
+
options: Schema7.optional(Schema7.Array(Schema7.String)),
|
|
662
|
+
verification: Schema7.optional(SuggestedVerification),
|
|
663
|
+
deferredName: Schema7.String
|
|
394
664
|
},
|
|
395
|
-
success:
|
|
665
|
+
success: Schema7.Struct({ questionId: Schema7.String }),
|
|
396
666
|
error: RunnerRpcError
|
|
397
667
|
}), Rpc.make("StartAgentStep", {
|
|
398
668
|
payload: {
|
|
399
669
|
lease: ProgramLease,
|
|
400
|
-
step:
|
|
401
|
-
deferredName:
|
|
402
|
-
role:
|
|
403
|
-
agentId:
|
|
404
|
-
prompt:
|
|
405
|
-
outputSchema:
|
|
406
|
-
secrets:
|
|
670
|
+
step: Schema7.String,
|
|
671
|
+
deferredName: Schema7.String,
|
|
672
|
+
role: Schema7.String,
|
|
673
|
+
agentId: Schema7.String,
|
|
674
|
+
prompt: Schema7.String,
|
|
675
|
+
outputSchema: Schema7.Json,
|
|
676
|
+
secrets: Schema7.optionalKey(Schema7.Array(Schema7.String))
|
|
407
677
|
},
|
|
408
|
-
success:
|
|
678
|
+
success: Schema7.Struct({ stepAttemptId: Schema7.String }),
|
|
409
679
|
error: RunnerRpcError
|
|
410
680
|
}), Rpc.make("StartVerification", {
|
|
411
681
|
payload: {
|
|
412
682
|
lease: ProgramLease,
|
|
413
|
-
step:
|
|
414
|
-
deferredName:
|
|
415
|
-
revision:
|
|
416
|
-
checks:
|
|
683
|
+
step: Schema7.String,
|
|
684
|
+
deferredName: Schema7.String,
|
|
685
|
+
revision: Schema7.optionalKey(Schema7.String),
|
|
686
|
+
checks: Schema7.optional(Schema7.Array(Schema7.String))
|
|
417
687
|
},
|
|
418
|
-
success:
|
|
688
|
+
success: Schema7.Struct({ verificationId: Schema7.String }),
|
|
419
689
|
error: RunnerRpcError
|
|
420
690
|
}), Rpc.make("KnownEvidence", {
|
|
421
|
-
payload: { lease: ProgramLease, trees:
|
|
422
|
-
success:
|
|
691
|
+
payload: { lease: ProgramLease, trees: Schema7.Array(Schema7.String) },
|
|
692
|
+
success: Schema7.Array(Schema7.Struct({ tree: Schema7.String, name: Schema7.String, command: Schema7.String })),
|
|
423
693
|
error: RunnerRpcError
|
|
424
694
|
}), Rpc.make("AwaitEvent", {
|
|
425
695
|
payload: {
|
|
426
696
|
lease: ProgramLease,
|
|
427
|
-
step:
|
|
428
|
-
deferredName:
|
|
429
|
-
event:
|
|
430
|
-
filter:
|
|
431
|
-
timeoutMillis:
|
|
697
|
+
step: Schema7.String,
|
|
698
|
+
deferredName: Schema7.String,
|
|
699
|
+
event: Schema7.String,
|
|
700
|
+
filter: Schema7.optional(Schema7.Record(Schema7.String, Schema7.Union([EventFilterValue, Schema7.Array(EventFilterValue)]))),
|
|
701
|
+
timeoutMillis: Schema7.Int
|
|
432
702
|
},
|
|
433
703
|
error: RunnerRpcError
|
|
434
704
|
}), Rpc.make("AdmitChild", {
|
|
435
705
|
payload: {
|
|
436
706
|
lease: ProgramLease,
|
|
437
|
-
step:
|
|
438
|
-
loop:
|
|
439
|
-
input:
|
|
440
|
-
deferredName:
|
|
707
|
+
step: Schema7.String,
|
|
708
|
+
loop: Schema7.String,
|
|
709
|
+
input: Schema7.Json,
|
|
710
|
+
deferredName: Schema7.String
|
|
441
711
|
},
|
|
442
|
-
success:
|
|
712
|
+
success: Schema7.Struct({ runId: Schema7.String }),
|
|
443
713
|
error: RunnerRpcError
|
|
444
714
|
}), Rpc.make("StoreArtifact", {
|
|
445
715
|
payload: {
|
|
446
716
|
lease: ProgramLease,
|
|
447
|
-
step:
|
|
448
|
-
kind:
|
|
449
|
-
title:
|
|
450
|
-
text:
|
|
451
|
-
data:
|
|
717
|
+
step: Schema7.String,
|
|
718
|
+
kind: Schema7.String,
|
|
719
|
+
title: Schema7.String,
|
|
720
|
+
text: Schema7.String,
|
|
721
|
+
data: Schema7.optional(Schema7.Json),
|
|
722
|
+
fileIds: Schema7.optional(Schema7.Array(Schema7.String))
|
|
452
723
|
},
|
|
453
|
-
success:
|
|
724
|
+
success: Schema7.Struct({ artifactId: Schema7.String }),
|
|
725
|
+
error: RunnerRpcError
|
|
726
|
+
}), Rpc.make("CreateRunFile", {
|
|
727
|
+
payload: {
|
|
728
|
+
lease: ProgramLease,
|
|
729
|
+
step: Schema7.String,
|
|
730
|
+
name: Schema7.String,
|
|
731
|
+
caption: Schema7.optional(Schema7.String),
|
|
732
|
+
contentType: Schema7.String,
|
|
733
|
+
byteSize: Schema7.Int,
|
|
734
|
+
sha256: Schema7.String
|
|
735
|
+
},
|
|
736
|
+
success: Schema7.Struct({ file: RunFileRecord, upload: Schema7.optional(RunFileUpload) }),
|
|
737
|
+
error: Schema7.Union([RunnerRpcError, RunFileRefused])
|
|
738
|
+
}), Rpc.make("RunFileParts", {
|
|
739
|
+
payload: { lease: ProgramLease, fileId: Schema7.String, partNumbers: Schema7.Array(Schema7.Int) },
|
|
740
|
+
success: Schema7.Struct({ parts: Schema7.Array(RunFilePartUrl) }),
|
|
741
|
+
error: RunnerRpcError
|
|
742
|
+
}), Rpc.make("CompleteRunFile", {
|
|
743
|
+
payload: { lease: ProgramLease, fileId: Schema7.String, parts: Schema7.optional(Schema7.Array(UploadedRunFilePart)) },
|
|
744
|
+
success: RunFileRecord,
|
|
454
745
|
error: RunnerRpcError
|
|
455
746
|
}), Rpc.make("RecordNote", {
|
|
456
747
|
payload: {
|
|
457
748
|
lease: ProgramLease,
|
|
458
|
-
step:
|
|
459
|
-
text:
|
|
460
|
-
artifactId:
|
|
749
|
+
step: Schema7.String,
|
|
750
|
+
text: Schema7.String,
|
|
751
|
+
artifactId: Schema7.optional(Schema7.String)
|
|
461
752
|
},
|
|
462
753
|
error: RunnerRpcError
|
|
463
754
|
}), Rpc.make("PerformHostEffect", {
|
|
464
755
|
payload: {
|
|
465
756
|
lease: ProgramLease,
|
|
466
|
-
step:
|
|
467
|
-
effect:
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
kind:
|
|
471
|
-
title:
|
|
472
|
-
body:
|
|
473
|
-
integration:
|
|
757
|
+
step: Schema7.String,
|
|
758
|
+
effect: Schema7.Union([
|
|
759
|
+
Schema7.Struct({ kind: Schema7.Literal("post_comment"), changeRequestId: Schema7.String, body: Schema7.String }),
|
|
760
|
+
Schema7.Struct({
|
|
761
|
+
kind: Schema7.Literal("change_request"),
|
|
762
|
+
title: Schema7.String,
|
|
763
|
+
body: Schema7.String,
|
|
764
|
+
integration: Schema7.optionalKey(Schema7.String)
|
|
765
|
+
}),
|
|
766
|
+
Schema7.Struct({
|
|
767
|
+
kind: Schema7.Literal("write_back"),
|
|
768
|
+
milestone: Schema7.optionalKey(Schema7.Literals(["started", "change_request_opened", "merged", "failed"])),
|
|
769
|
+
changeRequestUrl: Schema7.optionalKey(Schema7.String)
|
|
770
|
+
})
|
|
771
|
+
])
|
|
772
|
+
},
|
|
773
|
+
success: Schema7.UndefinedOr(Schema7.Struct({ id: Schema7.String, number: Schema7.String, url: Schema7.String })),
|
|
774
|
+
error: RunnerRpcError
|
|
775
|
+
}), Rpc.make("ReadTranscripts", {
|
|
776
|
+
payload: { lease: ProgramLease, step: Schema7.String, days: Schema7.Int },
|
|
777
|
+
success: Schema7.Struct({
|
|
778
|
+
runs: Schema7.Array(Schema7.Struct({
|
|
779
|
+
runId: Schema7.String,
|
|
780
|
+
loopId: Schema7.String,
|
|
781
|
+
teamId: Schema7.optionalKey(Schema7.String),
|
|
782
|
+
failure: Schema7.optionalKey(Schema7.String),
|
|
783
|
+
entries: Schema7.Array(Schema7.Struct({
|
|
784
|
+
stepAttemptId: Schema7.String,
|
|
785
|
+
sequence: Schema7.Int,
|
|
786
|
+
kind: Schema7.String,
|
|
787
|
+
text: Schema7.String
|
|
788
|
+
}))
|
|
789
|
+
}))
|
|
790
|
+
}),
|
|
791
|
+
error: RunnerRpcError
|
|
792
|
+
}), Rpc.make("Propose", {
|
|
793
|
+
payload: {
|
|
794
|
+
lease: ProgramLease,
|
|
795
|
+
step: Schema7.String,
|
|
796
|
+
proposal: Schema7.Union([
|
|
797
|
+
Schema7.Struct({
|
|
798
|
+
kind: Schema7.Literal("memory"),
|
|
799
|
+
teamId: Schema7.String,
|
|
800
|
+
content: Schema7.String,
|
|
801
|
+
citations: Schema7.NonEmptyArray(Schema7.Struct({ runId: Schema7.String, stepAttemptId: Schema7.String, sequence: Schema7.Int }))
|
|
474
802
|
}),
|
|
475
|
-
|
|
476
|
-
kind:
|
|
477
|
-
|
|
478
|
-
|
|
803
|
+
Schema7.Struct({
|
|
804
|
+
kind: Schema7.Literal("task"),
|
|
805
|
+
title: Schema7.String,
|
|
806
|
+
description: Schema7.String,
|
|
807
|
+
teamId: Schema7.optionalKey(Schema7.String),
|
|
808
|
+
citations: Schema7.NonEmptyArray(Schema7.Struct({ runId: Schema7.String, stepAttemptId: Schema7.String, sequence: Schema7.Int }))
|
|
479
809
|
})
|
|
480
810
|
])
|
|
481
811
|
},
|
|
482
|
-
success:
|
|
812
|
+
success: Schema7.Struct({ kind: Schema7.Literals(["memory", "task"]), id: Schema7.String }),
|
|
813
|
+
error: RunnerRpcError
|
|
814
|
+
}), Rpc.make("ReadProject", {
|
|
815
|
+
payload: { lease: ProgramLease, step: Schema7.String, projectId: Schema7.String },
|
|
816
|
+
success: Schema7.Struct({
|
|
817
|
+
project: Schema7.Struct({ id: Schema7.String, name: Schema7.String }),
|
|
818
|
+
health: Schema7.optionalKey(Schema7.Literals(["on_track", "at_risk", "off_track"])),
|
|
819
|
+
since: Schema7.optionalKey(Schema7.String),
|
|
820
|
+
runs: Schema7.Array(Schema7.Struct({
|
|
821
|
+
runId: Schema7.String,
|
|
822
|
+
loopId: Schema7.String,
|
|
823
|
+
status: Schema7.String,
|
|
824
|
+
taskKey: Schema7.optionalKey(Schema7.String),
|
|
825
|
+
taskTitle: Schema7.optionalKey(Schema7.String),
|
|
826
|
+
summary: Schema7.optionalKey(Schema7.String),
|
|
827
|
+
entries: Schema7.Array(Schema7.Struct({
|
|
828
|
+
stepAttemptId: Schema7.String,
|
|
829
|
+
sequence: Schema7.Int,
|
|
830
|
+
kind: Schema7.String,
|
|
831
|
+
text: Schema7.String
|
|
832
|
+
}))
|
|
833
|
+
})),
|
|
834
|
+
taskChanges: Schema7.Array(Schema7.Struct({ taskKey: Schema7.String, title: Schema7.String, change: Schema7.String, at: Schema7.String }))
|
|
835
|
+
}),
|
|
836
|
+
error: RunnerRpcError
|
|
837
|
+
}), Rpc.make("DraftUpdate", {
|
|
838
|
+
payload: {
|
|
839
|
+
lease: ProgramLease,
|
|
840
|
+
step: Schema7.String,
|
|
841
|
+
projectId: Schema7.String,
|
|
842
|
+
health: Schema7.Literals(["on_track", "at_risk", "off_track"]),
|
|
843
|
+
note: Schema7.String,
|
|
844
|
+
writtenFrom: Schema7.Struct({
|
|
845
|
+
runs: Schema7.Int,
|
|
846
|
+
taskChanges: Schema7.Int,
|
|
847
|
+
since: Schema7.optionalKey(Schema7.String)
|
|
848
|
+
})
|
|
849
|
+
},
|
|
850
|
+
success: Schema7.Struct({ id: Schema7.String }),
|
|
483
851
|
error: RunnerRpcError
|
|
484
852
|
}), Rpc.make("CreatePlanTasks", {
|
|
485
853
|
payload: {
|
|
486
854
|
lease: ProgramLease,
|
|
487
|
-
tickets:
|
|
488
|
-
key:
|
|
489
|
-
title:
|
|
490
|
-
body:
|
|
491
|
-
acceptanceCriteria:
|
|
492
|
-
blockedBy:
|
|
493
|
-
outcome:
|
|
855
|
+
tickets: Schema7.Array(Schema7.Struct({
|
|
856
|
+
key: Schema7.String,
|
|
857
|
+
title: Schema7.String,
|
|
858
|
+
body: Schema7.String,
|
|
859
|
+
acceptanceCriteria: Schema7.Array(Schema7.String),
|
|
860
|
+
blockedBy: Schema7.Array(Schema7.String),
|
|
861
|
+
outcome: Schema7.optionalKey(Schema7.Literals(["feature", "bug", "refactor", "investigation", "docs", "migration"]))
|
|
494
862
|
}))
|
|
495
863
|
},
|
|
496
|
-
success:
|
|
864
|
+
success: Schema7.Array(Schema7.Struct({ key: Schema7.String, taskId: Schema7.String })),
|
|
497
865
|
error: RunnerRpcError
|
|
498
866
|
}), Rpc.make("IntegrationBranch", {
|
|
499
|
-
payload: { lease: ProgramLease, repoBindingId:
|
|
500
|
-
success:
|
|
867
|
+
payload: { lease: ProgramLease, repoBindingId: Schema7.optionalKey(Schema7.String) },
|
|
868
|
+
success: Schema7.Struct({ repoBindingId: Schema7.String, branch: Schema7.String, revision: Schema7.String }),
|
|
501
869
|
error: RunnerRpcError
|
|
502
870
|
}), Rpc.make("MergeChangeRequest", {
|
|
503
|
-
payload: { lease: ProgramLease, step:
|
|
504
|
-
success:
|
|
505
|
-
|
|
506
|
-
|
|
871
|
+
payload: { lease: ProgramLease, step: Schema7.String, changeRequestId: Schema7.String },
|
|
872
|
+
success: Schema7.Union([
|
|
873
|
+
Schema7.Struct({ status: Schema7.Literal("merged"), revision: Schema7.String }),
|
|
874
|
+
Schema7.Struct({ status: Schema7.Literal("conflict") })
|
|
507
875
|
]),
|
|
508
876
|
error: RunnerRpcError
|
|
509
877
|
}), Rpc.make("PublishRelease", {
|
|
510
878
|
payload: {
|
|
511
879
|
lease: ProgramLease,
|
|
512
|
-
step:
|
|
513
|
-
tag:
|
|
514
|
-
revision:
|
|
515
|
-
title:
|
|
516
|
-
notes:
|
|
880
|
+
step: Schema7.String,
|
|
881
|
+
tag: Schema7.String,
|
|
882
|
+
revision: Schema7.optionalKey(Schema7.String),
|
|
883
|
+
title: Schema7.String,
|
|
884
|
+
notes: Schema7.String
|
|
517
885
|
},
|
|
518
|
-
success:
|
|
886
|
+
success: Schema7.Struct({ tag: Schema7.String, revision: Schema7.String, url: Schema7.String }),
|
|
519
887
|
error: RunnerRpcError
|
|
520
888
|
}), Rpc.make("ReportSteer", {
|
|
521
|
-
payload: { workUnitId:
|
|
522
|
-
success:
|
|
889
|
+
payload: { workUnitId: Schema7.String, messageId: Schema7.String, delivered: Schema7.Boolean },
|
|
890
|
+
success: Schema7.Void,
|
|
891
|
+
error: RunnerRpcError
|
|
892
|
+
}), Rpc.make("AppendTranscript", {
|
|
893
|
+
payload: { workUnitId: Schema7.String, entries: Schema7.Array(TranscriptAppendEntry).check(Schema7.isMaxLength(100)) },
|
|
894
|
+
success: Schema7.Void,
|
|
895
|
+
error: RunnerRpcError
|
|
896
|
+
}), Rpc.make("CreateCheckpointFile", {
|
|
897
|
+
payload: { lease: ProgramLease, byteSize: Schema7.Int, sha256: Schema7.String },
|
|
898
|
+
success: Schema7.Struct({ file: RunFileRecord, upload: Schema7.optional(RunFileUpload) }),
|
|
899
|
+
error: Schema7.Union([RunnerRpcError, RunFileRefused])
|
|
900
|
+
}), Rpc.make("CheckpointFileParts", {
|
|
901
|
+
payload: { lease: ProgramLease, fileId: Schema7.String, partNumbers: Schema7.Array(Schema7.Int) },
|
|
902
|
+
success: Schema7.Struct({ parts: Schema7.Array(RunFilePartUrl) }),
|
|
903
|
+
error: RunnerRpcError
|
|
904
|
+
}), Rpc.make("CompleteCheckpointFile", {
|
|
905
|
+
payload: { lease: ProgramLease, fileId: Schema7.String, parts: Schema7.optional(Schema7.Array(UploadedRunFilePart)) },
|
|
906
|
+
success: RunFileRecord,
|
|
523
907
|
error: RunnerRpcError
|
|
524
908
|
}), Rpc.make("SaveCheckpoint", {
|
|
525
909
|
payload: { lease: ProgramLease, checkpoint: StepCheckpoint },
|
|
526
|
-
success:
|
|
910
|
+
success: Schema7.Void,
|
|
527
911
|
error: RunnerRpcError
|
|
528
912
|
}), Rpc.make("ResumeCheckpoint", {
|
|
529
913
|
payload: { lease: ProgramLease },
|
|
530
|
-
success:
|
|
914
|
+
success: Schema7.UndefinedOr(ResumedCheckpoint),
|
|
531
915
|
error: RunnerRpcError
|
|
532
916
|
}), Rpc.make("SettledCheckpoints", {
|
|
533
|
-
success:
|
|
534
|
-
stepAttemptId:
|
|
535
|
-
ref:
|
|
536
|
-
repoBinding:
|
|
917
|
+
success: Schema7.Array(Schema7.Struct({
|
|
918
|
+
stepAttemptId: Schema7.String,
|
|
919
|
+
ref: Schema7.optionalKey(Schema7.String),
|
|
920
|
+
repoBinding: Schema7.optionalKey(WorkUnitRepoBinding)
|
|
537
921
|
})),
|
|
538
922
|
error: RunnerRpcError
|
|
539
923
|
}), Rpc.make("ForgetCheckpoints", {
|
|
540
|
-
payload: { stepAttemptIds:
|
|
541
|
-
success:
|
|
924
|
+
payload: { stepAttemptIds: Schema7.Array(Schema7.String) },
|
|
925
|
+
success: Schema7.Void,
|
|
542
926
|
error: RunnerRpcError
|
|
543
927
|
}), Rpc.make("Bundle", {
|
|
544
|
-
payload: { digest:
|
|
545
|
-
success:
|
|
928
|
+
payload: { digest: Schema7.String },
|
|
929
|
+
success: Schema7.Struct({ bundle: Schema7.String }),
|
|
546
930
|
error: RunnerRpcError
|
|
547
931
|
}), Rpc.make("SettledRuns", {
|
|
548
|
-
payload: { runIds:
|
|
549
|
-
success:
|
|
932
|
+
payload: { runIds: Schema7.Array(Schema7.String) },
|
|
933
|
+
success: Schema7.Array(Schema7.String),
|
|
550
934
|
error: RunnerRpcError
|
|
551
935
|
}), Rpc.make("ProgramSecrets", {
|
|
552
936
|
payload: { lease: ProgramLease },
|
|
553
|
-
success:
|
|
937
|
+
success: Schema7.Record(Schema7.String, Schema7.String),
|
|
554
938
|
error: RunnerRpcError
|
|
555
939
|
}), Rpc.make("Suspend", { payload: { lease: ProgramLease }, error: RunnerRpcError }), Rpc.make("FinishProgram", { payload: { lease: ProgramLease, outcome: ProgramOutcome }, error: RunnerRpcError }), Rpc.make("Signals", {
|
|
556
|
-
payload: { runnerReplicaId:
|
|
940
|
+
payload: { runnerReplicaId: Schema7.String },
|
|
557
941
|
success: RunnerSignal,
|
|
558
942
|
error: RunnerRpcError,
|
|
559
943
|
stream: true
|
|
@@ -577,11 +961,11 @@ var entryFor = (name, exit) => Effect2.gen(function* () {
|
|
|
577
961
|
return entry;
|
|
578
962
|
});
|
|
579
963
|
var decoded = (entry) => Effect2.orDie(decodeJournalExit(entry));
|
|
580
|
-
var JournalEntries =
|
|
581
|
-
var isSuspended =
|
|
964
|
+
var JournalEntries = Schema8.Record(Schema8.String, Schema8.Json);
|
|
965
|
+
var isSuspended = Schema8.is(Workflow.Suspended);
|
|
582
966
|
var makeEncodedEngine = (recorded, journal) => Effect2.gen(function* () {
|
|
583
967
|
const scope2 = yield* Effect2.scope;
|
|
584
|
-
const entries = (journalPart) => Effect2.map(Effect2.orDie(
|
|
968
|
+
const entries = (journalPart) => Effect2.map(Effect2.orDie(Schema8.decodeUnknownEffect(JournalEntries)(journalPart)), Object.entries);
|
|
585
969
|
const activities = new Map(yield* entries(recorded.activities));
|
|
586
970
|
const deferreds = new Map(yield* entries(recorded.deferreds));
|
|
587
971
|
const workflows = new Map;
|
|
@@ -658,8 +1042,11 @@ var makeEncodedEngine = (recorded, journal) => Effect2.gen(function* () {
|
|
|
658
1042
|
});
|
|
659
1043
|
var emptyWorkflow = Workflow.make("kitman-loop/none", { payload: {}, idempotencyKey: () => "none" });
|
|
660
1044
|
var replayStatuses = new Set([401, 403, 409, 429]);
|
|
661
|
-
var isRunnerRpcError =
|
|
1045
|
+
var isRunnerRpcError = Schema8.is(RunnerRpcError);
|
|
1046
|
+
var isRunFileRefused = Schema8.is(RunFileRefused);
|
|
662
1047
|
var refusedStep2 = (cause) => {
|
|
1048
|
+
if (isRunFileRefused(cause))
|
|
1049
|
+
return true;
|
|
663
1050
|
if ("code" in cause && (cause.code === "capability_denied" || cause.code === "step_refused"))
|
|
664
1051
|
return true;
|
|
665
1052
|
return isRunnerRpcError(cause) && cause.status >= 400 && cause.status < 500 && !replayStatuses.has(cause.status);
|
|
@@ -702,7 +1089,49 @@ var runnerHost = (journal) => ({
|
|
|
702
1089
|
timeoutMillis: launch.timeoutMillis
|
|
703
1090
|
}))
|
|
704
1091
|
});
|
|
705
|
-
var
|
|
1092
|
+
var put2 = (target, contentType, body) => Effect2.gen(function* () {
|
|
1093
|
+
const response = yield* (yield* HttpClient.HttpClient).execute(HttpClientRequest.put(target.url).pipe(HttpClientRequest.bodyUint8Array(body, contentType), HttpClientRequest.setHeaders(target.headers ?? {})));
|
|
1094
|
+
return (yield* HttpClientResponse.filterStatusOk(response)).headers.etag ?? "";
|
|
1095
|
+
});
|
|
1096
|
+
var readRange = (path, offset, size) => Effect2.scoped(Effect2.gen(function* () {
|
|
1097
|
+
const file = yield* (yield* FileSystem.FileSystem).open(path);
|
|
1098
|
+
return Option.getOrElse(yield* file.readAlloc(size, { position: BigInt(offset) }), () => new Uint8Array);
|
|
1099
|
+
}));
|
|
1100
|
+
var partUrlMarginMillis = 60000;
|
|
1101
|
+
var uploadParts = (files, path, contentType, fileId, upload) => Effect2.forEach(upload.parts, (part) => Effect2.gen(function* () {
|
|
1102
|
+
const now = yield* Clock.currentTimeMillis;
|
|
1103
|
+
const fresh = Date.parse(part.expiresAt) - now > partUrlMarginMillis ? part : (yield* files.runFileParts({ fileId, partNumbers: [part.partNumber] }))[0] ?? part;
|
|
1104
|
+
const body = yield* readRange(path, (part.partNumber - 1) * upload.partSize, upload.partSize);
|
|
1105
|
+
return { partNumber: part.partNumber, etag: yield* put2(fresh, contentType, body) };
|
|
1106
|
+
}));
|
|
1107
|
+
var uploadRunFile2 = (files, file) => Effect2.gen(function* () {
|
|
1108
|
+
const fs = yield* FileSystem.FileSystem;
|
|
1109
|
+
const contentType = runFileContentType(file.name);
|
|
1110
|
+
const byteSize = Number((yield* fs.stat(file.path)).size);
|
|
1111
|
+
const hash = sha256Hasher();
|
|
1112
|
+
yield* Stream.runForEach(fs.stream(file.path), (chunk) => Effect2.sync(() => hash.update(chunk)));
|
|
1113
|
+
const { file: slotted, upload } = yield* files.createRunFile({
|
|
1114
|
+
step: file.step,
|
|
1115
|
+
name: file.name,
|
|
1116
|
+
...file.caption === undefined ? undefined : { caption: file.caption },
|
|
1117
|
+
contentType,
|
|
1118
|
+
byteSize,
|
|
1119
|
+
sha256: hash.digest("hex")
|
|
1120
|
+
});
|
|
1121
|
+
if (upload === undefined)
|
|
1122
|
+
return slotted;
|
|
1123
|
+
return yield* upload.kind === "single" ? readRange(file.path, 0, byteSize).pipe(Effect2.flatMap((body) => put2(upload, contentType, body)), Effect2.andThen(files.completeRunFile({ fileId: slotted.id }))) : Effect2.flatMap(uploadParts(files, file.path, contentType, slotted.id, upload), (parts) => files.completeRunFile({ fileId: slotted.id, parts }));
|
|
1124
|
+
});
|
|
1125
|
+
var keepFile = (journal, step, { path, caption }) => Effect2.gen(function* () {
|
|
1126
|
+
const kept = yield* uploadRunFile2(journal, { step, name: path.split("/").at(-1) ?? path, path, caption }).pipe(Effect2.catch((cause) => isPlatformError(cause) ? Effect2.fail(new StepFailed2({ step, reason: `Could not read ${path}: ${cause.message}` })) : requested(step, Effect2.fail(cause))));
|
|
1127
|
+
if (kept.status !== "available")
|
|
1128
|
+
return yield* new StepFailed2({
|
|
1129
|
+
step,
|
|
1130
|
+
reason: `Kitman rejected ${path}: storage holds bytes that do not match its size, digest or type`
|
|
1131
|
+
});
|
|
1132
|
+
return { id: kept.id };
|
|
1133
|
+
});
|
|
1134
|
+
var runnerActivities = (journal, services) => ({
|
|
706
1135
|
changeRequest: {
|
|
707
1136
|
run: (request, step) => requested(step, journal.performHostEffect({
|
|
708
1137
|
step,
|
|
@@ -724,7 +1153,14 @@ var runnerActivities = (journal) => ({
|
|
|
724
1153
|
}
|
|
725
1154
|
})).pipe(Effect2.asVoid)
|
|
726
1155
|
},
|
|
727
|
-
artifact: {
|
|
1156
|
+
artifact: {
|
|
1157
|
+
run: ({ files, ...request }, step) => requested(step, journal.storeArtifact({
|
|
1158
|
+
step,
|
|
1159
|
+
...request,
|
|
1160
|
+
...files === undefined ? undefined : { fileIds: files.map((shown) => shown.id) }
|
|
1161
|
+
}))
|
|
1162
|
+
},
|
|
1163
|
+
file: { run: (request, step) => keepFile(journal, step, request).pipe(Effect2.provideContext(services)) },
|
|
728
1164
|
note: { run: (request, step) => requested(step, journal.recordNote({ step, ...request })) },
|
|
729
1165
|
createTasks: {
|
|
730
1166
|
run: (request, step) => requested(step, Effect2.map(journal.createPlanTasks(request.tickets), (tasks) => ({ tasks })))
|
|
@@ -732,6 +1168,10 @@ var runnerActivities = (journal) => ({
|
|
|
732
1168
|
integrationBranch: {
|
|
733
1169
|
run: (request, step) => requested(step, journal.integrationBranch(request.repoBindingId))
|
|
734
1170
|
},
|
|
1171
|
+
transcripts: { run: (request, step) => requested(step, journal.readTranscripts({ step, ...request })) },
|
|
1172
|
+
propose: { run: (proposal, step) => requested(step, journal.propose({ step, proposal })) },
|
|
1173
|
+
projectActivity: { run: (request, step) => requested(step, journal.readProject({ step, ...request })) },
|
|
1174
|
+
draftUpdate: { run: (request, step) => requested(step, journal.draftUpdate({ step, ...request })) },
|
|
735
1175
|
mergeChangeRequest: {
|
|
736
1176
|
run: (request, step) => requested(step, journal.mergeChangeRequest({ step, ...request }))
|
|
737
1177
|
},
|
|
@@ -749,11 +1189,12 @@ var describeFailure = (cause) => {
|
|
|
749
1189
|
};
|
|
750
1190
|
var journalLoss = (cause) => cause.reasons.flatMap((reason) => Cause.isDieReason(reason) && reason.defect instanceof JournalWriteFailed2 ? [reason.defect] : [])[0];
|
|
751
1191
|
var runProgram2 = (loop, work, journal) => Effect2.scoped(Effect2.gen(function* () {
|
|
1192
|
+
const services = yield* Effect2.context();
|
|
752
1193
|
const { engine, encoded } = yield* makeEncodedEngine(work.journal, journal);
|
|
753
1194
|
const workflow = loopWorkflow2(loop);
|
|
754
1195
|
const execute = executeLoop2(loop, {
|
|
755
1196
|
host: runnerHost(journal),
|
|
756
|
-
activities: runnerActivities(journal),
|
|
1197
|
+
activities: runnerActivities(journal, services),
|
|
757
1198
|
granted: new Set(loop.capabilities.filter((capability) => work.granted.includes(capability)))
|
|
758
1199
|
});
|
|
759
1200
|
yield* Layer.build(workflow.toLayer(execute).pipe(Layer.provide(Layer.succeed(WorkflowEngine.WorkflowEngine)(engine))));
|
|
@@ -767,7 +1208,7 @@ var runProgram2 = (loop, work, journal) => Effect2.scoped(Effect2.gen(function*
|
|
|
767
1208
|
return "suspended";
|
|
768
1209
|
}
|
|
769
1210
|
if (Exit3.isSuccess(result.exit)) {
|
|
770
|
-
const output = yield*
|
|
1211
|
+
const output = yield* Schema8.encodeUnknownEffect(Schema8.toCodecJson(loop.output))(result.exit.value).pipe(Effect2.flatMap(Schema8.decodeUnknownEffect(Schema8.Json)), Effect2.option);
|
|
771
1212
|
if (Option.isSome(output)) {
|
|
772
1213
|
yield* written(journal.finish({ status: "completed", output: output.value }));
|
|
773
1214
|
return "completed";
|
|
@@ -790,6 +1231,11 @@ var programLease2 = (work) => ({
|
|
|
790
1231
|
fencingToken: work.lease.fencingToken,
|
|
791
1232
|
capacitySlot: work.lease.capacitySlot
|
|
792
1233
|
});
|
|
1234
|
+
var rpcRunFiles2 = (rpc, lease) => ({
|
|
1235
|
+
createRunFile: (file) => rpc.createRunFile({ lease, ...file }),
|
|
1236
|
+
runFileParts: (request) => Effect2.map(rpc.runFileParts({ lease, ...request, partNumbers: [...request.partNumbers] }), ({ parts }) => parts),
|
|
1237
|
+
completeRunFile: ({ parts, ...request }) => rpc.completeRunFile({ lease, ...request, ...parts === undefined ? undefined : { parts: [...parts] } })
|
|
1238
|
+
});
|
|
793
1239
|
var rpcProgramJournal2 = (rpc, work) => {
|
|
794
1240
|
const lease = programLease2(work);
|
|
795
1241
|
return {
|
|
@@ -814,7 +1260,8 @@ var rpcProgramJournal2 = (rpc, work) => {
|
|
|
814
1260
|
startAgentStep: ({ secrets, ...step }) => rpc.startAgentStep({ lease, ...step, ...secrets === undefined ? undefined : { secrets: [...secrets] } }),
|
|
815
1261
|
awaitEvent: (wait) => rpc.awaitEvent({ lease, ...wait }),
|
|
816
1262
|
admitChild: (child) => rpc.admitChild({ lease, ...child }),
|
|
817
|
-
storeArtifact: (artifact) => rpc.storeArtifact({ lease, ...artifact }),
|
|
1263
|
+
storeArtifact: ({ fileIds, ...artifact }) => rpc.storeArtifact({ lease, ...artifact, ...fileIds === undefined ? undefined : { fileIds: [...fileIds] } }),
|
|
1264
|
+
...rpcRunFiles2(rpc, lease),
|
|
818
1265
|
recordNote: (note) => rpc.recordNote({ lease, ...note }),
|
|
819
1266
|
performHostEffect: (request) => rpc.performHostEffect({ lease, ...request }),
|
|
820
1267
|
createPlanTasks: (tickets) => rpc.createPlanTasks({
|
|
@@ -829,6 +1276,28 @@ var rpcProgramJournal2 = (rpc, work) => {
|
|
|
829
1276
|
}))
|
|
830
1277
|
}),
|
|
831
1278
|
integrationBranch: (repoBindingId) => rpc.integrationBranch({ lease, ...repoBindingId === undefined ? undefined : { repoBindingId } }),
|
|
1279
|
+
readTranscripts: (request) => rpc.readTranscripts({ lease, ...request }),
|
|
1280
|
+
propose: ({ step, proposal }) => rpc.propose({
|
|
1281
|
+
lease,
|
|
1282
|
+
step,
|
|
1283
|
+
proposal: proposal.kind === "memory" ? { ...proposal, citations: [...proposal.citations] } : {
|
|
1284
|
+
kind: "task",
|
|
1285
|
+
title: proposal.title,
|
|
1286
|
+
description: proposal.description,
|
|
1287
|
+
...proposal.teamId === undefined ? undefined : { teamId: proposal.teamId },
|
|
1288
|
+
citations: [...proposal.citations]
|
|
1289
|
+
}
|
|
1290
|
+
}),
|
|
1291
|
+
readProject: (request) => rpc.readProject({ lease, ...request }),
|
|
1292
|
+
draftUpdate: ({ writtenFrom, ...request }) => rpc.draftUpdate({
|
|
1293
|
+
lease,
|
|
1294
|
+
...request,
|
|
1295
|
+
writtenFrom: {
|
|
1296
|
+
runs: writtenFrom.runs,
|
|
1297
|
+
taskChanges: writtenFrom.taskChanges,
|
|
1298
|
+
...writtenFrom.since === undefined ? undefined : { since: writtenFrom.since }
|
|
1299
|
+
}
|
|
1300
|
+
}),
|
|
832
1301
|
mergeChangeRequest: (request) => rpc.mergeChangeRequest({ lease, ...request }),
|
|
833
1302
|
publishRelease: (request) => rpc.publishRelease({ lease, ...request }),
|
|
834
1303
|
suspend: rpc.suspend({ lease }),
|
|
@@ -839,7 +1308,7 @@ var rpcProgramJournal2 = (rpc, work) => {
|
|
|
839
1308
|
// packages/live/src/rpc/runner-client.ts
|
|
840
1309
|
import * as Effect3 from "effect/Effect";
|
|
841
1310
|
import * as Layer2 from "effect/Layer";
|
|
842
|
-
import * as
|
|
1311
|
+
import * as Stream2 from "effect/Stream";
|
|
843
1312
|
import { RpcClient, RpcSerialization } from "effect/rpc";
|
|
844
1313
|
import * as Socket from "effect/socket/Socket";
|
|
845
1314
|
var proxiedWebSocket = (proxy) => Layer2.succeed(Socket.WebSocketConstructor)((target) => {
|
|
@@ -878,44 +1347,58 @@ var makeRunnerRpcClient = (options) => Effect3.gen(function* () {
|
|
|
878
1347
|
awaitEvent: (input) => authorized(client.AwaitEvent(input)),
|
|
879
1348
|
admitChild: (input) => authorized(client.AdmitChild(input)),
|
|
880
1349
|
storeArtifact: (input) => authorized(client.StoreArtifact(input)),
|
|
1350
|
+
createRunFile: (input) => authorized(client.CreateRunFile(input)),
|
|
1351
|
+
runFileParts: (input) => authorized(client.RunFileParts(input)),
|
|
1352
|
+
completeRunFile: (input) => authorized(client.CompleteRunFile(input)),
|
|
881
1353
|
recordNote: (input) => authorized(client.RecordNote(input)),
|
|
882
1354
|
performHostEffect: (input) => authorized(client.PerformHostEffect(input)),
|
|
883
1355
|
createPlanTasks: (input) => authorized(client.CreatePlanTasks(input)),
|
|
1356
|
+
readTranscripts: (input) => authorized(client.ReadTranscripts(input)),
|
|
1357
|
+
propose: (input) => authorized(client.Propose(input)),
|
|
1358
|
+
readProject: (input) => authorized(client.ReadProject(input)),
|
|
1359
|
+
draftUpdate: (input) => authorized(client.DraftUpdate(input)),
|
|
884
1360
|
integrationBranch: (input) => authorized(client.IntegrationBranch(input)),
|
|
885
1361
|
mergeChangeRequest: (input) => authorized(client.MergeChangeRequest(input)),
|
|
886
1362
|
publishRelease: (input) => authorized(client.PublishRelease(input)),
|
|
887
1363
|
bundle: (digest) => authorized(client.Bundle({ digest })),
|
|
888
1364
|
settledRuns: (runIds) => authorized(client.SettledRuns({ runIds })),
|
|
889
1365
|
reportSteer: (input) => authorized(client.ReportSteer(input)),
|
|
1366
|
+
appendTranscript: (input) => authorized(client.AppendTranscript(input)),
|
|
1367
|
+
createCheckpointFile: (input) => authorized(client.CreateCheckpointFile(input)),
|
|
1368
|
+
checkpointFileParts: (input) => authorized(client.CheckpointFileParts(input)),
|
|
1369
|
+
completeCheckpointFile: (input) => authorized(client.CompleteCheckpointFile(input)),
|
|
890
1370
|
saveCheckpoint: (input) => authorized(client.SaveCheckpoint(input)),
|
|
891
1371
|
resumeCheckpoint: (input) => authorized(client.ResumeCheckpoint(input)),
|
|
892
1372
|
settledCheckpoints: authorized(client.SettledCheckpoints()),
|
|
893
1373
|
forgetCheckpoints: (stepAttemptIds) => authorized(client.ForgetCheckpoints({ stepAttemptIds })),
|
|
894
|
-
listen: (runnerReplicaId, onSignal) => authorized(
|
|
1374
|
+
listen: (runnerReplicaId, onSignal) => authorized(Stream2.runForEach(client.Signals({ runnerReplicaId }), onSignal))
|
|
895
1375
|
};
|
|
896
1376
|
});
|
|
897
1377
|
|
|
898
1378
|
// packages/sdk/src/program/host.ts
|
|
899
1379
|
import * as BunRuntime from "@effect/platform-bun/BunRuntime";
|
|
1380
|
+
import * as BunServices from "@effect/platform-bun/BunServices";
|
|
900
1381
|
import * as Config from "effect/Config";
|
|
901
1382
|
import * as ConfigProvider from "effect/ConfigProvider";
|
|
902
1383
|
import * as Effect4 from "effect/Effect";
|
|
1384
|
+
import * as Layer3 from "effect/Layer";
|
|
903
1385
|
import * as Option2 from "effect/Option";
|
|
904
1386
|
import * as Redacted2 from "effect/Redacted";
|
|
905
|
-
import * as
|
|
1387
|
+
import * as Schema9 from "effect/Schema";
|
|
1388
|
+
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
906
1389
|
var describeFlag2 = "--kitman-describe";
|
|
907
|
-
var Described2 =
|
|
908
|
-
|
|
909
|
-
loops:
|
|
910
|
-
agents:
|
|
911
|
-
schedules:
|
|
912
|
-
kits:
|
|
1390
|
+
var Described2 = Schema9.Union([
|
|
1391
|
+
Schema9.TaggedStruct("Described", {
|
|
1392
|
+
loops: Schema9.Array(LoopManifest),
|
|
1393
|
+
agents: Schema9.Record(Schema9.String, Schema9.Json),
|
|
1394
|
+
schedules: Schema9.optionalKey(Schema9.Record(Schema9.String, Schema9.Json)),
|
|
1395
|
+
kits: Schema9.optionalKey(Schema9.Record(Schema9.String, Schema9.Json))
|
|
913
1396
|
}),
|
|
914
|
-
|
|
1397
|
+
Schema9.TaggedStruct("Refused", { error: Schema9.Union([ManifestInvalid2, LoopCheckError2]) })
|
|
915
1398
|
]);
|
|
916
|
-
var encodeDescribed =
|
|
1399
|
+
var encodeDescribed = Schema9.encodeEffect(Schema9.fromJsonString(Schema9.toCodecJson(Described2)));
|
|
917
1400
|
|
|
918
|
-
class ProgramRefused extends
|
|
1401
|
+
class ProgramRefused extends Schema9.TaggedError()("ProgramRefused", { reason: Schema9.String }) {
|
|
919
1402
|
get message() {
|
|
920
1403
|
return this.reason;
|
|
921
1404
|
}
|
|
@@ -1018,7 +1501,7 @@ var host = (config) => Effect4.gen(function* () {
|
|
|
1018
1501
|
const loopId = yield* Config.String("KITMAN_LOOP_ID");
|
|
1019
1502
|
const apiUrl = yield* Config.String("KITMAN_API_URL");
|
|
1020
1503
|
const credential = yield* Config.Redacted("KITMAN_PROGRAM_CREDENTIAL");
|
|
1021
|
-
const work = yield*
|
|
1504
|
+
const work = yield* Schema9.decodeEffect(Schema9.fromJsonString(Schema9.Unknown))(yield* readStdin);
|
|
1022
1505
|
if (!isWorkUnit(work))
|
|
1023
1506
|
return yield* new ProgramRefused({ reason: "stdin holds no orchestration Work Unit" });
|
|
1024
1507
|
const loop = config.loops.find((candidate) => candidate.id === loopId);
|
|
@@ -1045,11 +1528,11 @@ var host = (config) => Effect4.gen(function* () {
|
|
|
1045
1528
|
if (guard !== undefined)
|
|
1046
1529
|
globalThis.fetch = Object.assign(guard.fetch, { preconnect: globalThis.fetch.preconnect });
|
|
1047
1530
|
const journal = rpcProgramJournal2(rpc, work);
|
|
1048
|
-
return yield* runProgram2(loop, work, guard === undefined ? journal : guard.journal(journal)).pipe(Effect4.provideService(ConfigProvider.ConfigProvider, ConfigProvider.fromUnknown(secrets.value)), Effect4.as(0), Effect4.catchTag("JournalWriteFailed", (error) => Effect4.as(Effect4.logError(error.message), 1)));
|
|
1531
|
+
return yield* runProgram2(loop, work, guard === undefined ? journal : guard.journal(journal)).pipe(Effect4.provide(Layer3.merge(BunServices.layer, FetchHttpClient.layer)), Effect4.provideService(ConfigProvider.ConfigProvider, ConfigProvider.fromUnknown(secrets.value)), Effect4.as(0), Effect4.catchTag("JournalWriteFailed", (error) => Effect4.as(Effect4.logError(error.message), 1)));
|
|
1049
1532
|
}).pipe(Effect4.scoped, Effect4.catch((error) => Effect4.as(Effect4.logError(error.message), 2)));
|
|
1050
1533
|
var runPackage2 = (config) => {
|
|
1051
1534
|
const program = process.argv.includes(describeFlag2) ? describe(config) : host(config);
|
|
1052
1535
|
BunRuntime.runMain(program.pipe(Effect4.flatMap((code) => Effect4.sync(() => process.exit(code)))));
|
|
1053
1536
|
};
|
|
1054
1537
|
|
|
1055
|
-
export { RunnerRpcProtocolVersion, JournalWriteFailed2, refusedStep2, runProgram2, programLease2, rpcProgramJournal2, describeFlag2, Described2, programSecrets2, programHostsEnv2, undeclaredHostsEnv2, networkGuard2, runPackage2 };
|
|
1538
|
+
export { digestSha256, RunnerRpcProtocolVersion, JournalWriteFailed2, refusedStep2, uploadRunFile2, runProgram2, programLease2, rpcRunFiles2, rpcProgramJournal2, describeFlag2, Described2, programSecrets2, programHostsEnv2, undeclaredHostsEnv2, networkGuard2, runPackage2 };
|