@cat-factory/kernel 0.283.0 → 0.285.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/domain/design-image-delivery.d.ts +128 -0
- package/dist/domain/design-image-delivery.d.ts.map +1 -0
- package/dist/domain/design-image-delivery.js +83 -0
- package/dist/domain/design-image-delivery.js.map +1 -0
- package/dist/domain/harness-capabilities.d.ts +7 -5
- package/dist/domain/harness-capabilities.d.ts.map +1 -1
- package/dist/domain/harness-capabilities.js +28 -8
- package/dist/domain/harness-capabilities.js.map +1 -1
- package/dist/domain/models.d.ts +2 -0
- package/dist/domain/models.d.ts.map +1 -1
- package/dist/domain/models.js +68 -11
- package/dist/domain/models.js.map +1 -1
- package/dist/domain/types.d.ts +40 -0
- package/dist/domain/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/ports/agent-executor.d.ts +39 -8
- package/dist/ports/agent-executor.d.ts.map +1 -1
- package/dist/ports/agent-executor.js.map +1 -1
- package/dist/ports/model-provider.d.ts +14 -0
- package/dist/ports/model-provider.d.ts.map +1 -1
- package/dist/ports/model-provider.js.map +1 -1
- package/dist/ports/pr-mergeability.d.ts +9 -1
- package/dist/ports/pr-mergeability.d.ts.map +1 -1
- package/dist/ports/pr-merger.d.ts +5 -2
- package/dist/ports/pr-merger.d.ts.map +1 -1
- package/dist/ports/pr-report.d.ts +10 -3
- package/dist/ports/pr-report.d.ts.map +1 -1
- package/dist/ports/runner-transport.d.ts +5 -1
- package/dist/ports/runner-transport.d.ts.map +1 -1
- package/dist/shared/redact-image-payloads.logic.d.ts +14 -0
- package/dist/shared/redact-image-payloads.logic.d.ts.map +1 -0
- package/dist/shared/redact-image-payloads.logic.js +100 -0
- package/dist/shared/redact-image-payloads.logic.js.map +1 -0
- package/package.json +2 -2
|
@@ -90,10 +90,14 @@ export interface RunnerJobResult {
|
|
|
90
90
|
* phase 3): one per involved-service repo it actually changed, beside the own-service
|
|
91
91
|
* `prUrl`/`branch`. The executor's `toRunResult` lifts these onto `AgentRunResult`. Absent
|
|
92
92
|
* for a single-repo run.
|
|
93
|
+
*
|
|
94
|
+
* `frameIds` echoes back the involved frames the DISPATCH attributed to that checkout: the
|
|
95
|
+
* fan-out clones one checkout per repo, so a monorepo hosting several of the run's involved
|
|
96
|
+
* services yields ONE pull request carrying all of their frames.
|
|
93
97
|
*/
|
|
94
98
|
peerPullRequests?: {
|
|
95
99
|
repo: string;
|
|
96
|
-
|
|
100
|
+
frameIds?: string[];
|
|
97
101
|
prUrl: string;
|
|
98
102
|
branch: string;
|
|
99
103
|
}[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner-transport.d.ts","sourceRoot":"","sources":["../../src/ports/runner-transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACnF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAyB/D,oFAAoF;AACpF,MAAM,MAAM,iBAAiB,GAAG,YAAY,CAAA;AAE5C;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,qBAAqB,GAAG,OAAO,GAAG,WAAW,CAAA;AAEzD;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,iDAAiD,CAAA;AAEtF;;;;GAIG;AACH,UAAU,iBAAiB;IACzB,IAAI,EAAE,WAAW,GAAG,UAAU,CAAA;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB;AAED;;;;;;;;;;GAUG;AACH,MAAM,W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E,OAAO,CAAC,EAC7B,IAAI,CAAC,EAAE,kBAAkB,EACzB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAA;IACpC,oCAAoC;IACpC,IAAI,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,CAAA;IAC/C;;;;;;;;;;OAUG;IACH,OAAO,CAAC,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1C;;;;;;;;;;;;OAYG;IACH,OAAO,CAAC,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAA;CAC3D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Replace every binary payload in a model-message body with a description of itself.
|
|
3
|
+
*
|
|
4
|
+
* Structure-preserving and TYPE-agnostic: it walks arrays and plain objects and rewrites only the
|
|
5
|
+
* values that ARE payloads, so the caller keeps serialising whatever shape its own SDK produced and
|
|
6
|
+
* this stays correct across the two (and any third) message vocabularies. A value it does not
|
|
7
|
+
* recognise is returned untouched, because the alternative — guessing at a shape — would redact a
|
|
8
|
+
* field of ordinary prose the moment a vocabulary grew one.
|
|
9
|
+
*
|
|
10
|
+
* Never throws and never mutates its input: a recording path must not be able to fail the call it
|
|
11
|
+
* is recording, and the body it was handed is the one being sent.
|
|
12
|
+
*/
|
|
13
|
+
export declare function redactImagePayloads<T>(value: T): T;
|
|
14
|
+
//# sourceMappingURL=redact-image-payloads.logic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact-image-payloads.logic.d.ts","sourceRoot":"","sources":["../../src/shared/redact-image-payloads.logic.ts"],"names":[],"mappings":"AAkCA;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAElD"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Keep IMAGE BYTES out of a recorded prompt body.
|
|
3
|
+
//
|
|
4
|
+
// Every path that records what a model was sent serialises the message array as JSON, and that was
|
|
5
|
+
// safe for exactly as long as a message was text. A multimodal turn carries a whole PNG in a
|
|
6
|
+
// content part, in one of two shapes depending on who composed it: a `Uint8Array` on an inline
|
|
7
|
+
// call through the AI SDK, or a `data:` URL on an OpenAI-shape request through the LLM proxy. Both
|
|
8
|
+
// are catastrophic to serialise verbatim — a typed array JSON-stringifies to one object ENTRY PER
|
|
9
|
+
// BYTE, so a half-megabyte design frame lands as several megabytes of `{"0":137,"1":80,…}` in the
|
|
10
|
+
// telemetry store, on every turn of the run that carried it.
|
|
11
|
+
//
|
|
12
|
+
// So a body is walked before it is serialised and each payload is replaced by a DESCRIPTION of
|
|
13
|
+
// itself. Stating it rather than deleting the part is the point: a reader of the recorded prompt
|
|
14
|
+
// has to be able to tell a turn that carried a picture from one that did not, and a silently
|
|
15
|
+
// removed part reads as the second.
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
/** The `data:` URL prefix an OpenAI-shape `image_url` part carries a picture in. */
|
|
18
|
+
const DATA_URL = /^data:([\w.+-]+\/[\w.+-]+)?(;[\w-]+=[\w-]+)*(;base64)?,/i;
|
|
19
|
+
/**
|
|
20
|
+
* How long a plain string may be before it is treated as an inlined payload rather than a URL.
|
|
21
|
+
*
|
|
22
|
+
* A remote `image_url` is a link and belongs in the record verbatim: it is how a reader finds the
|
|
23
|
+
* picture again. Only a `data:` URL carries the bytes, and this bound is the backstop for a
|
|
24
|
+
* producer that inlines one some other way (a bare base64 blob), sized well above any real URL.
|
|
25
|
+
*/
|
|
26
|
+
const MAX_INLINE_STRING = 2048;
|
|
27
|
+
/** A payload's stand-in: what it was and how big, never any of it. */
|
|
28
|
+
function describePayload(bytes, mediaType) {
|
|
29
|
+
return `<binary ${mediaType ?? 'payload'} withheld: ${bytes} bytes>`;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Replace every binary payload in a model-message body with a description of itself.
|
|
33
|
+
*
|
|
34
|
+
* Structure-preserving and TYPE-agnostic: it walks arrays and plain objects and rewrites only the
|
|
35
|
+
* values that ARE payloads, so the caller keeps serialising whatever shape its own SDK produced and
|
|
36
|
+
* this stays correct across the two (and any third) message vocabularies. A value it does not
|
|
37
|
+
* recognise is returned untouched, because the alternative — guessing at a shape — would redact a
|
|
38
|
+
* field of ordinary prose the moment a vocabulary grew one.
|
|
39
|
+
*
|
|
40
|
+
* Never throws and never mutates its input: a recording path must not be able to fail the call it
|
|
41
|
+
* is recording, and the body it was handed is the one being sent.
|
|
42
|
+
*/
|
|
43
|
+
export function redactImagePayloads(value) {
|
|
44
|
+
return walk(value, 0);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Depth is bounded because this runs on the hot path of every recorded call over a body the
|
|
48
|
+
* platform did not author (the proxy forwards whatever the agent CLI sent). A body nested past the
|
|
49
|
+
* bound is returned as-is rather than descended into: the payloads it could still hide are the same
|
|
50
|
+
* ones every real vocabulary puts within a few levels of the root.
|
|
51
|
+
*/
|
|
52
|
+
const MAX_DEPTH = 8;
|
|
53
|
+
function walk(value, depth) {
|
|
54
|
+
if (depth > MAX_DEPTH)
|
|
55
|
+
return value;
|
|
56
|
+
if (Array.isArray(value))
|
|
57
|
+
return value.map((entry) => walk(entry, depth + 1));
|
|
58
|
+
if (value instanceof Uint8Array)
|
|
59
|
+
return describePayload(value.byteLength);
|
|
60
|
+
if (value instanceof ArrayBuffer)
|
|
61
|
+
return describePayload(value.byteLength);
|
|
62
|
+
if (typeof value === 'string')
|
|
63
|
+
return redactDataUrl(value);
|
|
64
|
+
if (typeof value !== 'object' || value === null)
|
|
65
|
+
return value;
|
|
66
|
+
// Only PLAIN objects are descended into. Anything with a prototype of its own (the AI SDK also
|
|
67
|
+
// accepts a `URL` beside raw bytes, and a Buffer is a Uint8Array subclass caught above) is
|
|
68
|
+
// returned as-is: a walk would rebuild it as a bare object and change what gets serialised.
|
|
69
|
+
const proto = Object.getPrototypeOf(value);
|
|
70
|
+
if (proto !== Object.prototype && proto !== null)
|
|
71
|
+
return value;
|
|
72
|
+
const out = {};
|
|
73
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
74
|
+
out[key] = walk(entry, depth + 1);
|
|
75
|
+
}
|
|
76
|
+
return out;
|
|
77
|
+
}
|
|
78
|
+
/** A `data:` URL (or an over-long inline blob) described; anything else returned unchanged. */
|
|
79
|
+
function redactDataUrl(value) {
|
|
80
|
+
const match = DATA_URL.exec(value);
|
|
81
|
+
if (match) {
|
|
82
|
+
// The byte count is of the ENCODED payload. Reporting the decoded size would mean decoding it,
|
|
83
|
+
// which is the work this function exists to avoid, and the number is only ever read as a scale.
|
|
84
|
+
return describePayload(value.length - match[0].length, match[1]);
|
|
85
|
+
}
|
|
86
|
+
return value.length > MAX_INLINE_STRING && !/^https?:\/\//i.test(value) && isBase64ish(value)
|
|
87
|
+
? describePayload(value.length)
|
|
88
|
+
: value;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Whether a long string looks like raw base64 rather than prose.
|
|
92
|
+
*
|
|
93
|
+
* Deliberately narrow: a long PROMPT is the ordinary case on every one of these paths, and
|
|
94
|
+
* redacting one would destroy the record this whole subsystem exists to keep. Only a string that is
|
|
95
|
+
* entirely base64 alphabet with no whitespace qualifies, which no natural-language body is.
|
|
96
|
+
*/
|
|
97
|
+
function isBase64ish(value) {
|
|
98
|
+
return /^[A-Za-z0-9+/=_-]+$/.test(value);
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=redact-image-payloads.logic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact-image-payloads.logic.js","sourceRoot":"","sources":["../../src/shared/redact-image-payloads.logic.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,kDAAkD;AAClD,EAAE;AACF,mGAAmG;AACnG,6FAA6F;AAC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
"description": "Shared vocabulary, pure logic, and port interfaces for the Agent Architecture Board.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"ai": "^7.0.58",
|
|
28
28
|
"yaml": "^2.9.0",
|
|
29
|
-
"@cat-factory/contracts": "0.
|
|
29
|
+
"@cat-factory/contracts": "0.291.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@stryker-mutator/core": "9.6.1",
|