@jini-ai/daemon 0.1.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/LICENSE +201 -0
- package/dist/agent-executor.d.ts +458 -0
- package/dist/agent-executor.d.ts.map +1 -0
- package/dist/agent-executor.js +1277 -0
- package/dist/agent-executor.js.map +1 -0
- package/dist/artifacts/index.d.ts +14 -0
- package/dist/artifacts/index.d.ts.map +1 -0
- package/dist/artifacts/index.js +14 -0
- package/dist/artifacts/index.js.map +1 -0
- package/dist/artifacts/manifest.d.ts +90 -0
- package/dist/artifacts/manifest.d.ts.map +1 -0
- package/dist/artifacts/manifest.js +229 -0
- package/dist/artifacts/manifest.js.map +1 -0
- package/dist/artifacts/publication-guard.d.ts +28 -0
- package/dist/artifacts/publication-guard.d.ts.map +1 -0
- package/dist/artifacts/publication-guard.js +77 -0
- package/dist/artifacts/publication-guard.js.map +1 -0
- package/dist/artifacts/runtime-compat.d.ts +37 -0
- package/dist/artifacts/runtime-compat.d.ts.map +1 -0
- package/dist/artifacts/runtime-compat.js +33 -0
- package/dist/artifacts/runtime-compat.js.map +1 -0
- package/dist/artifacts/store.d.ts +85 -0
- package/dist/artifacts/store.d.ts.map +1 -0
- package/dist/artifacts/store.js +92 -0
- package/dist/artifacts/store.js.map +1 -0
- package/dist/artifacts/stub-guard.d.ts +73 -0
- package/dist/artifacts/stub-guard.d.ts.map +1 -0
- package/dist/artifacts/stub-guard.js +198 -0
- package/dist/artifacts/stub-guard.js.map +1 -0
- package/dist/artifacts/text-suppression.d.ts +68 -0
- package/dist/artifacts/text-suppression.d.ts.map +1 -0
- package/dist/artifacts/text-suppression.js +184 -0
- package/dist/artifacts/text-suppression.js.map +1 -0
- package/dist/close-status.d.ts +86 -0
- package/dist/close-status.d.ts.map +1 -0
- package/dist/close-status.js +91 -0
- package/dist/close-status.js.map +1 -0
- package/dist/continuation/continuation-transport.d.ts +41 -0
- package/dist/continuation/continuation-transport.d.ts.map +1 -0
- package/dist/continuation/continuation-transport.js +18 -0
- package/dist/continuation/continuation-transport.js.map +1 -0
- package/dist/continuation/index.d.ts +4 -0
- package/dist/continuation/index.d.ts.map +1 -0
- package/dist/continuation/index.js +4 -0
- package/dist/continuation/index.js.map +1 -0
- package/dist/continuation/journal.d.ts +37 -0
- package/dist/continuation/journal.d.ts.map +1 -0
- package/dist/continuation/journal.js +23 -0
- package/dist/continuation/journal.js.map +1 -0
- package/dist/continuation/run-start-handler.d.ts +75 -0
- package/dist/continuation/run-start-handler.d.ts.map +1 -0
- package/dist/continuation/run-start-handler.js +32 -0
- package/dist/continuation/run-start-handler.js.map +1 -0
- package/dist/delegated-tool-bridge.d.ts +53 -0
- package/dist/delegated-tool-bridge.d.ts.map +1 -0
- package/dist/delegated-tool-bridge.js +92 -0
- package/dist/delegated-tool-bridge.js.map +1 -0
- package/dist/event-log.d.ts +134 -0
- package/dist/event-log.d.ts.map +1 -0
- package/dist/event-log.js +108 -0
- package/dist/event-log.js.map +1 -0
- package/dist/frontend-capability-tools.d.ts +102 -0
- package/dist/frontend-capability-tools.d.ts.map +1 -0
- package/dist/frontend-capability-tools.js +68 -0
- package/dist/frontend-capability-tools.js.map +1 -0
- package/dist/frontend-session-registry.d.ts +127 -0
- package/dist/frontend-session-registry.d.ts.map +1 -0
- package/dist/frontend-session-registry.js +180 -0
- package/dist/frontend-session-registry.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/legacy-data-migration.d.ts +104 -0
- package/dist/legacy-data-migration.d.ts.map +1 -0
- package/dist/legacy-data-migration.js +239 -0
- package/dist/legacy-data-migration.js.map +1 -0
- package/dist/routines/index.d.ts +12 -0
- package/dist/routines/index.d.ts.map +1 -0
- package/dist/routines/index.js +12 -0
- package/dist/routines/index.js.map +1 -0
- package/dist/routines/routine-store.d.ts +77 -0
- package/dist/routines/routine-store.d.ts.map +1 -0
- package/dist/routines/routine-store.js +162 -0
- package/dist/routines/routine-store.js.map +1 -0
- package/dist/routines/schedule.d.ts +72 -0
- package/dist/routines/schedule.d.ts.map +1 -0
- package/dist/routines/schedule.js +263 -0
- package/dist/routines/schedule.js.map +1 -0
- package/dist/routines/scheduler.d.ts +34 -0
- package/dist/routines/scheduler.d.ts.map +1 -0
- package/dist/routines/scheduler.js +330 -0
- package/dist/routines/scheduler.js.map +1 -0
- package/dist/routines/types.d.ts +131 -0
- package/dist/routines/types.d.ts.map +1 -0
- package/dist/routines/types.js +9 -0
- package/dist/routines/types.js.map +1 -0
- package/dist/run/core/failure-taxonomy.d.ts +27 -0
- package/dist/run/core/failure-taxonomy.d.ts.map +1 -0
- package/dist/run/core/failure-taxonomy.js +16 -0
- package/dist/run/core/failure-taxonomy.js.map +1 -0
- package/dist/run/core/index.d.ts +5 -0
- package/dist/run/core/index.d.ts.map +1 -0
- package/dist/run/core/index.js +5 -0
- package/dist/run/core/index.js.map +1 -0
- package/dist/run/core/result.d.ts +25 -0
- package/dist/run/core/result.d.ts.map +1 -0
- package/dist/run/core/result.js +52 -0
- package/dist/run/core/result.js.map +1 -0
- package/dist/run/core/retry.d.ts +106 -0
- package/dist/run/core/retry.d.ts.map +1 -0
- package/dist/run/core/retry.js +210 -0
- package/dist/run/core/retry.js.map +1 -0
- package/dist/run/diagnostics/diagnostics.d.ts +86 -0
- package/dist/run/diagnostics/diagnostics.d.ts.map +1 -0
- package/dist/run/diagnostics/diagnostics.js +211 -0
- package/dist/run/diagnostics/diagnostics.js.map +1 -0
- package/dist/run/diagnostics/index.d.ts +3 -0
- package/dist/run/diagnostics/index.d.ts.map +1 -0
- package/dist/run/diagnostics/index.js +3 -0
- package/dist/run/diagnostics/index.js.map +1 -0
- package/dist/run/index.d.ts +16 -0
- package/dist/run/index.d.ts.map +1 -0
- package/dist/run/index.js +16 -0
- package/dist/run/index.js.map +1 -0
- package/dist/run-lifecycle.d.ts +118 -0
- package/dist/run-lifecycle.d.ts.map +1 -0
- package/dist/run-lifecycle.js +451 -0
- package/dist/run-lifecycle.js.map +1 -0
- package/dist/terminal-session.d.ts +139 -0
- package/dist/terminal-session.d.ts.map +1 -0
- package/dist/terminal-session.js +316 -0
- package/dist/terminal-session.js.map +1 -0
- package/dist/tokens.d.ts +9 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +19 -0
- package/dist/tokens.js.map +1 -0
- package/dist/tool-executor.d.ts +97 -0
- package/dist/tool-executor.d.ts.map +1 -0
- package/dist/tool-executor.js +198 -0
- package/dist/tool-executor.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../../src/run/core/retry.ts"],"names":[],"mappings":"AASA,uGAAuG;AAEvG,6EAA6E;AAC7E,+EAA+E;AAC/E,8CAA8C;AAC9C,8GAA8G;AAC9G,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAC;AACrD,8FAA8F;AAC9F,MAAM,CAAC,MAAM,uBAAuB,GAAqB,oBAAoB,CAAC;AAE9E,6EAA6E;AAC7E,6EAA6E;AAC7E,sEAAsE;AACtE,+EAA+E;AAC/E,2EAA2E;AAC3E,6EAA6E;AAC7E,0BAA0B;AAC1B,2JAA2J;AAC3J,MAAM,CAAC,MAAM,8BAA8B,GAAG,KAAK,CAAC;AACpD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AACjD,wFAAwF;AACxF,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC;AAC1C,mGAAmG;AACnG,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAEhD,SAAS,kBAAkB,CAAC,QAAwC;IAClE,OAAO,QAAQ,KAAK,YAAY;QAC9B,CAAC,CAAC,8BAA8B;QAChC,CAAC,CAAC,6BAA6B,CAAC;AACpC,CAAC;AAED,gFAAgF;AAChF,gFAAgF;AAChF,2EAA2E;AAC3E,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CAAC,CAAC;IAC1E,IAAI,WAAW,CAAC,gBAAgB;QAAE,OAAO,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IAExE,OAAO;QACL,GAAG,IAAI;QACP,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,mBAAmB;QAChC,YAAY,EAAE,qBAAqB,CACjC,iBAAiB,EACjB,OAAO,CAAC,gBAAgB,EACxB,KAAK,CAAC,MAAM,CACb;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/** @module run/diagnostics/diagnostics — Stderr/stdout tail collection and diagnostic analytics summarization for completed runs. */
|
|
2
|
+
/**
|
|
3
|
+
* Scrubs secrets/PII from a stream tail before it is stored or emitted. The
|
|
4
|
+
* engine provides the tail-collection mechanism but takes no opinion on the
|
|
5
|
+
* scrubbing policy: a consumer injects its own redactor (e.g. `@jini-ai/core`'s
|
|
6
|
+
* `redactSecrets`). Defaults to identity so a caller that has already scrubbed —
|
|
7
|
+
* or genuinely wants the raw tail — need not pass one.
|
|
8
|
+
*/
|
|
9
|
+
export type TailRedactor = (text: string) => string;
|
|
10
|
+
/** A recorded run event entry passed to diagnostics collection functions for scanning. */
|
|
11
|
+
export interface RunEventForDiagnostics {
|
|
12
|
+
event: string;
|
|
13
|
+
data: unknown;
|
|
14
|
+
}
|
|
15
|
+
/** Identifies which signal was the primary source of diagnostic information for a failed run. */
|
|
16
|
+
export type RunDiagnosticSource = 'error_event' | 'stderr' | 'exit_code' | 'signal' | 'unknown';
|
|
17
|
+
/** Bucketed stderr (and stdout) line count for low-cardinality analytics grouping. */
|
|
18
|
+
export type StderrLineCountBucket = 'none' | '1_5' | '6_20' | '21_100' | 'gt_100';
|
|
19
|
+
/** The mechanism that ended the run's child process or RPC session, derived from events and exit signals. */
|
|
20
|
+
export type RunCloseReason = 'exit_0' | 'exit_nonzero' | 'signal' | 'cancel_requested' | 'stream_error' | 'fatal_rpc_error' | 'empty_output' | 'unknown';
|
|
21
|
+
/** Diagnostic fields included in the `run_finished` analytics payload, summarizing what was observed at run end. */
|
|
22
|
+
export interface RunDiagnosticsAnalytics {
|
|
23
|
+
diagnostic_source: RunDiagnosticSource;
|
|
24
|
+
stderr_present: boolean;
|
|
25
|
+
stderr_line_count_bucket: StderrLineCountBucket;
|
|
26
|
+
stdout_present: boolean;
|
|
27
|
+
stdout_line_count_bucket: StderrLineCountBucket;
|
|
28
|
+
rpc_close_reason: RunCloseReason;
|
|
29
|
+
first_token_seen: boolean;
|
|
30
|
+
user_visible_output_seen: boolean;
|
|
31
|
+
tool_call_seen: boolean;
|
|
32
|
+
artifact_write_seen: boolean;
|
|
33
|
+
live_artifact_seen: boolean;
|
|
34
|
+
resume_auto_reseeded: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** Redacted, byte-capped tail of a stream (stderr or stdout) collected after a run completes. */
|
|
37
|
+
export interface StreamTailSummary {
|
|
38
|
+
tail: string;
|
|
39
|
+
lineCount: number;
|
|
40
|
+
truncated: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** Tail summary specifically for the stderr stream; alias of `StreamTailSummary` for call-site clarity. */
|
|
43
|
+
export type StderrTailSummary = StreamTailSummary;
|
|
44
|
+
/** Tail summary specifically for the stdout stream; alias of `StreamTailSummary` for call-site clarity. */
|
|
45
|
+
export type StdoutTailSummary = StreamTailSummary;
|
|
46
|
+
/**
|
|
47
|
+
* Maps a raw stderr (or stdout) line count to a low-cardinality analytics bucket.
|
|
48
|
+
* @param count - Total number of non-empty lines in the stream.
|
|
49
|
+
* @returns A `StderrLineCountBucket` string for use in analytics payloads.
|
|
50
|
+
*/
|
|
51
|
+
export declare function stderrLineCountBucket(count: number): StderrLineCountBucket;
|
|
52
|
+
/**
|
|
53
|
+
* Collects the tail of the stderr stream from a run's event list, scrubbed by the
|
|
54
|
+
* supplied redactor. Returns `undefined` when no stderr output was recorded.
|
|
55
|
+
* @param events - Recorded run events; only 'stderr' events are processed.
|
|
56
|
+
* @param redact - Secret/PII scrubber applied to the joined tail; defaults to identity.
|
|
57
|
+
* @returns A `StderrTailSummary` with the last 20 lines (capped at 4 KB) and a truncation flag, or `undefined`.
|
|
58
|
+
*/
|
|
59
|
+
export declare function collectStderrTailSummary(events?: RunEventForDiagnostics[], redact?: TailRedactor): StderrTailSummary | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Collects the tail of the stdout stream from a run's event list, scrubbed by the
|
|
62
|
+
* supplied redactor. Returns `undefined` when no stdout output was recorded.
|
|
63
|
+
* @param events - Recorded run events; only 'stdout' events are processed.
|
|
64
|
+
* @param redact - Secret/PII scrubber applied to the joined tail; defaults to identity.
|
|
65
|
+
* @returns A `StdoutTailSummary` with the last 20 lines (capped at 4 KB) and a truncation flag, or `undefined`.
|
|
66
|
+
*/
|
|
67
|
+
export declare function collectStdoutTailSummary(events?: RunEventForDiagnostics[], redact?: TailRedactor): StdoutTailSummary | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Produces the full `RunDiagnosticsAnalytics` payload for a completed run by scanning its event stream
|
|
70
|
+
* and combining observed flags (tool calls, artifact writes, first token) with process-level signals.
|
|
71
|
+
* @param args - Run events, exit code, signal, and boolean flags set by the daemon during finalization.
|
|
72
|
+
* @returns A `RunDiagnosticsAnalytics` object ready to spread into the `run_finished` analytics event.
|
|
73
|
+
*/
|
|
74
|
+
export declare function summarizeRunDiagnosticsForAnalytics(args: {
|
|
75
|
+
events?: RunEventForDiagnostics[];
|
|
76
|
+
exitCode?: number | null;
|
|
77
|
+
signal?: string | null;
|
|
78
|
+
cancelRequested?: boolean;
|
|
79
|
+
streamErrorSeen?: boolean;
|
|
80
|
+
fatalRpcErrorSeen?: boolean;
|
|
81
|
+
emptyOutputFailure?: boolean;
|
|
82
|
+
firstTokenSeen?: boolean;
|
|
83
|
+
artifactWriteSeen?: boolean;
|
|
84
|
+
liveArtifactSeen?: boolean;
|
|
85
|
+
}): RunDiagnosticsAnalytics;
|
|
86
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@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,OAAO,CAAC;CACpB;AAED,2GAA2G;AAC3G,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAClD,2GAA2G;AAC3G,MAAM,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AA4BlD;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,qBAAqB,CAM1E;AA2CD;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,GAAE,sBAAsB,EAAO,EACrC,MAAM,GAAE,YAA+B,GACtC,iBAAiB,GAAG,SAAS,CAE/B;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,GAAE,sBAAsB,EAAO,EACrC,MAAM,GAAE,YAA+B,GACtC,iBAAiB,GAAG,SAAS,CAE/B;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CAAC,IAAI,EAAE;IACxD,MAAM,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,GAAG,uBAAuB,CA8F1B"}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/** @module run/diagnostics/diagnostics — Stderr/stdout tail collection and diagnostic analytics summarization for completed runs. */
|
|
2
|
+
const identityRedactor = (text) => text;
|
|
3
|
+
const STDERR_TAIL_MAX_LINES = 20;
|
|
4
|
+
const STDERR_TAIL_MAX_BYTES = 4 * 1024;
|
|
5
|
+
function readStderrChunk(data) {
|
|
6
|
+
if (typeof data === 'string')
|
|
7
|
+
return data;
|
|
8
|
+
if (!data || typeof data !== 'object' || Array.isArray(data))
|
|
9
|
+
return null;
|
|
10
|
+
const obj = data;
|
|
11
|
+
if (typeof obj.chunk === 'string')
|
|
12
|
+
return obj.chunk;
|
|
13
|
+
if (typeof obj.text === 'string')
|
|
14
|
+
return obj.text;
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
function readStdoutChunk(data) {
|
|
18
|
+
if (typeof data === 'string')
|
|
19
|
+
return data;
|
|
20
|
+
if (!data || typeof data !== 'object' || Array.isArray(data))
|
|
21
|
+
return null;
|
|
22
|
+
const obj = data;
|
|
23
|
+
if (typeof obj.chunk === 'string')
|
|
24
|
+
return obj.chunk;
|
|
25
|
+
if (typeof obj.text === 'string')
|
|
26
|
+
return obj.text;
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
function countLines(text) {
|
|
30
|
+
if (!text)
|
|
31
|
+
return 0;
|
|
32
|
+
return text.split(/\r?\n/).filter((line) => line.length > 0).length;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Maps a raw stderr (or stdout) line count to a low-cardinality analytics bucket.
|
|
36
|
+
* @param count - Total number of non-empty lines in the stream.
|
|
37
|
+
* @returns A `StderrLineCountBucket` string for use in analytics payloads.
|
|
38
|
+
*/
|
|
39
|
+
export function stderrLineCountBucket(count) {
|
|
40
|
+
if (count <= 0)
|
|
41
|
+
return 'none';
|
|
42
|
+
if (count <= 5)
|
|
43
|
+
return '1_5';
|
|
44
|
+
if (count <= 20)
|
|
45
|
+
return '6_20';
|
|
46
|
+
if (count <= 100)
|
|
47
|
+
return '21_100';
|
|
48
|
+
return 'gt_100';
|
|
49
|
+
}
|
|
50
|
+
function truncateUtf8(value, maxBytes) {
|
|
51
|
+
const bytes = Buffer.byteLength(value, 'utf8');
|
|
52
|
+
if (bytes <= maxBytes)
|
|
53
|
+
return { value, truncated: false };
|
|
54
|
+
let end = value.length;
|
|
55
|
+
while (end > 0 && Buffer.byteLength(value.slice(0, end), 'utf8') > maxBytes) {
|
|
56
|
+
end -= 1;
|
|
57
|
+
}
|
|
58
|
+
return { value: value.slice(0, end), truncated: true };
|
|
59
|
+
}
|
|
60
|
+
function collectStreamTailSummary(events, eventName, readChunk, redact) {
|
|
61
|
+
let streamText = '';
|
|
62
|
+
for (const event of events) {
|
|
63
|
+
if (event.event !== eventName)
|
|
64
|
+
continue;
|
|
65
|
+
const chunk = readChunk(event.data);
|
|
66
|
+
if (chunk)
|
|
67
|
+
streamText += chunk;
|
|
68
|
+
}
|
|
69
|
+
const lineCount = countLines(streamText);
|
|
70
|
+
if (lineCount <= 0)
|
|
71
|
+
return undefined;
|
|
72
|
+
const lines = streamText.trimEnd().split(/\r?\n/);
|
|
73
|
+
const tailLines = lines.slice(-STDERR_TAIL_MAX_LINES);
|
|
74
|
+
const lineTruncated = lines.length > tailLines.length;
|
|
75
|
+
const redacted = redact(tailLines.join('\n'));
|
|
76
|
+
const byteCapped = truncateUtf8(redacted, STDERR_TAIL_MAX_BYTES);
|
|
77
|
+
return {
|
|
78
|
+
tail: byteCapped.value,
|
|
79
|
+
lineCount,
|
|
80
|
+
truncated: lineTruncated || byteCapped.truncated,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Collects the tail of the stderr stream from a run's event list, scrubbed by the
|
|
85
|
+
* supplied redactor. Returns `undefined` when no stderr output was recorded.
|
|
86
|
+
* @param events - Recorded run events; only 'stderr' events are processed.
|
|
87
|
+
* @param redact - Secret/PII scrubber applied to the joined tail; defaults to identity.
|
|
88
|
+
* @returns A `StderrTailSummary` with the last 20 lines (capped at 4 KB) and a truncation flag, or `undefined`.
|
|
89
|
+
*/
|
|
90
|
+
export function collectStderrTailSummary(events = [], redact = identityRedactor) {
|
|
91
|
+
return collectStreamTailSummary(events, 'stderr', readStderrChunk, redact);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Collects the tail of the stdout stream from a run's event list, scrubbed by the
|
|
95
|
+
* supplied redactor. Returns `undefined` when no stdout output was recorded.
|
|
96
|
+
* @param events - Recorded run events; only 'stdout' events are processed.
|
|
97
|
+
* @param redact - Secret/PII scrubber applied to the joined tail; defaults to identity.
|
|
98
|
+
* @returns A `StdoutTailSummary` with the last 20 lines (capped at 4 KB) and a truncation flag, or `undefined`.
|
|
99
|
+
*/
|
|
100
|
+
export function collectStdoutTailSummary(events = [], redact = identityRedactor) {
|
|
101
|
+
return collectStreamTailSummary(events, 'stdout', readStdoutChunk, redact);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Produces the full `RunDiagnosticsAnalytics` payload for a completed run by scanning its event stream
|
|
105
|
+
* and combining observed flags (tool calls, artifact writes, first token) with process-level signals.
|
|
106
|
+
* @param args - Run events, exit code, signal, and boolean flags set by the daemon during finalization.
|
|
107
|
+
* @returns A `RunDiagnosticsAnalytics` object ready to spread into the `run_finished` analytics event.
|
|
108
|
+
*/
|
|
109
|
+
export function summarizeRunDiagnosticsForAnalytics(args) {
|
|
110
|
+
const events = args.events ?? [];
|
|
111
|
+
let stderr = '';
|
|
112
|
+
let stdout = '';
|
|
113
|
+
let userVisibleOutputSeen = false;
|
|
114
|
+
let toolCallSeen = false;
|
|
115
|
+
let artifactWriteSeen = args.artifactWriteSeen === true;
|
|
116
|
+
let liveArtifactSeen = args.liveArtifactSeen === true;
|
|
117
|
+
let recordedCloseReason = null;
|
|
118
|
+
let resumeAutoReseeded = false;
|
|
119
|
+
for (const event of events) {
|
|
120
|
+
if (event.event === 'stderr') {
|
|
121
|
+
const chunk = readStderrChunk(event.data);
|
|
122
|
+
if (chunk)
|
|
123
|
+
stderr += chunk;
|
|
124
|
+
}
|
|
125
|
+
if (event.event === 'stdout') {
|
|
126
|
+
const chunk = readStdoutChunk(event.data);
|
|
127
|
+
if (chunk) {
|
|
128
|
+
stdout += chunk;
|
|
129
|
+
userVisibleOutputSeen = true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const data = event.data && typeof event.data === 'object'
|
|
133
|
+
? event.data
|
|
134
|
+
: {};
|
|
135
|
+
if (data.type === 'text_delta' || data.type === 'thinking_delta') {
|
|
136
|
+
const delta = typeof data.delta === 'string' ? data.delta : '';
|
|
137
|
+
if (delta.length > 0)
|
|
138
|
+
userVisibleOutputSeen = true;
|
|
139
|
+
}
|
|
140
|
+
if (data.type === 'tool_use')
|
|
141
|
+
toolCallSeen = true;
|
|
142
|
+
if (event.event === 'diagnostic' && data.type === 'agent_resume_auto_reseed') {
|
|
143
|
+
resumeAutoReseeded = true;
|
|
144
|
+
}
|
|
145
|
+
if (data.type === 'artifact')
|
|
146
|
+
artifactWriteSeen = true;
|
|
147
|
+
if (data.type === 'live_artifact' || event.event === 'live_artifact') {
|
|
148
|
+
liveArtifactSeen = true;
|
|
149
|
+
}
|
|
150
|
+
if (event.event === 'diagnostic' &&
|
|
151
|
+
data.type === 'runtime_close' &&
|
|
152
|
+
typeof data.rpc_close_reason === 'string') {
|
|
153
|
+
const reason = data.rpc_close_reason;
|
|
154
|
+
if (reason === 'exit_0' ||
|
|
155
|
+
reason === 'exit_nonzero' ||
|
|
156
|
+
reason === 'signal' ||
|
|
157
|
+
reason === 'cancel_requested' ||
|
|
158
|
+
reason === 'stream_error' ||
|
|
159
|
+
reason === 'fatal_rpc_error' ||
|
|
160
|
+
reason === 'empty_output' ||
|
|
161
|
+
reason === 'unknown') {
|
|
162
|
+
recordedCloseReason = reason;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
const stderrLineCount = countLines(stderr);
|
|
167
|
+
const stdoutLineCount = countLines(stdout);
|
|
168
|
+
const hasErrorEvent = events.some((event) => event.event === 'error');
|
|
169
|
+
const stderrPresent = stderrLineCount > 0;
|
|
170
|
+
const stdoutPresent = stdoutLineCount > 0;
|
|
171
|
+
let diagnosticSource = 'unknown';
|
|
172
|
+
if (hasErrorEvent)
|
|
173
|
+
diagnosticSource = 'error_event';
|
|
174
|
+
else if (stderrPresent)
|
|
175
|
+
diagnosticSource = 'stderr';
|
|
176
|
+
else if (args.signal)
|
|
177
|
+
diagnosticSource = 'signal';
|
|
178
|
+
else if (typeof args.exitCode === 'number')
|
|
179
|
+
diagnosticSource = 'exit_code';
|
|
180
|
+
let rpcCloseReason = 'unknown';
|
|
181
|
+
if (recordedCloseReason)
|
|
182
|
+
rpcCloseReason = recordedCloseReason;
|
|
183
|
+
else if (args.cancelRequested === true)
|
|
184
|
+
rpcCloseReason = 'cancel_requested';
|
|
185
|
+
else if (args.fatalRpcErrorSeen === true)
|
|
186
|
+
rpcCloseReason = 'fatal_rpc_error';
|
|
187
|
+
else if (args.streamErrorSeen === true)
|
|
188
|
+
rpcCloseReason = 'stream_error';
|
|
189
|
+
else if (args.emptyOutputFailure === true)
|
|
190
|
+
rpcCloseReason = 'empty_output';
|
|
191
|
+
else if (args.signal)
|
|
192
|
+
rpcCloseReason = 'signal';
|
|
193
|
+
else if (typeof args.exitCode === 'number') {
|
|
194
|
+
rpcCloseReason = args.exitCode === 0 ? 'exit_0' : 'exit_nonzero';
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
diagnostic_source: diagnosticSource,
|
|
198
|
+
stderr_present: stderrPresent,
|
|
199
|
+
stderr_line_count_bucket: stderrLineCountBucket(stderrLineCount),
|
|
200
|
+
stdout_present: stdoutPresent,
|
|
201
|
+
stdout_line_count_bucket: stderrLineCountBucket(stdoutLineCount),
|
|
202
|
+
rpc_close_reason: rpcCloseReason,
|
|
203
|
+
first_token_seen: args.firstTokenSeen === true,
|
|
204
|
+
user_visible_output_seen: userVisibleOutputSeen,
|
|
205
|
+
tool_call_seen: toolCallSeen,
|
|
206
|
+
artifact_write_seen: artifactWriteSeen,
|
|
207
|
+
live_artifact_seen: liveArtifactSeen,
|
|
208
|
+
resume_auto_reseeded: resumeAutoReseeded,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
//# s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wBAAwB,EAAE,qBAAqB,CAAC,eAAe,CAAC;QAChE,gBAAgB,EAAE,cAAc;QAChC,gBAAgB,EAAE,IAAI,CAAC,cAAc,KAAK,IAAI;QAC9C,wBAAwB,EAAE,qBAAqB;QAC/C,cAAc,EAAE,YAAY;QAC5B,mBAAmB,EAAE,iBAAiB;QACtC,kBAAkB,EAAE,gBAAgB;QACpC,oBAAoB,EAAE,kBAAkB;KACzC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/run/diagnostics/index.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/run/diagnostics/index.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module run — Public API for generic run-orchestration primitives: result and
|
|
3
|
+
* error-code derivation, the safe-retry policy and its failure taxonomy, and
|
|
4
|
+
* post-run diagnostic tail collection.
|
|
5
|
+
*
|
|
6
|
+
* These are the product-neutral run-orchestration helpers extracted from the
|
|
7
|
+
* daemon's run capability barrel. Product telemetry (runtime-type / usage /
|
|
8
|
+
* timing analytics), the vendor-specific failure classifier, artifact
|
|
9
|
+
* filesystem snapshotting, and MCP tool-bundle resolution are deliberately
|
|
10
|
+
* out of scope here — see `source-map.md`.
|
|
11
|
+
*/
|
|
12
|
+
export { runResultFromStatus, deriveRunErrorCode, DEFAULT_SAFE_RUN_RETRY_MAX_ATTEMPTS, SAFE_RUN_RETRY_STRATEGY, RATE_LIMIT_RETRY_BASE_DELAY_MS, TRANSIENT_RETRY_BASE_DELAY_MS, RETRY_BACKOFF_MULTIPLIER, MAX_RETRY_BACKOFF_DELAY_MS, computeRetryBackoffMs, decideSafeRunRetry, classifyProcessExitFailure, resumableFromProcessExit, } from './core/index.js';
|
|
13
|
+
export type { RunResult, RunStatusForAnalytics, RunFailureResult, RunFailureCategory, RunFailureDetail, RunFailureStage, RunRetryStrategy, RunRetrySuppressedReason, RunRetryFailureSignal, RunRetrySideEffectState, RunRetryPolicyInput, RunRetryPolicyDecision, } from './core/index.js';
|
|
14
|
+
export { stderrLineCountBucket, collectStderrTailSummary, collectStdoutTailSummary, summarizeRunDiagnosticsForAnalytics, } from './diagnostics/index.js';
|
|
15
|
+
export type { RunEventForDiagnostics, RunDiagnosticSource, StderrLineCountBucket, RunCloseReason, RunDiagnosticsAnalytics, StreamTailSummary, StderrTailSummary, StdoutTailSummary, TailRedactor, } from './diagnostics/index.js';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/run/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,mCAAmC,EACnC,uBAAuB,EACvB,8BAA8B,EAC9B,6BAA6B,EAC7B,wBAAwB,EACxB,0BAA0B,EAC1B,qBAAqB,EACrB,kBAAkB,EAClB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,SAAS,EACT,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,wBAAwB,EACxB,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,mCAAmC,GACpC,MAAM,wBAAwB,CAAC;AAChC,YAAY,EACV,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACd,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,GACb,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module run — Public API for generic run-orchestration primitives: result and
|
|
3
|
+
* error-code derivation, the safe-retry policy and its failure taxonomy, and
|
|
4
|
+
* post-run diagnostic tail collection.
|
|
5
|
+
*
|
|
6
|
+
* These are the product-neutral run-orchestration helpers extracted from the
|
|
7
|
+
* daemon's run capability barrel. Product telemetry (runtime-type / usage /
|
|
8
|
+
* timing analytics), the vendor-specific failure classifier, artifact
|
|
9
|
+
* filesystem snapshotting, and MCP tool-bundle resolution are deliberately
|
|
10
|
+
* out of scope here — see `source-map.md`.
|
|
11
|
+
*/
|
|
12
|
+
// core — result derivation, failure taxonomy, and retry policy
|
|
13
|
+
export { runResultFromStatus, deriveRunErrorCode, DEFAULT_SAFE_RUN_RETRY_MAX_ATTEMPTS, SAFE_RUN_RETRY_STRATEGY, RATE_LIMIT_RETRY_BASE_DELAY_MS, TRANSIENT_RETRY_BASE_DELAY_MS, RETRY_BACKOFF_MULTIPLIER, MAX_RETRY_BACKOFF_DELAY_MS, computeRetryBackoffMs, decideSafeRunRetry, classifyProcessExitFailure, resumableFromProcessExit, } from './core/index.js';
|
|
14
|
+
// diagnostics — stderr/stdout tail summaries and diagnostic analytics
|
|
15
|
+
export { stderrLineCountBucket, collectStderrTailSummary, collectStdoutTailSummary, summarizeRunDiagnosticsForAnalytics, } from './diagnostics/index.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/run/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,+DAA+D;AAC/D,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,mCAAmC,EACnC,uBAAuB,EACvB,8BAA8B,EAC9B,6BAA6B,EAC7B,wBAAwB,EACxB,0BAA0B,EAC1B,qBAAqB,EACrB,kBAAkB,EAClB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AAgBzB,sEAAsE;AACtE,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,wBAAwB,EACxB,mCAAmC,GACpC,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { RunAgentPayload, RunCancelRequest, RunChunkPayload, RunErrorPayload, RunProtocolEvent, RunStatus } from '@jini-ai/protocol';
|
|
2
|
+
import type { EventLog, EventLogReplayResult } from './event-log.js';
|
|
3
|
+
import type { TerminalRunOutcome } from './close-status.js';
|
|
4
|
+
export interface StartRunInput {
|
|
5
|
+
/** Opaque caller-supplied identity the run belongs to — never a project/conversation id (see module doc). */
|
|
6
|
+
readonly contextRef: string;
|
|
7
|
+
readonly agentId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Caller-supplied idempotency key. Starting twice with the same key
|
|
10
|
+
* returns the original run (`started: false`) instead of creating a
|
|
11
|
+
* second one — new behavior this port builds fresh, since OD's own
|
|
12
|
+
* `clientRequestId` is threaded through but never actually deduplicated
|
|
13
|
+
* against (confirmed absent upstream; see `source-map.md`).
|
|
14
|
+
*/
|
|
15
|
+
readonly idempotencyKey?: string;
|
|
16
|
+
/** Override the generated run id — test/fixture hook only. */
|
|
17
|
+
readonly runId?: string;
|
|
18
|
+
/** When set, arms an inactivity watchdog that fails the run as a resumable failure if no `emit()` occurs within this window. */
|
|
19
|
+
readonly inactivityTimeoutMs?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface StartRunResult {
|
|
22
|
+
readonly run: RunStatus;
|
|
23
|
+
/** `false` when an existing run was returned via idempotency-key replay rather than a new one being created. */
|
|
24
|
+
readonly started: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface FinishRunInput {
|
|
27
|
+
readonly runId: string;
|
|
28
|
+
readonly status: TerminalRunOutcome;
|
|
29
|
+
readonly code: number | null;
|
|
30
|
+
readonly signal: string | null;
|
|
31
|
+
/**
|
|
32
|
+
* True when a `'failed'`/`'cancelled'` run can be recovered by `resume()`
|
|
33
|
+
* instead of requiring a fresh `start()`. Generalized from OD's
|
|
34
|
+
* `run.resumable` flag (set only for a narrow, explicitly resumable
|
|
35
|
+
* failure-classification subset — see `run-failure-classification.ts` in
|
|
36
|
+
* the researched source).
|
|
37
|
+
*/
|
|
38
|
+
readonly resumable: boolean;
|
|
39
|
+
/** Gap 5 (session resume) — see `RunEndPayload.sessionRef`'s doc in `@jini-ai/protocol`. Threaded straight through to the durable `'end'` entry; this module has no opinion on what it means. */
|
|
40
|
+
readonly sessionRef?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ResumeRunResult {
|
|
43
|
+
readonly run: RunStatus;
|
|
44
|
+
/** `false` when the run was not eligible (not terminal, or terminal but not `resumable`) — not an error, just a no-op. */
|
|
45
|
+
readonly resumed: boolean;
|
|
46
|
+
}
|
|
47
|
+
/** The subset of `RunProtocolEvent` a driver may emit directly. `'start'`/`'end'` are kernel-managed — see `start()`/`finish()`. */
|
|
48
|
+
export type DriverEmittableInput = {
|
|
49
|
+
readonly event: 'agent';
|
|
50
|
+
readonly data: RunAgentPayload;
|
|
51
|
+
} | {
|
|
52
|
+
readonly event: 'stdout';
|
|
53
|
+
readonly data: RunChunkPayload;
|
|
54
|
+
} | {
|
|
55
|
+
readonly event: 'stderr';
|
|
56
|
+
readonly data: RunChunkPayload;
|
|
57
|
+
} | {
|
|
58
|
+
readonly event: 'error';
|
|
59
|
+
readonly data: RunErrorPayload;
|
|
60
|
+
};
|
|
61
|
+
export type Unsubscribe = () => void;
|
|
62
|
+
export interface StreamOptions {
|
|
63
|
+
readonly afterCursor?: string | null;
|
|
64
|
+
}
|
|
65
|
+
export type StreamSubscribeResult = {
|
|
66
|
+
readonly kind: 'ok';
|
|
67
|
+
readonly unsubscribe: Unsubscribe;
|
|
68
|
+
} | Exclude<EventLogReplayResult, {
|
|
69
|
+
kind: 'ok';
|
|
70
|
+
}>;
|
|
71
|
+
export interface RunLifecycle {
|
|
72
|
+
/** Rebuilds the in-memory run index from durable EventLog records. Hosts must await this once during boot before accepting run requests. */
|
|
73
|
+
rehydrate(): Promise<void>;
|
|
74
|
+
start(input: StartRunInput): Promise<StartRunResult>;
|
|
75
|
+
get(runId: string): Promise<RunStatus | undefined>;
|
|
76
|
+
list(contextRef?: string): Promise<readonly RunStatus[]>;
|
|
77
|
+
/** Records cancellation intent. Idempotent — cancelling an already-terminal run is a no-op, not an error. */
|
|
78
|
+
cancel(request: RunCancelRequest): Promise<RunStatus>;
|
|
79
|
+
/** Registers a listener fired synchronously when `cancel()` is called for `runId`. Returns an unsubscribe function. */
|
|
80
|
+
onCancelRequested(runId: string, listener: (request: RunCancelRequest) => void): Unsubscribe;
|
|
81
|
+
/** Appends a driver-observed event and fans it out to live subscribers. Throws if `runId` is unknown or already terminal. */
|
|
82
|
+
emit(runId: string, input: DriverEmittableInput): Promise<RunProtocolEvent>;
|
|
83
|
+
/** Idempotent terminal transition; a second call while already terminal is a no-op that returns the existing status unchanged. */
|
|
84
|
+
finish(input: FinishRunInput): Promise<RunStatus>;
|
|
85
|
+
resume(runId: string): Promise<ResumeRunResult>;
|
|
86
|
+
/** Resolves once `runId` reaches a terminal state; resolves immediately if it already has. */
|
|
87
|
+
waitForTerminal(runId: string): Promise<RunStatus>;
|
|
88
|
+
/**
|
|
89
|
+
* Replays buffered history after `options.afterCursor` (or from the
|
|
90
|
+
* beginning if omitted/null) and then subscribes `onEvent` for live
|
|
91
|
+
* delivery — the reconnect-and-resume-streaming operation a transport
|
|
92
|
+
* uses. Mirrors OD's own reconnect guarantee: a caller that reconnects
|
|
93
|
+
* already caught up on a *terminal* run still receives one more delivery
|
|
94
|
+
* of the final `'end'` event, so a client can never silently miss the
|
|
95
|
+
* terminal signal (`runs.ts` `stream()`, researched source).
|
|
96
|
+
*/
|
|
97
|
+
stream(runId: string, onEvent: (event: RunProtocolEvent) => void, options?: StreamOptions): Promise<StreamSubscribeResult>;
|
|
98
|
+
}
|
|
99
|
+
export interface CreateRunLifecycleInput {
|
|
100
|
+
readonly eventLog: EventLog;
|
|
101
|
+
/** Host-owned sink for asynchronous lifecycle failures that cannot be returned to a caller. Defaults to `console.error`. */
|
|
102
|
+
readonly onInternalError?: (context: RunLifecycleInternalErrorContext) => void;
|
|
103
|
+
}
|
|
104
|
+
export interface RunLifecycleInternalErrorContext {
|
|
105
|
+
readonly source: 'inactivity-timeout';
|
|
106
|
+
readonly runId: string;
|
|
107
|
+
readonly error: unknown;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Creates the in-process `RunLifecycle` reference implementation.
|
|
111
|
+
*
|
|
112
|
+
* @param input.eventLog - The durable `EventLog` port this lifecycle appends to and replays from.
|
|
113
|
+
* @returns A `RunLifecycle` backed by an in-memory run registry plus the injected `EventLog`.
|
|
114
|
+
* @complexity Per-call complexities documented on each method; the registry itself is a `Map` keyed by `runId` (O(1) lookup).
|
|
115
|
+
* @overallScore 100/100
|
|
116
|
+
*/
|
|
117
|
+
export declare function createRunLifecycle(input: CreateRunLifecycleInput): RunLifecycle;
|
|
118
|
+
//# sourceMappingURL=run-lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-lifecycle.d.ts","sourceRoot":"","sources":["../src/run-lifecycle.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EACV,eAAe,EACf,gBAAgB,EAChB,eAAe,EAEf,eAAe,EACf,gBAAgB,EAGhB,SAAS,EACV,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,QAAQ,EAAiB,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACpF,OAAO,KAAK,EAAsB,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGhF,MAAM,WAAW,aAAa;IAC5B,6GAA6G;IAC7G,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,E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