@themoltnet/agent-daemon 0.42.1 → 0.43.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/README.md +36 -23
- package/dist/cli.js +1256 -1337
- package/package.json +9 -8
package/dist/cli.js
CHANGED
|
@@ -5,10 +5,10 @@ import { Type } from "typebox";
|
|
|
5
5
|
import "multiformats/cid";
|
|
6
6
|
import "multiformats/codecs/json";
|
|
7
7
|
import "multiformats/hashes/sha2";
|
|
8
|
-
import
|
|
8
|
+
import "typebox/value";
|
|
9
9
|
import { dirname, join, resolve } from "node:path";
|
|
10
10
|
import { parseArgs, promisify } from "node:util";
|
|
11
|
-
import { AgentRuntime, ApiTaskReporter, ApiTaskSource, PollingApiTaskSource } from "@themoltnet/agent-runtime";
|
|
11
|
+
import { AgentRuntime, ApiTaskReporter, ApiTaskSource, PollingApiTaskSource, resolveProfileWarmSessionTtlSec, resolveRuntimeProfile, resolveRuntimeProfiles, validateRuntimeProfilePrerequisites } from "@themoltnet/agent-runtime";
|
|
12
12
|
import { GuestEnvironmentBoundaryError, assertGuestEnvironmentBoundary, createPiRetryTriage, findMainWorktree, isResolvedPathInsideRoot, normalizeRetryTriageResult, redactRetryTriageSecrets } from "@themoltnet/pi-runtime";
|
|
13
13
|
import { execFile, execFileSync } from "node:child_process";
|
|
14
14
|
import { createReadStream, createWriteStream, existsSync, mkdirSync, readdirSync, realpathSync, rmSync } from "node:fs";
|
|
@@ -41,64 +41,6 @@ import { mkdir, realpath, stat } from "node:fs/promises";
|
|
|
41
41
|
import { pipeline } from "node:stream/promises";
|
|
42
42
|
import { Writable } from "node:stream";
|
|
43
43
|
import { createGzip } from "node:zlib";
|
|
44
|
-
//#region ../../libs/tasks/src/context.ts
|
|
45
|
-
/**
|
|
46
|
-
* How an executor delivers a context entry to its underlying LLM.
|
|
47
|
-
* V1 bindings only; Tier-2 (reference_file, mcp_resource, imported_file,
|
|
48
|
-
* tool_response_seed, additional_context_hook) ship in a later slice.
|
|
49
|
-
*/
|
|
50
|
-
var CONTEXT_BINDINGS = [
|
|
51
|
-
"skill",
|
|
52
|
-
"context_inline",
|
|
53
|
-
"prompt_prefix",
|
|
54
|
-
"user_inline"
|
|
55
|
-
];
|
|
56
|
-
/** Maximum UTF-16 code units accepted in one ContextRef content field. */
|
|
57
|
-
var CONTEXT_REF_MAX_CONTENT_LENGTH = 65536;
|
|
58
|
-
var ContextBinding = Type.Unsafe(Type.Union(CONTEXT_BINDINGS.map((binding) => Type.Literal(binding)), { $id: "ContextBinding" }));
|
|
59
|
-
/**
|
|
60
|
-
* One context entry. Bytes are inlined: the proposer chose them, and the
|
|
61
|
-
* task's `inputCid` already pins the entire input — including
|
|
62
|
-
* `context[]` — so we don't need a separate per-entry hash, fetcher, or
|
|
63
|
-
* flagged-content gate. Tasks reference rendered packs (or any other
|
|
64
|
-
* external content) by copying their bytes into `content` at task
|
|
65
|
-
* creation time.
|
|
66
|
-
*
|
|
67
|
-
* - `slug` — short identifier the daemon uses to disambiguate
|
|
68
|
-
* entries. For `skill` binding it becomes the directory
|
|
69
|
-
* name under the runtime's skill discovery path. Must be
|
|
70
|
-
* kebab-case-safe (alphanumeric + dashes/underscores).
|
|
71
|
-
* - `binding` — how the bytes are delivered to the LLM (see above).
|
|
72
|
-
* - `content` — UTF-8 text. Capped at 65,536 UTF-16 code units per
|
|
73
|
-
* entry; total per-task context bytes are bounded by the
|
|
74
|
-
* soft `maxItems` cap and per-binding daemon limits.
|
|
75
|
-
* Raised from 32 KiB in 2026-05 — protocol-heavy operator
|
|
76
|
-
* skills (e.g. `.claude/skills/legreffier/SKILL.md`) ship
|
|
77
|
-
* at ~35 KiB inline, and the original cap was sized for
|
|
78
|
-
* short example skills, not the kind of skill the eval
|
|
79
|
-
* substrate is dogfooded on (#943, #823).
|
|
80
|
-
*/
|
|
81
|
-
var ContextRef = Type.Object({
|
|
82
|
-
slug: Type.String({
|
|
83
|
-
minLength: 1,
|
|
84
|
-
maxLength: 64,
|
|
85
|
-
pattern: "^[a-zA-Z0-9_-]+$"
|
|
86
|
-
}),
|
|
87
|
-
binding: ContextBinding,
|
|
88
|
-
content: Type.String({
|
|
89
|
-
minLength: 1,
|
|
90
|
-
maxLength: CONTEXT_REF_MAX_CONTENT_LENGTH
|
|
91
|
-
})
|
|
92
|
-
}, {
|
|
93
|
-
$id: "ContextRef",
|
|
94
|
-
additionalProperties: false
|
|
95
|
-
});
|
|
96
|
-
/** Reusable input fragment for any task type. Soft cap at 5 items. */
|
|
97
|
-
var TaskContext = Type.Array(ContextRef, {
|
|
98
|
-
$id: "TaskContext",
|
|
99
|
-
maxItems: 5
|
|
100
|
-
});
|
|
101
|
-
//#endregion
|
|
102
44
|
//#region ../../libs/tasks/src/rubric.ts
|
|
103
45
|
/**
|
|
104
46
|
* Rubric — structured acceptance criteria used by judgment tasks.
|
|
@@ -201,380 +143,868 @@ function validateRubricWeights(rubric) {
|
|
|
201
143
|
return null;
|
|
202
144
|
}
|
|
203
145
|
//#endregion
|
|
204
|
-
//#region ../../libs/tasks/src/
|
|
146
|
+
//#region ../../libs/tasks/src/success-criteria.ts
|
|
205
147
|
/**
|
|
206
|
-
*
|
|
207
|
-
*
|
|
148
|
+
* SuccessCriteria — proposer-stated acceptance criteria, evaluated in two
|
|
149
|
+
* complementary places.
|
|
208
150
|
*
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
151
|
+
* Before this envelope existed, criteria were scattered: a vestigial
|
|
152
|
+
* `criteriaCid` column nobody resolved, free-form prose on
|
|
153
|
+
* `fulfill_brief.input`, and inline `rubric` / `criteria[]` fields on
|
|
154
|
+
* judgment-task inputs. None of those were machine-verifiable
|
|
155
|
+
* end-to-end.
|
|
212
156
|
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
157
|
+
* This module defines a single, content-addressable envelope a proposer
|
|
158
|
+
* attaches to any task type. It has four orthogonal sections — pick
|
|
159
|
+
* whichever apply per task type:
|
|
160
|
+
*
|
|
161
|
+
* - `gates` Promise-level structural/process checks
|
|
162
|
+
* - `assertions` Declarative claims about output JSON
|
|
163
|
+
* - `rubric` Weighted-criteria scoring instrument, reused
|
|
164
|
+
* verbatim from `./rubric.ts`.
|
|
165
|
+
* - `sideEffects` Required process side-effects (e.g. diary entry)
|
|
166
|
+
*
|
|
167
|
+
* ## Two roles, two task types
|
|
168
|
+
*
|
|
169
|
+
* **Producer self-assessment** (fulfillment tasks: `fulfill_brief`,
|
|
170
|
+
* `curate_pack`, `render_pack`). The producer **LLM** evaluates the
|
|
171
|
+
* criteria against its own output and emits a `VerificationRecord`
|
|
172
|
+
* inside `output.verification`. The daemon is pure passthrough — it
|
|
173
|
+
* does not run `evaluateAssertions`, does not inspect the verification
|
|
174
|
+
* record. The REST API is dumb storage; it never re-runs assertions and
|
|
175
|
+
* never runs LLMs. The cross-field rule
|
|
176
|
+
* `requireVerificationWhenCriteriaPresent` enforces "verification
|
|
177
|
+
* required iff successCriteria present" at task-output validation time
|
|
178
|
+
* (server-side schema check). Self-assessment is a truthful self-rating,
|
|
179
|
+
* NOT enforcement — `verification.passed=false` does not block /complete
|
|
180
|
+
* and does not affect `acceptedAttemptN`. See
|
|
181
|
+
* `docs/use/tasks-and-runtime.md` for the full producer/judge flow.
|
|
182
|
+
*
|
|
183
|
+
* **Binding evaluation** (judgment tasks: `assess_brief`, `judge_pack`).
|
|
184
|
+
* A separate task whose IS the application of `successCriteria` to
|
|
185
|
+
* someone else's output. Different agent (enforced at claim time), same
|
|
186
|
+
* envelope. The judge's verdict is binding: this is the *gate* in the
|
|
187
|
+
* MoltNet model. The rubric inside `successCriteria.rubric` IS the job
|
|
188
|
+
* spec for the judge.
|
|
189
|
+
*
|
|
190
|
+
* The clean chain: producer task with `successCriteria` → producer
|
|
191
|
+
* self-assesses honestly → proposer (or automation) creates a downstream
|
|
192
|
+
* judgment task that references the same `successCriteria` (or a
|
|
193
|
+
* stricter rubric) → judgment task delivers the binding verdict.
|
|
194
|
+
*
|
|
195
|
+
* Storage: SuccessCriteria lives inline at `task.input.successCriteria`,
|
|
196
|
+
* pinned via the task's `inputCid`. No separate column or hash. When
|
|
197
|
+
* #881 lands, the `rubric` field can graduate to `{ rubricCid }` lookup
|
|
198
|
+
* without changing this envelope, and producer + judge tasks can pin
|
|
199
|
+
* the SAME rubric across the chain for end-to-end auditability.
|
|
215
200
|
*/
|
|
216
|
-
var
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
201
|
+
var SchemaCheckSpec = Type.Object({ schemaCid: Type.String({ minLength: 1 }) }, { additionalProperties: false });
|
|
202
|
+
var CidEqualsSpec = Type.Object({
|
|
203
|
+
path: Type.String({ minLength: 1 }),
|
|
204
|
+
expected: Type.String({ minLength: 1 })
|
|
205
|
+
}, { additionalProperties: false });
|
|
206
|
+
var SubmitToolCallGate = Type.Object({
|
|
207
|
+
id: Type.String({ minLength: 1 }),
|
|
208
|
+
kind: Type.Literal("submit-tool-call"),
|
|
209
|
+
description: Type.String({ minLength: 1 }),
|
|
210
|
+
required: Type.Boolean()
|
|
211
|
+
}, { additionalProperties: false });
|
|
212
|
+
var Gate = Type.Union([
|
|
213
|
+
SubmitToolCallGate,
|
|
214
|
+
Type.Object({
|
|
215
|
+
id: Type.String({ minLength: 1 }),
|
|
216
|
+
kind: Type.Literal("schema-check"),
|
|
217
|
+
spec: SchemaCheckSpec,
|
|
218
|
+
required: Type.Boolean()
|
|
219
|
+
}, { additionalProperties: false }),
|
|
220
|
+
Type.Object({
|
|
221
|
+
id: Type.String({ minLength: 1 }),
|
|
222
|
+
kind: Type.Literal("cid-equals"),
|
|
223
|
+
spec: CidEqualsSpec,
|
|
224
|
+
required: Type.Boolean()
|
|
225
|
+
}, { additionalProperties: false })
|
|
226
|
+
], { $id: "Gate" });
|
|
227
|
+
var AssertionOp = Type.Union([
|
|
228
|
+
Type.Literal("exists"),
|
|
229
|
+
Type.Literal("equals"),
|
|
230
|
+
Type.Literal("matches"),
|
|
231
|
+
Type.Literal("in-range"),
|
|
232
|
+
Type.Literal("min-length")
|
|
233
|
+
], { $id: "AssertionOp" });
|
|
234
|
+
var Assertion = Type.Object({
|
|
235
|
+
id: Type.String({ minLength: 1 }),
|
|
236
|
+
path: Type.String({ minLength: 1 }),
|
|
237
|
+
op: AssertionOp,
|
|
238
|
+
value: Type.Optional(Type.Unknown())
|
|
239
|
+
}, {
|
|
240
|
+
$id: "Assertion",
|
|
241
|
+
additionalProperties: false
|
|
220
242
|
});
|
|
221
|
-
var
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
243
|
+
var SideEffectsSpec = Type.Object({
|
|
244
|
+
diaryEntryRequired: Type.Optional(Type.Boolean()),
|
|
245
|
+
diaryEntryTags: Type.Optional(Type.Array(Type.String({ minLength: 1 }))),
|
|
246
|
+
referencedEntries: Type.Optional(Type.Integer({ minimum: 0 }))
|
|
247
|
+
}, {
|
|
248
|
+
$id: "SideEffectsSpec",
|
|
249
|
+
additionalProperties: false
|
|
225
250
|
});
|
|
226
|
-
var
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
Type.
|
|
231
|
-
Type.Number(
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
teamId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
237
|
-
provider: RuntimeModelProvider,
|
|
238
|
-
model: RuntimeModelName,
|
|
239
|
-
displayName: Type.Union([Type.String({ maxLength: 200 }), Type.Null()]),
|
|
240
|
-
description: Type.Union([Type.String({ maxLength: 4096 }), Type.Null()]),
|
|
241
|
-
capabilities: RuntimeModelCapabilities,
|
|
242
|
-
isActive: Type.Boolean(),
|
|
243
|
-
createdByAgentId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
244
|
-
createdByHumanId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
245
|
-
createdAt: Type.String({ format: "date-time" }),
|
|
246
|
-
updatedAt: Type.String({ format: "date-time" })
|
|
251
|
+
var SuccessCriteria = Type.Object({
|
|
252
|
+
version: Type.Literal(1),
|
|
253
|
+
gates: Type.Optional(Type.Array(Gate)),
|
|
254
|
+
assertions: Type.Optional(Type.Array(Assertion)),
|
|
255
|
+
rubric: Type.Optional(Rubric),
|
|
256
|
+
minComposite: Type.Optional(Type.Number({
|
|
257
|
+
minimum: 0,
|
|
258
|
+
maximum: 1
|
|
259
|
+
})),
|
|
260
|
+
sideEffects: Type.Optional(SideEffectsSpec)
|
|
247
261
|
}, {
|
|
248
|
-
$id: "
|
|
262
|
+
$id: "SuccessCriteria",
|
|
263
|
+
additionalProperties: false
|
|
264
|
+
});
|
|
265
|
+
var VerificationResultStatus = Type.Union([
|
|
266
|
+
Type.Literal("pass"),
|
|
267
|
+
Type.Literal("fail"),
|
|
268
|
+
Type.Literal("skip")
|
|
269
|
+
], { $id: "VerificationResultStatus" });
|
|
270
|
+
var VerificationResultKind = Type.Union([
|
|
271
|
+
Type.Literal("gate"),
|
|
272
|
+
Type.Literal("assertion"),
|
|
273
|
+
Type.Literal("rubric"),
|
|
274
|
+
Type.Literal("sideEffect")
|
|
275
|
+
], { $id: "VerificationResultKind" });
|
|
276
|
+
var VerificationResult = Type.Object({
|
|
277
|
+
id: Type.String({ minLength: 1 }),
|
|
278
|
+
kind: VerificationResultKind,
|
|
279
|
+
status: VerificationResultStatus,
|
|
280
|
+
detail: Type.Optional(Type.String())
|
|
281
|
+
}, {
|
|
282
|
+
$id: "VerificationResult",
|
|
283
|
+
additionalProperties: false
|
|
284
|
+
});
|
|
285
|
+
var VerificationRecord = Type.Object({
|
|
286
|
+
inputCid: Type.String({ minLength: 1 }),
|
|
287
|
+
results: Type.Array(VerificationResult),
|
|
288
|
+
passed: Type.Boolean({ description: "True iff every verification result has status \"pass\" or \"skip\"; false when any result has status \"fail\"." })
|
|
289
|
+
}, {
|
|
290
|
+
$id: "VerificationRecord",
|
|
249
291
|
additionalProperties: false
|
|
250
292
|
});
|
|
251
293
|
//#endregion
|
|
252
|
-
//#region ../../libs/tasks/src/
|
|
253
|
-
var
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
},
|
|
292
|
-
|
|
293
|
-
"artifact-planner@v1": {
|
|
294
|
-
description: "Minimal artifact-only context for bounded semantic classification and planning.",
|
|
295
|
-
fragments: ["artifact-planner-v1"]
|
|
296
|
-
},
|
|
297
|
-
"run-eval-direct@v1": {
|
|
298
|
-
description: "Minimal direct context for a short, isolated evaluation run.",
|
|
299
|
-
fragments: ["run-eval-direct-v1"]
|
|
300
|
-
},
|
|
301
|
-
"standard-engineering@v1": {
|
|
302
|
-
description: "Full opt-in operating guidance for engineering tasks that need diary research, accountable delivery, and verification discipline.",
|
|
303
|
-
fragments: [
|
|
304
|
-
"proactive-memory-v1",
|
|
305
|
-
"task-diary-discipline-v1",
|
|
306
|
-
"accountable-delivery-v1",
|
|
307
|
-
"judgment-diary-v1",
|
|
308
|
-
"verification-and-artifacts-v1"
|
|
309
|
-
]
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
};
|
|
313
|
-
function deepFreeze(value) {
|
|
314
|
-
if (value && typeof value === "object") {
|
|
315
|
-
for (const key of Object.keys(value)) deepFreeze(value[key]);
|
|
316
|
-
Object.freeze(value);
|
|
317
|
-
}
|
|
318
|
-
return value;
|
|
319
|
-
}
|
|
320
|
-
deepFreeze(RUNTIME_PROFILE_CONTEXT_CATALOGUE);
|
|
321
|
-
Object.freeze(Object.keys(RUNTIME_PROFILE_CONTEXT_CATALOGUE.recipes));
|
|
322
|
-
//#endregion
|
|
323
|
-
//#region ../../libs/models/src/credential-scopes.ts
|
|
324
|
-
var CREDENTIAL_SCOPES = {
|
|
325
|
-
AgentProfile: "agent:profile",
|
|
326
|
-
ConnectorInvoke: "connector:invoke",
|
|
327
|
-
CryptoSign: "crypto:sign",
|
|
328
|
-
DiaryManage: "diary:manage",
|
|
329
|
-
DiaryRead: "diary:read",
|
|
330
|
-
DiaryWrite: "diary:write",
|
|
331
|
-
HumanProfile: "human:profile",
|
|
332
|
-
KeyManage: "key:manage",
|
|
333
|
-
PackRead: "pack:read",
|
|
334
|
-
PackWrite: "pack:write",
|
|
335
|
-
RuntimeManage: "runtime:manage",
|
|
336
|
-
RuntimeRead: "runtime:read",
|
|
337
|
-
TaskClaim: "task:claim",
|
|
338
|
-
TaskExecute: "task:execute",
|
|
339
|
-
TaskManage: "task:manage",
|
|
340
|
-
TaskRead: "task:read",
|
|
341
|
-
TeamManage: "team:manage",
|
|
342
|
-
TeamRead: "team:read"
|
|
343
|
-
};
|
|
344
|
-
var ALL_CREDENTIAL_SCOPES = Object.freeze(Object.values(CREDENTIAL_SCOPES));
|
|
345
|
-
/**
|
|
346
|
-
* Minimum grant for the agent daemon. Task credentials attenuate this further
|
|
347
|
-
* to `task:execute` alone.
|
|
348
|
-
*/
|
|
349
|
-
var AGENT_CREDENTIAL_SCOPES = [
|
|
350
|
-
CREDENTIAL_SCOPES.AgentProfile,
|
|
351
|
-
CREDENTIAL_SCOPES.RuntimeRead,
|
|
352
|
-
CREDENTIAL_SCOPES.TaskRead,
|
|
353
|
-
CREDENTIAL_SCOPES.TaskClaim,
|
|
354
|
-
CREDENTIAL_SCOPES.TaskExecute
|
|
355
|
-
];
|
|
356
|
-
Object.freeze(ALL_CREDENTIAL_SCOPES.filter((scope) => scope !== CREDENTIAL_SCOPES.HumanProfile));
|
|
357
|
-
[
|
|
358
|
-
CREDENTIAL_SCOPES.AgentProfile,
|
|
359
|
-
CREDENTIAL_SCOPES.CryptoSign,
|
|
360
|
-
CREDENTIAL_SCOPES.DiaryManage,
|
|
361
|
-
CREDENTIAL_SCOPES.DiaryRead,
|
|
362
|
-
CREDENTIAL_SCOPES.DiaryWrite,
|
|
363
|
-
CREDENTIAL_SCOPES.HumanProfile,
|
|
364
|
-
CREDENTIAL_SCOPES.PackRead,
|
|
365
|
-
CREDENTIAL_SCOPES.PackWrite,
|
|
366
|
-
CREDENTIAL_SCOPES.TaskExecute,
|
|
367
|
-
CREDENTIAL_SCOPES.TaskManage,
|
|
368
|
-
CREDENTIAL_SCOPES.TaskRead,
|
|
369
|
-
CREDENTIAL_SCOPES.TeamManage,
|
|
370
|
-
CREDENTIAL_SCOPES.TeamRead
|
|
371
|
-
].filter((scope) => scope !== CREDENTIAL_SCOPES.HumanProfile);
|
|
372
|
-
//#endregion
|
|
373
|
-
//#region ../../libs/models/src/preview-sign.ts
|
|
374
|
-
function schemaRef$1(schema, id) {
|
|
375
|
-
return Type.Unsafe(Type.Ref(id));
|
|
376
|
-
}
|
|
377
|
-
var PreviewSignBase64UrlSchema = Type.String({
|
|
378
|
-
$id: "PreviewSignBase64Url",
|
|
379
|
-
minLength: 1,
|
|
380
|
-
maxLength: 5462,
|
|
381
|
-
pattern: "^[A-Za-z0-9_-]+$"
|
|
382
|
-
});
|
|
383
|
-
var PreviewSignSha256Base64UrlSchema = Type.String({
|
|
384
|
-
$id: "PreviewSignSha256Base64Url",
|
|
385
|
-
minLength: 43,
|
|
386
|
-
maxLength: 43,
|
|
387
|
-
pattern: "^[A-Za-z0-9_-]+$"
|
|
388
|
-
});
|
|
389
|
-
var PreviewSignP256DerSignatureBase64UrlSchema = Type.String({
|
|
390
|
-
$id: "PreviewSignP256DerSignatureBase64Url",
|
|
391
|
-
minLength: 11,
|
|
392
|
-
maxLength: 96,
|
|
393
|
-
pattern: "^[A-Za-z0-9_-]+$"
|
|
394
|
-
});
|
|
395
|
-
var PreviewSignEs256PublicKeySchema = Type.Object({
|
|
396
|
-
kty: Type.Literal(2),
|
|
397
|
-
algorithm: Type.Literal(-7),
|
|
398
|
-
curve: Type.Literal(1),
|
|
399
|
-
x: schemaRef$1(PreviewSignSha256Base64UrlSchema, "PreviewSignSha256Base64Url"),
|
|
400
|
-
y: schemaRef$1(PreviewSignSha256Base64UrlSchema, "PreviewSignSha256Base64Url")
|
|
294
|
+
//#region ../../libs/tasks/src/task-artifacts.ts
|
|
295
|
+
var TaskArtifact = Type.Object({
|
|
296
|
+
id: Type.String({ format: "uuid" }),
|
|
297
|
+
teamId: Type.String({ format: "uuid" }),
|
|
298
|
+
taskId: Type.String({ format: "uuid" }),
|
|
299
|
+
attemptN: Type.Union([Type.Integer({ minimum: 1 }), Type.Null()]),
|
|
300
|
+
kind: Type.String({
|
|
301
|
+
minLength: 1,
|
|
302
|
+
maxLength: 100
|
|
303
|
+
}),
|
|
304
|
+
title: Type.String({
|
|
305
|
+
minLength: 1,
|
|
306
|
+
maxLength: 255
|
|
307
|
+
}),
|
|
308
|
+
contentType: Type.String({
|
|
309
|
+
minLength: 1,
|
|
310
|
+
maxLength: 200
|
|
311
|
+
}),
|
|
312
|
+
contentEncoding: Type.Union([Type.String({
|
|
313
|
+
minLength: 1,
|
|
314
|
+
maxLength: 100
|
|
315
|
+
}), Type.Null()]),
|
|
316
|
+
sizeBytes: Type.Integer({ minimum: 0 }),
|
|
317
|
+
cid: Type.String({
|
|
318
|
+
minLength: 1,
|
|
319
|
+
maxLength: 100
|
|
320
|
+
}),
|
|
321
|
+
createdByAgentId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
322
|
+
expiresAt: Type.Union([Type.String({ format: "date-time" }), Type.Null()]),
|
|
323
|
+
createdAt: Type.String({ format: "date-time" })
|
|
324
|
+
}, { $id: "TaskArtifact" });
|
|
325
|
+
Type.Object({
|
|
326
|
+
artifacts: Type.Array(TaskArtifact),
|
|
327
|
+
nextCursor: Type.Union([Type.String({ minLength: 1 }), Type.Null()])
|
|
328
|
+
}, { $id: "TaskArtifactList" });
|
|
329
|
+
Type.Object({
|
|
330
|
+
limit: Type.Optional(Type.Integer({
|
|
331
|
+
minimum: 1,
|
|
332
|
+
maximum: 100
|
|
333
|
+
})),
|
|
334
|
+
cursor: Type.Optional(Type.String({ minLength: 1 }))
|
|
401
335
|
}, {
|
|
402
|
-
$id: "
|
|
336
|
+
$id: "ListTaskArtifactsQuery",
|
|
403
337
|
additionalProperties: false
|
|
404
338
|
});
|
|
405
|
-
var
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
x: schemaRef$1(PreviewSignSha256Base64UrlSchema, "PreviewSignSha256Base64Url"),
|
|
410
|
-
y: schemaRef$1(PreviewSignSha256Base64UrlSchema, "PreviewSignSha256Base64Url")
|
|
411
|
-
}, {
|
|
412
|
-
$id: "PreviewSignEcdhEsHkdf256PublicKey",
|
|
413
|
-
additionalProperties: false
|
|
339
|
+
var HeaderSafeContentType = Type.String({
|
|
340
|
+
minLength: 1,
|
|
341
|
+
maxLength: 200,
|
|
342
|
+
pattern: "^[\\x21-\\x7e][\\x20-\\x7e]*$"
|
|
414
343
|
});
|
|
415
|
-
var
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
344
|
+
var HeaderSafeContentEncoding = Type.String({
|
|
345
|
+
minLength: 1,
|
|
346
|
+
maxLength: 100,
|
|
347
|
+
pattern: "^[\\x21-\\x7e][\\x20-\\x7e]*$"
|
|
348
|
+
});
|
|
349
|
+
Type.Object({
|
|
350
|
+
kind: Type.String({
|
|
351
|
+
minLength: 1,
|
|
352
|
+
maxLength: 100
|
|
353
|
+
}),
|
|
354
|
+
title: Type.String({
|
|
355
|
+
minLength: 1,
|
|
356
|
+
maxLength: 255
|
|
357
|
+
}),
|
|
358
|
+
contentType: Type.Optional(HeaderSafeContentType),
|
|
359
|
+
contentEncoding: Type.Optional(HeaderSafeContentEncoding)
|
|
421
360
|
}, {
|
|
422
|
-
$id: "
|
|
361
|
+
$id: "UploadTaskArtifactQuery",
|
|
423
362
|
additionalProperties: false
|
|
424
363
|
});
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
$id: "PreviewSignArkgSeedPublicKey",
|
|
364
|
+
Type.String({
|
|
365
|
+
$id: "TaskArtifactContent",
|
|
366
|
+
description: "Task artifact content stream.",
|
|
367
|
+
format: "binary"
|
|
368
|
+
});
|
|
369
|
+
Type.Object({ taskId: Type.String({ format: "uuid" }) }, {
|
|
370
|
+
$id: "TaskArtifactTaskParams",
|
|
433
371
|
additionalProperties: false
|
|
434
372
|
});
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
outerPublicKey: schemaRef$1(PreviewSignEs256PublicKeySchema, "PreviewSignEs256PublicKey"),
|
|
439
|
-
previewKeyHandle: schemaRef$1(PreviewSignBase64UrlSchema, "PreviewSignBase64Url"),
|
|
440
|
-
seedPublicKey: schemaRef$1(PreviewSignArkgSeedPublicKeySchema, "PreviewSignArkgSeedPublicKey")
|
|
373
|
+
Type.Object({
|
|
374
|
+
taskId: Type.String({ format: "uuid" }),
|
|
375
|
+
attemptN: Type.Integer({ minimum: 1 })
|
|
441
376
|
}, {
|
|
442
|
-
$id: "
|
|
377
|
+
$id: "TaskArtifactAttemptParams",
|
|
443
378
|
additionalProperties: false
|
|
444
379
|
});
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
outerPublicKey: schemaRef$1(PreviewSignEs256PublicKeySchema, "PreviewSignEs256PublicKey"),
|
|
453
|
-
previewKeyHandle: schemaRef$1(PreviewSignBase64UrlSchema, "PreviewSignBase64Url")
|
|
380
|
+
Type.Object({
|
|
381
|
+
taskId: Type.String({ format: "uuid" }),
|
|
382
|
+
attemptN: Type.Integer({ minimum: 1 }),
|
|
383
|
+
cid: Type.String({
|
|
384
|
+
minLength: 1,
|
|
385
|
+
maxLength: 100
|
|
386
|
+
})
|
|
454
387
|
}, {
|
|
455
|
-
$id: "
|
|
388
|
+
$id: "TaskArtifactContentParams",
|
|
456
389
|
additionalProperties: false
|
|
457
390
|
});
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
391
|
+
Type.Object({
|
|
392
|
+
contentType: Type.Optional(HeaderSafeContentType),
|
|
393
|
+
contentEncoding: Type.Optional(HeaderSafeContentEncoding)
|
|
461
394
|
}, {
|
|
462
|
-
$id: "
|
|
395
|
+
$id: "StageTaskArtifactQuery",
|
|
463
396
|
additionalProperties: false
|
|
464
397
|
});
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
398
|
+
Type.Object({
|
|
399
|
+
cid: Type.String({
|
|
400
|
+
minLength: 1,
|
|
401
|
+
maxLength: 100
|
|
402
|
+
}),
|
|
403
|
+
sizeBytes: Type.Integer({ minimum: 0 }),
|
|
404
|
+
contentType: Type.String({
|
|
405
|
+
minLength: 1,
|
|
406
|
+
maxLength: 200
|
|
407
|
+
})
|
|
408
|
+
}, { $id: "StagedTaskArtifact" });
|
|
409
|
+
Type.Object({
|
|
410
|
+
taskId: Type.String({ format: "uuid" }),
|
|
411
|
+
cid: Type.String({
|
|
412
|
+
minLength: 1,
|
|
413
|
+
maxLength: 100
|
|
414
|
+
})
|
|
469
415
|
}, {
|
|
470
|
-
$id: "
|
|
416
|
+
$id: "TaskArtifactTaskContentParams",
|
|
471
417
|
additionalProperties: false
|
|
472
418
|
});
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
419
|
+
//#endregion
|
|
420
|
+
//#region ../../libs/tasks/src/task-types/assess-brief.ts
|
|
421
|
+
/**
|
|
422
|
+
* `assess_brief` — independently evaluate a fulfilled brief.
|
|
423
|
+
*
|
|
424
|
+
* output_kind: judgment
|
|
425
|
+
* criteria: required (`successCriteria.rubric` — same envelope as
|
|
426
|
+
* `judge_pack`)
|
|
427
|
+
* references: required (must reference the target `fulfill_brief` task)
|
|
428
|
+
*
|
|
429
|
+
* The assessor is a different agent from the producer (enforced by the
|
|
430
|
+
* server / runtime at claim time — not in the wire schema).
|
|
431
|
+
*
|
|
432
|
+
* The rubric in `successCriteria` IS the job spec — the assessor applies
|
|
433
|
+
* it to the target task's output and emits per-criterion scores. Other
|
|
434
|
+
* sections (`assertions`, `gates`, `sideEffects`) MAY be present and are
|
|
435
|
+
* evaluated against the *assessor's output*.
|
|
436
|
+
*/
|
|
437
|
+
var ASSESS_BRIEF_TYPE = "assess_brief";
|
|
438
|
+
var AssessBriefInput = Type.Object({
|
|
439
|
+
targetTaskId: Type.String({ format: "uuid" }),
|
|
440
|
+
successCriteria: SuccessCriteria
|
|
476
441
|
}, {
|
|
477
|
-
$id: "
|
|
442
|
+
$id: "AssessBriefInput",
|
|
443
|
+
additionalProperties: false
|
|
444
|
+
});
|
|
445
|
+
/** One score line. */
|
|
446
|
+
var AssessBriefScore = Type.Object({
|
|
447
|
+
criterionId: Type.String({ minLength: 1 }),
|
|
448
|
+
score: Type.Number({
|
|
449
|
+
minimum: 0,
|
|
450
|
+
maximum: 1
|
|
451
|
+
}),
|
|
452
|
+
rationale: Type.Optional(Type.String()),
|
|
453
|
+
evidence: Type.Optional(Type.Object({
|
|
454
|
+
commitsVerified: Type.Number(),
|
|
455
|
+
commitsTotal: Type.Number(),
|
|
456
|
+
signatureFailures: Type.Array(Type.String())
|
|
457
|
+
}, { additionalProperties: false }))
|
|
458
|
+
}, {
|
|
459
|
+
$id: "AssessBriefScore",
|
|
460
|
+
additionalProperties: false
|
|
461
|
+
});
|
|
462
|
+
var AssessBriefOutput = Type.Object({
|
|
463
|
+
scores: Type.Array(AssessBriefScore, { minItems: 1 }),
|
|
464
|
+
composite: Type.Number({
|
|
465
|
+
minimum: 0,
|
|
466
|
+
maximum: 1
|
|
467
|
+
}),
|
|
468
|
+
verdict: Type.String({ minLength: 1 }),
|
|
469
|
+
judgeModel: Type.Optional(Type.String())
|
|
470
|
+
}, {
|
|
471
|
+
$id: "AssessBriefOutput",
|
|
478
472
|
additionalProperties: false
|
|
479
473
|
});
|
|
480
|
-
var previewSignSchemaContext = {
|
|
481
|
-
PreviewSignBase64Url: PreviewSignBase64UrlSchema,
|
|
482
|
-
PreviewSignSha256Base64Url: PreviewSignSha256Base64UrlSchema,
|
|
483
|
-
PreviewSignP256DerSignatureBase64Url: PreviewSignP256DerSignatureBase64UrlSchema,
|
|
484
|
-
PreviewSignEs256PublicKey: PreviewSignEs256PublicKeySchema,
|
|
485
|
-
PreviewSignEcdhEsHkdf256PublicKey: PreviewSignEcdhEsHkdf256PublicKeySchema,
|
|
486
|
-
PreviewSignEsp256PublicKey: PreviewSignEsp256PublicKeySchema,
|
|
487
|
-
PreviewSignArkgSeedPublicKey: PreviewSignArkgSeedPublicKeySchema,
|
|
488
|
-
PreviewSignPublicMaterial: PreviewSignPublicMaterialSchema,
|
|
489
|
-
PreviewSignChallenge: PreviewSignChallengeSchema,
|
|
490
|
-
PreviewSignChallengeValue: PreviewSignChallengeValueSchema,
|
|
491
|
-
PreviewSignChallengeOperation: PreviewSignChallengeOperationSchema,
|
|
492
|
-
PreviewSignReceipt: PreviewSignReceiptSchema,
|
|
493
|
-
PreviewSignReceiptValue: PreviewSignReceiptValueSchema
|
|
494
|
-
};
|
|
495
|
-
//#endregion
|
|
496
|
-
//#region ../../libs/models/src/verification-method.ts
|
|
497
474
|
/**
|
|
498
|
-
*
|
|
475
|
+
* Async preflight (#1096):
|
|
476
|
+
* - `targetTaskId` resolves to a real task the caller can see.
|
|
477
|
+
* - The target is a `fulfill_brief` (you cannot grade an arbitrary
|
|
478
|
+
* task type as if it were a brief fulfillment).
|
|
479
|
+
* - Unless readiness checks are explicitly deferred, the target is
|
|
480
|
+
* `completed` with an accepted attempt — grading an in-flight or
|
|
481
|
+
* failed task would either race or grade nothing.
|
|
499
482
|
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
483
|
+
* Agent-distinctness ("assessor ≠ producer") is a runtime / auth-
|
|
484
|
+
* layer concern and intentionally NOT checked here. It belongs in
|
|
485
|
+
* an auth-aware claim-time check.
|
|
503
486
|
*/
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
487
|
+
async function validateAssessBriefInputAsync(input, ctx) {
|
|
488
|
+
const { targetTaskId } = input;
|
|
489
|
+
const errors = [];
|
|
490
|
+
const target = await ctx.resolveTask(targetTaskId);
|
|
491
|
+
if (!target) {
|
|
492
|
+
errors.push({
|
|
493
|
+
field: "targetTaskId",
|
|
494
|
+
message: `targetTaskId ${targetTaskId} does not resolve to a task you can read`
|
|
495
|
+
});
|
|
496
|
+
return errors;
|
|
497
|
+
}
|
|
498
|
+
if (target.taskType !== "fulfill_brief") errors.push({
|
|
499
|
+
field: "targetTaskId",
|
|
500
|
+
message: `targetTaskId ${targetTaskId} is a ${target.taskType}, not a fulfill_brief`
|
|
501
|
+
});
|
|
502
|
+
if (!ctx.deferReadinessChecks && (target.status !== "completed" || target.acceptedAttemptN === null)) errors.push({
|
|
503
|
+
field: "targetTaskId",
|
|
504
|
+
message: `targetTaskId ${targetTaskId} is not completed with an accepted attempt (status=${target.status}, acceptedAttemptN=${target.acceptedAttemptN})`
|
|
505
|
+
});
|
|
506
|
+
return errors;
|
|
507
|
+
}
|
|
509
508
|
//#endregion
|
|
510
|
-
//#region ../../libs/
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
var
|
|
528
|
-
|
|
529
|
-
"semantic",
|
|
530
|
-
"procedural",
|
|
531
|
-
"reflection"
|
|
532
|
-
];
|
|
533
|
-
var entryTypeLiterals = [
|
|
509
|
+
//#region ../../libs/tasks/src/task-types/curate-pack.ts
|
|
510
|
+
/**
|
|
511
|
+
* `curate_pack` — select and rank diary entries into a context pack.
|
|
512
|
+
*
|
|
513
|
+
* output_kind: artifact
|
|
514
|
+
* criteria: not required (rubric-less curation recipe)
|
|
515
|
+
* references: optional (e.g. a prior rendered pack being re-curated)
|
|
516
|
+
*
|
|
517
|
+
* This is step 1 of the three-session attribution loop (#875). The agent
|
|
518
|
+
* runs a structured exploration over a diary — tag inventory, hybrid
|
|
519
|
+
* search, type/tag narrowing — and emits a ranked entry list via
|
|
520
|
+
* `moltnet_pack_create`. The prompt is deterministic given the input
|
|
521
|
+
* (no operator interaction), so two runs with the same input should
|
|
522
|
+
* converge on similar packs.
|
|
523
|
+
*
|
|
524
|
+
* Related: `render_pack`, `judge_pack`.
|
|
525
|
+
*/
|
|
526
|
+
var CURATE_PACK_TYPE = "curate_pack";
|
|
527
|
+
var EntryTypeFilter = Type.Union([
|
|
534
528
|
Type.Literal("episodic"),
|
|
535
529
|
Type.Literal("semantic"),
|
|
536
530
|
Type.Literal("procedural"),
|
|
537
531
|
Type.Literal("reflection")
|
|
538
|
-
];
|
|
539
|
-
var
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
minLength: 1,
|
|
555
|
-
maxLength: 1e5
|
|
556
|
-
}),
|
|
557
|
-
tags: Type.Optional(Type.Array(Type.String({ maxLength: 128 }), { maxItems: 20 }))
|
|
532
|
+
]);
|
|
533
|
+
var CuratePackInput = Type.Object({
|
|
534
|
+
diaryId: Type.String({ format: "uuid" }),
|
|
535
|
+
taskPrompt: Type.String({ minLength: 1 }),
|
|
536
|
+
entryTypes: Type.Optional(Type.Array(EntryTypeFilter, { minItems: 1 })),
|
|
537
|
+
tagFilters: Type.Optional(Type.Object({
|
|
538
|
+
include: Type.Optional(Type.Array(Type.String())),
|
|
539
|
+
exclude: Type.Optional(Type.Array(Type.String())),
|
|
540
|
+
prefix: Type.Optional(Type.String())
|
|
541
|
+
}, { additionalProperties: false })),
|
|
542
|
+
tokenBudget: Type.Optional(Type.Number({ minimum: 500 })),
|
|
543
|
+
recipe: Type.Optional(Type.Union([Type.Literal("topic-focused-v1"), Type.Literal("scope-inventory-v1")])),
|
|
544
|
+
successCriteria: Type.Optional(SuccessCriteria)
|
|
545
|
+
}, {
|
|
546
|
+
$id: "CuratePackInput",
|
|
547
|
+
additionalProperties: false
|
|
558
548
|
});
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
549
|
+
/**
|
|
550
|
+
* Index of the curated pack plus the reasoning trace. The pack itself
|
|
551
|
+
* lives in the database (created via `moltnet_pack_create`); this output
|
|
552
|
+
* is the receipt.
|
|
553
|
+
*/
|
|
554
|
+
var CuratePackOutput = Type.Object({
|
|
555
|
+
packId: Type.String({ format: "uuid" }),
|
|
556
|
+
packCid: Type.String({ minLength: 1 }),
|
|
557
|
+
entries: Type.Array(Type.Object({
|
|
558
|
+
entryId: Type.String({ format: "uuid" }),
|
|
559
|
+
rank: Type.Number({ minimum: 1 }),
|
|
560
|
+
rationale: Type.String({ minLength: 1 })
|
|
561
|
+
}, { additionalProperties: false }), { minItems: 1 }),
|
|
562
|
+
recipeParams: Type.Record(Type.String(), Type.Unknown()),
|
|
563
|
+
checkpoints: Type.Optional(Type.Array(Type.Object({
|
|
564
|
+
phase: Type.String({ minLength: 1 }),
|
|
565
|
+
candidateIds: Type.Array(Type.String({ format: "uuid" })),
|
|
566
|
+
droppedIds: Type.Optional(Type.Array(Type.String({ format: "uuid" }))),
|
|
567
|
+
notes: Type.String({ minLength: 1 })
|
|
568
|
+
}, { additionalProperties: false }))),
|
|
569
|
+
summary: Type.String({ minLength: 1 }),
|
|
570
|
+
verification: Type.Optional(VerificationRecord)
|
|
571
|
+
}, {
|
|
572
|
+
$id: "CuratePackOutput",
|
|
573
|
+
additionalProperties: false
|
|
566
574
|
});
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
575
|
+
//#endregion
|
|
576
|
+
//#region ../../libs/runtime-profiles/src/context.ts
|
|
577
|
+
/**
|
|
578
|
+
* How an executor delivers a context entry to its underlying LLM.
|
|
579
|
+
* V1 bindings only; Tier-2 (reference_file, mcp_resource, imported_file,
|
|
580
|
+
* tool_response_seed, additional_context_hook) ship in a later slice.
|
|
581
|
+
*/
|
|
582
|
+
var CONTEXT_BINDINGS = [
|
|
583
|
+
"skill",
|
|
584
|
+
"context_inline",
|
|
585
|
+
"prompt_prefix",
|
|
586
|
+
"user_inline"
|
|
587
|
+
];
|
|
588
|
+
/** Maximum UTF-16 code units accepted in one ContextRef content field. */
|
|
589
|
+
var CONTEXT_REF_MAX_CONTENT_LENGTH = 65536;
|
|
590
|
+
var ContextBinding = Type.Unsafe(Type.Union(CONTEXT_BINDINGS.map((binding) => Type.Literal(binding)), { $id: "ContextBinding" }));
|
|
591
|
+
/**
|
|
592
|
+
* One context entry. Bytes are inlined: the proposer chose them, and the
|
|
593
|
+
* task's `inputCid` already pins the entire input — including
|
|
594
|
+
* `context[]` — so we don't need a separate per-entry hash, fetcher, or
|
|
595
|
+
* flagged-content gate. Tasks reference rendered packs (or any other
|
|
596
|
+
* external content) by copying their bytes into `content` at task
|
|
597
|
+
* creation time.
|
|
598
|
+
*
|
|
599
|
+
* - `slug` — short identifier the daemon uses to disambiguate
|
|
600
|
+
* entries. For `skill` binding it becomes the directory
|
|
601
|
+
* name under the runtime's skill discovery path. Must be
|
|
602
|
+
* kebab-case-safe (alphanumeric + dashes/underscores).
|
|
603
|
+
* - `binding` — how the bytes are delivered to the LLM (see above).
|
|
604
|
+
* - `content` — UTF-8 text. Capped at 65,536 UTF-16 code units per
|
|
605
|
+
* entry; total per-task context bytes are bounded by the
|
|
606
|
+
* soft `maxItems` cap and per-binding daemon limits.
|
|
607
|
+
* Raised from 32 KiB in 2026-05 — protocol-heavy operator
|
|
608
|
+
* skills (e.g. `.claude/skills/legreffier/SKILL.md`) ship
|
|
609
|
+
* at ~35 KiB inline, and the original cap was sized for
|
|
610
|
+
* short example skills, not the kind of skill the eval
|
|
611
|
+
* substrate is dogfooded on (#943, #823).
|
|
612
|
+
*/
|
|
613
|
+
var ContextRef = Type.Object({
|
|
614
|
+
slug: Type.String({
|
|
615
|
+
minLength: 1,
|
|
616
|
+
maxLength: 64,
|
|
617
|
+
pattern: "^[a-zA-Z0-9_-]+$"
|
|
618
|
+
}),
|
|
619
|
+
binding: ContextBinding,
|
|
620
|
+
content: Type.String({
|
|
621
|
+
minLength: 1,
|
|
622
|
+
maxLength: CONTEXT_REF_MAX_CONTENT_LENGTH
|
|
623
|
+
})
|
|
624
|
+
}, {
|
|
625
|
+
$id: "ContextRef",
|
|
626
|
+
additionalProperties: false
|
|
627
|
+
});
|
|
628
|
+
/** Reusable input fragment for any task type. Soft cap at 5 items. */
|
|
629
|
+
var TaskContext = Type.Array(ContextRef, {
|
|
630
|
+
$id: "TaskContext",
|
|
631
|
+
maxItems: 5
|
|
632
|
+
});
|
|
633
|
+
//#endregion
|
|
634
|
+
//#region ../../libs/runtime-profiles/src/runtime-models.ts
|
|
635
|
+
/**
|
|
636
|
+
* Runtime model catalog: a list of supported provider/model couples that
|
|
637
|
+
* MoltNet daemons can target. Backed by the `runtime_models` table.
|
|
638
|
+
*
|
|
639
|
+
* Scope is intrinsic to the row:
|
|
640
|
+
* - `teamId == null` => global entry (MoltNet-seeded, read-only to most callers)
|
|
641
|
+
* - `teamId != null` => team-owned custom entry
|
|
642
|
+
*
|
|
643
|
+
* The REST API exposes a single shape regardless of scope; the team header
|
|
644
|
+
* gates which rows are returned.
|
|
645
|
+
*/
|
|
646
|
+
var RuntimeModelProvider = Type.String({
|
|
647
|
+
minLength: 1,
|
|
648
|
+
maxLength: 100,
|
|
649
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9._-]{0,99}$"
|
|
650
|
+
});
|
|
651
|
+
var RuntimeModelName = Type.String({
|
|
652
|
+
minLength: 1,
|
|
653
|
+
maxLength: 200,
|
|
654
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,199}$"
|
|
655
|
+
});
|
|
656
|
+
var RuntimeModelCapabilities = Type.Record(Type.String({
|
|
657
|
+
minLength: 1,
|
|
658
|
+
maxLength: 64
|
|
659
|
+
}), Type.Union([
|
|
660
|
+
Type.Boolean(),
|
|
661
|
+
Type.Number(),
|
|
662
|
+
Type.String({ maxLength: 256 })
|
|
663
|
+
]));
|
|
664
|
+
Type.Object({
|
|
665
|
+
id: Type.String({ format: "uuid" }),
|
|
666
|
+
teamId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
667
|
+
provider: RuntimeModelProvider,
|
|
668
|
+
model: RuntimeModelName,
|
|
669
|
+
displayName: Type.Union([Type.String({ maxLength: 200 }), Type.Null()]),
|
|
670
|
+
description: Type.Union([Type.String({ maxLength: 4096 }), Type.Null()]),
|
|
671
|
+
capabilities: RuntimeModelCapabilities,
|
|
672
|
+
isActive: Type.Boolean(),
|
|
673
|
+
createdByAgentId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
674
|
+
createdByHumanId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
675
|
+
createdAt: Type.String({ format: "date-time" }),
|
|
676
|
+
updatedAt: Type.String({ format: "date-time" })
|
|
677
|
+
}, {
|
|
678
|
+
$id: "RuntimeModel",
|
|
679
|
+
additionalProperties: false
|
|
680
|
+
});
|
|
681
|
+
//#endregion
|
|
682
|
+
//#region ../../libs/runtime-profiles/src/runtime-profile-context-recipes.ts
|
|
683
|
+
var RUNTIME_PROFILE_CONTEXT_CATALOGUE = {
|
|
684
|
+
version: 1,
|
|
685
|
+
fragments: {
|
|
686
|
+
"artifact-planner-v1": {
|
|
687
|
+
binding: "prompt_prefix",
|
|
688
|
+
content: "# Bounded artifact planner\n\n- The typed task facts, embedded bounded manifest, exact bound artifact references, registered tools, and runtime capability section are the complete contract. Do not search diaries, inspect a mounted repository, enumerate unrelated tasks or artifacts, modify a checkout, commit, branch, push, or contact GitHub.\n- Read only the exact artifact CIDs named by the task, and only when the embedded manifest does not provide enough evidence. Use the registered task-artifact tools for artifact access; never use shell or CLI wrappers to fetch artifacts, paginate, or discover them speculatively.\n- If the effective runtime exposes a local calculator or shell, use it only inside scratch for coverage accounting, budget arithmetic, and JSON validation. The runtime capability section and policy are authoritative; do not assume a static executable list.\n- Perform semantic classification and planning from supplied content and producer/consumer evidence. Do not substitute filename, directory, language, ecosystem, or repository-specific exclusion rules for evidence.\n- Write and upload exactly the requested versioned plan artifact, then reference its returned metadata through the registered submit-output tool. Do not emit a second prose or JSON representation.",
|
|
689
|
+
slug: "artifact-planner-v1"
|
|
690
|
+
},
|
|
691
|
+
"accountable-delivery-v1": {
|
|
692
|
+
binding: "prompt_prefix",
|
|
693
|
+
content: "# Accountable delivery\n\n- Pair every commit made during this task with a task-provenance diary entry created by the `moltnet_create_entry` custom tool. Put the returned id in a `MoltNet-Diary: <id>` commit trailer. The tool does not currently promise a content signature; never describe an entry as signed unless the active runtime exposes and verifies a signing capability.\n- Do not disable commit signing when the active runtime provides it. A host-authenticated guest has no injected signing key, so do not recover one from host configuration or claim an unsigned commit is signed.\n- Push a branch and open or update a pull request only when the task asks for it. Use a host-brokered GitHub placeholder only when the runtime kernel declares one; if no GitHub credential is active, the authenticated operation is unavailable.\n- Keep changes, commits, and any requested pull request coherent enough to review independently.",
|
|
694
|
+
slug: "accountable-delivery-v1"
|
|
695
|
+
},
|
|
696
|
+
"judgment-diary-v1": {
|
|
697
|
+
binding: "prompt_prefix",
|
|
698
|
+
content: "# Judgment diary discipline\n\n- For an `assess_brief`, `judge_pack`, or `pr_review` task, create a diary entry with the `moltnet_create_entry` custom tool before submitting the structured judgment. Capture the rationale and evidence that support the verdict. Do not claim a content signature unless the active runtime exposes and verifies a signing capability.\n- Add the `judgment` tag and the active task type tag (`assess_brief`, `judge_pack`, or `pr_review`). For `judge_pack`, also add `rubric:<rubricId>` from the task facts.\n- Do not use a shell `moltnet entry` command: task provenance is injected only by the custom tool.",
|
|
699
|
+
slug: "judgment-diary-v1"
|
|
700
|
+
},
|
|
701
|
+
"proactive-memory-v1": {
|
|
702
|
+
binding: "prompt_prefix",
|
|
703
|
+
content: "# Proactive memory use\n\n- Before non-trivial investigation, debugging, code changes, or review, check the task diary for relevant prior knowledge instead of waiting for a human to ask. Use `moltnet_diary_tags` for cheap reconnaissance, `moltnet_list_entries` when tags or task provenance are known, and `moltnet_search_entries` for semantic similarity. Do not search randomly: pass `taskFilter` for task-local or correlation-local queries, and pass `tags` / `entryTypes` for broader prior-knowledge queries using known tags such as `incident`, `decision`, or `scope:<area>`. Broaden only after constrained searches miss.\n- Before creating an `episodic` incident entry, search for similar incidents using the proposed title, root cause, error text, affected subsystem, and watch-for terms, filtered by `entryTypes: [\"episodic\", \"semantic\"]` and any known `scope:*` or task-provenance tags. If a close prior match exists, do not create an isolated duplicate: reference the prior entry in your response or diary content, update or link it when the new occurrence adds material evidence, or create a new recurrence entry only when the recurrence itself is important signal.\n- When you create a recurrence entry, include the prior matching entry id(s) in the content and explain what is new about this occurrence.",
|
|
704
|
+
slug: "proactive-memory-v1"
|
|
705
|
+
},
|
|
706
|
+
"run-eval-direct-v1": {
|
|
707
|
+
binding: "prompt_prefix",
|
|
708
|
+
content: "# Direct evaluation run\n\nThe supplied scenario, typed task facts, injected context, and registered submit-output tool are the complete task contract. Do not search diaries, create diary entries, modify a repository, commit, branch, push, or open a pull request unless a task fact explicitly requires it. Submit the agent-authored payload in the first turn; correction turns exist only to recover a rejected or missing submission.",
|
|
709
|
+
slug: "run-eval-direct-v1"
|
|
710
|
+
},
|
|
711
|
+
"task-diary-discipline-v1": {
|
|
712
|
+
binding: "prompt_prefix",
|
|
713
|
+
content: "# Task diary discipline\n\n- During a daemon task, create diary entries only through the `moltnet_create_entry` custom tool. It binds entries to the current task diary and injects task, type, attempt, and correlation provenance tags.\n- Do not shell out to `moltnet entry create`, `moltnet entry create-signed`, or any other `moltnet entry` subcommand from bash while a task is running. Those paths bypass the custom tool's task-tag injection, so task-filtered diary queries cannot find the entry.\n- You may add useful tags, but do not try to replace task provenance supplied by the runtime.",
|
|
714
|
+
slug: "task-diary-discipline-v1"
|
|
715
|
+
},
|
|
716
|
+
"verification-and-artifacts-v1": {
|
|
717
|
+
binding: "prompt_prefix",
|
|
718
|
+
content: "# Verification and artifacts\n\n- Run relevant verification before submitting. When task facts include `successCriteria`, assess them honestly in the generated verification contract; a fail or skip with evidence is better than a fabricated pass.\n- The registered submit-output tool owns the exact agent submission schema and validation recovery. Use that schema; do not invent a JSON shape in prose.\n- Upload only task-relevant artifacts, and inspect each before uploading. Never upload secrets, credentials, API keys, auth tokens or headers, .env files, or personal or customer data; redact sensitive values, and prefer minimal, sanitized excerpts over whole logs, bundles, or datasets. Include artifact metadata only where the typed submit contract permits it.\n- If the task depends on prior artifacts, list and download the exact referenced artifact before judging or continuing that work.",
|
|
719
|
+
slug: "verification-and-artifacts-v1"
|
|
720
|
+
}
|
|
721
|
+
},
|
|
722
|
+
recipes: {
|
|
723
|
+
"artifact-planner@v1": {
|
|
724
|
+
description: "Minimal artifact-only context for bounded semantic classification and planning.",
|
|
725
|
+
fragments: ["artifact-planner-v1"]
|
|
726
|
+
},
|
|
727
|
+
"run-eval-direct@v1": {
|
|
728
|
+
description: "Minimal direct context for a short, isolated evaluation run.",
|
|
729
|
+
fragments: ["run-eval-direct-v1"]
|
|
730
|
+
},
|
|
731
|
+
"standard-engineering@v1": {
|
|
732
|
+
description: "Full opt-in operating guidance for engineering tasks that need diary research, accountable delivery, and verification discipline.",
|
|
733
|
+
fragments: [
|
|
734
|
+
"proactive-memory-v1",
|
|
735
|
+
"task-diary-discipline-v1",
|
|
736
|
+
"accountable-delivery-v1",
|
|
737
|
+
"judgment-diary-v1",
|
|
738
|
+
"verification-and-artifacts-v1"
|
|
739
|
+
]
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
function deepFreeze(value) {
|
|
744
|
+
if (value && typeof value === "object") {
|
|
745
|
+
for (const key of Object.keys(value)) deepFreeze(value[key]);
|
|
746
|
+
Object.freeze(value);
|
|
747
|
+
}
|
|
748
|
+
return value;
|
|
749
|
+
}
|
|
750
|
+
deepFreeze(RUNTIME_PROFILE_CONTEXT_CATALOGUE);
|
|
751
|
+
Object.freeze(Object.keys(RUNTIME_PROFILE_CONTEXT_CATALOGUE.recipes));
|
|
752
|
+
//#endregion
|
|
753
|
+
//#region ../../libs/models/src/credential-scopes.ts
|
|
754
|
+
var CREDENTIAL_SCOPES = {
|
|
755
|
+
AgentProfile: "agent:profile",
|
|
756
|
+
ConnectorInvoke: "connector:invoke",
|
|
757
|
+
CryptoSign: "crypto:sign",
|
|
758
|
+
DiaryManage: "diary:manage",
|
|
759
|
+
DiaryRead: "diary:read",
|
|
760
|
+
DiaryWrite: "diary:write",
|
|
761
|
+
HumanProfile: "human:profile",
|
|
762
|
+
KeyManage: "key:manage",
|
|
763
|
+
PackRead: "pack:read",
|
|
764
|
+
PackWrite: "pack:write",
|
|
765
|
+
RuntimeManage: "runtime:manage",
|
|
766
|
+
RuntimeRead: "runtime:read",
|
|
767
|
+
TaskClaim: "task:claim",
|
|
768
|
+
TaskExecute: "task:execute",
|
|
769
|
+
TaskManage: "task:manage",
|
|
770
|
+
TaskRead: "task:read",
|
|
771
|
+
TeamManage: "team:manage",
|
|
772
|
+
TeamRead: "team:read"
|
|
773
|
+
};
|
|
774
|
+
var ALL_CREDENTIAL_SCOPES = Object.freeze(Object.values(CREDENTIAL_SCOPES));
|
|
775
|
+
/**
|
|
776
|
+
* Minimum grant for the agent daemon. Task credentials attenuate this further
|
|
777
|
+
* to `task:execute` alone.
|
|
778
|
+
*/
|
|
779
|
+
var AGENT_CREDENTIAL_SCOPES = [
|
|
780
|
+
CREDENTIAL_SCOPES.AgentProfile,
|
|
781
|
+
CREDENTIAL_SCOPES.RuntimeRead,
|
|
782
|
+
CREDENTIAL_SCOPES.TaskRead,
|
|
783
|
+
CREDENTIAL_SCOPES.TaskClaim,
|
|
784
|
+
CREDENTIAL_SCOPES.TaskExecute
|
|
785
|
+
];
|
|
786
|
+
Object.freeze(ALL_CREDENTIAL_SCOPES.filter((scope) => scope !== CREDENTIAL_SCOPES.HumanProfile));
|
|
787
|
+
[
|
|
788
|
+
CREDENTIAL_SCOPES.AgentProfile,
|
|
789
|
+
CREDENTIAL_SCOPES.CryptoSign,
|
|
790
|
+
CREDENTIAL_SCOPES.DiaryManage,
|
|
791
|
+
CREDENTIAL_SCOPES.DiaryRead,
|
|
792
|
+
CREDENTIAL_SCOPES.DiaryWrite,
|
|
793
|
+
CREDENTIAL_SCOPES.HumanProfile,
|
|
794
|
+
CREDENTIAL_SCOPES.PackRead,
|
|
795
|
+
CREDENTIAL_SCOPES.PackWrite,
|
|
796
|
+
CREDENTIAL_SCOPES.TaskExecute,
|
|
797
|
+
CREDENTIAL_SCOPES.TaskManage,
|
|
798
|
+
CREDENTIAL_SCOPES.TaskRead,
|
|
799
|
+
CREDENTIAL_SCOPES.TeamManage,
|
|
800
|
+
CREDENTIAL_SCOPES.TeamRead
|
|
801
|
+
].filter((scope) => scope !== CREDENTIAL_SCOPES.HumanProfile);
|
|
802
|
+
//#endregion
|
|
803
|
+
//#region ../../libs/models/src/preview-sign.ts
|
|
804
|
+
function schemaRef$1(schema, id) {
|
|
805
|
+
return Type.Unsafe(Type.Ref(id));
|
|
806
|
+
}
|
|
807
|
+
var PreviewSignBase64UrlSchema = Type.String({
|
|
808
|
+
$id: "PreviewSignBase64Url",
|
|
809
|
+
minLength: 1,
|
|
810
|
+
maxLength: 5462,
|
|
811
|
+
pattern: "^[A-Za-z0-9_-]+$"
|
|
812
|
+
});
|
|
813
|
+
var PreviewSignSha256Base64UrlSchema = Type.String({
|
|
814
|
+
$id: "PreviewSignSha256Base64Url",
|
|
815
|
+
minLength: 43,
|
|
816
|
+
maxLength: 43,
|
|
817
|
+
pattern: "^[A-Za-z0-9_-]+$"
|
|
818
|
+
});
|
|
819
|
+
var PreviewSignP256DerSignatureBase64UrlSchema = Type.String({
|
|
820
|
+
$id: "PreviewSignP256DerSignatureBase64Url",
|
|
821
|
+
minLength: 11,
|
|
822
|
+
maxLength: 96,
|
|
823
|
+
pattern: "^[A-Za-z0-9_-]+$"
|
|
824
|
+
});
|
|
825
|
+
var PreviewSignEs256PublicKeySchema = Type.Object({
|
|
826
|
+
kty: Type.Literal(2),
|
|
827
|
+
algorithm: Type.Literal(-7),
|
|
828
|
+
curve: Type.Literal(1),
|
|
829
|
+
x: schemaRef$1(PreviewSignSha256Base64UrlSchema, "PreviewSignSha256Base64Url"),
|
|
830
|
+
y: schemaRef$1(PreviewSignSha256Base64UrlSchema, "PreviewSignSha256Base64Url")
|
|
831
|
+
}, {
|
|
832
|
+
$id: "PreviewSignEs256PublicKey",
|
|
833
|
+
additionalProperties: false
|
|
834
|
+
});
|
|
835
|
+
var PreviewSignEcdhEsHkdf256PublicKeySchema = Type.Object({
|
|
836
|
+
kty: Type.Literal(2),
|
|
837
|
+
algorithm: Type.Literal(-25),
|
|
838
|
+
curve: Type.Literal(1),
|
|
839
|
+
x: schemaRef$1(PreviewSignSha256Base64UrlSchema, "PreviewSignSha256Base64Url"),
|
|
840
|
+
y: schemaRef$1(PreviewSignSha256Base64UrlSchema, "PreviewSignSha256Base64Url")
|
|
841
|
+
}, {
|
|
842
|
+
$id: "PreviewSignEcdhEsHkdf256PublicKey",
|
|
843
|
+
additionalProperties: false
|
|
844
|
+
});
|
|
845
|
+
var PreviewSignEsp256PublicKeySchema = Type.Object({
|
|
846
|
+
kty: Type.Literal(2),
|
|
847
|
+
algorithm: Type.Literal(-9),
|
|
848
|
+
curve: Type.Literal(1),
|
|
849
|
+
x: schemaRef$1(PreviewSignSha256Base64UrlSchema, "PreviewSignSha256Base64Url"),
|
|
850
|
+
y: schemaRef$1(PreviewSignSha256Base64UrlSchema, "PreviewSignSha256Base64Url")
|
|
851
|
+
}, {
|
|
852
|
+
$id: "PreviewSignEsp256PublicKey",
|
|
853
|
+
additionalProperties: false
|
|
854
|
+
});
|
|
855
|
+
var PreviewSignArkgSeedPublicKeySchema = Type.Object({
|
|
856
|
+
kty: Type.Literal(-65537),
|
|
857
|
+
algorithm: Type.Literal(-65700),
|
|
858
|
+
derivedAlgorithm: Type.Literal(-9),
|
|
859
|
+
blindingKey: schemaRef$1(PreviewSignEs256PublicKeySchema, "PreviewSignEs256PublicKey"),
|
|
860
|
+
kemKey: schemaRef$1(PreviewSignEcdhEsHkdf256PublicKeySchema, "PreviewSignEcdhEsHkdf256PublicKey")
|
|
861
|
+
}, {
|
|
862
|
+
$id: "PreviewSignArkgSeedPublicKey",
|
|
863
|
+
additionalProperties: false
|
|
864
|
+
});
|
|
865
|
+
var PreviewSignPublicMaterialSchema = Type.Object({
|
|
866
|
+
version: Type.Literal(1),
|
|
867
|
+
outerCredentialId: schemaRef$1(PreviewSignBase64UrlSchema, "PreviewSignBase64Url"),
|
|
868
|
+
outerPublicKey: schemaRef$1(PreviewSignEs256PublicKeySchema, "PreviewSignEs256PublicKey"),
|
|
869
|
+
previewKeyHandle: schemaRef$1(PreviewSignBase64UrlSchema, "PreviewSignBase64Url"),
|
|
870
|
+
seedPublicKey: schemaRef$1(PreviewSignArkgSeedPublicKeySchema, "PreviewSignArkgSeedPublicKey")
|
|
871
|
+
}, {
|
|
872
|
+
$id: "PreviewSignPublicMaterial",
|
|
873
|
+
additionalProperties: false
|
|
874
|
+
});
|
|
875
|
+
var PreviewSignChallengeSchema = Type.Object({
|
|
876
|
+
verificationMethod: Type.Literal("human-hardware-previewsign"),
|
|
877
|
+
version: Type.Literal(1),
|
|
878
|
+
envelope: schemaRef$1(PreviewSignBase64UrlSchema, "PreviewSignBase64Url"),
|
|
879
|
+
digest: schemaRef$1(PreviewSignSha256Base64UrlSchema, "PreviewSignSha256Base64Url"),
|
|
880
|
+
additionalArguments: schemaRef$1(PreviewSignBase64UrlSchema, "PreviewSignBase64Url"),
|
|
881
|
+
outerCredentialId: schemaRef$1(PreviewSignBase64UrlSchema, "PreviewSignBase64Url"),
|
|
882
|
+
outerPublicKey: schemaRef$1(PreviewSignEs256PublicKeySchema, "PreviewSignEs256PublicKey"),
|
|
883
|
+
previewKeyHandle: schemaRef$1(PreviewSignBase64UrlSchema, "PreviewSignBase64Url")
|
|
884
|
+
}, {
|
|
885
|
+
$id: "PreviewSignChallenge",
|
|
886
|
+
additionalProperties: false
|
|
887
|
+
});
|
|
888
|
+
var PreviewSignChallengeValueSchema = Type.Object({
|
|
889
|
+
verificationMethod: Type.Literal("human-hardware-previewsign"),
|
|
890
|
+
value: schemaRef$1(PreviewSignChallengeSchema, "PreviewSignChallenge")
|
|
891
|
+
}, {
|
|
892
|
+
$id: "PreviewSignChallengeValue",
|
|
893
|
+
additionalProperties: false
|
|
894
|
+
});
|
|
895
|
+
var PreviewSignChallengeOperationSchema = Type.Union([Type.Literal("credential-registration"), Type.Literal("signing-request")], { $id: "PreviewSignChallengeOperation" });
|
|
896
|
+
var PreviewSignReceiptSchema = Type.Object({
|
|
897
|
+
version: Type.Literal(1),
|
|
898
|
+
signature: schemaRef$1(PreviewSignP256DerSignatureBase64UrlSchema, "PreviewSignP256DerSignatureBase64Url")
|
|
899
|
+
}, {
|
|
900
|
+
$id: "PreviewSignReceipt",
|
|
901
|
+
additionalProperties: false
|
|
902
|
+
});
|
|
903
|
+
var PreviewSignReceiptValueSchema = Type.Object({
|
|
904
|
+
verificationMethod: Type.Literal("human-hardware-previewsign"),
|
|
905
|
+
value: schemaRef$1(PreviewSignReceiptSchema, "PreviewSignReceipt")
|
|
906
|
+
}, {
|
|
907
|
+
$id: "PreviewSignReceiptValue",
|
|
908
|
+
additionalProperties: false
|
|
909
|
+
});
|
|
910
|
+
var previewSignSchemaContext = {
|
|
911
|
+
PreviewSignBase64Url: PreviewSignBase64UrlSchema,
|
|
912
|
+
PreviewSignSha256Base64Url: PreviewSignSha256Base64UrlSchema,
|
|
913
|
+
PreviewSignP256DerSignatureBase64Url: PreviewSignP256DerSignatureBase64UrlSchema,
|
|
914
|
+
PreviewSignEs256PublicKey: PreviewSignEs256PublicKeySchema,
|
|
915
|
+
PreviewSignEcdhEsHkdf256PublicKey: PreviewSignEcdhEsHkdf256PublicKeySchema,
|
|
916
|
+
PreviewSignEsp256PublicKey: PreviewSignEsp256PublicKeySchema,
|
|
917
|
+
PreviewSignArkgSeedPublicKey: PreviewSignArkgSeedPublicKeySchema,
|
|
918
|
+
PreviewSignPublicMaterial: PreviewSignPublicMaterialSchema,
|
|
919
|
+
PreviewSignChallenge: PreviewSignChallengeSchema,
|
|
920
|
+
PreviewSignChallengeValue: PreviewSignChallengeValueSchema,
|
|
921
|
+
PreviewSignChallengeOperation: PreviewSignChallengeOperationSchema,
|
|
922
|
+
PreviewSignReceipt: PreviewSignReceiptSchema,
|
|
923
|
+
PreviewSignReceiptValue: PreviewSignReceiptValueSchema
|
|
924
|
+
};
|
|
925
|
+
//#endregion
|
|
926
|
+
//#region ../../libs/models/src/verification-method.ts
|
|
927
|
+
/**
|
|
928
|
+
* Persisted and wire-level signing verification method identifiers.
|
|
929
|
+
*
|
|
930
|
+
* This vocabulary is append-only. Never rename, remove, or change an existing
|
|
931
|
+
* value: PostgreSQL rows, workflow inputs, and API clients persist these exact
|
|
932
|
+
* strings. Future signing methods must add a new property and value.
|
|
933
|
+
*/
|
|
934
|
+
var VERIFICATION_METHOD = {
|
|
935
|
+
AgentEd25519: "agent-ed25519",
|
|
936
|
+
HumanHardwarePreviewSign: "human-hardware-previewsign"
|
|
937
|
+
};
|
|
938
|
+
VERIFICATION_METHOD.AgentEd25519, VERIFICATION_METHOD.HumanHardwarePreviewSign;
|
|
939
|
+
//#endregion
|
|
940
|
+
//#region ../../libs/models/src/schemas.ts
|
|
941
|
+
var UuidSchema = Type.String({
|
|
942
|
+
format: "uuid",
|
|
943
|
+
description: "UUID v4 identifier"
|
|
944
|
+
});
|
|
945
|
+
var TimestampSchema = Type.String({
|
|
946
|
+
format: "date-time",
|
|
947
|
+
description: "ISO 8601 timestamp"
|
|
948
|
+
});
|
|
949
|
+
var verificationMethodLiterals = [Type.Literal(VERIFICATION_METHOD.AgentEd25519), Type.Literal(VERIFICATION_METHOD.HumanHardwarePreviewSign)];
|
|
950
|
+
Type.Union(verificationMethodLiterals, { description: "Stable signing verification method identifier" });
|
|
951
|
+
var visibilityLiterals = [
|
|
952
|
+
Type.Literal("private"),
|
|
953
|
+
Type.Literal("moltnet"),
|
|
954
|
+
Type.Literal("public")
|
|
955
|
+
];
|
|
956
|
+
Type.Union(visibilityLiterals, { description: "Entry visibility level" });
|
|
957
|
+
var ENTRY_TYPE_VALUES = [
|
|
958
|
+
"episodic",
|
|
959
|
+
"semantic",
|
|
960
|
+
"procedural",
|
|
961
|
+
"reflection"
|
|
962
|
+
];
|
|
963
|
+
var entryTypeLiterals = [
|
|
964
|
+
Type.Literal("episodic"),
|
|
965
|
+
Type.Literal("semantic"),
|
|
966
|
+
Type.Literal("procedural"),
|
|
967
|
+
Type.Literal("reflection")
|
|
968
|
+
];
|
|
969
|
+
var EntryTypeSchema = Type.Union(entryTypeLiterals, { description: "Entry memory type" });
|
|
970
|
+
/** Regex fragment matching a single entry type value. */
|
|
971
|
+
var ENTRY_TYPE_PATTERN = `(${ENTRY_TYPE_VALUES.join("|")})`;
|
|
972
|
+
`${ENTRY_TYPE_PATTERN}${ENTRY_TYPE_PATTERN}`, ENTRY_TYPE_VALUES.length - 1;
|
|
973
|
+
var PublicKeySchema = Type.String({
|
|
974
|
+
pattern: "^ed25519:[A-Za-z0-9+/=]+$",
|
|
975
|
+
description: "Ed25519 public key with prefix"
|
|
976
|
+
});
|
|
977
|
+
var FingerprintSchema = Type.String({
|
|
978
|
+
pattern: "^[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}$",
|
|
979
|
+
description: "Key fingerprint (A1B2-C3D4-E5F6-G7H8)"
|
|
980
|
+
});
|
|
981
|
+
Type.Object({
|
|
982
|
+
title: Type.Optional(Type.String({ maxLength: 255 })),
|
|
983
|
+
content: Type.String({
|
|
984
|
+
minLength: 1,
|
|
985
|
+
maxLength: 1e5
|
|
986
|
+
}),
|
|
987
|
+
tags: Type.Optional(Type.Array(Type.String({ maxLength: 128 }), { maxItems: 20 }))
|
|
988
|
+
});
|
|
989
|
+
Type.Object({
|
|
990
|
+
title: Type.Optional(Type.String({ maxLength: 255 })),
|
|
991
|
+
content: Type.Optional(Type.String({
|
|
992
|
+
minLength: 1,
|
|
993
|
+
maxLength: 1e5
|
|
994
|
+
})),
|
|
995
|
+
tags: Type.Optional(Type.Array(Type.String({ maxLength: 128 }), { maxItems: 20 }))
|
|
996
|
+
});
|
|
997
|
+
Type.Object({
|
|
998
|
+
query: Type.Optional(Type.String({
|
|
999
|
+
minLength: 1,
|
|
1000
|
+
maxLength: 500
|
|
1001
|
+
})),
|
|
1002
|
+
tags: Type.Optional(Type.Array(Type.String({ maxLength: 128 }), {
|
|
1003
|
+
minItems: 1,
|
|
1004
|
+
maxItems: 20,
|
|
1005
|
+
description: "Filter: entry must have ALL specified tags"
|
|
1006
|
+
})),
|
|
1007
|
+
limit: Type.Optional(Type.Number({
|
|
578
1008
|
minimum: 1,
|
|
579
1009
|
maximum: 100,
|
|
580
1010
|
default: 20
|
|
@@ -1173,921 +1603,491 @@ var SignerProblemSchema = Type.Object({
|
|
|
1173
1603
|
$id: "SignerProblem",
|
|
1174
1604
|
additionalProperties: false
|
|
1175
1605
|
});
|
|
1176
|
-
var SignerCeremonyParamsSchema = Type.Object({ ceremonyId: Type.Unsafe(schemaRef(SignerBase64UrlSchema)) }, {
|
|
1177
|
-
$id: "SignerCeremonyParams",
|
|
1178
|
-
additionalProperties: false
|
|
1179
|
-
});
|
|
1180
|
-
var SignerSessionSchema = Type.Object({
|
|
1181
|
-
version: Type.Literal(1),
|
|
1182
|
-
token: Type.Unsafe(schemaRef(SignerBase64UrlSchema)),
|
|
1183
|
-
expiresAt: Type.String()
|
|
1184
|
-
}, {
|
|
1185
|
-
$id: "SignerSession",
|
|
1186
|
-
additionalProperties: false
|
|
1187
|
-
});
|
|
1188
|
-
var SignerEnrollmentCeremonyRequestSchema = Type.Object({
|
|
1189
|
-
version: Type.Literal(1),
|
|
1190
|
-
operation: Type.Literal("credential-enrollment"),
|
|
1191
|
-
label: Type.String({
|
|
1192
|
-
minLength: 1,
|
|
1193
|
-
maxLength: 255
|
|
1194
|
-
}),
|
|
1195
|
-
teamId: Type.Unsafe(schemaRef(SignerUuidSchema))
|
|
1196
|
-
}, {
|
|
1197
|
-
$id: "SignerEnrollmentCeremonyRequest",
|
|
1198
|
-
additionalProperties: false
|
|
1199
|
-
});
|
|
1200
|
-
var SignerChallengeCeremonyRequestSchema = Type.Object({
|
|
1201
|
-
version: Type.Literal(1),
|
|
1202
|
-
operation: Type.Unsafe(schemaRef(SignerChallengeOperationSchema)),
|
|
1203
|
-
resourceId: Type.Unsafe(schemaRef(SignerUuidSchema)),
|
|
1204
|
-
challenge: Type.Unsafe(schemaRef(SignerPreviewSignChallengeValueSchema))
|
|
1205
|
-
}, {
|
|
1206
|
-
$id: "SignerChallengeCeremonyRequest",
|
|
1207
|
-
additionalProperties: false
|
|
1208
|
-
});
|
|
1209
|
-
var SignerCeremonyRequestSchema = Type.Union([Type.Unsafe(schemaRef(SignerEnrollmentCeremonyRequestSchema)), Type.Unsafe(schemaRef(SignerChallengeCeremonyRequestSchema))], { $id: "SignerCeremonyRequest" });
|
|
1210
|
-
var SignerCeremonySchema = Type.Object({
|
|
1211
|
-
version: Type.Literal(1),
|
|
1212
|
-
id: Type.Unsafe(schemaRef(SignerBase64UrlSchema)),
|
|
1213
|
-
operation: Type.Unsafe(schemaRef(SignerOperationSchema)),
|
|
1214
|
-
approvalUrl: Type.String(),
|
|
1215
|
-
expiresAt: Type.String()
|
|
1216
|
-
}, {
|
|
1217
|
-
$id: "SignerCeremony",
|
|
1218
|
-
additionalProperties: false
|
|
1219
|
-
});
|
|
1220
|
-
var SignerPendingResultSchema = Type.Object({
|
|
1221
|
-
version: Type.Literal(1),
|
|
1222
|
-
status: Type.Literal("pending"),
|
|
1223
|
-
operation: Type.Unsafe(schemaRef(SignerOperationSchema))
|
|
1224
|
-
}, {
|
|
1225
|
-
$id: "SignerPendingResult",
|
|
1226
|
-
additionalProperties: false
|
|
1227
|
-
});
|
|
1228
|
-
var SignerEnrollmentResultSchema = Type.Object({
|
|
1229
|
-
version: Type.Literal(1),
|
|
1230
|
-
status: Type.Literal("completed"),
|
|
1231
|
-
operation: Type.Literal("credential-enrollment"),
|
|
1232
|
-
publicMaterial: Type.Unsafe(schemaRef(SignerPreviewSignPublicMaterialSchema))
|
|
1233
|
-
}, {
|
|
1234
|
-
$id: "SignerEnrollmentResult",
|
|
1235
|
-
additionalProperties: false
|
|
1236
|
-
});
|
|
1237
|
-
var SignerReceiptSchema = PreviewSignReceiptValueSchema;
|
|
1238
|
-
var SignerSignatureResultSchema = Type.Object({
|
|
1239
|
-
version: Type.Literal(1),
|
|
1240
|
-
status: Type.Literal("completed"),
|
|
1241
|
-
operation: Type.Unsafe(schemaRef(SignerChallengeOperationSchema)),
|
|
1242
|
-
receipt: Type.Unsafe(schemaRef(SignerReceiptSchema))
|
|
1243
|
-
}, {
|
|
1244
|
-
$id: "SignerSignatureResult",
|
|
1245
|
-
additionalProperties: false
|
|
1246
|
-
});
|
|
1247
|
-
var SignerFailedResultSchema = Type.Object({
|
|
1248
|
-
version: Type.Literal(1),
|
|
1249
|
-
status: Type.Literal("failed"),
|
|
1250
|
-
operation: Type.Unsafe(schemaRef(SignerOperationSchema)),
|
|
1251
|
-
code: Type.String(),
|
|
1252
|
-
message: Type.String()
|
|
1253
|
-
}, {
|
|
1254
|
-
$id: "SignerFailedResult",
|
|
1255
|
-
additionalProperties: false
|
|
1256
|
-
});
|
|
1257
|
-
var SignerCeremonyResultSchema = Type.Union([
|
|
1258
|
-
Type.Unsafe(schemaRef(SignerPendingResultSchema)),
|
|
1259
|
-
Type.Unsafe(schemaRef(SignerEnrollmentResultSchema)),
|
|
1260
|
-
Type.Unsafe(schemaRef(SignerSignatureResultSchema)),
|
|
1261
|
-
Type.Unsafe(schemaRef(SignerFailedResultSchema))
|
|
1262
|
-
], { $id: "SignerCeremonyResult" });
|
|
1263
|
-
({ ...previewSignSchemaContext }), schemaId(SignerUuidSchema), schemaId(SignerOperationSchema), schemaId(SignerProblemSchema), schemaId(SignerCeremonyParamsSchema), schemaId(SignerSessionSchema), schemaId(SignerEnrollmentCeremonyRequestSchema), schemaId(SignerChallengeCeremonyRequestSchema), schemaId(SignerCeremonyRequestSchema), schemaId(SignerCeremonySchema), schemaId(SignerPendingResultSchema), schemaId(SignerEnrollmentResultSchema), schemaId(SignerSignatureResultSchema), schemaId(SignerFailedResultSchema), schemaId(SignerCeremonyResultSchema);
|
|
1264
|
-
//#endregion
|
|
1265
|
-
//#region ../../libs/models/src/tool-enforcement.ts
|
|
1266
|
-
var TOOL_ENFORCEMENT_VALUES = [
|
|
1267
|
-
"off",
|
|
1268
|
-
"watch",
|
|
1269
|
-
"enforce"
|
|
1270
|
-
];
|
|
1271
|
-
var toolEnforcementLiterals = [
|
|
1272
|
-
Type.Literal(TOOL_ENFORCEMENT_VALUES[0]),
|
|
1273
|
-
Type.Literal(TOOL_ENFORCEMENT_VALUES[1]),
|
|
1274
|
-
Type.Literal(TOOL_ENFORCEMENT_VALUES[2])
|
|
1275
|
-
];
|
|
1276
|
-
var ToolEnforcementSchema = Type.Union(toolEnforcementLiterals, { description: "Runtime tool-policy enforcement mode: off (inert), watch (audit only), enforce (block disallowed tools, fail-closed)." });
|
|
1277
|
-
//#endregion
|
|
1278
|
-
//#region ../../libs/tasks/src/runtime-profiles.ts
|
|
1279
|
-
var RuntimeProfileName = Type.String({
|
|
1280
|
-
minLength: 1,
|
|
1281
|
-
maxLength: 100,
|
|
1282
|
-
pattern: "^[a-zA-Z0-9][a-zA-Z0-9_-]{0,99}$"
|
|
1283
|
-
});
|
|
1284
|
-
var RuntimeProfileEnvName = Type.String({
|
|
1285
|
-
minLength: 1,
|
|
1286
|
-
maxLength: 128,
|
|
1287
|
-
pattern: "^[A-Z_][A-Z0-9_]*$"
|
|
1288
|
-
});
|
|
1289
|
-
var RuntimeProfileToolName = Type.String({
|
|
1290
|
-
minLength: 1,
|
|
1291
|
-
maxLength: 128,
|
|
1292
|
-
pattern: "^[a-zA-Z0-9._/-]+$"
|
|
1293
|
-
});
|
|
1294
|
-
var RUNTIME_PROFILE_RUNTIME_KIND_PATTERN = "^[a-z][a-z0-9._-]{0,99}$";
|
|
1295
|
-
new RegExp(RUNTIME_PROFILE_RUNTIME_KIND_PATTERN);
|
|
1296
|
-
var RuntimeProfileRuntimeKind = Type.String({
|
|
1297
|
-
minLength: 1,
|
|
1298
|
-
maxLength: 100,
|
|
1299
|
-
pattern: RUNTIME_PROFILE_RUNTIME_KIND_PATTERN
|
|
1300
|
-
});
|
|
1301
|
-
var RuntimeProfileWorkspaceMode = Type.Union([
|
|
1302
|
-
Type.Literal("none"),
|
|
1303
|
-
Type.Literal("shared_mount"),
|
|
1304
|
-
Type.Literal("dedicated_worktree")
|
|
1305
|
-
]);
|
|
1306
|
-
/**
|
|
1307
|
-
* Tool-policy enforcement mode for the profile's runtime `tool_call` gate:
|
|
1308
|
-
* `off` (inert), `watch` (audit only), `enforce` (block disallowed tools,
|
|
1309
|
-
* fail-closed). Read by the daemon via `GET /runtime-profiles/:id/allowed-tools`.
|
|
1310
|
-
*/
|
|
1311
|
-
var RuntimeProfileToolEnforcement = ToolEnforcementSchema;
|
|
1312
|
-
var RuntimeProfileAllowedWorkspaceModes = Type.Array(RuntimeProfileWorkspaceMode, {
|
|
1313
|
-
minItems: 1,
|
|
1314
|
-
maxItems: 3,
|
|
1315
|
-
uniqueItems: true
|
|
1316
|
-
});
|
|
1317
|
-
var RuntimeProfileThinkingLevelOptions = [
|
|
1318
|
-
Type.Literal("off"),
|
|
1319
|
-
Type.Literal("minimal"),
|
|
1320
|
-
Type.Literal("low"),
|
|
1321
|
-
Type.Literal("medium"),
|
|
1322
|
-
Type.Literal("high"),
|
|
1323
|
-
Type.Literal("xhigh")
|
|
1324
|
-
];
|
|
1325
|
-
Type.Union([...RuntimeProfileThinkingLevelOptions]);
|
|
1326
|
-
var RuntimeProfileNullableThinkingLevel = Type.Union([...RuntimeProfileThinkingLevelOptions, Type.Null()]);
|
|
1327
|
-
var RuntimeProfileNullableTemperature = Type.Union([Type.Null(), Type.Number({
|
|
1328
|
-
minimum: 0,
|
|
1329
|
-
maximum: 2
|
|
1330
|
-
})]);
|
|
1331
|
-
var RuntimeProfileNullableTopP = Type.Union([Type.Null(), Type.Number({
|
|
1332
|
-
minimum: 0,
|
|
1333
|
-
maximum: 1
|
|
1334
|
-
})]);
|
|
1335
|
-
var RuntimeProfileNullableTopK = Type.Union([Type.Integer({
|
|
1336
|
-
minimum: 1,
|
|
1337
|
-
maximum: 1e4
|
|
1338
|
-
}), Type.Null()]);
|
|
1339
|
-
var RuntimeProfileNullableMaxOutputTokens = Type.Union([Type.Integer({
|
|
1340
|
-
minimum: 1,
|
|
1341
|
-
maximum: 1e6
|
|
1342
|
-
}), Type.Null()]);
|
|
1343
|
-
var RuntimeProfileAllowedHost = Type.String({
|
|
1344
|
-
minLength: 1,
|
|
1345
|
-
maxLength: 255,
|
|
1346
|
-
pattern: "^(?:\\*\\.)?(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)(?:\\.(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?))*$"
|
|
1347
|
-
});
|
|
1348
|
-
var RuntimeProfileSandbox = Type.Object({
|
|
1349
|
-
network: Type.Optional(Type.Object({
|
|
1350
|
-
allowedHosts: Type.Optional(Type.Array(RuntimeProfileAllowedHost, { maxItems: 50 })),
|
|
1351
|
-
allowedInternalHosts: Type.Optional(Type.Array(RuntimeProfileAllowedHost, { maxItems: 50 }))
|
|
1352
|
-
}, { additionalProperties: false })),
|
|
1353
|
-
vfs: Type.Optional(Type.Object({
|
|
1354
|
-
shadow: Type.Optional(Type.Array(Type.String({
|
|
1355
|
-
minLength: 1,
|
|
1356
|
-
maxLength: 255
|
|
1357
|
-
}), { maxItems: 100 })),
|
|
1358
|
-
shadowMode: Type.Optional(Type.Union([Type.Literal("deny"), Type.Literal("tmpfs")]))
|
|
1359
|
-
}, { additionalProperties: false })),
|
|
1360
|
-
env: Type.Optional(Type.Record(RuntimeProfileEnvName, Type.String({ maxLength: 4096 }))),
|
|
1361
|
-
hostExec: Type.Optional(Type.Object({ autoApprove: Type.Optional(Type.Literal(false)) }, { additionalProperties: false })),
|
|
1362
|
-
resources: Type.Optional(Type.Object({
|
|
1363
|
-
memory: Type.Optional(Type.String({
|
|
1364
|
-
minLength: 2,
|
|
1365
|
-
maxLength: 16,
|
|
1366
|
-
pattern: "^[0-9]+[KMG]?$"
|
|
1367
|
-
})),
|
|
1368
|
-
cpus: Type.Optional(Type.Integer({
|
|
1369
|
-
minimum: 1,
|
|
1370
|
-
maximum: 32
|
|
1371
|
-
}))
|
|
1372
|
-
}, { additionalProperties: false }))
|
|
1373
|
-
}, {
|
|
1374
|
-
$id: "RuntimeProfileSandbox",
|
|
1375
|
-
additionalProperties: false
|
|
1376
|
-
});
|
|
1377
|
-
var RuntimeProfileContext = Type.Object({
|
|
1378
|
-
slug: Type.String({
|
|
1379
|
-
minLength: 1,
|
|
1380
|
-
maxLength: 64,
|
|
1381
|
-
pattern: "^[a-zA-Z0-9_-]+$"
|
|
1382
|
-
}),
|
|
1383
|
-
binding: Type.Union([
|
|
1384
|
-
Type.Literal("skill"),
|
|
1385
|
-
Type.Literal("context_inline"),
|
|
1386
|
-
Type.Literal("prompt_prefix"),
|
|
1387
|
-
Type.Literal("user_inline")
|
|
1388
|
-
]),
|
|
1389
|
-
content: Type.String({
|
|
1390
|
-
minLength: 1,
|
|
1391
|
-
maxLength: 65536
|
|
1392
|
-
})
|
|
1393
|
-
}, {
|
|
1394
|
-
$id: "RuntimeProfileContext",
|
|
1395
|
-
additionalProperties: false
|
|
1396
|
-
});
|
|
1397
|
-
var RuntimeProfileRef = Type.Object({ profileId: Type.String({ format: "uuid" }) }, {
|
|
1398
|
-
$id: "RuntimeProfileRef",
|
|
1606
|
+
var SignerCeremonyParamsSchema = Type.Object({ ceremonyId: Type.Unsafe(schemaRef(SignerBase64UrlSchema)) }, {
|
|
1607
|
+
$id: "SignerCeremonyParams",
|
|
1399
1608
|
additionalProperties: false
|
|
1400
1609
|
});
|
|
1401
|
-
var
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
var RuntimeProfileHeartbeatIntervalMs = Type.Integer({
|
|
1406
|
-
minimum: 0,
|
|
1407
|
-
maximum: 36e5
|
|
1408
|
-
});
|
|
1409
|
-
var RuntimeProfileMaxBatchSize = Type.Integer({
|
|
1410
|
-
minimum: 1,
|
|
1411
|
-
maximum: 1e3
|
|
1412
|
-
});
|
|
1413
|
-
var RuntimeProfileMaxTurns = Type.Integer({
|
|
1414
|
-
minimum: 0,
|
|
1415
|
-
maximum: 1e4
|
|
1416
|
-
});
|
|
1417
|
-
var RuntimeProfileMaxBashTimeouts = Type.Integer({
|
|
1418
|
-
minimum: 0,
|
|
1419
|
-
maximum: 1e3
|
|
1420
|
-
});
|
|
1421
|
-
Type.Object({
|
|
1422
|
-
id: Type.String({ format: "uuid" }),
|
|
1423
|
-
teamId: Type.String({ format: "uuid" }),
|
|
1424
|
-
name: RuntimeProfileName,
|
|
1425
|
-
description: Type.Union([Type.String({ maxLength: 4096 }), Type.Null()]),
|
|
1426
|
-
provider: Type.String({
|
|
1427
|
-
minLength: 1,
|
|
1428
|
-
maxLength: 100
|
|
1429
|
-
}),
|
|
1430
|
-
model: Type.String({
|
|
1431
|
-
minLength: 1,
|
|
1432
|
-
maxLength: 200
|
|
1433
|
-
}),
|
|
1434
|
-
thinkingLevel: RuntimeProfileNullableThinkingLevel,
|
|
1435
|
-
temperature: RuntimeProfileNullableTemperature,
|
|
1436
|
-
topP: RuntimeProfileNullableTopP,
|
|
1437
|
-
topK: RuntimeProfileNullableTopK,
|
|
1438
|
-
maxOutputTokens: RuntimeProfileNullableMaxOutputTokens,
|
|
1439
|
-
runtimeKind: RuntimeProfileRuntimeKind,
|
|
1440
|
-
sandbox: RuntimeProfileSandbox,
|
|
1441
|
-
sessionStorageMode: Type.Literal("local"),
|
|
1442
|
-
workspaceStorageMode: Type.Literal("local"),
|
|
1443
|
-
defaultWorkspaceMode: Type.Union([RuntimeProfileWorkspaceMode, Type.Null()]),
|
|
1444
|
-
allowedWorkspaceModes: RuntimeProfileAllowedWorkspaceModes,
|
|
1445
|
-
sessionTtlSec: Type.Integer({
|
|
1446
|
-
minimum: 1,
|
|
1447
|
-
maximum: 86400
|
|
1448
|
-
}),
|
|
1449
|
-
workspaceTtlSec: Type.Integer({
|
|
1450
|
-
minimum: 1,
|
|
1451
|
-
maximum: 86400
|
|
1452
|
-
}),
|
|
1453
|
-
leaseTtlSec: RuntimeProfileLeaseTtlSec,
|
|
1454
|
-
heartbeatIntervalMs: RuntimeProfileHeartbeatIntervalMs,
|
|
1455
|
-
maxBatchSize: RuntimeProfileMaxBatchSize,
|
|
1456
|
-
maxTurns: RuntimeProfileMaxTurns,
|
|
1457
|
-
maxBashTimeouts: RuntimeProfileMaxBashTimeouts,
|
|
1458
|
-
toolEnforcement: RuntimeProfileToolEnforcement,
|
|
1459
|
-
requiredEnv: Type.Array(RuntimeProfileEnvName, { maxItems: 100 }),
|
|
1460
|
-
requiredTools: Type.Array(RuntimeProfileToolName, { maxItems: 100 }),
|
|
1461
|
-
requiredExecutables: Type.Array(RuntimeProfileToolName, { maxItems: 100 }),
|
|
1462
|
-
context: Type.Array(RuntimeProfileContext, { maxItems: 5 }),
|
|
1463
|
-
revision: Type.Integer({ minimum: 1 }),
|
|
1464
|
-
definitionCid: Type.String({
|
|
1465
|
-
minLength: 1,
|
|
1466
|
-
maxLength: 100
|
|
1467
|
-
}),
|
|
1468
|
-
createdByAgentId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
1469
|
-
createdByHumanId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
1470
|
-
createdAt: Type.String({ format: "date-time" }),
|
|
1471
|
-
updatedAt: Type.String({ format: "date-time" })
|
|
1610
|
+
var SignerSessionSchema = Type.Object({
|
|
1611
|
+
version: Type.Literal(1),
|
|
1612
|
+
token: Type.Unsafe(schemaRef(SignerBase64UrlSchema)),
|
|
1613
|
+
expiresAt: Type.String()
|
|
1472
1614
|
}, {
|
|
1473
|
-
$id: "
|
|
1615
|
+
$id: "SignerSession",
|
|
1474
1616
|
additionalProperties: false
|
|
1475
1617
|
});
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
Type.
|
|
1480
|
-
Type.Literal("extend"),
|
|
1481
|
-
Type.Literal("fork")
|
|
1482
|
-
]);
|
|
1483
|
-
var RuntimeSessionCheckpointKind = Type.Union([Type.Literal("attempt_final")]);
|
|
1484
|
-
Type.Object({
|
|
1485
|
-
id: Type.String({ format: "uuid" }),
|
|
1486
|
-
teamId: Type.String({ format: "uuid" }),
|
|
1487
|
-
taskId: Type.String({ format: "uuid" }),
|
|
1488
|
-
attemptN: Type.Integer({ minimum: 1 }),
|
|
1489
|
-
sourceSlotId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
1490
|
-
sourceRuntimeProfileId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
1491
|
-
sessionKind: RuntimeSessionKind,
|
|
1492
|
-
parentSessionId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
1493
|
-
contentType: Type.String({
|
|
1494
|
-
minLength: 1,
|
|
1495
|
-
maxLength: 200
|
|
1496
|
-
}),
|
|
1497
|
-
contentEncoding: Type.Union([Type.String({
|
|
1498
|
-
minLength: 1,
|
|
1499
|
-
maxLength: 100
|
|
1500
|
-
}), Type.Null()]),
|
|
1501
|
-
sizeBytes: Type.Integer({ minimum: 0 }),
|
|
1502
|
-
sha256: Type.String({
|
|
1503
|
-
minLength: 64,
|
|
1504
|
-
maxLength: 64
|
|
1505
|
-
}),
|
|
1506
|
-
storageClass: Type.String({
|
|
1618
|
+
var SignerEnrollmentCeremonyRequestSchema = Type.Object({
|
|
1619
|
+
version: Type.Literal(1),
|
|
1620
|
+
operation: Type.Literal("credential-enrollment"),
|
|
1621
|
+
label: Type.String({
|
|
1507
1622
|
minLength: 1,
|
|
1508
|
-
maxLength:
|
|
1623
|
+
maxLength: 255
|
|
1509
1624
|
}),
|
|
1510
|
-
|
|
1511
|
-
uploadedAt: Type.String({ format: "date-time" })
|
|
1512
|
-
}, { $id: "RuntimeSession" });
|
|
1513
|
-
Type.Object({
|
|
1514
|
-
sourceSlotId: Type.Optional(Type.String({ format: "uuid" })),
|
|
1515
|
-
sourceRuntimeProfileId: Type.Optional(Type.String({ format: "uuid" })),
|
|
1516
|
-
sessionKind: RuntimeSessionKind,
|
|
1517
|
-
parentSessionId: Type.Optional(Type.String({ format: "uuid" }))
|
|
1625
|
+
teamId: Type.Unsafe(schemaRef(SignerUuidSchema))
|
|
1518
1626
|
}, {
|
|
1519
|
-
$id: "
|
|
1627
|
+
$id: "SignerEnrollmentCeremonyRequest",
|
|
1520
1628
|
additionalProperties: false
|
|
1521
1629
|
});
|
|
1522
|
-
Type.
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1630
|
+
var SignerChallengeCeremonyRequestSchema = Type.Object({
|
|
1631
|
+
version: Type.Literal(1),
|
|
1632
|
+
operation: Type.Unsafe(schemaRef(SignerChallengeOperationSchema)),
|
|
1633
|
+
resourceId: Type.Unsafe(schemaRef(SignerUuidSchema)),
|
|
1634
|
+
challenge: Type.Unsafe(schemaRef(SignerPreviewSignChallengeValueSchema))
|
|
1635
|
+
}, {
|
|
1636
|
+
$id: "SignerChallengeCeremonyRequest",
|
|
1637
|
+
additionalProperties: false
|
|
1526
1638
|
});
|
|
1527
|
-
Type.
|
|
1528
|
-
|
|
1529
|
-
|
|
1639
|
+
var SignerCeremonyRequestSchema = Type.Union([Type.Unsafe(schemaRef(SignerEnrollmentCeremonyRequestSchema)), Type.Unsafe(schemaRef(SignerChallengeCeremonyRequestSchema))], { $id: "SignerCeremonyRequest" });
|
|
1640
|
+
var SignerCeremonySchema = Type.Object({
|
|
1641
|
+
version: Type.Literal(1),
|
|
1642
|
+
id: Type.Unsafe(schemaRef(SignerBase64UrlSchema)),
|
|
1643
|
+
operation: Type.Unsafe(schemaRef(SignerOperationSchema)),
|
|
1644
|
+
approvalUrl: Type.String(),
|
|
1645
|
+
expiresAt: Type.String()
|
|
1530
1646
|
}, {
|
|
1531
|
-
$id: "
|
|
1647
|
+
$id: "SignerCeremony",
|
|
1532
1648
|
additionalProperties: false
|
|
1533
1649
|
});
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
Type.
|
|
1538
|
-
Type.Literal("fork"),
|
|
1539
|
-
Type.Literal("scratch")
|
|
1540
|
-
]);
|
|
1541
|
-
var RuntimeSlotState = Type.Union([Type.Literal("active"), Type.Literal("idle")]);
|
|
1542
|
-
var RuntimeWorkspace = Type.Object({
|
|
1543
|
-
id: Type.String({ format: "uuid" }),
|
|
1544
|
-
teamId: Type.String({ format: "uuid" }),
|
|
1545
|
-
workspaceId: Type.String({ minLength: 1 }),
|
|
1546
|
-
worktreePath: Type.String({ minLength: 1 }),
|
|
1547
|
-
worktreeBranch: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
|
|
1548
|
-
kind: RuntimeWorkspaceKind,
|
|
1549
|
-
createdAtMs: Type.Integer({ minimum: 0 }),
|
|
1550
|
-
lastUsedAtMs: Type.Integer({ minimum: 0 })
|
|
1551
|
-
}, { $id: "RuntimeWorkspace" });
|
|
1552
|
-
var RuntimeSlot = Type.Object({
|
|
1553
|
-
id: Type.String({ format: "uuid" }),
|
|
1554
|
-
teamId: Type.String({ format: "uuid" }),
|
|
1555
|
-
agentName: Type.String({
|
|
1556
|
-
minLength: 1,
|
|
1557
|
-
maxLength: 100
|
|
1558
|
-
}),
|
|
1559
|
-
runtimeProfileId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
1560
|
-
provider: Type.String({
|
|
1561
|
-
minLength: 1,
|
|
1562
|
-
maxLength: 100
|
|
1563
|
-
}),
|
|
1564
|
-
model: Type.String({
|
|
1565
|
-
minLength: 1,
|
|
1566
|
-
maxLength: 200
|
|
1567
|
-
}),
|
|
1568
|
-
slotKey: Type.String({ minLength: 1 }),
|
|
1569
|
-
taskType: Type.String({
|
|
1570
|
-
minLength: 1,
|
|
1571
|
-
maxLength: 100
|
|
1572
|
-
}),
|
|
1573
|
-
state: RuntimeSlotState,
|
|
1574
|
-
lastTaskId: Type.String({ format: "uuid" }),
|
|
1575
|
-
lastAttemptN: Type.Integer({ minimum: 1 }),
|
|
1576
|
-
sessionDir: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
|
|
1577
|
-
sessionPath: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
|
|
1578
|
-
workspaceRowId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
1579
|
-
createdAtMs: Type.Integer({ minimum: 0 }),
|
|
1580
|
-
lastUsedAtMs: Type.Integer({ minimum: 0 }),
|
|
1581
|
-
expiresAtMs: Type.Integer({ minimum: 0 })
|
|
1582
|
-
}, { $id: "RuntimeSlot" });
|
|
1583
|
-
var ResolvedRuntimeSlot = Type.Object({
|
|
1584
|
-
slot: RuntimeSlot,
|
|
1585
|
-
workspace: Type.Union([RuntimeWorkspace, Type.Null()])
|
|
1586
|
-
}, { $id: "ResolvedRuntimeSlot" });
|
|
1587
|
-
Type.Object({ items: Type.Array(ResolvedRuntimeSlot) }, { $id: "RuntimeSlotListResponse" });
|
|
1588
|
-
Type.Object({
|
|
1589
|
-
agentName: Type.String({
|
|
1590
|
-
minLength: 1,
|
|
1591
|
-
maxLength: 100
|
|
1592
|
-
}),
|
|
1593
|
-
runtimeProfileId: Type.String({ format: "uuid" }),
|
|
1594
|
-
provider: Type.String({
|
|
1595
|
-
minLength: 1,
|
|
1596
|
-
maxLength: 100
|
|
1597
|
-
}),
|
|
1598
|
-
model: Type.String({
|
|
1599
|
-
minLength: 1,
|
|
1600
|
-
maxLength: 200
|
|
1601
|
-
}),
|
|
1602
|
-
slotKey: Type.String({ minLength: 1 }),
|
|
1603
|
-
taskType: Type.String({
|
|
1604
|
-
minLength: 1,
|
|
1605
|
-
maxLength: 100
|
|
1606
|
-
}),
|
|
1607
|
-
sessionDir: Type.Optional(Type.String({ minLength: 1 })),
|
|
1608
|
-
sessionPath: Type.Optional(Type.String({ minLength: 1 })),
|
|
1609
|
-
workspaceId: Type.Optional(Type.String({ minLength: 1 })),
|
|
1610
|
-
worktreePath: Type.Optional(Type.String({ minLength: 1 })),
|
|
1611
|
-
worktreeBranch: Type.Optional(Type.String({ minLength: 1 })),
|
|
1612
|
-
workspaceKind: Type.Optional(RuntimeWorkspaceKind),
|
|
1613
|
-
lastTaskId: Type.String({ format: "uuid" }),
|
|
1614
|
-
lastAttemptN: Type.Integer({ minimum: 1 })
|
|
1650
|
+
var SignerPendingResultSchema = Type.Object({
|
|
1651
|
+
version: Type.Literal(1),
|
|
1652
|
+
status: Type.Literal("pending"),
|
|
1653
|
+
operation: Type.Unsafe(schemaRef(SignerOperationSchema))
|
|
1615
1654
|
}, {
|
|
1616
|
-
$id: "
|
|
1655
|
+
$id: "SignerPendingResult",
|
|
1617
1656
|
additionalProperties: false
|
|
1618
1657
|
});
|
|
1619
|
-
Type.Object({
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
runtimeProfileId: Type.String({ format: "uuid" }),
|
|
1625
|
-
provider: Type.String({
|
|
1626
|
-
minLength: 1,
|
|
1627
|
-
maxLength: 100
|
|
1628
|
-
}),
|
|
1629
|
-
model: Type.String({
|
|
1630
|
-
minLength: 1,
|
|
1631
|
-
maxLength: 200
|
|
1632
|
-
}),
|
|
1633
|
-
slotKey: Type.String({ minLength: 1 }),
|
|
1634
|
-
taskId: Type.String({ format: "uuid" }),
|
|
1635
|
-
attemptN: Type.Integer({ minimum: 1 }),
|
|
1636
|
-
sessionPath: Type.Optional(Type.String({ minLength: 1 }))
|
|
1658
|
+
var SignerEnrollmentResultSchema = Type.Object({
|
|
1659
|
+
version: Type.Literal(1),
|
|
1660
|
+
status: Type.Literal("completed"),
|
|
1661
|
+
operation: Type.Literal("credential-enrollment"),
|
|
1662
|
+
publicMaterial: Type.Unsafe(schemaRef(SignerPreviewSignPublicMaterialSchema))
|
|
1637
1663
|
}, {
|
|
1638
|
-
$id: "
|
|
1664
|
+
$id: "SignerEnrollmentResult",
|
|
1639
1665
|
additionalProperties: false
|
|
1640
1666
|
});
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1667
|
+
var SignerReceiptSchema = PreviewSignReceiptValueSchema;
|
|
1668
|
+
var SignerSignatureResultSchema = Type.Object({
|
|
1669
|
+
version: Type.Literal(1),
|
|
1670
|
+
status: Type.Literal("completed"),
|
|
1671
|
+
operation: Type.Unsafe(schemaRef(SignerChallengeOperationSchema)),
|
|
1672
|
+
receipt: Type.Unsafe(schemaRef(SignerReceiptSchema))
|
|
1644
1673
|
}, {
|
|
1645
|
-
$id: "
|
|
1674
|
+
$id: "SignerSignatureResult",
|
|
1646
1675
|
additionalProperties: false
|
|
1647
1676
|
});
|
|
1648
|
-
Type.Object({
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
state: Type.Optional(RuntimeSlotState),
|
|
1655
|
-
limit: Type.Optional(Type.Integer({
|
|
1656
|
-
minimum: 1,
|
|
1657
|
-
maximum: 200
|
|
1658
|
-
}))
|
|
1677
|
+
var SignerFailedResultSchema = Type.Object({
|
|
1678
|
+
version: Type.Literal(1),
|
|
1679
|
+
status: Type.Literal("failed"),
|
|
1680
|
+
operation: Type.Unsafe(schemaRef(SignerOperationSchema)),
|
|
1681
|
+
code: Type.String(),
|
|
1682
|
+
message: Type.String()
|
|
1659
1683
|
}, {
|
|
1660
|
-
$id: "
|
|
1684
|
+
$id: "SignerFailedResult",
|
|
1661
1685
|
additionalProperties: false
|
|
1662
1686
|
});
|
|
1687
|
+
var SignerCeremonyResultSchema = Type.Union([
|
|
1688
|
+
Type.Unsafe(schemaRef(SignerPendingResultSchema)),
|
|
1689
|
+
Type.Unsafe(schemaRef(SignerEnrollmentResultSchema)),
|
|
1690
|
+
Type.Unsafe(schemaRef(SignerSignatureResultSchema)),
|
|
1691
|
+
Type.Unsafe(schemaRef(SignerFailedResultSchema))
|
|
1692
|
+
], { $id: "SignerCeremonyResult" });
|
|
1693
|
+
({ ...previewSignSchemaContext }), schemaId(SignerUuidSchema), schemaId(SignerOperationSchema), schemaId(SignerProblemSchema), schemaId(SignerCeremonyParamsSchema), schemaId(SignerSessionSchema), schemaId(SignerEnrollmentCeremonyRequestSchema), schemaId(SignerChallengeCeremonyRequestSchema), schemaId(SignerCeremonyRequestSchema), schemaId(SignerCeremonySchema), schemaId(SignerPendingResultSchema), schemaId(SignerEnrollmentResultSchema), schemaId(SignerSignatureResultSchema), schemaId(SignerFailedResultSchema), schemaId(SignerCeremonyResultSchema);
|
|
1663
1694
|
//#endregion
|
|
1664
|
-
//#region ../../libs/
|
|
1695
|
+
//#region ../../libs/models/src/tool-enforcement.ts
|
|
1696
|
+
var TOOL_ENFORCEMENT_VALUES = [
|
|
1697
|
+
"off",
|
|
1698
|
+
"watch",
|
|
1699
|
+
"enforce"
|
|
1700
|
+
];
|
|
1701
|
+
var toolEnforcementLiterals = [
|
|
1702
|
+
Type.Literal(TOOL_ENFORCEMENT_VALUES[0]),
|
|
1703
|
+
Type.Literal(TOOL_ENFORCEMENT_VALUES[1]),
|
|
1704
|
+
Type.Literal(TOOL_ENFORCEMENT_VALUES[2])
|
|
1705
|
+
];
|
|
1706
|
+
var ToolEnforcementSchema = Type.Union(toolEnforcementLiterals, { description: "Runtime tool-policy enforcement mode: off (inert), watch (audit only), enforce (block disallowed tools, fail-closed)." });
|
|
1707
|
+
//#endregion
|
|
1708
|
+
//#region ../../libs/runtime-profiles/src/runtime-profiles.ts
|
|
1709
|
+
var RuntimeProfileName = Type.String({
|
|
1710
|
+
minLength: 1,
|
|
1711
|
+
maxLength: 100,
|
|
1712
|
+
pattern: "^[a-zA-Z0-9][a-zA-Z0-9_-]{0,99}$"
|
|
1713
|
+
});
|
|
1714
|
+
var RuntimeProfileEnvName = Type.String({
|
|
1715
|
+
minLength: 1,
|
|
1716
|
+
maxLength: 128,
|
|
1717
|
+
pattern: "^[A-Z_][A-Z0-9_]*$"
|
|
1718
|
+
});
|
|
1719
|
+
var RuntimeProfileToolName = Type.String({
|
|
1720
|
+
minLength: 1,
|
|
1721
|
+
maxLength: 128,
|
|
1722
|
+
pattern: "^[a-zA-Z0-9._/-]+$"
|
|
1723
|
+
});
|
|
1724
|
+
var RUNTIME_PROFILE_RUNTIME_KIND_PATTERN = "^[a-z][a-z0-9._-]{0,99}$";
|
|
1725
|
+
new RegExp(RUNTIME_PROFILE_RUNTIME_KIND_PATTERN);
|
|
1726
|
+
var RuntimeProfileRuntimeKind = Type.String({
|
|
1727
|
+
minLength: 1,
|
|
1728
|
+
maxLength: 100,
|
|
1729
|
+
pattern: RUNTIME_PROFILE_RUNTIME_KIND_PATTERN
|
|
1730
|
+
});
|
|
1731
|
+
var RuntimeProfileWorkspaceMode = Type.Union([
|
|
1732
|
+
Type.Literal("none"),
|
|
1733
|
+
Type.Literal("shared_mount"),
|
|
1734
|
+
Type.Literal("dedicated_worktree")
|
|
1735
|
+
]);
|
|
1665
1736
|
/**
|
|
1666
|
-
*
|
|
1667
|
-
*
|
|
1668
|
-
*
|
|
1669
|
-
* Before this envelope existed, criteria were scattered: a vestigial
|
|
1670
|
-
* `criteriaCid` column nobody resolved, free-form prose on
|
|
1671
|
-
* `fulfill_brief.input`, and inline `rubric` / `criteria[]` fields on
|
|
1672
|
-
* judgment-task inputs. None of those were machine-verifiable
|
|
1673
|
-
* end-to-end.
|
|
1674
|
-
*
|
|
1675
|
-
* This module defines a single, content-addressable envelope a proposer
|
|
1676
|
-
* attaches to any task type. It has four orthogonal sections — pick
|
|
1677
|
-
* whichever apply per task type:
|
|
1678
|
-
*
|
|
1679
|
-
* - `gates` Promise-level structural/process checks
|
|
1680
|
-
* - `assertions` Declarative claims about output JSON
|
|
1681
|
-
* - `rubric` Weighted-criteria scoring instrument, reused
|
|
1682
|
-
* verbatim from `./rubric.ts`.
|
|
1683
|
-
* - `sideEffects` Required process side-effects (e.g. diary entry)
|
|
1684
|
-
*
|
|
1685
|
-
* ## Two roles, two task types
|
|
1686
|
-
*
|
|
1687
|
-
* **Producer self-assessment** (fulfillment tasks: `fulfill_brief`,
|
|
1688
|
-
* `curate_pack`, `render_pack`). The producer **LLM** evaluates the
|
|
1689
|
-
* criteria against its own output and emits a `VerificationRecord`
|
|
1690
|
-
* inside `output.verification`. The daemon is pure passthrough — it
|
|
1691
|
-
* does not run `evaluateAssertions`, does not inspect the verification
|
|
1692
|
-
* record. The REST API is dumb storage; it never re-runs assertions and
|
|
1693
|
-
* never runs LLMs. The cross-field rule
|
|
1694
|
-
* `requireVerificationWhenCriteriaPresent` enforces "verification
|
|
1695
|
-
* required iff successCriteria present" at task-output validation time
|
|
1696
|
-
* (server-side schema check). Self-assessment is a truthful self-rating,
|
|
1697
|
-
* NOT enforcement — `verification.passed=false` does not block /complete
|
|
1698
|
-
* and does not affect `acceptedAttemptN`. See
|
|
1699
|
-
* `docs/use/tasks-and-runtime.md` for the full producer/judge flow.
|
|
1700
|
-
*
|
|
1701
|
-
* **Binding evaluation** (judgment tasks: `assess_brief`, `judge_pack`).
|
|
1702
|
-
* A separate task whose IS the application of `successCriteria` to
|
|
1703
|
-
* someone else's output. Different agent (enforced at claim time), same
|
|
1704
|
-
* envelope. The judge's verdict is binding: this is the *gate* in the
|
|
1705
|
-
* MoltNet model. The rubric inside `successCriteria.rubric` IS the job
|
|
1706
|
-
* spec for the judge.
|
|
1707
|
-
*
|
|
1708
|
-
* The clean chain: producer task with `successCriteria` → producer
|
|
1709
|
-
* self-assesses honestly → proposer (or automation) creates a downstream
|
|
1710
|
-
* judgment task that references the same `successCriteria` (or a
|
|
1711
|
-
* stricter rubric) → judgment task delivers the binding verdict.
|
|
1712
|
-
*
|
|
1713
|
-
* Storage: SuccessCriteria lives inline at `task.input.successCriteria`,
|
|
1714
|
-
* pinned via the task's `inputCid`. No separate column or hash. When
|
|
1715
|
-
* #881 lands, the `rubric` field can graduate to `{ rubricCid }` lookup
|
|
1716
|
-
* without changing this envelope, and producer + judge tasks can pin
|
|
1717
|
-
* the SAME rubric across the chain for end-to-end auditability.
|
|
1737
|
+
* Tool-policy enforcement mode for the profile's runtime `tool_call` gate:
|
|
1738
|
+
* `off` (inert), `watch` (audit only), `enforce` (block disallowed tools,
|
|
1739
|
+
* fail-closed). Read by the daemon via `GET /runtime-profiles/:id/allowed-tools`.
|
|
1718
1740
|
*/
|
|
1719
|
-
var
|
|
1720
|
-
var
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
var SubmitToolCallGate = Type.Object({
|
|
1725
|
-
id: Type.String({ minLength: 1 }),
|
|
1726
|
-
kind: Type.Literal("submit-tool-call"),
|
|
1727
|
-
description: Type.String({ minLength: 1 }),
|
|
1728
|
-
required: Type.Boolean()
|
|
1729
|
-
}, { additionalProperties: false });
|
|
1730
|
-
var Gate = Type.Union([
|
|
1731
|
-
SubmitToolCallGate,
|
|
1732
|
-
Type.Object({
|
|
1733
|
-
id: Type.String({ minLength: 1 }),
|
|
1734
|
-
kind: Type.Literal("schema-check"),
|
|
1735
|
-
spec: SchemaCheckSpec,
|
|
1736
|
-
required: Type.Boolean()
|
|
1737
|
-
}, { additionalProperties: false }),
|
|
1738
|
-
Type.Object({
|
|
1739
|
-
id: Type.String({ minLength: 1 }),
|
|
1740
|
-
kind: Type.Literal("cid-equals"),
|
|
1741
|
-
spec: CidEqualsSpec,
|
|
1742
|
-
required: Type.Boolean()
|
|
1743
|
-
}, { additionalProperties: false })
|
|
1744
|
-
], { $id: "Gate" });
|
|
1745
|
-
var AssertionOp = Type.Union([
|
|
1746
|
-
Type.Literal("exists"),
|
|
1747
|
-
Type.Literal("equals"),
|
|
1748
|
-
Type.Literal("matches"),
|
|
1749
|
-
Type.Literal("in-range"),
|
|
1750
|
-
Type.Literal("min-length")
|
|
1751
|
-
], { $id: "AssertionOp" });
|
|
1752
|
-
var Assertion = Type.Object({
|
|
1753
|
-
id: Type.String({ minLength: 1 }),
|
|
1754
|
-
path: Type.String({ minLength: 1 }),
|
|
1755
|
-
op: AssertionOp,
|
|
1756
|
-
value: Type.Optional(Type.Unknown())
|
|
1757
|
-
}, {
|
|
1758
|
-
$id: "Assertion",
|
|
1759
|
-
additionalProperties: false
|
|
1741
|
+
var RuntimeProfileToolEnforcement = ToolEnforcementSchema;
|
|
1742
|
+
var RuntimeProfileAllowedWorkspaceModes = Type.Array(RuntimeProfileWorkspaceMode, {
|
|
1743
|
+
minItems: 1,
|
|
1744
|
+
maxItems: 3,
|
|
1745
|
+
uniqueItems: true
|
|
1760
1746
|
});
|
|
1761
|
-
var
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1747
|
+
var RuntimeProfileThinkingLevelOptions = [
|
|
1748
|
+
Type.Literal("off"),
|
|
1749
|
+
Type.Literal("minimal"),
|
|
1750
|
+
Type.Literal("low"),
|
|
1751
|
+
Type.Literal("medium"),
|
|
1752
|
+
Type.Literal("high"),
|
|
1753
|
+
Type.Literal("xhigh")
|
|
1754
|
+
];
|
|
1755
|
+
Type.Union([...RuntimeProfileThinkingLevelOptions]);
|
|
1756
|
+
var RuntimeProfileNullableThinkingLevel = Type.Union([...RuntimeProfileThinkingLevelOptions, Type.Null()]);
|
|
1757
|
+
var RuntimeProfileNullableTemperature = Type.Union([Type.Null(), Type.Number({
|
|
1758
|
+
minimum: 0,
|
|
1759
|
+
maximum: 2
|
|
1760
|
+
})]);
|
|
1761
|
+
var RuntimeProfileNullableTopP = Type.Union([Type.Null(), Type.Number({
|
|
1762
|
+
minimum: 0,
|
|
1763
|
+
maximum: 1
|
|
1764
|
+
})]);
|
|
1765
|
+
var RuntimeProfileNullableTopK = Type.Union([Type.Integer({
|
|
1766
|
+
minimum: 1,
|
|
1767
|
+
maximum: 1e4
|
|
1768
|
+
}), Type.Null()]);
|
|
1769
|
+
var RuntimeProfileNullableMaxOutputTokens = Type.Union([Type.Integer({
|
|
1770
|
+
minimum: 1,
|
|
1771
|
+
maximum: 1e6
|
|
1772
|
+
}), Type.Null()]);
|
|
1773
|
+
var RuntimeProfileAllowedHost = Type.String({
|
|
1774
|
+
minLength: 1,
|
|
1775
|
+
maxLength: 255,
|
|
1776
|
+
pattern: "^(?:\\*\\.)?(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)(?:\\.(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?))*$"
|
|
1768
1777
|
});
|
|
1769
|
-
var
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1778
|
+
var RuntimeProfileSandbox = Type.Object({
|
|
1779
|
+
network: Type.Optional(Type.Object({
|
|
1780
|
+
allowedHosts: Type.Optional(Type.Array(RuntimeProfileAllowedHost, { maxItems: 50 })),
|
|
1781
|
+
allowedInternalHosts: Type.Optional(Type.Array(RuntimeProfileAllowedHost, { maxItems: 50 }))
|
|
1782
|
+
}, { additionalProperties: false })),
|
|
1783
|
+
vfs: Type.Optional(Type.Object({
|
|
1784
|
+
shadow: Type.Optional(Type.Array(Type.String({
|
|
1785
|
+
minLength: 1,
|
|
1786
|
+
maxLength: 255
|
|
1787
|
+
}), { maxItems: 100 })),
|
|
1788
|
+
shadowMode: Type.Optional(Type.Union([Type.Literal("deny"), Type.Literal("tmpfs")]))
|
|
1789
|
+
}, { additionalProperties: false })),
|
|
1790
|
+
env: Type.Optional(Type.Record(RuntimeProfileEnvName, Type.String({ maxLength: 4096 }))),
|
|
1791
|
+
hostExec: Type.Optional(Type.Object({ autoApprove: Type.Optional(Type.Literal(false)) }, { additionalProperties: false })),
|
|
1792
|
+
resources: Type.Optional(Type.Object({
|
|
1793
|
+
memory: Type.Optional(Type.String({
|
|
1794
|
+
minLength: 2,
|
|
1795
|
+
maxLength: 16,
|
|
1796
|
+
pattern: "^[0-9]+[KMG]?$"
|
|
1797
|
+
})),
|
|
1798
|
+
cpus: Type.Optional(Type.Integer({
|
|
1799
|
+
minimum: 1,
|
|
1800
|
+
maximum: 32
|
|
1801
|
+
}))
|
|
1802
|
+
}, { additionalProperties: false }))
|
|
1779
1803
|
}, {
|
|
1780
|
-
$id: "
|
|
1804
|
+
$id: "RuntimeProfileSandbox",
|
|
1781
1805
|
additionalProperties: false
|
|
1782
1806
|
});
|
|
1783
|
-
var
|
|
1784
|
-
Type.
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
Type.
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1807
|
+
var RuntimeProfileContext = Type.Object({
|
|
1808
|
+
slug: Type.String({
|
|
1809
|
+
minLength: 1,
|
|
1810
|
+
maxLength: 64,
|
|
1811
|
+
pattern: "^[a-zA-Z0-9_-]+$"
|
|
1812
|
+
}),
|
|
1813
|
+
binding: Type.Union([
|
|
1814
|
+
Type.Literal("skill"),
|
|
1815
|
+
Type.Literal("context_inline"),
|
|
1816
|
+
Type.Literal("prompt_prefix"),
|
|
1817
|
+
Type.Literal("user_inline")
|
|
1818
|
+
]),
|
|
1819
|
+
content: Type.String({
|
|
1820
|
+
minLength: 1,
|
|
1821
|
+
maxLength: 65536
|
|
1822
|
+
})
|
|
1799
1823
|
}, {
|
|
1800
|
-
$id: "
|
|
1824
|
+
$id: "RuntimeProfileContext",
|
|
1801
1825
|
additionalProperties: false
|
|
1802
1826
|
});
|
|
1803
|
-
var
|
|
1804
|
-
|
|
1805
|
-
results: Type.Array(VerificationResult),
|
|
1806
|
-
passed: Type.Boolean({ description: "True iff every verification result has status \"pass\" or \"skip\"; false when any result has status \"fail\"." })
|
|
1807
|
-
}, {
|
|
1808
|
-
$id: "VerificationRecord",
|
|
1827
|
+
var RuntimeProfileRef = Type.Object({ profileId: Type.String({ format: "uuid" }) }, {
|
|
1828
|
+
$id: "RuntimeProfileRef",
|
|
1809
1829
|
additionalProperties: false
|
|
1810
1830
|
});
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1831
|
+
var RuntimeProfileLeaseTtlSec = Type.Integer({
|
|
1832
|
+
minimum: 1,
|
|
1833
|
+
maximum: 86400
|
|
1834
|
+
});
|
|
1835
|
+
var RuntimeProfileHeartbeatIntervalMs = Type.Integer({
|
|
1836
|
+
minimum: 0,
|
|
1837
|
+
maximum: 36e5
|
|
1838
|
+
});
|
|
1839
|
+
var RuntimeProfileMaxBatchSize = Type.Integer({
|
|
1840
|
+
minimum: 1,
|
|
1841
|
+
maximum: 1e3
|
|
1842
|
+
});
|
|
1843
|
+
var RuntimeProfileMaxTurns = Type.Integer({
|
|
1844
|
+
minimum: 0,
|
|
1845
|
+
maximum: 1e4
|
|
1846
|
+
});
|
|
1847
|
+
var RuntimeProfileMaxBashTimeouts = Type.Integer({
|
|
1848
|
+
minimum: 0,
|
|
1849
|
+
maximum: 1e3
|
|
1850
|
+
});
|
|
1851
|
+
Type.Object({
|
|
1814
1852
|
id: Type.String({ format: "uuid" }),
|
|
1815
1853
|
teamId: Type.String({ format: "uuid" }),
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1854
|
+
name: RuntimeProfileName,
|
|
1855
|
+
description: Type.Union([Type.String({ maxLength: 4096 }), Type.Null()]),
|
|
1856
|
+
provider: Type.String({
|
|
1819
1857
|
minLength: 1,
|
|
1820
1858
|
maxLength: 100
|
|
1821
1859
|
}),
|
|
1822
|
-
|
|
1823
|
-
minLength: 1,
|
|
1824
|
-
maxLength: 255
|
|
1825
|
-
}),
|
|
1826
|
-
contentType: Type.String({
|
|
1860
|
+
model: Type.String({
|
|
1827
1861
|
minLength: 1,
|
|
1828
1862
|
maxLength: 200
|
|
1829
1863
|
}),
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1864
|
+
thinkingLevel: RuntimeProfileNullableThinkingLevel,
|
|
1865
|
+
temperature: RuntimeProfileNullableTemperature,
|
|
1866
|
+
topP: RuntimeProfileNullableTopP,
|
|
1867
|
+
topK: RuntimeProfileNullableTopK,
|
|
1868
|
+
maxOutputTokens: RuntimeProfileNullableMaxOutputTokens,
|
|
1869
|
+
runtimeKind: RuntimeProfileRuntimeKind,
|
|
1870
|
+
sandbox: RuntimeProfileSandbox,
|
|
1871
|
+
sessionStorageMode: Type.Literal("local"),
|
|
1872
|
+
workspaceStorageMode: Type.Literal("local"),
|
|
1873
|
+
defaultWorkspaceMode: Type.Union([RuntimeProfileWorkspaceMode, Type.Null()]),
|
|
1874
|
+
allowedWorkspaceModes: RuntimeProfileAllowedWorkspaceModes,
|
|
1875
|
+
sessionTtlSec: Type.Integer({
|
|
1876
|
+
minimum: 1,
|
|
1877
|
+
maximum: 86400
|
|
1878
|
+
}),
|
|
1879
|
+
workspaceTtlSec: Type.Integer({
|
|
1880
|
+
minimum: 1,
|
|
1881
|
+
maximum: 86400
|
|
1882
|
+
}),
|
|
1883
|
+
leaseTtlSec: RuntimeProfileLeaseTtlSec,
|
|
1884
|
+
heartbeatIntervalMs: RuntimeProfileHeartbeatIntervalMs,
|
|
1885
|
+
maxBatchSize: RuntimeProfileMaxBatchSize,
|
|
1886
|
+
maxTurns: RuntimeProfileMaxTurns,
|
|
1887
|
+
maxBashTimeouts: RuntimeProfileMaxBashTimeouts,
|
|
1888
|
+
toolEnforcement: RuntimeProfileToolEnforcement,
|
|
1889
|
+
requiredEnv: Type.Array(RuntimeProfileEnvName, { maxItems: 100 }),
|
|
1890
|
+
requiredTools: Type.Array(RuntimeProfileToolName, { maxItems: 100 }),
|
|
1891
|
+
requiredExecutables: Type.Array(RuntimeProfileToolName, { maxItems: 100 }),
|
|
1892
|
+
context: Type.Array(RuntimeProfileContext, { maxItems: 5 }),
|
|
1893
|
+
revision: Type.Integer({ minimum: 1 }),
|
|
1894
|
+
definitionCid: Type.String({
|
|
1836
1895
|
minLength: 1,
|
|
1837
1896
|
maxLength: 100
|
|
1838
1897
|
}),
|
|
1839
1898
|
createdByAgentId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
1840
|
-
|
|
1841
|
-
createdAt: Type.String({ format: "date-time" })
|
|
1842
|
-
|
|
1843
|
-
Type.Object({
|
|
1844
|
-
artifacts: Type.Array(TaskArtifact),
|
|
1845
|
-
nextCursor: Type.Union([Type.String({ minLength: 1 }), Type.Null()])
|
|
1846
|
-
}, { $id: "TaskArtifactList" });
|
|
1847
|
-
Type.Object({
|
|
1848
|
-
limit: Type.Optional(Type.Integer({
|
|
1849
|
-
minimum: 1,
|
|
1850
|
-
maximum: 100
|
|
1851
|
-
})),
|
|
1852
|
-
cursor: Type.Optional(Type.String({ minLength: 1 }))
|
|
1899
|
+
createdByHumanId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
1900
|
+
createdAt: Type.String({ format: "date-time" }),
|
|
1901
|
+
updatedAt: Type.String({ format: "date-time" })
|
|
1853
1902
|
}, {
|
|
1854
|
-
$id: "
|
|
1903
|
+
$id: "RuntimeProfile",
|
|
1855
1904
|
additionalProperties: false
|
|
1856
1905
|
});
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
pattern: "^[\\x21-\\x7e][\\x20-\\x7e]*$"
|
|
1866
|
-
});
|
|
1906
|
+
//#endregion
|
|
1907
|
+
//#region ../../libs/runtime-profiles/src/runtime-sessions.ts
|
|
1908
|
+
var RuntimeSessionKind = Type.Union([
|
|
1909
|
+
Type.Literal("root"),
|
|
1910
|
+
Type.Literal("extend"),
|
|
1911
|
+
Type.Literal("fork")
|
|
1912
|
+
]);
|
|
1913
|
+
var RuntimeSessionCheckpointKind = Type.Union([Type.Literal("attempt_final")]);
|
|
1867
1914
|
Type.Object({
|
|
1868
|
-
|
|
1915
|
+
id: Type.String({ format: "uuid" }),
|
|
1916
|
+
teamId: Type.String({ format: "uuid" }),
|
|
1917
|
+
taskId: Type.String({ format: "uuid" }),
|
|
1918
|
+
attemptN: Type.Integer({ minimum: 1 }),
|
|
1919
|
+
sourceSlotId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
1920
|
+
sourceRuntimeProfileId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
1921
|
+
sessionKind: RuntimeSessionKind,
|
|
1922
|
+
parentSessionId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
1923
|
+
contentType: Type.String({
|
|
1924
|
+
minLength: 1,
|
|
1925
|
+
maxLength: 200
|
|
1926
|
+
}),
|
|
1927
|
+
contentEncoding: Type.Union([Type.String({
|
|
1869
1928
|
minLength: 1,
|
|
1870
1929
|
maxLength: 100
|
|
1930
|
+
}), Type.Null()]),
|
|
1931
|
+
sizeBytes: Type.Integer({ minimum: 0 }),
|
|
1932
|
+
sha256: Type.String({
|
|
1933
|
+
minLength: 64,
|
|
1934
|
+
maxLength: 64
|
|
1871
1935
|
}),
|
|
1872
|
-
|
|
1936
|
+
storageClass: Type.String({
|
|
1873
1937
|
minLength: 1,
|
|
1874
|
-
maxLength:
|
|
1938
|
+
maxLength: 100
|
|
1875
1939
|
}),
|
|
1876
|
-
|
|
1877
|
-
|
|
1940
|
+
checkpointKind: RuntimeSessionCheckpointKind,
|
|
1941
|
+
uploadedAt: Type.String({ format: "date-time" })
|
|
1942
|
+
}, { $id: "RuntimeSession" });
|
|
1943
|
+
Type.Object({
|
|
1944
|
+
sourceSlotId: Type.Optional(Type.String({ format: "uuid" })),
|
|
1945
|
+
sourceRuntimeProfileId: Type.Optional(Type.String({ format: "uuid" })),
|
|
1946
|
+
sessionKind: RuntimeSessionKind,
|
|
1947
|
+
parentSessionId: Type.Optional(Type.String({ format: "uuid" }))
|
|
1878
1948
|
}, {
|
|
1879
|
-
$id: "
|
|
1949
|
+
$id: "UploadRuntimeSessionQuery",
|
|
1880
1950
|
additionalProperties: false
|
|
1881
1951
|
});
|
|
1882
1952
|
Type.String({
|
|
1883
|
-
$id: "
|
|
1884
|
-
description: "
|
|
1953
|
+
$id: "RuntimeSessionContent",
|
|
1954
|
+
description: "Runtime session content stream.",
|
|
1885
1955
|
format: "binary"
|
|
1886
1956
|
});
|
|
1887
|
-
Type.Object({ taskId: Type.String({ format: "uuid" }) }, {
|
|
1888
|
-
$id: "TaskArtifactTaskParams",
|
|
1889
|
-
additionalProperties: false
|
|
1890
|
-
});
|
|
1891
1957
|
Type.Object({
|
|
1892
1958
|
taskId: Type.String({ format: "uuid" }),
|
|
1893
1959
|
attemptN: Type.Integer({ minimum: 1 })
|
|
1894
1960
|
}, {
|
|
1895
|
-
$id: "
|
|
1961
|
+
$id: "RuntimeSessionAttemptParams",
|
|
1896
1962
|
additionalProperties: false
|
|
1897
1963
|
});
|
|
1964
|
+
//#endregion
|
|
1965
|
+
//#region ../../libs/runtime-profiles/src/runtime-slots.ts
|
|
1966
|
+
var RuntimeWorkspaceKind = Type.Union([
|
|
1967
|
+
Type.Literal("origin"),
|
|
1968
|
+
Type.Literal("fork"),
|
|
1969
|
+
Type.Literal("scratch")
|
|
1970
|
+
]);
|
|
1971
|
+
var RuntimeSlotState = Type.Union([Type.Literal("active"), Type.Literal("idle")]);
|
|
1972
|
+
var RuntimeWorkspace = Type.Object({
|
|
1973
|
+
id: Type.String({ format: "uuid" }),
|
|
1974
|
+
teamId: Type.String({ format: "uuid" }),
|
|
1975
|
+
workspaceId: Type.String({ minLength: 1 }),
|
|
1976
|
+
worktreePath: Type.String({ minLength: 1 }),
|
|
1977
|
+
worktreeBranch: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
|
|
1978
|
+
kind: RuntimeWorkspaceKind,
|
|
1979
|
+
createdAtMs: Type.Integer({ minimum: 0 }),
|
|
1980
|
+
lastUsedAtMs: Type.Integer({ minimum: 0 })
|
|
1981
|
+
}, { $id: "RuntimeWorkspace" });
|
|
1982
|
+
var RuntimeSlot = Type.Object({
|
|
1983
|
+
id: Type.String({ format: "uuid" }),
|
|
1984
|
+
teamId: Type.String({ format: "uuid" }),
|
|
1985
|
+
agentName: Type.String({
|
|
1986
|
+
minLength: 1,
|
|
1987
|
+
maxLength: 100
|
|
1988
|
+
}),
|
|
1989
|
+
runtimeProfileId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
1990
|
+
provider: Type.String({
|
|
1991
|
+
minLength: 1,
|
|
1992
|
+
maxLength: 100
|
|
1993
|
+
}),
|
|
1994
|
+
model: Type.String({
|
|
1995
|
+
minLength: 1,
|
|
1996
|
+
maxLength: 200
|
|
1997
|
+
}),
|
|
1998
|
+
slotKey: Type.String({ minLength: 1 }),
|
|
1999
|
+
taskType: Type.String({
|
|
2000
|
+
minLength: 1,
|
|
2001
|
+
maxLength: 100
|
|
2002
|
+
}),
|
|
2003
|
+
state: RuntimeSlotState,
|
|
2004
|
+
lastTaskId: Type.String({ format: "uuid" }),
|
|
2005
|
+
lastAttemptN: Type.Integer({ minimum: 1 }),
|
|
2006
|
+
sessionDir: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
|
|
2007
|
+
sessionPath: Type.Union([Type.String({ minLength: 1 }), Type.Null()]),
|
|
2008
|
+
workspaceRowId: Type.Union([Type.String({ format: "uuid" }), Type.Null()]),
|
|
2009
|
+
createdAtMs: Type.Integer({ minimum: 0 }),
|
|
2010
|
+
lastUsedAtMs: Type.Integer({ minimum: 0 }),
|
|
2011
|
+
expiresAtMs: Type.Integer({ minimum: 0 })
|
|
2012
|
+
}, { $id: "RuntimeSlot" });
|
|
2013
|
+
var ResolvedRuntimeSlot = Type.Object({
|
|
2014
|
+
slot: RuntimeSlot,
|
|
2015
|
+
workspace: Type.Union([RuntimeWorkspace, Type.Null()])
|
|
2016
|
+
}, { $id: "ResolvedRuntimeSlot" });
|
|
2017
|
+
Type.Object({ items: Type.Array(ResolvedRuntimeSlot) }, { $id: "RuntimeSlotListResponse" });
|
|
1898
2018
|
Type.Object({
|
|
1899
|
-
|
|
1900
|
-
attemptN: Type.Integer({ minimum: 1 }),
|
|
1901
|
-
cid: Type.String({
|
|
2019
|
+
agentName: Type.String({
|
|
1902
2020
|
minLength: 1,
|
|
1903
2021
|
maxLength: 100
|
|
1904
|
-
})
|
|
1905
|
-
},
|
|
1906
|
-
|
|
1907
|
-
additionalProperties: false
|
|
1908
|
-
});
|
|
1909
|
-
Type.Object({
|
|
1910
|
-
contentType: Type.Optional(HeaderSafeContentType),
|
|
1911
|
-
contentEncoding: Type.Optional(HeaderSafeContentEncoding)
|
|
1912
|
-
}, {
|
|
1913
|
-
$id: "StageTaskArtifactQuery",
|
|
1914
|
-
additionalProperties: false
|
|
1915
|
-
});
|
|
1916
|
-
Type.Object({
|
|
1917
|
-
cid: Type.String({
|
|
2022
|
+
}),
|
|
2023
|
+
runtimeProfileId: Type.String({ format: "uuid" }),
|
|
2024
|
+
provider: Type.String({
|
|
1918
2025
|
minLength: 1,
|
|
1919
2026
|
maxLength: 100
|
|
1920
2027
|
}),
|
|
1921
|
-
|
|
1922
|
-
contentType: Type.String({
|
|
2028
|
+
model: Type.String({
|
|
1923
2029
|
minLength: 1,
|
|
1924
2030
|
maxLength: 200
|
|
1925
|
-
})
|
|
1926
|
-
|
|
1927
|
-
Type.
|
|
1928
|
-
taskId: Type.String({ format: "uuid" }),
|
|
1929
|
-
cid: Type.String({
|
|
2031
|
+
}),
|
|
2032
|
+
slotKey: Type.String({ minLength: 1 }),
|
|
2033
|
+
taskType: Type.String({
|
|
1930
2034
|
minLength: 1,
|
|
1931
2035
|
maxLength: 100
|
|
1932
|
-
})
|
|
1933
|
-
}, {
|
|
1934
|
-
$id: "TaskArtifactTaskContentParams",
|
|
1935
|
-
additionalProperties: false
|
|
1936
|
-
});
|
|
1937
|
-
//#endregion
|
|
1938
|
-
//#region ../../libs/tasks/src/task-types/assess-brief.ts
|
|
1939
|
-
/**
|
|
1940
|
-
* `assess_brief` — independently evaluate a fulfilled brief.
|
|
1941
|
-
*
|
|
1942
|
-
* output_kind: judgment
|
|
1943
|
-
* criteria: required (`successCriteria.rubric` — same envelope as
|
|
1944
|
-
* `judge_pack`)
|
|
1945
|
-
* references: required (must reference the target `fulfill_brief` task)
|
|
1946
|
-
*
|
|
1947
|
-
* The assessor is a different agent from the producer (enforced by the
|
|
1948
|
-
* server / runtime at claim time — not in the wire schema).
|
|
1949
|
-
*
|
|
1950
|
-
* The rubric in `successCriteria` IS the job spec — the assessor applies
|
|
1951
|
-
* it to the target task's output and emits per-criterion scores. Other
|
|
1952
|
-
* sections (`assertions`, `gates`, `sideEffects`) MAY be present and are
|
|
1953
|
-
* evaluated against the *assessor's output*.
|
|
1954
|
-
*/
|
|
1955
|
-
var ASSESS_BRIEF_TYPE = "assess_brief";
|
|
1956
|
-
var AssessBriefInput = Type.Object({
|
|
1957
|
-
targetTaskId: Type.String({ format: "uuid" }),
|
|
1958
|
-
successCriteria: SuccessCriteria
|
|
1959
|
-
}, {
|
|
1960
|
-
$id: "AssessBriefInput",
|
|
1961
|
-
additionalProperties: false
|
|
1962
|
-
});
|
|
1963
|
-
/** One score line. */
|
|
1964
|
-
var AssessBriefScore = Type.Object({
|
|
1965
|
-
criterionId: Type.String({ minLength: 1 }),
|
|
1966
|
-
score: Type.Number({
|
|
1967
|
-
minimum: 0,
|
|
1968
|
-
maximum: 1
|
|
1969
2036
|
}),
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
2037
|
+
sessionDir: Type.Optional(Type.String({ minLength: 1 })),
|
|
2038
|
+
sessionPath: Type.Optional(Type.String({ minLength: 1 })),
|
|
2039
|
+
workspaceId: Type.Optional(Type.String({ minLength: 1 })),
|
|
2040
|
+
worktreePath: Type.Optional(Type.String({ minLength: 1 })),
|
|
2041
|
+
worktreeBranch: Type.Optional(Type.String({ minLength: 1 })),
|
|
2042
|
+
workspaceKind: Type.Optional(RuntimeWorkspaceKind),
|
|
2043
|
+
lastTaskId: Type.String({ format: "uuid" }),
|
|
2044
|
+
lastAttemptN: Type.Integer({ minimum: 1 })
|
|
1976
2045
|
}, {
|
|
1977
|
-
$id: "
|
|
2046
|
+
$id: "BeginRuntimeSlotBody",
|
|
1978
2047
|
additionalProperties: false
|
|
1979
2048
|
});
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
maximum: 1
|
|
2049
|
+
Type.Object({
|
|
2050
|
+
agentName: Type.String({
|
|
2051
|
+
minLength: 1,
|
|
2052
|
+
maxLength: 100
|
|
1985
2053
|
}),
|
|
1986
|
-
|
|
1987
|
-
|
|
2054
|
+
runtimeProfileId: Type.String({ format: "uuid" }),
|
|
2055
|
+
provider: Type.String({
|
|
2056
|
+
minLength: 1,
|
|
2057
|
+
maxLength: 100
|
|
2058
|
+
}),
|
|
2059
|
+
model: Type.String({
|
|
2060
|
+
minLength: 1,
|
|
2061
|
+
maxLength: 200
|
|
2062
|
+
}),
|
|
2063
|
+
slotKey: Type.String({ minLength: 1 }),
|
|
2064
|
+
taskId: Type.String({ format: "uuid" }),
|
|
2065
|
+
attemptN: Type.Integer({ minimum: 1 }),
|
|
2066
|
+
sessionPath: Type.Optional(Type.String({ minLength: 1 }))
|
|
1988
2067
|
}, {
|
|
1989
|
-
$id: "
|
|
2068
|
+
$id: "FinishRuntimeSlotBody",
|
|
1990
2069
|
additionalProperties: false
|
|
1991
2070
|
});
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
* - The target is a `fulfill_brief` (you cannot grade an arbitrary
|
|
1996
|
-
* task type as if it were a brief fulfillment).
|
|
1997
|
-
* - Unless readiness checks are explicitly deferred, the target is
|
|
1998
|
-
* `completed` with an accepted attempt — grading an in-flight or
|
|
1999
|
-
* failed task would either race or grade nothing.
|
|
2000
|
-
*
|
|
2001
|
-
* Agent-distinctness ("assessor ≠ producer") is a runtime / auth-
|
|
2002
|
-
* layer concern and intentionally NOT checked here. It belongs in
|
|
2003
|
-
* an auth-aware claim-time check.
|
|
2004
|
-
*/
|
|
2005
|
-
async function validateAssessBriefInputAsync(input, ctx) {
|
|
2006
|
-
const { targetTaskId } = input;
|
|
2007
|
-
const errors = [];
|
|
2008
|
-
const target = await ctx.resolveTask(targetTaskId);
|
|
2009
|
-
if (!target) {
|
|
2010
|
-
errors.push({
|
|
2011
|
-
field: "targetTaskId",
|
|
2012
|
-
message: `targetTaskId ${targetTaskId} does not resolve to a task you can read`
|
|
2013
|
-
});
|
|
2014
|
-
return errors;
|
|
2015
|
-
}
|
|
2016
|
-
if (target.taskType !== "fulfill_brief") errors.push({
|
|
2017
|
-
field: "targetTaskId",
|
|
2018
|
-
message: `targetTaskId ${targetTaskId} is a ${target.taskType}, not a fulfill_brief`
|
|
2019
|
-
});
|
|
2020
|
-
if (!ctx.deferReadinessChecks && (target.status !== "completed" || target.acceptedAttemptN === null)) errors.push({
|
|
2021
|
-
field: "targetTaskId",
|
|
2022
|
-
message: `targetTaskId ${targetTaskId} is not completed with an accepted attempt (status=${target.status}, acceptedAttemptN=${target.acceptedAttemptN})`
|
|
2023
|
-
});
|
|
2024
|
-
return errors;
|
|
2025
|
-
}
|
|
2026
|
-
//#endregion
|
|
2027
|
-
//#region ../../libs/tasks/src/task-types/curate-pack.ts
|
|
2028
|
-
/**
|
|
2029
|
-
* `curate_pack` — select and rank diary entries into a context pack.
|
|
2030
|
-
*
|
|
2031
|
-
* output_kind: artifact
|
|
2032
|
-
* criteria: not required (rubric-less curation recipe)
|
|
2033
|
-
* references: optional (e.g. a prior rendered pack being re-curated)
|
|
2034
|
-
*
|
|
2035
|
-
* This is step 1 of the three-session attribution loop (#875). The agent
|
|
2036
|
-
* runs a structured exploration over a diary — tag inventory, hybrid
|
|
2037
|
-
* search, type/tag narrowing — and emits a ranked entry list via
|
|
2038
|
-
* `moltnet_pack_create`. The prompt is deterministic given the input
|
|
2039
|
-
* (no operator interaction), so two runs with the same input should
|
|
2040
|
-
* converge on similar packs.
|
|
2041
|
-
*
|
|
2042
|
-
* Related: `render_pack`, `judge_pack`.
|
|
2043
|
-
*/
|
|
2044
|
-
var CURATE_PACK_TYPE = "curate_pack";
|
|
2045
|
-
var EntryTypeFilter = Type.Union([
|
|
2046
|
-
Type.Literal("episodic"),
|
|
2047
|
-
Type.Literal("semantic"),
|
|
2048
|
-
Type.Literal("procedural"),
|
|
2049
|
-
Type.Literal("reflection")
|
|
2050
|
-
]);
|
|
2051
|
-
var CuratePackInput = Type.Object({
|
|
2052
|
-
diaryId: Type.String({ format: "uuid" }),
|
|
2053
|
-
taskPrompt: Type.String({ minLength: 1 }),
|
|
2054
|
-
entryTypes: Type.Optional(Type.Array(EntryTypeFilter, { minItems: 1 })),
|
|
2055
|
-
tagFilters: Type.Optional(Type.Object({
|
|
2056
|
-
include: Type.Optional(Type.Array(Type.String())),
|
|
2057
|
-
exclude: Type.Optional(Type.Array(Type.String())),
|
|
2058
|
-
prefix: Type.Optional(Type.String())
|
|
2059
|
-
}, { additionalProperties: false })),
|
|
2060
|
-
tokenBudget: Type.Optional(Type.Number({ minimum: 500 })),
|
|
2061
|
-
recipe: Type.Optional(Type.Union([Type.Literal("topic-focused-v1"), Type.Literal("scope-inventory-v1")])),
|
|
2062
|
-
successCriteria: Type.Optional(SuccessCriteria)
|
|
2071
|
+
Type.Object({
|
|
2072
|
+
taskId: Type.String({ format: "uuid" }),
|
|
2073
|
+
attemptN: Type.Integer({ minimum: 1 })
|
|
2063
2074
|
}, {
|
|
2064
|
-
$id: "
|
|
2075
|
+
$id: "FindLatestRuntimeSlotForAttemptQuery",
|
|
2065
2076
|
additionalProperties: false
|
|
2066
2077
|
});
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
rationale: Type.String({ minLength: 1 })
|
|
2079
|
-
}, { additionalProperties: false }), { minItems: 1 }),
|
|
2080
|
-
recipeParams: Type.Record(Type.String(), Type.Unknown()),
|
|
2081
|
-
checkpoints: Type.Optional(Type.Array(Type.Object({
|
|
2082
|
-
phase: Type.String({ minLength: 1 }),
|
|
2083
|
-
candidateIds: Type.Array(Type.String({ format: "uuid" })),
|
|
2084
|
-
droppedIds: Type.Optional(Type.Array(Type.String({ format: "uuid" }))),
|
|
2085
|
-
notes: Type.String({ minLength: 1 })
|
|
2086
|
-
}, { additionalProperties: false }))),
|
|
2087
|
-
summary: Type.String({ minLength: 1 }),
|
|
2088
|
-
verification: Type.Optional(VerificationRecord)
|
|
2078
|
+
Type.Object({
|
|
2079
|
+
agentName: Type.Optional(Type.String({
|
|
2080
|
+
minLength: 1,
|
|
2081
|
+
maxLength: 100
|
|
2082
|
+
})),
|
|
2083
|
+
runtimeProfileId: Type.Optional(Type.String({ format: "uuid" })),
|
|
2084
|
+
state: Type.Optional(RuntimeSlotState),
|
|
2085
|
+
limit: Type.Optional(Type.Integer({
|
|
2086
|
+
minimum: 1,
|
|
2087
|
+
maximum: 200
|
|
2088
|
+
}))
|
|
2089
2089
|
}, {
|
|
2090
|
-
$id: "
|
|
2090
|
+
$id: "ListRuntimeSlotsQuery",
|
|
2091
2091
|
additionalProperties: false
|
|
2092
2092
|
});
|
|
2093
2093
|
//#endregion
|
|
@@ -3362,9 +3362,9 @@ var COMMON_OPTIONAL_FLAGS = `\
|
|
|
3362
3362
|
--guest-credential-mode <mode>
|
|
3363
3363
|
Guest trust boundary: host-authenticated or
|
|
3364
3364
|
guest-config. Defaults to host-authenticated for
|
|
3365
|
-
agent-key and
|
|
3366
|
-
guest-config exposes the complete local
|
|
3367
|
-
credential tree to the VM.
|
|
3365
|
+
both agent-key and OAuth2 authentication.
|
|
3366
|
+
Explicit guest-config exposes the complete local
|
|
3367
|
+
agent credential tree to the VM.
|
|
3368
3368
|
--lease-ttl-sec <n> Sliding liveness window. Silence longer than
|
|
3369
3369
|
this ends the attempt with lease_expired.
|
|
3370
3370
|
Default: 300.
|
|
@@ -3540,16 +3540,18 @@ function isHelpFlag(args) {
|
|
|
3540
3540
|
//#region src/lib/agent-context.ts
|
|
3541
3541
|
/**
|
|
3542
3542
|
* Guest credentials are an explicit trust decision, never an incidental
|
|
3543
|
-
* consequence of files found on disk.
|
|
3544
|
-
*
|
|
3545
|
-
*
|
|
3546
|
-
*
|
|
3543
|
+
* consequence of files found on disk. The guest boundary is independent of
|
|
3544
|
+
* how the daemon itself authenticates: both agent-key and OAuth2 default to
|
|
3545
|
+
* the host-authenticated boundary, where structured MoltNet operations reuse
|
|
3546
|
+
* the trusted host-side Agent and the guest receives no credential material.
|
|
3547
|
+
* OAuth2 still resolves that Agent from the local config and secret provider
|
|
3548
|
+
* on the host — reading `moltnet.json` on the host does not imply projecting
|
|
3549
|
+
* it into the guest. `guest-config` remains an explicit compatibility opt-in
|
|
3550
|
+
* for tasks that need credential-bearing guest-shell operations.
|
|
3547
3551
|
*/
|
|
3548
|
-
function resolveDaemonGuestCredentialMode(
|
|
3552
|
+
function resolveDaemonGuestCredentialMode(requested) {
|
|
3549
3553
|
if (requested !== void 0 && requested !== "guest-config" && requested !== "host-authenticated") throw new Error(`Invalid --guest-credential-mode "${requested}": expected guest-config or host-authenticated.`);
|
|
3550
|
-
|
|
3551
|
-
if (authMode === "oauth2" && mode === "host-authenticated") throw new Error("--guest-credential-mode host-authenticated requires agent-key authentication. OAuth2 requires the local agent configuration.");
|
|
3552
|
-
return mode;
|
|
3554
|
+
return requested ?? "host-authenticated";
|
|
3553
3555
|
}
|
|
3554
3556
|
/**
|
|
3555
3557
|
* Report which auth mode `connect()` will use, without ever reading the secret
|
|
@@ -3570,18 +3572,18 @@ function detectAuthMode(env) {
|
|
|
3570
3572
|
*
|
|
3571
3573
|
* Rules (see design entry edb848a1):
|
|
3572
3574
|
* - The subject must be an `agent`; a human credential can never run the daemon.
|
|
3573
|
-
* - A team-bound agent key (`credentialBinding.
|
|
3575
|
+
* - A team-bound agent key (`credentialBinding.bindingScope === 'team'`) must match the
|
|
3574
3576
|
* `--team` the daemon was started with. A key is an immutable team ceiling, so
|
|
3575
3577
|
* a mismatch would only surface as an obscure mid-poll 403 otherwise.
|
|
3576
|
-
* - An
|
|
3577
|
-
*
|
|
3578
|
+
* - An identity-scoped key or an OAuth2 identity is accepted; normal team-scoped
|
|
3579
|
+
* authorization governs those requests.
|
|
3578
3580
|
*/
|
|
3579
3581
|
function assessStartupBinding(whoami, teamId) {
|
|
3580
3582
|
if (whoami.subjectType !== "agent") return {
|
|
3581
3583
|
ok: false,
|
|
3582
3584
|
reason: `the daemon must authenticate as an agent, but whoami reported subjectType "${whoami.subjectType}". Provide agent credentials (an agent key or the agent's client id/secret).`
|
|
3583
3585
|
};
|
|
3584
|
-
const boundTeamId = whoami.credentialBinding?.boundTeamId;
|
|
3586
|
+
const boundTeamId = whoami.credentialBinding?.bindingScope === "team" ? whoami.credentialBinding.boundTeamId : void 0;
|
|
3585
3587
|
if (teamId && boundTeamId && boundTeamId !== teamId) return {
|
|
3586
3588
|
ok: false,
|
|
3587
3589
|
reason: `the agent key is bound to team ${boundTeamId}, but the daemon was started with --team ${teamId}. Restart with --team ${boundTeamId}, or issue a key for team ${teamId}.`
|
|
@@ -3623,8 +3625,8 @@ async function validateStartupBinding(options) {
|
|
|
3623
3625
|
async function resolveAgentContext(agentName, options = {}) {
|
|
3624
3626
|
if (!/^[a-zA-Z0-9_-]+$/.test(agentName)) throw new Error(`Invalid agent name "${agentName}": must match /^[a-zA-Z0-9_-]+$/`);
|
|
3625
3627
|
const roots = resolveCredentialRoots(options.agentRootDir);
|
|
3628
|
+
const guestCredentialMode = resolveDaemonGuestCredentialMode(options.guestCredentialMode);
|
|
3626
3629
|
if (options.authMode === "agent-key") {
|
|
3627
|
-
const guestCredentialMode = resolveDaemonGuestCredentialMode("agent-key", options.guestCredentialMode);
|
|
3628
3630
|
const { rootDir, agentDir } = guestCredentialMode === "guest-config" ? resolveCompleteGuestCredentials(roots, agentName) : {
|
|
3629
3631
|
rootDir: roots[0] ?? process.cwd(),
|
|
3630
3632
|
agentDir: join(roots[0] ?? process.cwd(), ".moltnet", agentName)
|
|
@@ -3636,17 +3638,17 @@ async function resolveAgentContext(agentName, options = {}) {
|
|
|
3636
3638
|
guestCredentialMode
|
|
3637
3639
|
};
|
|
3638
3640
|
}
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
const
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
guestCredentialMode
|
|
3641
|
+
const located = guestCredentialMode === "guest-config" ? resolveCompleteGuestCredentials(roots, agentName) : locateAgentConfig(roots, agentName);
|
|
3642
|
+
if (located) {
|
|
3643
|
+
const agent = await connect({
|
|
3644
|
+
configDir: located.agentDir,
|
|
3645
|
+
secretProviders: createNodeSecretProviderRegistry()
|
|
3646
|
+
});
|
|
3647
|
+
return {
|
|
3648
|
+
agentDir: located.agentDir,
|
|
3649
|
+
agentRootDir: located.rootDir,
|
|
3650
|
+
agent,
|
|
3651
|
+
guestCredentialMode
|
|
3650
3652
|
};
|
|
3651
3653
|
}
|
|
3652
3654
|
const tried = roots.map((root) => join(root, ".moltnet", agentName));
|
|
@@ -3658,6 +3660,15 @@ function isTransientWhoamiError(error) {
|
|
|
3658
3660
|
const statusCode = error.statusCode;
|
|
3659
3661
|
return typeof statusCode === "number" && (statusCode === 408 || statusCode === 429 || statusCode >= 500);
|
|
3660
3662
|
}
|
|
3663
|
+
function locateAgentConfig(roots, agentName) {
|
|
3664
|
+
for (const rootDir of roots) {
|
|
3665
|
+
const agentDir = join(rootDir, ".moltnet", agentName);
|
|
3666
|
+
if (existsSync(join(agentDir, "moltnet.json"))) return {
|
|
3667
|
+
rootDir,
|
|
3668
|
+
agentDir
|
|
3669
|
+
};
|
|
3670
|
+
}
|
|
3671
|
+
}
|
|
3661
3672
|
function resolveCompleteGuestCredentials(roots, agentName) {
|
|
3662
3673
|
const partial = [];
|
|
3663
3674
|
for (const rootDir of roots) {
|
|
@@ -5034,102 +5045,6 @@ function runWithDaemonRuntimeContext(context, callback) {
|
|
|
5034
5045
|
return storage.run(context, callback);
|
|
5035
5046
|
}
|
|
5036
5047
|
//#endregion
|
|
5037
|
-
//#region src/lib/runtime-profile.ts
|
|
5038
|
-
var RuntimeProfilePrerequisiteError = class extends Error {
|
|
5039
|
-
constructor(profileName, missingEnv, missingTools, missingExecutables) {
|
|
5040
|
-
const parts = [
|
|
5041
|
-
missingEnv.length > 0 ? `missing env: ${missingEnv.join(", ")}` : null,
|
|
5042
|
-
missingTools.length > 0 ? `missing tools: ${missingTools.join(", ")}` : null,
|
|
5043
|
-
missingExecutables.length > 0 ? `missing guest executables: ${missingExecutables.join(", ")}` : null
|
|
5044
|
-
].filter(Boolean);
|
|
5045
|
-
super(`Runtime profile "${profileName}" prerequisites are not satisfied: ${parts.join("; ")}`);
|
|
5046
|
-
this.profileName = profileName;
|
|
5047
|
-
this.missingEnv = missingEnv;
|
|
5048
|
-
this.missingTools = missingTools;
|
|
5049
|
-
this.missingExecutables = missingExecutables;
|
|
5050
|
-
this.name = "RuntimeProfilePrerequisiteError";
|
|
5051
|
-
}
|
|
5052
|
-
};
|
|
5053
|
-
var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
5054
|
-
async function resolveRuntimeProfile(options) {
|
|
5055
|
-
const profile = UUID_RE.test(options.profile) ? await options.agent.runtimeProfiles.get(options.profile) : await resolveProfileByName(options);
|
|
5056
|
-
if (options.teamId && profile.teamId !== options.teamId) throw new Error(`Runtime profile "${options.profile}" belongs to team ${profile.teamId}, not ${options.teamId}.`);
|
|
5057
|
-
if (!Value.Check(RuntimeProfileSandbox, profile.sandbox)) throw new Error(`Runtime profile "${profile.name}" contains unsupported sandbox fields.`);
|
|
5058
|
-
return {
|
|
5059
|
-
id: profile.id,
|
|
5060
|
-
name: profile.name,
|
|
5061
|
-
teamId: profile.teamId,
|
|
5062
|
-
runtimeKind: profile.runtimeKind,
|
|
5063
|
-
definitionCid: profile.definitionCid,
|
|
5064
|
-
provider: profile.provider,
|
|
5065
|
-
model: profile.model,
|
|
5066
|
-
thinkingLevel: profile.thinkingLevel ?? null,
|
|
5067
|
-
temperature: profile.temperature ?? null,
|
|
5068
|
-
topP: profile.topP ?? null,
|
|
5069
|
-
topK: profile.topK ?? null,
|
|
5070
|
-
maxOutputTokens: profile.maxOutputTokens ?? null,
|
|
5071
|
-
leaseTtlSec: profile.leaseTtlSec,
|
|
5072
|
-
heartbeatIntervalMs: profile.heartbeatIntervalMs,
|
|
5073
|
-
maxBatchSize: profile.maxBatchSize,
|
|
5074
|
-
maxTurns: profile.maxTurns,
|
|
5075
|
-
maxBashTimeouts: profile.maxBashTimeouts,
|
|
5076
|
-
sessionTtlSec: profile.sessionTtlSec,
|
|
5077
|
-
workspaceTtlSec: profile.workspaceTtlSec,
|
|
5078
|
-
defaultWorkspaceMode: profile.defaultWorkspaceMode ?? null,
|
|
5079
|
-
allowedWorkspaceModes: profile.allowedWorkspaceModes,
|
|
5080
|
-
requiredEnv: profile.requiredEnv,
|
|
5081
|
-
requiredTools: profile.requiredTools,
|
|
5082
|
-
requiredExecutables: profile.requiredExecutables,
|
|
5083
|
-
toolEnforcement: profile.toolEnforcement,
|
|
5084
|
-
context: profile.context ?? [],
|
|
5085
|
-
sandboxConfig: profile.sandbox,
|
|
5086
|
-
mountPath: resolve(options.cwd),
|
|
5087
|
-
source: `runtime-profile:${profile.id}`
|
|
5088
|
-
};
|
|
5089
|
-
}
|
|
5090
|
-
async function resolveRuntimeProfiles(options) {
|
|
5091
|
-
const seen = /* @__PURE__ */ new Set();
|
|
5092
|
-
const out = [];
|
|
5093
|
-
for (const profile of options.profiles) {
|
|
5094
|
-
const resolved = await resolveRuntimeProfile({
|
|
5095
|
-
agent: options.agent,
|
|
5096
|
-
profile,
|
|
5097
|
-
teamId: options.teamId,
|
|
5098
|
-
cwd: options.cwd
|
|
5099
|
-
});
|
|
5100
|
-
if (seen.has(resolved.id)) continue;
|
|
5101
|
-
seen.add(resolved.id);
|
|
5102
|
-
out.push(resolved);
|
|
5103
|
-
}
|
|
5104
|
-
return out;
|
|
5105
|
-
}
|
|
5106
|
-
function validateRuntimeProfilePrerequisites(profile, env, inventory) {
|
|
5107
|
-
const missingEnv = profile.requiredEnv.filter((name) => !env[name]);
|
|
5108
|
-
const available = new Set(inventory?.tools ?? []);
|
|
5109
|
-
const executableInventory = new Set(inventory?.executables ?? []);
|
|
5110
|
-
const missingTools = profile.requiredTools.filter((tool) => !available.has(tool));
|
|
5111
|
-
const missingExecutables = profile.requiredExecutables.filter((executable) => !executableInventory.has(executable));
|
|
5112
|
-
if (missingEnv.length > 0 || missingTools.length > 0 || missingExecutables.length > 0) throw new RuntimeProfilePrerequisiteError(profile.name, missingEnv, missingTools, missingExecutables);
|
|
5113
|
-
}
|
|
5114
|
-
function resolveProfileWarmSessionTtlSec(profile) {
|
|
5115
|
-
return Math.min(profile.sessionTtlSec, profile.workspaceTtlSec);
|
|
5116
|
-
}
|
|
5117
|
-
async function resolveProfileByName(options) {
|
|
5118
|
-
if (!options.teamId) throw new Error(`Runtime profile name "${options.profile}" requires --team. Use a profile UUID when running without a team-scoped list.`);
|
|
5119
|
-
const matches = (await options.agent.runtimeProfiles.list({ teamId: options.teamId })).items.filter((item) => item.name === options.profile);
|
|
5120
|
-
if (matches.length === 0) throw new Error(`Runtime profile "${options.profile}" was not found in team ${options.teamId}.`);
|
|
5121
|
-
if (matches.length > 1) throw new Error(`Runtime profile name "${options.profile}" is ambiguous in team ${options.teamId}. Use the profile UUID instead.`);
|
|
5122
|
-
const profile = matches[0];
|
|
5123
|
-
return {
|
|
5124
|
-
...profile,
|
|
5125
|
-
thinkingLevel: profile.thinkingLevel ?? null,
|
|
5126
|
-
temperature: profile.temperature ?? null,
|
|
5127
|
-
topP: profile.topP ?? null,
|
|
5128
|
-
topK: profile.topK ?? null,
|
|
5129
|
-
maxOutputTokens: profile.maxOutputTokens ?? null
|
|
5130
|
-
};
|
|
5131
|
-
}
|
|
5132
|
-
//#endregion
|
|
5133
5048
|
//#region src/lib/runtime-profile-retry-triage.ts
|
|
5134
5049
|
function createRuntimeProfileRetryTriage(options) {
|
|
5135
5050
|
return createPiRetryTriage({
|
|
@@ -5926,7 +5841,9 @@ async function runPolling(opts) {
|
|
|
5926
5841
|
rootLogger.info({
|
|
5927
5842
|
authMode: cfg.authMode,
|
|
5928
5843
|
subjectType: startupWhoami.subjectType,
|
|
5929
|
-
|
|
5844
|
+
bindingScope: startupWhoami.credentialBinding?.bindingScope ?? null,
|
|
5845
|
+
credentialKeyId: startupWhoami.credentialBinding?.keyId ?? null,
|
|
5846
|
+
boundTeamId: startupWhoami.credentialBinding?.bindingScope === "team" ? startupWhoami.credentialBinding.boundTeamId : null,
|
|
5930
5847
|
guestCredentialMode: ctx.guestCredentialMode,
|
|
5931
5848
|
taskTypes: taskTypes.length > 0 ? taskTypes : ["*"],
|
|
5932
5849
|
correlationId: values["correlation-id"] ?? null,
|
|
@@ -6210,7 +6127,8 @@ async function runPolling(opts) {
|
|
|
6210
6127
|
onVmDiagnostic: (diagnostic) => {
|
|
6211
6128
|
const fields = {
|
|
6212
6129
|
event: diagnostic.event,
|
|
6213
|
-
credentialMode: diagnostic.credentialMode
|
|
6130
|
+
credentialMode: diagnostic.credentialMode,
|
|
6131
|
+
...diagnostic.brokeredSecretCount !== void 0 && { brokeredSecretCount: diagnostic.brokeredSecretCount }
|
|
6214
6132
|
};
|
|
6215
6133
|
if (diagnostic.level === "warning") taskLogger.warn(fields, diagnostic.message);
|
|
6216
6134
|
else taskLogger.info(fields, diagnostic.message);
|
|
@@ -6576,7 +6494,8 @@ async function runOnce(argv, runtimeAdapter = defaultPiDaemonAdapter) {
|
|
|
6576
6494
|
onVmDiagnostic: (diagnostic) => {
|
|
6577
6495
|
const fields = {
|
|
6578
6496
|
event: diagnostic.event,
|
|
6579
|
-
credentialMode: diagnostic.credentialMode
|
|
6497
|
+
credentialMode: diagnostic.credentialMode,
|
|
6498
|
+
...diagnostic.brokeredSecretCount !== void 0 && { brokeredSecretCount: diagnostic.brokeredSecretCount }
|
|
6580
6499
|
};
|
|
6581
6500
|
if (diagnostic.level === "warning") rootLogger.warn(fields, diagnostic.message);
|
|
6582
6501
|
else rootLogger.info(fields, diagnostic.message);
|