@caupulican/pi-adaptative 0.90.4 → 0.90.5
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/CHANGELOG.md +6 -0
- package/dist/core/autonomy/lane-tracker.d.ts +5 -0
- package/dist/core/autonomy/lane-tracker.d.ts.map +1 -1
- package/dist/core/autonomy/lane-tracker.js +8 -0
- package/dist/core/autonomy/lane-tracker.js.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.d.ts +2 -0
- package/dist/core/delegation/worker-authority-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-authority-resolver.js +23 -3
- package/dist/core/delegation/worker-authority-resolver.js.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts +1 -1
- package/dist/core/delegation/worker-delegation-controller.d.ts.map +1 -1
- package/dist/core/delegation/worker-delegation-controller.js +48 -13
- package/dist/core/delegation/worker-delegation-controller.js.map +1 -1
- package/dist/core/delegation/worker-lane-projection.d.ts.map +1 -1
- package/dist/core/delegation/worker-lane-projection.js +6 -0
- package/dist/core/delegation/worker-lane-projection.js.map +1 -1
- package/dist/core/delegation/worker-profile-resolver.d.ts +28 -1
- package/dist/core/delegation/worker-profile-resolver.d.ts.map +1 -1
- package/dist/core/delegation/worker-profile-resolver.js +38 -9
- package/dist/core/delegation/worker-profile-resolver.js.map +1 -1
- package/dist/core/orchestration/worker-model-pins.d.ts +28 -0
- package/dist/core/orchestration/worker-model-pins.d.ts.map +1 -0
- package/dist/core/orchestration/worker-model-pins.js +141 -0
- package/dist/core/orchestration/worker-model-pins.js.map +1 -0
- package/dist/core/runtime-builder.d.ts.map +1 -1
- package/dist/core/runtime-builder.js +1 -0
- package/dist/core/runtime-builder.js.map +1 -1
- package/dist/core/settings-manager.d.ts +4 -1
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +24 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/tools/delegate-status.d.ts +2 -0
- package/dist/core/tools/delegate-status.d.ts.map +1 -1
- package/dist/core/tools/delegate-status.js +7 -0
- package/dist/core/tools/delegate-status.js.map +1 -1
- package/dist/core/tools/delegate.d.ts +6 -0
- package/dist/core/tools/delegate.d.ts.map +1 -1
- package/dist/core/tools/delegate.js +38 -6
- package/dist/core/tools/delegate.js.map +1 -1
- package/docs/settings.md +31 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-lane-projection.d.ts","sourceRoot":"","sources":["../../../src/core/delegation/worker-lane-projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAsB,MAAM,6BAA6B,CAAC;AAClF,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAGnG,eAAO,MAAM,8BAA8B,EAAE,WAAW,CAAC,MAAM,CAA4C,CAAC;AAC5G,eAAO,MAAM,mCAAmC,EAAE,WAAW,CAAC,MAAM,CAGlE,CAAC;AAEH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAE5E;AAaD,wBAAgB,qBAAqB,CACpC,QAAQ,EAAE,qBAAqB,EAC/B,MAAM,EAAE,MAAM,GACZ,mBAAmB,GAAG,SAAS,CAQjC;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"worker-lane-projection.d.ts","sourceRoot":"","sources":["../../../src/core/delegation/worker-lane-projection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAsB,MAAM,6BAA6B,CAAC;AAClF,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAGnG,eAAO,MAAM,8BAA8B,EAAE,WAAW,CAAC,MAAM,CAA4C,CAAC;AAC5G,eAAO,MAAM,mCAAmC,EAAE,WAAW,CAAC,MAAM,CAGlE,CAAC;AAEH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAE5E;AAaD,wBAAgB,qBAAqB,CACpC,QAAQ,EAAE,qBAAqB,EAC/B,MAAM,EAAE,MAAM,GACZ,mBAAmB,GAAG,SAAS,CAQjC;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAiD/G;AAED,oEAAoE;AACpE,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,qBAAqB,GAAG,UAAU,EAAE,CAkB7F;AAED,wBAAgB,4BAA4B,CAC3C,QAAQ,EAAE,qBAAqB,EAC/B,aAAa,EAAE,MAAM,GACnB,mBAAmB,GAAG,SAAS,CAQjC"}
|
|
@@ -66,6 +66,12 @@ export function projectWorkerLaneRecord(snapshot, taskId) {
|
|
|
66
66
|
status,
|
|
67
67
|
label,
|
|
68
68
|
profileId: attempt.dispatch.profileId,
|
|
69
|
+
...(attempt.dispatch.executionContract
|
|
70
|
+
? {
|
|
71
|
+
modelRef: `${attempt.dispatch.executionContract.worker.modelBinding.provider}/${attempt.dispatch.executionContract.worker.modelBinding.modelId}`,
|
|
72
|
+
thinkingLevel: attempt.dispatch.executionContract.worker.modelBinding.thinkingLevel,
|
|
73
|
+
}
|
|
74
|
+
: {}),
|
|
69
75
|
...(reasonCode ? { reasonCode } : {}),
|
|
70
76
|
...(attempt.status !== "queued" ? { startedAt: attempt.createdAt } : {}),
|
|
71
77
|
...(status === "queued" || status === "running"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-lane-projection.js","sourceRoot":"","sources":["../../../src/core/delegation/worker-lane-projection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,MAAM,CAAC,MAAM,8BAA8B,GAAwB,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAC5G,MAAM,CAAC,MAAM,mCAAmC,GAAwB,IAAI,GAAG,CAAC;IAC/E,GAAG,8BAA8B;IACjC,WAAW;CACX,CAAC,CAAC;AAEH,MAAM,UAAU,sBAAsB,CAAC,OAA4B;IAClE,OAAO,OAAO,CAAC,QAAQ,CAAC,aAAa,KAAK,iBAAiB,CAAC;AAC7D,CAAC;AAED,SAAS,cAAc,CAAC,OAA4B;IACnD,IAAI,OAAO,CAAC,MAAM,KAAK,WAAW;QAAE,OAAO,WAAW,CAAC;IACvD,IAAI,OAAO,CAAC,MAAM,KAAK,WAAW;QAAE,OAAO,UAAU,CAAC;IACtD,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC3D,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC3D,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,EAAE,UAAU,IAAI,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC;IAC1E,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,kBAAkB,CAAC;IAC7D,IAAI,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC;QAAE,OAAO,SAAS,CAAC;IACrD,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,qBAAqB,CACpC,QAA+B,EAC/B,MAAc;IAEd,MAAM,IAAI,GA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AAa,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAClF,CAAC,CAAC;SACD,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACV,CAAC","sourcesContent":["import type { LaneRecord, LaneTerminalStatus } from \"../autonomy/lane-tracker.ts\";\nimport type { AttemptRuntimeState, TaskRuntimeProjection } from \"../orchestration/task-runtime.ts\";\nimport { deriveWorkerTaskLabel } from \"./worker-task-label.ts\";\n\nexport const ACTIVE_WORKER_ATTEMPT_STATUSES: ReadonlySet<string> = new Set([\"queued\", \"leased\", \"running\"]);\nexport const NONTERMINAL_WORKER_ATTEMPT_STATUSES: ReadonlySet<string> = new Set([\n\t...ACTIVE_WORKER_ATTEMPT_STATUSES,\n\t\"suspended\",\n]);\n\nexport function isManagedWorkerAttempt(attempt: AttemptRuntimeState): boolean {\n\treturn attempt.dispatch.executionKind === \"managed-process\";\n}\n\nfunction terminalStatus(attempt: AttemptRuntimeState): LaneTerminalStatus {\n\tif (attempt.status === \"completed\") return \"succeeded\";\n\tif (attempt.status === \"cancelled\") return \"canceled\";\n\tif (attempt.result?.status === \"partial\") return \"partial\";\n\tif (attempt.result?.status === \"blocked\") return \"blocked\";\n\tconst reasonCode = attempt.result?.reasonCode ?? attempt.reasonCode ?? \"\";\n\tif (reasonCode.includes(\"budget\")) return \"budget_exhausted\";\n\tif (reasonCode.includes(\"timeout\")) return \"timeout\";\n\treturn \"failed\";\n}\n\nexport function selectedWorkerAttempt(\n\tsnapshot: TaskRuntimeProjection,\n\ttaskId: string,\n): AttemptRuntimeState | undefined {\n\tconst task = snapshot.tasks[taskId];\n\tif (!task) return undefined;\n\tconst attempts = task.attemptIds.map((attemptId) => snapshot.attempts[attemptId]).filter(Boolean);\n\treturn (\n\t\t[...attempts].reverse().find((attempt) => attempt && NONTERMINAL_WORKER_ATTEMPT_STATUSES.has(attempt.status)) ??\n\t\tattempts.at(-1)\n\t);\n}\n\n/**\n * One-way compatibility projection from durable orchestration state. A LaneRecord is never read\n * back to decide lifecycle, retry, verification, or notification transitions.\n */\nexport function projectWorkerLaneRecord(snapshot: TaskRuntimeProjection, taskId: string): LaneRecord | undefined {\n\tconst task = snapshot.tasks[taskId];\n\tconst attempt = selectedWorkerAttempt(snapshot, taskId);\n\tif (!task || !attempt) return undefined;\n\tconst managed = isManagedWorkerAttempt(attempt);\n\tconst objective = snapshot.objectives[task.task.objectiveId];\n\tconst awaitingVerification =\n\t\tattempt.result?.nextAction === \"independent_verification_required\" && task.verification === undefined;\n\tconst status = awaitingVerification\n\t\t? \"running\"\n\t\t: task.verification\n\t\t\t? task.verification.verdict === \"accepted\"\n\t\t\t\t? \"succeeded\"\n\t\t\t\t: \"failed\"\n\t\t\t: attempt.status === \"queued\"\n\t\t\t\t? \"queued\"\n\t\t\t\t: attempt.status === \"leased\" || attempt.status === \"running\" || attempt.status === \"suspended\"\n\t\t\t\t\t? \"running\"\n\t\t\t\t\t: terminalStatus(attempt);\n\tconst reasonCode = task.verification?.reasonCode ?? attempt.result?.reasonCode ?? attempt.reasonCode;\n\tconst genericTitle = `Delegated ${task.task.role} work`;\n\tconst label = deriveWorkerTaskLabel(\n\t\ttask.task.title === genericTitle ? task.task.description : task.task.title,\n\t\tgenericTitle,\n\t);\n\tconst goalId = objective?.objective.objectiveId.startsWith(\"goal:\")\n\t\t? objective.objective.objectiveId.slice(\"goal:\".length)\n\t\t: undefined;\n\treturn {\n\t\tlaneId: managed ? (attempt.dispatch.logicalLaneId ?? taskId) : taskId,\n\t\ttype: managed ? \"tmux-worker\" : \"worker\",\n\t\tstatus,\n\t\tlabel,\n\t\tprofileId: attempt.dispatch.profileId,\n\t\t...(reasonCode ? { reasonCode } : {}),\n\t\t...(attempt.status !== \"queued\" ? { startedAt: attempt.createdAt } : {}),\n\t\t...(status === \"queued\" || status === \"running\"\n\t\t\t? {}\n\t\t\t: { completedAt: task.verification?.completedAt ?? attempt.updatedAt }),\n\t\t...(attempt.result?.usage.costUsd !== undefined ? { costUsd: attempt.result.usage.costUsd } : {}),\n\t\t...(goalId ? { goalId } : {}),\n\t\t...(attempt.dispatch.worktreeLaneKey ? { worktreeLaneKey: attempt.dispatch.worktreeLaneKey } : {}),\n\t};\n}\n\n/** Latest durable turn for each externally managed logical lane. */\nexport function projectManagedWorkerLaneRecords(snapshot: TaskRuntimeProjection): LaneRecord[] {\n\tconst latest = new Map<string, { sequence: number; createdAt: string; record: LaneRecord }>();\n\tfor (const taskId of Object.keys(snapshot.tasks)) {\n\t\tconst attempt = selectedWorkerAttempt(snapshot, taskId);\n\t\tif (!attempt || !isManagedWorkerAttempt(attempt)) continue;\n\t\tconst record = projectWorkerLaneRecord(snapshot, taskId);\n\t\tif (!record) continue;\n\t\tconst sequence = attempt.dispatch.dispatchSequence ?? 1;\n\t\tconst current = latest.get(record.laneId);\n\t\tif (\n\t\t\t!current ||\n\t\t\tsequence > current.sequence ||\n\t\t\t(sequence === current.sequence && attempt.createdAt.localeCompare(current.createdAt) > 0)\n\t\t) {\n\t\t\tlatest.set(record.laneId, { sequence, createdAt: attempt.createdAt, record });\n\t\t}\n\t}\n\treturn [...latest.values()].map((entry) => entry.record);\n}\n\nexport function selectedManagedWorkerAttempt(\n\tsnapshot: TaskRuntimeProjection,\n\tlogicalLaneId: string,\n): AttemptRuntimeState | undefined {\n\treturn Object.values(snapshot.attempts)\n\t\t.filter((attempt) => isManagedWorkerAttempt(attempt) && attempt.dispatch.logicalLaneId === logicalLaneId)\n\t\t.sort((left, right) => {\n\t\t\tconst sequence = (left.dispatch.dispatchSequence ?? 1) - (right.dispatch.dispatchSequence ?? 1);\n\t\t\treturn sequence !== 0 ? sequence : left.createdAt.localeCompare(right.createdAt);\n\t\t})\n\t\t.at(-1);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"worker-lane-projection.js","sourceRoot":"","sources":["../../../src/core/delegation/worker-lane-projection.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,MAAM,CAAC,MAAM,8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C,gBAAgB,IAAI,CAAC,CAAC,CAAC;QAChG,OAAO,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAClF,CAAC,CAAC;SACD,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACV,CAAC","sourcesContent":["import type { LaneRecord, LaneTerminalStatus } from \"../autonomy/lane-tracker.ts\";\nimport type { AttemptRuntimeState, TaskRuntimeProjection } from \"../orchestration/task-runtime.ts\";\nimport { deriveWorkerTaskLabel } from \"./worker-task-label.ts\";\n\nexport const ACTIVE_WORKER_ATTEMPT_STATUSES: ReadonlySet<string> = new Set([\"queued\", \"leased\", \"running\"]);\nexport const NONTERMINAL_WORKER_ATTEMPT_STATUSES: ReadonlySet<string> = new Set([\n\t...ACTIVE_WORKER_ATTEMPT_STATUSES,\n\t\"suspended\",\n]);\n\nexport function isManagedWorkerAttempt(attempt: AttemptRuntimeState): boolean {\n\treturn attempt.dispatch.executionKind === \"managed-process\";\n}\n\nfunction terminalStatus(attempt: AttemptRuntimeState): LaneTerminalStatus {\n\tif (attempt.status === \"completed\") return \"succeeded\";\n\tif (attempt.status === \"cancelled\") return \"canceled\";\n\tif (attempt.result?.status === \"partial\") return \"partial\";\n\tif (attempt.result?.status === \"blocked\") return \"blocked\";\n\tconst reasonCode = attempt.result?.reasonCode ?? attempt.reasonCode ?? \"\";\n\tif (reasonCode.includes(\"budget\")) return \"budget_exhausted\";\n\tif (reasonCode.includes(\"timeout\")) return \"timeout\";\n\treturn \"failed\";\n}\n\nexport function selectedWorkerAttempt(\n\tsnapshot: TaskRuntimeProjection,\n\ttaskId: string,\n): AttemptRuntimeState | undefined {\n\tconst task = snapshot.tasks[taskId];\n\tif (!task) return undefined;\n\tconst attempts = task.attemptIds.map((attemptId) => snapshot.attempts[attemptId]).filter(Boolean);\n\treturn (\n\t\t[...attempts].reverse().find((attempt) => attempt && NONTERMINAL_WORKER_ATTEMPT_STATUSES.has(attempt.status)) ??\n\t\tattempts.at(-1)\n\t);\n}\n\n/**\n * One-way compatibility projection from durable orchestration state. A LaneRecord is never read\n * back to decide lifecycle, retry, verification, or notification transitions.\n */\nexport function projectWorkerLaneRecord(snapshot: TaskRuntimeProjection, taskId: string): LaneRecord | undefined {\n\tconst task = snapshot.tasks[taskId];\n\tconst attempt = selectedWorkerAttempt(snapshot, taskId);\n\tif (!task || !attempt) return undefined;\n\tconst managed = isManagedWorkerAttempt(attempt);\n\tconst objective = snapshot.objectives[task.task.objectiveId];\n\tconst awaitingVerification =\n\t\tattempt.result?.nextAction === \"independent_verification_required\" && task.verification === undefined;\n\tconst status = awaitingVerification\n\t\t? \"running\"\n\t\t: task.verification\n\t\t\t? task.verification.verdict === \"accepted\"\n\t\t\t\t? \"succeeded\"\n\t\t\t\t: \"failed\"\n\t\t\t: attempt.status === \"queued\"\n\t\t\t\t? \"queued\"\n\t\t\t\t: attempt.status === \"leased\" || attempt.status === \"running\" || attempt.status === \"suspended\"\n\t\t\t\t\t? \"running\"\n\t\t\t\t\t: terminalStatus(attempt);\n\tconst reasonCode = task.verification?.reasonCode ?? attempt.result?.reasonCode ?? attempt.reasonCode;\n\tconst genericTitle = `Delegated ${task.task.role} work`;\n\tconst label = deriveWorkerTaskLabel(\n\t\ttask.task.title === genericTitle ? task.task.description : task.task.title,\n\t\tgenericTitle,\n\t);\n\tconst goalId = objective?.objective.objectiveId.startsWith(\"goal:\")\n\t\t? objective.objective.objectiveId.slice(\"goal:\".length)\n\t\t: undefined;\n\treturn {\n\t\tlaneId: managed ? (attempt.dispatch.logicalLaneId ?? taskId) : taskId,\n\t\ttype: managed ? \"tmux-worker\" : \"worker\",\n\t\tstatus,\n\t\tlabel,\n\t\tprofileId: attempt.dispatch.profileId,\n\t\t...(attempt.dispatch.executionContract\n\t\t\t? {\n\t\t\t\t\tmodelRef: `${attempt.dispatch.executionContract.worker.modelBinding.provider}/${attempt.dispatch.executionContract.worker.modelBinding.modelId}`,\n\t\t\t\t\tthinkingLevel: attempt.dispatch.executionContract.worker.modelBinding.thinkingLevel,\n\t\t\t\t}\n\t\t\t: {}),\n\t\t...(reasonCode ? { reasonCode } : {}),\n\t\t...(attempt.status !== \"queued\" ? { startedAt: attempt.createdAt } : {}),\n\t\t...(status === \"queued\" || status === \"running\"\n\t\t\t? {}\n\t\t\t: { completedAt: task.verification?.completedAt ?? attempt.updatedAt }),\n\t\t...(attempt.result?.usage.costUsd !== undefined ? { costUsd: attempt.result.usage.costUsd } : {}),\n\t\t...(goalId ? { goalId } : {}),\n\t\t...(attempt.dispatch.worktreeLaneKey ? { worktreeLaneKey: attempt.dispatch.worktreeLaneKey } : {}),\n\t};\n}\n\n/** Latest durable turn for each externally managed logical lane. */\nexport function projectManagedWorkerLaneRecords(snapshot: TaskRuntimeProjection): LaneRecord[] {\n\tconst latest = new Map<string, { sequence: number; createdAt: string; record: LaneRecord }>();\n\tfor (const taskId of Object.keys(snapshot.tasks)) {\n\t\tconst attempt = selectedWorkerAttempt(snapshot, taskId);\n\t\tif (!attempt || !isManagedWorkerAttempt(attempt)) continue;\n\t\tconst record = projectWorkerLaneRecord(snapshot, taskId);\n\t\tif (!record) continue;\n\t\tconst sequence = attempt.dispatch.dispatchSequence ?? 1;\n\t\tconst current = latest.get(record.laneId);\n\t\tif (\n\t\t\t!current ||\n\t\t\tsequence > current.sequence ||\n\t\t\t(sequence === current.sequence && attempt.createdAt.localeCompare(current.createdAt) > 0)\n\t\t) {\n\t\t\tlatest.set(record.laneId, { sequence, createdAt: attempt.createdAt, record });\n\t\t}\n\t}\n\treturn [...latest.values()].map((entry) => entry.record);\n}\n\nexport function selectedManagedWorkerAttempt(\n\tsnapshot: TaskRuntimeProjection,\n\tlogicalLaneId: string,\n): AttemptRuntimeState | undefined {\n\treturn Object.values(snapshot.attempts)\n\t\t.filter((attempt) => isManagedWorkerAttempt(attempt) && attempt.dispatch.logicalLaneId === logicalLaneId)\n\t\t.sort((left, right) => {\n\t\t\tconst sequence = (left.dispatch.dispatchSequence ?? 1) - (right.dispatch.dispatchSequence ?? 1);\n\t\t\treturn sequence !== 0 ? sequence : left.createdAt.localeCompare(right.createdAt);\n\t\t})\n\t\t.at(-1);\n}\n"]}
|
|
@@ -13,6 +13,12 @@ export interface ResolvedWorkerProfile {
|
|
|
13
13
|
resourcePointers: readonly ResourcePointer[];
|
|
14
14
|
soul?: string;
|
|
15
15
|
}
|
|
16
|
+
export interface ResolvedWorkerProfilePreset {
|
|
17
|
+
profile: OrchestrationProfile;
|
|
18
|
+
/** Metadata-only pointers admitted from the profile-linked resource configuration. */
|
|
19
|
+
resourcePointers: readonly ResourcePointer[];
|
|
20
|
+
soul?: string;
|
|
21
|
+
}
|
|
16
22
|
export interface WorkerProfileResolverOptions {
|
|
17
23
|
agentDir: string;
|
|
18
24
|
cwd: string;
|
|
@@ -39,6 +45,13 @@ export declare class WorkerProfileResolver {
|
|
|
39
45
|
ok: false;
|
|
40
46
|
reason: string;
|
|
41
47
|
};
|
|
48
|
+
resolvePreset(request: WorkerDelegationRequest, defaultProfileId: string | undefined): {
|
|
49
|
+
ok: true;
|
|
50
|
+
resolved: ResolvedWorkerProfilePreset;
|
|
51
|
+
} | {
|
|
52
|
+
ok: false;
|
|
53
|
+
reason: string;
|
|
54
|
+
};
|
|
42
55
|
resolveVerifier(workerProfile: OrchestrationProfile): {
|
|
43
56
|
ok: true;
|
|
44
57
|
resolved: ResolvedWorkerProfile;
|
|
@@ -46,6 +59,20 @@ export declare class WorkerProfileResolver {
|
|
|
46
59
|
ok: false;
|
|
47
60
|
reason: string;
|
|
48
61
|
};
|
|
62
|
+
resolveVerifierPreset(workerProfile: OrchestrationProfile): {
|
|
63
|
+
ok: true;
|
|
64
|
+
resolved: ResolvedWorkerProfilePreset;
|
|
65
|
+
} | {
|
|
66
|
+
ok: false;
|
|
67
|
+
reason: string;
|
|
68
|
+
};
|
|
69
|
+
bindPreset(preset: ResolvedWorkerProfilePreset, modelPin?: OrchestrationModelBinding): {
|
|
70
|
+
ok: true;
|
|
71
|
+
resolved: ResolvedWorkerProfile;
|
|
72
|
+
} | {
|
|
73
|
+
ok: false;
|
|
74
|
+
reason: string;
|
|
75
|
+
};
|
|
49
76
|
resolveContract(contract: WorkerProfileExecutionContract): {
|
|
50
77
|
ok: true;
|
|
51
78
|
resolved: ResolvedWorkerProfile;
|
|
@@ -53,7 +80,7 @@ export declare class WorkerProfileResolver {
|
|
|
53
80
|
ok: false;
|
|
54
81
|
reason: string;
|
|
55
82
|
};
|
|
56
|
-
private
|
|
83
|
+
private resolveProfilePresetId;
|
|
57
84
|
private loadProfiles;
|
|
58
85
|
}
|
|
59
86
|
//# sourceMappingURL=worker-profile-resolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-profile-resolver.d.ts","sourceRoot":"","sources":["../../../src/core/delegation/worker-profile-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EACX,yBAAyB,EACzB,oBAAoB,EACpB,eAAe,EACf,8BAA8B,EAC9B,MAAM,+BAA+B,CAAC;AAMvC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gDAAgD,CAAC;AAC9F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAiC,KAAK,mCAAmC,EAAE,MAAM,8BAA8B,CAAC;AAEvH,MAAM,WAAW,qBAAqB;IACrC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAClB,YAAY,EAAE,yBAAyB,CAAC;IACxC,OAAO,EAAE,oBAAoB,CAAC;IAC9B,sFAAsF;IACtF,g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AAE,EAAE,EAAE,IAAI,CAAC;QAAC,QAAQ,EAAE,qBAAqB,CAAA;KAAE,GAAG;QAAE,EAAE,EAAE,KAAK,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAmB/E;IAED,OAAO,CAAC,sBAAsB;IAiC9B,OAAO,CAAC,YAAY;CA4BpB"}
|
|
@@ -15,13 +15,17 @@ export class WorkerProfileResolver {
|
|
|
15
15
|
}));
|
|
16
16
|
}
|
|
17
17
|
resolve(request, defaultProfileId) {
|
|
18
|
+
const preset = this.resolvePreset(request, defaultProfileId);
|
|
19
|
+
return preset.ok ? this.bindPreset(preset.resolved) : preset;
|
|
20
|
+
}
|
|
21
|
+
resolvePreset(request, defaultProfileId) {
|
|
18
22
|
const requestedProfileId = request.profileId?.trim();
|
|
19
23
|
// Profiles are routing presets, not authority cages. Any loaded preset may be selected; the
|
|
20
24
|
// execution controller independently intersects its materialized plan with inherited authority.
|
|
21
25
|
const profileId = requestedProfileId || defaultProfileId;
|
|
22
26
|
if (!profileId)
|
|
23
27
|
return { ok: false, reason: "orchestration_profile_required" };
|
|
24
|
-
const selected = this.
|
|
28
|
+
const selected = this.resolveProfilePresetId(profileId);
|
|
25
29
|
if (!selected.ok)
|
|
26
30
|
return selected;
|
|
27
31
|
const profile = selected.resolved.profile;
|
|
@@ -34,10 +38,14 @@ export class WorkerProfileResolver {
|
|
|
34
38
|
return selected;
|
|
35
39
|
}
|
|
36
40
|
resolveVerifier(workerProfile) {
|
|
41
|
+
const preset = this.resolveVerifierPreset(workerProfile);
|
|
42
|
+
return preset.ok ? this.bindPreset(preset.resolved) : preset;
|
|
43
|
+
}
|
|
44
|
+
resolveVerifierPreset(workerProfile) {
|
|
37
45
|
if (!workerProfile.requireIndependentVerification || !workerProfile.verificationProfileId) {
|
|
38
46
|
return { ok: false, reason: "independent_verifier_not_configured" };
|
|
39
47
|
}
|
|
40
|
-
const selected = this.
|
|
48
|
+
const selected = this.resolveProfilePresetId(workerProfile.verificationProfileId);
|
|
41
49
|
if (!selected.ok)
|
|
42
50
|
return selected;
|
|
43
51
|
if (selected.resolved.profile.role !== "verifier") {
|
|
@@ -45,6 +53,32 @@ export class WorkerProfileResolver {
|
|
|
45
53
|
}
|
|
46
54
|
return selected;
|
|
47
55
|
}
|
|
56
|
+
bindPreset(preset, modelPin) {
|
|
57
|
+
const resolvedModel = modelPin
|
|
58
|
+
? resolvePinnedOrchestrationModel(modelPin, this.options.getModelRegistry(), (model) => this.options.isModelExhausted(model))
|
|
59
|
+
: resolveConfiguredOrchestrationModel(preset.profile, this.options.getModelRegistry(), (model) => this.options.isModelExhausted(model));
|
|
60
|
+
if (!resolvedModel) {
|
|
61
|
+
return {
|
|
62
|
+
ok: false,
|
|
63
|
+
reason: modelPin ? "orchestration_model_unavailable" : "orchestration_profile_model_unavailable",
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
ok: true,
|
|
68
|
+
resolved: {
|
|
69
|
+
model: resolvedModel.model,
|
|
70
|
+
modelBinding: resolvedModel.binding,
|
|
71
|
+
profile: modelPin
|
|
72
|
+
? {
|
|
73
|
+
...structuredClone(preset.profile),
|
|
74
|
+
modelPolicy: { mode: "fixed", candidates: [resolvedModel.binding] },
|
|
75
|
+
}
|
|
76
|
+
: structuredClone(preset.profile),
|
|
77
|
+
resourcePointers: structuredClone(preset.resourcePointers),
|
|
78
|
+
...(preset.soul ? { soul: preset.soul } : {}),
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
}
|
|
48
82
|
resolveContract(contract) {
|
|
49
83
|
// Admission already fixed this contract. Live host controls may revoke execution, but mutable
|
|
50
84
|
// profile files cannot retroactively redefine the model, resources, or authority snapshot.
|
|
@@ -62,13 +96,10 @@ export class WorkerProfileResolver {
|
|
|
62
96
|
},
|
|
63
97
|
};
|
|
64
98
|
}
|
|
65
|
-
|
|
99
|
+
resolveProfilePresetId(profileId, loaded = this.loadProfiles()) {
|
|
66
100
|
const profile = loaded.registry.get(profileId);
|
|
67
101
|
if (!profile)
|
|
68
102
|
return { ok: false, reason: "orchestration_profile_not_found" };
|
|
69
|
-
const resolvedModel = resolveConfiguredOrchestrationModel(profile, this.options.getModelRegistry(), (model) => this.options.isModelExhausted(model));
|
|
70
|
-
if (!resolvedModel)
|
|
71
|
-
return { ok: false, reason: "orchestration_profile_model_unavailable" };
|
|
72
103
|
const linkedProfiles = profile.resourceProfileNames.map((name) => this.options.getSettingsManager().getProfileRegistry().getProfile(name));
|
|
73
104
|
if (linkedProfiles.some((linked) => linked === undefined)) {
|
|
74
105
|
return { ok: false, reason: "orchestration_resource_profile_not_found" };
|
|
@@ -85,9 +116,7 @@ export class WorkerProfileResolver {
|
|
|
85
116
|
return {
|
|
86
117
|
ok: true,
|
|
87
118
|
resolved: {
|
|
88
|
-
|
|
89
|
-
modelBinding: resolvedModel.binding,
|
|
90
|
-
profile,
|
|
119
|
+
profile: structuredClone(profile),
|
|
91
120
|
resourcePointers,
|
|
92
121
|
...(soul ? { soul } : {}),
|
|
93
122
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-profile-resolver.js","sourceRoot":"","sources":["../../../src/core/delegation/worker-profile-resolver.ts"],"names":[],"mappings":"AAQA,OAAO,EACN,mCAAmC,EACnC,+BAA+B,GAC/B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAI9E,OAAO,EAAE,6BAA6B,EAA4C,MAAM,8BAA8B,CAAC;AA2BvH,MAAM,OAAO,qBAAqB;IAIjC,YAAY,OAAqC;QAFhC,sBAAiB,GAAG,IAAI,GAAG,EAAU,CAAC;QAGtD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAED,OAAO;QACN,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACnC,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CA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C,GAAG,CAAC,GAAG,CAAC;gBAAE,SAAS;YAC9C,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAChC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,iCAAiC,UAAU,EAAE,CAAC,CAAC;QAC1E,CAAC;QACD,MAAM,QAAQ,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QACtC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QACzF,KAAK,MAAM,MAAM,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;YAC3C,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;gBAAE,SAAS;YACrD,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC9B,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;IAC/B,CAAC;CACD","sourcesContent":["import type { Api, Model } from \"@caupulican/pi-ai\";\nimport type { ModelRegistry } from \"../model-registry.ts\";\nimport type {\n\tOrchestrationModelBinding,\n\tOrchestrationProfile,\n\tResourcePointer,\n\tWorkerProfileExecutionContract,\n} from \"../orchestration/contracts.ts\";\nimport {\n\tresolveConfiguredOrchestrationModel,\n\tresolvePinnedOrchestrationModel,\n} from \"../orchestration/model-binding.ts\";\nimport { OrchestrationProfileStore } from \"../orchestration/profile-store.ts\";\nimport type { SessionTaskProfileStore } from \"../orchestration/session-task-profile-store.ts\";\nimport type { SettingsManager } from \"../settings-manager.ts\";\nimport type { WorkerDelegationRequest } from \"./worker-delegation-request.ts\";\nimport { catalogWorkerResourcePointers, type WorkerResourceCatalogResourceLoader } from \"./worker-resource-catalog.ts\";\n\nexport interface ResolvedWorkerProfile {\n\tmodel: Model<Api>;\n\tmodelBinding: OrchestrationModelBinding;\n\tprofile: OrchestrationProfile;\n\t/** Metadata-only pointers admitted from the profile-linked resource configuration. */\n\tresourcePointers: readonly ResourcePointer[];\n\tsoul?: string;\n}\n\nexport interface WorkerProfileResolverOptions {\n\tagentDir: string;\n\tcwd: string;\n\tgetSettingsManager(): SettingsManager;\n\tgetResourceLoader(): WorkerResourceCatalogResourceLoader;\n\tgetModelRegistry(): ModelRegistry;\n\tisModelExhausted(model: Model<Api>): boolean;\n\tgetTaskProfileStore(): SessionTaskProfileStore;\n\tonDiagnostic(message: string): void;\n}\n\ninterface LoadedWorkerProfiles {\n\tprofiles: OrchestrationProfile[];\n\tregistry: ReadonlyMap<string, OrchestrationProfile>;\n}\n\nexport class WorkerProfileResolver {\n\tprivate readonly options: WorkerProfileResolverOptions;\n\tprivate readonly warnedDiagnostics = new Set<string>();\n\n\tconstructor(options: WorkerProfileResolverOptions) {\n\t\tthis.options = options;\n\t}\n\n\tcatalog(): Array<{ profileId: string; role: string; description: string }> {\n\t\tconst loaded = this.loadProfiles();\n\t\treturn loaded.profiles.map((profile) => ({\n\t\t\tprofileId: profile.profileId,\n\t\t\trole: profile.role,\n\t\t\tdescription: profile.description,\n\t\t}));\n\t}\n\n\tresolve(\n\t\trequest: WorkerDelegationRequest,\n\t\tdefaultProfileId: string | undefined,\n\t): { ok: true; resolved: ResolvedWorkerProfile } | { ok: false; reason: string } {\n\t\tconst requestedProfileId = request.profileId?.trim();\n\t\t// Profiles are routing presets, not authority cages. Any loaded preset may be selected; the\n\t\t// execution controller independently intersects its materialized plan with inherited authority.\n\t\tconst profileId = requestedProfileId || defaultProfileId;\n\t\tif (!profileId) return { ok: false, reason: \"orchestration_profile_required\" };\n\t\tconst selected = this.resolveProfileId(profileId);\n\t\tif (!selected.ok) return selected;\n\t\tconst profile = selected.resolved.profile;\n\t\tif (request.verificationOfTaskId && profile.role !== \"verifier\") {\n\t\t\treturn { ok: false, reason: \"verification_profile_role_mismatch\" };\n\t\t}\n\t\tif (!request.verificationOfTaskId && profile.role === \"verifier\") {\n\t\t\treturn { ok: false, reason: \"verifier_profile_requires_runtime_dispatch\" };\n\t\t}\n\t\treturn selected;\n\t}\n\n\tresolveVerifier(\n\t\tworkerProfile: OrchestrationProfile,\n\t): { ok: true; resolved: ResolvedWorkerProfile } | { ok: false; reason: string } {\n\t\tif (!workerProfile.requireIndependentVerification || !workerProfile.verificationProfileId) {\n\t\t\treturn { ok: false, reason: \"independent_verifier_not_configured\" };\n\t\t}\n\t\tconst selected = this.resolveProfileId(workerProfile.verificationProfileId);\n\t\tif (!selected.ok) return selected;\n\t\tif (selected.resolved.profile.role !== \"verifier\") {\n\t\t\treturn { ok: false, reason: \"verification_profile_role_mismatch\" };\n\t\t}\n\t\treturn selected;\n\t}\n\n\tresolveContract(\n\t\tcontract: WorkerProfileExecutionContract,\n\t): { ok: true; resolved: ResolvedWorkerProfile } | { ok: false; reason: string } {\n\t\t// Admission already fixed this contract. Live host controls may revoke execution, but mutable\n\t\t// profile files cannot retroactively redefine the model, resources, or authority snapshot.\n\t\tconst resolvedModel = resolvePinnedOrchestrationModel(\n\t\t\tcontract.modelBinding,\n\t\t\tthis.options.getModelRegistry(),\n\t\t\t(model) => this.options.isModelExhausted(model),\n\t\t);\n\t\tif (!resolvedModel) return { ok: false, reason: \"orchestration_profile_model_unavailable\" };\n\t\treturn {\n\t\t\tok: true,\n\t\t\tresolved: {\n\t\t\t\tmodel: resolvedModel.model,\n\t\t\t\tmodelBinding: resolvedModel.binding,\n\t\t\t\tprofile: structuredClone(contract.profile),\n\t\t\t\tresourcePointers: structuredClone(contract.resourcePointers),\n\t\t\t\t...(contract.soul ? { soul: contract.soul } : {}),\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate resolveProfileId(\n\t\tprofileId: string,\n\t\tloaded: LoadedWorkerProfiles = this.loadProfiles(),\n\t): { ok: true; resolved: ResolvedWorkerProfile } | { ok: false; reason: string } {\n\t\tconst profile = loaded.registry.get(profileId);\n\t\tif (!profile) return { ok: false, reason: \"orchestration_profile_not_found\" };\n\t\tconst resolvedModel = resolveConfiguredOrchestrationModel(profile, this.options.getModelRegistry(), (model) =>\n\t\t\tthis.options.isModelExhausted(model),\n\t\t);\n\t\tif (!resolvedModel) return { ok: false, reason: \"orchestration_profile_model_unavailable\" };\n\t\tconst linkedProfiles = profile.resourceProfileNames.map((name) =>\n\t\t\tthis.options.getSettingsManager().getProfileRegistry().getProfile(name),\n\t\t);\n\t\tif (linkedProfiles.some((linked) => linked === undefined)) {\n\t\t\treturn { ok: false, reason: \"orchestration_resource_profile_not_found\" };\n\t\t}\n\t\tconst soul = linkedProfiles\n\t\t\t.flatMap((linked) => (linked?.soul ? [linked.soul] : []))\n\t\t\t.join(\"\\n\\n\")\n\t\t\t.trim();\n\t\tconst resourcePointers = catalogWorkerResourcePointers({\n\t\t\tcwd: this.options.cwd,\n\t\t\tresourceLoader: this.options.getResourceLoader(),\n\t\t\tresourceProfiles: linkedProfiles.filter(\n\t\t\t\t(linked): linked is NonNullable<typeof linked> => linked !== undefined,\n\t\t\t),\n\t\t});\n\t\treturn {\n\t\t\tok: true,\n\t\t\tresolved: {\n\t\t\t\tmodel: resolvedModel.model,\n\t\t\t\tmodelBinding: resolvedModel.binding,\n\t\t\t\tprofile,\n\t\t\t\tresourcePointers,\n\t\t\t\t...(soul ? { soul } : {}),\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate loadProfiles(): LoadedWorkerProfiles {\n\t\tconst loaded = new OrchestrationProfileStore({\n\t\t\tagentDir: this.options.agentDir,\n\t\t\tcwd: this.options.cwd,\n\t\t\tprojectTrusted: this.options.getSettingsManager().isProjectTrusted(),\n\t\t}).load();\n\t\tfor (const diagnostic of loaded.diagnostics) {\n\t\t\tconst key = `${diagnostic.path}\\0${diagnostic.message}`;\n\t\t\tif (this.warnedDiagnostics.has(key)) continue;\n\t\t\tthis.warnedDiagnostics.add(key);\n\t\t\tthis.options.onDiagnostic(`Orchestration profile ignored (${diagnostic.path}): ${diagnostic.message}`);\n\t\t}\n\t\tconst taskProfiles = this.options.getTaskProfileStore().load();\n\t\tfor (const diagnostic of taskProfiles.diagnostics) {\n\t\t\tconst key = `session\\0${diagnostic}`;\n\t\t\tif (this.warnedDiagnostics.has(key)) continue;\n\t\t\tthis.warnedDiagnostics.add(key);\n\t\t\tthis.options.onDiagnostic(`Session task profile ignored: ${diagnostic}`);\n\t\t}\n\t\tconst profiles = [...loaded.profiles];\n\t\tconst registry = new Map(loaded.profiles.map((profile) => [profile.profileId, profile]));\n\t\tfor (const record of taskProfiles.records) {\n\t\t\tif (registry.has(record.profile.profileId)) continue;\n\t\t\tprofiles.push(record.profile);\n\t\t\tregistry.set(record.profile.profileId, record.profile);\n\t\t}\n\t\treturn { profiles, registry };\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"worker-profile-resolver.js","sourceRoot":"","sources":["../../../src/core/delegation/worker-profile-resolver.ts"],"names":[],"mappings":"AAQA,OAAO,EACN,mCAAmC,EACnC,+BAA+B,GAC/B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAI9E,OAAO,EAAE,6BAA6B,EAA4C,MAAM,8BAA8B,CAAC;AAkCvH,MAAM,OAAO,qBAAqB;IAIjC,YAAY,OAAqC;QAFhC,sBAAiB,GAAG,IAAI,GAAG,EAAU,CAAC;QAGtD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAED,OAAO;QACN,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACnC,OAAO,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YACxC,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,I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,CAAC;YACnD,MAAM,GAAG,GAAG,YAAY,UAAU,EAAE,CAAC;YACrC,IAAI,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,SAAS;YAC9C,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAChC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,iCAAiC,UAAU,EAAE,CAAC,CAAC;QAC1E,CAAC;QACD,MAAM,QAAQ,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;QACtC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QACzF,KAAK,MAAM,MAAM,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;YAC3C,IAAI,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;gBAAE,SAAS;YACrD,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC9B,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QACxD,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;IAC/B,CAAC;CACD","sourcesContent":["import type { Api, Model } from \"@caupulican/pi-ai\";\nimport type { ModelRegistry } from \"../model-registry.ts\";\nimport type {\n\tOrchestrationModelBinding,\n\tOrchestrationProfile,\n\tResourcePointer,\n\tWorkerProfileExecutionContract,\n} from \"../orchestration/contracts.ts\";\nimport {\n\tresolveConfiguredOrchestrationModel,\n\tresolvePinnedOrchestrationModel,\n} from \"../orchestration/model-binding.ts\";\nimport { OrchestrationProfileStore } from \"../orchestration/profile-store.ts\";\nimport type { SessionTaskProfileStore } from \"../orchestration/session-task-profile-store.ts\";\nimport type { SettingsManager } from \"../settings-manager.ts\";\nimport type { WorkerDelegationRequest } from \"./worker-delegation-request.ts\";\nimport { catalogWorkerResourcePointers, type WorkerResourceCatalogResourceLoader } from \"./worker-resource-catalog.ts\";\n\nexport interface ResolvedWorkerProfile {\n\tmodel: Model<Api>;\n\tmodelBinding: OrchestrationModelBinding;\n\tprofile: OrchestrationProfile;\n\t/** Metadata-only pointers admitted from the profile-linked resource configuration. */\n\tresourcePointers: readonly ResourcePointer[];\n\tsoul?: string;\n}\n\nexport interface ResolvedWorkerProfilePreset {\n\tprofile: OrchestrationProfile;\n\t/** Metadata-only pointers admitted from the profile-linked resource configuration. */\n\tresourcePointers: readonly ResourcePointer[];\n\tsoul?: string;\n}\n\nexport interface WorkerProfileResolverOptions {\n\tagentDir: string;\n\tcwd: string;\n\tgetSettingsManager(): SettingsManager;\n\tgetResourceLoader(): WorkerResourceCatalogResourceLoader;\n\tgetModelRegistry(): ModelRegistry;\n\tisModelExhausted(model: Model<Api>): boolean;\n\tgetTaskProfileStore(): SessionTaskProfileStore;\n\tonDiagnostic(message: string): void;\n}\n\ninterface LoadedWorkerProfiles {\n\tprofiles: OrchestrationProfile[];\n\tregistry: ReadonlyMap<string, OrchestrationProfile>;\n}\n\nexport class WorkerProfileResolver {\n\tprivate readonly options: WorkerProfileResolverOptions;\n\tprivate readonly warnedDiagnostics = new Set<string>();\n\n\tconstructor(options: WorkerProfileResolverOptions) {\n\t\tthis.options = options;\n\t}\n\n\tcatalog(): Array<{ profileId: string; role: string; description: string }> {\n\t\tconst loaded = this.loadProfiles();\n\t\treturn loaded.profiles.map((profile) => ({\n\t\t\tprofileId: profile.profileId,\n\t\t\trole: profile.role,\n\t\t\tdescription: profile.description,\n\t\t}));\n\t}\n\n\tresolve(\n\t\trequest: WorkerDelegationRequest,\n\t\tdefaultProfileId: string | undefined,\n\t): { ok: true; resolved: ResolvedWorkerProfile } | { ok: false; reason: string } {\n\t\tconst preset = this.resolvePreset(request, defaultProfileId);\n\t\treturn preset.ok ? this.bindPreset(preset.resolved) : preset;\n\t}\n\n\tresolvePreset(\n\t\trequest: WorkerDelegationRequest,\n\t\tdefaultProfileId: string | undefined,\n\t): { ok: true; resolved: ResolvedWorkerProfilePreset } | { ok: false; reason: string } {\n\t\tconst requestedProfileId = request.profileId?.trim();\n\t\t// Profiles are routing presets, not authority cages. Any loaded preset may be selected; the\n\t\t// execution controller independently intersects its materialized plan with inherited authority.\n\t\tconst profileId = requestedProfileId || defaultProfileId;\n\t\tif (!profileId) return { ok: false, reason: \"orchestration_profile_required\" };\n\t\tconst selected = this.resolveProfilePresetId(profileId);\n\t\tif (!selected.ok) return selected;\n\t\tconst profile = selected.resolved.profile;\n\t\tif (request.verificationOfTaskId && profile.role !== \"verifier\") {\n\t\t\treturn { ok: false, reason: \"verification_profile_role_mismatch\" };\n\t\t}\n\t\tif (!request.verificationOfTaskId && profile.role === \"verifier\") {\n\t\t\treturn { ok: false, reason: \"verifier_profile_requires_runtime_dispatch\" };\n\t\t}\n\t\treturn selected;\n\t}\n\n\tresolveVerifier(\n\t\tworkerProfile: OrchestrationProfile,\n\t): { ok: true; resolved: ResolvedWorkerProfile } | { ok: false; reason: string } {\n\t\tconst preset = this.resolveVerifierPreset(workerProfile);\n\t\treturn preset.ok ? this.bindPreset(preset.resolved) : preset;\n\t}\n\n\tresolveVerifierPreset(\n\t\tworkerProfile: OrchestrationProfile,\n\t): { ok: true; resolved: ResolvedWorkerProfilePreset } | { ok: false; reason: string } {\n\t\tif (!workerProfile.requireIndependentVerification || !workerProfile.verificationProfileId) {\n\t\t\treturn { ok: false, reason: \"independent_verifier_not_configured\" };\n\t\t}\n\t\tconst selected = this.resolveProfilePresetId(workerProfile.verificationProfileId);\n\t\tif (!selected.ok) return selected;\n\t\tif (selected.resolved.profile.role !== \"verifier\") {\n\t\t\treturn { ok: false, reason: \"verification_profile_role_mismatch\" };\n\t\t}\n\t\treturn selected;\n\t}\n\n\tbindPreset(\n\t\tpreset: ResolvedWorkerProfilePreset,\n\t\tmodelPin?: OrchestrationModelBinding,\n\t): { ok: true; resolved: ResolvedWorkerProfile } | { ok: false; reason: string } {\n\t\tconst resolvedModel = modelPin\n\t\t\t? resolvePinnedOrchestrationModel(modelPin, this.options.getModelRegistry(), (model) =>\n\t\t\t\t\tthis.options.isModelExhausted(model),\n\t\t\t\t)\n\t\t\t: resolveConfiguredOrchestrationModel(preset.profile, this.options.getModelRegistry(), (model) =>\n\t\t\t\t\tthis.options.isModelExhausted(model),\n\t\t\t\t);\n\t\tif (!resolvedModel) {\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\treason: modelPin ? \"orchestration_model_unavailable\" : \"orchestration_profile_model_unavailable\",\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tok: true,\n\t\t\tresolved: {\n\t\t\t\tmodel: resolvedModel.model,\n\t\t\t\tmodelBinding: resolvedModel.binding,\n\t\t\t\tprofile: modelPin\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...structuredClone(preset.profile),\n\t\t\t\t\t\t\tmodelPolicy: { mode: \"fixed\", candidates: [resolvedModel.binding] },\n\t\t\t\t\t\t}\n\t\t\t\t\t: structuredClone(preset.profile),\n\t\t\t\tresourcePointers: structuredClone(preset.resourcePointers),\n\t\t\t\t...(preset.soul ? { soul: preset.soul } : {}),\n\t\t\t},\n\t\t};\n\t}\n\n\tresolveContract(\n\t\tcontract: WorkerProfileExecutionContract,\n\t): { ok: true; resolved: ResolvedWorkerProfile } | { ok: false; reason: string } {\n\t\t// Admission already fixed this contract. Live host controls may revoke execution, but mutable\n\t\t// profile files cannot retroactively redefine the model, resources, or authority snapshot.\n\t\tconst resolvedModel = resolvePinnedOrchestrationModel(\n\t\t\tcontract.modelBinding,\n\t\t\tthis.options.getModelRegistry(),\n\t\t\t(model) => this.options.isModelExhausted(model),\n\t\t);\n\t\tif (!resolvedModel) return { ok: false, reason: \"orchestration_profile_model_unavailable\" };\n\t\treturn {\n\t\t\tok: true,\n\t\t\tresolved: {\n\t\t\t\tmodel: resolvedModel.model,\n\t\t\t\tmodelBinding: resolvedModel.binding,\n\t\t\t\tprofile: structuredClone(contract.profile),\n\t\t\t\tresourcePointers: structuredClone(contract.resourcePointers),\n\t\t\t\t...(contract.soul ? { soul: contract.soul } : {}),\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate resolveProfilePresetId(\n\t\tprofileId: string,\n\t\tloaded: LoadedWorkerProfiles = this.loadProfiles(),\n\t): { ok: true; resolved: ResolvedWorkerProfilePreset } | { ok: false; reason: string } {\n\t\tconst profile = loaded.registry.get(profileId);\n\t\tif (!profile) return { ok: false, reason: \"orchestration_profile_not_found\" };\n\t\tconst linkedProfiles = profile.resourceProfileNames.map((name) =>\n\t\t\tthis.options.getSettingsManager().getProfileRegistry().getProfile(name),\n\t\t);\n\t\tif (linkedProfiles.some((linked) => linked === undefined)) {\n\t\t\treturn { ok: false, reason: \"orchestration_resource_profile_not_found\" };\n\t\t}\n\t\tconst soul = linkedProfiles\n\t\t\t.flatMap((linked) => (linked?.soul ? [linked.soul] : []))\n\t\t\t.join(\"\\n\\n\")\n\t\t\t.trim();\n\t\tconst resourcePointers = catalogWorkerResourcePointers({\n\t\t\tcwd: this.options.cwd,\n\t\t\tresourceLoader: this.options.getResourceLoader(),\n\t\t\tresourceProfiles: linkedProfiles.filter(\n\t\t\t\t(linked): linked is NonNullable<typeof linked> => linked !== undefined,\n\t\t\t),\n\t\t});\n\t\treturn {\n\t\t\tok: true,\n\t\t\tresolved: {\n\t\t\t\tprofile: structuredClone(profile),\n\t\t\t\tresourcePointers,\n\t\t\t\t...(soul ? { soul } : {}),\n\t\t\t},\n\t\t};\n\t}\n\n\tprivate loadProfiles(): LoadedWorkerProfiles {\n\t\tconst loaded = new OrchestrationProfileStore({\n\t\t\tagentDir: this.options.agentDir,\n\t\t\tcwd: this.options.cwd,\n\t\t\tprojectTrusted: this.options.getSettingsManager().isProjectTrusted(),\n\t\t}).load();\n\t\tfor (const diagnostic of loaded.diagnostics) {\n\t\t\tconst key = `${diagnostic.path}\\0${diagnostic.message}`;\n\t\t\tif (this.warnedDiagnostics.has(key)) continue;\n\t\t\tthis.warnedDiagnostics.add(key);\n\t\t\tthis.options.onDiagnostic(`Orchestration profile ignored (${diagnostic.path}): ${diagnostic.message}`);\n\t\t}\n\t\tconst taskProfiles = this.options.getTaskProfileStore().load();\n\t\tfor (const diagnostic of taskProfiles.diagnostics) {\n\t\t\tconst key = `session\\0${diagnostic}`;\n\t\t\tif (this.warnedDiagnostics.has(key)) continue;\n\t\t\tthis.warnedDiagnostics.add(key);\n\t\t\tthis.options.onDiagnostic(`Session task profile ignored: ${diagnostic}`);\n\t\t}\n\t\tconst profiles = [...loaded.profiles];\n\t\tconst registry = new Map(loaded.profiles.map((profile) => [profile.profileId, profile]));\n\t\tfor (const record of taskProfiles.records) {\n\t\t\tif (registry.has(record.profile.profileId)) continue;\n\t\t\tprofiles.push(record.profile);\n\t\t\tregistry.set(record.profile.profileId, record.profile);\n\t\t}\n\t\treturn { profiles, registry };\n\t}\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type OrchestrationModelBinding, type WorkerRole } from "./contracts.ts";
|
|
2
|
+
export type WorkerModelPinSource = "global" | "project" | "directoryProfile";
|
|
3
|
+
export interface WorkerModelPinsSettings {
|
|
4
|
+
default?: OrchestrationModelBinding;
|
|
5
|
+
roles?: Partial<Record<WorkerRole, OrchestrationModelBinding>>;
|
|
6
|
+
}
|
|
7
|
+
export interface ResolvedWorkerModelPin {
|
|
8
|
+
binding: OrchestrationModelBinding;
|
|
9
|
+
source: WorkerModelPinSource;
|
|
10
|
+
}
|
|
11
|
+
export type WorkerModelPinPolicy = {
|
|
12
|
+
status: "absent";
|
|
13
|
+
} | {
|
|
14
|
+
status: "invalid";
|
|
15
|
+
diagnostics: readonly string[];
|
|
16
|
+
} | {
|
|
17
|
+
status: "active";
|
|
18
|
+
byRole: Readonly<Partial<Record<WorkerRole, ResolvedWorkerModelPin>>>;
|
|
19
|
+
};
|
|
20
|
+
export interface WorkerModelPinPolicyLayers {
|
|
21
|
+
global?: unknown;
|
|
22
|
+
project?: unknown;
|
|
23
|
+
directoryProfile?: unknown;
|
|
24
|
+
}
|
|
25
|
+
/** Compile independently validated settings scopes into one immutable admission policy. */
|
|
26
|
+
export declare function compileWorkerModelPinPolicy(layers: WorkerModelPinPolicyLayers): WorkerModelPinPolicy;
|
|
27
|
+
export declare function resolveWorkerModelPin(policy: WorkerModelPinPolicy, role: WorkerRole): ResolvedWorkerModelPin | undefined;
|
|
28
|
+
//# sourceMappingURL=worker-model-pins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-model-pins.d.ts","sourceRoot":"","sources":["../../../src/core/orchestration/worker-model-pins.ts"],"names":[],"mappings":"AACA,OAAO,EAIN,KAAK,yBAAyB,EAE9B,KAAK,UAAU,EACf,MAAM,gBAAgB,CAAC;AAExB,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,SAAS,GAAG,kBAAkB,CAAC;AAE7E,MAAM,WAAW,uBAAuB;IACvC,OAAO,CAAC,EAAE,yBAAyB,CAAC;IACpC,KAAK,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,yBAAyB,CAAC,CAAC,CAAC;CAC/D;AAED,MAAM,WAAW,sBAAsB;IACtC,OAAO,EAAE,yBAAyB,CAAC;IACnC,MAAM,EAAE,oBAAoB,CAAC;CAC7B;AAED,MAAM,MAAM,oBAAoB,GAC7B;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,GACpB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACrD;IACA,MAAM,EAAE,QAAQ,CAAC;IACjB,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC;CACrE,CAAC;AAEL,MAAM,WAAW,0BAA0B;IAC1C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC3B;AAqJD,2FAA2F;AAC3F,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,0BAA0B,GAAG,oBAAoB,CAmBpG;AAED,wBAAgB,qBAAqB,CACpC,MAAM,EAAE,oBAAoB,EAC5B,IAAI,EAAE,UAAU,GACd,sBAAsB,GAAG,SAAS,CAIpC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { isPlainRecord } from "../util/value-guards.js";
|
|
2
|
+
import { MAX_ORCHESTRATION_MODEL_ID_LENGTH, MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH, ORCHESTRATION_THINKING_LEVELS, WORKER_ROLES, } from "./contracts.js";
|
|
3
|
+
const POLICY_KEYS = new Set(["default", "roles"]);
|
|
4
|
+
const BINDING_KEYS = new Set(["provider", "modelId", "thinkingLevel"]);
|
|
5
|
+
const WORKER_ROLE_SET = new Set(WORKER_ROLES);
|
|
6
|
+
const THINKING_LEVEL_SET = new Set(ORCHESTRATION_THINKING_LEVELS);
|
|
7
|
+
function cloneBinding(binding) {
|
|
8
|
+
return { ...binding };
|
|
9
|
+
}
|
|
10
|
+
function bindingDiagnostic(scope, path, expectation) {
|
|
11
|
+
return `workerDelegation.modelPins.${path} in ${scope} settings must ${expectation}`;
|
|
12
|
+
}
|
|
13
|
+
function parseBinding(value, scope, path, diagnostics) {
|
|
14
|
+
if (!isPlainRecord(value)) {
|
|
15
|
+
diagnostics.push(bindingDiagnostic(scope, path, "be an object"));
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const unknownKeys = Object.keys(value).filter((key) => !BINDING_KEYS.has(key));
|
|
19
|
+
if (unknownKeys.length > 0) {
|
|
20
|
+
diagnostics.push(bindingDiagnostic(scope, path, `contain only provider, modelId, and thinkingLevel`));
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
const provider = typeof value.provider === "string" ? value.provider.trim() : "";
|
|
24
|
+
if (!provider || provider.length > MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH) {
|
|
25
|
+
diagnostics.push(bindingDiagnostic(scope, `${path}.provider`, `be a nonempty string of at most ${MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH} characters`));
|
|
26
|
+
}
|
|
27
|
+
const modelId = typeof value.modelId === "string" ? value.modelId.trim() : "";
|
|
28
|
+
if (!modelId || modelId.length > MAX_ORCHESTRATION_MODEL_ID_LENGTH) {
|
|
29
|
+
diagnostics.push(bindingDiagnostic(scope, `${path}.modelId`, `be a nonempty string of at most ${MAX_ORCHESTRATION_MODEL_ID_LENGTH} characters`));
|
|
30
|
+
}
|
|
31
|
+
const thinkingLevel = value.thinkingLevel;
|
|
32
|
+
if (typeof thinkingLevel !== "string" || !THINKING_LEVEL_SET.has(thinkingLevel)) {
|
|
33
|
+
diagnostics.push(bindingDiagnostic(scope, `${path}.thinkingLevel`, `be one of ${ORCHESTRATION_THINKING_LEVELS.join(", ")}`));
|
|
34
|
+
}
|
|
35
|
+
if (!provider || !modelId || typeof thinkingLevel !== "string" || !THINKING_LEVEL_SET.has(thinkingLevel)) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
provider,
|
|
40
|
+
modelId,
|
|
41
|
+
thinkingLevel: thinkingLevel,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function parseLayer(value, scope) {
|
|
45
|
+
if (value === undefined)
|
|
46
|
+
return { present: false, diagnostics: [] };
|
|
47
|
+
const diagnostics = [];
|
|
48
|
+
if (!isPlainRecord(value)) {
|
|
49
|
+
return {
|
|
50
|
+
present: true,
|
|
51
|
+
diagnostics: [`workerDelegation.modelPins in ${scope} settings must be an object`],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const unknownKeys = Object.keys(value).filter((key) => !POLICY_KEYS.has(key));
|
|
55
|
+
if (unknownKeys.length > 0) {
|
|
56
|
+
diagnostics.push(`workerDelegation.modelPins in ${scope} settings contains unknown fields: ${unknownKeys.join(", ")}`);
|
|
57
|
+
}
|
|
58
|
+
const settings = {};
|
|
59
|
+
if (Object.hasOwn(value, "default")) {
|
|
60
|
+
const binding = parseBinding(value.default, scope, "default", diagnostics);
|
|
61
|
+
if (binding)
|
|
62
|
+
settings.default = binding;
|
|
63
|
+
}
|
|
64
|
+
if (Object.hasOwn(value, "roles")) {
|
|
65
|
+
if (!isPlainRecord(value.roles)) {
|
|
66
|
+
diagnostics.push(`workerDelegation.modelPins.roles in ${scope} settings must be an object`);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const roles = {};
|
|
70
|
+
for (const [role, candidate] of Object.entries(value.roles)) {
|
|
71
|
+
if (!WORKER_ROLE_SET.has(role)) {
|
|
72
|
+
diagnostics.push(`workerDelegation.modelPins.roles in ${scope} settings contains unknown role: ${role}`);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const binding = parseBinding(candidate, scope, `roles.${role}`, diagnostics);
|
|
76
|
+
if (binding)
|
|
77
|
+
roles[role] = binding;
|
|
78
|
+
}
|
|
79
|
+
settings.roles = roles;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return { present: true, settings, diagnostics };
|
|
83
|
+
}
|
|
84
|
+
function pinFromLayer(layer, role) {
|
|
85
|
+
if (!layer)
|
|
86
|
+
return undefined;
|
|
87
|
+
const binding = layer.settings.roles?.[role] ?? layer.settings.default;
|
|
88
|
+
return binding ? { binding: cloneBinding(binding), source: layer.source } : undefined;
|
|
89
|
+
}
|
|
90
|
+
function pinFromLocalLayers(directoryLayer, projectLayer, role) {
|
|
91
|
+
const roleLayer = directoryLayer?.settings.roles?.[role]
|
|
92
|
+
? directoryLayer
|
|
93
|
+
: projectLayer?.settings.roles?.[role]
|
|
94
|
+
? projectLayer
|
|
95
|
+
: undefined;
|
|
96
|
+
const roleBinding = roleLayer?.settings.roles?.[role];
|
|
97
|
+
if (roleLayer && roleBinding) {
|
|
98
|
+
return {
|
|
99
|
+
binding: cloneBinding(roleBinding),
|
|
100
|
+
source: roleLayer.source,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
const defaultLayer = directoryLayer?.settings.default
|
|
104
|
+
? directoryLayer
|
|
105
|
+
: projectLayer?.settings.default
|
|
106
|
+
? projectLayer
|
|
107
|
+
: undefined;
|
|
108
|
+
return defaultLayer?.settings.default
|
|
109
|
+
? { binding: cloneBinding(defaultLayer.settings.default), source: defaultLayer.source }
|
|
110
|
+
: undefined;
|
|
111
|
+
}
|
|
112
|
+
/** Compile independently validated settings scopes into one immutable admission policy. */
|
|
113
|
+
export function compileWorkerModelPinPolicy(layers) {
|
|
114
|
+
const global = parseLayer(layers.global, "global");
|
|
115
|
+
const project = parseLayer(layers.project, "project");
|
|
116
|
+
const directoryProfile = parseLayer(layers.directoryProfile, "directoryProfile");
|
|
117
|
+
const diagnostics = [...global.diagnostics, ...project.diagnostics, ...directoryProfile.diagnostics];
|
|
118
|
+
if (diagnostics.length > 0)
|
|
119
|
+
return { status: "invalid", diagnostics };
|
|
120
|
+
if (!global.present && !project.present && !directoryProfile.present)
|
|
121
|
+
return { status: "absent" };
|
|
122
|
+
const globalLayer = global.settings ? { settings: global.settings, source: "global" } : undefined;
|
|
123
|
+
const projectLayer = project.settings ? { settings: project.settings, source: "project" } : undefined;
|
|
124
|
+
const directoryLayer = directoryProfile.settings
|
|
125
|
+
? { settings: directoryProfile.settings, source: "directoryProfile" }
|
|
126
|
+
: undefined;
|
|
127
|
+
const byRole = {};
|
|
128
|
+
for (const role of WORKER_ROLES) {
|
|
129
|
+
const pin = pinFromLayer(globalLayer, role) ?? pinFromLocalLayers(directoryLayer, projectLayer, role);
|
|
130
|
+
if (pin)
|
|
131
|
+
byRole[role] = pin;
|
|
132
|
+
}
|
|
133
|
+
return Object.keys(byRole).length > 0 ? { status: "active", byRole } : { status: "absent" };
|
|
134
|
+
}
|
|
135
|
+
export function resolveWorkerModelPin(policy, role) {
|
|
136
|
+
if (policy.status !== "active")
|
|
137
|
+
return undefined;
|
|
138
|
+
const pin = policy.byRole[role];
|
|
139
|
+
return pin ? { binding: cloneBinding(pin.binding), source: pin.source } : undefined;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=worker-model-pins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worker-model-pins.js","sourceRoot":"","sources":["../../../src/core/orchestration/worker-model-pins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EACN,iCAAiC,EACjC,uCAAuC,EACvC,6BAA6B,EAE7B,YAAY,GAEZ,MAAM,gBAAgB,CAAC;AAuCxB,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;AAClD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC;AACvE,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;AACnE,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAEvF,SAAS,YAAY,CAAC,OAAkC;IACvD,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC;AACvB,CAAC;AAED,SAAS,iBAAiB,CAAC,KAA2B,EAAE,IAAY,EAAE,WAAmB;IACxF,OAAO,8BAA8B,IAAI,OAAO,KAAK,kBAAkB,WAAW,EAAE,CAAC;AACtF,CAAC;AAED,SAAS,YAAY,CACpB,KAAc,EACd,KAA2B,EAC3B,IAAY,EACZ,WAAqB;IAErB,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC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AAE,IAAI,CAAC,IAAI,kBAAkB,CAAC,cAAc,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;QACtG,IAAI,GAAG;YAAE,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;IAC7B,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC7F,CAAC;AAED,MAAM,UAAU,qBAAqB,CACpC,MAA4B,EAC5B,IAAgB;IAEhB,IAAI,MAAM,CAAC,MAAM,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IACjD,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACrF,CAAC","sourcesContent":["import { isPlainRecord } from \"../util/value-guards.ts\";\nimport {\n\tMAX_ORCHESTRATION_MODEL_ID_LENGTH,\n\tMAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH,\n\tORCHESTRATION_THINKING_LEVELS,\n\ttype OrchestrationModelBinding,\n\tWORKER_ROLES,\n\ttype WorkerRole,\n} from \"./contracts.ts\";\n\nexport type WorkerModelPinSource = \"global\" | \"project\" | \"directoryProfile\";\n\nexport interface WorkerModelPinsSettings {\n\tdefault?: OrchestrationModelBinding;\n\troles?: Partial<Record<WorkerRole, OrchestrationModelBinding>>;\n}\n\nexport interface ResolvedWorkerModelPin {\n\tbinding: OrchestrationModelBinding;\n\tsource: WorkerModelPinSource;\n}\n\nexport type WorkerModelPinPolicy =\n\t| { status: \"absent\" }\n\t| { status: \"invalid\"; diagnostics: readonly string[] }\n\t| {\n\t\t\tstatus: \"active\";\n\t\t\tbyRole: Readonly<Partial<Record<WorkerRole, ResolvedWorkerModelPin>>>;\n\t };\n\nexport interface WorkerModelPinPolicyLayers {\n\tglobal?: unknown;\n\tproject?: unknown;\n\tdirectoryProfile?: unknown;\n}\n\ninterface NormalizedPinLayer {\n\tsettings: WorkerModelPinsSettings;\n\tsource: WorkerModelPinSource;\n}\n\ninterface ParsedPinLayer {\n\tpresent: boolean;\n\tsettings?: WorkerModelPinsSettings;\n\tdiagnostics: string[];\n}\n\nconst POLICY_KEYS = new Set([\"default\", \"roles\"]);\nconst BINDING_KEYS = new Set([\"provider\", \"modelId\", \"thinkingLevel\"]);\nconst WORKER_ROLE_SET: ReadonlySet<string> = new Set(WORKER_ROLES);\nconst THINKING_LEVEL_SET: ReadonlySet<string> = new Set(ORCHESTRATION_THINKING_LEVELS);\n\nfunction cloneBinding(binding: OrchestrationModelBinding): OrchestrationModelBinding {\n\treturn { ...binding };\n}\n\nfunction bindingDiagnostic(scope: WorkerModelPinSource, path: string, expectation: string): string {\n\treturn `workerDelegation.modelPins.${path} in ${scope} settings must ${expectation}`;\n}\n\nfunction parseBinding(\n\tvalue: unknown,\n\tscope: WorkerModelPinSource,\n\tpath: string,\n\tdiagnostics: string[],\n): OrchestrationModelBinding | undefined {\n\tif (!isPlainRecord(value)) {\n\t\tdiagnostics.push(bindingDiagnostic(scope, path, \"be an object\"));\n\t\treturn undefined;\n\t}\n\tconst unknownKeys = Object.keys(value).filter((key) => !BINDING_KEYS.has(key));\n\tif (unknownKeys.length > 0) {\n\t\tdiagnostics.push(bindingDiagnostic(scope, path, `contain only provider, modelId, and thinkingLevel`));\n\t\treturn undefined;\n\t}\n\tconst provider = typeof value.provider === \"string\" ? value.provider.trim() : \"\";\n\tif (!provider || provider.length > MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH) {\n\t\tdiagnostics.push(\n\t\t\tbindingDiagnostic(\n\t\t\t\tscope,\n\t\t\t\t`${path}.provider`,\n\t\t\t\t`be a nonempty string of at most ${MAX_ORCHESTRATION_MODEL_PROVIDER_LENGTH} characters`,\n\t\t\t),\n\t\t);\n\t}\n\tconst modelId = typeof value.modelId === \"string\" ? value.modelId.trim() : \"\";\n\tif (!modelId || modelId.length > MAX_ORCHESTRATION_MODEL_ID_LENGTH) {\n\t\tdiagnostics.push(\n\t\t\tbindingDiagnostic(\n\t\t\t\tscope,\n\t\t\t\t`${path}.modelId`,\n\t\t\t\t`be a nonempty string of at most ${MAX_ORCHESTRATION_MODEL_ID_LENGTH} characters`,\n\t\t\t),\n\t\t);\n\t}\n\tconst thinkingLevel = value.thinkingLevel;\n\tif (typeof thinkingLevel !== \"string\" || !THINKING_LEVEL_SET.has(thinkingLevel)) {\n\t\tdiagnostics.push(\n\t\t\tbindingDiagnostic(scope, `${path}.thinkingLevel`, `be one of ${ORCHESTRATION_THINKING_LEVELS.join(\", \")}`),\n\t\t);\n\t}\n\tif (!provider || !modelId || typeof thinkingLevel !== \"string\" || !THINKING_LEVEL_SET.has(thinkingLevel)) {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\tprovider,\n\t\tmodelId,\n\t\tthinkingLevel: thinkingLevel as OrchestrationModelBinding[\"thinkingLevel\"],\n\t};\n}\n\nfunction parseLayer(value: unknown, scope: WorkerModelPinSource): ParsedPinLayer {\n\tif (value === undefined) return { present: false, diagnostics: [] };\n\tconst diagnostics: string[] = [];\n\tif (!isPlainRecord(value)) {\n\t\treturn {\n\t\t\tpresent: true,\n\t\t\tdiagnostics: [`workerDelegation.modelPins in ${scope} settings must be an object`],\n\t\t};\n\t}\n\tconst unknownKeys = Object.keys(value).filter((key) => !POLICY_KEYS.has(key));\n\tif (unknownKeys.length > 0) {\n\t\tdiagnostics.push(\n\t\t\t`workerDelegation.modelPins in ${scope} settings contains unknown fields: ${unknownKeys.join(\", \")}`,\n\t\t);\n\t}\n\tconst settings: WorkerModelPinsSettings = {};\n\tif (Object.hasOwn(value, \"default\")) {\n\t\tconst binding = parseBinding(value.default, scope, \"default\", diagnostics);\n\t\tif (binding) settings.default = binding;\n\t}\n\tif (Object.hasOwn(value, \"roles\")) {\n\t\tif (!isPlainRecord(value.roles)) {\n\t\t\tdiagnostics.push(`workerDelegation.modelPins.roles in ${scope} settings must be an object`);\n\t\t} else {\n\t\t\tconst roles: Partial<Record<WorkerRole, OrchestrationModelBinding>> = {};\n\t\t\tfor (const [role, candidate] of Object.entries(value.roles)) {\n\t\t\t\tif (!WORKER_ROLE_SET.has(role)) {\n\t\t\t\t\tdiagnostics.push(`workerDelegation.modelPins.roles in ${scope} settings contains unknown role: ${role}`);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst binding = parseBinding(candidate, scope, `roles.${role}`, diagnostics);\n\t\t\t\tif (binding) roles[role as WorkerRole] = binding;\n\t\t\t}\n\t\t\tsettings.roles = roles;\n\t\t}\n\t}\n\treturn { present: true, settings, diagnostics };\n}\n\nfunction pinFromLayer(layer: NormalizedPinLayer | undefined, role: WorkerRole): ResolvedWorkerModelPin | undefined {\n\tif (!layer) return undefined;\n\tconst binding = layer.settings.roles?.[role] ?? layer.settings.default;\n\treturn binding ? { binding: cloneBinding(binding), source: layer.source } : undefined;\n}\n\nfunction pinFromLocalLayers(\n\tdirectoryLayer: NormalizedPinLayer | undefined,\n\tprojectLayer: NormalizedPinLayer | undefined,\n\trole: WorkerRole,\n): ResolvedWorkerModelPin | undefined {\n\tconst roleLayer = directoryLayer?.settings.roles?.[role]\n\t\t? directoryLayer\n\t\t: projectLayer?.settings.roles?.[role]\n\t\t\t? projectLayer\n\t\t\t: undefined;\n\tconst roleBinding = roleLayer?.settings.roles?.[role];\n\tif (roleLayer && roleBinding) {\n\t\treturn {\n\t\t\tbinding: cloneBinding(roleBinding),\n\t\t\tsource: roleLayer.source,\n\t\t};\n\t}\n\tconst defaultLayer = directoryLayer?.settings.default\n\t\t? directoryLayer\n\t\t: projectLayer?.settings.default\n\t\t\t? projectLayer\n\t\t\t: undefined;\n\treturn defaultLayer?.settings.default\n\t\t? { binding: cloneBinding(defaultLayer.settings.default), source: defaultLayer.source }\n\t\t: undefined;\n}\n\n/** Compile independently validated settings scopes into one immutable admission policy. */\nexport function compileWorkerModelPinPolicy(layers: WorkerModelPinPolicyLayers): WorkerModelPinPolicy {\n\tconst global = parseLayer(layers.global, \"global\");\n\tconst project = parseLayer(layers.project, \"project\");\n\tconst directoryProfile = parseLayer(layers.directoryProfile, \"directoryProfile\");\n\tconst diagnostics = [...global.diagnostics, ...project.diagnostics, ...directoryProfile.diagnostics];\n\tif (diagnostics.length > 0) return { status: \"invalid\", diagnostics };\n\tif (!global.present && !project.present && !directoryProfile.present) return { status: \"absent\" };\n\n\tconst globalLayer = global.settings ? { settings: global.settings, source: \"global\" as const } : undefined;\n\tconst projectLayer = project.settings ? { settings: project.settings, source: \"project\" as const } : undefined;\n\tconst directoryLayer = directoryProfile.settings\n\t\t? { settings: directoryProfile.settings, source: \"directoryProfile\" as const }\n\t\t: undefined;\n\tconst byRole: Partial<Record<WorkerRole, ResolvedWorkerModelPin>> = {};\n\tfor (const role of WORKER_ROLES) {\n\t\tconst pin = pinFromLayer(globalLayer, role) ?? pinFromLocalLayers(directoryLayer, projectLayer, role);\n\t\tif (pin) byRole[role] = pin;\n\t}\n\treturn Object.keys(byRole).length > 0 ? { status: \"active\", byRole } : { status: \"absent\" };\n}\n\nexport function resolveWorkerModelPin(\n\tpolicy: WorkerModelPinPolicy,\n\trole: WorkerRole,\n): ResolvedWorkerModelPin | undefined {\n\tif (policy.status !== \"active\") return undefined;\n\tconst pin = policy.byRole[role];\n\treturn pin ? { binding: cloneBinding(pin.binding), source: pin.source } : undefined;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-builder.d.ts","sourceRoot":"","sources":["../../src/core/runtime-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AA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;YAEa,kBAAkB;YA4ClB,gBAAgB;IAQ9B,OAAO,CAAC,2BAA2B;YAMrB,4BAA4B;IAQ1C;;;;OAIG;IACG,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC,CA+C/C;CACD;AAED,wBAAsB,iBAAiB,CACtC,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,gBAAgB,GAAE,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,OAAqB,EAC9D,oBAAoB,CAAC,EAAE,OAAO;;;;;;;;;;;;GAuD9B"}
|
|
@@ -658,6 +658,7 @@ export class RuntimeBuilder {
|
|
|
658
658
|
startWorkerDelegation: (args) => this.deps.startWorkerDelegation(args),
|
|
659
659
|
runWorkerDelegation: (args) => this.deps.runWorkerDelegationOnce(args),
|
|
660
660
|
orchestrationProfiles: this.deps.getOrchestrationProfileCatalog(),
|
|
661
|
+
workerModelPinPolicy: settingsManager.getWorkerModelPinPolicy(),
|
|
661
662
|
...(workerAgentControl ? { workerAgentControl } : {}),
|
|
662
663
|
status: {
|
|
663
664
|
getLaneRecords: () => this.deps.getWorkerLaneRecords(),
|