@cat-factory/orchestration 0.123.3 → 0.123.4
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/modules/observability/AgentContextObservabilityService.d.ts +24 -2
- package/dist/modules/observability/AgentContextObservabilityService.d.ts.map +1 -1
- package/dist/modules/observability/AgentContextObservabilityService.js +39 -7
- package/dist/modules/observability/AgentContextObservabilityService.js.map +1 -1
- package/package.json +11 -11
|
@@ -16,6 +16,14 @@ export declare const MAX_AGENT_CONTEXT_CHARS: number;
|
|
|
16
16
|
* prompts first), so the most useful context survives when the budget is reached.
|
|
17
17
|
*/
|
|
18
18
|
export declare const MAX_AGENT_CONTEXT_TOTAL_CHARS: number;
|
|
19
|
+
/**
|
|
20
|
+
* Stored in place of a secret-bearing file's body. A file whose NAME marks it as a raw
|
|
21
|
+
* credential store (`.env`, `*.pem`, an SSH key, `.npmrc`, …) has no field-name/URL
|
|
22
|
+
* scaffolding for {@link redactSecrets}'s pattern rules to latch onto — a bare PEM block or
|
|
23
|
+
* a `KEY=value` dump would pass through the shape scrub verbatim — so its whole body is
|
|
24
|
+
* dropped rather than persisted.
|
|
25
|
+
*/
|
|
26
|
+
export declare const SECRET_FILE_PLACEHOLDER = "[REDACTED: secret-shaped file omitted from snapshot]";
|
|
19
27
|
export interface AgentContextObservabilityServiceDependencies {
|
|
20
28
|
agentContextSnapshotRepository: AgentContextSnapshotRepository;
|
|
21
29
|
workspaceSettingsRepository: WorkspaceSettingsRepository;
|
|
@@ -53,8 +61,22 @@ export declare class AgentContextObservabilityService implements AgentContextRec
|
|
|
53
61
|
/**
|
|
54
62
|
* Persist one dispatch's context, assigning its id + timestamp. Returns without
|
|
55
63
|
* storing when prompt recording is disabled deployment-wide or the workspace has
|
|
56
|
-
* turned `storeAgentContext` off.
|
|
57
|
-
*
|
|
64
|
+
* turned `storeAgentContext` off.
|
|
65
|
+
*
|
|
66
|
+
* Every stored body is a defence-in-depth SECRET SCRUB before it lands in the telemetry
|
|
67
|
+
* store: prompts, fragment bodies and injected file contents run through
|
|
68
|
+
* {@link redactSecrets} (a value the dispatch site's allow-list can't fully guarantee is
|
|
69
|
+
* clean — a task description, a linked doc, or an injected file may embed a token), and a
|
|
70
|
+
* file whose NAME marks it as a raw credential store ({@link isSecretShapedFilename}) has
|
|
71
|
+
* its whole body dropped ({@link SECRET_FILE_PLACEHOLDER}), since a bare PEM/`.env` body
|
|
72
|
+
* has no scaffolding for the shape rules to catch. Scrub happens BEFORE the size budget so
|
|
73
|
+
* truncation can never split a secret across the cap and defeat the pattern match. Bodies
|
|
74
|
+
* are then clamped so an oversized prompt/file never drops the whole snapshot.
|
|
75
|
+
*
|
|
76
|
+
* The `extras` bag is deep-scrubbed too ({@link redactSecretsDeep}): several of its values
|
|
77
|
+
* are human-authored free text (the run's decisions, revision feedback) — the SAME token-
|
|
78
|
+
* in-prose risk as a task description — so every string it carries at any depth is scrubbed
|
|
79
|
+
* rather than trusting the dispatch-site allow-list to have kept it clean.
|
|
58
80
|
*/
|
|
59
81
|
record(input: RecordAgentContextInput): Promise<void>;
|
|
60
82
|
/** Snapshots recorded for a run, newest first (for the observability drill-down). */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentContextObservabilityService.d.ts","sourceRoot":"","sources":["../../../src/modules/observability/AgentContextObservabilityService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,8BAA8B,EAC9B,KAAK,EACL,WAAW,EACX,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"AgentContextObservabilityService.d.ts","sourceRoot":"","sources":["../../../src/modules/observability/AgentContextObservabilityService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,8BAA8B,EAC9B,KAAK,EACL,WAAW,EACX,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,q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2
|
/**
|
|
3
3
|
* Defensive upper bound (characters) on any single stored body — a prompt or one
|
|
4
4
|
* injected file. Real agent context sits far below this; the cap exists only so a
|
|
@@ -21,6 +21,14 @@ function clamp(text) {
|
|
|
21
21
|
return text;
|
|
22
22
|
return `${text.slice(0, MAX_AGENT_CONTEXT_CHARS)}\n…[truncated ${text.length - MAX_AGENT_CONTEXT_CHARS} chars]`;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Stored in place of a secret-bearing file's body. A file whose NAME marks it as a raw
|
|
26
|
+
* credential store (`.env`, `*.pem`, an SSH key, `.npmrc`, …) has no field-name/URL
|
|
27
|
+
* scaffolding for {@link redactSecrets}'s pattern rules to latch onto — a bare PEM block or
|
|
28
|
+
* a `KEY=value` dump would pass through the shape scrub verbatim — so its whole body is
|
|
29
|
+
* dropped rather than persisted.
|
|
30
|
+
*/
|
|
31
|
+
export const SECRET_FILE_PLACEHOLDER = '[REDACTED: secret-shaped file omitted from snapshot]';
|
|
24
32
|
/**
|
|
25
33
|
* A shared character budget for one snapshot. Each call first applies the per-body cap,
|
|
26
34
|
* then trims against the remaining aggregate budget — so the bodies passed earlier (the
|
|
@@ -71,8 +79,22 @@ export class AgentContextObservabilityService {
|
|
|
71
79
|
/**
|
|
72
80
|
* Persist one dispatch's context, assigning its id + timestamp. Returns without
|
|
73
81
|
* storing when prompt recording is disabled deployment-wide or the workspace has
|
|
74
|
-
* turned `storeAgentContext` off.
|
|
75
|
-
*
|
|
82
|
+
* turned `storeAgentContext` off.
|
|
83
|
+
*
|
|
84
|
+
* Every stored body is a defence-in-depth SECRET SCRUB before it lands in the telemetry
|
|
85
|
+
* store: prompts, fragment bodies and injected file contents run through
|
|
86
|
+
* {@link redactSecrets} (a value the dispatch site's allow-list can't fully guarantee is
|
|
87
|
+
* clean — a task description, a linked doc, or an injected file may embed a token), and a
|
|
88
|
+
* file whose NAME marks it as a raw credential store ({@link isSecretShapedFilename}) has
|
|
89
|
+
* its whole body dropped ({@link SECRET_FILE_PLACEHOLDER}), since a bare PEM/`.env` body
|
|
90
|
+
* has no scaffolding for the shape rules to catch. Scrub happens BEFORE the size budget so
|
|
91
|
+
* truncation can never split a secret across the cap and defeat the pattern match. Bodies
|
|
92
|
+
* are then clamped so an oversized prompt/file never drops the whole snapshot.
|
|
93
|
+
*
|
|
94
|
+
* The `extras` bag is deep-scrubbed too ({@link redactSecretsDeep}): several of its values
|
|
95
|
+
* are human-authored free text (the run's decisions, revision feedback) — the SAME token-
|
|
96
|
+
* in-prose risk as a task description — so every string it carries at any depth is scrubbed
|
|
97
|
+
* rather than trusting the dispatch-site allow-list to have kept it clean.
|
|
76
98
|
*/
|
|
77
99
|
async record(input) {
|
|
78
100
|
if (!this.recordPrompts)
|
|
@@ -82,14 +104,24 @@ export class AgentContextObservabilityService {
|
|
|
82
104
|
// One shared budget per snapshot, consumed prompts-first so the most useful context
|
|
83
105
|
// survives if a dispatch injects an unusual amount of file content.
|
|
84
106
|
const budget = makeBudget();
|
|
107
|
+
// Scrub credentials, THEN clamp — a truncated body must never hide a half-cut secret.
|
|
108
|
+
const scrub = (text) => budget(redactSecrets(text) ?? '');
|
|
85
109
|
const snapshot = {
|
|
86
110
|
...input,
|
|
87
111
|
id: this.idGenerator.next('ctx'),
|
|
88
112
|
createdAt: this.clock.now(),
|
|
89
|
-
systemPrompt:
|
|
90
|
-
userPrompt:
|
|
91
|
-
fragments: input.fragments.map((f) => ({ id: f.id, body:
|
|
92
|
-
contextFiles: input.contextFiles.map((f) => ({
|
|
113
|
+
systemPrompt: scrub(input.systemPrompt),
|
|
114
|
+
userPrompt: scrub(input.userPrompt),
|
|
115
|
+
fragments: input.fragments.map((f) => ({ id: f.id, body: scrub(f.body) })),
|
|
116
|
+
contextFiles: input.contextFiles.map((f) => ({
|
|
117
|
+
...f,
|
|
118
|
+
content: isSecretShapedFilename(f.path)
|
|
119
|
+
? budget(SECRET_FILE_PLACEHOLDER)
|
|
120
|
+
: scrub(f.content),
|
|
121
|
+
})),
|
|
122
|
+
// Structural bits, but some values (decisions, revision feedback) are free-text prose
|
|
123
|
+
// that can embed a token — scrub every string in the bag, not just the known bodies.
|
|
124
|
+
extras: redactSecretsDeep(input.extras),
|
|
93
125
|
};
|
|
94
126
|
await this.repository.record(snapshot);
|
|
95
127
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentContextObservabilityService.js","sourceRoot":"","sources":["../../../src/modules/observability/AgentContextObservabilityService.ts"],"names":[],"mappings":"AASA,OAAO,
|
|
1
|
+
{"version":3,"file":"AgentContextObservabilityService.js","sourceRoot":"","sources":["../../../src/modules/observability/AgentContextObservabilityService.ts"],"names":[],"mappings":"AASA,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACtB,aAAa,EACb,iBAAiB,GAClB,MAAM,qBAAqB,CAAA;AAE5B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,GAAG,IAAI,CAAA;AAEjD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;AAE5D,SAAS,KAAK,CAAC,IAAY;IACzB,IAAI,IAAI,CAAC,MAAM,IAAI,uBAAuB;QAAE,OAAO,IAAI,CAAA;IACvD,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,uBAAuB,CAAC,iBAAiB,IAAI,CAAC,MAAM,GAAG,uBAAuB,SAAS,CAAA;AACjH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,sDAAsD,CAAA;AAE7F;;;;;;GAMG;AACH,SAAS,UAAU,CAAC,KAAK,GAAG,6BAA6B;IACvD,IAAI,SAAS,GAAG,KAAK,CAAA;IACrB,OAAO,CAAC,IAAY,EAAU,EAAE;QAC9B,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAA;QAC1B,IAAI,MAAM,CAAC,MAAM,IAAI,SAAS,EA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A;IACnC,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cat-factory/orchestration",
|
|
3
|
-
"version": "0.123.
|
|
3
|
+
"version": "0.123.4",
|
|
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,20 +25,20 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"ai": "^6.0.230",
|
|
28
|
-
"@cat-factory/agents": "0.62.
|
|
29
|
-
"@cat-factory/caching": "0.10.
|
|
30
|
-
"@cat-factory/contracts": "0.148.
|
|
31
|
-
"@cat-factory/integrations": "0.86.
|
|
32
|
-
"@cat-factory/kernel": "0.
|
|
33
|
-
"@cat-factory/prompt-fragments": "0.13.
|
|
34
|
-
"@cat-factory/sandbox": "0.9.
|
|
35
|
-
"@cat-factory/spend": "0.12.
|
|
36
|
-
"@cat-factory/workspaces": "0.16.
|
|
28
|
+
"@cat-factory/agents": "0.62.12",
|
|
29
|
+
"@cat-factory/caching": "0.10.9",
|
|
30
|
+
"@cat-factory/contracts": "0.148.1",
|
|
31
|
+
"@cat-factory/integrations": "0.86.4",
|
|
32
|
+
"@cat-factory/kernel": "0.140.0",
|
|
33
|
+
"@cat-factory/prompt-fragments": "0.13.39",
|
|
34
|
+
"@cat-factory/sandbox": "0.9.103",
|
|
35
|
+
"@cat-factory/spend": "0.12.53",
|
|
36
|
+
"@cat-factory/workspaces": "0.16.6"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"typescript": "7.0.2",
|
|
40
40
|
"vitest": "^4.1.10",
|
|
41
|
-
"@cat-factory/sandbox-fixtures": "0.7.
|
|
41
|
+
"@cat-factory/sandbox-fixtures": "0.7.174"
|
|
42
42
|
},
|
|
43
43
|
"scripts": {
|
|
44
44
|
"build": "tsc -b tsconfig.build.json",
|