@kitman-sh/sdk 0.0.0-stage → 0.7.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 +215 -0
- package/dist/chunk-7hwhxthh.js +1055 -0
- package/dist/chunk-zp7s46pz.js +3966 -0
- package/dist/loop/index.js +193 -0
- package/dist/program/index.js +30 -0
- package/package.json +29 -4
- package/types/packages/core/src/a2a.d.ts +577 -0
- package/types/packages/core/src/agent-capabilities.d.ts +1434 -0
- package/types/packages/core/src/agent-environment.d.ts +2429 -0
- package/types/packages/core/src/agent-launch-snapshot.d.ts +44 -0
- package/types/packages/core/src/agent-sandbox-policy.d.ts +33 -0
- package/types/packages/core/src/approval-queue.d.ts +126 -0
- package/types/packages/core/src/audit.d.ts +52 -0
- package/types/packages/core/src/change-delivery.d.ts +39 -0
- package/types/packages/core/src/change-request-review.d.ts +146 -0
- package/types/packages/core/src/change-request.d.ts +432 -0
- package/types/packages/core/src/common.d.ts +6 -0
- package/types/packages/core/src/connection.d.ts +33 -0
- package/types/packages/core/src/context-feedback.d.ts +89 -0
- package/types/packages/core/src/context-pack.d.ts +182 -0
- package/types/packages/core/src/crypto.d.ts +11 -0
- package/types/packages/core/src/data-lifecycle.d.ts +195 -0
- package/types/packages/core/src/decision.d.ts +48 -0
- package/types/packages/core/src/delivery-operation.d.ts +125 -0
- package/types/packages/core/src/delivery-policy.d.ts +174 -0
- package/types/packages/core/src/engineering-resources.d.ts +26 -0
- package/types/packages/core/src/enterprise-code-host.d.ts +18 -0
- package/types/packages/core/src/epic-delivery.d.ts +38 -0
- package/types/packages/core/src/extension.d.ts +35 -0
- package/types/packages/core/src/external-effect.d.ts +313 -0
- package/types/packages/core/src/fix-flow.d.ts +149 -0
- package/types/packages/core/src/following.d.ts +59 -0
- package/types/packages/core/src/github-delivery-fixtures.d.ts +28 -0
- package/types/packages/core/src/github-delivery.d.ts +78 -0
- package/types/packages/core/src/gitlab-delivery-fixtures.d.ts +26 -0
- package/types/packages/core/src/gitlab-delivery.d.ts +76 -0
- package/types/packages/core/src/global-search.d.ts +42 -0
- package/types/packages/core/src/id.d.ts +1 -0
- package/types/packages/core/src/index.d.ts +74 -0
- package/types/packages/core/src/integration.d.ts +255 -0
- package/types/packages/core/src/intent.d.ts +260 -0
- package/types/packages/core/src/json.d.ts +10 -0
- package/types/packages/core/src/kit-taxonomy.d.ts +21 -0
- package/types/packages/core/src/kit.d.ts +1489 -0
- package/types/packages/core/src/live.d.ts +8309 -0
- package/types/packages/core/src/loop-layers.d.ts +59 -0
- package/types/packages/core/src/loop-version.d.ts +59 -0
- package/types/packages/core/src/loop.d.ts +3076 -0
- package/types/packages/core/src/me.d.ts +31 -0
- package/types/packages/core/src/memory.d.ts +88 -0
- package/types/packages/core/src/my-teams.d.ts +1230 -0
- package/types/packages/core/src/notification.d.ts +181 -0
- package/types/packages/core/src/observability.d.ts +175 -0
- package/types/packages/core/src/package-declarations.d.ts +435 -0
- package/types/packages/core/src/package.d.ts +369 -0
- package/types/packages/core/src/personal-development-profile.d.ts +11 -0
- package/types/packages/core/src/platform-release.d.ts +60 -0
- package/types/packages/core/src/program-credential.d.ts +10 -0
- package/types/packages/core/src/project.d.ts +66 -0
- package/types/packages/core/src/proposal.d.ts +292 -0
- package/types/packages/core/src/provider-safe-text.d.ts +2 -0
- package/types/packages/core/src/redaction.d.ts +73 -0
- package/types/packages/core/src/repo-binding.d.ts +131 -0
- package/types/packages/core/src/run-journal.d.ts +28 -0
- package/types/packages/core/src/run-launch.d.ts +67 -0
- package/types/packages/core/src/run.d.ts +566 -0
- package/types/packages/core/src/runner-eligibility.d.ts +43 -0
- package/types/packages/core/src/runner-routing.d.ts +11 -0
- package/types/packages/core/src/runner-trust.d.ts +67 -0
- package/types/packages/core/src/runner.d.ts +3750 -0
- package/types/packages/core/src/runtime-type.d.ts +36 -0
- package/types/packages/core/src/schedule.d.ts +136 -0
- package/types/packages/core/src/schema.d.ts +89 -0
- package/types/packages/core/src/scope-directory.d.ts +100 -0
- package/types/packages/core/src/secret.d.ts +37 -0
- package/types/packages/core/src/session.d.ts +90 -0
- package/types/packages/core/src/step-brief.d.ts +50 -0
- package/types/packages/core/src/sync-kit.d.ts +587 -0
- package/types/packages/core/src/task-detail.d.ts +491 -0
- package/types/packages/core/src/task-execution-record.d.ts +620 -0
- package/types/packages/core/src/task-key.d.ts +9 -0
- package/types/packages/core/src/task.d.ts +543 -0
- package/types/packages/core/src/trigger-dispatch.d.ts +421 -0
- package/types/packages/core/src/work-unit.d.ts +740 -0
- package/types/packages/core/src/workspace.d.ts +96 -0
- package/types/packages/live/src/rpc/runner-client.d.ts +947 -0
- package/types/packages/live/src/rpc/runner-group.d.ts +733 -0
- package/types/packages/sdk/src/build/index.d.ts +45 -0
- package/types/packages/sdk/src/loop/activities.d.ts +187 -0
- package/types/packages/sdk/src/loop/check.d.ts +39 -0
- package/types/packages/sdk/src/loop/config.d.ts +68 -0
- package/types/packages/sdk/src/loop/define.d.ts +76 -0
- package/types/packages/sdk/src/loop/evidence.d.ts +66 -0
- package/types/packages/sdk/src/loop/index.d.ts +9 -0
- package/types/packages/sdk/src/loop/plan.d.ts +43 -0
- package/types/packages/sdk/src/loop/review.d.ts +86 -0
- package/types/packages/sdk/src/loop/steps.d.ts +224 -0
- package/types/packages/sdk/src/loop/test-loop.d.ts +112 -0
- package/types/packages/sdk/src/program/engine.d.ts +144 -0
- package/types/packages/sdk/src/program/host.d.ts +70 -0
- package/types/packages/sdk/src/program/index.d.ts +2 -0
- package/README.md +0 -3
|
@@ -0,0 +1,3966 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/core/src/package-declarations.ts
|
|
3
|
+
import * as Schema14 from "effect/Schema";
|
|
4
|
+
|
|
5
|
+
// packages/core/src/agent-sandbox-policy.ts
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
7
|
+
var Path = Schema.String.check(Schema.isMinLength(1));
|
|
8
|
+
var AgentSandboxNetwork = Schema.Union([
|
|
9
|
+
Schema.Struct({ hosts: Schema.Array(Schema.String.check(Schema.isMinLength(1))) }),
|
|
10
|
+
Schema.Literal("open")
|
|
11
|
+
]);
|
|
12
|
+
var AgentSandboxPolicy = Schema.Struct({
|
|
13
|
+
writablePaths: Schema.Array(Path),
|
|
14
|
+
readDeniedPaths: Schema.Array(Path),
|
|
15
|
+
readAllowedPaths: Schema.Array(Path),
|
|
16
|
+
network: AgentSandboxNetwork,
|
|
17
|
+
environment: Schema.Record(Schema.String.check(Schema.isMinLength(1)), Schema.String),
|
|
18
|
+
dockerImageDigest: Schema.optionalKey(Schema.String.check(Schema.isPattern(new RegExp("^sha256:[a-f0-9]{64}$", "u"))))
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// packages/core/src/loop-version.ts
|
|
22
|
+
import * as Schema4 from "effect/Schema";
|
|
23
|
+
|
|
24
|
+
// packages/core/src/common.ts
|
|
25
|
+
import * as Schema3 from "effect/Schema";
|
|
26
|
+
|
|
27
|
+
// packages/core/src/schema.ts
|
|
28
|
+
import * as Exit from "effect/Exit";
|
|
29
|
+
import * as JsonSchema from "effect/JsonSchema";
|
|
30
|
+
import * as Predicate from "effect/Predicate";
|
|
31
|
+
import * as Schema2 from "effect/Schema";
|
|
32
|
+
var Days = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
33
|
+
var DatePattern = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
|
|
34
|
+
var TimePattern = /^(\d\d):(\d\d):(\d\d)(?:\.\d+)?(?:([Zz])|([+-])(\d\d):(\d\d))$/;
|
|
35
|
+
function isRfc3339Date(value) {
|
|
36
|
+
const match = DatePattern.exec(value);
|
|
37
|
+
if (match === null)
|
|
38
|
+
return false;
|
|
39
|
+
const year = Number(match[1]);
|
|
40
|
+
const month = Number(match[2]);
|
|
41
|
+
const day = Number(match[3]);
|
|
42
|
+
const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
43
|
+
return month >= 1 && month <= 12 && day >= 1 && day <= (month === 2 && leap ? 29 : Days[month] ?? 0);
|
|
44
|
+
}
|
|
45
|
+
function isRfc3339Time(value) {
|
|
46
|
+
const match = TimePattern.exec(value);
|
|
47
|
+
if (match === null)
|
|
48
|
+
return false;
|
|
49
|
+
const hour = Number(match[1]);
|
|
50
|
+
const minute = Number(match[2]);
|
|
51
|
+
const second = Number(match[3]);
|
|
52
|
+
if (hour > 23 || minute > 59 || second > 60)
|
|
53
|
+
return false;
|
|
54
|
+
if (match[5] !== undefined && (Number(match[6]) > 23 || Number(match[7]) > 59))
|
|
55
|
+
return false;
|
|
56
|
+
if (second < 60)
|
|
57
|
+
return true;
|
|
58
|
+
const sign = match[5] === "-" ? -1 : 1;
|
|
59
|
+
const utcMinutes = hour * 60 + minute - sign * (Number(match[6] ?? 0) * 60 + Number(match[7] ?? 0));
|
|
60
|
+
return (utcMinutes % 1440 + 1440) % 1440 === 1439;
|
|
61
|
+
}
|
|
62
|
+
var isDateTime = Schema2.makeFilter((value) => {
|
|
63
|
+
const parts = value.split(/T/i);
|
|
64
|
+
return parts.length === 2 && isRfc3339Date(parts[0] ?? "") && isRfc3339Time(parts[1] ?? "");
|
|
65
|
+
}, { expected: "an RFC 3339 date-time", toJsonSchema: () => ({ format: "date-time" }) });
|
|
66
|
+
var Numeric = Schema2.Union([Schema2.Finite, Schema2.FiniteFromString]);
|
|
67
|
+
var isWholeNumber = Schema2.makeFilter(Number.isInteger, {
|
|
68
|
+
expected: "an integer",
|
|
69
|
+
toJsonSchema: () => ({ multipleOf: 1 })
|
|
70
|
+
});
|
|
71
|
+
function guard(schema) {
|
|
72
|
+
const cached = guards.get(schema);
|
|
73
|
+
if (cached !== undefined) {
|
|
74
|
+
return cached;
|
|
75
|
+
}
|
|
76
|
+
const decode = Schema2.decodeUnknownExit(Schema2.toType(schema));
|
|
77
|
+
const created = (input) => Exit.isSuccess(decode(input, { onExcessProperty: "error" })) || hasUndefinedProperty(input) && Exit.isSuccess(decode(withoutUndefined(input), { onExcessProperty: "error" }));
|
|
78
|
+
guards.set(schema, created);
|
|
79
|
+
return created;
|
|
80
|
+
}
|
|
81
|
+
var guards = new WeakMap;
|
|
82
|
+
function hasUndefinedProperty(value) {
|
|
83
|
+
if (Array.isArray(value))
|
|
84
|
+
return value.some(hasUndefinedProperty);
|
|
85
|
+
if (!Predicate.isObject(value))
|
|
86
|
+
return false;
|
|
87
|
+
return Object.values(value).some((entry) => entry === undefined || hasUndefinedProperty(entry));
|
|
88
|
+
}
|
|
89
|
+
function withoutUndefined(value) {
|
|
90
|
+
if (Array.isArray(value)) {
|
|
91
|
+
return value.map(withoutUndefined);
|
|
92
|
+
}
|
|
93
|
+
if (!Predicate.isObject(value) || Object.getPrototypeOf(value) !== Object.prototype)
|
|
94
|
+
return value;
|
|
95
|
+
return Object.fromEntries(Object.entries(value).flatMap(([key, entry]) => entry === undefined ? [] : [[key, withoutUndefined(entry)]]));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// packages/core/src/common.ts
|
|
99
|
+
var Id = Schema3.String.check(Schema3.isMinLength(1));
|
|
100
|
+
var Slug = Schema3.String.check(Schema3.isMinLength(1), Schema3.isPattern(new RegExp("^[a-z0-9]+(?:-[a-z0-9]+)*$", "u")));
|
|
101
|
+
var Timestamp = Schema3.String.check(isDateTime);
|
|
102
|
+
var ApiError = Schema3.Struct({
|
|
103
|
+
error: Schema3.Struct({
|
|
104
|
+
code: Schema3.String,
|
|
105
|
+
message: Schema3.String,
|
|
106
|
+
details: Schema3.optionalKey(Schema3.Record(Schema3.String, Schema3.Unknown))
|
|
107
|
+
})
|
|
108
|
+
});
|
|
109
|
+
var ActorType = Schema3.Union([
|
|
110
|
+
Schema3.Literal("human"),
|
|
111
|
+
Schema3.Literal("delegated_agent"),
|
|
112
|
+
Schema3.Literal("agent")
|
|
113
|
+
]);
|
|
114
|
+
|
|
115
|
+
// packages/core/src/loop-version.ts
|
|
116
|
+
var LoopReferenceSchema = Schema4.Union([
|
|
117
|
+
Schema4.Struct({ loopId: Id, alias: Schema4.String.check(Schema4.isMinLength(1), Schema4.isMaxLength(120)) }),
|
|
118
|
+
Schema4.Struct({ loopId: Id, versionId: Id }),
|
|
119
|
+
Schema4.Struct({ loopId: Id, version: Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(1)) }),
|
|
120
|
+
Schema4.Struct({
|
|
121
|
+
loopId: Id,
|
|
122
|
+
digest: Schema4.String.check(Schema4.isMinLength(64), Schema4.isMaxLength(64), Schema4.isPattern(new RegExp("^[a-f0-9]{64}$", "u")))
|
|
123
|
+
}),
|
|
124
|
+
Schema4.Struct({
|
|
125
|
+
slug: Schema4.String.check(Schema4.isMinLength(1), Schema4.isMaxLength(240)),
|
|
126
|
+
alias: Schema4.String.check(Schema4.isMinLength(1), Schema4.isMaxLength(120))
|
|
127
|
+
}),
|
|
128
|
+
Schema4.Struct({
|
|
129
|
+
slug: Schema4.String.check(Schema4.isMinLength(1), Schema4.isMaxLength(240)),
|
|
130
|
+
version: Schema4.Int.check(Schema4.isGreaterThanOrEqualTo(1))
|
|
131
|
+
}),
|
|
132
|
+
Schema4.Struct({
|
|
133
|
+
slug: Schema4.String.check(Schema4.isMinLength(1), Schema4.isMaxLength(240)),
|
|
134
|
+
digest: Schema4.String.check(Schema4.isMinLength(64), Schema4.isMaxLength(64), Schema4.isPattern(new RegExp("^[a-f0-9]{64}$", "u")))
|
|
135
|
+
})
|
|
136
|
+
]);
|
|
137
|
+
|
|
138
|
+
// packages/core/src/agent-environment.ts
|
|
139
|
+
import * as Schema5 from "effect/Schema";
|
|
140
|
+
var AgentEnvironmentPolicy = Schema5.Union([Schema5.Literal("recommended"), Schema5.Literal("required")]);
|
|
141
|
+
var AgentHarnessId = Schema5.Union([
|
|
142
|
+
Schema5.Literal("opencode"),
|
|
143
|
+
Schema5.Literal("claude-code"),
|
|
144
|
+
Schema5.Literal("codex"),
|
|
145
|
+
Schema5.Literal("pi")
|
|
146
|
+
]);
|
|
147
|
+
var Sha256 = Schema5.String.check(Schema5.isPattern(new RegExp("^[a-fA-F0-9]{64}$", "u")));
|
|
148
|
+
var relativePathPattern = "^(?!/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.\\.?($|/)).+$";
|
|
149
|
+
var skillNamePattern = "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$";
|
|
150
|
+
var SourcePath = Schema5.String.check(Schema5.isMinLength(1), Schema5.isPattern(new RegExp(relativePathPattern, "u")));
|
|
151
|
+
var SkillSource = Schema5.Union([
|
|
152
|
+
Schema5.Struct({
|
|
153
|
+
kind: Schema5.Literal("skills_sh"),
|
|
154
|
+
slug: Schema5.String.check(Schema5.isMinLength(1)),
|
|
155
|
+
version: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1)))
|
|
156
|
+
}),
|
|
157
|
+
Schema5.Struct({
|
|
158
|
+
kind: Schema5.Literal("kitman"),
|
|
159
|
+
skillId: Schema5.optionalKey(Id),
|
|
160
|
+
name: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1))),
|
|
161
|
+
contentMarkdown: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1))),
|
|
162
|
+
files: Schema5.optionalKey(Schema5.Record(SourcePath, Schema5.String))
|
|
163
|
+
}),
|
|
164
|
+
Schema5.Struct({
|
|
165
|
+
kind: Schema5.Literal("git"),
|
|
166
|
+
url: Schema5.String.check(Schema5.isMinLength(1)),
|
|
167
|
+
ref: Schema5.String.check(Schema5.isMinLength(1)),
|
|
168
|
+
path: Schema5.optionalKey(SourcePath),
|
|
169
|
+
sha256: Schema5.optionalKey(Sha256)
|
|
170
|
+
}),
|
|
171
|
+
Schema5.Struct({
|
|
172
|
+
kind: Schema5.Literal("package"),
|
|
173
|
+
packageName: Schema5.String.check(Schema5.isMinLength(1)),
|
|
174
|
+
version: Schema5.String.check(Schema5.isMinLength(1)),
|
|
175
|
+
path: Schema5.optionalKey(SourcePath),
|
|
176
|
+
sha256: Schema5.optionalKey(Sha256)
|
|
177
|
+
}),
|
|
178
|
+
Schema5.Struct({ kind: Schema5.Literal("url"), url: Schema5.String.check(Schema5.isMinLength(1)), sha256: Sha256 }),
|
|
179
|
+
Schema5.Struct({ kind: Schema5.Literal("local_path"), path: Schema5.String.check(Schema5.isMinLength(1)) })
|
|
180
|
+
]);
|
|
181
|
+
var PluginSource = Schema5.Union([
|
|
182
|
+
Schema5.Struct({
|
|
183
|
+
kind: Schema5.Literal("package"),
|
|
184
|
+
packageName: Schema5.String.check(Schema5.isMinLength(1)),
|
|
185
|
+
version: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1)))
|
|
186
|
+
}),
|
|
187
|
+
Schema5.Struct({
|
|
188
|
+
kind: Schema5.Literal("git"),
|
|
189
|
+
url: Schema5.String.check(Schema5.isMinLength(1)),
|
|
190
|
+
ref: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1)))
|
|
191
|
+
}),
|
|
192
|
+
Schema5.Struct({
|
|
193
|
+
kind: Schema5.Literal("url"),
|
|
194
|
+
url: Schema5.String.check(Schema5.isMinLength(1)),
|
|
195
|
+
sha256: Schema5.String.check(Schema5.isPattern(new RegExp("^[a-fA-F0-9]{64}$", "u")))
|
|
196
|
+
}),
|
|
197
|
+
Schema5.Struct({ kind: Schema5.Literal("local_path"), path: Schema5.String.check(Schema5.isMinLength(1)) })
|
|
198
|
+
]);
|
|
199
|
+
var McpServerTransport = Schema5.Union([
|
|
200
|
+
Schema5.Struct({
|
|
201
|
+
kind: Schema5.Literal("stdio"),
|
|
202
|
+
command: Schema5.String.check(Schema5.isMinLength(1)),
|
|
203
|
+
args: Schema5.optionalKey(Schema5.Array(Schema5.String)),
|
|
204
|
+
env: Schema5.optionalKey(Schema5.Record(Schema5.String, Schema5.String))
|
|
205
|
+
}),
|
|
206
|
+
Schema5.Struct({
|
|
207
|
+
kind: Schema5.Literal("streamable_http"),
|
|
208
|
+
url: Schema5.String.check(Schema5.isMinLength(1)),
|
|
209
|
+
headers: Schema5.optionalKey(Schema5.Record(Schema5.String, Schema5.String))
|
|
210
|
+
})
|
|
211
|
+
]);
|
|
212
|
+
var ProviderAuthRef = Schema5.Union([
|
|
213
|
+
Schema5.Struct({
|
|
214
|
+
provider: Schema5.String.check(Schema5.isMinLength(1)),
|
|
215
|
+
policy: AgentEnvironmentPolicy,
|
|
216
|
+
kind: Schema5.Literal("existing_harness_login"),
|
|
217
|
+
accountHint: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1)))
|
|
218
|
+
}),
|
|
219
|
+
Schema5.Struct({
|
|
220
|
+
provider: Schema5.String.check(Schema5.isMinLength(1)),
|
|
221
|
+
policy: AgentEnvironmentPolicy,
|
|
222
|
+
kind: Schema5.Literal("local_env"),
|
|
223
|
+
envName: Schema5.String.check(Schema5.isMinLength(1))
|
|
224
|
+
}),
|
|
225
|
+
Schema5.Struct({
|
|
226
|
+
provider: Schema5.String.check(Schema5.isMinLength(1)),
|
|
227
|
+
policy: AgentEnvironmentPolicy,
|
|
228
|
+
kind: Schema5.Literal("runner_secret"),
|
|
229
|
+
runnerSecretName: Schema5.String.check(Schema5.isMinLength(1))
|
|
230
|
+
}),
|
|
231
|
+
Schema5.Struct({
|
|
232
|
+
provider: Schema5.String.check(Schema5.isMinLength(1)),
|
|
233
|
+
policy: AgentEnvironmentPolicy,
|
|
234
|
+
kind: Schema5.Literal("managed_oauth"),
|
|
235
|
+
grantId: Schema5.optionalKey(Id)
|
|
236
|
+
})
|
|
237
|
+
]);
|
|
238
|
+
var RunnerSecretSource = Schema5.Union([
|
|
239
|
+
Schema5.Struct({ kind: Schema5.Literal("env"), envName: Schema5.String.check(Schema5.isMinLength(1)) }),
|
|
240
|
+
Schema5.Struct({ kind: Schema5.Literal("file"), pathRef: Schema5.String.check(Schema5.isMinLength(1)) }),
|
|
241
|
+
Schema5.Struct({ kind: Schema5.Literal("exec"), commandRef: Schema5.String.check(Schema5.isMinLength(1)) })
|
|
242
|
+
]);
|
|
243
|
+
var RunnerSecretRef = Schema5.Struct({
|
|
244
|
+
name: Schema5.String.check(Schema5.isMinLength(1)),
|
|
245
|
+
policy: AgentEnvironmentPolicy,
|
|
246
|
+
source: RunnerSecretSource,
|
|
247
|
+
capabilities: Schema5.optionalKey(Schema5.Array(Schema5.String.check(Schema5.isMinLength(1))))
|
|
248
|
+
});
|
|
249
|
+
var AgentSkillRequirement = Schema5.Struct({
|
|
250
|
+
name: Schema5.String.check(Schema5.isMinLength(1)),
|
|
251
|
+
policy: AgentEnvironmentPolicy,
|
|
252
|
+
source: SkillSource
|
|
253
|
+
});
|
|
254
|
+
var AgentPluginRequirement = Schema5.Struct({
|
|
255
|
+
name: Schema5.String.check(Schema5.isMinLength(1)),
|
|
256
|
+
policy: AgentEnvironmentPolicy,
|
|
257
|
+
source: PluginSource
|
|
258
|
+
});
|
|
259
|
+
var AgentMcpServerRequirement = Schema5.Struct({
|
|
260
|
+
name: Schema5.String.check(Schema5.isMinLength(1)),
|
|
261
|
+
policy: AgentEnvironmentPolicy,
|
|
262
|
+
transport: McpServerTransport
|
|
263
|
+
});
|
|
264
|
+
var AgentHarnessSetting = Schema5.Struct({
|
|
265
|
+
harness: AgentHarnessId,
|
|
266
|
+
key: Schema5.String.check(Schema5.isMinLength(1)),
|
|
267
|
+
policy: AgentEnvironmentPolicy,
|
|
268
|
+
value: Schema5.Unknown
|
|
269
|
+
});
|
|
270
|
+
var AgentRuntimeConstraint = Schema5.Struct({
|
|
271
|
+
key: Schema5.String.check(Schema5.isMinLength(1)),
|
|
272
|
+
policy: AgentEnvironmentPolicy,
|
|
273
|
+
value: Schema5.Unknown
|
|
274
|
+
});
|
|
275
|
+
var AgentPermissionRequirement = Schema5.Struct({
|
|
276
|
+
key: Schema5.String.check(Schema5.isMinLength(1)),
|
|
277
|
+
policy: AgentEnvironmentPolicy,
|
|
278
|
+
value: Schema5.Unknown
|
|
279
|
+
});
|
|
280
|
+
var AgentHookRequirement = Schema5.Struct({
|
|
281
|
+
name: Schema5.String.check(Schema5.isMinLength(1)),
|
|
282
|
+
event: Schema5.String.check(Schema5.isMinLength(1)),
|
|
283
|
+
policy: AgentEnvironmentPolicy,
|
|
284
|
+
command: Schema5.String.check(Schema5.isMinLength(1)),
|
|
285
|
+
args: Schema5.optionalKey(Schema5.Array(Schema5.String)),
|
|
286
|
+
timeoutMs: Schema5.optionalKey(Schema5.Finite.check(Schema5.isGreaterThanOrEqualTo(1)))
|
|
287
|
+
});
|
|
288
|
+
var AgentSandboxPolicyRequirement = Schema5.Struct({
|
|
289
|
+
key: Schema5.String.check(Schema5.isMinLength(1)),
|
|
290
|
+
policy: AgentEnvironmentPolicy,
|
|
291
|
+
value: Schema5.Unknown
|
|
292
|
+
});
|
|
293
|
+
var AgentEnvironmentFragment = Schema5.Struct({
|
|
294
|
+
skills: Schema5.optionalKey(Schema5.Array(AgentSkillRequirement)),
|
|
295
|
+
plugins: Schema5.optionalKey(Schema5.Array(AgentPluginRequirement)),
|
|
296
|
+
mcpServers: Schema5.optionalKey(Schema5.Array(AgentMcpServerRequirement)),
|
|
297
|
+
harnessSettings: Schema5.optionalKey(Schema5.Array(AgentHarnessSetting)),
|
|
298
|
+
providerAuthRefs: Schema5.optionalKey(Schema5.Array(ProviderAuthRef)),
|
|
299
|
+
runnerSecretRefs: Schema5.optionalKey(Schema5.Array(RunnerSecretRef)),
|
|
300
|
+
permissions: Schema5.optionalKey(Schema5.Array(AgentPermissionRequirement)),
|
|
301
|
+
hooks: Schema5.optionalKey(Schema5.Array(AgentHookRequirement)),
|
|
302
|
+
runtimeConstraints: Schema5.optionalKey(Schema5.Array(AgentRuntimeConstraint)),
|
|
303
|
+
sandboxPolicyRequirements: Schema5.optionalKey(Schema5.Array(AgentSandboxPolicyRequirement))
|
|
304
|
+
});
|
|
305
|
+
var HarnessKitActivation = Schema5.Struct({
|
|
306
|
+
harness: AgentHarnessId,
|
|
307
|
+
kitId: Id,
|
|
308
|
+
enabled: Schema5.Boolean,
|
|
309
|
+
policy: Schema5.optionalKey(AgentEnvironmentPolicy)
|
|
310
|
+
});
|
|
311
|
+
var AgentModelPreference = Schema5.Struct({
|
|
312
|
+
harness: AgentHarnessId,
|
|
313
|
+
profileRef: Schema5.String.check(Schema5.isMinLength(1)),
|
|
314
|
+
provider: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1))),
|
|
315
|
+
model: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1)))
|
|
316
|
+
});
|
|
317
|
+
var UserAgentPreferences = Schema5.Struct({
|
|
318
|
+
userId: Schema5.optionalKey(Id),
|
|
319
|
+
defaultHarness: Schema5.optionalKey(AgentHarnessId),
|
|
320
|
+
perHarnessKitActivations: Schema5.optionalKey(Schema5.Array(HarnessKitActivation)),
|
|
321
|
+
modelPreferences: Schema5.optionalKey(Schema5.Array(AgentModelPreference)),
|
|
322
|
+
providerAuthRefs: Schema5.optionalKey(Schema5.Array(ProviderAuthRef)),
|
|
323
|
+
ui: Schema5.optionalKey(Schema5.Record(Schema5.String, Schema5.Unknown)),
|
|
324
|
+
agentEnvironment: Schema5.optionalKey(AgentEnvironmentFragment)
|
|
325
|
+
});
|
|
326
|
+
var AgentSyncProfileSource = Schema5.Union([
|
|
327
|
+
Schema5.Struct({
|
|
328
|
+
kind: Schema5.Literal("personal_kit_defaults"),
|
|
329
|
+
harness: Schema5.optionalKey(AgentHarnessId),
|
|
330
|
+
enabled: Schema5.Boolean
|
|
331
|
+
}),
|
|
332
|
+
Schema5.Struct({ kind: Schema5.Literal("workspace_assignments"), workspaceId: Id, enabled: Schema5.Boolean }),
|
|
333
|
+
Schema5.Struct({
|
|
334
|
+
kind: Schema5.Literal("team_defaults"),
|
|
335
|
+
workspaceId: Id,
|
|
336
|
+
teamId: Schema5.optionalKey(Id),
|
|
337
|
+
enabled: Schema5.Boolean
|
|
338
|
+
}),
|
|
339
|
+
Schema5.Struct({ kind: Schema5.Literal("project_kits"), projectId: Id, enabled: Schema5.Boolean })
|
|
340
|
+
]);
|
|
341
|
+
var AgentSyncProfile = Schema5.Struct({
|
|
342
|
+
id: Schema5.optionalKey(Id),
|
|
343
|
+
userId: Id,
|
|
344
|
+
name: Schema5.String.check(Schema5.isMinLength(1)),
|
|
345
|
+
default: Schema5.optionalKey(Schema5.Boolean),
|
|
346
|
+
harnesses: Schema5.optionalKey(Schema5.Array(AgentHarnessId)),
|
|
347
|
+
sources: Schema5.Array(AgentSyncProfileSource)
|
|
348
|
+
});
|
|
349
|
+
var AgentKitSourceFields = {
|
|
350
|
+
kitRef: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1), Schema5.isMaxLength(240))),
|
|
351
|
+
kitVersion: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1), Schema5.isMaxLength(120))),
|
|
352
|
+
kitSha256: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(64), Schema5.isMaxLength(64), Schema5.isPattern(new RegExp("^[a-fA-F0-9]{64}$", "u")))),
|
|
353
|
+
kitActivationId: Schema5.optionalKey(Id),
|
|
354
|
+
kitActivationType: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1), Schema5.isMaxLength(80)))
|
|
355
|
+
};
|
|
356
|
+
var AgentEnvironmentSource = Schema5.Union([
|
|
357
|
+
Schema5.Struct({
|
|
358
|
+
kind: Schema5.Literal("built_in"),
|
|
359
|
+
label: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1)))
|
|
360
|
+
}),
|
|
361
|
+
Schema5.Struct({
|
|
362
|
+
kind: Schema5.Literal("user_preferences"),
|
|
363
|
+
userId: Id,
|
|
364
|
+
label: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1)))
|
|
365
|
+
}),
|
|
366
|
+
Schema5.Struct({
|
|
367
|
+
kind: Schema5.Literal("user_kit"),
|
|
368
|
+
userId: Id,
|
|
369
|
+
kitId: Id,
|
|
370
|
+
...AgentKitSourceFields,
|
|
371
|
+
label: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1)))
|
|
372
|
+
}),
|
|
373
|
+
Schema5.Struct({
|
|
374
|
+
kind: Schema5.Literal("agent_sync_profile"),
|
|
375
|
+
profileId: Schema5.optionalKey(Id),
|
|
376
|
+
userId: Id,
|
|
377
|
+
label: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1)))
|
|
378
|
+
}),
|
|
379
|
+
Schema5.Struct({
|
|
380
|
+
kind: Schema5.Literal("device_local"),
|
|
381
|
+
label: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1)))
|
|
382
|
+
}),
|
|
383
|
+
Schema5.Struct({
|
|
384
|
+
kind: Schema5.Literal("workspace_kit"),
|
|
385
|
+
kitId: Id,
|
|
386
|
+
...AgentKitSourceFields,
|
|
387
|
+
label: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1)))
|
|
388
|
+
}),
|
|
389
|
+
Schema5.Struct({
|
|
390
|
+
kind: Schema5.Literal("team_default_kit"),
|
|
391
|
+
teamId: Id,
|
|
392
|
+
kitId: Id,
|
|
393
|
+
...AgentKitSourceFields,
|
|
394
|
+
label: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1)))
|
|
395
|
+
}),
|
|
396
|
+
Schema5.Struct({
|
|
397
|
+
kind: Schema5.Literal("project_kit"),
|
|
398
|
+
kitId: Id,
|
|
399
|
+
...AgentKitSourceFields,
|
|
400
|
+
provenance: Schema5.optionalKey(Schema5.Union([
|
|
401
|
+
Schema5.Literal("explicit"),
|
|
402
|
+
Schema5.Literal("workspace_default"),
|
|
403
|
+
Schema5.Literal("workspace_mandatory")
|
|
404
|
+
])),
|
|
405
|
+
policyRevision: Schema5.optionalKey(Schema5.Int.check(Schema5.isGreaterThanOrEqualTo(1))),
|
|
406
|
+
label: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1)))
|
|
407
|
+
}),
|
|
408
|
+
Schema5.Struct({
|
|
409
|
+
kind: Schema5.Literal("marketplace_kit"),
|
|
410
|
+
kitSourceId: Id,
|
|
411
|
+
kitVersionId: Schema5.optionalKey(Id),
|
|
412
|
+
kitInstallationId: Schema5.optionalKey(Id),
|
|
413
|
+
kitActivationId: Schema5.optionalKey(Id),
|
|
414
|
+
label: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1)))
|
|
415
|
+
}),
|
|
416
|
+
Schema5.Struct({
|
|
417
|
+
kind: Schema5.Literal("step_attempt_override"),
|
|
418
|
+
stepAttemptId: Id,
|
|
419
|
+
label: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1)))
|
|
420
|
+
}),
|
|
421
|
+
Schema5.Struct({
|
|
422
|
+
kind: Schema5.Literal("command_override"),
|
|
423
|
+
label: Schema5.optionalKey(Schema5.String.check(Schema5.isMinLength(1)))
|
|
424
|
+
})
|
|
425
|
+
]);
|
|
426
|
+
var ResolvedAgentSkillRequirement = Schema5.Struct({
|
|
427
|
+
item: AgentSkillRequirement,
|
|
428
|
+
source: AgentEnvironmentSource
|
|
429
|
+
});
|
|
430
|
+
var ResolvedAgentPluginRequirement = Schema5.Struct({
|
|
431
|
+
item: AgentPluginRequirement,
|
|
432
|
+
source: AgentEnvironmentSource
|
|
433
|
+
});
|
|
434
|
+
var ResolvedAgentMcpServerRequirement = Schema5.Struct({
|
|
435
|
+
item: AgentMcpServerRequirement,
|
|
436
|
+
source: AgentEnvironmentSource
|
|
437
|
+
});
|
|
438
|
+
var ResolvedAgentHarnessSetting = Schema5.Struct({ item: AgentHarnessSetting, source: AgentEnvironmentSource });
|
|
439
|
+
var ResolvedProviderAuthRef = Schema5.Struct({ item: ProviderAuthRef, source: AgentEnvironmentSource });
|
|
440
|
+
var ResolvedRunnerSecretRef = Schema5.Struct({ item: RunnerSecretRef, source: AgentEnvironmentSource });
|
|
441
|
+
var ResolvedAgentPermissionRequirement = Schema5.Struct({
|
|
442
|
+
item: AgentPermissionRequirement,
|
|
443
|
+
source: AgentEnvironmentSource
|
|
444
|
+
});
|
|
445
|
+
var ResolvedAgentHookRequirement = Schema5.Struct({ item: AgentHookRequirement, source: AgentEnvironmentSource });
|
|
446
|
+
var ResolvedAgentRuntimeConstraint = Schema5.Struct({
|
|
447
|
+
item: AgentRuntimeConstraint,
|
|
448
|
+
source: AgentEnvironmentSource
|
|
449
|
+
});
|
|
450
|
+
var ResolvedAgentSandboxPolicyRequirement = Schema5.Struct({
|
|
451
|
+
item: AgentSandboxPolicyRequirement,
|
|
452
|
+
source: AgentEnvironmentSource
|
|
453
|
+
});
|
|
454
|
+
var AgentEnvironment = Schema5.Struct({
|
|
455
|
+
harness: AgentHarnessId,
|
|
456
|
+
skills: Schema5.Array(ResolvedAgentSkillRequirement),
|
|
457
|
+
plugins: Schema5.Array(ResolvedAgentPluginRequirement),
|
|
458
|
+
mcpServers: Schema5.Array(ResolvedAgentMcpServerRequirement),
|
|
459
|
+
harnessSettings: Schema5.Array(ResolvedAgentHarnessSetting),
|
|
460
|
+
providerAuthRefs: Schema5.Array(ResolvedProviderAuthRef),
|
|
461
|
+
runnerSecretRefs: Schema5.Array(ResolvedRunnerSecretRef),
|
|
462
|
+
permissions: Schema5.Array(ResolvedAgentPermissionRequirement),
|
|
463
|
+
hooks: Schema5.Array(ResolvedAgentHookRequirement),
|
|
464
|
+
runtimeConstraints: Schema5.Array(ResolvedAgentRuntimeConstraint),
|
|
465
|
+
sandboxPolicyRequirements: Schema5.Array(ResolvedAgentSandboxPolicyRequirement),
|
|
466
|
+
warnings: Schema5.Array(Schema5.String)
|
|
467
|
+
});
|
|
468
|
+
var KitMarketplaceAgentEnvironmentSyncStates = ["ready", "needs_sync", "blocked"];
|
|
469
|
+
var KitMarketplaceAgentEnvironmentEffectKinds = [
|
|
470
|
+
"skill",
|
|
471
|
+
"plugin",
|
|
472
|
+
"mcp_server",
|
|
473
|
+
"harness_setting",
|
|
474
|
+
"provider_auth_ref",
|
|
475
|
+
"runner_secret_ref",
|
|
476
|
+
"permission",
|
|
477
|
+
"hook",
|
|
478
|
+
"runtime_constraint",
|
|
479
|
+
"sandbox_policy_requirement"
|
|
480
|
+
];
|
|
481
|
+
var KitMarketplaceAgentEnvironmentMaterializerRequirements = [
|
|
482
|
+
"config_writer",
|
|
483
|
+
"provider_auth",
|
|
484
|
+
"runner_secret",
|
|
485
|
+
"bun",
|
|
486
|
+
"sandbox_policy"
|
|
487
|
+
];
|
|
488
|
+
var KitMarketplaceAgentEnvironmentEffect = Schema5.Struct({
|
|
489
|
+
kind: Schema5.Literals(KitMarketplaceAgentEnvironmentEffectKinds),
|
|
490
|
+
name: Schema5.String.check(Schema5.isMinLength(1)),
|
|
491
|
+
policy: AgentEnvironmentPolicy,
|
|
492
|
+
source: AgentEnvironmentSource,
|
|
493
|
+
materializerRequirements: Schema5.Array(Schema5.Literals(KitMarketplaceAgentEnvironmentMaterializerRequirements))
|
|
494
|
+
});
|
|
495
|
+
var KitMarketplaceAgentEnvironmentSyncPreview = Schema5.Struct({
|
|
496
|
+
state: Schema5.Literals(KitMarketplaceAgentEnvironmentSyncStates),
|
|
497
|
+
agentEnvironment: AgentEnvironment,
|
|
498
|
+
effects: Schema5.Array(KitMarketplaceAgentEnvironmentEffect),
|
|
499
|
+
blockers: Schema5.Array(Schema5.String),
|
|
500
|
+
drift: Schema5.Array(Schema5.String)
|
|
501
|
+
});
|
|
502
|
+
var AgentEnvironmentSyncPlanStatuses = ["ready", "needs_apply", "blocked"];
|
|
503
|
+
var AgentEnvironmentSyncPlanItemKinds = [
|
|
504
|
+
"skill",
|
|
505
|
+
"plugin",
|
|
506
|
+
"mcp_server",
|
|
507
|
+
"harness_setting",
|
|
508
|
+
"provider_auth_ref",
|
|
509
|
+
"runner_secret_ref",
|
|
510
|
+
"permission",
|
|
511
|
+
"hook",
|
|
512
|
+
"runtime_constraint",
|
|
513
|
+
"sandbox_policy_requirement"
|
|
514
|
+
];
|
|
515
|
+
var AgentEnvironmentSyncPlanApplyModes = ["automatic", "manual", "verify_only"];
|
|
516
|
+
var AgentEnvironmentSyncPlanItem = Schema5.Struct({
|
|
517
|
+
kind: Schema5.Literals(AgentEnvironmentSyncPlanItemKinds),
|
|
518
|
+
name: Schema5.String.check(Schema5.isMinLength(1)),
|
|
519
|
+
policy: AgentEnvironmentPolicy,
|
|
520
|
+
source: AgentEnvironmentSource,
|
|
521
|
+
materializerRequirements: Schema5.Array(Schema5.Literals(KitMarketplaceAgentEnvironmentMaterializerRequirements)),
|
|
522
|
+
applyMode: Schema5.Literals(AgentEnvironmentSyncPlanApplyModes)
|
|
523
|
+
});
|
|
524
|
+
var AgentEnvironmentSyncPlan = Schema5.Struct({
|
|
525
|
+
status: Schema5.Literals(AgentEnvironmentSyncPlanStatuses),
|
|
526
|
+
targetHarness: AgentHarnessId,
|
|
527
|
+
agentEnvironment: AgentEnvironment,
|
|
528
|
+
items: Schema5.Array(AgentEnvironmentSyncPlanItem),
|
|
529
|
+
blockers: Schema5.Array(Schema5.String),
|
|
530
|
+
drift: Schema5.Array(Schema5.String)
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
// packages/core/src/kit.ts
|
|
534
|
+
import * as Schema6 from "effect/Schema";
|
|
535
|
+
import * as Struct6 from "effect/Struct";
|
|
536
|
+
var KitKinds = ["technology", "brand", "domain", "process", "other"];
|
|
537
|
+
var ProjectKitProvenanceKinds = ["explicit", "workspace_default", "workspace_mandatory"];
|
|
538
|
+
var KitKind = Schema6.Union([
|
|
539
|
+
Schema6.Literal("technology"),
|
|
540
|
+
Schema6.Literal("brand"),
|
|
541
|
+
Schema6.Literal("domain"),
|
|
542
|
+
Schema6.Literal("process"),
|
|
543
|
+
Schema6.Literal("other")
|
|
544
|
+
]);
|
|
545
|
+
var Kit = Schema6.Struct({
|
|
546
|
+
id: Id,
|
|
547
|
+
workspaceId: Id,
|
|
548
|
+
name: Schema6.String,
|
|
549
|
+
slug: Slug,
|
|
550
|
+
kind: KitKind,
|
|
551
|
+
description: Schema6.optionalKey(Schema6.String),
|
|
552
|
+
contentMarkdown: Schema6.String,
|
|
553
|
+
metadata: Schema6.Record(Schema6.String, Schema6.Unknown),
|
|
554
|
+
projectAttachment: Schema6.optionalKey(Schema6.Struct({
|
|
555
|
+
provenance: Schema6.Literals(ProjectKitProvenanceKinds),
|
|
556
|
+
workspaceKitAssignmentId: Schema6.optionalKey(Id),
|
|
557
|
+
policyRevision: Schema6.optionalKey(Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(1))),
|
|
558
|
+
package: Schema6.optionalKey(Schema6.String)
|
|
559
|
+
})),
|
|
560
|
+
package: Schema6.optionalKey(Schema6.String),
|
|
561
|
+
agentEnvironment: Schema6.optionalKey(AgentEnvironmentFragment),
|
|
562
|
+
agentInstructions: Schema6.optionalKey(Schema6.String),
|
|
563
|
+
doNotDo: Schema6.optionalKey(Schema6.String),
|
|
564
|
+
createdAt: Timestamp,
|
|
565
|
+
updatedAt: Timestamp
|
|
566
|
+
});
|
|
567
|
+
var KitPublisherIdentity = Schema6.Struct({
|
|
568
|
+
name: Schema6.String.check(Schema6.isMinLength(1)),
|
|
569
|
+
type: Schema6.optionalKey(Schema6.Union([
|
|
570
|
+
Schema6.Literal("kitman"),
|
|
571
|
+
Schema6.Literal("workspace"),
|
|
572
|
+
Schema6.Literal("organization"),
|
|
573
|
+
Schema6.Literal("individual")
|
|
574
|
+
])),
|
|
575
|
+
url: Schema6.optionalKey(Schema6.String),
|
|
576
|
+
verified: Schema6.optionalKey(Schema6.Boolean)
|
|
577
|
+
});
|
|
578
|
+
var KitSourceType = Schema6.Union([
|
|
579
|
+
Schema6.Literal("hosted"),
|
|
580
|
+
Schema6.Literal("git"),
|
|
581
|
+
Schema6.Literal("package"),
|
|
582
|
+
Schema6.Literal("url"),
|
|
583
|
+
Schema6.Literal("skills_sh")
|
|
584
|
+
]);
|
|
585
|
+
var KitTrustStatus = Schema6.Union([
|
|
586
|
+
Schema6.Literal("unreviewed"),
|
|
587
|
+
Schema6.Literal("trusted"),
|
|
588
|
+
Schema6.Literal("reviewed"),
|
|
589
|
+
Schema6.Literal("rejected"),
|
|
590
|
+
Schema6.Literal("deprecated")
|
|
591
|
+
]);
|
|
592
|
+
var KitReviewStatus = Schema6.Union([
|
|
593
|
+
Schema6.Literal("pending"),
|
|
594
|
+
Schema6.Literal("approved"),
|
|
595
|
+
Schema6.Literal("rejected"),
|
|
596
|
+
Schema6.Literal("deprecated")
|
|
597
|
+
]);
|
|
598
|
+
var KitSourceVisibility = Schema6.Union([
|
|
599
|
+
Schema6.Literal("public"),
|
|
600
|
+
Schema6.Literal("organization"),
|
|
601
|
+
Schema6.Literal("workspace")
|
|
602
|
+
]);
|
|
603
|
+
var SpdxLicenseExpression = Schema6.String.check(Schema6.isMinLength(1), Schema6.isMaxLength(240), Schema6.isPattern(new RegExp("^[A-Za-z0-9][A-Za-z0-9.+:()\\-\\s]*$", "u")));
|
|
604
|
+
var KitLifecycleStatus = Schema6.Union([
|
|
605
|
+
Schema6.Literal("active"),
|
|
606
|
+
Schema6.Literal("deprecated"),
|
|
607
|
+
Schema6.Literal("rejected")
|
|
608
|
+
]);
|
|
609
|
+
var KitMarketplaceInstallState = Schema6.Union([
|
|
610
|
+
Schema6.Literal("not_installed"),
|
|
611
|
+
Schema6.Literal("installed"),
|
|
612
|
+
Schema6.Literal("active"),
|
|
613
|
+
Schema6.Literal("update_available")
|
|
614
|
+
]);
|
|
615
|
+
var KitMarketplaceRuntimeState = Schema6.Union([
|
|
616
|
+
Schema6.Literal("ready"),
|
|
617
|
+
Schema6.Literal("needs_sync"),
|
|
618
|
+
Schema6.Literal("proposal_required"),
|
|
619
|
+
Schema6.Literal("deprecated"),
|
|
620
|
+
Schema6.Literal("blocked")
|
|
621
|
+
]);
|
|
622
|
+
var KitMarketplaceLifecycleOperation = Schema6.Union([
|
|
623
|
+
Schema6.Literal("install"),
|
|
624
|
+
Schema6.Literal("activate"),
|
|
625
|
+
Schema6.Literal("update"),
|
|
626
|
+
Schema6.Literal("rollback"),
|
|
627
|
+
Schema6.Literal("disable"),
|
|
628
|
+
Schema6.Literal("uninstall")
|
|
629
|
+
]);
|
|
630
|
+
var KitCompatibility = Schema6.Struct({
|
|
631
|
+
harnesses: Schema6.optionalKey(Schema6.Array(Schema6.String)),
|
|
632
|
+
capabilities: Schema6.optionalKey(Schema6.Array(Schema6.String)),
|
|
633
|
+
minimumKitmanVersion: Schema6.optionalKey(Schema6.String),
|
|
634
|
+
runtimeRequirements: Schema6.optionalKey(Schema6.Array(Schema6.String))
|
|
635
|
+
});
|
|
636
|
+
var Sha2562 = Schema6.String.check(Schema6.isPattern(new RegExp("^[a-fA-F0-9]{64}$", "u")));
|
|
637
|
+
var SourcePath2 = Schema6.String.check(Schema6.isMinLength(1), Schema6.isPattern(new RegExp("^(?!/)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.\\.?($|/))(?!.*\\s).+$", "u")));
|
|
638
|
+
var HostedKitSourceProvenance = Schema6.Struct({
|
|
639
|
+
sourceType: Schema6.Literal("hosted"),
|
|
640
|
+
path: Schema6.optionalKey(SourcePath2),
|
|
641
|
+
sha256: Schema6.optionalKey(Sha2562)
|
|
642
|
+
});
|
|
643
|
+
var GitKitSourceProvenance = Schema6.Struct({
|
|
644
|
+
sourceType: Schema6.Literal("git"),
|
|
645
|
+
repositoryUrl: Schema6.String.check(Schema6.isMinLength(1)),
|
|
646
|
+
ref: Schema6.String.check(Schema6.isMinLength(1)),
|
|
647
|
+
path: Schema6.optionalKey(SourcePath2),
|
|
648
|
+
sha256: Schema6.optionalKey(Sha2562)
|
|
649
|
+
});
|
|
650
|
+
var PackageKitSourceProvenance = Schema6.Struct({
|
|
651
|
+
sourceType: Schema6.Literal("package"),
|
|
652
|
+
packageName: Schema6.String.check(Schema6.isMinLength(1)),
|
|
653
|
+
version: Schema6.String.check(Schema6.isMinLength(1)),
|
|
654
|
+
path: Schema6.optionalKey(SourcePath2),
|
|
655
|
+
sha256: Schema6.optionalKey(Sha2562)
|
|
656
|
+
});
|
|
657
|
+
var UrlKitSourceProvenance = Schema6.Struct({
|
|
658
|
+
sourceType: Schema6.Literal("url"),
|
|
659
|
+
url: Schema6.String.check(Schema6.isMinLength(1)),
|
|
660
|
+
sha256: Sha2562
|
|
661
|
+
});
|
|
662
|
+
var SkillsShKitSourceProvenance = Schema6.Struct({
|
|
663
|
+
sourceType: Schema6.Literal("skills_sh"),
|
|
664
|
+
skillsSlug: Schema6.String.check(Schema6.isMinLength(1)),
|
|
665
|
+
version: Schema6.optionalKey(Schema6.String.check(Schema6.isMinLength(1))),
|
|
666
|
+
sha256: Schema6.optionalKey(Sha2562)
|
|
667
|
+
});
|
|
668
|
+
var KitSourceProvenance = Schema6.Union([
|
|
669
|
+
HostedKitSourceProvenance,
|
|
670
|
+
GitKitSourceProvenance,
|
|
671
|
+
PackageKitSourceProvenance,
|
|
672
|
+
UrlKitSourceProvenance,
|
|
673
|
+
SkillsShKitSourceProvenance
|
|
674
|
+
]);
|
|
675
|
+
var KitSourceBase = Schema6.Struct({
|
|
676
|
+
id: Id,
|
|
677
|
+
workspaceId: Schema6.optionalKey(Id),
|
|
678
|
+
name: Schema6.String,
|
|
679
|
+
slug: Slug,
|
|
680
|
+
summary: Schema6.String,
|
|
681
|
+
publisher: KitPublisherIdentity,
|
|
682
|
+
visibility: KitSourceVisibility,
|
|
683
|
+
licenseExpression: Schema6.optionalKey(SpdxLicenseExpression),
|
|
684
|
+
tags: Schema6.Array(Schema6.String),
|
|
685
|
+
compatibleHarnesses: Schema6.Array(Schema6.String),
|
|
686
|
+
capabilitySummaries: Schema6.Array(Schema6.String),
|
|
687
|
+
trustStatus: KitTrustStatus,
|
|
688
|
+
reviewStatus: KitReviewStatus,
|
|
689
|
+
lifecycleStatus: KitLifecycleStatus,
|
|
690
|
+
installable: Schema6.Boolean,
|
|
691
|
+
createdAt: Timestamp,
|
|
692
|
+
updatedAt: Timestamp
|
|
693
|
+
});
|
|
694
|
+
var KitSource = Schema6.Union([
|
|
695
|
+
Schema6.Struct({
|
|
696
|
+
...KitSourceBase.fields,
|
|
697
|
+
...Schema6.Struct({ sourceType: Schema6.Literal("hosted"), provenance: HostedKitSourceProvenance }).fields
|
|
698
|
+
}),
|
|
699
|
+
Schema6.Struct({
|
|
700
|
+
...KitSourceBase.fields,
|
|
701
|
+
...Schema6.Struct({ sourceType: Schema6.Literal("git"), provenance: GitKitSourceProvenance }).fields
|
|
702
|
+
}),
|
|
703
|
+
Schema6.Struct({
|
|
704
|
+
...KitSourceBase.fields,
|
|
705
|
+
...Schema6.Struct({ sourceType: Schema6.Literal("package"), provenance: PackageKitSourceProvenance }).fields
|
|
706
|
+
}),
|
|
707
|
+
Schema6.Struct({
|
|
708
|
+
...KitSourceBase.fields,
|
|
709
|
+
...Schema6.Struct({ sourceType: Schema6.Literal("url"), provenance: UrlKitSourceProvenance }).fields
|
|
710
|
+
}),
|
|
711
|
+
Schema6.Struct({
|
|
712
|
+
...KitSourceBase.fields,
|
|
713
|
+
...Schema6.Struct({ sourceType: Schema6.Literal("skills_sh"), provenance: SkillsShKitSourceProvenance }).fields
|
|
714
|
+
})
|
|
715
|
+
]);
|
|
716
|
+
var KitVersion = Schema6.Struct({
|
|
717
|
+
id: Id,
|
|
718
|
+
kitSourceId: Id,
|
|
719
|
+
version: Schema6.String,
|
|
720
|
+
provenance: KitSourceProvenance,
|
|
721
|
+
contentKitId: Schema6.optionalKey(Id),
|
|
722
|
+
compatibility: KitCompatibility,
|
|
723
|
+
trustStatus: KitTrustStatus,
|
|
724
|
+
reviewStatus: KitReviewStatus,
|
|
725
|
+
lifecycleStatus: KitLifecycleStatus,
|
|
726
|
+
reviewMetadata: Schema6.Record(Schema6.String, Schema6.Unknown),
|
|
727
|
+
publishedAt: Schema6.optionalKey(Timestamp),
|
|
728
|
+
createdAt: Timestamp,
|
|
729
|
+
updatedAt: Timestamp
|
|
730
|
+
});
|
|
731
|
+
var KitInstallationScope = Schema6.Union([
|
|
732
|
+
Schema6.Literal("user"),
|
|
733
|
+
Schema6.Literal("workspace"),
|
|
734
|
+
Schema6.Literal("team"),
|
|
735
|
+
Schema6.Literal("project")
|
|
736
|
+
]);
|
|
737
|
+
var KitInstallationBase = Schema6.Struct({
|
|
738
|
+
id: Id,
|
|
739
|
+
kitSourceId: Id,
|
|
740
|
+
scopeType: KitInstallationScope,
|
|
741
|
+
scopeId: Id,
|
|
742
|
+
trustStatus: KitTrustStatus,
|
|
743
|
+
reviewStatus: KitReviewStatus,
|
|
744
|
+
lifecycleStatus: KitLifecycleStatus,
|
|
745
|
+
installedByActorType: Schema6.optionalKey(Schema6.String),
|
|
746
|
+
installedByActorId: Schema6.optionalKey(Id),
|
|
747
|
+
enabled: Schema6.Boolean,
|
|
748
|
+
package: Schema6.optionalKey(Schema6.String),
|
|
749
|
+
createdAt: Timestamp,
|
|
750
|
+
updatedAt: Timestamp
|
|
751
|
+
});
|
|
752
|
+
var KitInstallation = Schema6.Union([
|
|
753
|
+
Schema6.Struct({
|
|
754
|
+
...KitInstallationBase.fields,
|
|
755
|
+
...Schema6.Struct({ pinned: Schema6.Literal(true), kitVersionId: Id }).fields
|
|
756
|
+
}),
|
|
757
|
+
Schema6.Struct({
|
|
758
|
+
...KitInstallationBase.fields,
|
|
759
|
+
...Schema6.Struct({ pinned: Schema6.Literal(false), kitVersionId: Schema6.optionalKey(Id) }).fields
|
|
760
|
+
})
|
|
761
|
+
]);
|
|
762
|
+
var KitRegistrySearchItem = Schema6.Struct({
|
|
763
|
+
id: Id,
|
|
764
|
+
name: Schema6.String,
|
|
765
|
+
slug: Slug,
|
|
766
|
+
summary: Schema6.String,
|
|
767
|
+
publisher: KitPublisherIdentity,
|
|
768
|
+
visibility: KitSourceVisibility,
|
|
769
|
+
licenseExpression: Schema6.optionalKey(SpdxLicenseExpression),
|
|
770
|
+
sourceType: KitSourceType,
|
|
771
|
+
versions: Schema6.Array(Schema6.String),
|
|
772
|
+
tags: Schema6.Array(Schema6.String),
|
|
773
|
+
compatibleHarnesses: Schema6.Array(Schema6.String),
|
|
774
|
+
capabilitySummaries: Schema6.Array(Schema6.String),
|
|
775
|
+
trustStatus: KitTrustStatus,
|
|
776
|
+
reviewStatus: KitReviewStatus,
|
|
777
|
+
lifecycleStatus: KitLifecycleStatus,
|
|
778
|
+
installable: Schema6.Boolean
|
|
779
|
+
});
|
|
780
|
+
var KitActivation = Schema6.Struct({
|
|
781
|
+
id: Id,
|
|
782
|
+
kitInstallationId: Id,
|
|
783
|
+
kitSourceId: Id,
|
|
784
|
+
kitVersionId: Schema6.optionalKey(Id),
|
|
785
|
+
scopeType: KitInstallationScope,
|
|
786
|
+
scopeId: Id,
|
|
787
|
+
activationType: Schema6.Union([
|
|
788
|
+
Schema6.Literal("workspace_default"),
|
|
789
|
+
Schema6.Literal("team_default"),
|
|
790
|
+
Schema6.Literal("project_attachment"),
|
|
791
|
+
Schema6.Literal("personal_default"),
|
|
792
|
+
Schema6.Literal("harness")
|
|
793
|
+
]),
|
|
794
|
+
active: Schema6.Boolean,
|
|
795
|
+
activeThrough: Schema6.optionalKey(Schema6.String),
|
|
796
|
+
metadata: Schema6.Record(Schema6.String, Schema6.Unknown),
|
|
797
|
+
createdAt: Timestamp,
|
|
798
|
+
updatedAt: Timestamp
|
|
799
|
+
});
|
|
800
|
+
var KitRegistrySearch = Schema6.Struct({
|
|
801
|
+
items: Schema6.Array(KitRegistrySearchItem)
|
|
802
|
+
});
|
|
803
|
+
var KitMarketplaceCatalogItem = Schema6.Struct({
|
|
804
|
+
id: Id,
|
|
805
|
+
name: Schema6.String,
|
|
806
|
+
slug: Slug,
|
|
807
|
+
summary: Schema6.String,
|
|
808
|
+
publisher: KitPublisherIdentity,
|
|
809
|
+
visibility: KitSourceVisibility,
|
|
810
|
+
licenseExpression: Schema6.optionalKey(SpdxLicenseExpression),
|
|
811
|
+
sourceType: KitSourceType,
|
|
812
|
+
trustStatus: KitTrustStatus,
|
|
813
|
+
reviewStatus: KitReviewStatus,
|
|
814
|
+
lifecycleStatus: KitLifecycleStatus,
|
|
815
|
+
installable: Schema6.Boolean,
|
|
816
|
+
latestVersion: Schema6.optionalKey(Schema6.String),
|
|
817
|
+
installedVersion: Schema6.optionalKey(Schema6.String),
|
|
818
|
+
installState: KitMarketplaceInstallState,
|
|
819
|
+
runtimeState: KitMarketplaceRuntimeState,
|
|
820
|
+
activeThrough: Schema6.optionalKey(Schema6.String),
|
|
821
|
+
compatibleHarnesses: Schema6.Array(Schema6.String),
|
|
822
|
+
capabilitySummaries: Schema6.Array(Schema6.String),
|
|
823
|
+
tags: Schema6.Array(Schema6.String),
|
|
824
|
+
installedByPackage: Schema6.optionalKey(Schema6.String)
|
|
825
|
+
});
|
|
826
|
+
var KitMarketplacePageInfo = Schema6.Struct({
|
|
827
|
+
hasNextPage: Schema6.Boolean,
|
|
828
|
+
endCursor: Schema6.optionalKey(Schema6.String.check(Schema6.isMinLength(1)))
|
|
829
|
+
});
|
|
830
|
+
var KitMarketplaceCatalog = Schema6.Struct({
|
|
831
|
+
items: Schema6.Array(KitMarketplaceCatalogItem).check(Schema6.isMaxLength(100)),
|
|
832
|
+
total: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(0)),
|
|
833
|
+
pageInfo: KitMarketplacePageInfo
|
|
834
|
+
});
|
|
835
|
+
var KitMarketplaceDetail = Schema6.Struct({
|
|
836
|
+
...KitMarketplaceCatalogItem.fields,
|
|
837
|
+
...Schema6.Struct({
|
|
838
|
+
provenance: KitSourceProvenance,
|
|
839
|
+
versions: Schema6.Array(KitVersion),
|
|
840
|
+
installations: Schema6.Array(KitInstallation),
|
|
841
|
+
activations: Schema6.Array(KitActivation)
|
|
842
|
+
}).fields
|
|
843
|
+
});
|
|
844
|
+
var KitMarketplaceCatalogValidator = guard(KitMarketplaceCatalog);
|
|
845
|
+
var KitMarketplaceDetailValidator = guard(KitMarketplaceDetail);
|
|
846
|
+
var KitMarketplacePreviewInput = Schema6.Struct({
|
|
847
|
+
operation: KitMarketplaceLifecycleOperation,
|
|
848
|
+
source: Schema6.String.check(Schema6.isMinLength(1)),
|
|
849
|
+
version: Schema6.optionalKey(Schema6.String.check(Schema6.isMinLength(1))),
|
|
850
|
+
scopeType: Schema6.optionalKey(KitInstallationScope),
|
|
851
|
+
scopeId: Schema6.optionalKey(Id),
|
|
852
|
+
activationType: Schema6.optionalKey(Schema6.Union([
|
|
853
|
+
Schema6.Literal("workspace_default"),
|
|
854
|
+
Schema6.Literal("team_default"),
|
|
855
|
+
Schema6.Literal("project_attachment"),
|
|
856
|
+
Schema6.Literal("personal_default"),
|
|
857
|
+
Schema6.Literal("harness")
|
|
858
|
+
]))
|
|
859
|
+
});
|
|
860
|
+
var KitMarketplaceSyncReadiness = Schema6.Struct({
|
|
861
|
+
state: Schema6.Union([Schema6.Literal("ready"), Schema6.Literal("needs_sync"), Schema6.Literal("blocked")]),
|
|
862
|
+
blockers: Schema6.Array(Schema6.String)
|
|
863
|
+
});
|
|
864
|
+
var KitMarketplacePreview = Schema6.Struct({
|
|
865
|
+
previewToken: Schema6.String.check(Schema6.isMinLength(1)),
|
|
866
|
+
operation: KitMarketplaceLifecycleOperation,
|
|
867
|
+
sourceId: Id,
|
|
868
|
+
sourceSlug: Slug,
|
|
869
|
+
scopeType: KitInstallationScope,
|
|
870
|
+
scopeId: Id,
|
|
871
|
+
fromVersion: Schema6.optionalKey(Schema6.String),
|
|
872
|
+
toVersion: Schema6.optionalKey(Schema6.String),
|
|
873
|
+
installState: KitMarketplaceInstallState,
|
|
874
|
+
runtimeState: KitMarketplaceRuntimeState,
|
|
875
|
+
contextImpact: Schema6.Array(Schema6.String),
|
|
876
|
+
agentEnvironmentEffects: Schema6.Array(Schema6.String),
|
|
877
|
+
activeThrough: Schema6.optionalKey(Schema6.String),
|
|
878
|
+
conflicts: Schema6.Array(Schema6.String),
|
|
879
|
+
warnings: Schema6.Array(Schema6.String),
|
|
880
|
+
syncReadiness: KitMarketplaceSyncReadiness,
|
|
881
|
+
requiresProposal: Schema6.Boolean
|
|
882
|
+
});
|
|
883
|
+
var KitMarketplaceApplyPreviewInput = Schema6.Struct({
|
|
884
|
+
...KitMarketplacePreviewInput.fields,
|
|
885
|
+
...Schema6.Struct({ previewToken: Schema6.String.check(Schema6.isMinLength(1)) }).fields
|
|
886
|
+
});
|
|
887
|
+
var KitMarketplaceLifecycleResult = Schema6.Struct({
|
|
888
|
+
status: Schema6.Union([
|
|
889
|
+
Schema6.Literal("installed"),
|
|
890
|
+
Schema6.Literal("activated"),
|
|
891
|
+
Schema6.Literal("updated"),
|
|
892
|
+
Schema6.Literal("rolled_back"),
|
|
893
|
+
Schema6.Literal("disabled"),
|
|
894
|
+
Schema6.Literal("uninstalled")
|
|
895
|
+
]),
|
|
896
|
+
previewToken: Schema6.String.check(Schema6.isMinLength(1)),
|
|
897
|
+
installation: Schema6.optionalKey(KitInstallation),
|
|
898
|
+
activation: Schema6.optionalKey(KitActivation),
|
|
899
|
+
syncReadiness: KitMarketplaceSyncReadiness
|
|
900
|
+
});
|
|
901
|
+
var KitCreate = Schema6.Struct({
|
|
902
|
+
name: Schema6.String.check(Schema6.isMinLength(1), Schema6.isMaxLength(160)),
|
|
903
|
+
slug: Schema6.optionalKey(Slug),
|
|
904
|
+
kind: Schema6.optionalKey(KitKind),
|
|
905
|
+
description: Schema6.optionalKey(Schema6.String),
|
|
906
|
+
contentMarkdown: Schema6.String.check(Schema6.isMinLength(1)),
|
|
907
|
+
metadata: Schema6.optionalKey(Schema6.Record(Schema6.String, Schema6.Unknown)),
|
|
908
|
+
agentEnvironment: Schema6.optionalKey(AgentEnvironmentFragment),
|
|
909
|
+
agentInstructions: Schema6.optionalKey(Schema6.String),
|
|
910
|
+
doNotDo: Schema6.optionalKey(Schema6.String)
|
|
911
|
+
});
|
|
912
|
+
var KitUpdate = Schema6.Struct(Struct6.map(KitCreate.fields, Schema6.optionalKey));
|
|
913
|
+
var KitDeleteResult = Schema6.Struct({ deleted: Schema6.Boolean });
|
|
914
|
+
var KitList = Schema6.Struct({
|
|
915
|
+
items: Schema6.Array(Kit),
|
|
916
|
+
policyOptOuts: Schema6.optionalKey(Schema6.Array(Schema6.Struct({
|
|
917
|
+
workspaceKitAssignmentId: Id,
|
|
918
|
+
kitId: Id,
|
|
919
|
+
policyRevision: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(1))
|
|
920
|
+
})))
|
|
921
|
+
});
|
|
922
|
+
var ProjectKitAttachResult = Schema6.Struct({
|
|
923
|
+
status: Schema6.Union([Schema6.Literal("attached"), Schema6.Literal("already_attached")]),
|
|
924
|
+
projectId: Id,
|
|
925
|
+
kitId: Id
|
|
926
|
+
});
|
|
927
|
+
var ProjectKitDetachResult = Schema6.Struct({
|
|
928
|
+
status: Schema6.Union([Schema6.Literal("detached"), Schema6.Literal("not_attached")]),
|
|
929
|
+
projectId: Id,
|
|
930
|
+
kitId: Id
|
|
931
|
+
});
|
|
932
|
+
var WorkspacePolicyKitMode = Schema6.Union([Schema6.Literal("default"), Schema6.Literal("mandatory")]);
|
|
933
|
+
var ProjectKitProvenanceKind = Schema6.Union([
|
|
934
|
+
Schema6.Literal("explicit"),
|
|
935
|
+
Schema6.Literal("workspace_default"),
|
|
936
|
+
Schema6.Literal("workspace_mandatory")
|
|
937
|
+
]);
|
|
938
|
+
var WorkspacePolicyKitAssignment = Schema6.Struct({
|
|
939
|
+
id: Id,
|
|
940
|
+
workspaceId: Id,
|
|
941
|
+
kitId: Id,
|
|
942
|
+
mode: WorkspacePolicyKitMode,
|
|
943
|
+
revision: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(1)),
|
|
944
|
+
createdByActorType: Schema6.optionalKey(ActorType),
|
|
945
|
+
createdByActorId: Schema6.optionalKey(Id),
|
|
946
|
+
package: Schema6.optionalKey(Schema6.String),
|
|
947
|
+
createdAt: Timestamp,
|
|
948
|
+
updatedAt: Timestamp
|
|
949
|
+
});
|
|
950
|
+
var WorkspacePolicyKitAssignmentList = Schema6.Struct({
|
|
951
|
+
items: Schema6.Array(WorkspacePolicyKitAssignment)
|
|
952
|
+
});
|
|
953
|
+
var WorkspacePolicyKitCandidate = Schema6.Struct({
|
|
954
|
+
kitId: Id,
|
|
955
|
+
name: Schema6.String,
|
|
956
|
+
kind: KitKind,
|
|
957
|
+
trustStatus: KitTrustStatus,
|
|
958
|
+
installationState: Schema6.Literal("active")
|
|
959
|
+
});
|
|
960
|
+
var WorkspacePolicyKitCandidateList = Schema6.Struct({ items: Schema6.Array(WorkspacePolicyKitCandidate) });
|
|
961
|
+
var WorkspacePolicyKitAssignmentCreate = Schema6.Struct({
|
|
962
|
+
kitId: Id,
|
|
963
|
+
mode: WorkspacePolicyKitMode
|
|
964
|
+
});
|
|
965
|
+
var WorkspacePolicyKitAssignmentUpdate = Schema6.Struct({
|
|
966
|
+
mode: WorkspacePolicyKitMode,
|
|
967
|
+
expectedRevision: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(1))
|
|
968
|
+
});
|
|
969
|
+
var WorkspacePolicyKitAssignmentDelete = Schema6.Struct({
|
|
970
|
+
expectedRevision: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(1))
|
|
971
|
+
});
|
|
972
|
+
var WorkspacePolicyKitAssignmentDeleteResult = Schema6.Struct({
|
|
973
|
+
deleted: Schema6.Boolean,
|
|
974
|
+
assignmentId: Id
|
|
975
|
+
});
|
|
976
|
+
var ProjectKitPolicyOverride = Schema6.Struct({
|
|
977
|
+
id: Id,
|
|
978
|
+
workspaceId: Id,
|
|
979
|
+
projectId: Id,
|
|
980
|
+
workspaceKitAssignmentId: Id,
|
|
981
|
+
kind: Schema6.Literal("opt_out"),
|
|
982
|
+
reason: Schema6.optionalKey(Schema6.String),
|
|
983
|
+
createdByActorType: ActorType,
|
|
984
|
+
createdByActorId: Id,
|
|
985
|
+
createdAt: Timestamp
|
|
986
|
+
});
|
|
987
|
+
var ProjectKitPolicyOverrideCreate = Schema6.Struct({
|
|
988
|
+
expectedRevision: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(1)),
|
|
989
|
+
reason: Schema6.optionalKey(Schema6.String.check(Schema6.isMinLength(1), Schema6.isMaxLength(1000)))
|
|
990
|
+
});
|
|
991
|
+
var ProjectKitPolicyOverrideDelete = Schema6.Struct({
|
|
992
|
+
expectedRevision: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(1))
|
|
993
|
+
});
|
|
994
|
+
var ProjectKitPolicyOverrideDeleteResult = Schema6.Struct({
|
|
995
|
+
deleted: Schema6.Boolean,
|
|
996
|
+
projectId: Id,
|
|
997
|
+
workspaceKitAssignmentId: Id
|
|
998
|
+
});
|
|
999
|
+
var ProjectPolicyKitConvergenceResult = Schema6.Struct({
|
|
1000
|
+
projectId: Id,
|
|
1001
|
+
state: Schema6.Union([Schema6.Literal("current"), Schema6.Literal("degraded")]),
|
|
1002
|
+
highestPolicyRevision: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(0)),
|
|
1003
|
+
scanned: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(0), Schema6.isLessThanOrEqualTo(100)),
|
|
1004
|
+
applied: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(0), Schema6.isLessThanOrEqualTo(100)),
|
|
1005
|
+
replayed: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(0), Schema6.isLessThanOrEqualTo(100)),
|
|
1006
|
+
explicitAttachmentsPreserved: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(0), Schema6.isLessThanOrEqualTo(100)),
|
|
1007
|
+
hasMore: Schema6.Boolean,
|
|
1008
|
+
retry: Schema6.Boolean,
|
|
1009
|
+
repairAvailable: Schema6.Boolean,
|
|
1010
|
+
nextCursor: Schema6.optionalKey(Id)
|
|
1011
|
+
});
|
|
1012
|
+
var ProjectPolicyKitConvergenceInput = Schema6.Struct({ cursor: Schema6.optionalKey(Id) });
|
|
1013
|
+
var WorkspacePolicyKitBackfillPreviewKinds = [
|
|
1014
|
+
"affected",
|
|
1015
|
+
"unchanged",
|
|
1016
|
+
"opted_out",
|
|
1017
|
+
"inaccessible",
|
|
1018
|
+
"conflict"
|
|
1019
|
+
];
|
|
1020
|
+
var WorkspacePolicyKitBackfillApplyStatuses = [
|
|
1021
|
+
"pending",
|
|
1022
|
+
"applied",
|
|
1023
|
+
"skipped",
|
|
1024
|
+
"conflict",
|
|
1025
|
+
"retryable_failure",
|
|
1026
|
+
"cancelled"
|
|
1027
|
+
];
|
|
1028
|
+
var WorkspacePolicyKitBackfillStates = ["previewed", "running", "partial", "completed", "cancelled"];
|
|
1029
|
+
var WorkspacePolicyKitBackfillPreviewKind = Schema6.Literals(WorkspacePolicyKitBackfillPreviewKinds);
|
|
1030
|
+
var WorkspacePolicyKitBackfillApplyStatus = Schema6.Literals(WorkspacePolicyKitBackfillApplyStatuses);
|
|
1031
|
+
var WorkspacePolicyKitBackfillState = Schema6.Literals(WorkspacePolicyKitBackfillStates);
|
|
1032
|
+
var WorkspacePolicyKitBackfillCounts = Schema6.Struct({
|
|
1033
|
+
affected: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(0)),
|
|
1034
|
+
unchanged: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(0)),
|
|
1035
|
+
optedOut: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(0)),
|
|
1036
|
+
inaccessible: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(0)),
|
|
1037
|
+
conflict: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(0)),
|
|
1038
|
+
pending: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(0)),
|
|
1039
|
+
applied: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(0)),
|
|
1040
|
+
skipped: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(0)),
|
|
1041
|
+
retryableFailure: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(0)),
|
|
1042
|
+
cancelled: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(0))
|
|
1043
|
+
});
|
|
1044
|
+
var WorkspacePolicyKitBackfillItem = Schema6.Struct({
|
|
1045
|
+
projectId: Id,
|
|
1046
|
+
projectName: Schema6.String,
|
|
1047
|
+
previewKind: WorkspacePolicyKitBackfillPreviewKind,
|
|
1048
|
+
applyStatus: WorkspacePolicyKitBackfillApplyStatus,
|
|
1049
|
+
attempts: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(0)),
|
|
1050
|
+
errorCode: Schema6.optionalKey(Schema6.String),
|
|
1051
|
+
errorMessage: Schema6.optionalKey(Schema6.String)
|
|
1052
|
+
});
|
|
1053
|
+
var WorkspacePolicyKitBackfillPage = Schema6.Struct({
|
|
1054
|
+
backfillId: Id,
|
|
1055
|
+
workspaceId: Id,
|
|
1056
|
+
policyRevision: Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(0)),
|
|
1057
|
+
previewToken: Schema6.String.check(Schema6.isMinLength(1)),
|
|
1058
|
+
state: WorkspacePolicyKitBackfillState,
|
|
1059
|
+
counts: WorkspacePolicyKitBackfillCounts,
|
|
1060
|
+
items: Schema6.Array(WorkspacePolicyKitBackfillItem).check(Schema6.isMaxLength(100)),
|
|
1061
|
+
hasMore: Schema6.Boolean,
|
|
1062
|
+
nextCursor: Schema6.optionalKey(Id),
|
|
1063
|
+
createdAt: Timestamp,
|
|
1064
|
+
updatedAt: Timestamp
|
|
1065
|
+
});
|
|
1066
|
+
var WorkspacePolicyKitBackfillPreviewInput = Schema6.Struct({
|
|
1067
|
+
limit: Schema6.optionalKey(Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(1), Schema6.isLessThanOrEqualTo(100))),
|
|
1068
|
+
cursor: Schema6.optionalKey(Id)
|
|
1069
|
+
});
|
|
1070
|
+
var WorkspacePolicyKitBackfillApplyInput = Schema6.Struct({
|
|
1071
|
+
previewToken: Schema6.String.check(Schema6.isMinLength(1)),
|
|
1072
|
+
limit: Schema6.optionalKey(Schema6.Int.check(Schema6.isGreaterThanOrEqualTo(1), Schema6.isLessThanOrEqualTo(100))),
|
|
1073
|
+
cursor: Schema6.optionalKey(Id)
|
|
1074
|
+
});
|
|
1075
|
+
var WorkspacePolicyKitBackfillStatusQuery = Schema6.Struct({
|
|
1076
|
+
limit: Schema6.optionalKey(Numeric.check(isWholeNumber, Schema6.isGreaterThanOrEqualTo(1), Schema6.isLessThanOrEqualTo(100))),
|
|
1077
|
+
cursor: Schema6.optionalKey(Id)
|
|
1078
|
+
});
|
|
1079
|
+
var WorkspacePolicyKitBackfillCancelResult = Schema6.Struct({
|
|
1080
|
+
backfillId: Id,
|
|
1081
|
+
state: Schema6.Literal("cancelled")
|
|
1082
|
+
});
|
|
1083
|
+
|
|
1084
|
+
// packages/core/src/loop-layers.ts
|
|
1085
|
+
var LoopLayers = ["project", "workspace", "shipped"];
|
|
1086
|
+
var AgentEfforts = ["low", "medium", "high", "xhigh"];
|
|
1087
|
+
|
|
1088
|
+
// packages/core/src/schedule.ts
|
|
1089
|
+
import * as Schema13 from "effect/Schema";
|
|
1090
|
+
import * as DateTime from "effect/DateTime";
|
|
1091
|
+
import * as Option from "effect/Option";
|
|
1092
|
+
|
|
1093
|
+
// packages/core/src/loop.ts
|
|
1094
|
+
import * as Effect from "effect/Effect";
|
|
1095
|
+
import * as Schema12 from "effect/Schema";
|
|
1096
|
+
|
|
1097
|
+
// packages/core/src/context-pack.ts
|
|
1098
|
+
import * as Schema7 from "effect/Schema";
|
|
1099
|
+
var ContextPackIndexEntryKinds = [
|
|
1100
|
+
"task",
|
|
1101
|
+
"project",
|
|
1102
|
+
"kit",
|
|
1103
|
+
"memory",
|
|
1104
|
+
"decision",
|
|
1105
|
+
"session",
|
|
1106
|
+
"session_update",
|
|
1107
|
+
"proposal",
|
|
1108
|
+
"task_dependency",
|
|
1109
|
+
"repo_binding",
|
|
1110
|
+
"agent_environment",
|
|
1111
|
+
"loop_step"
|
|
1112
|
+
];
|
|
1113
|
+
var ContextPackRetrievalRefKinds = [
|
|
1114
|
+
"kit",
|
|
1115
|
+
"memory",
|
|
1116
|
+
"decision",
|
|
1117
|
+
"session",
|
|
1118
|
+
"session_update",
|
|
1119
|
+
"proposal",
|
|
1120
|
+
"task_dependency",
|
|
1121
|
+
"repo_binding",
|
|
1122
|
+
"agent_environment",
|
|
1123
|
+
"loop_step"
|
|
1124
|
+
];
|
|
1125
|
+
var ContextPackMode = Schema7.Union([
|
|
1126
|
+
Schema7.Literal("planning"),
|
|
1127
|
+
Schema7.Literal("implementation"),
|
|
1128
|
+
Schema7.Literal("debugging"),
|
|
1129
|
+
Schema7.Literal("review"),
|
|
1130
|
+
Schema7.Literal("handoff")
|
|
1131
|
+
]);
|
|
1132
|
+
var ContextPackIndexEntryKind = Schema7.Literals(ContextPackIndexEntryKinds);
|
|
1133
|
+
var ContextPackRetrievalRefKind = Schema7.Literals(ContextPackRetrievalRefKinds);
|
|
1134
|
+
var ContextPackLaunchBrief = Schema7.Struct({
|
|
1135
|
+
mode: ContextPackMode,
|
|
1136
|
+
taskTitle: Schema7.String.check(Schema7.isMinLength(1)),
|
|
1137
|
+
projectName: Schema7.optionalKey(Schema7.String.check(Schema7.isMinLength(1))),
|
|
1138
|
+
summary: Schema7.String.check(Schema7.isMinLength(1))
|
|
1139
|
+
});
|
|
1140
|
+
var ContextPackIndexEntry = Schema7.Struct({
|
|
1141
|
+
kind: ContextPackIndexEntryKind,
|
|
1142
|
+
id: Id,
|
|
1143
|
+
title: Schema7.String.check(Schema7.isMinLength(1)),
|
|
1144
|
+
reason: Schema7.String.check(Schema7.isMinLength(1))
|
|
1145
|
+
});
|
|
1146
|
+
var ContextPackRetrievalRef = Schema7.Struct({
|
|
1147
|
+
kind: ContextPackRetrievalRefKind,
|
|
1148
|
+
id: Id,
|
|
1149
|
+
label: Schema7.String.check(Schema7.isMinLength(1))
|
|
1150
|
+
});
|
|
1151
|
+
var ContextPackReadinessEvidence = Schema7.Struct({
|
|
1152
|
+
scopeAvailable: Schema7.Boolean,
|
|
1153
|
+
acceptanceCriteriaAvailable: Schema7.Boolean,
|
|
1154
|
+
dependenciesSatisfied: Schema7.Boolean,
|
|
1155
|
+
executionPlanAvailable: Schema7.Boolean,
|
|
1156
|
+
repoBindingAvailable: Schema7.Boolean,
|
|
1157
|
+
verificationCommands: Schema7.Array(Schema7.String.check(Schema7.isMinLength(1), Schema7.isMaxLength(500))).check(Schema7.isMaxLength(50)),
|
|
1158
|
+
deliveryTargetAvailable: Schema7.Boolean
|
|
1159
|
+
});
|
|
1160
|
+
var ContextPackRelevanceSummary = Schema7.Struct({
|
|
1161
|
+
included: Schema7.Array(Schema7.String.check(Schema7.isMinLength(1))),
|
|
1162
|
+
omitted: Schema7.Array(Schema7.String.check(Schema7.isMinLength(1))),
|
|
1163
|
+
notes: Schema7.Array(Schema7.String.check(Schema7.isMinLength(1))),
|
|
1164
|
+
readiness: Schema7.optionalKey(ContextPackReadinessEvidence)
|
|
1165
|
+
});
|
|
1166
|
+
var ContextPackBudget = Schema7.Struct({
|
|
1167
|
+
maxMarkdownChars: Schema7.Int.check(Schema7.isGreaterThanOrEqualTo(1)),
|
|
1168
|
+
markdownChars: Schema7.Int.check(Schema7.isGreaterThanOrEqualTo(0)),
|
|
1169
|
+
indexedItemCount: Schema7.Int.check(Schema7.isGreaterThanOrEqualTo(0)),
|
|
1170
|
+
retrievalRefCount: Schema7.Int.check(Schema7.isGreaterThanOrEqualTo(0))
|
|
1171
|
+
});
|
|
1172
|
+
var ContextPack = Schema7.Struct({
|
|
1173
|
+
contextPackId: Id,
|
|
1174
|
+
workspaceId: Id,
|
|
1175
|
+
projectId: Schema7.optionalKey(Id),
|
|
1176
|
+
taskId: Id,
|
|
1177
|
+
mode: ContextPackMode,
|
|
1178
|
+
contentMarkdown: Schema7.String.check(Schema7.isMinLength(1)),
|
|
1179
|
+
launchBrief: ContextPackLaunchBrief,
|
|
1180
|
+
contextIndex: Schema7.Array(ContextPackIndexEntry),
|
|
1181
|
+
retrievalRefs: Schema7.Array(ContextPackRetrievalRef),
|
|
1182
|
+
relevanceSummary: ContextPackRelevanceSummary,
|
|
1183
|
+
budget: ContextPackBudget,
|
|
1184
|
+
includedKitIds: Schema7.Array(Id),
|
|
1185
|
+
includedMemoryIds: Schema7.Array(Id),
|
|
1186
|
+
includedDecisionIds: Schema7.Array(Id),
|
|
1187
|
+
includedProposalIds: Schema7.Array(Id),
|
|
1188
|
+
includedSessionIds: Schema7.Array(Id),
|
|
1189
|
+
createdByActorType: ActorType,
|
|
1190
|
+
createdByActorId: Id,
|
|
1191
|
+
createdAt: Timestamp
|
|
1192
|
+
});
|
|
1193
|
+
var ContextPackGenerate = Schema7.Struct({
|
|
1194
|
+
mode: Schema7.optionalKey(ContextPackMode)
|
|
1195
|
+
});
|
|
1196
|
+
var ContextPackLatestQuery = Schema7.Struct({
|
|
1197
|
+
mode: Schema7.optionalKey(ContextPackMode)
|
|
1198
|
+
});
|
|
1199
|
+
var ContextPackResult = Schema7.Struct({
|
|
1200
|
+
contextPackId: Id,
|
|
1201
|
+
mode: ContextPackMode,
|
|
1202
|
+
contentMarkdown: Schema7.String.check(Schema7.isMinLength(1)),
|
|
1203
|
+
launchBrief: Schema7.optionalKey(ContextPackLaunchBrief),
|
|
1204
|
+
contextIndex: Schema7.optionalKey(Schema7.Array(ContextPackIndexEntry)),
|
|
1205
|
+
retrievalRefs: Schema7.optionalKey(Schema7.Array(ContextPackRetrievalRef)),
|
|
1206
|
+
relevanceSummary: Schema7.optionalKey(ContextPackRelevanceSummary),
|
|
1207
|
+
budget: Schema7.optionalKey(ContextPackBudget),
|
|
1208
|
+
includedDecisionIds: Schema7.optionalKey(Schema7.Array(Id)),
|
|
1209
|
+
includedProposalIds: Schema7.optionalKey(Schema7.Array(Id))
|
|
1210
|
+
});
|
|
1211
|
+
var ContextPackRetrievalInput = Schema7.Struct({
|
|
1212
|
+
contextPackId: Id,
|
|
1213
|
+
ref: ContextPackRetrievalRef
|
|
1214
|
+
});
|
|
1215
|
+
var ContextPackRetrievedContext = Schema7.Struct({
|
|
1216
|
+
contextPackId: Id,
|
|
1217
|
+
ref: ContextPackRetrievalRef,
|
|
1218
|
+
contentMarkdown: Schema7.String.check(Schema7.isMinLength(1)),
|
|
1219
|
+
safety: Schema7.Struct({
|
|
1220
|
+
rawContentIncluded: Schema7.Boolean,
|
|
1221
|
+
notes: Schema7.Array(Schema7.String.check(Schema7.isMinLength(1)))
|
|
1222
|
+
})
|
|
1223
|
+
});
|
|
1224
|
+
|
|
1225
|
+
// packages/core/src/extension.ts
|
|
1226
|
+
import * as Schema10 from "effect/Schema";
|
|
1227
|
+
|
|
1228
|
+
// packages/core/src/run.ts
|
|
1229
|
+
import * as Schema9 from "effect/Schema";
|
|
1230
|
+
|
|
1231
|
+
// packages/core/src/redaction.ts
|
|
1232
|
+
import * as Schema8 from "effect/Schema";
|
|
1233
|
+
import * as Data from "effect/Data";
|
|
1234
|
+
var EvidenceRefContractVersion = "evidence-ref.v1";
|
|
1235
|
+
var RedactionClassificationSchema = Schema8.Union([
|
|
1236
|
+
Schema8.Literal("secret"),
|
|
1237
|
+
Schema8.Literal("credential"),
|
|
1238
|
+
Schema8.Literal("pii"),
|
|
1239
|
+
Schema8.Literal("source"),
|
|
1240
|
+
Schema8.Literal("log"),
|
|
1241
|
+
Schema8.Literal("diff"),
|
|
1242
|
+
Schema8.Literal("transcript"),
|
|
1243
|
+
Schema8.Literal("provider_payload"),
|
|
1244
|
+
Schema8.Literal("url"),
|
|
1245
|
+
Schema8.Literal("path"),
|
|
1246
|
+
Schema8.Literal("unknown")
|
|
1247
|
+
]);
|
|
1248
|
+
var RedactionFindingSchema = Schema8.Struct({
|
|
1249
|
+
path: Schema8.String.check(Schema8.isMinLength(1), Schema8.isMaxLength(512)),
|
|
1250
|
+
classification: RedactionClassificationSchema,
|
|
1251
|
+
rule: Schema8.String.check(Schema8.isMinLength(1), Schema8.isMaxLength(120)),
|
|
1252
|
+
preview: Schema8.String.check(Schema8.isMaxLength(160)),
|
|
1253
|
+
sha256: Schema8.String.check(Schema8.isPattern(new RegExp("^[a-f0-9]{64}$", "u")))
|
|
1254
|
+
});
|
|
1255
|
+
var EvidenceRef = Schema8.Struct({
|
|
1256
|
+
contractVersion: Schema8.Literal(EvidenceRefContractVersion),
|
|
1257
|
+
kind: Schema8.String.check(Schema8.isMinLength(1), Schema8.isMaxLength(80)),
|
|
1258
|
+
summary: Schema8.String.check(Schema8.isMinLength(1), Schema8.isMaxLength(240)),
|
|
1259
|
+
sha256: Schema8.String.check(Schema8.isPattern(new RegExp("^[a-f0-9]{64}$", "u"))),
|
|
1260
|
+
redaction: Schema8.Literal("redacted"),
|
|
1261
|
+
findingCount: Schema8.Int.check(Schema8.isGreaterThanOrEqualTo(0)),
|
|
1262
|
+
classifications: Schema8.Array(RedactionClassificationSchema).check(Schema8.isMaxLength(20))
|
|
1263
|
+
});
|
|
1264
|
+
var RedactionSurfaceKinds = ["api", "mcp", "cli", "web", "event", "log", "evidence", "export"];
|
|
1265
|
+
var RedactionSurfaceKindSchema = Schema8.Literals(RedactionSurfaceKinds);
|
|
1266
|
+
var RedactionWaiver = Schema8.Struct({
|
|
1267
|
+
contractVersion: Schema8.Literal("redaction-waiver.v1"),
|
|
1268
|
+
id: Schema8.String.check(Schema8.isMinLength(1)),
|
|
1269
|
+
workspaceId: Schema8.String.check(Schema8.isMinLength(1)),
|
|
1270
|
+
findingId: Schema8.String.check(Schema8.isMinLength(1)),
|
|
1271
|
+
reason: Schema8.String.check(Schema8.isMinLength(1), Schema8.isMaxLength(1000)),
|
|
1272
|
+
authorityActorType: Schema8.Union([
|
|
1273
|
+
Schema8.Literal("human"),
|
|
1274
|
+
Schema8.Literal("delegated_agent"),
|
|
1275
|
+
Schema8.Literal("agent")
|
|
1276
|
+
]),
|
|
1277
|
+
authorityActorId: Schema8.String.check(Schema8.isMinLength(1)),
|
|
1278
|
+
authorityRole: Schema8.Union([Schema8.Literal("owner"), Schema8.Literal("admin")]),
|
|
1279
|
+
expiresAt: Schema8.optionalKey(Schema8.String.check(isDateTime)),
|
|
1280
|
+
createdAt: Schema8.String.check(isDateTime)
|
|
1281
|
+
});
|
|
1282
|
+
class DurableSurfaceScanError extends Data.TaggedError("DurableSurfaceScanError") {
|
|
1283
|
+
constructor(findings) {
|
|
1284
|
+
super({ message: "Durable surface scanner rejected unsafe or unknown content", findings });
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
var LIVE_CANONICAL_ID_KEYS = new Set([
|
|
1288
|
+
"workspace_id",
|
|
1289
|
+
"project_id",
|
|
1290
|
+
"task_id",
|
|
1291
|
+
"session_id",
|
|
1292
|
+
"step_attempt_id",
|
|
1293
|
+
"agent_identity_id",
|
|
1294
|
+
"memory_id",
|
|
1295
|
+
"context_pack_id",
|
|
1296
|
+
"loop_id",
|
|
1297
|
+
"run_id",
|
|
1298
|
+
"loop_change_id",
|
|
1299
|
+
"approval_id",
|
|
1300
|
+
"subject_id",
|
|
1301
|
+
"item_id",
|
|
1302
|
+
"runner_id",
|
|
1303
|
+
"runner_replica_id",
|
|
1304
|
+
"work_unit_id",
|
|
1305
|
+
"placement_id",
|
|
1306
|
+
"dependency_id",
|
|
1307
|
+
"detail_id",
|
|
1308
|
+
"run_event_id",
|
|
1309
|
+
"run_message_id",
|
|
1310
|
+
"run_result_id",
|
|
1311
|
+
"sender_run_id",
|
|
1312
|
+
"recipient_run_id",
|
|
1313
|
+
"lease_id",
|
|
1314
|
+
"client_mutation_id"
|
|
1315
|
+
]);
|
|
1316
|
+
var LOCAL_PATH_KEYS = new Set([
|
|
1317
|
+
"path",
|
|
1318
|
+
"local_path",
|
|
1319
|
+
"host_path",
|
|
1320
|
+
"checkout_path",
|
|
1321
|
+
"worktree_path",
|
|
1322
|
+
"directory",
|
|
1323
|
+
"dir",
|
|
1324
|
+
"socket",
|
|
1325
|
+
"docker_socket",
|
|
1326
|
+
"ssh_agent_socket"
|
|
1327
|
+
]);
|
|
1328
|
+
var VALUE_RULES = [
|
|
1329
|
+
["secret", /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/u, "private-key"],
|
|
1330
|
+
["credential", /\bBearer\s+[A-Za-z0-9._~+/-]+=*/iu, "bearer-token"],
|
|
1331
|
+
[
|
|
1332
|
+
"credential",
|
|
1333
|
+
/(?:^|[^A-Za-z0-9])(?:ghp_|github_pat_|glpat-|ksa1\.|sk-[A-Za-z0-9_-]{8,}|xox[baprs]-)[A-Za-z0-9._-]+/u,
|
|
1334
|
+
"provider-token"
|
|
1335
|
+
],
|
|
1336
|
+
[
|
|
1337
|
+
"credential",
|
|
1338
|
+
/(?:api[_ -]?key|secret|token|password)\s*[:=]\s*(?!env\b|file\b|exec\b)[^\s,;}]+/iu,
|
|
1339
|
+
"credential-assignment"
|
|
1340
|
+
],
|
|
1341
|
+
["pii", /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b/iu, "email"],
|
|
1342
|
+
["pii", /\b\d{3}-\d{2}-\d{4}\b/u, "ssn"],
|
|
1343
|
+
["pii", /(?:\+\d[\d ()-]{8,}\d|\(\d{3}\)[\d -]{7,}\d|\b\d{3}[ -]\d{3}[ -]\d{4}\b)/u, "phone"],
|
|
1344
|
+
["pii", /\b(?:\d[ -]*?){13,19}\b/u, "payment-number"],
|
|
1345
|
+
["url", /\b(?:https?|ftp):\/\/[^\s]+/iu, "url-content"],
|
|
1346
|
+
["diff", /(^|\n)diff --git\s/u, "diff-content"],
|
|
1347
|
+
["source", /(^|\n)\s*(?:import|export|const|let|var|function|class)\s+[A-Za-z_$]/u, "source-content"],
|
|
1348
|
+
["log", /(?:^|\n)\s*\d{4}-\d{2}-\d{2}T\S+\s+(?:ERROR|WARN|INFO|DEBUG)\b/u, "structured-log"],
|
|
1349
|
+
["transcript", /(?:^|\n)\s*(?:user|assistant|system)\s*:/iu, "transcript-content"]
|
|
1350
|
+
];
|
|
1351
|
+
var normalizedKeys = new Map;
|
|
1352
|
+
var CREDENTIAL_RULES = VALUE_RULES.flatMap(([classification, pattern]) => classification === "secret" || classification === "credential" ? [[classification, new RegExp(pattern.source, `${pattern.flags}g`)]] : []);
|
|
1353
|
+
|
|
1354
|
+
// packages/core/src/run.ts
|
|
1355
|
+
var RunContractVersion = Schema9.Literal("run.v1");
|
|
1356
|
+
var ImmutableExecutionClosureContractVersion = Schema9.Literal("immutable-execution-closure.v1");
|
|
1357
|
+
var Sha2563 = Schema9.String.check(Schema9.isPattern(new RegExp("^[a-f0-9]{64}$", "u")));
|
|
1358
|
+
var BoundedText = Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(4000));
|
|
1359
|
+
var SafeKey = Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(120), Schema9.isPattern(new RegExp("^[A-Za-z][A-Za-z0-9_-]*$", "u")));
|
|
1360
|
+
var SafeJson = Schema9.Union([
|
|
1361
|
+
Schema9.Null,
|
|
1362
|
+
Schema9.Boolean,
|
|
1363
|
+
Schema9.Finite.check(Schema9.isLessThanOrEqualTo(Number.MAX_SAFE_INTEGER), Schema9.isGreaterThanOrEqualTo(Number.MIN_SAFE_INTEGER)),
|
|
1364
|
+
BoundedText,
|
|
1365
|
+
Schema9.Array(Schema9.suspend(() => SafeJson)).check(Schema9.isMaxLength(200)),
|
|
1366
|
+
Schema9.Record(SafeKey, Schema9.suspend(() => SafeJson)).check(Schema9.isMaxProperties(200))
|
|
1367
|
+
]).annotate({ identifier: "RunSafeJson" });
|
|
1368
|
+
var RunActorRef = Schema9.Struct({
|
|
1369
|
+
actorType: Schema9.Union([ActorType, Schema9.Literal("runner")]),
|
|
1370
|
+
actorId: Id,
|
|
1371
|
+
delegatedByUserId: Schema9.optionalKey(Id),
|
|
1372
|
+
agentIdentityId: Schema9.optionalKey(Id),
|
|
1373
|
+
runnerId: Schema9.optionalKey(Id)
|
|
1374
|
+
});
|
|
1375
|
+
var RunResourceRef = Schema9.Struct({
|
|
1376
|
+
kind: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(80)),
|
|
1377
|
+
id: Id
|
|
1378
|
+
});
|
|
1379
|
+
var RunSchemaRef = Schema9.Struct({
|
|
1380
|
+
kind: Schema9.Literal("typebox_ref"),
|
|
1381
|
+
name: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(160)),
|
|
1382
|
+
version: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(40)),
|
|
1383
|
+
sha256: Sha2563
|
|
1384
|
+
});
|
|
1385
|
+
var AgentPinnedKitRef = Schema9.Struct({
|
|
1386
|
+
kitId: Id,
|
|
1387
|
+
version: Schema9.Int.check(Schema9.isGreaterThanOrEqualTo(1)),
|
|
1388
|
+
sha256: Sha2563,
|
|
1389
|
+
precedence: Schema9.Int.check(Schema9.isGreaterThanOrEqualTo(0)),
|
|
1390
|
+
required: Schema9.Boolean
|
|
1391
|
+
});
|
|
1392
|
+
var AgentSkillRef = Schema9.Struct({
|
|
1393
|
+
sourceId: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(240)),
|
|
1394
|
+
name: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(160)),
|
|
1395
|
+
version: Schema9.optionalKey(Schema9.String.check(Schema9.isMaxLength(80))),
|
|
1396
|
+
sha256: Schema9.optionalKey(Sha2563),
|
|
1397
|
+
required: Schema9.Boolean
|
|
1398
|
+
});
|
|
1399
|
+
var AgentReference = Schema9.Union([
|
|
1400
|
+
Schema9.Struct({ agentId: Id, alias: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(80)) }),
|
|
1401
|
+
Schema9.Struct({ agentId: Id, version: Schema9.Int.check(Schema9.isGreaterThanOrEqualTo(1)), digest: Sha2563 })
|
|
1402
|
+
]);
|
|
1403
|
+
var AgentToolGrant = Schema9.Struct({
|
|
1404
|
+
ref: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(240)),
|
|
1405
|
+
inputSchema: Schema9.optionalKey(RunSchemaRef),
|
|
1406
|
+
scope: Schema9.optionalKey(RunResourceRef),
|
|
1407
|
+
approval: Schema9.Union([Schema9.Literal("none"), Schema9.Literal("human_each_call"), Schema9.Literal("human_once")]),
|
|
1408
|
+
delegable: Schema9.Boolean
|
|
1409
|
+
});
|
|
1410
|
+
var AgentHarnessSelector = Schema9.Struct({
|
|
1411
|
+
mode: Schema9.Union([Schema9.Literal("direct_model"), Schema9.Literal("harness_v1"), Schema9.Literal("native")]),
|
|
1412
|
+
harness: Schema9.optionalKey(Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(80))),
|
|
1413
|
+
adapterRef: Schema9.optionalKey(Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(240))),
|
|
1414
|
+
requiredCapabilities: Schema9.Array(Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(80))).check(Schema9.isMaxLength(40)),
|
|
1415
|
+
allowedFallbacks: Schema9.Array(Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(160))).check(Schema9.isMaxLength(20))
|
|
1416
|
+
});
|
|
1417
|
+
var AgentModelSelector = Schema9.Struct({
|
|
1418
|
+
providerRef: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(160)),
|
|
1419
|
+
modelRef: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(160)),
|
|
1420
|
+
profile: Schema9.optionalKey(Schema9.String.check(Schema9.isMaxLength(80))),
|
|
1421
|
+
reasoning: Schema9.optionalKey(Schema9.String.check(Schema9.isMaxLength(80)))
|
|
1422
|
+
});
|
|
1423
|
+
var AgentPolicy = Schema9.Struct({
|
|
1424
|
+
requestedCapabilities: Schema9.Array(Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(120))).check(Schema9.isMaxLength(100)),
|
|
1425
|
+
maxChildDepth: Schema9.Int.check(Schema9.isGreaterThanOrEqualTo(0), Schema9.isLessThanOrEqualTo(32)),
|
|
1426
|
+
allowSubdelegation: Schema9.Boolean,
|
|
1427
|
+
maxWallSeconds: Schema9.optionalKey(Schema9.Int.check(Schema9.isGreaterThanOrEqualTo(1), Schema9.isLessThanOrEqualTo(31536000))),
|
|
1428
|
+
maxInputTokens: Schema9.optionalKey(Schema9.Int.check(Schema9.isGreaterThanOrEqualTo(0), Schema9.isLessThanOrEqualTo(1e8))),
|
|
1429
|
+
maxOutputTokens: Schema9.optionalKey(Schema9.Int.check(Schema9.isGreaterThanOrEqualTo(0), Schema9.isLessThanOrEqualTo(1e8))),
|
|
1430
|
+
hardLimit: Schema9.Boolean
|
|
1431
|
+
});
|
|
1432
|
+
var AgentProvenance = Schema9.Struct({
|
|
1433
|
+
source: Schema9.Union([
|
|
1434
|
+
Schema9.Literal("kitman"),
|
|
1435
|
+
Schema9.Literal("workspace"),
|
|
1436
|
+
Schema9.Literal("project"),
|
|
1437
|
+
Schema9.Literal("git"),
|
|
1438
|
+
Schema9.Literal("package"),
|
|
1439
|
+
Schema9.Literal("import")
|
|
1440
|
+
]),
|
|
1441
|
+
sourceRef: Schema9.optionalKey(Schema9.String.check(Schema9.isMaxLength(240))),
|
|
1442
|
+
sourceCommitSha: Schema9.optionalKey(Schema9.String.check(Schema9.isMaxLength(128))),
|
|
1443
|
+
contentSha256: Sha2563,
|
|
1444
|
+
reviewedBy: Schema9.optionalKey(Schema9.Array(RunActorRef).check(Schema9.isMaxLength(20)))
|
|
1445
|
+
});
|
|
1446
|
+
var Agent = Schema9.Struct({
|
|
1447
|
+
contractVersion: RunContractVersion,
|
|
1448
|
+
id: Id,
|
|
1449
|
+
workspaceId: Id,
|
|
1450
|
+
projectId: Schema9.optionalKey(Id),
|
|
1451
|
+
name: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(160)),
|
|
1452
|
+
slug: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(160), Schema9.isPattern(new RegExp("^[a-z0-9]+(?:-[a-z0-9]+)*$", "u"))),
|
|
1453
|
+
currentVersion: Schema9.optionalKey(Schema9.Int.check(Schema9.isGreaterThanOrEqualTo(1))),
|
|
1454
|
+
status: Schema9.Union([
|
|
1455
|
+
Schema9.Literal("draft"),
|
|
1456
|
+
Schema9.Literal("published"),
|
|
1457
|
+
Schema9.Literal("deprecated"),
|
|
1458
|
+
Schema9.Literal("disabled"),
|
|
1459
|
+
Schema9.Literal("archived")
|
|
1460
|
+
]),
|
|
1461
|
+
createdBy: RunActorRef,
|
|
1462
|
+
createdAt: Timestamp,
|
|
1463
|
+
updatedAt: Timestamp
|
|
1464
|
+
});
|
|
1465
|
+
var RunMessageTypes = [
|
|
1466
|
+
"progress",
|
|
1467
|
+
"question",
|
|
1468
|
+
"answer",
|
|
1469
|
+
"context_request",
|
|
1470
|
+
"context_response",
|
|
1471
|
+
"finding",
|
|
1472
|
+
"partial_result",
|
|
1473
|
+
"handoff",
|
|
1474
|
+
"instruction",
|
|
1475
|
+
"notice"
|
|
1476
|
+
];
|
|
1477
|
+
var RunMessageType = Schema9.Literals(RunMessageTypes);
|
|
1478
|
+
var MessageEvidenceRefs = Schema9.Array(RunResourceRef).check(Schema9.isMaxLength(100));
|
|
1479
|
+
var MessageProgressPayload = Schema9.Struct({
|
|
1480
|
+
type: Schema9.Literal("progress"),
|
|
1481
|
+
summary: BoundedText,
|
|
1482
|
+
phase: Schema9.optionalKey(Schema9.String.check(Schema9.isMaxLength(120))),
|
|
1483
|
+
percent: Schema9.optionalKey(Schema9.Finite.check(Schema9.isGreaterThanOrEqualTo(0), Schema9.isLessThanOrEqualTo(100))),
|
|
1484
|
+
evidenceRefs: Schema9.optionalKey(MessageEvidenceRefs)
|
|
1485
|
+
});
|
|
1486
|
+
var MessageQuestionPayload = Schema9.Struct({
|
|
1487
|
+
type: Schema9.Literal("question"),
|
|
1488
|
+
questionId: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(160)),
|
|
1489
|
+
prompt: BoundedText,
|
|
1490
|
+
answerSchema: RunSchemaRef,
|
|
1491
|
+
urgency: Schema9.Union([Schema9.Literal("normal"), Schema9.Literal("blocking")]),
|
|
1492
|
+
waitId: Id
|
|
1493
|
+
});
|
|
1494
|
+
var MessageAnswerPayload = Schema9.Struct({
|
|
1495
|
+
type: Schema9.Literal("answer"),
|
|
1496
|
+
questionId: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(160)),
|
|
1497
|
+
answer: SafeJson,
|
|
1498
|
+
answerSchema: RunSchemaRef,
|
|
1499
|
+
waitId: Id
|
|
1500
|
+
});
|
|
1501
|
+
var MessageContextRequestPayload = Schema9.Struct({
|
|
1502
|
+
type: Schema9.Literal("context_request"),
|
|
1503
|
+
requestId: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(160)),
|
|
1504
|
+
refs: Schema9.Array(RunResourceRef).check(Schema9.isMaxLength(100)),
|
|
1505
|
+
reason: BoundedText
|
|
1506
|
+
});
|
|
1507
|
+
var MessageContextResponsePayload = Schema9.Struct({
|
|
1508
|
+
type: Schema9.Literal("context_response"),
|
|
1509
|
+
requestId: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(160)),
|
|
1510
|
+
refs: Schema9.Array(RunResourceRef).check(Schema9.isMaxLength(100)),
|
|
1511
|
+
summaries: Schema9.Array(SafeJson).check(Schema9.isMaxLength(100))
|
|
1512
|
+
});
|
|
1513
|
+
var MessageFindingPayload = Schema9.Struct({
|
|
1514
|
+
type: Schema9.Literal("finding"),
|
|
1515
|
+
severity: Schema9.Union([
|
|
1516
|
+
Schema9.Literal("info"),
|
|
1517
|
+
Schema9.Literal("low"),
|
|
1518
|
+
Schema9.Literal("medium"),
|
|
1519
|
+
Schema9.Literal("high"),
|
|
1520
|
+
Schema9.Literal("critical")
|
|
1521
|
+
]),
|
|
1522
|
+
category: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(120)),
|
|
1523
|
+
summary: BoundedText,
|
|
1524
|
+
evidenceRefs: MessageEvidenceRefs
|
|
1525
|
+
});
|
|
1526
|
+
var MessagePartialResultPayload = Schema9.Struct({
|
|
1527
|
+
type: Schema9.Literal("partial_result"),
|
|
1528
|
+
outputSchema: RunSchemaRef,
|
|
1529
|
+
data: SafeJson,
|
|
1530
|
+
complete: Schema9.Literal(false)
|
|
1531
|
+
});
|
|
1532
|
+
var MessageHandoffPayload = Schema9.Struct({
|
|
1533
|
+
type: Schema9.Literal("handoff"),
|
|
1534
|
+
summary: BoundedText,
|
|
1535
|
+
nextAction: Schema9.optionalKey(Schema9.String.check(Schema9.isMaxLength(4000))),
|
|
1536
|
+
evidenceRefs: Schema9.optionalKey(MessageEvidenceRefs)
|
|
1537
|
+
});
|
|
1538
|
+
var MessageInstructionPayload = Schema9.Struct({
|
|
1539
|
+
type: Schema9.Literal("instruction"),
|
|
1540
|
+
instruction: BoundedText,
|
|
1541
|
+
authority: Schema9.Union([Schema9.Literal("normal"), Schema9.Literal("operator")])
|
|
1542
|
+
});
|
|
1543
|
+
var MessageNoticePayload = Schema9.Struct({
|
|
1544
|
+
type: Schema9.Literal("notice"),
|
|
1545
|
+
code: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(120)),
|
|
1546
|
+
summary: BoundedText
|
|
1547
|
+
});
|
|
1548
|
+
var RunMessagePayload = Schema9.Union([
|
|
1549
|
+
MessageProgressPayload,
|
|
1550
|
+
MessageQuestionPayload,
|
|
1551
|
+
MessageAnswerPayload,
|
|
1552
|
+
MessageContextRequestPayload,
|
|
1553
|
+
MessageContextResponsePayload,
|
|
1554
|
+
MessageFindingPayload,
|
|
1555
|
+
MessagePartialResultPayload,
|
|
1556
|
+
MessageHandoffPayload,
|
|
1557
|
+
MessageInstructionPayload,
|
|
1558
|
+
MessageNoticePayload
|
|
1559
|
+
]);
|
|
1560
|
+
var RunMessage = Schema9.Struct({
|
|
1561
|
+
contractVersion: RunContractVersion,
|
|
1562
|
+
id: Id,
|
|
1563
|
+
workspaceId: Id,
|
|
1564
|
+
projectId: Schema9.optionalKey(Id),
|
|
1565
|
+
rootRunId: Id,
|
|
1566
|
+
sender: Schema9.Union([
|
|
1567
|
+
Schema9.Struct({ kind: Schema9.Union([Schema9.Literal("run"), Schema9.Literal("step_attempt")]), id: Id }),
|
|
1568
|
+
RunActorRef
|
|
1569
|
+
]),
|
|
1570
|
+
recipient: Schema9.Struct({ kind: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(80)), id: Id }),
|
|
1571
|
+
type: RunMessageType,
|
|
1572
|
+
streamKey: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(240)),
|
|
1573
|
+
sequence: Schema9.Int.check(Schema9.isGreaterThanOrEqualTo(1)),
|
|
1574
|
+
correlationId: Schema9.optionalKey(Id),
|
|
1575
|
+
causationId: Schema9.optionalKey(Id),
|
|
1576
|
+
replyToMessageId: Schema9.optionalKey(Id),
|
|
1577
|
+
payloadSchema: Schema9.optionalKey(RunSchemaRef),
|
|
1578
|
+
payload: RunMessagePayload,
|
|
1579
|
+
delivery: Schema9.Union([
|
|
1580
|
+
Schema9.Literal("created"),
|
|
1581
|
+
Schema9.Literal("queued"),
|
|
1582
|
+
Schema9.Literal("delivered"),
|
|
1583
|
+
Schema9.Literal("acknowledged"),
|
|
1584
|
+
Schema9.Literal("expired"),
|
|
1585
|
+
Schema9.Literal("failed")
|
|
1586
|
+
]),
|
|
1587
|
+
idempotencyKey: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(240)),
|
|
1588
|
+
expiresAt: Schema9.optionalKey(Timestamp),
|
|
1589
|
+
createdAt: Timestamp,
|
|
1590
|
+
acknowledgedAt: Schema9.optionalKey(Timestamp)
|
|
1591
|
+
});
|
|
1592
|
+
var RunResult = Schema9.Struct({
|
|
1593
|
+
contractVersion: RunContractVersion,
|
|
1594
|
+
id: Id,
|
|
1595
|
+
workspaceId: Id,
|
|
1596
|
+
projectId: Schema9.optionalKey(Id),
|
|
1597
|
+
runId: Id,
|
|
1598
|
+
rootRunId: Id,
|
|
1599
|
+
attempt: Schema9.Int.check(Schema9.isGreaterThanOrEqualTo(1)),
|
|
1600
|
+
outcome: Schema9.Union([
|
|
1601
|
+
Schema9.Literal("succeeded"),
|
|
1602
|
+
Schema9.Literal("failed"),
|
|
1603
|
+
Schema9.Literal("canceled"),
|
|
1604
|
+
Schema9.Literal("blocked"),
|
|
1605
|
+
Schema9.Literal("expired")
|
|
1606
|
+
]),
|
|
1607
|
+
output: Schema9.optionalKey(Schema9.Struct({ schema: RunSchemaRef, data: SafeJson, digest: Sha2563 })),
|
|
1608
|
+
failure: Schema9.optionalKey(Schema9.Struct({
|
|
1609
|
+
code: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(120)),
|
|
1610
|
+
category: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(80)),
|
|
1611
|
+
summary: BoundedText,
|
|
1612
|
+
retryable: Schema9.Boolean,
|
|
1613
|
+
details: Schema9.optionalKey(SafeJson)
|
|
1614
|
+
})),
|
|
1615
|
+
evidenceRefs: Schema9.Array(Schema9.Union([RunResourceRef, EvidenceRef])).check(Schema9.isMaxLength(100)),
|
|
1616
|
+
childSummary: Schema9.Struct({
|
|
1617
|
+
awaited: Schema9.Int.check(Schema9.isGreaterThanOrEqualTo(0)),
|
|
1618
|
+
detached: Schema9.Int.check(Schema9.isGreaterThanOrEqualTo(0)),
|
|
1619
|
+
succeeded: Schema9.Int.check(Schema9.isGreaterThanOrEqualTo(0)),
|
|
1620
|
+
failed: Schema9.Int.check(Schema9.isGreaterThanOrEqualTo(0)),
|
|
1621
|
+
canceled: Schema9.Int.check(Schema9.isGreaterThanOrEqualTo(0))
|
|
1622
|
+
}),
|
|
1623
|
+
usage: Schema9.optionalKey(Schema9.Record(SafeKey, SafeJson).check(Schema9.isMaxProperties(20))),
|
|
1624
|
+
producedBy: Schema9.Struct({
|
|
1625
|
+
workUnitId: Schema9.optionalKey(Id),
|
|
1626
|
+
leaseId: Schema9.optionalKey(Id),
|
|
1627
|
+
fencingTokenDigest: Schema9.optionalKey(Sha2563)
|
|
1628
|
+
}),
|
|
1629
|
+
createdAt: Timestamp,
|
|
1630
|
+
finalizedAt: Timestamp
|
|
1631
|
+
});
|
|
1632
|
+
var RunEvent = Schema9.Struct({
|
|
1633
|
+
contractVersion: RunContractVersion,
|
|
1634
|
+
id: Id,
|
|
1635
|
+
eventVersion: Schema9.Literal(1),
|
|
1636
|
+
streamId: Id,
|
|
1637
|
+
sequence: Schema9.Int.check(Schema9.isGreaterThanOrEqualTo(1)),
|
|
1638
|
+
workspaceId: Id,
|
|
1639
|
+
projectId: Schema9.optionalKey(Id),
|
|
1640
|
+
subject: RunResourceRef,
|
|
1641
|
+
rootRunId: Id,
|
|
1642
|
+
type: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(100)),
|
|
1643
|
+
actor: Schema9.optionalKey(RunActorRef),
|
|
1644
|
+
correlationId: Schema9.optionalKey(Id),
|
|
1645
|
+
causationId: Schema9.optionalKey(Id),
|
|
1646
|
+
occurredAt: Timestamp,
|
|
1647
|
+
data: Schema9.Struct({ type: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(100)), value: SafeJson })
|
|
1648
|
+
});
|
|
1649
|
+
var WaitKinds = [
|
|
1650
|
+
"timer",
|
|
1651
|
+
"message",
|
|
1652
|
+
"child_run",
|
|
1653
|
+
"external_event",
|
|
1654
|
+
"human_approval",
|
|
1655
|
+
"provider_check",
|
|
1656
|
+
"provider_quota",
|
|
1657
|
+
"resource"
|
|
1658
|
+
];
|
|
1659
|
+
var WaitKind = Schema9.Literals(WaitKinds);
|
|
1660
|
+
var Wait = Schema9.Struct({
|
|
1661
|
+
contractVersion: RunContractVersion,
|
|
1662
|
+
id: Id,
|
|
1663
|
+
workspaceId: Id,
|
|
1664
|
+
projectId: Schema9.optionalKey(Id),
|
|
1665
|
+
runId: Id,
|
|
1666
|
+
rootRunId: Id,
|
|
1667
|
+
stepKey: Schema9.optionalKey(Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(160))),
|
|
1668
|
+
kind: WaitKind,
|
|
1669
|
+
state: Schema9.Union([
|
|
1670
|
+
Schema9.Literal("open"),
|
|
1671
|
+
Schema9.Literal("resolved"),
|
|
1672
|
+
Schema9.Literal("expired"),
|
|
1673
|
+
Schema9.Literal("canceled")
|
|
1674
|
+
]),
|
|
1675
|
+
correlation: Schema9.Record(SafeKey, SafeJson).check(Schema9.isMaxProperties(20)),
|
|
1676
|
+
expectedSchema: Schema9.optionalKey(RunSchemaRef),
|
|
1677
|
+
timeout: Schema9.Struct({
|
|
1678
|
+
dueAt: Schema9.optionalKey(Timestamp),
|
|
1679
|
+
onTimeout: Schema9.Union([
|
|
1680
|
+
Schema9.Literal("fail"),
|
|
1681
|
+
Schema9.Literal("block"),
|
|
1682
|
+
Schema9.Literal("cancel"),
|
|
1683
|
+
Schema9.Literal("default"),
|
|
1684
|
+
Schema9.Literal("escalate")
|
|
1685
|
+
]),
|
|
1686
|
+
defaultValue: Schema9.optionalKey(SafeJson)
|
|
1687
|
+
}),
|
|
1688
|
+
responderScope: Schema9.optionalKey(RunResourceRef),
|
|
1689
|
+
resolution: Schema9.optionalKey(Schema9.Struct({
|
|
1690
|
+
kind: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(80)),
|
|
1691
|
+
data: Schema9.optionalKey(SafeJson),
|
|
1692
|
+
digest: Sha2563,
|
|
1693
|
+
actor: Schema9.optionalKey(RunActorRef)
|
|
1694
|
+
})),
|
|
1695
|
+
createdAt: Timestamp,
|
|
1696
|
+
resolvedAt: Schema9.optionalKey(Timestamp)
|
|
1697
|
+
});
|
|
1698
|
+
var ControlCommandKinds = [
|
|
1699
|
+
"pause",
|
|
1700
|
+
"resume",
|
|
1701
|
+
"extend_budget",
|
|
1702
|
+
"cancel",
|
|
1703
|
+
"retry",
|
|
1704
|
+
"rerun_latest",
|
|
1705
|
+
"takeover",
|
|
1706
|
+
"release_takeover",
|
|
1707
|
+
"answer_wait",
|
|
1708
|
+
"approve_wait",
|
|
1709
|
+
"reject_wait",
|
|
1710
|
+
"refresh_context",
|
|
1711
|
+
"repair_readiness",
|
|
1712
|
+
"sync_agent_environment",
|
|
1713
|
+
"escalate_sandbox",
|
|
1714
|
+
"rotate_secret_ref",
|
|
1715
|
+
"rerun_verification",
|
|
1716
|
+
"create_follow_up",
|
|
1717
|
+
"drain_replica",
|
|
1718
|
+
"discard_cache",
|
|
1719
|
+
"request_status",
|
|
1720
|
+
"request_handoff"
|
|
1721
|
+
];
|
|
1722
|
+
var ControlCommandKind = Schema9.Literals(ControlCommandKinds);
|
|
1723
|
+
var ControlCommand = Schema9.Struct({
|
|
1724
|
+
contractVersion: RunContractVersion,
|
|
1725
|
+
id: Id,
|
|
1726
|
+
workspaceId: Id,
|
|
1727
|
+
projectId: Schema9.optionalKey(Id),
|
|
1728
|
+
target: RunResourceRef,
|
|
1729
|
+
kind: ControlCommandKind,
|
|
1730
|
+
payload: Schema9.Struct({ kind: ControlCommandKind, data: SafeJson }),
|
|
1731
|
+
requestedBy: RunActorRef,
|
|
1732
|
+
idempotencyKey: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(240)),
|
|
1733
|
+
expectedResourceVersion: Schema9.optionalKey(Schema9.Int.check(Schema9.isGreaterThanOrEqualTo(1))),
|
|
1734
|
+
status: Schema9.Union([
|
|
1735
|
+
Schema9.Literal("accepted"),
|
|
1736
|
+
Schema9.Literal("queued"),
|
|
1737
|
+
Schema9.Literal("applied"),
|
|
1738
|
+
Schema9.Literal("rejected"),
|
|
1739
|
+
Schema9.Literal("expired"),
|
|
1740
|
+
Schema9.Literal("superseded")
|
|
1741
|
+
]),
|
|
1742
|
+
rejection: Schema9.optionalKey(Schema9.Struct({ code: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(120)), summary: BoundedText })),
|
|
1743
|
+
createdAt: Timestamp,
|
|
1744
|
+
appliedAt: Schema9.optionalKey(Timestamp)
|
|
1745
|
+
});
|
|
1746
|
+
var ControlCommandList = Schema9.Struct({ items: Schema9.Array(ControlCommand).check(Schema9.isMaxLength(50)) });
|
|
1747
|
+
var RunCommandCenterSnapshot = Schema9.Struct({
|
|
1748
|
+
source: Schema9.Literal("http_snapshot"),
|
|
1749
|
+
collection: Schema9.Literal("run_command_center"),
|
|
1750
|
+
scope: Schema9.Struct({
|
|
1751
|
+
kind: Schema9.Literal("run"),
|
|
1752
|
+
workspaceId: Id,
|
|
1753
|
+
projectId: Schema9.optionalKey(Id),
|
|
1754
|
+
runId: Id
|
|
1755
|
+
}),
|
|
1756
|
+
capturedAt: Timestamp,
|
|
1757
|
+
consistency: Schema9.Literal("lower_bound"),
|
|
1758
|
+
lowerBound: Schema9.String.check(Schema9.isMinLength(1), Schema9.isMaxLength(512)),
|
|
1759
|
+
isComplete: Schema9.Literal(true)
|
|
1760
|
+
});
|
|
1761
|
+
|
|
1762
|
+
// packages/core/src/extension.ts
|
|
1763
|
+
var NativeExtensionTargets = ["runner_backend", "harness", "sandbox"];
|
|
1764
|
+
var NativeExtensionTarget = Schema10.Literals(NativeExtensionTargets);
|
|
1765
|
+
var NativeExtensionPolicies = ["optional", "required"];
|
|
1766
|
+
var NativeExtensionPolicy = Schema10.Literals(NativeExtensionPolicies);
|
|
1767
|
+
var NativeExtensionIdentity = Schema10.String.check(Schema10.isMinLength(3), Schema10.isMaxLength(120), Schema10.isPattern(new RegExp("^[a-z0-9][a-z0-9_-]*(\\.[a-z0-9][a-z0-9_-]*)+$", "u")));
|
|
1768
|
+
var NativeExtensionRef = Schema10.Struct({
|
|
1769
|
+
extensionId: NativeExtensionIdentity,
|
|
1770
|
+
version: Schema10.Int.check(Schema10.isGreaterThanOrEqualTo(1), Schema10.isLessThanOrEqualTo(10)),
|
|
1771
|
+
policy: NativeExtensionPolicy,
|
|
1772
|
+
requiredCapabilities: Schema10.optionalKey(Schema10.Array(Schema10.String.check(Schema10.isMinLength(1), Schema10.isMaxLength(120))).check(Schema10.isMaxLength(50))),
|
|
1773
|
+
configuration: Schema10.optionalKey(Schema10.Record(Schema10.String.check(Schema10.isMinLength(1), Schema10.isMaxLength(120)), SafeJson).check(Schema10.isMaxProperties(40)))
|
|
1774
|
+
});
|
|
1775
|
+
var NativeExtensionDescriptor = Schema10.Struct({
|
|
1776
|
+
extensionId: NativeExtensionIdentity,
|
|
1777
|
+
version: Schema10.Int.check(Schema10.isGreaterThanOrEqualTo(1), Schema10.isLessThanOrEqualTo(10)),
|
|
1778
|
+
target: NativeExtensionTarget,
|
|
1779
|
+
requiredCapabilities: Schema10.Array(Schema10.String.check(Schema10.isMinLength(1), Schema10.isMaxLength(120))).check(Schema10.isMaxLength(50)),
|
|
1780
|
+
configurationSchema: Schema10.optionalKey(Schema10.Record(Schema10.String.check(Schema10.isMinLength(1), Schema10.isMaxLength(120)), SafeJson).check(Schema10.isMaxProperties(80))),
|
|
1781
|
+
resultSchema: Schema10.optionalKey(Schema10.Record(Schema10.String.check(Schema10.isMinLength(1), Schema10.isMaxLength(120)), SafeJson).check(Schema10.isMaxProperties(80))),
|
|
1782
|
+
observability: Schema10.Struct({
|
|
1783
|
+
transcriptPolicy: Schema10.Literal("metadata_only"),
|
|
1784
|
+
maxMetadataChars: Schema10.optionalKey(Schema10.Int.check(Schema10.isGreaterThanOrEqualTo(1), Schema10.isLessThanOrEqualTo(65536)))
|
|
1785
|
+
})
|
|
1786
|
+
});
|
|
1787
|
+
|
|
1788
|
+
// packages/core/src/proposal.ts
|
|
1789
|
+
import * as Schema11 from "effect/Schema";
|
|
1790
|
+
var ProposalStatuses = [
|
|
1791
|
+
"proposed",
|
|
1792
|
+
"in_review",
|
|
1793
|
+
"approved",
|
|
1794
|
+
"rejected",
|
|
1795
|
+
"applied",
|
|
1796
|
+
"reverted",
|
|
1797
|
+
"superseded",
|
|
1798
|
+
"canceled"
|
|
1799
|
+
];
|
|
1800
|
+
var KitMarketplaceProposalTargetTypes = [
|
|
1801
|
+
"kit_source",
|
|
1802
|
+
"kit_version",
|
|
1803
|
+
"kit_installation",
|
|
1804
|
+
"kit_activation",
|
|
1805
|
+
"kit_trust_policy"
|
|
1806
|
+
];
|
|
1807
|
+
var KitMarketplaceProposalActions = [
|
|
1808
|
+
"source_publish",
|
|
1809
|
+
"version_publish",
|
|
1810
|
+
"source_update",
|
|
1811
|
+
"trust_change",
|
|
1812
|
+
"visibility_change",
|
|
1813
|
+
"broad_activation",
|
|
1814
|
+
"risky_agent_environment_effect",
|
|
1815
|
+
"rollback"
|
|
1816
|
+
];
|
|
1817
|
+
var ProposalTargetTypes = [
|
|
1818
|
+
"memory",
|
|
1819
|
+
"kit",
|
|
1820
|
+
"agent_environment_policy",
|
|
1821
|
+
"decision",
|
|
1822
|
+
"task",
|
|
1823
|
+
"project_context",
|
|
1824
|
+
"context_relevance",
|
|
1825
|
+
...KitMarketplaceProposalTargetTypes
|
|
1826
|
+
];
|
|
1827
|
+
var ProposalRiskLevels = ["low", "medium", "high"];
|
|
1828
|
+
var ProposalApprovalPolicyModes = [
|
|
1829
|
+
"auto_approve_low_risk",
|
|
1830
|
+
"require_other_project_member",
|
|
1831
|
+
"require_workspace_owner_or_admin"
|
|
1832
|
+
];
|
|
1833
|
+
var ProposalPolicyViolationCodes = [
|
|
1834
|
+
"autonomous_self_approval",
|
|
1835
|
+
"self_capability_escalation",
|
|
1836
|
+
"missing_required_approval",
|
|
1837
|
+
"unsafe_payload",
|
|
1838
|
+
"target_conflict"
|
|
1839
|
+
];
|
|
1840
|
+
var ProposalPolicyViolationSeverities = ["warning", "blocking"];
|
|
1841
|
+
var ProposalCheckKinds = ["schema", "policy", "preflight", "conflict", "safety"];
|
|
1842
|
+
var ProposalCheckStatuses = ["pending", "passed", "failed", "warning", "skipped"];
|
|
1843
|
+
var ProposalApplicationActions = ["applied", "rejected", "reverted"];
|
|
1844
|
+
var ProposalRenderedDiffFormats = ["summary", "field_diff", "markdown"];
|
|
1845
|
+
var ProposalRenderedDiffSectionRisks = ["low", "medium", "high"];
|
|
1846
|
+
var ProposalRenderedDiffRefKinds = [
|
|
1847
|
+
"memory",
|
|
1848
|
+
"kit",
|
|
1849
|
+
"loop",
|
|
1850
|
+
"agent",
|
|
1851
|
+
"agent_environment_policy",
|
|
1852
|
+
"decision",
|
|
1853
|
+
"task",
|
|
1854
|
+
"project_context",
|
|
1855
|
+
"context_relevance",
|
|
1856
|
+
...KitMarketplaceProposalTargetTypes,
|
|
1857
|
+
"session",
|
|
1858
|
+
"step_attempt",
|
|
1859
|
+
"change_request"
|
|
1860
|
+
];
|
|
1861
|
+
var ForbiddenProposalNormalizedKeys = [
|
|
1862
|
+
"raw_code",
|
|
1863
|
+
"source_code",
|
|
1864
|
+
"raw_source",
|
|
1865
|
+
"source_snapshot",
|
|
1866
|
+
"source_archive",
|
|
1867
|
+
"file_content",
|
|
1868
|
+
"raw_diff",
|
|
1869
|
+
"diff",
|
|
1870
|
+
"patch",
|
|
1871
|
+
"raw_patch",
|
|
1872
|
+
"raw_log",
|
|
1873
|
+
"raw_logs",
|
|
1874
|
+
"terminal_log",
|
|
1875
|
+
"raw_terminal_log",
|
|
1876
|
+
"stdout",
|
|
1877
|
+
"stderr",
|
|
1878
|
+
"raw_stdout",
|
|
1879
|
+
"raw_stderr",
|
|
1880
|
+
"transcript",
|
|
1881
|
+
"raw_transcript",
|
|
1882
|
+
"raw_provider_payload",
|
|
1883
|
+
"provider_payload",
|
|
1884
|
+
"provider_webhook_payload",
|
|
1885
|
+
"raw_webhook",
|
|
1886
|
+
"provider_comment_body",
|
|
1887
|
+
"comment_body",
|
|
1888
|
+
"raw_comment",
|
|
1889
|
+
"raw_comments",
|
|
1890
|
+
"token",
|
|
1891
|
+
"access_token",
|
|
1892
|
+
"refresh_token",
|
|
1893
|
+
"password",
|
|
1894
|
+
"private_key",
|
|
1895
|
+
"secret",
|
|
1896
|
+
"secret_value",
|
|
1897
|
+
"client_secret",
|
|
1898
|
+
"api_key",
|
|
1899
|
+
"authorization",
|
|
1900
|
+
"cookie",
|
|
1901
|
+
"durable_asset_url",
|
|
1902
|
+
"asset_url",
|
|
1903
|
+
"download_url",
|
|
1904
|
+
"upload_url",
|
|
1905
|
+
"presigned_url",
|
|
1906
|
+
"signed_url"
|
|
1907
|
+
];
|
|
1908
|
+
var ForbiddenProposalNormalizedKeySet = new Set(ForbiddenProposalNormalizedKeys);
|
|
1909
|
+
var ProposalSafePayloadKeyPattern = `^(?!(?:${proposalForbiddenKeyVariants().map(escapeRegExp).join("|")})$).+$`;
|
|
1910
|
+
var ProposalForbiddenContentPattern = "sk-[A-Za-z0-9_-]{8,}|ghp_[A-Za-z0-9_]+|glpat-[A-Za-z0-9_-]+|\\bBearer\\s+[A-Za-z0-9._~+/=-]+|eyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+|[dD][iI][fF][fF]\\s+--git|[rR][aA][wW]\\s+(?:[tT][eE][rR][mM][iI][nN][aA][lL]\\s+)?[lL][oO][gG]s?|[tT][eE][rR][mM][iI][nN][aA][lL]\\s+[oO][uU][tT][pP][uU][tT]|[rR][aA][wW]\\s+[tT][rR][aA][nN][sS][cC][rR][iI][pP][tT]s?|[sS][oO][uU][rR][cC][eE]\\s+[cC][oO][dD][eE]|[fF][iI][lL][eE]\\s+[cC][oO][nN][tT][eE][nN][tT]";
|
|
1911
|
+
var ProposalSafeStringPattern = `^(?!.*(?:${ProposalForbiddenContentPattern})).*$`;
|
|
1912
|
+
var ProposalStatus = Schema11.Literals(ProposalStatuses);
|
|
1913
|
+
var ProposalTargetType = Schema11.Literals(ProposalTargetTypes);
|
|
1914
|
+
var ProposalRiskLevel = Schema11.Literals(ProposalRiskLevels);
|
|
1915
|
+
var ProposalApprovalPolicyMode = Schema11.Literals(ProposalApprovalPolicyModes);
|
|
1916
|
+
var ProposalPolicyViolationCode = Schema11.Literals(ProposalPolicyViolationCodes);
|
|
1917
|
+
var ProposalPolicyViolationSeverity = Schema11.Literals(ProposalPolicyViolationSeverities);
|
|
1918
|
+
var ProposalCheckKind = Schema11.Literals(ProposalCheckKinds);
|
|
1919
|
+
var ProposalCheckStatus = Schema11.Literals(ProposalCheckStatuses);
|
|
1920
|
+
var ProposalApplicationAction = Schema11.Literals(ProposalApplicationActions);
|
|
1921
|
+
var ProposalRenderedDiffFormat = Schema11.Literals(ProposalRenderedDiffFormats);
|
|
1922
|
+
var ProposalRenderedDiffSectionRisk = Schema11.Literals(ProposalRenderedDiffSectionRisks);
|
|
1923
|
+
var ProposalRenderedDiffRefKind = Schema11.Literals(ProposalRenderedDiffRefKinds);
|
|
1924
|
+
var ProposalSafeString = Schema11.String.check(Schema11.isMaxLength(4000), Schema11.isPattern(new RegExp(ProposalSafeStringPattern, "u")));
|
|
1925
|
+
var ProposalSafeMetadataScalar = Schema11.Union([ProposalSafeString, Schema11.Finite, Schema11.Boolean, Schema11.Null]);
|
|
1926
|
+
var ProposalSafeMetadataValue = Schema11.Union([
|
|
1927
|
+
ProposalSafeMetadataScalar,
|
|
1928
|
+
Schema11.Array(ProposalSafeMetadataScalar).check(Schema11.isMaxLength(100))
|
|
1929
|
+
]);
|
|
1930
|
+
var ProposalSafeMetadata = Schema11.Record(Schema11.String.check(Schema11.isMinLength(1), Schema11.isPattern(new RegExp(ProposalSafePayloadKeyPattern, "u"))), ProposalSafeMetadataValue);
|
|
1931
|
+
var ProposalPayload = Schema11.Struct({
|
|
1932
|
+
memory: Schema11.optionalKey(ProposalSafeMetadata),
|
|
1933
|
+
kit: Schema11.optionalKey(ProposalSafeMetadata),
|
|
1934
|
+
kit_source: Schema11.optionalKey(ProposalSafeMetadata),
|
|
1935
|
+
kit_version: Schema11.optionalKey(ProposalSafeMetadata),
|
|
1936
|
+
kit_installation: Schema11.optionalKey(ProposalSafeMetadata),
|
|
1937
|
+
kit_activation: Schema11.optionalKey(ProposalSafeMetadata),
|
|
1938
|
+
kit_trust_policy: Schema11.optionalKey(ProposalSafeMetadata),
|
|
1939
|
+
agent_environment_policy: Schema11.optionalKey(ProposalSafeMetadata),
|
|
1940
|
+
decision: Schema11.optionalKey(ProposalSafeMetadata),
|
|
1941
|
+
task: Schema11.optionalKey(ProposalSafeMetadata),
|
|
1942
|
+
project_context: Schema11.optionalKey(ProposalSafeMetadata),
|
|
1943
|
+
context_relevance: Schema11.optionalKey(ProposalSafeMetadata)
|
|
1944
|
+
});
|
|
1945
|
+
var ProposalTargetRef = Schema11.Struct({
|
|
1946
|
+
type: ProposalTargetType,
|
|
1947
|
+
id: Schema11.optionalKey(Id),
|
|
1948
|
+
scopeType: Schema11.optionalKey(Schema11.Union([
|
|
1949
|
+
Schema11.Literal("workspace"),
|
|
1950
|
+
Schema11.Literal("project"),
|
|
1951
|
+
Schema11.Literal("task"),
|
|
1952
|
+
Schema11.Literal("kit")
|
|
1953
|
+
])),
|
|
1954
|
+
scopeId: Schema11.optionalKey(Id)
|
|
1955
|
+
});
|
|
1956
|
+
var ProposalApprovalPolicy = Schema11.Struct({
|
|
1957
|
+
mode: ProposalApprovalPolicyMode,
|
|
1958
|
+
requireDifferentApprover: Schema11.optionalKey(Schema11.Boolean),
|
|
1959
|
+
autonomousAgentApprovalAllowed: Schema11.Literal(false),
|
|
1960
|
+
deniedViolationCodes: Schema11.Array(ProposalPolicyViolationCode)
|
|
1961
|
+
});
|
|
1962
|
+
var ProposalPolicyViolation = Schema11.Struct({
|
|
1963
|
+
code: ProposalPolicyViolationCode,
|
|
1964
|
+
severity: ProposalPolicyViolationSeverity,
|
|
1965
|
+
message: ProposalSafeString,
|
|
1966
|
+
actorId: Schema11.optionalKey(Id),
|
|
1967
|
+
target: Schema11.optionalKey(ProposalTargetRef),
|
|
1968
|
+
metadata: Schema11.optionalKey(ProposalSafeMetadata)
|
|
1969
|
+
});
|
|
1970
|
+
var ProposalRenderedDiffRef = Schema11.Struct({
|
|
1971
|
+
kind: ProposalRenderedDiffRefKind,
|
|
1972
|
+
id: Schema11.optionalKey(Id),
|
|
1973
|
+
externalId: Schema11.optionalKey(Schema11.String.check(Schema11.isMinLength(1))),
|
|
1974
|
+
url: Schema11.optionalKey(Schema11.String.check(Schema11.isMinLength(1))),
|
|
1975
|
+
title: Schema11.optionalKey(Schema11.String.check(Schema11.isMinLength(1), Schema11.isMaxLength(240)))
|
|
1976
|
+
});
|
|
1977
|
+
var ProposalRenderedDiffSection = Schema11.Struct({
|
|
1978
|
+
title: Schema11.String.check(Schema11.isMinLength(1), Schema11.isMaxLength(240), Schema11.isPattern(new RegExp(ProposalSafeStringPattern, "u"))),
|
|
1979
|
+
beforeSummary: Schema11.optionalKey(ProposalSafeString),
|
|
1980
|
+
afterSummary: Schema11.optionalKey(ProposalSafeString),
|
|
1981
|
+
risk: ProposalRenderedDiffSectionRisk
|
|
1982
|
+
});
|
|
1983
|
+
var ProposalRenderedDiff = Schema11.Struct({
|
|
1984
|
+
format: ProposalRenderedDiffFormat,
|
|
1985
|
+
title: Schema11.String.check(Schema11.isMinLength(1), Schema11.isMaxLength(240), Schema11.isPattern(new RegExp(ProposalSafeStringPattern, "u"))),
|
|
1986
|
+
summary: ProposalSafeString,
|
|
1987
|
+
sections: Schema11.Array(ProposalRenderedDiffSection),
|
|
1988
|
+
refs: Schema11.Array(ProposalRenderedDiffRef)
|
|
1989
|
+
});
|
|
1990
|
+
var ProposalRiskSummary = Schema11.Struct({
|
|
1991
|
+
level: ProposalRiskLevel,
|
|
1992
|
+
summary: ProposalSafeString,
|
|
1993
|
+
reasons: Schema11.Array(ProposalSafeString)
|
|
1994
|
+
});
|
|
1995
|
+
var KitMarketplaceProposalAction = Schema11.Literals(KitMarketplaceProposalActions);
|
|
1996
|
+
var KitMarketplaceProposalReview = Schema11.Struct({
|
|
1997
|
+
action: KitMarketplaceProposalAction,
|
|
1998
|
+
target: ProposalTargetRef,
|
|
1999
|
+
payload: ProposalPayload,
|
|
2000
|
+
renderedDiff: ProposalRenderedDiff,
|
|
2001
|
+
riskSummary: ProposalRiskSummary,
|
|
2002
|
+
validationFindings: Schema11.Array(ProposalPolicyViolation),
|
|
2003
|
+
approvalPolicy: ProposalApprovalPolicy
|
|
2004
|
+
});
|
|
2005
|
+
var Proposal = Schema11.Struct({
|
|
2006
|
+
id: Id,
|
|
2007
|
+
workspaceId: Id,
|
|
2008
|
+
projectId: Schema11.optionalKey(Id),
|
|
2009
|
+
taskId: Schema11.optionalKey(Id),
|
|
2010
|
+
target: ProposalTargetRef,
|
|
2011
|
+
title: Schema11.String.check(Schema11.isMinLength(1), Schema11.isMaxLength(240), Schema11.isPattern(new RegExp(ProposalSafeStringPattern, "u"))),
|
|
2012
|
+
summary: ProposalSafeString,
|
|
2013
|
+
status: ProposalStatus,
|
|
2014
|
+
riskLevel: ProposalRiskLevel,
|
|
2015
|
+
approvalPolicy: ProposalApprovalPolicy,
|
|
2016
|
+
proposedByActorType: ActorType,
|
|
2017
|
+
proposedByActorId: Id,
|
|
2018
|
+
delegatedByUserId: Schema11.optionalKey(Id),
|
|
2019
|
+
createdAt: Timestamp,
|
|
2020
|
+
updatedAt: Timestamp
|
|
2021
|
+
});
|
|
2022
|
+
var ProposalRevision = Schema11.Struct({
|
|
2023
|
+
id: Id,
|
|
2024
|
+
proposalId: Id,
|
|
2025
|
+
revisionNumber: Schema11.Int.check(Schema11.isGreaterThanOrEqualTo(1)),
|
|
2026
|
+
payload: ProposalPayload,
|
|
2027
|
+
renderedDiff: ProposalRenderedDiff,
|
|
2028
|
+
riskSummary: ProposalRiskSummary,
|
|
2029
|
+
createdByActorType: ActorType,
|
|
2030
|
+
createdByActorId: Id,
|
|
2031
|
+
createdAt: Timestamp
|
|
2032
|
+
});
|
|
2033
|
+
var ProposalCommentAnchor = Schema11.Struct({
|
|
2034
|
+
path: Schema11.Array(Schema11.String.check(Schema11.isMinLength(1), Schema11.isPattern(new RegExp(ProposalSafePayloadKeyPattern, "u")))),
|
|
2035
|
+
label: Schema11.optionalKey(Schema11.String.check(Schema11.isMinLength(1), Schema11.isMaxLength(120), Schema11.isPattern(new RegExp(ProposalSafeStringPattern, "u"))))
|
|
2036
|
+
});
|
|
2037
|
+
var ProposalComment = Schema11.Struct({
|
|
2038
|
+
id: Id,
|
|
2039
|
+
proposalId: Id,
|
|
2040
|
+
revisionId: Schema11.optionalKey(Id),
|
|
2041
|
+
body: ProposalSafeString,
|
|
2042
|
+
anchor: Schema11.optionalKey(ProposalCommentAnchor),
|
|
2043
|
+
actorType: ActorType,
|
|
2044
|
+
actorId: Id,
|
|
2045
|
+
delegatedByUserId: Schema11.optionalKey(Id),
|
|
2046
|
+
createdAt: Timestamp
|
|
2047
|
+
});
|
|
2048
|
+
var ProposalCheck = Schema11.Struct({
|
|
2049
|
+
id: Id,
|
|
2050
|
+
proposalId: Id,
|
|
2051
|
+
revisionId: Schema11.optionalKey(Id),
|
|
2052
|
+
kind: ProposalCheckKind,
|
|
2053
|
+
status: ProposalCheckStatus,
|
|
2054
|
+
summary: ProposalSafeString,
|
|
2055
|
+
details: Schema11.optionalKey(ProposalSafeMetadata),
|
|
2056
|
+
createdAt: Timestamp
|
|
2057
|
+
});
|
|
2058
|
+
var ProposalApplication = Schema11.Struct({
|
|
2059
|
+
id: Id,
|
|
2060
|
+
proposalId: Id,
|
|
2061
|
+
revisionId: Id,
|
|
2062
|
+
action: ProposalApplicationAction,
|
|
2063
|
+
target: ProposalTargetRef,
|
|
2064
|
+
appliedByActorType: ActorType,
|
|
2065
|
+
appliedByActorId: Id,
|
|
2066
|
+
targetVersionBefore: Schema11.optionalKey(Schema11.String.check(Schema11.isMinLength(1), Schema11.isMaxLength(240), Schema11.isPattern(new RegExp(ProposalSafeStringPattern, "u")))),
|
|
2067
|
+
targetVersionAfter: Schema11.optionalKey(Schema11.String.check(Schema11.isMinLength(1), Schema11.isMaxLength(240), Schema11.isPattern(new RegExp(ProposalSafeStringPattern, "u")))),
|
|
2068
|
+
rollbackRef: Schema11.optionalKey(Schema11.String.check(Schema11.isMinLength(1), Schema11.isMaxLength(240), Schema11.isPattern(new RegExp(ProposalSafeStringPattern, "u")))),
|
|
2069
|
+
appliedAt: Timestamp
|
|
2070
|
+
});
|
|
2071
|
+
function proposalForbiddenKeyVariants() {
|
|
2072
|
+
return ForbiddenProposalNormalizedKeys.flatMap((key) => {
|
|
2073
|
+
const camel = key.replace(/_([a-z])/g, (_match, letter) => letter.toUpperCase());
|
|
2074
|
+
const kebab = key.replaceAll("_", "-");
|
|
2075
|
+
return [key, camel, kebab];
|
|
2076
|
+
});
|
|
2077
|
+
}
|
|
2078
|
+
function escapeRegExp(value) {
|
|
2079
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
// packages/core/src/loop.ts
|
|
2083
|
+
var LoopStatuses = ["draft", "active", "disabled", "archived"];
|
|
2084
|
+
var LoopStepImplementationKinds = [
|
|
2085
|
+
"built_in_action",
|
|
2086
|
+
"agent",
|
|
2087
|
+
"wait_for_event",
|
|
2088
|
+
"human_approval",
|
|
2089
|
+
"runner_sandbox",
|
|
2090
|
+
"package_ref",
|
|
2091
|
+
"repeat_until",
|
|
2092
|
+
"call_loop"
|
|
2093
|
+
];
|
|
2094
|
+
var RunStatuses = ["pending", "running", "blocked", "completed", "failed", "canceled", "expired"];
|
|
2095
|
+
var RunStepStatuses = [
|
|
2096
|
+
"pending",
|
|
2097
|
+
"running",
|
|
2098
|
+
"waiting",
|
|
2099
|
+
"blocked",
|
|
2100
|
+
"completed",
|
|
2101
|
+
"failed",
|
|
2102
|
+
"skipped",
|
|
2103
|
+
"canceled"
|
|
2104
|
+
];
|
|
2105
|
+
var StepAttemptStatuses = [
|
|
2106
|
+
"pending",
|
|
2107
|
+
"running",
|
|
2108
|
+
"waiting",
|
|
2109
|
+
"blocked",
|
|
2110
|
+
"completed",
|
|
2111
|
+
"failed",
|
|
2112
|
+
"canceled"
|
|
2113
|
+
];
|
|
2114
|
+
var QuestionStatuses = [
|
|
2115
|
+
"open",
|
|
2116
|
+
"answered",
|
|
2117
|
+
"resume_requested",
|
|
2118
|
+
"resumed",
|
|
2119
|
+
"resume_failed",
|
|
2120
|
+
"expired",
|
|
2121
|
+
"cancelled"
|
|
2122
|
+
];
|
|
2123
|
+
var LoopGuardSources = [
|
|
2124
|
+
"trigger_event",
|
|
2125
|
+
"task",
|
|
2126
|
+
"project",
|
|
2127
|
+
"proposal",
|
|
2128
|
+
"decision",
|
|
2129
|
+
"step_attempt",
|
|
2130
|
+
"change_request",
|
|
2131
|
+
"context_feedback",
|
|
2132
|
+
"run",
|
|
2133
|
+
"project_policy"
|
|
2134
|
+
];
|
|
2135
|
+
var LoopSourceModes = ["direct", "git_backed"];
|
|
2136
|
+
var LoopGuardOperators = ["equals", "not_equals", "in", "not_in", "exists", "not_exists"];
|
|
2137
|
+
var LoopCapabilityScopeKinds = [
|
|
2138
|
+
"workspace",
|
|
2139
|
+
"project",
|
|
2140
|
+
"task",
|
|
2141
|
+
"change_request",
|
|
2142
|
+
"step_attempt",
|
|
2143
|
+
"run",
|
|
2144
|
+
"repo_binding",
|
|
2145
|
+
"provider_host"
|
|
2146
|
+
];
|
|
2147
|
+
var LoopRetryBackoffKinds = ["none", "fixed", "exponential"];
|
|
2148
|
+
var LoopRequiredRunStepStatuses = [
|
|
2149
|
+
"pending",
|
|
2150
|
+
"running",
|
|
2151
|
+
"waiting",
|
|
2152
|
+
"blocked",
|
|
2153
|
+
"completed",
|
|
2154
|
+
"failed",
|
|
2155
|
+
"canceled"
|
|
2156
|
+
];
|
|
2157
|
+
var LoopSafeRefKinds = [
|
|
2158
|
+
"task",
|
|
2159
|
+
"kit",
|
|
2160
|
+
"memory",
|
|
2161
|
+
"decision",
|
|
2162
|
+
"knowledge_record",
|
|
2163
|
+
"context_pack",
|
|
2164
|
+
"step_attempt",
|
|
2165
|
+
"change_request",
|
|
2166
|
+
"change_request_review",
|
|
2167
|
+
"provider_action",
|
|
2168
|
+
"thread_entry",
|
|
2169
|
+
"run",
|
|
2170
|
+
"artifact"
|
|
2171
|
+
];
|
|
2172
|
+
var LoopBaseCapabilityKinds = [
|
|
2173
|
+
"read_task",
|
|
2174
|
+
"read_repo_binding",
|
|
2175
|
+
"read_agent_environment",
|
|
2176
|
+
"read_kit",
|
|
2177
|
+
"update_task_status",
|
|
2178
|
+
"read_change_request",
|
|
2179
|
+
"read_change_request_review",
|
|
2180
|
+
"read_task_link",
|
|
2181
|
+
"refresh_change_request_metadata",
|
|
2182
|
+
"record_change_request_review",
|
|
2183
|
+
"record_session_update",
|
|
2184
|
+
"create_task_link",
|
|
2185
|
+
"create_task_dependency",
|
|
2186
|
+
"create_task_asset",
|
|
2187
|
+
"create_follow_up_task",
|
|
2188
|
+
"execute_agent",
|
|
2189
|
+
"read_step_attempt",
|
|
2190
|
+
"record_task_thread_entry",
|
|
2191
|
+
"write_provider_repository",
|
|
2192
|
+
"write_provider_change_request",
|
|
2193
|
+
"publish_provider_check",
|
|
2194
|
+
"write_provider_comment",
|
|
2195
|
+
"request_provider_changes",
|
|
2196
|
+
"approve_provider_change_request",
|
|
2197
|
+
"merge_provider_change_request",
|
|
2198
|
+
"wait_for_event",
|
|
2199
|
+
"request_human_approval",
|
|
2200
|
+
"execute_package_ref"
|
|
2201
|
+
];
|
|
2202
|
+
var LoopCapabilityKinds = [
|
|
2203
|
+
...LoopBaseCapabilityKinds,
|
|
2204
|
+
"read_context_feedback",
|
|
2205
|
+
"read_session_update",
|
|
2206
|
+
"read_repo_binding",
|
|
2207
|
+
"read_agent_environment",
|
|
2208
|
+
"read_kit",
|
|
2209
|
+
"read_memory",
|
|
2210
|
+
"read_decision",
|
|
2211
|
+
"create_task_dependency",
|
|
2212
|
+
"propose_memory",
|
|
2213
|
+
"propose_kit",
|
|
2214
|
+
"propose_decision",
|
|
2215
|
+
"propose_agent_environment_policy",
|
|
2216
|
+
"propose_project_context",
|
|
2217
|
+
"propose_context_relevance",
|
|
2218
|
+
"execute_runner_sandbox"
|
|
2219
|
+
];
|
|
2220
|
+
var LoopStatus = Schema12.Literals(LoopStatuses);
|
|
2221
|
+
var LoopTriggerEvent = Schema12.String.check(Schema12.isMinLength(3), Schema12.isMaxLength(160), Schema12.isPattern(new RegExp("^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)+$", "u")));
|
|
2222
|
+
var LoopStepImplementationKind = Schema12.Literals(LoopStepImplementationKinds);
|
|
2223
|
+
var RunStatus = Schema12.Literals(RunStatuses);
|
|
2224
|
+
var RunStepStatus = Schema12.Literals(RunStepStatuses);
|
|
2225
|
+
var StepAttemptStatus = Schema12.Literals(StepAttemptStatuses);
|
|
2226
|
+
var QuestionStatus = Schema12.Literals(QuestionStatuses);
|
|
2227
|
+
var LoopGuardSource = Schema12.Literals(LoopGuardSources);
|
|
2228
|
+
var LoopSourceMode = Schema12.Literals(LoopSourceModes);
|
|
2229
|
+
var LoopCapabilityKind = Schema12.Literals(LoopCapabilityKinds);
|
|
2230
|
+
var LoopGuardOperator = Schema12.Literals(LoopGuardOperators);
|
|
2231
|
+
var LoopCapabilityScopeKind = Schema12.Literals(LoopCapabilityScopeKinds);
|
|
2232
|
+
var LoopRetryBackoffKind = Schema12.Literals(LoopRetryBackoffKinds);
|
|
2233
|
+
var LoopRequiredRunStepStatus = Schema12.Literals(LoopRequiredRunStepStatuses);
|
|
2234
|
+
var LoopSafeRefKind = Schema12.Literals(LoopSafeRefKinds);
|
|
2235
|
+
var LoopSha256 = Schema12.String.check(Schema12.isPattern(new RegExp("^[a-fA-F0-9]{64}$", "u")));
|
|
2236
|
+
var LoopGitCommitSha = Schema12.String.check(Schema12.isPattern(new RegExp("^[a-fA-F0-9]{40}$|^[a-fA-F0-9]{64}$", "u")));
|
|
2237
|
+
var LoopReferenceForbiddenContentPattern = "(?:^|[^A-Za-z0-9])sk-[A-Za-z0-9_-]{16,}|ghp_[A-Za-z0-9_]+|github_pat_[A-Za-z0-9_]+|glpat-[A-Za-z0-9_-]+|\\b[Bb][Ee][Aa][Rr][Ee][Rr]\\s+[A-Za-z0-9._~+/=-]+|eyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+|[dD][iI][fF][fF]\\s+--git|[rR][aA][wW]\\s+(?:[tT][eE][rR][mM][iI][nN][aA][lL]\\s+)?[lL][oO][gG]s?|[tT][eE][rR][mM][iI][nN][aA][lL]\\s+[oO][uU][tT][pP][uU][tT]|[rR][aA][wW]\\s+[tT][rR][aA][nN][sS][cC][rR][iI][pP][tT]s?|[sS][oO][uU][rR][cC][eE]\\s+[cC][oO][dD][eE]|[fF][iI][lL][eE]\\s+[cC][oO][nN][tT][eE][nN][tT]";
|
|
2238
|
+
var LoopReferenceAndUrlForbiddenContentPattern = `${LoopReferenceForbiddenContentPattern}|[A-Za-z][A-Za-z0-9+.-]*://\\S+`;
|
|
2239
|
+
var LoopSafeReferencePattern = `^(?!.*(?:${LoopReferenceAndUrlForbiddenContentPattern})).*$`;
|
|
2240
|
+
var LoopScopeValueForbiddenContentPattern = LoopReferenceAndUrlForbiddenContentPattern;
|
|
2241
|
+
var LoopSafeScopeValuePattern = `^(?!.*(?:${LoopScopeValueForbiddenContentPattern})).*$`;
|
|
2242
|
+
var LoopSafeInternalReferencePattern = `^(?!.*(?:${LoopScopeValueForbiddenContentPattern})).*$`;
|
|
2243
|
+
var LoopForbiddenDataflowKeys = [
|
|
2244
|
+
"raw_code",
|
|
2245
|
+
"source_code",
|
|
2246
|
+
"raw_source",
|
|
2247
|
+
"source_snapshot",
|
|
2248
|
+
"source_archive",
|
|
2249
|
+
"file_content",
|
|
2250
|
+
"raw_diff",
|
|
2251
|
+
"diff",
|
|
2252
|
+
"patch",
|
|
2253
|
+
"raw_patch",
|
|
2254
|
+
"raw_log",
|
|
2255
|
+
"raw_logs",
|
|
2256
|
+
"terminal_log",
|
|
2257
|
+
"raw_terminal_log",
|
|
2258
|
+
"stdout",
|
|
2259
|
+
"stderr",
|
|
2260
|
+
"raw_stdout",
|
|
2261
|
+
"raw_stderr",
|
|
2262
|
+
"transcript",
|
|
2263
|
+
"raw_transcript",
|
|
2264
|
+
"raw_provider_payload",
|
|
2265
|
+
"provider_payload",
|
|
2266
|
+
"provider_webhook_payload",
|
|
2267
|
+
"raw_webhook",
|
|
2268
|
+
"provider_comment_body",
|
|
2269
|
+
"comment_body",
|
|
2270
|
+
"raw_comment",
|
|
2271
|
+
"raw_comments",
|
|
2272
|
+
"token",
|
|
2273
|
+
"access_token",
|
|
2274
|
+
"refresh_token",
|
|
2275
|
+
"password",
|
|
2276
|
+
"private_key",
|
|
2277
|
+
"secret",
|
|
2278
|
+
"secret_value",
|
|
2279
|
+
"client_secret",
|
|
2280
|
+
"api_key",
|
|
2281
|
+
"credential",
|
|
2282
|
+
"credentials",
|
|
2283
|
+
"credential_value",
|
|
2284
|
+
"resolved_value",
|
|
2285
|
+
"authorization",
|
|
2286
|
+
"cookie",
|
|
2287
|
+
"durable_asset_url",
|
|
2288
|
+
"asset_url",
|
|
2289
|
+
"download_url",
|
|
2290
|
+
"upload_url",
|
|
2291
|
+
"presigned_url",
|
|
2292
|
+
"signed_url",
|
|
2293
|
+
"database_url",
|
|
2294
|
+
"connection_string",
|
|
2295
|
+
"postgres_url",
|
|
2296
|
+
"redis_url",
|
|
2297
|
+
"dsn"
|
|
2298
|
+
];
|
|
2299
|
+
var LoopForbiddenDataflowKeyPattern = LoopForbiddenDataflowKeys.map(loopForbiddenKeyPattern).join("|");
|
|
2300
|
+
var LoopForbiddenDataflowKeyRegExp = new RegExp(LoopForbiddenDataflowKeyPattern);
|
|
2301
|
+
var LoopForbiddenContentRegExp = new RegExp(LoopReferenceAndUrlForbiddenContentPattern);
|
|
2302
|
+
var LoopSafeReferenceString = Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(240), Schema12.isPattern(new RegExp(LoopSafeReferencePattern, "u")));
|
|
2303
|
+
var LoopSafeInternalReferenceString = Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(240), Schema12.isPattern(new RegExp(LoopSafeInternalReferencePattern, "u")));
|
|
2304
|
+
var LoopSafeText = Schema12.String.check(Schema12.isMaxLength(4000), Schema12.isPattern(new RegExp(LoopSafeReferencePattern, "u")));
|
|
2305
|
+
var LoopSafeOutputDataString = Schema12.String.check(Schema12.isMaxLength(4000), Schema12.isPattern(new RegExp(LoopSafeInternalReferencePattern, "u")));
|
|
2306
|
+
var LoopSafePackageName = Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(200), Schema12.isPattern(new RegExp(LoopSafeReferencePattern, "u")));
|
|
2307
|
+
var LoopSafeScopeValue = Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(240), Schema12.isPattern(new RegExp(LoopSafeScopeValuePattern, "u")));
|
|
2308
|
+
var LoopSafeKey = Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(120), Schema12.isPattern(new RegExp(`^(?!.*(?:${LoopForbiddenDataflowKeyPattern}))(?!.*(?:${LoopReferenceForbiddenContentPattern}))[A-Za-z0-9][A-Za-z0-9_-]*$`, "u")));
|
|
2309
|
+
var LoopDataflowKey = Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(120), Schema12.isPattern(new RegExp(`^(?!.*(?:${LoopForbiddenDataflowKeyPattern}))(?!.*(?:${LoopReferenceForbiddenContentPattern}))[A-Za-z][A-Za-z0-9]*(?:[_-][A-Za-z0-9]+)*$`, "u")));
|
|
2310
|
+
var LoopDataPathSegment = Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(120), Schema12.isPattern(new RegExp(`^(?!.*(?:${LoopForbiddenDataflowKeyPattern}))(?!.*(?:${LoopReferenceForbiddenContentPattern}))[A-Za-z_][A-Za-z0-9_-]*$`, "u")));
|
|
2311
|
+
var LoopGitRef = Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(240), Schema12.isPattern(new RegExp(`^(?!.*(?:${LoopReferenceForbiddenContentPattern}))(?!@$)(?!.*\\.\\.)(?!.*@\\{)(?!.*//)(?!.*[\\s~^:?*\\[\\\\])(?!.*(?:^|/)\\.)(?!.*(?:^|/)\\.\\.?(?:/|$))(?!.*\\.lock(?:/|$))(?!.*/$)(?!.*\\.$)[A-Za-z0-9][A-Za-z0-9._/-]*$`, "u")));
|
|
2312
|
+
var LoopBundleRef = Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(500), Schema12.isPattern(new RegExp(`^(?!.*(?:${LoopReferenceAndUrlForbiddenContentPattern}))(?!/)(?!.*:)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.\\.?($|/))(?!.*\\s).+$`, "u")));
|
|
2313
|
+
var LoopSourcePath = Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(500), Schema12.isPattern(new RegExp(`^(?!.*(?:${LoopReferenceForbiddenContentPattern}))(?!/)(?!.*:)(?!.*\\\\)(?!.*//)(?!.*(?:^|/)\\.\\.?($|/))(?!.*\\s).+$`, "u")));
|
|
2314
|
+
function loopForbiddenKeyPattern(key) {
|
|
2315
|
+
const words = key.split(/[_-]+/).filter(Boolean);
|
|
2316
|
+
const separated = words.map((word) => loopCaseInsensitiveWordPattern(word)).join("[_-]+");
|
|
2317
|
+
const camel = words.map((word, index) => index === 0 ? loopCaseInsensitiveWordPattern(word) : loopCaseInsensitiveWordPattern(word, true)).join("");
|
|
2318
|
+
return `(?:(?:^|[_-])${separated}(?=$|[_-])|(?:^|[_-]|(?<=[a-z0-9])(?=[A-Z]))${camel}(?=$|[_-]|[A-Z]))`;
|
|
2319
|
+
}
|
|
2320
|
+
function loopCaseInsensitiveWordPattern(word, uppercaseFirst = false) {
|
|
2321
|
+
return Array.from(word).map((char, index) => {
|
|
2322
|
+
const lower = char.toLowerCase();
|
|
2323
|
+
const upper = char.toUpperCase();
|
|
2324
|
+
if (uppercaseFirst && index === 0)
|
|
2325
|
+
return `[${upper}${lower}]`;
|
|
2326
|
+
if (lower !== upper)
|
|
2327
|
+
return `[${lower}${upper}]`;
|
|
2328
|
+
return char.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
|
|
2329
|
+
}).join("");
|
|
2330
|
+
}
|
|
2331
|
+
var LoopDataSchemaRef = Schema12.Struct({
|
|
2332
|
+
kind: Schema12.Literal("typebox_ref"),
|
|
2333
|
+
name: LoopSafeReferenceString,
|
|
2334
|
+
version: Schema12.optionalKey(Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(120), Schema12.isPattern(new RegExp(LoopSafeReferencePattern, "u")))),
|
|
2335
|
+
sha256: Schema12.optionalKey(LoopSha256)
|
|
2336
|
+
});
|
|
2337
|
+
var LoopStepOutputDataValue = Schema12.Union([
|
|
2338
|
+
LoopSafeOutputDataString,
|
|
2339
|
+
Schema12.Finite,
|
|
2340
|
+
Schema12.Boolean,
|
|
2341
|
+
Schema12.Null,
|
|
2342
|
+
Schema12.Array(Schema12.suspend(() => LoopStepOutputDataValue)).check(Schema12.isMaxLength(200)),
|
|
2343
|
+
Schema12.Record(LoopDataPathSegment, Schema12.suspend(() => LoopStepOutputDataValue)).check(Schema12.isMaxProperties(200))
|
|
2344
|
+
]).annotate({ identifier: "LoopStepOutputDataValue" });
|
|
2345
|
+
var LoopSafeMetadata = Schema12.Record(LoopDataPathSegment, LoopStepOutputDataValue);
|
|
2346
|
+
var LoopGuardValue = Schema12.Union([LoopSafeOutputDataString, Schema12.Finite, Schema12.Boolean]);
|
|
2347
|
+
var LoopSafeRef = Schema12.Struct({
|
|
2348
|
+
kind: LoopSafeRefKind,
|
|
2349
|
+
id: Schema12.optionalKey(LoopSafeInternalReferenceString),
|
|
2350
|
+
externalId: Schema12.optionalKey(LoopSafeInternalReferenceString),
|
|
2351
|
+
provider: Schema12.optionalKey(LoopSafeInternalReferenceString),
|
|
2352
|
+
title: Schema12.optionalKey(LoopSafeInternalReferenceString)
|
|
2353
|
+
});
|
|
2354
|
+
var LoopGuard = Schema12.Struct({
|
|
2355
|
+
key: LoopSafeKey,
|
|
2356
|
+
source: LoopGuardSource,
|
|
2357
|
+
path: Schema12.Array(LoopDataPathSegment).check(Schema12.isMinLength(1)),
|
|
2358
|
+
operator: LoopGuardOperator,
|
|
2359
|
+
value: Schema12.optionalKey(LoopGuardValue),
|
|
2360
|
+
values: Schema12.optionalKey(Schema12.Array(LoopGuardValue).check(Schema12.isMinLength(1)))
|
|
2361
|
+
});
|
|
2362
|
+
var LoopCapabilityScope = Schema12.Struct({
|
|
2363
|
+
kind: LoopCapabilityScopeKind,
|
|
2364
|
+
id: Schema12.optionalKey(Id),
|
|
2365
|
+
idRef: Schema12.optionalKey(LoopSafeReferenceString),
|
|
2366
|
+
value: Schema12.optionalKey(LoopSafeScopeValue)
|
|
2367
|
+
});
|
|
2368
|
+
var LoopCapabilityGrant = Schema12.Struct({
|
|
2369
|
+
capability: LoopCapabilityKind,
|
|
2370
|
+
scope: Schema12.optionalKey(LoopCapabilityScope),
|
|
2371
|
+
reason: Schema12.optionalKey(LoopSafeText)
|
|
2372
|
+
});
|
|
2373
|
+
var LoopRequiredContextSlice = Schema12.Struct({
|
|
2374
|
+
kind: ContextPackRetrievalRefKind,
|
|
2375
|
+
id: Schema12.optionalKey(Id),
|
|
2376
|
+
idRef: Schema12.optionalKey(LoopSafeReferenceString),
|
|
2377
|
+
reason: LoopSafeText,
|
|
2378
|
+
required: Schema12.Boolean.pipe(Schema12.withDecodingDefaultKey(Effect.succeed(true)))
|
|
2379
|
+
});
|
|
2380
|
+
var LoopRetryPolicy = Schema12.Struct({
|
|
2381
|
+
maxAttempts: Schema12.Int.check(Schema12.isGreaterThanOrEqualTo(1), Schema12.isLessThanOrEqualTo(20)),
|
|
2382
|
+
backoff: LoopRetryBackoffKind,
|
|
2383
|
+
delaySeconds: Schema12.optionalKey(Schema12.Int.check(Schema12.isGreaterThanOrEqualTo(1), Schema12.isLessThanOrEqualTo(86400)))
|
|
2384
|
+
});
|
|
2385
|
+
var LoopTimeoutPolicy = Schema12.Struct({
|
|
2386
|
+
timeoutSeconds: Schema12.Int.check(Schema12.isGreaterThanOrEqualTo(1), Schema12.isLessThanOrEqualTo(604800))
|
|
2387
|
+
});
|
|
2388
|
+
var LoopDirectSource = Schema12.Struct({
|
|
2389
|
+
mode: Schema12.Literal("direct"),
|
|
2390
|
+
registeredFrom: Schema12.optionalKey(Schema12.Union([Schema12.Literal("api"), Schema12.Literal("cli"), Schema12.Literal("mcp"), Schema12.Literal("import")])),
|
|
2391
|
+
bundleRef: Schema12.optionalKey(LoopBundleRef),
|
|
2392
|
+
bundleSha256: Schema12.optionalKey(LoopSha256),
|
|
2393
|
+
metadata: Schema12.optionalKey(LoopSafeMetadata)
|
|
2394
|
+
});
|
|
2395
|
+
var LoopGitBackedSource = Schema12.Struct({
|
|
2396
|
+
mode: Schema12.Literal("git_backed"),
|
|
2397
|
+
repoBindingId: Id,
|
|
2398
|
+
gitRef: LoopGitRef,
|
|
2399
|
+
commitSha: LoopGitCommitSha,
|
|
2400
|
+
definitionPath: Schema12.optionalKey(LoopSourcePath),
|
|
2401
|
+
packagePath: Schema12.optionalKey(LoopSourcePath),
|
|
2402
|
+
metadata: Schema12.optionalKey(LoopSafeMetadata)
|
|
2403
|
+
});
|
|
2404
|
+
var LoopSource = Schema12.Union([LoopDirectSource, LoopGitBackedSource]);
|
|
2405
|
+
var LoopStepPackageMetadata = Schema12.Struct({
|
|
2406
|
+
packageName: LoopSafePackageName,
|
|
2407
|
+
version: Schema12.optionalKey(Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(120), Schema12.isPattern(new RegExp(LoopSafeReferencePattern, "u")))),
|
|
2408
|
+
entrypoint: LoopSafeReferenceString,
|
|
2409
|
+
source: LoopSource,
|
|
2410
|
+
runtime: Schema12.optionalKey(Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(120), Schema12.isPattern(new RegExp(LoopSafeReferencePattern, "u")))),
|
|
2411
|
+
integritySha256: Schema12.optionalKey(LoopSha256),
|
|
2412
|
+
metadata: Schema12.optionalKey(LoopSafeMetadata)
|
|
2413
|
+
});
|
|
2414
|
+
var LoopStepInputBindingFields = {
|
|
2415
|
+
key: LoopDataflowKey,
|
|
2416
|
+
required: Schema12.optionalKey(Schema12.Boolean)
|
|
2417
|
+
};
|
|
2418
|
+
var LoopStepInputBinding = Schema12.Union([
|
|
2419
|
+
Schema12.Struct({
|
|
2420
|
+
...LoopStepInputBindingFields,
|
|
2421
|
+
source: Schema12.Literal("trigger_event"),
|
|
2422
|
+
path: Schema12.Array(LoopDataPathSegment).check(Schema12.isMinLength(1))
|
|
2423
|
+
}),
|
|
2424
|
+
Schema12.Struct({
|
|
2425
|
+
...LoopStepInputBindingFields,
|
|
2426
|
+
source: Schema12.Literal("subject"),
|
|
2427
|
+
path: Schema12.Array(LoopDataPathSegment).check(Schema12.isMinLength(1))
|
|
2428
|
+
}),
|
|
2429
|
+
Schema12.Struct({
|
|
2430
|
+
...LoopStepInputBindingFields,
|
|
2431
|
+
source: Schema12.Literal("context"),
|
|
2432
|
+
path: Schema12.Array(LoopDataPathSegment).check(Schema12.isMinLength(1))
|
|
2433
|
+
}),
|
|
2434
|
+
Schema12.Struct({
|
|
2435
|
+
...LoopStepInputBindingFields,
|
|
2436
|
+
source: Schema12.Literal("step_output"),
|
|
2437
|
+
stepKey: LoopSafeKey,
|
|
2438
|
+
outputKey: LoopDataflowKey,
|
|
2439
|
+
path: Schema12.optionalKey(Schema12.Array(LoopDataPathSegment).check(Schema12.isMinLength(1)))
|
|
2440
|
+
}),
|
|
2441
|
+
Schema12.Struct({
|
|
2442
|
+
...LoopStepInputBindingFields,
|
|
2443
|
+
source: Schema12.Literal("run"),
|
|
2444
|
+
path: Schema12.Array(LoopDataPathSegment).check(Schema12.isMinLength(1))
|
|
2445
|
+
}),
|
|
2446
|
+
Schema12.Struct({
|
|
2447
|
+
...LoopStepInputBindingFields,
|
|
2448
|
+
source: Schema12.Literal("literal"),
|
|
2449
|
+
value: LoopStepOutputDataValue
|
|
2450
|
+
})
|
|
2451
|
+
]);
|
|
2452
|
+
var LoopStepOutputRef = Schema12.Struct({
|
|
2453
|
+
key: LoopDataflowKey,
|
|
2454
|
+
schemaRef: Schema12.optionalKey(LoopDataSchemaRef),
|
|
2455
|
+
path: Schema12.optionalKey(Schema12.Array(LoopDataPathSegment).check(Schema12.isMinLength(1))),
|
|
2456
|
+
required: Schema12.optionalKey(Schema12.Boolean)
|
|
2457
|
+
});
|
|
2458
|
+
var LoopBuiltInActionStepImplementation = Schema12.Struct({
|
|
2459
|
+
kind: Schema12.Literal("built_in_action"),
|
|
2460
|
+
action: LoopSafeReferenceString,
|
|
2461
|
+
input: Schema12.optionalKey(LoopSafeMetadata)
|
|
2462
|
+
});
|
|
2463
|
+
var LoopAgentRuntimeComponentSelector = Schema12.Struct({
|
|
2464
|
+
implementation: LoopSafeReferenceString,
|
|
2465
|
+
kind: Schema12.Union([Schema12.Literal("preferred"), Schema12.Literal("required")])
|
|
2466
|
+
});
|
|
2467
|
+
var LoopAgentStepImplementation = Schema12.Struct({
|
|
2468
|
+
kind: Schema12.Literal("agent"),
|
|
2469
|
+
taskIdRef: LoopSafeReferenceString,
|
|
2470
|
+
agentId: Id,
|
|
2471
|
+
agentRef: Schema12.optionalKey(AgentReference),
|
|
2472
|
+
runtimeKind: Schema12.optionalKey(LoopSafeReferenceString),
|
|
2473
|
+
harness: Schema12.optionalKey(LoopAgentRuntimeComponentSelector),
|
|
2474
|
+
sandbox: Schema12.optionalKey(LoopAgentRuntimeComponentSelector),
|
|
2475
|
+
models: Schema12.optionalKey(Schema12.Array(AgentModelSelector).check(Schema12.isMinLength(1), Schema12.isMaxLength(20))),
|
|
2476
|
+
extensions: Schema12.optionalKey(Schema12.Array(NativeExtensionRef).check(Schema12.isMaxLength(20)))
|
|
2477
|
+
});
|
|
2478
|
+
var LoopWaitForEventStepImplementation = Schema12.Struct({
|
|
2479
|
+
kind: Schema12.Literal("wait_for_event"),
|
|
2480
|
+
event: LoopTriggerEvent,
|
|
2481
|
+
anyOf: Schema12.optionalKey(Schema12.Array(LoopTriggerEvent).check(Schema12.isMinLength(1))),
|
|
2482
|
+
correlationPath: Schema12.Array(LoopDataPathSegment).check(Schema12.isMinLength(1)),
|
|
2483
|
+
authPolicy: Schema12.optionalKey(Schema12.Struct({
|
|
2484
|
+
mode: Schema12.Union([Schema12.Literal("trusted_source"), Schema12.Literal("actor")]),
|
|
2485
|
+
capability: Schema12.optionalKey(LoopSafeReferenceString)
|
|
2486
|
+
})),
|
|
2487
|
+
cancellation: Schema12.optionalKey(Schema12.Union([Schema12.Literal("cancel"), Schema12.Literal("timeout")])),
|
|
2488
|
+
releaseRunner: Schema12.optionalKey(Schema12.Boolean)
|
|
2489
|
+
});
|
|
2490
|
+
var LoopHumanApprovalStepImplementation = Schema12.Struct({
|
|
2491
|
+
kind: Schema12.Literal("human_approval"),
|
|
2492
|
+
prompt: LoopSafeText,
|
|
2493
|
+
approvalPolicy: ProposalApprovalPolicy
|
|
2494
|
+
});
|
|
2495
|
+
var LoopRunnerSandboxStepImplementation = Schema12.Struct({
|
|
2496
|
+
kind: Schema12.Literal("runner_sandbox"),
|
|
2497
|
+
runnerSelector: LoopSafeMetadata,
|
|
2498
|
+
entrypoint: LoopSafeReferenceString,
|
|
2499
|
+
package: Schema12.optionalKey(LoopStepPackageMetadata)
|
|
2500
|
+
});
|
|
2501
|
+
var LoopPackageRefStepImplementation = Schema12.Struct({
|
|
2502
|
+
kind: Schema12.Literal("package_ref"),
|
|
2503
|
+
package: LoopStepPackageMetadata
|
|
2504
|
+
});
|
|
2505
|
+
var LoopCallStepImplementation = Schema12.Struct({
|
|
2506
|
+
kind: Schema12.Literal("call_loop"),
|
|
2507
|
+
loop: LoopReferenceSchema,
|
|
2508
|
+
mode: Schema12.Literal("awaited")
|
|
2509
|
+
});
|
|
2510
|
+
var LoopConcreteActionImplementation = Schema12.Union([
|
|
2511
|
+
LoopBuiltInActionStepImplementation,
|
|
2512
|
+
LoopAgentStepImplementation,
|
|
2513
|
+
LoopWaitForEventStepImplementation,
|
|
2514
|
+
LoopHumanApprovalStepImplementation,
|
|
2515
|
+
LoopRunnerSandboxStepImplementation,
|
|
2516
|
+
LoopPackageRefStepImplementation
|
|
2517
|
+
]);
|
|
2518
|
+
var LoopRepeatUntilSafetyPolicy = Schema12.Struct({
|
|
2519
|
+
maxIterations: Schema12.Int.check(Schema12.isGreaterThanOrEqualTo(1), Schema12.isLessThanOrEqualTo(1000)),
|
|
2520
|
+
timeoutSeconds: Schema12.optionalKey(Schema12.Int.check(Schema12.isGreaterThanOrEqualTo(1), Schema12.isLessThanOrEqualTo(604800)))
|
|
2521
|
+
});
|
|
2522
|
+
var LoopRepeatUntilStepImplementation = Schema12.Struct({
|
|
2523
|
+
kind: Schema12.Literal("repeat_until"),
|
|
2524
|
+
body: LoopConcreteActionImplementation,
|
|
2525
|
+
convergenceOutput: LoopDataflowKey,
|
|
2526
|
+
safetyPolicy: LoopRepeatUntilSafetyPolicy
|
|
2527
|
+
});
|
|
2528
|
+
var LoopStepImplementation = Schema12.Union([
|
|
2529
|
+
LoopConcreteActionImplementation,
|
|
2530
|
+
LoopRepeatUntilStepImplementation,
|
|
2531
|
+
LoopCallStepImplementation
|
|
2532
|
+
]);
|
|
2533
|
+
var LoopStep = Schema12.Struct({
|
|
2534
|
+
key: LoopSafeKey,
|
|
2535
|
+
title: LoopSafeReferenceString,
|
|
2536
|
+
required: Schema12.Boolean.pipe(Schema12.withDecodingDefaultKey(Effect.succeed(true))),
|
|
2537
|
+
dependsOn: Schema12.Array(LoopSafeKey),
|
|
2538
|
+
requiredContext: Schema12.Array(LoopRequiredContextSlice),
|
|
2539
|
+
guards: Schema12.Array(LoopGuard),
|
|
2540
|
+
implementation: LoopStepImplementation,
|
|
2541
|
+
inputSchemaRef: LoopDataSchemaRef,
|
|
2542
|
+
outputSchemaRef: LoopDataSchemaRef,
|
|
2543
|
+
inputBindings: Schema12.Array(LoopStepInputBinding),
|
|
2544
|
+
outputRefs: Schema12.Array(LoopStepOutputRef),
|
|
2545
|
+
allowedCapabilities: Schema12.Array(LoopCapabilityGrant),
|
|
2546
|
+
retryPolicy: LoopRetryPolicy,
|
|
2547
|
+
timeoutPolicy: LoopTimeoutPolicy,
|
|
2548
|
+
metadata: LoopSafeMetadata
|
|
2549
|
+
});
|
|
2550
|
+
var LoopStepOutput = Schema12.Struct({
|
|
2551
|
+
stepKey: LoopSafeKey,
|
|
2552
|
+
outputSchemaRef: LoopDataSchemaRef,
|
|
2553
|
+
summary: LoopSafeText,
|
|
2554
|
+
data: Schema12.Record(LoopDataflowKey, LoopStepOutputDataValue).check(Schema12.isMinProperties(1)),
|
|
2555
|
+
metadata: Schema12.optionalKey(LoopSafeMetadata),
|
|
2556
|
+
refs: Schema12.Array(LoopSafeRef)
|
|
2557
|
+
});
|
|
2558
|
+
var RunStepStateFields = {
|
|
2559
|
+
stepKey: Schema12.String.check(Schema12.isMinLength(1)),
|
|
2560
|
+
sequence: Schema12.Int.check(Schema12.isGreaterThanOrEqualTo(0)),
|
|
2561
|
+
attempts: Schema12.Int.check(Schema12.isGreaterThanOrEqualTo(0)),
|
|
2562
|
+
stepAttemptId: Schema12.optionalKey(Id),
|
|
2563
|
+
startedAt: Schema12.optionalKey(Timestamp),
|
|
2564
|
+
endedAt: Schema12.optionalKey(Timestamp),
|
|
2565
|
+
output: Schema12.optionalKey(LoopStepOutput),
|
|
2566
|
+
failureSummary: Schema12.optionalKey(LoopSafeText),
|
|
2567
|
+
updatedAt: Timestamp
|
|
2568
|
+
};
|
|
2569
|
+
var RunStepState = Schema12.Union([
|
|
2570
|
+
Schema12.Struct({
|
|
2571
|
+
...RunStepStateFields,
|
|
2572
|
+
required: Schema12.Literal(true),
|
|
2573
|
+
status: LoopRequiredRunStepStatus
|
|
2574
|
+
}),
|
|
2575
|
+
Schema12.Struct({
|
|
2576
|
+
...RunStepStateFields,
|
|
2577
|
+
required: Schema12.Literal(false),
|
|
2578
|
+
status: RunStepStatus
|
|
2579
|
+
})
|
|
2580
|
+
]);
|
|
2581
|
+
var RunState = Schema12.Struct({
|
|
2582
|
+
stepStates: Schema12.Array(RunStepState),
|
|
2583
|
+
summary: Schema12.optionalKey(LoopSafeText),
|
|
2584
|
+
resultMetadata: LoopSafeMetadata
|
|
2585
|
+
});
|
|
2586
|
+
var RunTrigger = Schema12.Struct({
|
|
2587
|
+
event: LoopSafeReferenceString,
|
|
2588
|
+
eventId: Id,
|
|
2589
|
+
subject: Schema12.optionalKey(RunResourceRef),
|
|
2590
|
+
occurredAt: Timestamp,
|
|
2591
|
+
metadata: LoopSafeMetadata
|
|
2592
|
+
});
|
|
2593
|
+
var RunWaiting = Schema12.Union([
|
|
2594
|
+
Schema12.Struct({ kind: Schema12.Literal("question"), name: Schema12.String.check(Schema12.isMinLength(1)), questionId: Id }),
|
|
2595
|
+
Schema12.Struct({
|
|
2596
|
+
kind: Schema12.Literal("clock"),
|
|
2597
|
+
name: Schema12.String.check(Schema12.isMinLength(1)),
|
|
2598
|
+
firesAt: Timestamp
|
|
2599
|
+
}),
|
|
2600
|
+
Schema12.Struct({
|
|
2601
|
+
kind: Schema12.Literal("event"),
|
|
2602
|
+
name: Schema12.String.check(Schema12.isMinLength(1)),
|
|
2603
|
+
event: Schema12.String.check(Schema12.isMinLength(1)),
|
|
2604
|
+
timesOutAt: Timestamp
|
|
2605
|
+
}),
|
|
2606
|
+
Schema12.Struct({ kind: Schema12.Literal("step"), name: Schema12.String.check(Schema12.isMinLength(1)), stepAttemptId: Id }),
|
|
2607
|
+
Schema12.Struct({ kind: Schema12.Literal("child"), name: Schema12.String.check(Schema12.isMinLength(1)), runId: Id }),
|
|
2608
|
+
Schema12.Struct({
|
|
2609
|
+
kind: Schema12.Literal("verification"),
|
|
2610
|
+
name: Schema12.String.check(Schema12.isMinLength(1)),
|
|
2611
|
+
verificationId: Id
|
|
2612
|
+
})
|
|
2613
|
+
]);
|
|
2614
|
+
var RunEvidence = Schema12.Struct({
|
|
2615
|
+
id: Id,
|
|
2616
|
+
step: Schema12.String,
|
|
2617
|
+
name: Schema12.String,
|
|
2618
|
+
command: Schema12.String,
|
|
2619
|
+
status: Schema12.Literals(["passed", "failed"]),
|
|
2620
|
+
preExisting: Schema12.Boolean,
|
|
2621
|
+
revision: Schema12.String,
|
|
2622
|
+
tree: Schema12.String,
|
|
2623
|
+
durationMs: Schema12.Int.check(Schema12.isGreaterThanOrEqualTo(0)),
|
|
2624
|
+
outputTail: Schema12.String,
|
|
2625
|
+
recordedAt: Timestamp
|
|
2626
|
+
});
|
|
2627
|
+
var ApprovedVerification = Schema12.Struct({
|
|
2628
|
+
id: Id,
|
|
2629
|
+
repoBindingId: Id,
|
|
2630
|
+
name: Schema12.String,
|
|
2631
|
+
command: Schema12.String,
|
|
2632
|
+
workingDirectory: Schema12.optionalKey(Schema12.String),
|
|
2633
|
+
approvedByUserId: Schema12.String,
|
|
2634
|
+
createdAt: Timestamp
|
|
2635
|
+
});
|
|
2636
|
+
var ApprovedVerificationList = Schema12.Struct({ items: Schema12.Array(ApprovedVerification) });
|
|
2637
|
+
var BundleDigest = Schema12.String.check(Schema12.isMinLength(64), Schema12.isMaxLength(64), Schema12.isPattern(new RegExp("^[a-f0-9]{64}$", "u")));
|
|
2638
|
+
var RunArtifact = Schema12.Struct({
|
|
2639
|
+
id: Id,
|
|
2640
|
+
runId: Id,
|
|
2641
|
+
projectId: Schema12.optionalKey(Id),
|
|
2642
|
+
taskId: Schema12.optionalKey(Id),
|
|
2643
|
+
step: Schema12.String,
|
|
2644
|
+
kind: Schema12.String,
|
|
2645
|
+
title: Schema12.String,
|
|
2646
|
+
text: Schema12.String,
|
|
2647
|
+
data: Schema12.optionalKey(Schema12.Unknown),
|
|
2648
|
+
createdAt: Timestamp
|
|
2649
|
+
});
|
|
2650
|
+
var RunArtifactSearch = Schema12.Struct({
|
|
2651
|
+
query: Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(2000)),
|
|
2652
|
+
limit: Schema12.optionalKey(Schema12.Int.check(Schema12.isGreaterThanOrEqualTo(1), Schema12.isLessThanOrEqualTo(50)))
|
|
2653
|
+
});
|
|
2654
|
+
var RunArtifactSearchResult = Schema12.Struct({ items: Schema12.Array(RunArtifact) });
|
|
2655
|
+
var RunClosureKinds = ["complete", "abandoned"];
|
|
2656
|
+
var RunClosure = Schema12.Struct({
|
|
2657
|
+
kind: Schema12.Literals(RunClosureKinds),
|
|
2658
|
+
reason: Schema12.optionalKey(Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(2000))),
|
|
2659
|
+
closedByUserId: Id,
|
|
2660
|
+
closedAt: Timestamp
|
|
2661
|
+
});
|
|
2662
|
+
var RunCloseInput = Schema12.Struct({
|
|
2663
|
+
kind: Schema12.Literals(RunClosureKinds),
|
|
2664
|
+
reason: Schema12.optionalKey(Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(2000)))
|
|
2665
|
+
});
|
|
2666
|
+
var RunAlignmentVerdicts = ["aligned", "not_aligned", "unverified"];
|
|
2667
|
+
var RunAlignment = Schema12.Struct({
|
|
2668
|
+
verdict: Schema12.Literals(RunAlignmentVerdicts),
|
|
2669
|
+
reasons: Schema12.Array(Schema12.String),
|
|
2670
|
+
intentVersion: Schema12.Int.check(Schema12.isGreaterThanOrEqualTo(1)),
|
|
2671
|
+
judgedAt: Timestamp
|
|
2672
|
+
});
|
|
2673
|
+
var Run = Schema12.Struct({
|
|
2674
|
+
id: Id,
|
|
2675
|
+
workspaceId: Id,
|
|
2676
|
+
projectId: Schema12.optionalKey(Id),
|
|
2677
|
+
taskId: Schema12.optionalKey(Id),
|
|
2678
|
+
sessionId: Schema12.optionalKey(Id),
|
|
2679
|
+
loopId: Id,
|
|
2680
|
+
packageVersionId: Schema12.optionalKey(Id),
|
|
2681
|
+
resourceVersion: Schema12.Int.check(Schema12.isGreaterThanOrEqualTo(1)),
|
|
2682
|
+
status: RunStatus,
|
|
2683
|
+
trigger: RunTrigger,
|
|
2684
|
+
state: RunState,
|
|
2685
|
+
loopDigest: Schema12.optionalKey(BundleDigest),
|
|
2686
|
+
loopLayer: Schema12.optionalKey(Schema12.Literals(["project", "workspace", "shipped"])),
|
|
2687
|
+
parentRunId: Schema12.optionalKey(Id),
|
|
2688
|
+
waiting: Schema12.optionalKey(Schema12.Array(RunWaiting)),
|
|
2689
|
+
output: Schema12.optionalKey(Schema12.Unknown),
|
|
2690
|
+
failureSummary: Schema12.optionalKey(Schema12.String),
|
|
2691
|
+
closure: Schema12.optionalKey(RunClosure),
|
|
2692
|
+
alignment: Schema12.optionalKey(RunAlignment),
|
|
2693
|
+
startedAt: Schema12.optionalKey(Timestamp),
|
|
2694
|
+
completedAt: Schema12.optionalKey(Timestamp),
|
|
2695
|
+
createdAt: Timestamp,
|
|
2696
|
+
updatedAt: Timestamp
|
|
2697
|
+
});
|
|
2698
|
+
var StepAttemptInputKinds = ["kit", "memory", "decision", "knowledge_record", "context_pack"];
|
|
2699
|
+
var StepAttemptInputScopeKinds = ["workspace", "project", "task", "loop", "agent"];
|
|
2700
|
+
var StepAttemptInputKind = Schema12.Literals(StepAttemptInputKinds);
|
|
2701
|
+
var StepAttemptInputScopeKind = Schema12.Literals(StepAttemptInputScopeKinds);
|
|
2702
|
+
var StepAttemptInputScope = Schema12.Struct({
|
|
2703
|
+
kind: StepAttemptInputScopeKind,
|
|
2704
|
+
id: Id
|
|
2705
|
+
});
|
|
2706
|
+
var StepAttemptInputAvailability = Schema12.Union([
|
|
2707
|
+
Schema12.Struct({
|
|
2708
|
+
kind: Schema12.Literal("available"),
|
|
2709
|
+
inspectRef: LoopSafeRef
|
|
2710
|
+
}),
|
|
2711
|
+
Schema12.Struct({
|
|
2712
|
+
kind: Schema12.Union([Schema12.Literal("redacted"), Schema12.Literal("unavailable")]),
|
|
2713
|
+
reason: LoopSafeText
|
|
2714
|
+
})
|
|
2715
|
+
]);
|
|
2716
|
+
var StepAttemptInputBase = {
|
|
2717
|
+
kind: StepAttemptInputKind,
|
|
2718
|
+
sourceId: Id,
|
|
2719
|
+
sourceScope: StepAttemptInputScope,
|
|
2720
|
+
inclusionReason: LoopSafeText,
|
|
2721
|
+
resolvedAt: Timestamp,
|
|
2722
|
+
appliedToStepKey: LoopSafeKey,
|
|
2723
|
+
availability: StepAttemptInputAvailability
|
|
2724
|
+
};
|
|
2725
|
+
var StepAttemptInput = Schema12.Union([
|
|
2726
|
+
Schema12.Struct({
|
|
2727
|
+
...StepAttemptInputBase,
|
|
2728
|
+
sourceVersion: Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(240), Schema12.isPattern(new RegExp(LoopSafeReferencePattern, "u")))
|
|
2729
|
+
}),
|
|
2730
|
+
Schema12.Struct({
|
|
2731
|
+
...StepAttemptInputBase,
|
|
2732
|
+
contentSha256: LoopSha256
|
|
2733
|
+
})
|
|
2734
|
+
]);
|
|
2735
|
+
var StepAttemptInputManifest = Schema12.Struct({
|
|
2736
|
+
manifestVersion: Schema12.Int.check(Schema12.isGreaterThanOrEqualTo(1)),
|
|
2737
|
+
assembledAt: Timestamp,
|
|
2738
|
+
entries: Schema12.Array(StepAttemptInput),
|
|
2739
|
+
budget: Schema12.optionalKey(LoopSafeMetadata)
|
|
2740
|
+
});
|
|
2741
|
+
var StepAttemptAgent = Schema12.Struct({
|
|
2742
|
+
id: Id,
|
|
2743
|
+
version: Schema12.optionalKey(Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(240), Schema12.isPattern(new RegExp(LoopSafeReferencePattern, "u"))))
|
|
2744
|
+
});
|
|
2745
|
+
var StepAttemptRunner = Schema12.Struct({
|
|
2746
|
+
id: Id,
|
|
2747
|
+
capabilitySnapshot: Schema12.optionalKey(LoopSafeMetadata)
|
|
2748
|
+
});
|
|
2749
|
+
var StepAttemptExecutionEnvironment = Schema12.Struct({
|
|
2750
|
+
agent: Schema12.optionalKey(StepAttemptAgent),
|
|
2751
|
+
runner: Schema12.optionalKey(StepAttemptRunner),
|
|
2752
|
+
harness: Schema12.optionalKey(LoopSafeReferenceString),
|
|
2753
|
+
model: Schema12.optionalKey(LoopSafeReferenceString),
|
|
2754
|
+
metadata: LoopSafeMetadata
|
|
2755
|
+
});
|
|
2756
|
+
var StepAttemptLease = Schema12.Struct({
|
|
2757
|
+
ownerId: Id,
|
|
2758
|
+
runnerReplicaId: Schema12.optionalKey(Id),
|
|
2759
|
+
leaseId: Id,
|
|
2760
|
+
fencingToken: LoopSafeReferenceString,
|
|
2761
|
+
capacitySlot: Schema12.optionalKey(LoopSafeReferenceString),
|
|
2762
|
+
expiresAt: Timestamp,
|
|
2763
|
+
lastHeartbeatAt: Schema12.optionalKey(Timestamp)
|
|
2764
|
+
});
|
|
2765
|
+
var JsonDocumentObject = Schema12.JsonObject;
|
|
2766
|
+
var StepBrief = Schema12.Struct({
|
|
2767
|
+
stepAttemptId: Id,
|
|
2768
|
+
harness: Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(80)),
|
|
2769
|
+
model: Schema12.optionalKey(Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(200))),
|
|
2770
|
+
effort: Schema12.optionalKey(Schema12.Literals(AgentEfforts)),
|
|
2771
|
+
prompt: Schema12.String.check(Schema12.isMinLength(1)),
|
|
2772
|
+
contextPack: Schema12.optionalKey(Schema12.Struct({
|
|
2773
|
+
contextPackId: Schema12.optionalKey(Id),
|
|
2774
|
+
mode: Schema12.String.check(Schema12.isMinLength(1)),
|
|
2775
|
+
contentMarkdown: Schema12.String.check(Schema12.isMinLength(1))
|
|
2776
|
+
})),
|
|
2777
|
+
outputSchema: JsonDocumentObject,
|
|
2778
|
+
skills: Schema12.optionalKey(Schema12.Array(Schema12.Struct({
|
|
2779
|
+
name: Schema12.String.check(Schema12.isPattern(new RegExp(skillNamePattern, "u"))),
|
|
2780
|
+
files: Schema12.Record(Schema12.String.check(Schema12.isPattern(new RegExp(relativePathPattern, "u"))), Schema12.String)
|
|
2781
|
+
}))),
|
|
2782
|
+
toolless: Schema12.optionalKey(Schema12.Literal(true))
|
|
2783
|
+
});
|
|
2784
|
+
var StepOutputSubmission = Schema12.Struct({ output: JsonDocumentObject });
|
|
2785
|
+
var StepSessionUpdate = Schema12.Struct({
|
|
2786
|
+
kind: Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(80)),
|
|
2787
|
+
content: Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(4000))
|
|
2788
|
+
});
|
|
2789
|
+
var StepOutputSubmissionResult = Schema12.Union([
|
|
2790
|
+
Schema12.Struct({ status: Schema12.Literal("accepted") }),
|
|
2791
|
+
Schema12.Struct({
|
|
2792
|
+
status: Schema12.Literal("rejected"),
|
|
2793
|
+
message: Schema12.String,
|
|
2794
|
+
submissionsLeft: Schema12.Int.check(Schema12.isGreaterThanOrEqualTo(0))
|
|
2795
|
+
}),
|
|
2796
|
+
Schema12.Struct({ status: Schema12.Literal("failed"), message: Schema12.String })
|
|
2797
|
+
]);
|
|
2798
|
+
var StepAttempt = Schema12.Struct({
|
|
2799
|
+
id: Id,
|
|
2800
|
+
workspaceId: Id,
|
|
2801
|
+
projectId: Schema12.optionalKey(Id),
|
|
2802
|
+
taskId: Schema12.optionalKey(Id),
|
|
2803
|
+
sessionId: Schema12.optionalKey(Id),
|
|
2804
|
+
runId: Id,
|
|
2805
|
+
stepSnapshotId: Schema12.optionalKey(Id),
|
|
2806
|
+
stepKey: Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(240)),
|
|
2807
|
+
sequence: Schema12.Int.check(Schema12.isGreaterThanOrEqualTo(0)),
|
|
2808
|
+
required: Schema12.Boolean,
|
|
2809
|
+
attempt: Schema12.Int.check(Schema12.isGreaterThanOrEqualTo(1)),
|
|
2810
|
+
retryOfAttemptId: Schema12.optionalKey(Id),
|
|
2811
|
+
status: StepAttemptStatus,
|
|
2812
|
+
inputManifest: StepAttemptInputManifest,
|
|
2813
|
+
execution: StepAttemptExecutionEnvironment,
|
|
2814
|
+
output: Schema12.optionalKey(LoopStepOutput),
|
|
2815
|
+
brief: Schema12.optionalKey(StepBrief),
|
|
2816
|
+
failureSummary: Schema12.optionalKey(LoopSafeText),
|
|
2817
|
+
reviewEvidence: Schema12.Array(LoopSafeRef),
|
|
2818
|
+
lease: Schema12.optionalKey(StepAttemptLease),
|
|
2819
|
+
claimIdempotencyKey: Schema12.optionalKey(LoopSafeReferenceString),
|
|
2820
|
+
terminalIdempotencyKey: Schema12.optionalKey(LoopSafeReferenceString),
|
|
2821
|
+
startedAt: Schema12.optionalKey(Timestamp),
|
|
2822
|
+
completedAt: Schema12.optionalKey(Timestamp),
|
|
2823
|
+
createdAt: Timestamp,
|
|
2824
|
+
updatedAt: Timestamp
|
|
2825
|
+
});
|
|
2826
|
+
var StepAttemptList = Schema12.Struct({ items: Schema12.Array(StepAttempt) });
|
|
2827
|
+
var QuestionResponderPolicy = Schema12.Struct({
|
|
2828
|
+
eligibleMemberIds: Schema12.Array(Id).check(Schema12.isMinLength(1), Schema12.isMaxLength(100), Schema12.isUnique()),
|
|
2829
|
+
allowWorkspaceAdmins: Schema12.Boolean
|
|
2830
|
+
});
|
|
2831
|
+
var QuestionAnswer = Schema12.Struct({
|
|
2832
|
+
value: LoopSafeText,
|
|
2833
|
+
answeredByUserId: Id,
|
|
2834
|
+
answeredAt: Timestamp,
|
|
2835
|
+
idempotencyKey: Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(240))
|
|
2836
|
+
});
|
|
2837
|
+
var Question = Schema12.Struct({
|
|
2838
|
+
id: Id,
|
|
2839
|
+
workspaceId: Id,
|
|
2840
|
+
projectId: Schema12.optionalKey(Id),
|
|
2841
|
+
taskId: Schema12.optionalKey(Id),
|
|
2842
|
+
runId: Id,
|
|
2843
|
+
stepKey: Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(240)),
|
|
2844
|
+
waitId: Id,
|
|
2845
|
+
taskThreadEntryId: Schema12.optionalKey(Id),
|
|
2846
|
+
prompt: LoopSafeText,
|
|
2847
|
+
options: Schema12.optionalKey(Schema12.Array(LoopSafeText)),
|
|
2848
|
+
freeText: Schema12.optionalKey(Schema12.Boolean),
|
|
2849
|
+
responderPolicy: QuestionResponderPolicy,
|
|
2850
|
+
status: QuestionStatus,
|
|
2851
|
+
answer: Schema12.optionalKey(QuestionAnswer),
|
|
2852
|
+
resolutionOutcome: Schema12.optionalKey(LoopSafeText),
|
|
2853
|
+
createdAt: Timestamp,
|
|
2854
|
+
updatedAt: Timestamp,
|
|
2855
|
+
resolvedAt: Schema12.optionalKey(Timestamp)
|
|
2856
|
+
});
|
|
2857
|
+
var QuestionAnswerCreate = Schema12.Struct({
|
|
2858
|
+
value: LoopSafeText,
|
|
2859
|
+
idempotencyKey: Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(240))
|
|
2860
|
+
});
|
|
2861
|
+
var QuestionList = Schema12.Struct({ items: Schema12.Array(Question) });
|
|
2862
|
+
var RunLaunchContext = Schema12.Struct({
|
|
2863
|
+
projectId: Schema12.optionalKey(Id),
|
|
2864
|
+
remoteUrl: Schema12.optionalKey(Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(2000))),
|
|
2865
|
+
repoBindingId: Schema12.optionalKey(Id),
|
|
2866
|
+
branch: Schema12.optionalKey(Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(255)))
|
|
2867
|
+
});
|
|
2868
|
+
var RunStart = Schema12.Struct({
|
|
2869
|
+
workspaceId: Id,
|
|
2870
|
+
loop: Schema12.optionalKey(Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(120))),
|
|
2871
|
+
words: Schema12.optionalKey(Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(4000))),
|
|
2872
|
+
task: Schema12.optionalKey(Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(200))),
|
|
2873
|
+
teamId: Schema12.optionalKey(Id),
|
|
2874
|
+
taskTypeId: Schema12.optionalKey(Id),
|
|
2875
|
+
input: Schema12.optionalKey(Schema12.Record(Schema12.String, Schema12.Unknown)),
|
|
2876
|
+
context: Schema12.optionalKey(RunLaunchContext),
|
|
2877
|
+
devVersionId: Schema12.optionalKey(Id),
|
|
2878
|
+
constraints: Schema12.optionalKey(Schema12.Array(Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(1000))).check(Schema12.isMaxLength(20)))
|
|
2879
|
+
});
|
|
2880
|
+
var RunStarted = Schema12.Struct({
|
|
2881
|
+
run: Run,
|
|
2882
|
+
task: Schema12.optionalKey(Schema12.Struct({ id: Id, taskKey: Schema12.String })),
|
|
2883
|
+
inferred: Schema12.Struct({
|
|
2884
|
+
repoBindingId: Schema12.optionalKey(Id),
|
|
2885
|
+
branch: Schema12.optionalKey(Schema12.String),
|
|
2886
|
+
changeRequestId: Schema12.optionalKey(Id),
|
|
2887
|
+
trackerKeys: Schema12.Array(Schema12.String),
|
|
2888
|
+
outcome: Schema12.optionalKey(Schema12.String)
|
|
2889
|
+
})
|
|
2890
|
+
});
|
|
2891
|
+
var RunStepSummary = Schema12.Struct({
|
|
2892
|
+
name: Schema12.String,
|
|
2893
|
+
status: StepAttemptStatus,
|
|
2894
|
+
startedAt: Timestamp,
|
|
2895
|
+
completedAt: Schema12.optionalKey(Timestamp),
|
|
2896
|
+
output: Schema12.optionalKey(Schema12.Unknown),
|
|
2897
|
+
attempts: Schema12.Array(Schema12.Struct({
|
|
2898
|
+
id: Id,
|
|
2899
|
+
attempt: Schema12.Int.check(Schema12.isGreaterThanOrEqualTo(1)),
|
|
2900
|
+
status: StepAttemptStatus,
|
|
2901
|
+
failureSummary: Schema12.optionalKey(Schema12.String)
|
|
2902
|
+
}))
|
|
2903
|
+
});
|
|
2904
|
+
var RunSteerDeliveries = ["queued", "delivered", "failed"];
|
|
2905
|
+
var RunSteer = Schema12.Struct({
|
|
2906
|
+
id: Id,
|
|
2907
|
+
text: LoopSafeText,
|
|
2908
|
+
delivery: Schema12.Literals(RunSteerDeliveries),
|
|
2909
|
+
step: Schema12.optionalKey(Schema12.String),
|
|
2910
|
+
createdAt: Timestamp
|
|
2911
|
+
});
|
|
2912
|
+
var RunSteerInput = Schema12.Struct({
|
|
2913
|
+
text: LoopSafeText,
|
|
2914
|
+
idempotencyKey: Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(240))
|
|
2915
|
+
});
|
|
2916
|
+
var RunSteerSent = Schema12.Struct({
|
|
2917
|
+
steer: RunSteer,
|
|
2918
|
+
target: Schema12.Literals(["session", "next_step"])
|
|
2919
|
+
});
|
|
2920
|
+
var RunShow = Schema12.Struct({
|
|
2921
|
+
run: Run,
|
|
2922
|
+
steps: Schema12.Array(RunStepSummary),
|
|
2923
|
+
questions: Schema12.Array(Question),
|
|
2924
|
+
children: Schema12.Array(Schema12.Struct({ runId: Id, name: Schema12.String, status: RunStatus, createdAt: Timestamp })),
|
|
2925
|
+
activities: Schema12.Array(Schema12.Struct({
|
|
2926
|
+
name: Schema12.String,
|
|
2927
|
+
attempt: Schema12.Int.check(Schema12.isGreaterThanOrEqualTo(1)),
|
|
2928
|
+
status: Schema12.Literals(["succeeded", "failed"]),
|
|
2929
|
+
recordedAt: Timestamp
|
|
2930
|
+
})),
|
|
2931
|
+
artifacts: Schema12.Array(RunArtifact),
|
|
2932
|
+
events: Schema12.Array(Schema12.Struct({ id: Id, type: Schema12.String, occurredAt: Timestamp })),
|
|
2933
|
+
evidence: Schema12.Array(RunEvidence),
|
|
2934
|
+
steers: Schema12.Array(RunSteer),
|
|
2935
|
+
waiting: Schema12.Array(RunWaiting),
|
|
2936
|
+
closures: Schema12.Array(RunClosure)
|
|
2937
|
+
});
|
|
2938
|
+
var RunStartPreview = Schema12.Struct({
|
|
2939
|
+
loop: Schema12.Struct({ id: Schema12.String, title: Schema12.String, outcome: Schema12.optionalKey(Schema12.String) }),
|
|
2940
|
+
inputSchema: Schema12.Record(Schema12.String, Schema12.Unknown),
|
|
2941
|
+
input: Schema12.Record(Schema12.String, Schema12.Unknown),
|
|
2942
|
+
missing: Schema12.Array(Schema12.String),
|
|
2943
|
+
projectId: Schema12.optionalKey(Id),
|
|
2944
|
+
inferred: Schema12.Struct({
|
|
2945
|
+
repoBindingId: Schema12.optionalKey(Id),
|
|
2946
|
+
branch: Schema12.optionalKey(Schema12.String),
|
|
2947
|
+
changeRequestId: Schema12.optionalKey(Id),
|
|
2948
|
+
trackerKeys: Schema12.Array(Schema12.String),
|
|
2949
|
+
outcome: Schema12.optionalKey(Schema12.String)
|
|
2950
|
+
})
|
|
2951
|
+
});
|
|
2952
|
+
var ProgramLoop = Schema12.Struct({
|
|
2953
|
+
id: Schema12.String,
|
|
2954
|
+
title: Schema12.String,
|
|
2955
|
+
layer: Schema12.Literals(["project", "workspace", "shipped"]),
|
|
2956
|
+
digest: Schema12.String,
|
|
2957
|
+
outcome: Schema12.optionalKey(Schema12.String),
|
|
2958
|
+
offers: Schema12.Array(Schema12.Struct({ id: Schema12.String, title: Schema12.String, loop: Schema12.String })),
|
|
2959
|
+
publishedAt: Timestamp,
|
|
2960
|
+
package: Schema12.String
|
|
2961
|
+
});
|
|
2962
|
+
var LoopDetail = Schema12.Struct({ id: Schema12.String, resolved: Schema12.optionalKey(ProgramLoop) });
|
|
2963
|
+
var AutomaticStart = Schema12.Struct({
|
|
2964
|
+
eventId: Schema12.String,
|
|
2965
|
+
eventType: Schema12.String,
|
|
2966
|
+
projectId: Schema12.Union([Schema12.String, Schema12.Null]),
|
|
2967
|
+
loop: Schema12.String,
|
|
2968
|
+
runId: Schema12.optionalKey(Schema12.String),
|
|
2969
|
+
rejection: Schema12.optionalKey(Schema12.String),
|
|
2970
|
+
at: Schema12.String
|
|
2971
|
+
});
|
|
2972
|
+
var AutomaticStartList = Schema12.Struct({ items: Schema12.Array(AutomaticStart) });
|
|
2973
|
+
var ProgramAgent = Schema12.Struct({
|
|
2974
|
+
id: Schema12.String,
|
|
2975
|
+
layer: Schema12.Literals(["project", "workspace", "shipped"]),
|
|
2976
|
+
package: Schema12.String,
|
|
2977
|
+
extends: Schema12.optionalKey(Schema12.String),
|
|
2978
|
+
instructions: Schema12.optionalKey(Schema12.String),
|
|
2979
|
+
harness: Schema12.optionalKey(Schema12.String),
|
|
2980
|
+
model: Schema12.optionalKey(Schema12.String),
|
|
2981
|
+
effort: Schema12.optionalKey(Schema12.Literals(AgentEfforts)),
|
|
2982
|
+
kits: Schema12.optionalKey(Schema12.Array(Schema12.String)),
|
|
2983
|
+
network: Schema12.optionalKey(AgentSandboxNetwork),
|
|
2984
|
+
sandbox: Schema12.optionalKey(Schema12.Literal("docker")),
|
|
2985
|
+
fieldLayers: Schema12.optionalKey(Schema12.Struct({
|
|
2986
|
+
instructions: Schema12.optionalKey(Schema12.Literals(LoopLayers)),
|
|
2987
|
+
harness: Schema12.optionalKey(Schema12.Literals(LoopLayers)),
|
|
2988
|
+
model: Schema12.optionalKey(Schema12.Literals(LoopLayers)),
|
|
2989
|
+
effort: Schema12.optionalKey(Schema12.Literals(LoopLayers)),
|
|
2990
|
+
kits: Schema12.optionalKey(Schema12.Literals(LoopLayers)),
|
|
2991
|
+
network: Schema12.optionalKey(Schema12.Literals(LoopLayers)),
|
|
2992
|
+
sandbox: Schema12.optionalKey(Schema12.Literals(LoopLayers))
|
|
2993
|
+
}))
|
|
2994
|
+
});
|
|
2995
|
+
var ProgramAgentList = Schema12.Struct({ items: Schema12.Array(ProgramAgent) });
|
|
2996
|
+
var ProgramLoopList = Schema12.Struct({ items: Schema12.Array(ProgramLoop) });
|
|
2997
|
+
var RunList = Schema12.Struct({ items: Schema12.Array(Run) });
|
|
2998
|
+
var RunWaitReasons = ["question", "completed", "failed", "stopped", "timeout"];
|
|
2999
|
+
var RunWaitResult = Schema12.Struct({
|
|
3000
|
+
reason: Schema12.Literals(RunWaitReasons),
|
|
3001
|
+
run: Run,
|
|
3002
|
+
questions: Schema12.Array(Question)
|
|
3003
|
+
});
|
|
3004
|
+
var RunAnswer = Schema12.Struct({
|
|
3005
|
+
value: LoopSafeText,
|
|
3006
|
+
question: Schema12.optionalKey(Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(200))),
|
|
3007
|
+
idempotencyKey: Schema12.String.check(Schema12.isMinLength(1), Schema12.isMaxLength(240))
|
|
3008
|
+
});
|
|
3009
|
+
var RunActionKinds = ["offer", "stop", "resume"];
|
|
3010
|
+
var RunActionSummary = Schema12.Struct({
|
|
3011
|
+
id: Schema12.String.check(Schema12.isMinLength(1)),
|
|
3012
|
+
title: Schema12.String,
|
|
3013
|
+
kind: Schema12.Literals(RunActionKinds),
|
|
3014
|
+
loop: Schema12.optionalKey(Schema12.String)
|
|
3015
|
+
});
|
|
3016
|
+
var RunActionList = Schema12.Struct({ items: Schema12.Array(RunActionSummary) });
|
|
3017
|
+
var RunActionTaken = Schema12.Struct({ action: Schema12.String, run: Run });
|
|
3018
|
+
|
|
3019
|
+
// packages/core/src/schedule.ts
|
|
3020
|
+
var ScheduleFrequency = ["daily", "weekly"];
|
|
3021
|
+
var ScheduleMisfirePolicies = ["skip", "fire_once", "catch_up"];
|
|
3022
|
+
var ScheduleOverlapPolicies = ["allow", "skip", "coalesce"];
|
|
3023
|
+
var ScheduleVersionStatuses = ["draft", "published", "disabled", "archived"];
|
|
3024
|
+
var ScheduleCalendarRule = Schema13.Struct({
|
|
3025
|
+
frequency: Schema13.Literals(ScheduleFrequency),
|
|
3026
|
+
hour: Schema13.Int.check(Schema13.isGreaterThanOrEqualTo(0), Schema13.isLessThanOrEqualTo(23)),
|
|
3027
|
+
minute: Schema13.Int.check(Schema13.isGreaterThanOrEqualTo(0), Schema13.isLessThanOrEqualTo(59)),
|
|
3028
|
+
second: Schema13.optionalKey(Schema13.Int.check(Schema13.isGreaterThanOrEqualTo(0), Schema13.isLessThanOrEqualTo(59))),
|
|
3029
|
+
daysOfWeek: Schema13.optionalKey(Schema13.Array(Schema13.Int.check(Schema13.isGreaterThanOrEqualTo(0), Schema13.isLessThanOrEqualTo(6))).check(Schema13.isMinLength(1), Schema13.isMaxLength(7)))
|
|
3030
|
+
});
|
|
3031
|
+
var ScheduleCronRule = Schema13.Struct({
|
|
3032
|
+
cron: Schema13.String.check(Schema13.isMinLength(9), Schema13.isMaxLength(200), Schema13.isPattern(new RegExp("^[0-9*,/-]+( [0-9*,/-]+){4}$", "u")))
|
|
3033
|
+
});
|
|
3034
|
+
var ScheduleRule = Schema13.Union([ScheduleCalendarRule, ScheduleCronRule]);
|
|
3035
|
+
var cronBounds = [
|
|
3036
|
+
[0, 59],
|
|
3037
|
+
[0, 23],
|
|
3038
|
+
[1, 31],
|
|
3039
|
+
[1, 12],
|
|
3040
|
+
[0, 7]
|
|
3041
|
+
];
|
|
3042
|
+
function cronField(field, [min, max]) {
|
|
3043
|
+
const values = new Set;
|
|
3044
|
+
for (const part of field.split(",")) {
|
|
3045
|
+
const match = /^(\*|(\d+)(?:-(\d+))?)(?:\/(\d+))?$/.exec(part);
|
|
3046
|
+
if (match === null)
|
|
3047
|
+
return;
|
|
3048
|
+
const from = match[1] === "*" ? min : Number(match[2]);
|
|
3049
|
+
const to = match[1] === "*" ? max : match[3] === undefined ? match[4] === undefined ? from : max : Number(match[3]);
|
|
3050
|
+
const step = match[4] === undefined ? 1 : Number(match[4]);
|
|
3051
|
+
if (from < min || to > max || from > to || step < 1)
|
|
3052
|
+
return;
|
|
3053
|
+
for (let value = from;value <= to; value += step)
|
|
3054
|
+
values.add(value);
|
|
3055
|
+
}
|
|
3056
|
+
return values;
|
|
3057
|
+
}
|
|
3058
|
+
function parseCron(cron) {
|
|
3059
|
+
const fields = cron.split(" ");
|
|
3060
|
+
const [minutes, hours, days, months, weekdays] = fields.map((field, index) => cronField(field, cronBounds[index] ?? [0, 0]));
|
|
3061
|
+
if (fields.length !== 5 || !minutes || !hours || !days || !months || !weekdays)
|
|
3062
|
+
return;
|
|
3063
|
+
return {
|
|
3064
|
+
minutes,
|
|
3065
|
+
hours,
|
|
3066
|
+
days,
|
|
3067
|
+
months,
|
|
3068
|
+
weekdays: new Set([...weekdays].map((value) => value % 7)),
|
|
3069
|
+
dayRestricted: !(fields[2] ?? "").startsWith("*"),
|
|
3070
|
+
weekdayRestricted: !(fields[4] ?? "").startsWith("*")
|
|
3071
|
+
};
|
|
3072
|
+
}
|
|
3073
|
+
function isScheduleRule(value) {
|
|
3074
|
+
return guard(ScheduleRule)(value) && (!("cron" in value) || parseCron(value.cron) !== undefined);
|
|
3075
|
+
}
|
|
3076
|
+
var ScheduleVersion = Schema13.Struct({
|
|
3077
|
+
contractVersion: Schema13.Literal("schedule.v1"),
|
|
3078
|
+
id: Schema13.String.check(Schema13.isMinLength(1)),
|
|
3079
|
+
scheduleId: Schema13.String.check(Schema13.isMinLength(1)),
|
|
3080
|
+
workspaceId: Schema13.String.check(Schema13.isMinLength(1)),
|
|
3081
|
+
projectId: Schema13.optionalKey(Schema13.String.check(Schema13.isMinLength(1))),
|
|
3082
|
+
loopId: Schema13.optionalKey(Schema13.String.check(Schema13.isMinLength(1))),
|
|
3083
|
+
name: Schema13.optionalKey(Schema13.String.check(Schema13.isMinLength(1), Schema13.isMaxLength(200))),
|
|
3084
|
+
version: Schema13.Int.check(Schema13.isGreaterThanOrEqualTo(1)),
|
|
3085
|
+
status: Schema13.Literals(ScheduleVersionStatuses),
|
|
3086
|
+
timezone: Schema13.String.check(Schema13.isMinLength(1), Schema13.isMaxLength(80)),
|
|
3087
|
+
rule: ScheduleRule,
|
|
3088
|
+
misfirePolicy: Schema13.Literals(ScheduleMisfirePolicies),
|
|
3089
|
+
overlapPolicy: Schema13.Literals(ScheduleOverlapPolicies),
|
|
3090
|
+
maxCatchUp: Schema13.Int.check(Schema13.isGreaterThanOrEqualTo(0), Schema13.isLessThanOrEqualTo(200)),
|
|
3091
|
+
misfireGraceSeconds: Schema13.optionalKey(Schema13.Int.check(Schema13.isGreaterThanOrEqualTo(0), Schema13.isLessThanOrEqualTo(604800))),
|
|
3092
|
+
inputSchemaRef: Schema13.optionalKey(LoopDataSchemaRef),
|
|
3093
|
+
input: Schema13.optionalKey(SafeJson),
|
|
3094
|
+
createdAt: Schema13.String.check(Schema13.isMinLength(1))
|
|
3095
|
+
});
|
|
3096
|
+
var zones = new Map;
|
|
3097
|
+
var resolvedLocalDateTimes = new Map;
|
|
3098
|
+
|
|
3099
|
+
// packages/core/src/package-declarations.ts
|
|
3100
|
+
var LoopCapabilities2 = [
|
|
3101
|
+
"agent_work",
|
|
3102
|
+
"ask",
|
|
3103
|
+
"call",
|
|
3104
|
+
"verify",
|
|
3105
|
+
"change_request",
|
|
3106
|
+
"write_back",
|
|
3107
|
+
"post_comment",
|
|
3108
|
+
"create_tasks",
|
|
3109
|
+
"merge_change_request",
|
|
3110
|
+
"publish_release"
|
|
3111
|
+
];
|
|
3112
|
+
var JsonObject2 = Schema14.Record(Schema14.String, Schema14.Json);
|
|
3113
|
+
var recordKeyedBy = (pattern, value) => Schema14.Record(Schema14.String, value).check(Schema14.makeFilter((record) => {
|
|
3114
|
+
const bad = Object.keys(record).find((key) => !new RegExp(pattern).test(key));
|
|
3115
|
+
return bad === undefined ? true : `${JSON.stringify(bad)} is not a valid name or relative path`;
|
|
3116
|
+
}));
|
|
3117
|
+
var SecretName = Schema14.String.check(Schema14.isPattern(/^[A-Za-z_][A-Za-z0-9_]{0,127}$/));
|
|
3118
|
+
var EventFilterValue = Schema14.Union([Schema14.String, Schema14.Finite, Schema14.Boolean, Schema14.Null]);
|
|
3119
|
+
var LoopManifest = Schema14.Struct({
|
|
3120
|
+
id: Schema14.String,
|
|
3121
|
+
title: Schema14.String,
|
|
3122
|
+
input: JsonObject2,
|
|
3123
|
+
output: JsonObject2,
|
|
3124
|
+
outcome: Schema14.optionalKey(Schema14.Literals(["feature", "bug", "refactor", "investigation", "docs", "migration"])),
|
|
3125
|
+
agents: Schema14.Record(Schema14.String, Schema14.String),
|
|
3126
|
+
checkout: Schema14.Literals(["none", "read", "write"]),
|
|
3127
|
+
when: Schema14.Array(Schema14.Struct({
|
|
3128
|
+
event: Schema14.String,
|
|
3129
|
+
filter: Schema14.optionalKey(Schema14.Record(Schema14.String, Schema14.Union([EventFilterValue, Schema14.Array(EventFilterValue)]))),
|
|
3130
|
+
input: Schema14.Record(Schema14.String, Schema14.String)
|
|
3131
|
+
})),
|
|
3132
|
+
offers: Schema14.Array(Schema14.Struct({ id: Schema14.String, title: Schema14.String, loop: Schema14.String })),
|
|
3133
|
+
capabilities: Schema14.Array(Schema14.Literals(LoopCapabilities2)),
|
|
3134
|
+
secrets: Schema14.optionalKey(Schema14.Array(SecretName)),
|
|
3135
|
+
network: Schema14.optionalKey(AgentSandboxNetwork)
|
|
3136
|
+
});
|
|
3137
|
+
var AgentDeclaration = Schema14.Struct({
|
|
3138
|
+
extends: Schema14.optionalKey(Schema14.String),
|
|
3139
|
+
instructions: Schema14.optionalKey(Schema14.String),
|
|
3140
|
+
harness: Schema14.optionalKey(Schema14.String),
|
|
3141
|
+
model: Schema14.optionalKey(Schema14.String),
|
|
3142
|
+
effort: Schema14.optionalKey(Schema14.Literals(AgentEfforts)),
|
|
3143
|
+
kits: Schema14.optionalKey(Schema14.Array(Schema14.String)),
|
|
3144
|
+
network: Schema14.optionalKey(Schema14.Union([Schema14.Struct({ hosts: Schema14.Array(Schema14.String) }), Schema14.Literal("open")])),
|
|
3145
|
+
sandbox: Schema14.optionalKey(Schema14.Literal("docker"))
|
|
3146
|
+
});
|
|
3147
|
+
var scheduleFields = {
|
|
3148
|
+
name: Schema14.String.check(Schema14.isMinLength(1)),
|
|
3149
|
+
loop: Schema14.String,
|
|
3150
|
+
project: Schema14.optionalKey(Schema14.String),
|
|
3151
|
+
input: Schema14.optionalKey(JsonObject2),
|
|
3152
|
+
timezone: Schema14.String,
|
|
3153
|
+
misfire: Schema14.optionalKey(Schema14.Literals(ScheduleMisfirePolicies)),
|
|
3154
|
+
overlap: Schema14.optionalKey(Schema14.Literals(ScheduleOverlapPolicies))
|
|
3155
|
+
};
|
|
3156
|
+
var ScheduleDeclaration = Schema14.Union([
|
|
3157
|
+
Schema14.Struct({
|
|
3158
|
+
...scheduleFields,
|
|
3159
|
+
cron: Schema14.String.check(Schema14.makeFilter((cron) => isScheduleRule({ cron }) || "five cron fields, each within its range"))
|
|
3160
|
+
}),
|
|
3161
|
+
Schema14.Struct({
|
|
3162
|
+
...scheduleFields,
|
|
3163
|
+
rule: Schema14.declare((value) => isScheduleRule(value), {
|
|
3164
|
+
expected: "a Schedule rule: frequency daily or weekly, hour, minute, and optionally second and daysOfWeek"
|
|
3165
|
+
})
|
|
3166
|
+
})
|
|
3167
|
+
]);
|
|
3168
|
+
var AuthoredKitDeclaration = Schema14.Struct({
|
|
3169
|
+
name: Schema14.String.check(Schema14.isMinLength(1)),
|
|
3170
|
+
kind: Schema14.optionalKey(Schema14.Literals(KitKinds)),
|
|
3171
|
+
description: Schema14.optionalKey(Schema14.String),
|
|
3172
|
+
context: Schema14.String,
|
|
3173
|
+
skills: Schema14.optionalKey(recordKeyedBy(skillNamePattern, recordKeyedBy(relativePathPattern, Schema14.String)))
|
|
3174
|
+
});
|
|
3175
|
+
var KitInstallationDeclaration = Schema14.Struct({
|
|
3176
|
+
source: Schema14.String.check(Schema14.isMinLength(1)),
|
|
3177
|
+
version: Schema14.optionalKey(Schema14.String)
|
|
3178
|
+
});
|
|
3179
|
+
var KitAssignmentDeclaration = Schema14.Struct({
|
|
3180
|
+
kit: Schema14.String.check(Schema14.isMinLength(1)),
|
|
3181
|
+
workspace: Schema14.optionalKey(Schema14.Literals(["default", "mandatory"])),
|
|
3182
|
+
projects: Schema14.optionalKey(Schema14.Array(Schema14.String))
|
|
3183
|
+
});
|
|
3184
|
+
var KitDeclaration = Schema14.Union([
|
|
3185
|
+
KitInstallationDeclaration,
|
|
3186
|
+
KitAssignmentDeclaration,
|
|
3187
|
+
AuthoredKitDeclaration
|
|
3188
|
+
]);
|
|
3189
|
+
var PackageDeclarations = Schema14.Struct({
|
|
3190
|
+
loops: Schema14.Array(LoopManifest),
|
|
3191
|
+
agents: Schema14.Record(Schema14.String, AgentDeclaration),
|
|
3192
|
+
schedules: Schema14.optionalKey(Schema14.Record(Schema14.String, ScheduleDeclaration)),
|
|
3193
|
+
kits: Schema14.optionalKey(Schema14.Record(Schema14.String, KitDeclaration))
|
|
3194
|
+
});
|
|
3195
|
+
var sameLoop = Schema14.toEquivalence(LoopManifest);
|
|
3196
|
+
var sameAgent = Schema14.toEquivalence(AgentDeclaration);
|
|
3197
|
+
|
|
3198
|
+
// packages/sdk/src/loop/define.ts
|
|
3199
|
+
import * as Effect2 from "effect/Effect";
|
|
3200
|
+
import * as Schema15 from "effect/Schema";
|
|
3201
|
+
var LoopOutcome2 = Schema15.Literals(["feature", "bug", "refactor", "investigation", "docs", "migration"]);
|
|
3202
|
+
var defineLoop2 = (definition) => definition;
|
|
3203
|
+
|
|
3204
|
+
class ManifestInvalid2 extends Schema15.TaggedError()("ManifestInvalid", {
|
|
3205
|
+
loop: Schema15.String,
|
|
3206
|
+
message: Schema15.String
|
|
3207
|
+
}) {
|
|
3208
|
+
}
|
|
3209
|
+
var jsonSchemaOf2 = (loop, schema) => Effect2.try({
|
|
3210
|
+
try: () => Schema15.toJsonSchemaDocument(schema),
|
|
3211
|
+
catch: (error) => new ManifestInvalid2({ loop, message: `Schema has no JSON Schema: ${String(error)}` })
|
|
3212
|
+
}).pipe(Effect2.flatMap((document) => Schema15.decodeUnknownEffect(JsonObjectSchema)({ ...document.schema, $defs: document.definitions }).pipe(Effect2.mapError((error) => new ManifestInvalid2({ loop, message: error.message })))));
|
|
3213
|
+
var JsonObjectSchema = Schema15.Record(Schema15.String, Schema15.Json);
|
|
3214
|
+
var declarationsAreData = (definition) => Schema15.decodeEffect(JsonObjectSchema)({
|
|
3215
|
+
agents: definition.agents,
|
|
3216
|
+
when: definition.when ?? [],
|
|
3217
|
+
offers: definition.offers ?? []
|
|
3218
|
+
}).pipe(Effect2.mapError((error) => new ManifestInvalid2({ loop: definition.id, message: `Declarations must be data: ${error.message}` })));
|
|
3219
|
+
var loopManifest2 = (definition) => Effect2.gen(function* () {
|
|
3220
|
+
yield* declarationsAreData(definition);
|
|
3221
|
+
return {
|
|
3222
|
+
id: definition.id,
|
|
3223
|
+
title: definition.title,
|
|
3224
|
+
input: yield* jsonSchemaOf2(definition.id, definition.input),
|
|
3225
|
+
output: yield* jsonSchemaOf2(definition.id, definition.output),
|
|
3226
|
+
...definition.outcome === undefined ? undefined : { outcome: definition.outcome },
|
|
3227
|
+
agents: definition.agents,
|
|
3228
|
+
checkout: definition.checkout,
|
|
3229
|
+
when: definition.when ?? [],
|
|
3230
|
+
offers: definition.offers ?? [],
|
|
3231
|
+
capabilities: definition.capabilities,
|
|
3232
|
+
...definition.secrets === undefined ? undefined : { secrets: definition.secrets },
|
|
3233
|
+
...definition.network === undefined ? undefined : { network: definition.network }
|
|
3234
|
+
};
|
|
3235
|
+
});
|
|
3236
|
+
// packages/sdk/src/loop/steps.ts
|
|
3237
|
+
import * as Cause from "effect/Cause";
|
|
3238
|
+
import * as Context from "effect/Context";
|
|
3239
|
+
import * as Duration from "effect/Duration";
|
|
3240
|
+
import * as Effect3 from "effect/Effect";
|
|
3241
|
+
import * as Exit2 from "effect/Exit";
|
|
3242
|
+
import * as Schema17 from "effect/Schema";
|
|
3243
|
+
import { Activity, DurableDeferred } from "effect/workflow";
|
|
3244
|
+
|
|
3245
|
+
// packages/sdk/src/loop/evidence.ts
|
|
3246
|
+
import * as Schema16 from "effect/Schema";
|
|
3247
|
+
var EvidenceCheck2 = Schema16.Struct({
|
|
3248
|
+
name: Schema16.String,
|
|
3249
|
+
command: Schema16.String,
|
|
3250
|
+
status: Schema16.Literals(["passed", "failed"]),
|
|
3251
|
+
preExisting: Schema16.Boolean,
|
|
3252
|
+
durationMs: Schema16.Finite,
|
|
3253
|
+
evidenceId: Schema16.String
|
|
3254
|
+
});
|
|
3255
|
+
var VerifyResult2 = Schema16.Struct({
|
|
3256
|
+
revision: Schema16.String,
|
|
3257
|
+
tree: Schema16.String,
|
|
3258
|
+
passed: Schema16.Boolean,
|
|
3259
|
+
checks: Schema16.Array(EvidenceCheck2)
|
|
3260
|
+
});
|
|
3261
|
+
var OutcomeTable2 = {
|
|
3262
|
+
feature: "Approved verifications pass on the head tree, and review says the scope was met",
|
|
3263
|
+
bug: "A reproducing check fails on the base and passes on the head",
|
|
3264
|
+
refactor: "Approved verifications pass on both base and head",
|
|
3265
|
+
investigation: "A conclusion Output with its sources; no patch needed",
|
|
3266
|
+
docs: "The documented commands run",
|
|
3267
|
+
migration: "A rollback check passes",
|
|
3268
|
+
none: "Only the approved verifications"
|
|
3269
|
+
};
|
|
3270
|
+
var verdict = (reasons) => reasons.length === 0 ? { settled: true } : { settled: false, reasons };
|
|
3271
|
+
var missing = (side) => `No verification evidence for the ${side}`;
|
|
3272
|
+
var allPass = (side, result) => {
|
|
3273
|
+
if (result === undefined)
|
|
3274
|
+
return [missing(side)];
|
|
3275
|
+
if (result.checks.length === 0)
|
|
3276
|
+
return [`No approved verification ran on the ${side} tree ${result.tree}`];
|
|
3277
|
+
return result.checks.filter((check) => check.status === "failed" && !check.preExisting).map((check) => `${check.name} fails on the ${side} tree ${result.tree}`);
|
|
3278
|
+
};
|
|
3279
|
+
var checkOn = (side, result, name) => {
|
|
3280
|
+
if (result === undefined)
|
|
3281
|
+
return { reason: missing(side) };
|
|
3282
|
+
if (name === undefined)
|
|
3283
|
+
return { reason: `No check was named for the ${side}` };
|
|
3284
|
+
const found = result.checks.find((check) => check.name === name);
|
|
3285
|
+
return found === undefined ? { reason: `No evidence for ${name} on the ${side} tree ${result.tree}` } : { found };
|
|
3286
|
+
};
|
|
3287
|
+
var passesOnHead = (head, name) => {
|
|
3288
|
+
const { found, reason } = checkOn("head", head, name);
|
|
3289
|
+
if (found === undefined)
|
|
3290
|
+
return [reason];
|
|
3291
|
+
return found.status === "passed" ? [] : [`${found.name} fails on the head tree ${head?.tree}`];
|
|
3292
|
+
};
|
|
3293
|
+
var bugReasons = (input) => {
|
|
3294
|
+
const base = checkOn("base", input.base, input.reproducing);
|
|
3295
|
+
const head = checkOn("head", input.head, input.reproducing);
|
|
3296
|
+
return [
|
|
3297
|
+
...base.found === undefined ? [base.reason] : base.found.status === "failed" ? [] : [`${base.found.name} does not fail on the base tree ${input.base?.tree}, so the bug is not reproduced`],
|
|
3298
|
+
...head.found === undefined ? [head.reason] : head.found.status === "passed" ? [] : [`${head.found.name} fails on the head tree ${input.head?.tree}`]
|
|
3299
|
+
];
|
|
3300
|
+
};
|
|
3301
|
+
var conclusionReasons = (conclusion) => {
|
|
3302
|
+
if (conclusion === undefined || conclusion.text.trim() === "")
|
|
3303
|
+
return ["No conclusion was given"];
|
|
3304
|
+
return conclusion.sources.length === 0 ? ["The conclusion names no sources"] : [];
|
|
3305
|
+
};
|
|
3306
|
+
var scopeReasons = (scope) => {
|
|
3307
|
+
if (scope === undefined)
|
|
3308
|
+
return ["Review has not judged the scope"];
|
|
3309
|
+
if (scope.met)
|
|
3310
|
+
return [];
|
|
3311
|
+
return scope.unmet.length === 0 ? ["Review found the scope unmet"] : scope.unmet.map((item) => `Review found the scope unmet: ${item}`);
|
|
3312
|
+
};
|
|
3313
|
+
var evidenceGate2 = (input) => {
|
|
3314
|
+
switch (input.outcome) {
|
|
3315
|
+
case "feature":
|
|
3316
|
+
return verdict([...allPass("head", input.head), ...scopeReasons(input.review)]);
|
|
3317
|
+
case "bug":
|
|
3318
|
+
return verdict(bugReasons(input));
|
|
3319
|
+
case "refactor":
|
|
3320
|
+
return verdict([...allPass("base", input.base), ...allPass("head", input.head)]);
|
|
3321
|
+
case "investigation":
|
|
3322
|
+
return verdict(conclusionReasons(input.conclusion));
|
|
3323
|
+
case "docs":
|
|
3324
|
+
return verdict((input.documented ?? []).length === 0 ? ["No documented command was named"] : (input.documented ?? []).flatMap((name) => passesOnHead(input.head, name)));
|
|
3325
|
+
case "migration":
|
|
3326
|
+
return verdict(passesOnHead(input.head, input.rollback));
|
|
3327
|
+
default:
|
|
3328
|
+
return verdict(allPass("head", input.head));
|
|
3329
|
+
}
|
|
3330
|
+
};
|
|
3331
|
+
|
|
3332
|
+
// packages/sdk/src/loop/steps.ts
|
|
3333
|
+
class StepFailed2 extends Schema17.TaggedError()("StepFailed", {
|
|
3334
|
+
step: Schema17.String,
|
|
3335
|
+
reason: Schema17.String
|
|
3336
|
+
}) {
|
|
3337
|
+
get message() {
|
|
3338
|
+
return `Step "${this.step}" failed: ${this.reason}`;
|
|
3339
|
+
}
|
|
3340
|
+
}
|
|
3341
|
+
|
|
3342
|
+
class OutputInvalid2 extends Schema17.TaggedError()("OutputInvalid", {
|
|
3343
|
+
step: Schema17.String,
|
|
3344
|
+
message: Schema17.String
|
|
3345
|
+
}) {
|
|
3346
|
+
}
|
|
3347
|
+
|
|
3348
|
+
class QuestionRefused2 extends Schema17.TaggedError()("QuestionRefused", {
|
|
3349
|
+
step: Schema17.String,
|
|
3350
|
+
answer: Schema17.String,
|
|
3351
|
+
options: Schema17.Array(Schema17.String)
|
|
3352
|
+
}) {
|
|
3353
|
+
}
|
|
3354
|
+
|
|
3355
|
+
class WaitTimedOut2 extends Schema17.TaggedError()("WaitTimedOut", {
|
|
3356
|
+
step: Schema17.String,
|
|
3357
|
+
event: Schema17.String
|
|
3358
|
+
}) {
|
|
3359
|
+
}
|
|
3360
|
+
|
|
3361
|
+
class ChildFailed2 extends Schema17.TaggedError()("ChildFailed", {
|
|
3362
|
+
step: Schema17.String,
|
|
3363
|
+
loop: Schema17.String,
|
|
3364
|
+
reason: Schema17.String
|
|
3365
|
+
}) {
|
|
3366
|
+
get message() {
|
|
3367
|
+
return `Child Run of "${this.loop}" for Step "${this.step}" failed: ${this.reason}`;
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
|
|
3371
|
+
class CapabilityDenied2 extends Schema17.TaggedError()("CapabilityDenied", {
|
|
3372
|
+
step: Schema17.String,
|
|
3373
|
+
capability: Schema17.Literals(LoopCapabilities2),
|
|
3374
|
+
secret: Schema17.optionalKey(Schema17.String)
|
|
3375
|
+
}) {
|
|
3376
|
+
get message() {
|
|
3377
|
+
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`;
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
|
|
3381
|
+
class DuplicateStep2 extends Schema17.TaggedError()("DuplicateStep", {
|
|
3382
|
+
step: Schema17.String
|
|
3383
|
+
}) {
|
|
3384
|
+
}
|
|
3385
|
+
|
|
3386
|
+
class InputInvalid2 extends Schema17.TaggedError()("InputInvalid", {
|
|
3387
|
+
loop: Schema17.String,
|
|
3388
|
+
message: Schema17.String
|
|
3389
|
+
}) {
|
|
3390
|
+
}
|
|
3391
|
+
var LoopEvent2 = Schema17.Struct({ type: Schema17.String, payload: Schema17.Record(Schema17.String, Schema17.Json) });
|
|
3392
|
+
|
|
3393
|
+
class LoopRun2 extends Context.Service()("@kitman-sh/sdk/loop/LoopRun") {
|
|
3394
|
+
}
|
|
3395
|
+
|
|
3396
|
+
class LoopHost2 extends Context.Service()("@kitman-sh/sdk/loop/LoopHost") {
|
|
3397
|
+
}
|
|
3398
|
+
var agentWorkDeferred2 = (step) => DurableDeferred.make(`agent_work/${step}`, { success: Schema17.Json, error: StepFailed2 });
|
|
3399
|
+
var answerDeferred2 = (step) => DurableDeferred.make(`ask/${step}`, { success: Schema17.String, error: StepFailed2 });
|
|
3400
|
+
var childDeferred2 = (step) => DurableDeferred.make(`call/${step}`, { success: Schema17.Json, error: ChildFailed2 });
|
|
3401
|
+
var eventDeferred2 = (step) => DurableDeferred.make(`wait_for/${step}`, { success: LoopEvent2, error: WaitTimedOut2 });
|
|
3402
|
+
var verifyDeferred2 = (step) => DurableDeferred.make(`verify/${step}`, { success: VerifyResult2, error: StepFailed2 });
|
|
3403
|
+
var recordStep = (name, kind, exit) => {
|
|
3404
|
+
if (Exit2.isSuccess(exit))
|
|
3405
|
+
return { name, kind, status: "succeeded", result: exit.value };
|
|
3406
|
+
if (Cause.hasInterruptsOnly(exit.cause))
|
|
3407
|
+
return;
|
|
3408
|
+
return { name, kind, status: "failed", error: Cause.squash(exit.cause) };
|
|
3409
|
+
};
|
|
3410
|
+
var takeStep2 = (name, kind, capability, body) => Effect3.gen(function* () {
|
|
3411
|
+
const run = yield* LoopRun2;
|
|
3412
|
+
if (run.names.has(name))
|
|
3413
|
+
return yield* new DuplicateStep2({ step: name });
|
|
3414
|
+
if (capability !== undefined && !run.granted.has(capability))
|
|
3415
|
+
return yield* new CapabilityDenied2({ step: name, capability });
|
|
3416
|
+
run.names.add(name);
|
|
3417
|
+
return yield* body.pipe(Effect3.onExit((exit) => Effect3.sync(() => {
|
|
3418
|
+
const record = recordStep(name, kind, exit);
|
|
3419
|
+
if (record !== undefined)
|
|
3420
|
+
run.steps.push(record);
|
|
3421
|
+
})));
|
|
3422
|
+
});
|
|
3423
|
+
var launch = (deferred, start) => Activity.make({
|
|
3424
|
+
name: deferred.name,
|
|
3425
|
+
error: StepFailed2,
|
|
3426
|
+
execute: Effect3.gen(function* () {
|
|
3427
|
+
return yield* start(yield* LoopHost2, yield* DurableDeferred.token(deferred));
|
|
3428
|
+
})
|
|
3429
|
+
});
|
|
3430
|
+
var toJson = (step, schema, value) => Schema17.encodeUnknownEffect(Schema17.toCodecJson(schema))(value).pipe(Effect3.flatMap(Schema17.decodeUnknownEffect(Schema17.Json)), Effect3.mapError((error) => new StepFailed2({ step, reason: error.message })));
|
|
3431
|
+
var agentWork2 = (name, options) => takeStep2(name, "agent_work", "agent_work", Effect3.gen(function* () {
|
|
3432
|
+
const run = yield* LoopRun2;
|
|
3433
|
+
const agent = run.agents[options.agent];
|
|
3434
|
+
const undeclared = options.secrets?.find((secret) => !run.secrets.has(secret));
|
|
3435
|
+
if (undeclared !== undefined)
|
|
3436
|
+
return yield* new CapabilityDenied2({ step: name, capability: "agent_work", secret: undeclared });
|
|
3437
|
+
if (agent === undefined)
|
|
3438
|
+
return yield* new StepFailed2({ step: name, reason: `Agent role "${options.agent}" is not declared` });
|
|
3439
|
+
const deferred = agentWorkDeferred2(name);
|
|
3440
|
+
const output = yield* jsonSchemaOf2(run.loop, options.output).pipe(Effect3.mapError((error) => new StepFailed2({ step: name, reason: error.message })));
|
|
3441
|
+
yield* launch(deferred, (host, token) => host.startAgentWork({
|
|
3442
|
+
step: name,
|
|
3443
|
+
role: options.agent,
|
|
3444
|
+
agent,
|
|
3445
|
+
prompt: options.prompt,
|
|
3446
|
+
output,
|
|
3447
|
+
...options.secrets === undefined ? undefined : { secrets: options.secrets },
|
|
3448
|
+
token
|
|
3449
|
+
}));
|
|
3450
|
+
const submitted = yield* DurableDeferred.await(deferred);
|
|
3451
|
+
return yield* Schema17.decodeEffect(Schema17.toCodecJson(options.output))(submitted).pipe(Effect3.mapError((error) => new OutputInvalid2({ step: name, message: error.message })));
|
|
3452
|
+
}));
|
|
3453
|
+
var ask2 = (name, question) => takeStep2(name, "ask", "ask", Effect3.gen(function* () {
|
|
3454
|
+
const deferred = answerDeferred2(name);
|
|
3455
|
+
const options = "options" in question ? question.options : undefined;
|
|
3456
|
+
yield* launch(deferred, (host, token) => host.putQuestion({
|
|
3457
|
+
step: name,
|
|
3458
|
+
prompt: question.prompt,
|
|
3459
|
+
...options === undefined ? undefined : { options },
|
|
3460
|
+
token
|
|
3461
|
+
}));
|
|
3462
|
+
const answer = yield* DurableDeferred.await(deferred);
|
|
3463
|
+
if (options === undefined)
|
|
3464
|
+
return answer;
|
|
3465
|
+
const offered = options.find((option) => option === answer);
|
|
3466
|
+
if (offered === undefined)
|
|
3467
|
+
return yield* new QuestionRefused2({ step: name, answer, options });
|
|
3468
|
+
return offered;
|
|
3469
|
+
}));
|
|
3470
|
+
var call2 = (name, loop, input) => takeStep2(name, "call", "call", Effect3.gen(function* () {
|
|
3471
|
+
const deferred = childDeferred2(name);
|
|
3472
|
+
const encoded = yield* toJson(name, loop.input, input);
|
|
3473
|
+
yield* launch(deferred, (host, token) => host.admitChild({ step: name, loop: loop.id, input: encoded, token }));
|
|
3474
|
+
const result = yield* DurableDeferred.await(deferred);
|
|
3475
|
+
return yield* Schema17.decodeEffect(Schema17.toCodecJson(loop.output))(result).pipe(Effect3.mapError((error) => new ChildFailed2({ step: name, loop: loop.id, reason: error.message })));
|
|
3476
|
+
}));
|
|
3477
|
+
var waitFor2 = (name, wait) => takeStep2(name, "wait_for", undefined, Effect3.gen(function* () {
|
|
3478
|
+
const deferred = eventDeferred2(name);
|
|
3479
|
+
const timeoutMillis = Duration.toMillis(Duration.fromInputUnsafe(wait.timeout));
|
|
3480
|
+
yield* launch(deferred, (host, token) => host.awaitEvent({
|
|
3481
|
+
step: name,
|
|
3482
|
+
event: wait.event,
|
|
3483
|
+
...wait.filter === undefined ? undefined : { filter: wait.filter },
|
|
3484
|
+
timeoutMillis,
|
|
3485
|
+
token
|
|
3486
|
+
}));
|
|
3487
|
+
return yield* DurableDeferred.await(deferred);
|
|
3488
|
+
}));
|
|
3489
|
+
var verify2 = (name, request) => takeStep2(name, "verify", "verify", Effect3.gen(function* () {
|
|
3490
|
+
const deferred = verifyDeferred2(name);
|
|
3491
|
+
yield* launch(deferred, (host, token) => host.startVerification({
|
|
3492
|
+
step: name,
|
|
3493
|
+
...request.revision === undefined ? undefined : { revision: request.revision },
|
|
3494
|
+
...request.checks === undefined ? undefined : { checks: request.checks },
|
|
3495
|
+
token
|
|
3496
|
+
}));
|
|
3497
|
+
return yield* DurableDeferred.await(deferred);
|
|
3498
|
+
}));
|
|
3499
|
+
var approval = ["Approve", "Reject"];
|
|
3500
|
+
var suggestVerification2 = (name, verification) => takeStep2(name, "ask", "ask", Effect3.gen(function* () {
|
|
3501
|
+
const deferred = answerDeferred2(name);
|
|
3502
|
+
yield* launch(deferred, (host, token) => host.putQuestion({
|
|
3503
|
+
step: name,
|
|
3504
|
+
prompt: `Approve the verification "${verification.name}" for this repository? It runs \`${verification.command}\`${verification.workingDirectory === undefined ? "" : ` in ${verification.workingDirectory}`}.`,
|
|
3505
|
+
options: approval,
|
|
3506
|
+
verification,
|
|
3507
|
+
token
|
|
3508
|
+
}));
|
|
3509
|
+
return (yield* DurableDeferred.await(deferred)) === "Approve" ? "approved" : "rejected";
|
|
3510
|
+
}));
|
|
3511
|
+
// packages/sdk/src/loop/activities.ts
|
|
3512
|
+
import * as Context2 from "effect/Context";
|
|
3513
|
+
import * as Effect5 from "effect/Effect";
|
|
3514
|
+
import * as Schema19 from "effect/Schema";
|
|
3515
|
+
import { Activity as Activity2 } from "effect/workflow";
|
|
3516
|
+
|
|
3517
|
+
// packages/sdk/src/loop/plan.ts
|
|
3518
|
+
import * as Effect4 from "effect/Effect";
|
|
3519
|
+
import * as Schema18 from "effect/Schema";
|
|
3520
|
+
var PlanTicket2 = Schema18.Struct({
|
|
3521
|
+
key: Schema18.String,
|
|
3522
|
+
title: Schema18.String,
|
|
3523
|
+
body: Schema18.String,
|
|
3524
|
+
acceptanceCriteria: Schema18.Array(Schema18.String),
|
|
3525
|
+
repoBindingId: Schema18.optional(Schema18.String),
|
|
3526
|
+
blockedBy: Schema18.Array(Schema18.String),
|
|
3527
|
+
outcome: Schema18.optional(LoopOutcome2)
|
|
3528
|
+
});
|
|
3529
|
+
var cycleMessage = (keys) => `These tickets block each other in a cycle, so none can start: ${keys.join(", ")}`;
|
|
3530
|
+
var ticketsProblem = (tickets) => {
|
|
3531
|
+
const keys = new Set;
|
|
3532
|
+
for (const ticket of tickets) {
|
|
3533
|
+
if (keys.has(ticket.key))
|
|
3534
|
+
return `Two tickets have the key "${ticket.key}"`;
|
|
3535
|
+
keys.add(ticket.key);
|
|
3536
|
+
}
|
|
3537
|
+
for (const ticket of tickets)
|
|
3538
|
+
for (const blocker of ticket.blockedBy)
|
|
3539
|
+
if (!keys.has(blocker))
|
|
3540
|
+
return `Ticket "${ticket.key}" is blocked by "${blocker}", which is not a ticket`;
|
|
3541
|
+
const { blocked } = wavesOf(tickets);
|
|
3542
|
+
return blocked.length === 0 ? undefined : cycleMessage(blocked);
|
|
3543
|
+
};
|
|
3544
|
+
var PlanTickets2 = Schema18.Array(PlanTicket2).check(Schema18.makeFilter((tickets) => ticketsProblem(tickets) ?? true));
|
|
3545
|
+
|
|
3546
|
+
class BlockingCycle2 extends Schema18.TaggedError()("BlockingCycle", {
|
|
3547
|
+
tickets: Schema18.Array(Schema18.String)
|
|
3548
|
+
}) {
|
|
3549
|
+
get message() {
|
|
3550
|
+
return cycleMessage(this.tickets);
|
|
3551
|
+
}
|
|
3552
|
+
}
|
|
3553
|
+
var byRepoBinding = (left, right) => (left.repoBindingId ?? "").localeCompare(right.repoBindingId ?? "");
|
|
3554
|
+
function wavesOf(tickets) {
|
|
3555
|
+
const placed = new Set;
|
|
3556
|
+
const waves = [];
|
|
3557
|
+
let left = tickets;
|
|
3558
|
+
while (left.length > 0) {
|
|
3559
|
+
const ready = left.filter((ticket) => ticket.blockedBy.every((blocker) => placed.has(blocker)));
|
|
3560
|
+
if (ready.length === 0)
|
|
3561
|
+
break;
|
|
3562
|
+
for (const ticket of ready)
|
|
3563
|
+
placed.add(ticket.key);
|
|
3564
|
+
waves.push(ready.toSorted(byRepoBinding));
|
|
3565
|
+
left = left.filter((ticket) => !placed.has(ticket.key));
|
|
3566
|
+
}
|
|
3567
|
+
return { waves, blocked: left.map((ticket) => ticket.key) };
|
|
3568
|
+
}
|
|
3569
|
+
var planWaves2 = (tickets) => Effect4.suspend(() => {
|
|
3570
|
+
const { waves, blocked } = wavesOf(tickets);
|
|
3571
|
+
return blocked.length === 0 ? Effect4.succeed(waves) : Effect4.fail(new BlockingCycle2({ tickets: blocked }));
|
|
3572
|
+
});
|
|
3573
|
+
|
|
3574
|
+
// packages/sdk/src/loop/activities.ts
|
|
3575
|
+
var ChangeRequestRequest2 = Schema19.Struct({
|
|
3576
|
+
title: Schema19.String,
|
|
3577
|
+
body: Schema19.String,
|
|
3578
|
+
integration: Schema19.optional(Schema19.String)
|
|
3579
|
+
});
|
|
3580
|
+
var ChangeRequestResult2 = Schema19.Struct({ id: Schema19.String, number: Schema19.String, url: Schema19.String });
|
|
3581
|
+
var WriteBackMilestones2 = ["started", "change_request_opened", "merged", "failed"];
|
|
3582
|
+
var WriteBackRequest2 = Schema19.Struct({
|
|
3583
|
+
milestone: Schema19.optional(Schema19.Literals(WriteBackMilestones2)),
|
|
3584
|
+
changeRequestUrl: Schema19.optional(Schema19.String)
|
|
3585
|
+
});
|
|
3586
|
+
var ArtifactRequest2 = Schema19.Struct({
|
|
3587
|
+
kind: Schema19.String,
|
|
3588
|
+
title: Schema19.String,
|
|
3589
|
+
text: Schema19.String,
|
|
3590
|
+
data: Schema19.optional(Schema19.Json)
|
|
3591
|
+
});
|
|
3592
|
+
var ArtifactResult2 = Schema19.Struct({ artifactId: Schema19.String });
|
|
3593
|
+
var NoteRequest2 = Schema19.Struct({ text: Schema19.String, artifactId: Schema19.optional(Schema19.String) });
|
|
3594
|
+
var CreateTasksRequest2 = Schema19.Struct({ tickets: Schema19.Array(PlanTicket2) });
|
|
3595
|
+
var CreateTasksResult2 = Schema19.Struct({
|
|
3596
|
+
tasks: Schema19.Array(Schema19.Struct({ key: Schema19.String, taskId: Schema19.String }))
|
|
3597
|
+
});
|
|
3598
|
+
var IntegrationBranchRequest2 = Schema19.Struct({ repoBindingId: Schema19.optional(Schema19.String) });
|
|
3599
|
+
var IntegrationBranch2 = Schema19.Struct({
|
|
3600
|
+
repoBindingId: Schema19.String,
|
|
3601
|
+
branch: Schema19.String,
|
|
3602
|
+
revision: Schema19.String
|
|
3603
|
+
});
|
|
3604
|
+
var MergeChangeRequestRequest2 = Schema19.Struct({ changeRequestId: Schema19.String });
|
|
3605
|
+
var MergeResult2 = Schema19.Union([
|
|
3606
|
+
Schema19.Struct({ status: Schema19.Literal("merged"), revision: Schema19.String }),
|
|
3607
|
+
Schema19.Struct({ status: Schema19.Literal("conflict") })
|
|
3608
|
+
]);
|
|
3609
|
+
var CommentRequest2 = Schema19.Struct({ changeRequestId: Schema19.String, body: Schema19.String });
|
|
3610
|
+
var ReleaseRequest2 = Schema19.Struct({
|
|
3611
|
+
tag: Schema19.String,
|
|
3612
|
+
revision: Schema19.optional(Schema19.String),
|
|
3613
|
+
title: Schema19.String,
|
|
3614
|
+
notes: Schema19.String
|
|
3615
|
+
});
|
|
3616
|
+
var ReleaseResult2 = Schema19.Struct({ tag: Schema19.String, revision: Schema19.String, url: Schema19.String });
|
|
3617
|
+
|
|
3618
|
+
class ChangeRequestActivity2 extends Context2.Service()("@kitman-sh/sdk/loop/ChangeRequestActivity") {
|
|
3619
|
+
}
|
|
3620
|
+
|
|
3621
|
+
class WriteBackActivity2 extends Context2.Service()("@kitman-sh/sdk/loop/WriteBackActivity") {
|
|
3622
|
+
}
|
|
3623
|
+
|
|
3624
|
+
class ArtifactActivity2 extends Context2.Service()("@kitman-sh/sdk/loop/ArtifactActivity") {
|
|
3625
|
+
}
|
|
3626
|
+
|
|
3627
|
+
class NoteActivity2 extends Context2.Service()("@kitman-sh/sdk/loop/NoteActivity") {
|
|
3628
|
+
}
|
|
3629
|
+
|
|
3630
|
+
class CommentActivity2 extends Context2.Service()("@kitman-sh/sdk/loop/CommentActivity") {
|
|
3631
|
+
}
|
|
3632
|
+
|
|
3633
|
+
class CreateTasksActivity2 extends Context2.Service()("@kitman-sh/sdk/loop/CreateTasksActivity") {
|
|
3634
|
+
}
|
|
3635
|
+
|
|
3636
|
+
class IntegrationBranchActivity2 extends Context2.Service()("@kitman-sh/sdk/loop/IntegrationBranchActivity") {
|
|
3637
|
+
}
|
|
3638
|
+
|
|
3639
|
+
class MergeChangeRequestActivity2 extends Context2.Service()("@kitman-sh/sdk/loop/MergeChangeRequestActivity") {
|
|
3640
|
+
}
|
|
3641
|
+
|
|
3642
|
+
class ReleaseActivity2 extends Context2.Service()("@kitman-sh/sdk/loop/ReleaseActivity") {
|
|
3643
|
+
}
|
|
3644
|
+
var hostActivity = (name, kind, capability, success, execute) => takeStep2(name, kind, capability, Activity2.make({ name: `${kind}/${name}`, success, error: StepFailed2, execute }));
|
|
3645
|
+
var changeRequest2 = (name, request) => hostActivity(name, "change_request", "change_request", ChangeRequestResult2, Effect5.gen(function* () {
|
|
3646
|
+
return yield* (yield* ChangeRequestActivity2).run(request, name);
|
|
3647
|
+
}));
|
|
3648
|
+
var writeBack2 = (name, request) => hostActivity(name, "write_back", "write_back", Schema19.Void, Effect5.gen(function* () {
|
|
3649
|
+
return yield* (yield* WriteBackActivity2).run(request, name);
|
|
3650
|
+
}));
|
|
3651
|
+
var artifact2 = (name, request) => hostActivity(name, "artifact", undefined, ArtifactResult2, Effect5.gen(function* () {
|
|
3652
|
+
return yield* (yield* ArtifactActivity2).run(request, name);
|
|
3653
|
+
}));
|
|
3654
|
+
var note2 = (name, request) => hostActivity(name, "note", undefined, Schema19.Void, Effect5.gen(function* () {
|
|
3655
|
+
return yield* (yield* NoteActivity2).run(request, name);
|
|
3656
|
+
}));
|
|
3657
|
+
var comment2 = (name, request) => hostActivity(name, "comment", "post_comment", Schema19.Void, Effect5.gen(function* () {
|
|
3658
|
+
return yield* (yield* CommentActivity2).run(request, name);
|
|
3659
|
+
}));
|
|
3660
|
+
var createTasks2 = (name, request) => hostActivity(name, "create_tasks", "create_tasks", CreateTasksResult2, Effect5.gen(function* () {
|
|
3661
|
+
return yield* (yield* CreateTasksActivity2).run(request, name);
|
|
3662
|
+
}));
|
|
3663
|
+
var integrationBranch2 = (name, request) => hostActivity(name, "integration_branch", "merge_change_request", IntegrationBranch2, Effect5.gen(function* () {
|
|
3664
|
+
return yield* (yield* IntegrationBranchActivity2).run(request, name);
|
|
3665
|
+
}));
|
|
3666
|
+
var mergeChangeRequest2 = (name, request) => hostActivity(name, "merge_change_request", "merge_change_request", MergeResult2, Effect5.gen(function* () {
|
|
3667
|
+
return yield* (yield* MergeChangeRequestActivity2).run(request, name);
|
|
3668
|
+
}));
|
|
3669
|
+
var release2 = (name, request) => hostActivity(name, "release", "publish_release", ReleaseResult2, Effect5.gen(function* () {
|
|
3670
|
+
return yield* (yield* ReleaseActivity2).run(request, name);
|
|
3671
|
+
}));
|
|
3672
|
+
// packages/sdk/src/loop/test-loop.ts
|
|
3673
|
+
import * as ConfigProvider from "effect/ConfigProvider";
|
|
3674
|
+
import * as Context3 from "effect/Context";
|
|
3675
|
+
import * as Data2 from "effect/Data";
|
|
3676
|
+
import * as Effect6 from "effect/Effect";
|
|
3677
|
+
import * as Exit3 from "effect/Exit";
|
|
3678
|
+
import * as Layer from "effect/Layer";
|
|
3679
|
+
import * as Option2 from "effect/Option";
|
|
3680
|
+
import * as Schema20 from "effect/Schema";
|
|
3681
|
+
import { DurableDeferred as DurableDeferred2, Workflow, WorkflowEngine } from "effect/workflow";
|
|
3682
|
+
var LoopJournal2 = Schema20.Struct({
|
|
3683
|
+
activities: Schema20.Record(Schema20.String, Schema20.Json),
|
|
3684
|
+
deferreds: Schema20.Record(Schema20.String, Schema20.Json)
|
|
3685
|
+
});
|
|
3686
|
+
|
|
3687
|
+
class ScriptedFailure2 extends Data2.TaggedClass("ScriptedFailure") {
|
|
3688
|
+
}
|
|
3689
|
+
var scriptedFailure2 = (reason) => new ScriptedFailure2({ reason });
|
|
3690
|
+
var defaultActivities = {
|
|
3691
|
+
changeRequest: {
|
|
3692
|
+
run: () => Effect6.succeed({ id: "change-request-1", number: "1", url: "test://change-requests/1" })
|
|
3693
|
+
},
|
|
3694
|
+
writeBack: { run: () => Effect6.void },
|
|
3695
|
+
artifact: { run: (request) => Effect6.succeed({ artifactId: request.title }) },
|
|
3696
|
+
note: { run: () => Effect6.void },
|
|
3697
|
+
comment: { run: () => Effect6.void },
|
|
3698
|
+
createTasks: {
|
|
3699
|
+
run: (request) => Effect6.succeed({ tasks: request.tickets.map((ticket) => ({ key: ticket.key, taskId: `task-${ticket.key}` })) })
|
|
3700
|
+
},
|
|
3701
|
+
integrationBranch: {
|
|
3702
|
+
run: (request) => Effect6.succeed({
|
|
3703
|
+
repoBindingId: request.repoBindingId ?? "repo",
|
|
3704
|
+
branch: "kitman/run/integration",
|
|
3705
|
+
revision: "integration-head"
|
|
3706
|
+
})
|
|
3707
|
+
},
|
|
3708
|
+
mergeChangeRequest: {
|
|
3709
|
+
run: (request) => Effect6.succeed({ status: "merged", revision: `merged-${request.changeRequestId}` })
|
|
3710
|
+
},
|
|
3711
|
+
release: {
|
|
3712
|
+
run: (request) => Effect6.succeed({
|
|
3713
|
+
tag: request.tag,
|
|
3714
|
+
revision: request.revision ?? "base-head",
|
|
3715
|
+
url: `test://releases/${request.tag}`
|
|
3716
|
+
})
|
|
3717
|
+
}
|
|
3718
|
+
};
|
|
3719
|
+
var withoutServices = (effect) => Effect6.orDie(Effect6.provide(effect, Context3.empty()));
|
|
3720
|
+
var deferredExit = (deferred) => Schema20.Exit(Schema20.toCodecJson(deferred.successSchema), Schema20.toCodecJson(deferred.errorSchema), Schema20.toCodecJson(Schema20.Defect()));
|
|
3721
|
+
var journaled = (engine, journal, ran) => ({
|
|
3722
|
+
...engine,
|
|
3723
|
+
activityExecute: (activity, attempt) => Effect6.gen(function* () {
|
|
3724
|
+
const key = `${activity.name}/${attempt}`;
|
|
3725
|
+
const recorded = journal.activities[key];
|
|
3726
|
+
if (recorded !== undefined)
|
|
3727
|
+
return new Workflow.Complete({
|
|
3728
|
+
exit: yield* withoutServices(Schema20.decodeEffect(Schema20.toCodecJson(activity.exitSchema))(recorded))
|
|
3729
|
+
});
|
|
3730
|
+
const result = yield* engine.activityExecute(activity, attempt);
|
|
3731
|
+
if (result instanceof Workflow.Complete) {
|
|
3732
|
+
ran.push(activity.name);
|
|
3733
|
+
journal.activities[key] = yield* withoutServices(Schema20.encodeEffect(Schema20.toCodecJson(activity.exitSchema))(result.exit));
|
|
3734
|
+
}
|
|
3735
|
+
return result;
|
|
3736
|
+
}),
|
|
3737
|
+
deferredResult: (deferred) => Effect6.gen(function* () {
|
|
3738
|
+
const recorded = journal.deferreds[deferred.name];
|
|
3739
|
+
if (recorded !== undefined)
|
|
3740
|
+
return Option2.some(yield* withoutServices(Schema20.decodeEffect(Schema20.toCodecJson(deferredExit(deferred)))(recorded)));
|
|
3741
|
+
const result = yield* engine.deferredResult(deferred);
|
|
3742
|
+
if (Option2.isSome(result))
|
|
3743
|
+
journal.deferreds[deferred.name] = yield* withoutServices(Schema20.encodeEffect(Schema20.toCodecJson(deferredExit(deferred)))(result.value));
|
|
3744
|
+
return result;
|
|
3745
|
+
})
|
|
3746
|
+
});
|
|
3747
|
+
var scriptedExit = (scripted, failure) => scripted === undefined ? Exit3.fail(failure("nothing was scripted for this Step")) : scripted instanceof ScriptedFailure2 ? Exit3.fail(failure(scripted.reason)) : Exit3.succeed(scripted);
|
|
3748
|
+
var scriptedHost = (script, engine, agentLaunches, childLaunches) => {
|
|
3749
|
+
const resolve = (deferred, token, exit) => DurableDeferred2.done(deferred, { token, exit }).pipe(Effect6.provideService(WorkflowEngine.WorkflowEngine, engine));
|
|
3750
|
+
return {
|
|
3751
|
+
startAgentWork: (launch) => Effect6.andThen(Effect6.sync(() => agentLaunches.push({
|
|
3752
|
+
step: launch.step,
|
|
3753
|
+
agent: launch.agent,
|
|
3754
|
+
prompt: launch.prompt,
|
|
3755
|
+
...launch.secrets === undefined ? undefined : { secrets: launch.secrets }
|
|
3756
|
+
})), resolve(agentWorkDeferred2(launch.step), launch.token, scriptedExit(script.outputs?.[launch.step], (reason) => new StepFailed2({ step: launch.step, reason })))),
|
|
3757
|
+
putQuestion: (launch) => {
|
|
3758
|
+
const answer = script.answers?.[launch.step];
|
|
3759
|
+
return resolve(answerDeferred2(launch.step), launch.token, answer === undefined ? Exit3.fail(new StepFailed2({ step: launch.step, reason: "no answer was scripted" })) : Exit3.succeed(answer));
|
|
3760
|
+
},
|
|
3761
|
+
admitChild: (launch) => Effect6.andThen(Effect6.sync(() => childLaunches.push({ step: launch.step, loop: launch.loop, input: launch.input })), resolve(childDeferred2(launch.step), launch.token, scriptedExit(script.children?.[launch.step], (reason) => new ChildFailed2({ step: launch.step, loop: launch.loop, reason })))),
|
|
3762
|
+
awaitEvent: (launch) => {
|
|
3763
|
+
const event = script.events?.[launch.step];
|
|
3764
|
+
return resolve(eventDeferred2(launch.step), launch.token, event === undefined ? Exit3.fail(new WaitTimedOut2({ step: launch.step, event: launch.event })) : Exit3.succeed(event));
|
|
3765
|
+
},
|
|
3766
|
+
startVerification: (launch) => {
|
|
3767
|
+
const scripted = script.verifications?.[launch.step];
|
|
3768
|
+
return resolve(verifyDeferred2(launch.step), launch.token, scripted instanceof ScriptedFailure2 ? Exit3.fail(new StepFailed2({ step: launch.step, reason: scripted.reason })) : Exit3.succeed(scripted ?? {
|
|
3769
|
+
revision: launch.revision ?? "head",
|
|
3770
|
+
tree: launch.revision ?? "head",
|
|
3771
|
+
passed: true,
|
|
3772
|
+
checks: []
|
|
3773
|
+
}));
|
|
3774
|
+
}
|
|
3775
|
+
};
|
|
3776
|
+
};
|
|
3777
|
+
var loopWorkflow2 = (loop) => Workflow.make(`kitman-loop/${loop.id}`, {
|
|
3778
|
+
payload: { input: Schema20.Json },
|
|
3779
|
+
idempotencyKey: () => loop.id,
|
|
3780
|
+
success: loop.output,
|
|
3781
|
+
error: Schema20.declare((_error) => true)
|
|
3782
|
+
});
|
|
3783
|
+
var executeLoop2 = (loop, runtime) => ({ input }) => Effect6.gen(function* () {
|
|
3784
|
+
const decoded = yield* Schema20.decodeEffect(Schema20.toCodecJson(loop.input))(input).pipe(Effect6.mapError((error) => new InputInvalid2({ loop: loop.id, message: error.message })));
|
|
3785
|
+
const run = LoopRun2.of({
|
|
3786
|
+
loop: loop.id,
|
|
3787
|
+
agents: loop.agents,
|
|
3788
|
+
granted: runtime.granted,
|
|
3789
|
+
secrets: new Set(loop.secrets),
|
|
3790
|
+
names: new Set,
|
|
3791
|
+
steps: []
|
|
3792
|
+
});
|
|
3793
|
+
runtime.onRun?.(run);
|
|
3794
|
+
return yield* loop.run(decoded).pipe(Effect6.provideService(LoopRun2, run), Effect6.provideService(LoopHost2, runtime.host), Effect6.provideService(ChangeRequestActivity2, runtime.activities.changeRequest), Effect6.provideService(WriteBackActivity2, runtime.activities.writeBack), Effect6.provideService(ArtifactActivity2, runtime.activities.artifact), Effect6.provideService(NoteActivity2, runtime.activities.note), Effect6.provideService(CommentActivity2, runtime.activities.comment), Effect6.provideService(CreateTasksActivity2, runtime.activities.createTasks), Effect6.provideService(IntegrationBranchActivity2, runtime.activities.integrationBranch), Effect6.provideService(MergeChangeRequestActivity2, runtime.activities.mergeChangeRequest), Effect6.provideService(ReleaseActivity2, runtime.activities.release));
|
|
3795
|
+
});
|
|
3796
|
+
var testLoop2 = (loop, script) => {
|
|
3797
|
+
const journal = {
|
|
3798
|
+
activities: { ...script.journal?.activities },
|
|
3799
|
+
deferreds: { ...script.journal?.deferreds }
|
|
3800
|
+
};
|
|
3801
|
+
const ran = [];
|
|
3802
|
+
const agentLaunches = [];
|
|
3803
|
+
const childLaunches = [];
|
|
3804
|
+
let latestSteps = [];
|
|
3805
|
+
const granted = new Set((script.grant ?? loop.capabilities).filter((capability) => loop.capabilities.includes(capability)));
|
|
3806
|
+
const activities = { ...defaultActivities, ...script.activities };
|
|
3807
|
+
const workflow = loopWorkflow2(loop);
|
|
3808
|
+
const execute = (payload) => Effect6.gen(function* () {
|
|
3809
|
+
const engine = yield* WorkflowEngine.WorkflowEngine;
|
|
3810
|
+
return yield* executeLoop2(loop, {
|
|
3811
|
+
host: scriptedHost(script, engine, agentLaunches, childLaunches),
|
|
3812
|
+
activities,
|
|
3813
|
+
granted,
|
|
3814
|
+
onRun: (run) => {
|
|
3815
|
+
latestSteps = run.steps;
|
|
3816
|
+
}
|
|
3817
|
+
})(payload).pipe(Effect6.provideService(WorkflowEngine.WorkflowEngine, journaled(engine, journal, ran)));
|
|
3818
|
+
});
|
|
3819
|
+
return Effect6.gen(function* () {
|
|
3820
|
+
const result = yield* Effect6.exit(workflow.execute({ input: script.input }).pipe(Effect6.provideService(ConfigProvider.ConfigProvider, ConfigProvider.fromUnknown(script.secrets ?? {}))));
|
|
3821
|
+
return { result, steps: latestSteps, journal, activities: ran, agentLaunches, childLaunches };
|
|
3822
|
+
}).pipe(Effect6.provide(workflow.toLayer(execute).pipe(Layer.provideMerge(WorkflowEngine.layerMemory))));
|
|
3823
|
+
};
|
|
3824
|
+
// packages/sdk/src/loop/review.ts
|
|
3825
|
+
import * as Schema21 from "effect/Schema";
|
|
3826
|
+
var Severity2 = Schema21.Literals(["blocker", "major", "minor"]);
|
|
3827
|
+
var Finding2 = Schema21.Struct({
|
|
3828
|
+
severity: Severity2,
|
|
3829
|
+
file: Schema21.String,
|
|
3830
|
+
line: Schema21.Int,
|
|
3831
|
+
detail: Schema21.String
|
|
3832
|
+
});
|
|
3833
|
+
var MergedFinding2 = Schema21.Struct({
|
|
3834
|
+
id: Schema21.String,
|
|
3835
|
+
...Finding2.fields,
|
|
3836
|
+
seats: Schema21.Array(Schema21.String)
|
|
3837
|
+
});
|
|
3838
|
+
var Rebuttal2 = Schema21.Struct({ findingId: Schema21.String, reason: Schema21.String });
|
|
3839
|
+
var RebuttalVerdict2 = Schema21.Struct({ findingId: Schema21.String, accepted: Schema21.Boolean });
|
|
3840
|
+
var ScopeJudgement2 = Schema21.Struct({ met: Schema21.Boolean, unmet: Schema21.Array(Schema21.String) });
|
|
3841
|
+
var rank = { blocker: 0, major: 1, minor: 2 };
|
|
3842
|
+
var isBlocking2 = (finding) => finding.severity !== "minor";
|
|
3843
|
+
var mergeFindings2 = (bySeat) => {
|
|
3844
|
+
const merged = new Map;
|
|
3845
|
+
for (const [seat, findings] of Object.entries(bySeat))
|
|
3846
|
+
for (const finding of findings) {
|
|
3847
|
+
const id = `${finding.file}:${finding.line}`;
|
|
3848
|
+
const known = merged.get(id);
|
|
3849
|
+
const seats = [...new Set([...known?.seats ?? [], seat])];
|
|
3850
|
+
const worst = known === undefined || rank[finding.severity] < rank[known.severity] ? finding : known;
|
|
3851
|
+
merged.set(id, { id, severity: worst.severity, file: worst.file, line: worst.line, detail: worst.detail, seats });
|
|
3852
|
+
}
|
|
3853
|
+
return [...merged.values()].toSorted((left, right) => rank[left.severity] - rank[right.severity]);
|
|
3854
|
+
};
|
|
3855
|
+
var splitDisputed2 = (findings, rebuttals) => {
|
|
3856
|
+
const disputed = [];
|
|
3857
|
+
const undisputed = [];
|
|
3858
|
+
for (const finding of findings) {
|
|
3859
|
+
const rebuttal = rebuttals.find((entry) => entry.findingId === finding.id);
|
|
3860
|
+
if (rebuttal === undefined)
|
|
3861
|
+
undisputed.push(finding);
|
|
3862
|
+
else
|
|
3863
|
+
disputed.push({ finding, rebuttal });
|
|
3864
|
+
}
|
|
3865
|
+
return { disputed, undisputed };
|
|
3866
|
+
};
|
|
3867
|
+
var settleRound2 = (round) => {
|
|
3868
|
+
const { disputed, undisputed } = splitDisputed2(round.findings, round.rebuttals);
|
|
3869
|
+
const accepted = (entry) => {
|
|
3870
|
+
const verdicts = round.verdicts.filter((verdict) => verdict.findingId === entry.finding.id);
|
|
3871
|
+
return verdicts.length > 0 && verdicts.every((verdict) => verdict.accepted);
|
|
3872
|
+
};
|
|
3873
|
+
return {
|
|
3874
|
+
open: undisputed,
|
|
3875
|
+
withdrawn: disputed.filter(accepted),
|
|
3876
|
+
standing: disputed.filter((entry) => !accepted(entry))
|
|
3877
|
+
};
|
|
3878
|
+
};
|
|
3879
|
+
var rallyStop2 = (input) => {
|
|
3880
|
+
const open = input.settled.open.filter(isBlocking2).map((finding) => finding.id);
|
|
3881
|
+
const standing = input.settled.standing.flatMap((entry) => isBlocking2(entry.finding) ? [entry.finding.id] : []);
|
|
3882
|
+
const unsettled = [...open, ...standing];
|
|
3883
|
+
const stop = (reason) => ({ stop: true, reason, unsettled });
|
|
3884
|
+
if (unsettled.length === 0)
|
|
3885
|
+
return stop("settled");
|
|
3886
|
+
if (standing.length > 0)
|
|
3887
|
+
return stop("dispute_stands");
|
|
3888
|
+
if (input.previous !== undefined && sameIds(input.previous, unsettled))
|
|
3889
|
+
return stop("findings_returned");
|
|
3890
|
+
return input.round >= input.maxRounds ? stop("round_cap") : { stop: false };
|
|
3891
|
+
};
|
|
3892
|
+
var sameIds = (left, right) => left.length === right.length && left.every((id) => right.includes(id));
|
|
3893
|
+
// packages/sdk/src/loop/check.ts
|
|
3894
|
+
import * as Cause2 from "effect/Cause";
|
|
3895
|
+
import * as Effect7 from "effect/Effect";
|
|
3896
|
+
import * as Exit5 from "effect/Exit";
|
|
3897
|
+
import * as Predicate2 from "effect/Predicate";
|
|
3898
|
+
import * as Schema22 from "effect/Schema";
|
|
3899
|
+
class CheckFailed2 extends Schema22.TaggedError()("CheckFailed", {
|
|
3900
|
+
loop: Schema22.String,
|
|
3901
|
+
check: Schema22.String,
|
|
3902
|
+
reason: Schema22.String
|
|
3903
|
+
}) {
|
|
3904
|
+
get detail() {
|
|
3905
|
+
return `Check "${this.check}": ${this.reason}`;
|
|
3906
|
+
}
|
|
3907
|
+
get message() {
|
|
3908
|
+
return `Loop "${this.loop}": ${this.detail}`;
|
|
3909
|
+
}
|
|
3910
|
+
}
|
|
3911
|
+
|
|
3912
|
+
class StepNamedTwice2 extends Schema22.TaggedError()("StepNamedTwice", {
|
|
3913
|
+
loop: Schema22.String,
|
|
3914
|
+
check: Schema22.String,
|
|
3915
|
+
step: Schema22.String
|
|
3916
|
+
}) {
|
|
3917
|
+
get detail() {
|
|
3918
|
+
return `Check "${this.check}": Step "${this.step}" is named twice`;
|
|
3919
|
+
}
|
|
3920
|
+
get message() {
|
|
3921
|
+
return `Loop "${this.loop}": ${this.detail}`;
|
|
3922
|
+
}
|
|
3923
|
+
}
|
|
3924
|
+
|
|
3925
|
+
class ReplayDiverged2 extends Schema22.TaggedError()("ReplayDiverged", {
|
|
3926
|
+
loop: Schema22.String,
|
|
3927
|
+
check: Schema22.String,
|
|
3928
|
+
first: Schema22.Array(Schema22.String),
|
|
3929
|
+
replay: Schema22.Array(Schema22.String),
|
|
3930
|
+
rerun: Schema22.Array(Schema22.String)
|
|
3931
|
+
}) {
|
|
3932
|
+
get detail() {
|
|
3933
|
+
const steps = (names) => names.join(", ") || "no Steps";
|
|
3934
|
+
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.`;
|
|
3935
|
+
}
|
|
3936
|
+
get message() {
|
|
3937
|
+
return `Loop "${this.loop}": ${this.detail}`;
|
|
3938
|
+
}
|
|
3939
|
+
}
|
|
3940
|
+
var LoopCheckError2 = Schema22.Union([CheckFailed2, StepNamedTwice2, ReplayDiverged2]);
|
|
3941
|
+
var checkLoop2 = (loop, check) => Effect7.gen(function* () {
|
|
3942
|
+
const first = yield* testLoop2(loop, check.script);
|
|
3943
|
+
if (Exit5.isFailure(first.result)) {
|
|
3944
|
+
const error = Cause2.squash(first.result.cause);
|
|
3945
|
+
if (Predicate2.isTagged(error, "DuplicateStep") && Predicate2.hasProperty(error, "step"))
|
|
3946
|
+
return yield* new StepNamedTwice2({ loop: loop.id, check: check.name, step: String(error.step) });
|
|
3947
|
+
return yield* new CheckFailed2({
|
|
3948
|
+
loop: loop.id,
|
|
3949
|
+
check: check.name,
|
|
3950
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
3951
|
+
});
|
|
3952
|
+
}
|
|
3953
|
+
const replay = yield* testLoop2(loop, { ...check.script, journal: first.journal });
|
|
3954
|
+
const names = (steps) => steps.map((step) => step.name);
|
|
3955
|
+
if (replay.activities.length > 0 || names(replay.steps).join() !== names(first.steps).join())
|
|
3956
|
+
return yield* new ReplayDiverged2({
|
|
3957
|
+
loop: loop.id,
|
|
3958
|
+
check: check.name,
|
|
3959
|
+
first: names(first.steps),
|
|
3960
|
+
replay: names(replay.steps),
|
|
3961
|
+
rerun: replay.activities
|
|
3962
|
+
});
|
|
3963
|
+
});
|
|
3964
|
+
// packages/sdk/src/loop/config.ts
|
|
3965
|
+
var defineConfig2 = (config) => config;
|
|
3966
|
+
export { AgentSandboxNetwork, guard, Id, Timestamp, LoopStepOutput, StepBrief, LoopCapabilities2, LoopManifest, AgentDeclaration, KitInstallationDeclaration, KitAssignmentDeclaration, PackageDeclarations, LoopOutcome2, defineLoop2, ManifestInvalid2, jsonSchemaOf2, loopManifest2, EvidenceCheck2, VerifyResult2, OutcomeTable2, evidenceGate2, StepFailed2, OutputInvalid2, QuestionRefused2, WaitTimedOut2, ChildFailed2, CapabilityDenied2, DuplicateStep2, InputInvalid2, LoopEvent2, LoopRun2, LoopHost2, agentWorkDeferred2, answerDeferred2, childDeferred2, eventDeferred2, verifyDeferred2, takeStep2, agentWork2, ask2, call2, waitFor2, verify2, suggestVerification2, PlanTicket2, PlanTickets2, BlockingCycle2, planWaves2, ChangeRequestRequest2, ChangeRequestResult2, WriteBackMilestones2, WriteBackRequest2, ArtifactRequest2, ArtifactResult2, NoteRequest2, CreateTasksRequest2, CreateTasksResult2, IntegrationBranchRequest2, IntegrationBranch2, MergeChangeRequestRequest2, MergeResult2, CommentRequest2, ReleaseRequest2, ReleaseResult2, ChangeRequestActivity2, WriteBackActivity2, ArtifactActivity2, NoteActivity2, CommentActivity2, CreateTasksActivity2, IntegrationBranchActivity2, MergeChangeRequestActivity2, ReleaseActivity2, changeRequest2, writeBack2, artifact2, note2, comment2, createTasks2, integrationBranch2, mergeChangeRequest2, release2, LoopJournal2, ScriptedFailure2, scriptedFailure2, loopWorkflow2, executeLoop2, testLoop2, Severity2, Finding2, MergedFinding2, Rebuttal2, RebuttalVerdict2, ScopeJudgement2, isBlocking2, mergeFindings2, splitDisputed2, settleRound2, rallyStop2, CheckFailed2, StepNamedTwice2, ReplayDiverged2, LoopCheckError2, checkLoop2, defineConfig2 };
|