@genesislcap/ai-assistant 15.14.2 → 15.15.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/ai-assistant.api.json +5 -5
- package/dist/chat-driver.cjs +285 -70
- package/dist/chat-driver.cjs.map +4 -4
- package/dist/chat-driver.mjs +285 -70
- package/dist/chat-driver.mjs.map +4 -4
- package/dist/custom-elements.json +32 -0
- package/dist/dts/chat-driver-node.d.ts +1 -1
- package/dist/dts/chat-driver-node.d.ts.map +1 -1
- package/dist/dts/components/chat-driver/chat-driver.d.ts.map +1 -1
- package/dist/dts/utils/condense-history.d.ts.map +1 -1
- package/dist/dts/utils/history-transform.d.ts.map +1 -1
- package/dist/esm/components/chat-driver/chat-driver.js +34 -7
- package/dist/esm/utils/condense-history.js +31 -7
- package/dist/esm/utils/condense-history.test.js +68 -1
- package/dist/esm/utils/history-transform.js +8 -1
- package/dist/esm/utils/history-transform.test.js +22 -1
- package/package.json +17 -17
- package/src/chat-driver-node.ts +7 -0
- package/src/components/chat-driver/chat-driver.ts +48 -3
- package/src/utils/condense-history.test.ts +84 -2
- package/src/utils/condense-history.ts +27 -4
- package/src/utils/history-transform.test.ts +31 -0
- package/src/utils/history-transform.ts +7 -1
|
@@ -271,6 +271,14 @@
|
|
|
271
271
|
"package": "@genesislcap/foundation-ai"
|
|
272
272
|
}
|
|
273
273
|
},
|
|
274
|
+
{
|
|
275
|
+
"kind": "js",
|
|
276
|
+
"name": "ChatAttachment",
|
|
277
|
+
"declaration": {
|
|
278
|
+
"name": "ChatAttachment",
|
|
279
|
+
"package": "@genesislcap/foundation-ai"
|
|
280
|
+
}
|
|
281
|
+
},
|
|
274
282
|
{
|
|
275
283
|
"kind": "js",
|
|
276
284
|
"name": "ChatFallback",
|
|
@@ -279,6 +287,14 @@
|
|
|
279
287
|
"package": "@genesislcap/foundation-ai"
|
|
280
288
|
}
|
|
281
289
|
},
|
|
290
|
+
{
|
|
291
|
+
"kind": "js",
|
|
292
|
+
"name": "ChatImageAttachment",
|
|
293
|
+
"declaration": {
|
|
294
|
+
"name": "ChatImageAttachment",
|
|
295
|
+
"package": "@genesislcap/foundation-ai"
|
|
296
|
+
}
|
|
297
|
+
},
|
|
282
298
|
{
|
|
283
299
|
"kind": "js",
|
|
284
300
|
"name": "ChatMessage",
|
|
@@ -295,6 +311,14 @@
|
|
|
295
311
|
"package": "@genesislcap/foundation-ai"
|
|
296
312
|
}
|
|
297
313
|
},
|
|
314
|
+
{
|
|
315
|
+
"kind": "js",
|
|
316
|
+
"name": "ChatTextAttachment",
|
|
317
|
+
"declaration": {
|
|
318
|
+
"name": "ChatTextAttachment",
|
|
319
|
+
"package": "@genesislcap/foundation-ai"
|
|
320
|
+
}
|
|
321
|
+
},
|
|
298
322
|
{
|
|
299
323
|
"kind": "js",
|
|
300
324
|
"name": "ChatThinkingPolicy",
|
|
@@ -327,6 +351,14 @@
|
|
|
327
351
|
"package": "@genesislcap/foundation-ai"
|
|
328
352
|
}
|
|
329
353
|
},
|
|
354
|
+
{
|
|
355
|
+
"kind": "js",
|
|
356
|
+
"name": "ChatToolResult",
|
|
357
|
+
"declaration": {
|
|
358
|
+
"name": "ChatToolResult",
|
|
359
|
+
"package": "@genesislcap/foundation-ai"
|
|
360
|
+
}
|
|
361
|
+
},
|
|
330
362
|
{
|
|
331
363
|
"kind": "js",
|
|
332
364
|
"name": "GeminiModelId",
|
|
@@ -24,7 +24,7 @@ export * from './config/config';
|
|
|
24
24
|
export * from './config/define-stateful-agent';
|
|
25
25
|
export * from './config/fallback-agents';
|
|
26
26
|
export { AnthropicProvider, AnthropicTransport, GeminiProvider, GeminiTransport, MutableAIProviderRegistry, SUPPORTED_ANTHROPIC_MODEL_IDS, SUPPORTED_GEMINI_MODEL_IDS, DEFAULT_PROVIDER_REFUSED_MESSAGE, PROVIDER_REFUSED_CODE, ProviderRefusedError, isObservableAIProviderRegistry, ANTHROPIC_CACHE_READ_MULTIPLIER, ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER, ANTHROPIC_CACHE_WRITE_5M_MULTIPLIER, anthropicRatesFor, anthropicTokenCost, GEMINI_CACHED_INPUT_MULTIPLIER, GEMINI_LONG_CONTEXT_THRESHOLD, geminiRatesFor, geminiTokenCost, vendorOfModel, } from '@genesislcap/foundation-ai';
|
|
27
|
-
export type { AggregateUsage, AIProvider, AIProviderRegistry, AnthropicModelId, CachePolicy, ChatFallback, ChatMessage, ChatRequestOptions, ChatThinkingPolicy, ChatToolChoice, ChatToolDefinition, ChatToolHandlers, GeminiModelId, AnthropicUsageRecord, GeminiUsageRecord, TokenCost, TokenCostBreakdown, TokenRates, } from '@genesislcap/foundation-ai';
|
|
27
|
+
export type { AggregateUsage, AIProvider, AIProviderRegistry, AnthropicModelId, CachePolicy, ChatAttachment, ChatFallback, ChatImageAttachment, ChatMessage, ChatRequestOptions, ChatTextAttachment, ChatThinkingPolicy, ChatToolChoice, ChatToolDefinition, ChatToolHandlers, ChatToolResult, GeminiModelId, AnthropicUsageRecord, GeminiUsageRecord, TokenCost, TokenCostBreakdown, TokenRates, } from '@genesislcap/foundation-ai';
|
|
28
28
|
export { addUsage, emptyUsage, messageUsage, sumUsage, totalTokens } from './utils/sum-usage';
|
|
29
29
|
export { usageRows } from './utils/usage-rows';
|
|
30
30
|
export type { UsageRow } from './utils/usage-rows';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-driver-node.d.ts","sourceRoot":"","sources":["../../src/chat-driver-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AASzC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,yBAAyB,EAKzB,6BAA6B,EAC7B,0BAA0B,EAQ1B,gCAAgC,EAChC,qBAAqB,EACrB,oBAAoB,EACpB,8BAA8B,EAW9B,+BAA+B,EAC/B,mCAAmC,EACnC,mCAAmC,EACnC,iBAAiB,EACjB,kBAAkB,EAClB,8BAA8B,EAC9B,6BAA6B,EAC7B,cAAc,EACd,eAAe,EAGf,aAAa,GACd,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAGV,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,
|
|
1
|
+
{"version":3,"file":"chat-driver-node.d.ts","sourceRoot":"","sources":["../../src/chat-driver-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AASzC,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,yBAAyB,EAKzB,6BAA6B,EAC7B,0BAA0B,EAQ1B,gCAAgC,EAChC,qBAAqB,EACrB,oBAAoB,EACpB,8BAA8B,EAW9B,+BAA+B,EAC/B,mCAAmC,EACnC,mCAAmC,EACnC,iBAAiB,EACjB,kBAAkB,EAClB,8BAA8B,EAC9B,6BAA6B,EAC7B,cAAc,EACd,eAAe,EAGf,aAAa,GACd,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAGV,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EAIX,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,aAAa,EAIb,oBAAoB,EACpB,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,UAAU,GACX,MAAM,4BAA4B,CAAC;AAoBpC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAS9F,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AASnD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACtE,YAAY,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAClF,YAAY,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAKnF,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC1F,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-driver.d.ts","sourceRoot":"","sources":["../../../../src/components/chat-driver/chat-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAEd,kBAAkB,EAClB,cAAc,EAEd,cAAc,EACd,gBAAgB,
|
|
1
|
+
{"version":3,"file":"chat-driver.d.ts","sourceRoot":"","sources":["../../../../src/components/chat-driver/chat-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EAEd,kBAAkB,EAClB,cAAc,EAEd,cAAc,EACd,gBAAgB,EAGhB,WAAW,EAIX,cAAc,EAKd,yBAAyB,EAEzB,qBAAqB,EAGtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,oBAAoB,EAQrB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,KAAK,WAAW,EAAqB,MAAM,+BAA+B,CAAC;AACpF,OAAO,KAAK,EACV,WA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+E;IAC/E,UAAU,EAAE,MAAM,CAAC;IACnB,gFAAgF;IAChF,UAAU,EAAE,MAAM,CAAC;IACnB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gFAAgF;IAChF,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAAY,CAAC,EAAE,eAAe,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,2DAA2D;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,4FAA4F;IAC5F,eAAe,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IACjD;;;OAGG;IACH,UAAU,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC;IAC5C;;;;;;;;;;;;;;;;OAgBG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC;IAC5B,oEAAoE;IACpE,OAAO,EAAE,MAAM,CAAC;IAChB,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,WAAW,EAAE,MAAM,CAAC;CACrB;
|
|
1
|
+
{"version":3,"file":"condense-history.d.ts","sourceRoot":"","sources":["../../../src/utils/condense-history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE/F;;;;;;;;;;;;;GAaG;AAEH;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,OAAO,CAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,WAAW,EAAE,EACtB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,EAC/C,GAAG,EAAE,eAAe,EACpB,WAAW,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,GAClD,WAAW,EAAE,CAuLf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"history-transform.d.ts","sourceRoot":"","sources":["../../../src/utils/history-transform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"history-transform.d.ts","sourceRoot":"","sources":["../../../src/utils/history-transform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AA0B9D;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,WAAW,EAAE,CAKjG;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW,EAAE,CAG3F;AAID,uFAAuF;AACvF,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAE9C,sFAAsF;AACtF,eAAO,MAAM,+BAA+B,IAAI,CAAC;AAEjD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM,GAAG,IAAI,CAWhF;AAkCD;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,SAAS,WAAW,EAAE,GAAG;IAC/E,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB,CAYA;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,GAAG,WAAW,EAAE,CAanF;AAED,oEAAoE;AACpE,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,WAAW,GAAG,MAAM,CAG7D"}
|
|
@@ -28,6 +28,23 @@ import { TOOL_FOLD_SYMBOL } from '../../utils/tool-fold';
|
|
|
28
28
|
* `formatBlockedReason`, which returns `undefined` for a figure-less budget so a
|
|
29
29
|
* host-set explanation survives the latch.
|
|
30
30
|
*/
|
|
31
|
+
/**
|
|
32
|
+
* The images on a tool handler's return, or `undefined` if it did not return any.
|
|
33
|
+
*
|
|
34
|
+
* Deliberately strict: `attachments` must be a non-empty array in which EVERY entry carries
|
|
35
|
+
* `kind: 'image'`. A handler returning an ordinary object that happens to have an
|
|
36
|
+
* `attachments` key therefore still JSON-stringifies exactly as it did before, and a
|
|
37
|
+
* half-populated array fails the check rather than silently sending some of the images.
|
|
38
|
+
*/
|
|
39
|
+
const toolResultImages = (result) => {
|
|
40
|
+
if (!result || typeof result !== 'object')
|
|
41
|
+
return undefined;
|
|
42
|
+
const candidate = result.attachments;
|
|
43
|
+
if (!Array.isArray(candidate) || candidate.length === 0)
|
|
44
|
+
return undefined;
|
|
45
|
+
const allImages = candidate.every((att) => !!att && typeof att === 'object' && att.kind === 'image');
|
|
46
|
+
return allImages ? candidate : undefined;
|
|
47
|
+
};
|
|
31
48
|
/**
|
|
32
49
|
* Lift the reportable facts off a {@link ProviderRefusedError} (GENC-1506).
|
|
33
50
|
*
|
|
@@ -2765,15 +2782,25 @@ export class ChatDriver extends EventTarget {
|
|
|
2765
2782
|
const capturedTrace = () => traceCapture.traces.length ? traceCapture.traces.flat() : undefined;
|
|
2766
2783
|
try {
|
|
2767
2784
|
const result = yield handler(tc.args, this.buildHandlerContext(tc.id, traceCapture));
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2785
|
+
// A handler that returns images gets them carried as real attachments instead of
|
|
2786
|
+
// JSON-stringified into the text — the difference between a model reading
|
|
2787
|
+
// `{"kind":"image","data":"iVBOR…"}` as prose and actually SEEING the render.
|
|
2788
|
+
// The guard is deliberately narrow (every entry must carry `kind: 'image'`) so an
|
|
2789
|
+
// ordinary object return that happens to have an `attachments` key still
|
|
2790
|
+
// stringifies exactly as before.
|
|
2791
|
+
const resultImages = toolResultImages(result);
|
|
2792
|
+
const content = resultImages
|
|
2793
|
+
? typeof result.content === 'string'
|
|
2794
|
+
? result.content
|
|
2795
|
+
: JSON.stringify(Object.assign(Object.assign({}, result), { attachments: undefined }))
|
|
2796
|
+
: typeof result === 'string'
|
|
2797
|
+
? result
|
|
2798
|
+
: JSON.stringify(result);
|
|
2799
|
+
executedById.set(tc.id, Object.assign(Object.assign({ toolCallId: tc.id, content }, (resultImages ? { attachments: resultImages } : {})), {
|
|
2772
2800
|
// Concatenated when a handler invoked several children, so none is lost.
|
|
2773
2801
|
// Stays `undefined` when nothing was captured — readers key off presence,
|
|
2774
2802
|
// and an empty array is a different claim from "no sub-agent ran".
|
|
2775
|
-
subAgentTrace: capturedTrace()
|
|
2776
|
-
});
|
|
2803
|
+
subAgentTrace: capturedTrace() }));
|
|
2777
2804
|
anyRealToolExecuted = true;
|
|
2778
2805
|
}
|
|
2779
2806
|
catch (e) {
|
|
@@ -2824,7 +2851,7 @@ export class ChatDriver extends EventTarget {
|
|
|
2824
2851
|
this.appendToHistory({
|
|
2825
2852
|
role: 'tool',
|
|
2826
2853
|
content: '',
|
|
2827
|
-
toolResult: { toolCallId: r.toolCallId, content: r.content },
|
|
2854
|
+
toolResult: Object.assign({ toolCallId: r.toolCallId, content: r.content }, (r.attachments ? { attachments: r.attachments } : {})),
|
|
2828
2855
|
});
|
|
2829
2856
|
}
|
|
2830
2857
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
1
2
|
/**
|
|
2
3
|
* Tool-context condensation: collapse stale tool payloads out of the history
|
|
3
4
|
* sent to the model, while leaving stored history untouched.
|
|
@@ -50,11 +51,19 @@ function triggerReason(trigger) {
|
|
|
50
51
|
* and must not carry the clause. Identifying information is not what separates them — a stub too
|
|
51
52
|
* bare to say what the call did is how GENC-1494 started.
|
|
52
53
|
*/
|
|
53
|
-
function condenseStub(target, tool, trigger, origLen, restorable
|
|
54
|
+
function condenseStub(target, tool, trigger, origLen, restorable,
|
|
55
|
+
/**
|
|
56
|
+
* Images elided alongside the text. Reported separately because the model reads this stub as
|
|
57
|
+
* fact: folding base64 bytes into the char count would tell it a 15KB render was "~15447
|
|
58
|
+
* chars" of prose. One variable cannot be both the size FLOOR (bytes, correctly) and a
|
|
59
|
+
* model-facing description (characters).
|
|
60
|
+
*/
|
|
61
|
+
imageCount = 0) {
|
|
54
62
|
const what = target === 'args' ? 'args' : 'result';
|
|
55
63
|
const key = trigger.kind === 'superseded' ? ` ${trigger.by}` : '';
|
|
56
64
|
const restore = restorable ? '; re-call to restore' : '';
|
|
57
|
-
|
|
65
|
+
const images = imageCount > 0 ? ` + ${imageCount} image${imageCount === 1 ? '' : 's'}` : '';
|
|
66
|
+
return `[${tool}${key} — ${what} elided, ~${origLen} chars${images} (${triggerReason(trigger)})${restore}]`;
|
|
58
67
|
}
|
|
59
68
|
/** Stable label for the `context.condensed` meta-event's `trigger` field. */
|
|
60
69
|
function triggerLabel(trigger) {
|
|
@@ -199,7 +208,7 @@ export function applyCondensation(history, policies, ctx, onCondensed) {
|
|
|
199
208
|
return fired;
|
|
200
209
|
};
|
|
201
210
|
return history.map((msg) => {
|
|
202
|
-
var _a, _b, _c, _d;
|
|
211
|
+
var _a, _b, _c, _d, _e;
|
|
203
212
|
// Tool-call ARGS live on the assistant message.
|
|
204
213
|
if ((_a = msg.toolCalls) === null || _a === void 0 ? void 0 : _a.length) {
|
|
205
214
|
let changed = false;
|
|
@@ -255,16 +264,27 @@ export function applyCondensation(history, policies, ctx, onCondensed) {
|
|
|
255
264
|
const entry = policies.get(msg.toolResult.toolCallId);
|
|
256
265
|
// Defensive `?? 0` for restored/malformed history — `content` is typed
|
|
257
266
|
// `string`, but a 0-length payload is simply below the floor and skipped.
|
|
258
|
-
|
|
267
|
+
//
|
|
268
|
+
// Attachment bytes COUNT toward the floor (GENC-1508). An image-bearing result is
|
|
269
|
+
// typically a few words of text — "rendered the mockup" — plus ~15KB of base64, so
|
|
270
|
+
// sizing on `content` alone leaves it permanently under CONDENSE_MIN_CHARS and the
|
|
271
|
+
// image rides every subsequent turn. That is the exact payload condensation exists
|
|
272
|
+
// to shed, so it must be what is measured.
|
|
273
|
+
const textLen = (_c = (_b = msg.toolResult.content) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
|
|
274
|
+
const images = (_d = msg.toolResult.attachments) !== null && _d !== void 0 ? _d : [];
|
|
275
|
+
// Bytes gate the FLOOR (an image result is a few words of text plus ~15KB of base64, so
|
|
276
|
+
// sizing on text alone would never condense it); `textLen` and the image count are what
|
|
277
|
+
// the model is told. See condenseStub.
|
|
278
|
+
const origLen = textLen + images.reduce((n, att) => { var _a, _b; return n + ((_b = (_a = att.data) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0); }, 0);
|
|
259
279
|
const fired = (entry === null || entry === void 0 ? void 0 : entry.policy.response)
|
|
260
280
|
? firstFired(msg.toolResult.toolCallId, entry)
|
|
261
281
|
: undefined;
|
|
262
282
|
if (entry && fired && origLen >= CONDENSE_MIN_CHARS) {
|
|
263
|
-
const tool = (
|
|
283
|
+
const tool = (_e = nameById.get(msg.toolResult.toolCallId)) !== null && _e !== void 0 ? _e : msg.toolResult.toolCallId;
|
|
264
284
|
const result = entry.policy.response; // `fired` is only set when response is declared
|
|
265
285
|
// Kept non-empty — Anthropic rejects empty tool_result content.
|
|
266
286
|
const content = result === 'drop' || result === 'pointer'
|
|
267
|
-
? condenseStub('response', tool, fired,
|
|
287
|
+
? condenseStub('response', tool, fired, textLen, result === 'pointer', images.length)
|
|
268
288
|
: result.replaceWith;
|
|
269
289
|
if (!entry.reportedResponse) {
|
|
270
290
|
entry.reportedResponse = true;
|
|
@@ -278,7 +298,11 @@ export function applyCondensation(history, policies, ctx, onCondensed) {
|
|
|
278
298
|
tokensSaved: estimateTokensSaved(origLen, content.length),
|
|
279
299
|
});
|
|
280
300
|
}
|
|
281
|
-
|
|
301
|
+
// `attachments` is dropped, not spread through: the stub says the payload was
|
|
302
|
+
// elided, and leaving the images attached would make that a lie AND shed none of
|
|
303
|
+
// the bytes the condensation was performed to shed.
|
|
304
|
+
const _f = msg.toolResult, { attachments: _elided } = _f, restOfResult = __rest(_f, ["attachments"]);
|
|
305
|
+
return Object.assign(Object.assign({}, msg), { toolResult: Object.assign(Object.assign({}, restOfResult), { content }) });
|
|
282
306
|
}
|
|
283
307
|
}
|
|
284
308
|
return msg;
|
|
@@ -381,7 +381,6 @@ suite('multi-trigger first-wins: the earliest-listed firing trigger is the reaso
|
|
|
381
381
|
assert.is((_a = events.find((e) => e.toolCallId === 'm1')) === null || _a === void 0 ? void 0 : _a.trigger, 'superseded:A', 'first-listed firing trigger wins as the reason');
|
|
382
382
|
assert.is((_b = events.find((e) => e.toolCallId === 'm2')) === null || _b === void 0 ? void 0 : _b.trigger, 'turnEnd', 'the supersession survivor still collapses via the next trigger');
|
|
383
383
|
});
|
|
384
|
-
suite.run();
|
|
385
384
|
// ── batched collapse (GENC-1476) ───────────────────────────────────────────
|
|
386
385
|
// Condensation rewrites history in place, so collapsing the instant a trigger fires
|
|
387
386
|
// breaks the prompt cache on nearly every call of a re-read loop. Batching holds the
|
|
@@ -478,3 +477,71 @@ batch('a mixed policy batches superseded but still honours agentEnd immediately'
|
|
|
478
477
|
assert.is(afterSwap.filter((c) => c.startsWith('[')).length, 2, 'agentEnd collapses both');
|
|
479
478
|
});
|
|
480
479
|
batch.run();
|
|
480
|
+
// ---------------------------------------------------------------------------
|
|
481
|
+
// image-bearing tool results (GENC-1508)
|
|
482
|
+
//
|
|
483
|
+
// A render tool returns a few words of text plus ~15KB of base64. Sizing the payload
|
|
484
|
+
// on `content` alone leaves it permanently under the floor, so the image rides every
|
|
485
|
+
// later turn — the exact bytes condensation exists to shed. And a stub that leaves the
|
|
486
|
+
// attachments in place claims a collapse that did not happen.
|
|
487
|
+
// ---------------------------------------------------------------------------
|
|
488
|
+
/** A tool result shaped like a mockup render: short text, one large image. */
|
|
489
|
+
const imageToolMsg = (toolCallId, dataLen) => ({
|
|
490
|
+
role: 'tool',
|
|
491
|
+
content: 'rendered',
|
|
492
|
+
toolResult: {
|
|
493
|
+
toolCallId,
|
|
494
|
+
content: 'rendered',
|
|
495
|
+
attachments: [
|
|
496
|
+
{ kind: 'image', name: 'mockup.png', mimeType: 'image/png', data: 'a'.repeat(dataLen) },
|
|
497
|
+
],
|
|
498
|
+
},
|
|
499
|
+
});
|
|
500
|
+
suite('image bytes count toward the condense floor, so a short-text render condenses', () => {
|
|
501
|
+
const history = [
|
|
502
|
+
asstCall('m1', 'render_mockup', { html: '<p/>' }),
|
|
503
|
+
imageToolMsg('m1', CONDENSE_MIN_CHARS + 500),
|
|
504
|
+
asstCall('m2', 'render_mockup', { html: '<p/>' }),
|
|
505
|
+
imageToolMsg('m2', CONDENSE_MIN_CHARS + 500),
|
|
506
|
+
];
|
|
507
|
+
const policies = new Map([
|
|
508
|
+
['m1', reg({ on: { kind: 'superseded', by: 'mockup' }, response: 'pointer' })],
|
|
509
|
+
['m2', reg({ on: { kind: 'superseded', by: 'mockup' }, response: 'pointer' })],
|
|
510
|
+
]);
|
|
511
|
+
const { on } = sink();
|
|
512
|
+
const out = applyCondensation(history, policies, ctx(), on);
|
|
513
|
+
assert.ok(out[1].toolResult.content.startsWith('['), 'the superseded render is collapsed to a stub — sizing on content alone would skip it');
|
|
514
|
+
});
|
|
515
|
+
suite('a condensed image result drops its attachments, not just its text', () => {
|
|
516
|
+
var _a;
|
|
517
|
+
const history = [
|
|
518
|
+
asstCall('m1', 'render_mockup', { html: '<p/>' }),
|
|
519
|
+
imageToolMsg('m1', CONDENSE_MIN_CHARS + 500),
|
|
520
|
+
asstCall('m2', 'render_mockup', { html: '<p/>' }),
|
|
521
|
+
imageToolMsg('m2', CONDENSE_MIN_CHARS + 500),
|
|
522
|
+
];
|
|
523
|
+
const policies = new Map([
|
|
524
|
+
['m1', reg({ on: { kind: 'superseded', by: 'mockup' }, response: 'pointer' })],
|
|
525
|
+
['m2', reg({ on: { kind: 'superseded', by: 'mockup' }, response: 'pointer' })],
|
|
526
|
+
]);
|
|
527
|
+
const { on } = sink();
|
|
528
|
+
const out = applyCondensation(history, policies, ctx(), on);
|
|
529
|
+
assert.is(out[1].toolResult.attachments, undefined, 'leaving the image attached would shed none of the bytes the stub claims were elided');
|
|
530
|
+
assert.equal((_a = out[3].toolResult.attachments) === null || _a === void 0 ? void 0 : _a.length, 1, 'the surviving latest render keeps its image');
|
|
531
|
+
});
|
|
532
|
+
suite('a short text-only result is still below the floor with no attachments', () => {
|
|
533
|
+
const history = [
|
|
534
|
+
asstCall('s1', 'render_mockup', {}),
|
|
535
|
+
toolMsg('s1', 'rendered'),
|
|
536
|
+
asstCall('s2', 'render_mockup', {}),
|
|
537
|
+
toolMsg('s2', 'rendered'),
|
|
538
|
+
];
|
|
539
|
+
const policies = new Map([
|
|
540
|
+
['s1', reg({ on: { kind: 'superseded', by: 'mockup' }, response: 'pointer' })],
|
|
541
|
+
['s2', reg({ on: { kind: 'superseded', by: 'mockup' }, response: 'pointer' })],
|
|
542
|
+
]);
|
|
543
|
+
const { on } = sink();
|
|
544
|
+
const out = applyCondensation(history, policies, ctx(), on);
|
|
545
|
+
assert.is(out[1].toolResult.content, 'rendered', 'the floor still protects small payloads');
|
|
546
|
+
});
|
|
547
|
+
suite.run();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
1
2
|
/**
|
|
2
3
|
* Masks the tool-specific payload of a single message — clears tool call args
|
|
3
4
|
* and replaces tool result content with a placeholder. Used when passing history
|
|
@@ -9,7 +10,13 @@ function maskToolPayload(msg) {
|
|
|
9
10
|
return Object.assign(Object.assign({}, msg), { toolCalls: msg.toolCalls.map((tc) => (Object.assign(Object.assign({}, tc), { args: {} }))) });
|
|
10
11
|
}
|
|
11
12
|
if (msg.toolResult) {
|
|
12
|
-
|
|
13
|
+
// `attachments` is dropped, not spread through. Masking exists to keep another agent's
|
|
14
|
+
// payload out of this one's context, and an image is the largest payload there is — spreading
|
|
15
|
+
// it would stub the prose while still shipping the render, defeating the mask for exactly the
|
|
16
|
+
// case it matters most. `applyHistoryCap` masks everything past the cap for sub-agent context,
|
|
17
|
+
// so without this every older image rides every sub-agent turn under an "omitted" label.
|
|
18
|
+
const _b = msg.toolResult, { attachments: _masked } = _b, restOfResult = __rest(_b, ["attachments"]);
|
|
19
|
+
return Object.assign(Object.assign({}, msg), { toolResult: Object.assign(Object.assign({}, restOfResult), { content: "[other agent's tool result omitted]" }) });
|
|
13
20
|
}
|
|
14
21
|
return msg;
|
|
15
22
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert, createLogicSuite } from '@genesislcap/foundation-testing';
|
|
2
|
-
import { buildCompactionSummaryPrompt, compactionDividerLabel, COMPACT_KEEP_RECENT_MESSAGES, COMPACT_MIN_MESSAGES_TO_COMPACT, findCompactionCut, normalizeForProvider, } from './history-transform';
|
|
2
|
+
import { buildCompactionSummaryPrompt, compactionDividerLabel, COMPACT_KEEP_RECENT_MESSAGES, COMPACT_MIN_MESSAGES_TO_COMPACT, findCompactionCut, normalizeForProvider, transformHistoryForAgent, } from './history-transform';
|
|
3
3
|
const asMsg = (o) => o;
|
|
4
4
|
const user = (content) => asMsg({ role: 'user', content });
|
|
5
5
|
const assistant = (content) => asMsg({ role: 'assistant', content });
|
|
@@ -134,4 +134,25 @@ Suite('compactionDividerLabel pluralizes and falls back to 0', () => {
|
|
|
134
134
|
assert.is(compactionDividerLabel(asMsg({ role: 'compacted-summary', content: '', compaction: { compactedCount: 12 } })), 'Compacted 12 earlier messages');
|
|
135
135
|
assert.is(compactionDividerLabel(asMsg({ role: 'compacted-summary', content: '' })), 'Compacted 0 earlier messages');
|
|
136
136
|
});
|
|
137
|
+
// ── masking another agent's tool payload (GENC-1508) ─────────────────────────
|
|
138
|
+
Suite('transformHistoryForAgent drops tool-result IMAGES, not just the text', () => {
|
|
139
|
+
const history = [
|
|
140
|
+
asMsg({
|
|
141
|
+
role: 'tool',
|
|
142
|
+
content: '',
|
|
143
|
+
agentName: 'other-agent',
|
|
144
|
+
toolResult: {
|
|
145
|
+
toolCallId: 'r1',
|
|
146
|
+
content: 'rendered the mockup',
|
|
147
|
+
attachments: [
|
|
148
|
+
{ kind: 'image', name: 'mockup.png', mimeType: 'image/png', data: 'a'.repeat(2000) },
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
}),
|
|
152
|
+
];
|
|
153
|
+
const out = transformHistoryForAgent(history, 'this-agent');
|
|
154
|
+
assert.ok(out[0].toolResult.content.includes('omitted'), 'the text is stubbed, as it always was');
|
|
155
|
+
assert.is(out[0].toolResult.attachments, undefined, "masking exists to keep another agent's payload out of context — an image IS the payload, " +
|
|
156
|
+
'and stubbing the prose while shipping the render defeats the mask where it matters most');
|
|
157
|
+
});
|
|
137
158
|
Suite.run();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/ai-assistant",
|
|
3
3
|
"description": "Genesis AI Assistant micro-frontend",
|
|
4
|
-
"version": "15.
|
|
4
|
+
"version": "15.15.0",
|
|
5
5
|
"license": "SEE LICENSE IN license.txt",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/ai-assistant.d.ts",
|
|
@@ -73,26 +73,26 @@
|
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@genesislcap/foundation-testing": "15.
|
|
77
|
-
"@genesislcap/genx": "15.
|
|
78
|
-
"@genesislcap/rollup-builder": "15.
|
|
79
|
-
"@genesislcap/ts-builder": "15.
|
|
80
|
-
"@genesislcap/uvu-playwright-builder": "15.
|
|
81
|
-
"@genesislcap/vite-builder": "15.
|
|
82
|
-
"@genesislcap/webpack-builder": "15.
|
|
76
|
+
"@genesislcap/foundation-testing": "15.15.0",
|
|
77
|
+
"@genesislcap/genx": "15.15.0",
|
|
78
|
+
"@genesislcap/rollup-builder": "15.15.0",
|
|
79
|
+
"@genesislcap/ts-builder": "15.15.0",
|
|
80
|
+
"@genesislcap/uvu-playwright-builder": "15.15.0",
|
|
81
|
+
"@genesislcap/vite-builder": "15.15.0",
|
|
82
|
+
"@genesislcap/webpack-builder": "15.15.0",
|
|
83
83
|
"@types/dompurify": "^3.0.5",
|
|
84
84
|
"@types/marked": "^5.0.2",
|
|
85
85
|
"esbuild": "0.25.12"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@genesislcap/foundation-ai": "15.
|
|
89
|
-
"@genesislcap/foundation-logger": "15.
|
|
90
|
-
"@genesislcap/foundation-notifications": "15.
|
|
91
|
-
"@genesislcap/foundation-redux": "15.
|
|
92
|
-
"@genesislcap/foundation-ui": "15.
|
|
93
|
-
"@genesislcap/foundation-utils": "15.
|
|
94
|
-
"@genesislcap/rapid-design-system": "15.
|
|
95
|
-
"@genesislcap/web-core": "15.
|
|
88
|
+
"@genesislcap/foundation-ai": "15.15.0",
|
|
89
|
+
"@genesislcap/foundation-logger": "15.15.0",
|
|
90
|
+
"@genesislcap/foundation-notifications": "15.15.0",
|
|
91
|
+
"@genesislcap/foundation-redux": "15.15.0",
|
|
92
|
+
"@genesislcap/foundation-ui": "15.15.0",
|
|
93
|
+
"@genesislcap/foundation-utils": "15.15.0",
|
|
94
|
+
"@genesislcap/rapid-design-system": "15.15.0",
|
|
95
|
+
"@genesislcap/web-core": "15.15.0",
|
|
96
96
|
"dompurify": "^3.3.1",
|
|
97
97
|
"marked": "^17.0.3"
|
|
98
98
|
},
|
|
@@ -105,5 +105,5 @@
|
|
|
105
105
|
"access": "public"
|
|
106
106
|
},
|
|
107
107
|
"customElements": "dist/custom-elements.json",
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "6cb5a251c9b3e1bf509fece8db32acdc1d4c747b"
|
|
109
109
|
}
|
package/src/chat-driver-node.ts
CHANGED
|
@@ -85,13 +85,20 @@ export type {
|
|
|
85
85
|
AIProviderRegistry,
|
|
86
86
|
AnthropicModelId,
|
|
87
87
|
CachePolicy,
|
|
88
|
+
// The attachment union, so a headless caller can hand a screenshot to a model or return one
|
|
89
|
+
// from a tool handler without restating the shape — and, more to the point, without missing
|
|
90
|
+
// that the image arm's `kind` is REQUIRED and is the only thing the transports branch on.
|
|
91
|
+
ChatAttachment,
|
|
88
92
|
ChatFallback,
|
|
93
|
+
ChatImageAttachment,
|
|
89
94
|
ChatMessage,
|
|
90
95
|
ChatRequestOptions,
|
|
96
|
+
ChatTextAttachment,
|
|
91
97
|
ChatThinkingPolicy,
|
|
92
98
|
ChatToolChoice,
|
|
93
99
|
ChatToolDefinition,
|
|
94
100
|
ChatToolHandlers,
|
|
101
|
+
ChatToolResult,
|
|
95
102
|
GeminiModelId,
|
|
96
103
|
// Pricing input/output shapes, alongside the functions re-exported above — a caller that
|
|
97
104
|
// can invoke them but cannot name their argument or result has to restate the shape by
|
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
ChatAttachment,
|
|
8
8
|
ChatDriverResult,
|
|
9
9
|
ChatFallback,
|
|
10
|
+
ChatImageAttachment,
|
|
10
11
|
ChatMessage,
|
|
11
12
|
ChatRequestOptions,
|
|
12
13
|
ChatThinkingPolicy,
|
|
@@ -106,6 +107,24 @@ type ProviderRefusedDetail = NonNullable<
|
|
|
106
107
|
* `formatBlockedReason`, which returns `undefined` for a figure-less budget so a
|
|
107
108
|
* host-set explanation survives the latch.
|
|
108
109
|
*/
|
|
110
|
+
/**
|
|
111
|
+
* The images on a tool handler's return, or `undefined` if it did not return any.
|
|
112
|
+
*
|
|
113
|
+
* Deliberately strict: `attachments` must be a non-empty array in which EVERY entry carries
|
|
114
|
+
* `kind: 'image'`. A handler returning an ordinary object that happens to have an
|
|
115
|
+
* `attachments` key therefore still JSON-stringifies exactly as it did before, and a
|
|
116
|
+
* half-populated array fails the check rather than silently sending some of the images.
|
|
117
|
+
*/
|
|
118
|
+
const toolResultImages = (result: unknown): ChatImageAttachment[] | undefined => {
|
|
119
|
+
if (!result || typeof result !== 'object') return undefined;
|
|
120
|
+
const candidate = (result as { attachments?: unknown }).attachments;
|
|
121
|
+
if (!Array.isArray(candidate) || candidate.length === 0) return undefined;
|
|
122
|
+
const allImages = candidate.every(
|
|
123
|
+
(att) => !!att && typeof att === 'object' && (att as { kind?: unknown }).kind === 'image',
|
|
124
|
+
);
|
|
125
|
+
return allImages ? (candidate as ChatImageAttachment[]) : undefined;
|
|
126
|
+
};
|
|
127
|
+
|
|
109
128
|
/**
|
|
110
129
|
* Lift the reportable facts off a {@link ProviderRefusedError} (GENC-1506).
|
|
111
130
|
*
|
|
@@ -3415,7 +3434,12 @@ export class ChatDriver extends EventTarget implements AiDriver {
|
|
|
3415
3434
|
|
|
3416
3435
|
const executedById = new Map<
|
|
3417
3436
|
string,
|
|
3418
|
-
{
|
|
3437
|
+
{
|
|
3438
|
+
toolCallId: string;
|
|
3439
|
+
content: string;
|
|
3440
|
+
attachments?: ChatImageAttachment[];
|
|
3441
|
+
subAgentTrace?: ChatMessage[];
|
|
3442
|
+
}
|
|
3419
3443
|
>();
|
|
3420
3444
|
const unknownToolIds = new Set<string>();
|
|
3421
3445
|
// Subset of unknownToolIds that were stale (previously available) rather
|
|
@@ -3579,10 +3603,24 @@ export class ChatDriver extends EventTarget implements AiDriver {
|
|
|
3579
3603
|
traceCapture.traces.length ? traceCapture.traces.flat() : undefined;
|
|
3580
3604
|
try {
|
|
3581
3605
|
const result = await handler(tc.args, this.buildHandlerContext(tc.id, traceCapture));
|
|
3582
|
-
|
|
3606
|
+
// A handler that returns images gets them carried as real attachments instead of
|
|
3607
|
+
// JSON-stringified into the text — the difference between a model reading
|
|
3608
|
+
// `{"kind":"image","data":"iVBOR…"}` as prose and actually SEEING the render.
|
|
3609
|
+
// The guard is deliberately narrow (every entry must carry `kind: 'image'`) so an
|
|
3610
|
+
// ordinary object return that happens to have an `attachments` key still
|
|
3611
|
+
// stringifies exactly as before.
|
|
3612
|
+
const resultImages = toolResultImages(result);
|
|
3613
|
+
const content = resultImages
|
|
3614
|
+
? typeof (result as { content?: unknown }).content === 'string'
|
|
3615
|
+
? (result as { content: string }).content
|
|
3616
|
+
: JSON.stringify({ ...(result as object), attachments: undefined })
|
|
3617
|
+
: typeof result === 'string'
|
|
3618
|
+
? result
|
|
3619
|
+
: JSON.stringify(result);
|
|
3583
3620
|
executedById.set(tc.id, {
|
|
3584
3621
|
toolCallId: tc.id,
|
|
3585
3622
|
content,
|
|
3623
|
+
...(resultImages ? { attachments: resultImages } : {}),
|
|
3586
3624
|
// Concatenated when a handler invoked several children, so none is lost.
|
|
3587
3625
|
// Stays `undefined` when nothing was captured — readers key off presence,
|
|
3588
3626
|
// and an empty array is a different claim from "no sub-agent ran".
|
|
@@ -3640,7 +3678,14 @@ export class ChatDriver extends EventTarget implements AiDriver {
|
|
|
3640
3678
|
this.appendToHistory({
|
|
3641
3679
|
role: 'tool',
|
|
3642
3680
|
content: '',
|
|
3643
|
-
toolResult: {
|
|
3681
|
+
toolResult: {
|
|
3682
|
+
toolCallId: r.toolCallId,
|
|
3683
|
+
content: r.content,
|
|
3684
|
+
// Images DO persist, unlike the sub-agent trace above: they are the payload
|
|
3685
|
+
// the model must see on every replay of this turn, not a one-off UI artefact.
|
|
3686
|
+
// `condenseWhen` is what sheds them once they are spent — see condense-history.
|
|
3687
|
+
...(r.attachments ? { attachments: r.attachments } : {}),
|
|
3688
|
+
},
|
|
3644
3689
|
});
|
|
3645
3690
|
}
|
|
3646
3691
|
}
|