@cat-factory/orchestration 0.21.1 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/container.d.ts +9 -1
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +22 -3
- package/dist/container.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/execution/ExecutionService.d.ts +10 -0
- package/dist/modules/execution/ExecutionService.d.ts.map +1 -1
- package/dist/modules/execution/ExecutionService.js +86 -2
- package/dist/modules/execution/ExecutionService.js.map +1 -1
- package/dist/validation/validateRegistrations.d.ts +42 -0
- package/dist/validation/validateRegistrations.d.ts.map +1 -0
- package/dist/validation/validateRegistrations.js +150 -0
- package/dist/validation/validateRegistrations.js.map +1 -0
- package/package.json +9 -9
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { registeredAgentKinds, registeredKindRequiresContainer, registeredStructuredOutput, } from '@cat-factory/agents';
|
|
2
|
+
import { CI_FIXER_AGENT_KIND, CONFLICT_RESOLVER_AGENT_KIND, ON_CALL_AGENT_KIND, registeredGateFactories, registeredPipelines, stubGateContext, } from '@cat-factory/kernel';
|
|
3
|
+
import { RESULT_VIEW_ID_SET } from '@cat-factory/contracts';
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
// Boot-time validation of the deployment's registered extensions (agent kinds, gates,
|
|
6
|
+
// pipelines). A typo'd gate `helperKind`, an unknown `resultView`, or a pipeline naming a
|
|
7
|
+
// kind that doesn't exist used to surface mid-run (a failed dispatch) or silently (a prose
|
|
8
|
+
// fallback). `validateRegistrations()` turns those into a LOUD startup error instead — a
|
|
9
|
+
// facade calls it once after all `register*` side-effect imports + provider wiring, before
|
|
10
|
+
// serving, so a misconfigured deployment fails fast at boot.
|
|
11
|
+
//
|
|
12
|
+
// This lives in orchestration because it cross-checks the gate registry (kernel) against the
|
|
13
|
+
// agent-kind registry (@cat-factory/agents) and the pipeline registry — only orchestration
|
|
14
|
+
// depends on all three.
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
/** Built-in container helper kinds a gate may escalate to (handled by the executor/harness,
|
|
17
|
+
* not the custom-kind registry). A gate `helperKind` is valid if it's one of these or a
|
|
18
|
+
* registered container-capable kind. */
|
|
19
|
+
const BUILT_IN_HELPER_KINDS = new Set([
|
|
20
|
+
CI_FIXER_AGENT_KIND,
|
|
21
|
+
CONFLICT_RESOLVER_AGENT_KIND,
|
|
22
|
+
ON_CALL_AGENT_KIND,
|
|
23
|
+
]);
|
|
24
|
+
/**
|
|
25
|
+
* Collect every registration problem (does not throw). Useful for tests and for callers that
|
|
26
|
+
* want to log warnings without aborting. {@link validateRegistrations} throws on any `error`.
|
|
27
|
+
*/
|
|
28
|
+
export function collectRegistrationProblems(opts = {}) {
|
|
29
|
+
const knownResultViewIds = opts.knownResultViewIds ?? RESULT_VIEW_ID_SET;
|
|
30
|
+
const builtInHelperKinds = opts.builtInHelperKinds ?? BUILT_IN_HELPER_KINDS;
|
|
31
|
+
const problems = [];
|
|
32
|
+
const agentKinds = registeredAgentKinds();
|
|
33
|
+
const registeredKindIds = new Set(agentKinds.map((d) => d.kind));
|
|
34
|
+
const gateKinds = new Set(registeredGateFactories().map((g) => g.kind));
|
|
35
|
+
// 1. Every gate's helperKind must resolve to a registered container-capable kind or a
|
|
36
|
+
// built-in helper. The factory is a pure constructor, so we build it with a stub context
|
|
37
|
+
// just to read its declared helperKind.
|
|
38
|
+
for (const { kind, factory } of registeredGateFactories()) {
|
|
39
|
+
let helperKind;
|
|
40
|
+
try {
|
|
41
|
+
helperKind = factory(stubGateContext()).helperKind;
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
problems.push({
|
|
45
|
+
severity: 'error',
|
|
46
|
+
code: 'gate_factory_threw',
|
|
47
|
+
message: `Gate "${kind}" factory threw while validating: ${err.message}`,
|
|
48
|
+
});
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const helperOk = builtInHelperKinds.has(helperKind) ||
|
|
52
|
+
(registeredKindIds.has(helperKind) && registeredKindRequiresContainer(helperKind));
|
|
53
|
+
if (!helperOk) {
|
|
54
|
+
problems.push({
|
|
55
|
+
severity: 'error',
|
|
56
|
+
code: 'gate_helper_unresolved',
|
|
57
|
+
message: `Gate "${kind}" escalates to helperKind "${helperKind}", which is neither a ` +
|
|
58
|
+
`built-in helper nor a registered container-capable agent kind. Register the helper ` +
|
|
59
|
+
`(a container surface) or fix the helperKind.`,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// 2. Every registered kind's presentation.resultView must be a known view id (else the SPA
|
|
64
|
+
// silently falls back to prose).
|
|
65
|
+
for (const def of agentKinds) {
|
|
66
|
+
const resultView = def.presentation?.resultView;
|
|
67
|
+
if (resultView !== undefined && !knownResultViewIds.has(resultView)) {
|
|
68
|
+
problems.push({
|
|
69
|
+
severity: 'error',
|
|
70
|
+
code: 'unknown_result_view',
|
|
71
|
+
message: `Agent kind "${def.kind}" declares resultView "${resultView}", which is not a known ` +
|
|
72
|
+
`result view. Use one of: ${[...knownResultViewIds].join(', ')}.`,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
// 3. Coherence (warn): a kind with postOps that has an agent step which is NOT structured
|
|
77
|
+
// output likely can't feed those post-ops from `result.custom`. Heuristic, so a warning.
|
|
78
|
+
for (const def of agentKinds) {
|
|
79
|
+
const hasPostOps = (def.postOps?.length ?? 0) > 0;
|
|
80
|
+
const declaresStructured = def.agent?.output?.kind === 'structured' || registeredStructuredOutput(def.kind) !== undefined;
|
|
81
|
+
if (hasPostOps && def.agent && !declaresStructured) {
|
|
82
|
+
problems.push({
|
|
83
|
+
severity: 'warn',
|
|
84
|
+
code: 'postops_without_structured_output',
|
|
85
|
+
message: `Agent kind "${def.kind}" declares postOps but its agent step has no structured ` +
|
|
86
|
+
`output — postOps that read result.custom will see nothing. Declare structuredOutput ` +
|
|
87
|
+
`(or agent.output.kind: 'structured') if the post-op consumes the agent's JSON.`,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// 4. Pipeline kinds (only when a built-in catalog is supplied — see option doc).
|
|
92
|
+
if (opts.knownAgentKinds) {
|
|
93
|
+
const known = opts.knownAgentKinds;
|
|
94
|
+
for (const pipeline of registeredPipelines()) {
|
|
95
|
+
for (const agentKind of pipeline.agentKinds) {
|
|
96
|
+
const ok = known.has(agentKind) ||
|
|
97
|
+
registeredKindIds.has(agentKind) ||
|
|
98
|
+
gateKinds.has(agentKind) ||
|
|
99
|
+
builtInHelperKinds.has(agentKind);
|
|
100
|
+
if (!ok) {
|
|
101
|
+
problems.push({
|
|
102
|
+
severity: 'error',
|
|
103
|
+
code: 'pipeline_unknown_kind',
|
|
104
|
+
message: `Pipeline "${pipeline.id}" references agent kind "${agentKind}", which is not a ` +
|
|
105
|
+
`known built-in, a registered kind, or a registered gate.`,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return problems;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Validate the registered extensions, throwing an aggregated error on any `error`-severity
|
|
115
|
+
* problem and logging `warn`-severity ones. Call once at facade boot, after every `register*`
|
|
116
|
+
* import side effect + provider wiring, before serving requests.
|
|
117
|
+
*/
|
|
118
|
+
export function validateRegistrations(opts = {}) {
|
|
119
|
+
const problems = collectRegistrationProblems(opts);
|
|
120
|
+
if (opts.onWarn) {
|
|
121
|
+
for (const w of problems.filter((p) => p.severity === 'warn'))
|
|
122
|
+
opts.onWarn(w);
|
|
123
|
+
}
|
|
124
|
+
const errors = problems.filter((p) => p.severity === 'error');
|
|
125
|
+
if (errors.length > 0) {
|
|
126
|
+
throw new Error(`Invalid extension registrations (${errors.length}):\n` +
|
|
127
|
+
errors.map((e) => ` - [${e.code}] ${e.message}`).join('\n'));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// A module-level guard so a per-request facade build (the Worker rebuilds its container per
|
|
131
|
+
// request) validates ONCE rather than on every request. Tests that intentionally register
|
|
132
|
+
// bogus kinds call `collectRegistrationProblems`/`validateRegistrations` directly instead.
|
|
133
|
+
let validated = false;
|
|
134
|
+
/** Run {@link validateRegistrations} at most once per process. Safe to call from a per-request build. */
|
|
135
|
+
export function validateRegistrationsOnce(opts = {}) {
|
|
136
|
+
if (validated)
|
|
137
|
+
return;
|
|
138
|
+
// Flip the guard only AFTER a clean validation. Setting it first would poison the guard on a
|
|
139
|
+
// throw: on the Worker (where this runs inside `fetch` on the first request) a misconfigured
|
|
140
|
+
// deployment would 500 exactly once, then — the module flag now `true` for the isolate's life —
|
|
141
|
+
// serve the broken config silently on every later request. Validating until it passes keeps the
|
|
142
|
+
// failure loud (every request re-throws) until the deployment is fixed, matching the boot intent.
|
|
143
|
+
validateRegistrations(opts);
|
|
144
|
+
validated = true;
|
|
145
|
+
}
|
|
146
|
+
/** Reset the once-guard. Intended for tests that exercise the boot path repeatedly. */
|
|
147
|
+
export function resetRegistrationValidationGuard() {
|
|
148
|
+
validated = false;
|
|
149
|
+
}
|
|
150
|
+
//# sourceMappingURL=validateRegistrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateRegistrations.js","sourceRoot":"","sources":["../../src/validation/validateRegistrations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,+BAA+B,EAC/B,0BAA0B,GAC3B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,mBAAmB,EACnB,4BAA4B,EAC5B,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,GAChB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAE3D,8EAA8E;AAC9E,sFAAsF;AACtF,0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,EAAE,CAAC;QAChB,KAAK,MAAM,CAAC,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC;YAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;IAC/E,CAAC;IACD,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAA;IAC7D,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,oCAAoC,MAAM,CAAC,MAAM,MAAM;YACrD,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAC/D,CAAA;IACH,CAAC;AACH,CAAC;AAED,4FAA4F;AAC5F,0FAA0F;AAC1F,2FAA2F;AAC3F,IAAI,SAAS,GAAG,KAAK,CAAA;AAErB,yGAAyG;AACzG,MAAM,UAAU,yBAAyB,CAAC,IAAI,GAAiC,EAAE;IAC/E,IAAI,SAAS;QAAE,OAAM;IACrB,6FAA6F;IAC7F,6FAA6F;IAC7F,gGAAgG;IAChG,gGAAgG;IAChG,kGAAkG;IAClG,qBAAqB,CAAC,IAAI,CAAC,CAAA;IAC3B,SAAS,GAAG,IAAI,CAAA;AAClB,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,gCAAgC;IAC9C,SAAS,GAAG,KAAK,CAAA;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cat-factory/orchestration",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "Delivery-workflow engine for the Agent Architecture Board (execution, bootstrap, pipelines, board, boardScan, requirements, and composition root).",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"ai": "^6.0.209",
|
|
28
|
-
"@cat-factory/agents": "0.
|
|
29
|
-
"@cat-factory/contracts": "0.
|
|
30
|
-
"@cat-factory/integrations": "0.
|
|
31
|
-
"@cat-factory/kernel": "0.
|
|
32
|
-
"@cat-factory/prompt-fragments": "0.7.
|
|
33
|
-
"@cat-factory/sandbox": "0.8.
|
|
34
|
-
"@cat-factory/spend": "0.9.
|
|
35
|
-
"@cat-factory/workspaces": "0.7.
|
|
28
|
+
"@cat-factory/agents": "0.15.0",
|
|
29
|
+
"@cat-factory/contracts": "0.27.0",
|
|
30
|
+
"@cat-factory/integrations": "0.21.1",
|
|
31
|
+
"@cat-factory/kernel": "0.30.0",
|
|
32
|
+
"@cat-factory/prompt-fragments": "0.7.25",
|
|
33
|
+
"@cat-factory/sandbox": "0.8.3",
|
|
34
|
+
"@cat-factory/spend": "0.9.4",
|
|
35
|
+
"@cat-factory/workspaces": "0.7.37"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"typescript": "7.0.1-rc",
|