@vellumai/assistant 0.8.8-dev.202606061631.10cd5fe → 0.8.8-dev.202606061701.9ee494c
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/openapi.yaml +176 -0
- package/package.json +1 -1
- package/src/__tests__/conversation-agent-loop.test.ts +5 -10
- package/src/__tests__/conversation-runtime-assembly.test.ts +29 -24
- package/src/__tests__/injector-chain.test.ts +31 -17
- package/src/__tests__/injector-disk-pressure.test.ts +17 -4
- package/src/cli/lib/__tests__/plugin-details.test.ts +372 -0
- package/src/cli/lib/plugin-details.ts +409 -0
- package/src/daemon/conversation-agent-loop.ts +13 -24
- package/src/daemon/conversation-runtime-assembly.ts +46 -218
- package/src/plugins/defaults/memory-retrieval/hooks/post-compact.ts +14 -11
- package/src/plugins/defaults/memory-retrieval/injectors.ts +19 -6
- package/src/plugins/defaults/memory-retrieval/unified-turn-context.ts +223 -0
- package/src/plugins/types.ts +32 -2
- package/src/runtime/routes/__tests__/plugins-routes.test.ts +255 -4
- package/src/runtime/routes/plugins-routes.ts +236 -21
package/openapi.yaml
CHANGED
|
@@ -19426,6 +19426,182 @@ paths:
|
|
|
19426
19426
|
required: true
|
|
19427
19427
|
schema:
|
|
19428
19428
|
type: string
|
|
19429
|
+
get:
|
|
19430
|
+
operationId: plugins_by_name_get
|
|
19431
|
+
summary: Get a plugin's detail view
|
|
19432
|
+
description:
|
|
19433
|
+
Resolve a single plugin's tracked metadata (description, homepage, license, version, source) plus its
|
|
19434
|
+
README markdown. Unions the locally installed copy, the marketplace manifest, and the plugin's repository at the
|
|
19435
|
+
pinned ref — preferring the installed copy. Names that are neither installed nor present in the catalog return
|
|
19436
|
+
404. Powers the web plugin detail page; mirrors `GET /v1/skills/:id`.
|
|
19437
|
+
tags:
|
|
19438
|
+
- plugins
|
|
19439
|
+
responses:
|
|
19440
|
+
"200":
|
|
19441
|
+
description: Successful response
|
|
19442
|
+
content:
|
|
19443
|
+
application/json:
|
|
19444
|
+
schema:
|
|
19445
|
+
type: object
|
|
19446
|
+
properties:
|
|
19447
|
+
name:
|
|
19448
|
+
type: string
|
|
19449
|
+
description: Install name. Matches `assistant plugins install <name>`.
|
|
19450
|
+
installed:
|
|
19451
|
+
type: boolean
|
|
19452
|
+
description: Whether a copy is materialized under `<workspaceDir>/plugins/<name>/`.
|
|
19453
|
+
description:
|
|
19454
|
+
anyOf:
|
|
19455
|
+
- type: string
|
|
19456
|
+
- type: "null"
|
|
19457
|
+
description: Short description, best-effort across disk, manifest, and repo.
|
|
19458
|
+
homepage:
|
|
19459
|
+
anyOf:
|
|
19460
|
+
- type: string
|
|
19461
|
+
- type: "null"
|
|
19462
|
+
description: Project homepage URL, when known.
|
|
19463
|
+
license:
|
|
19464
|
+
anyOf:
|
|
19465
|
+
- type: string
|
|
19466
|
+
- type: "null"
|
|
19467
|
+
description: SPDX license expression, when known.
|
|
19468
|
+
version:
|
|
19469
|
+
anyOf:
|
|
19470
|
+
- type: string
|
|
19471
|
+
- type: "null"
|
|
19472
|
+
description: Resolved version (installed copy first, then repo `package.json`).
|
|
19473
|
+
source:
|
|
19474
|
+
oneOf:
|
|
19475
|
+
- type: object
|
|
19476
|
+
properties:
|
|
19477
|
+
kind:
|
|
19478
|
+
type: string
|
|
19479
|
+
const: first-party
|
|
19480
|
+
required:
|
|
19481
|
+
- kind
|
|
19482
|
+
additionalProperties: false
|
|
19483
|
+
- type: object
|
|
19484
|
+
properties:
|
|
19485
|
+
kind:
|
|
19486
|
+
type: string
|
|
19487
|
+
const: github
|
|
19488
|
+
repo:
|
|
19489
|
+
type: string
|
|
19490
|
+
description: "`owner/repo` of the external plugin repository."
|
|
19491
|
+
path:
|
|
19492
|
+
description: Directory within the repo, when the plugin is not at the root.
|
|
19493
|
+
type: string
|
|
19494
|
+
ref:
|
|
19495
|
+
type: string
|
|
19496
|
+
description: Pinned git ref the plugin is fetched from.
|
|
19497
|
+
required:
|
|
19498
|
+
- kind
|
|
19499
|
+
- repo
|
|
19500
|
+
- ref
|
|
19501
|
+
additionalProperties: false
|
|
19502
|
+
description: "Origin of the match: a first-party in-repo plugin or a whitelisted external one."
|
|
19503
|
+
readme:
|
|
19504
|
+
anyOf:
|
|
19505
|
+
- type: string
|
|
19506
|
+
- type: "null"
|
|
19507
|
+
description: README markdown, or null when the plugin ships none.
|
|
19508
|
+
ref:
|
|
19509
|
+
type: string
|
|
19510
|
+
description: Git ref the catalog metadata / README were resolved at.
|
|
19511
|
+
required:
|
|
19512
|
+
- name
|
|
19513
|
+
- installed
|
|
19514
|
+
- description
|
|
19515
|
+
- homepage
|
|
19516
|
+
- license
|
|
19517
|
+
- version
|
|
19518
|
+
- source
|
|
19519
|
+
- readme
|
|
19520
|
+
- ref
|
|
19521
|
+
additionalProperties: false
|
|
19522
|
+
"400":
|
|
19523
|
+
description: The plugin name failed sanitization (e.g. contained slashes, dots, or uppercase letters).
|
|
19524
|
+
"404":
|
|
19525
|
+
description: No installed copy and no catalog entry claims the given name.
|
|
19526
|
+
parameters:
|
|
19527
|
+
- name: name
|
|
19528
|
+
in: path
|
|
19529
|
+
required: true
|
|
19530
|
+
schema:
|
|
19531
|
+
type: string
|
|
19532
|
+
- name: ref
|
|
19533
|
+
in: query
|
|
19534
|
+
required: false
|
|
19535
|
+
schema:
|
|
19536
|
+
type: string
|
|
19537
|
+
description: Optional git ref to read catalog metadata / README at. Defaults to the CLI's `DEFAULT_PLUGIN_REF`.
|
|
19538
|
+
/v1/plugins/install:
|
|
19539
|
+
post:
|
|
19540
|
+
operationId: plugins_install_post
|
|
19541
|
+
summary: Install a plugin
|
|
19542
|
+
description:
|
|
19543
|
+
Install a plugin by name from the canonical source — a whitelisted `experimental/plugins/marketplace.json`
|
|
19544
|
+
entry, else the first-party `experimental/plugins/<name>/` convention. Materializes the plugin under
|
|
19545
|
+
`<workspaceDir>/plugins/<name>/`; the assistant must be restarted to load it. Mirrors the CLI's `assistant
|
|
19546
|
+
plugins install <name>`. An already-installed name without `force` returns 409; a name that resolves to nothing
|
|
19547
|
+
at the ref returns 404. Sibling to `POST /v1/skills/install`.
|
|
19548
|
+
tags:
|
|
19549
|
+
- plugins
|
|
19550
|
+
responses:
|
|
19551
|
+
"200":
|
|
19552
|
+
description: Successful response
|
|
19553
|
+
content:
|
|
19554
|
+
application/json:
|
|
19555
|
+
schema:
|
|
19556
|
+
type: object
|
|
19557
|
+
properties:
|
|
19558
|
+
ok:
|
|
19559
|
+
type: boolean
|
|
19560
|
+
const: true
|
|
19561
|
+
name:
|
|
19562
|
+
type: string
|
|
19563
|
+
description: Install name that was materialized.
|
|
19564
|
+
target:
|
|
19565
|
+
type: string
|
|
19566
|
+
description: Absolute path the plugin was materialized into on the host.
|
|
19567
|
+
fileCount:
|
|
19568
|
+
type: number
|
|
19569
|
+
description: Number of files written for the installed plugin.
|
|
19570
|
+
ref:
|
|
19571
|
+
type: string
|
|
19572
|
+
description: Git ref the plugin was fetched from.
|
|
19573
|
+
required:
|
|
19574
|
+
- ok
|
|
19575
|
+
- name
|
|
19576
|
+
- target
|
|
19577
|
+
- fileCount
|
|
19578
|
+
- ref
|
|
19579
|
+
additionalProperties: false
|
|
19580
|
+
"400":
|
|
19581
|
+
description: The request body was missing `name` or the name failed sanitization.
|
|
19582
|
+
"404":
|
|
19583
|
+
description: No plugin resolves to the given name at the requested ref.
|
|
19584
|
+
"409":
|
|
19585
|
+
description: A plugin with the same name is already installed and `force` was not set.
|
|
19586
|
+
requestBody:
|
|
19587
|
+
required: true
|
|
19588
|
+
content:
|
|
19589
|
+
application/json:
|
|
19590
|
+
schema:
|
|
19591
|
+
type: object
|
|
19592
|
+
properties:
|
|
19593
|
+
name:
|
|
19594
|
+
type: string
|
|
19595
|
+
description: Install name to resolve against the catalog (first-party directory or marketplace entry).
|
|
19596
|
+
ref:
|
|
19597
|
+
description: Optional git ref to install from. Defaults to the CLI's `DEFAULT_PLUGIN_REF`.
|
|
19598
|
+
type: string
|
|
19599
|
+
force:
|
|
19600
|
+
description: Overwrite an existing install in place. Defaults to false.
|
|
19601
|
+
type: boolean
|
|
19602
|
+
required:
|
|
19603
|
+
- name
|
|
19604
|
+
additionalProperties: false
|
|
19429
19605
|
/v1/plugins/search:
|
|
19430
19606
|
get:
|
|
19431
19607
|
operationId: plugins_search_get
|
package/package.json
CHANGED
|
@@ -312,10 +312,6 @@ let mockInjectionBlocks: {
|
|
|
312
312
|
pkbSystemReminder?: string;
|
|
313
313
|
unifiedTurnContext?: string;
|
|
314
314
|
} = {};
|
|
315
|
-
const buildUnifiedTurnContextBlockMock = mock(
|
|
316
|
-
(options: Record<string, unknown>) =>
|
|
317
|
-
`<turn_context>\ncurrent_time: ${String(options.timestamp)}\n</turn_context>`,
|
|
318
|
-
);
|
|
319
315
|
const defaultApplyRuntimeInjectionsImpl = async (
|
|
320
316
|
msgs: Message[],
|
|
321
317
|
_options?: unknown,
|
|
@@ -360,7 +356,6 @@ const getSlackCompactionWatermarkForPrefixMock = mock(
|
|
|
360
356
|
);
|
|
361
357
|
mock.module("../daemon/conversation-runtime-assembly.js", () => ({
|
|
362
358
|
applyRuntimeInjections: applyRuntimeInjectionsMock,
|
|
363
|
-
buildUnifiedTurnContextBlock: buildUnifiedTurnContextBlockMock,
|
|
364
359
|
stripInjectionsForCompaction: (msgs: Message[]) => msgs,
|
|
365
360
|
isSlackChannelConversation: () => false,
|
|
366
361
|
getSlackCompactionWatermarkForPrefix:
|
|
@@ -746,7 +741,6 @@ beforeEach(() => {
|
|
|
746
741
|
applyRuntimeInjectionsMock.mockImplementation(
|
|
747
742
|
defaultApplyRuntimeInjectionsImpl,
|
|
748
743
|
);
|
|
749
|
-
buildUnifiedTurnContextBlockMock.mockClear();
|
|
750
744
|
resolveTurnTimezoneContextMock.mockClear();
|
|
751
745
|
formatTurnTimestampMock.mockClear();
|
|
752
746
|
mockSlackChronologicalContext = null;
|
|
@@ -806,10 +800,11 @@ describe("session-agent-loop", () => {
|
|
|
806
800
|
expect(formatTurnTimestampMock).toHaveBeenCalledWith({
|
|
807
801
|
timeZone: "America/New_York",
|
|
808
802
|
});
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
803
|
+
// The loop resolves the unified turn-context inputs into the injection
|
|
804
|
+
// options bag; the `unified-turn-context` injector later builds the block
|
|
805
|
+
// from them.
|
|
806
|
+
const injectionOptions = applyRuntimeInjectionsMock.mock.calls[0]?.[1];
|
|
807
|
+
expect(injectionOptions).toMatchObject({
|
|
813
808
|
configuredUserTimezone: "America/New_York",
|
|
814
809
|
clientTimezone: "America/Los_Angeles",
|
|
815
810
|
detectedTimezone: "America/Chicago",
|
|
@@ -42,14 +42,12 @@ import {
|
|
|
42
42
|
import type {
|
|
43
43
|
ChannelCapabilities,
|
|
44
44
|
SlackTranscriptInputRow,
|
|
45
|
-
UnifiedTurnContextOptions,
|
|
46
45
|
} from "../daemon/conversation-runtime-assembly.js";
|
|
47
46
|
import {
|
|
48
47
|
applyRuntimeInjections,
|
|
49
48
|
assembleSlackActiveThreadFocusBlock,
|
|
50
49
|
assembleSlackChronologicalMessages,
|
|
51
50
|
buildSubagentStatusBlock,
|
|
52
|
-
buildUnifiedTurnContextBlock,
|
|
53
51
|
getSlackCompactionWatermarkForPrefix,
|
|
54
52
|
injectChannelCapabilityContext,
|
|
55
53
|
injectChannelCommandContext,
|
|
@@ -73,6 +71,10 @@ import {
|
|
|
73
71
|
writeSlackMetadata,
|
|
74
72
|
} from "../messaging/providers/slack/message-metadata.js";
|
|
75
73
|
import { parentAlias } from "../messaging/providers/slack/render-transcript.js";
|
|
74
|
+
import {
|
|
75
|
+
buildUnifiedTurnContextBlock,
|
|
76
|
+
type UnifiedTurnContextOptions,
|
|
77
|
+
} from "../plugins/defaults/memory-retrieval/unified-turn-context.js";
|
|
76
78
|
import type { Message } from "../providers/types.js";
|
|
77
79
|
import { wrapUntrustedContent } from "../security/untrusted-content.js";
|
|
78
80
|
import { getSubagentManager } from "../subagent/index.js";
|
|
@@ -826,8 +828,10 @@ describe("applyRuntimeInjections — injection mode", () => {
|
|
|
826
828
|
const fullOptions = {
|
|
827
829
|
// Non-interactive turn so the `<non_interactive_context>` branch fires.
|
|
828
830
|
isNonInteractive: true,
|
|
829
|
-
|
|
830
|
-
|
|
831
|
+
// Unified turn-context inputs so the `unified-turn-context` injector emits
|
|
832
|
+
// the `<turn_context>` block from the options bag.
|
|
833
|
+
timestamp: "2026-03-04 (Tuesday) 12:00:00 +00:00 (UTC)",
|
|
834
|
+
interfaceName: "telegram",
|
|
831
835
|
// Guardian trust so the personal-memory gate admits the actor regardless
|
|
832
836
|
// of the telegram channel capabilities under test, letting the reminder
|
|
833
837
|
// gate hinge purely on PKB content presence.
|
|
@@ -1763,6 +1767,8 @@ describe("buildUnifiedTurnContextBlock", () => {
|
|
|
1763
1767
|
// ---------------------------------------------------------------------------
|
|
1764
1768
|
|
|
1765
1769
|
describe("applyRuntimeInjections with unifiedTurnContext", () => {
|
|
1770
|
+
afterEach(clearConversations);
|
|
1771
|
+
|
|
1766
1772
|
const baseMessages: Message[] = [
|
|
1767
1773
|
{
|
|
1768
1774
|
role: "user",
|
|
@@ -1770,12 +1776,15 @@ describe("applyRuntimeInjections with unifiedTurnContext", () => {
|
|
|
1770
1776
|
},
|
|
1771
1777
|
];
|
|
1772
1778
|
|
|
1773
|
-
const
|
|
1774
|
-
|
|
1779
|
+
const sampleOptions: UnifiedTurnContextOptions = {
|
|
1780
|
+
timestamp: "2026-04-02T12:00:00Z",
|
|
1781
|
+
interfaceName: "macos",
|
|
1782
|
+
};
|
|
1783
|
+
const sampleBlock = buildUnifiedTurnContextBlock(sampleOptions);
|
|
1775
1784
|
|
|
1776
|
-
test("injects
|
|
1785
|
+
test("injects the turn-context block when the inputs are provided", async () => {
|
|
1777
1786
|
const { messages: result } = await applyRuntimeInjections(baseMessages, {
|
|
1778
|
-
|
|
1787
|
+
...sampleOptions,
|
|
1779
1788
|
});
|
|
1780
1789
|
|
|
1781
1790
|
expect(result).toHaveLength(1);
|
|
@@ -1789,16 +1798,7 @@ describe("applyRuntimeInjections with unifiedTurnContext", () => {
|
|
|
1789
1798
|
);
|
|
1790
1799
|
});
|
|
1791
1800
|
|
|
1792
|
-
test("does not inject when
|
|
1793
|
-
const { messages: result } = await applyRuntimeInjections(baseMessages, {
|
|
1794
|
-
unifiedTurnContext: null,
|
|
1795
|
-
});
|
|
1796
|
-
|
|
1797
|
-
expect(result).toHaveLength(1);
|
|
1798
|
-
expect(result[0].content).toHaveLength(1);
|
|
1799
|
-
});
|
|
1800
|
-
|
|
1801
|
-
test("does not inject when unifiedTurnContext is omitted", async () => {
|
|
1801
|
+
test("does not inject when the timestamp input is omitted", async () => {
|
|
1802
1802
|
const { messages: result } = await applyRuntimeInjections(baseMessages, {});
|
|
1803
1803
|
|
|
1804
1804
|
expect(result).toHaveLength(1);
|
|
@@ -1807,7 +1807,7 @@ describe("applyRuntimeInjections with unifiedTurnContext", () => {
|
|
|
1807
1807
|
|
|
1808
1808
|
test("injected in full mode", async () => {
|
|
1809
1809
|
const { messages: result } = await applyRuntimeInjections(baseMessages, {
|
|
1810
|
-
|
|
1810
|
+
...sampleOptions,
|
|
1811
1811
|
mode: "full",
|
|
1812
1812
|
});
|
|
1813
1813
|
|
|
@@ -1821,7 +1821,7 @@ describe("applyRuntimeInjections with unifiedTurnContext", () => {
|
|
|
1821
1821
|
|
|
1822
1822
|
test("injected in minimal mode (no mode guard)", async () => {
|
|
1823
1823
|
const { messages: result } = await applyRuntimeInjections(baseMessages, {
|
|
1824
|
-
|
|
1824
|
+
...sampleOptions,
|
|
1825
1825
|
mode: "minimal",
|
|
1826
1826
|
});
|
|
1827
1827
|
|
|
@@ -1839,6 +1839,8 @@ describe("applyRuntimeInjections with unifiedTurnContext", () => {
|
|
|
1839
1839
|
// ---------------------------------------------------------------------------
|
|
1840
1840
|
|
|
1841
1841
|
describe("applyRuntimeInjections blocks.unifiedTurnContext", () => {
|
|
1842
|
+
afterEach(clearConversations);
|
|
1843
|
+
|
|
1842
1844
|
const userTailMessages: Message[] = [
|
|
1843
1845
|
{
|
|
1844
1846
|
role: "user",
|
|
@@ -1846,12 +1848,15 @@ describe("applyRuntimeInjections blocks.unifiedTurnContext", () => {
|
|
|
1846
1848
|
},
|
|
1847
1849
|
];
|
|
1848
1850
|
|
|
1849
|
-
const
|
|
1850
|
-
|
|
1851
|
+
const sampleOptions: UnifiedTurnContextOptions = {
|
|
1852
|
+
timestamp: "2026-04-02T12:00:00Z",
|
|
1853
|
+
interfaceName: "macos",
|
|
1854
|
+
};
|
|
1855
|
+
const sampleBlock = buildUnifiedTurnContextBlock(sampleOptions);
|
|
1851
1856
|
|
|
1852
1857
|
test("captures unifiedTurnContext when tail is a user message", async () => {
|
|
1853
1858
|
const result = await applyRuntimeInjections(userTailMessages, {
|
|
1854
|
-
|
|
1859
|
+
...sampleOptions,
|
|
1855
1860
|
});
|
|
1856
1861
|
|
|
1857
1862
|
expect(result.blocks.unifiedTurnContext).toBe(sampleBlock);
|
|
@@ -1870,7 +1875,7 @@ describe("applyRuntimeInjections blocks.unifiedTurnContext", () => {
|
|
|
1870
1875
|
];
|
|
1871
1876
|
|
|
1872
1877
|
const result = await applyRuntimeInjections(assistantTailMessages, {
|
|
1873
|
-
|
|
1878
|
+
...sampleOptions,
|
|
1874
1879
|
});
|
|
1875
1880
|
|
|
1876
1881
|
expect(result.blocks.unifiedTurnContext).toBeUndefined();
|
|
@@ -53,6 +53,10 @@ import {
|
|
|
53
53
|
} from "../daemon/conversation-registry.js";
|
|
54
54
|
import { buildPkbReminder } from "../daemon/pkb-reminder-builder.js";
|
|
55
55
|
import { getPkbRoot } from "../memory/pkb/types.js";
|
|
56
|
+
import {
|
|
57
|
+
buildUnifiedTurnContextBlock,
|
|
58
|
+
type UnifiedTurnContextOptions,
|
|
59
|
+
} from "../plugins/defaults/memory-retrieval/unified-turn-context.js";
|
|
56
60
|
import type { TurnContext } from "../plugins/types.js";
|
|
57
61
|
import type { Message } from "../providers/types.js";
|
|
58
62
|
import { getSubagentManager } from "../subagent/index.js";
|
|
@@ -280,22 +284,24 @@ describe("injector chain", () => {
|
|
|
280
284
|
test("applyRuntimeInjections without turnContext still runs the chain under a synthesized context", async () => {
|
|
281
285
|
// The static chain is the canonical injection path, so
|
|
282
286
|
// `applyRuntimeInjections` must drive it even when the caller doesn't
|
|
283
|
-
// pass a `turnContext`.
|
|
284
|
-
//
|
|
285
|
-
//
|
|
287
|
+
// pass a `turnContext`. With no caller-supplied context the assembly
|
|
288
|
+
// falls back to the runtime-assembly fallback conversation id, so the
|
|
289
|
+
// live-sourced unified turn context resolves off that conversation.
|
|
286
290
|
const runMessages: Message[] = [
|
|
287
291
|
{ role: "user", content: [{ type: "text", text: "hi" }] },
|
|
288
292
|
];
|
|
289
293
|
|
|
294
|
+
const synthesizedOptions: UnifiedTurnContextOptions = {
|
|
295
|
+
timestamp: "synthesized",
|
|
296
|
+
};
|
|
297
|
+
const synthesizedBlock = buildUnifiedTurnContextBlock(synthesizedOptions);
|
|
290
298
|
const result = await applyRuntimeInjections(runMessages, {
|
|
291
|
-
|
|
299
|
+
...synthesizedOptions,
|
|
292
300
|
});
|
|
293
301
|
|
|
294
302
|
// The unified-turn-context injector fires even without a caller-supplied
|
|
295
303
|
// turnContext, proving the chain runs under the synthesized context.
|
|
296
|
-
expect(result.blocks.unifiedTurnContext).toBe(
|
|
297
|
-
"<turn_context>\nsynthesized\n</turn_context>",
|
|
298
|
-
);
|
|
304
|
+
expect(result.blocks.unifiedTurnContext).toBe(synthesizedBlock);
|
|
299
305
|
});
|
|
300
306
|
|
|
301
307
|
test("golden-path: default chain injects workspace + unified-turn + PKB + NOW + subagent in the correct positions", async () => {
|
|
@@ -328,8 +334,11 @@ describe("injector chain", () => {
|
|
|
328
334
|
|
|
329
335
|
const workspaceText =
|
|
330
336
|
"<workspace>\nRoot: /sandbox\nDirectories: src, lib\n</workspace>";
|
|
331
|
-
const
|
|
332
|
-
|
|
337
|
+
const unifiedTurnOptions: UnifiedTurnContextOptions = {
|
|
338
|
+
timestamp: "2026-04-22",
|
|
339
|
+
interfaceName: "macos",
|
|
340
|
+
};
|
|
341
|
+
const unifiedTurn = buildUnifiedTurnContextBlock(unifiedTurnOptions);
|
|
333
342
|
// A completed child renders deterministically (no elapsed clock), so the
|
|
334
343
|
// block the injector self-resolves matches `buildSubagentStatusBlock`.
|
|
335
344
|
const subagentChild = makeSubagentState("sub-1", "worker", "completed");
|
|
@@ -338,8 +347,8 @@ describe("injector chain", () => {
|
|
|
338
347
|
|
|
339
348
|
seedWorkspaceContext(workspaceText);
|
|
340
349
|
const result = await applyRuntimeInjections(runMessages, {
|
|
350
|
+
...unifiedTurnOptions,
|
|
341
351
|
turnContext: makeTurnContext(),
|
|
342
|
-
unifiedTurnContext: unifiedTurn,
|
|
343
352
|
});
|
|
344
353
|
|
|
345
354
|
// Extract the tail user message content as a list of text strings.
|
|
@@ -450,8 +459,15 @@ describe("injector chain", () => {
|
|
|
450
459
|
// injector except `unified-turn-context` checks `mode === "full"` and
|
|
451
460
|
// opts out in minimal mode, so the tail should carry only the turn
|
|
452
461
|
// context prepend plus any non-injector hardcoded content (none
|
|
453
|
-
// here).
|
|
454
|
-
//
|
|
462
|
+
// here).
|
|
463
|
+
// Empty workspace text keeps that injector inert while the unified
|
|
464
|
+
// turn-context inputs flow through the injection options bag. A live child
|
|
465
|
+
// subagent is seeded so the subagent-status injector has a block to skip.
|
|
466
|
+
const minimalTurnOptions: UnifiedTurnContextOptions = {
|
|
467
|
+
timestamp: "2026-04-22",
|
|
468
|
+
};
|
|
469
|
+
const minimalTurnBlock = buildUnifiedTurnContextBlock(minimalTurnOptions);
|
|
470
|
+
seedWorkspaceContext("");
|
|
455
471
|
seedSubagentChild(
|
|
456
472
|
TEST_CONVERSATION_ID,
|
|
457
473
|
makeSubagentState("sub-1", "worker", "running"),
|
|
@@ -464,9 +480,9 @@ describe("injector chain", () => {
|
|
|
464
480
|
},
|
|
465
481
|
],
|
|
466
482
|
{
|
|
483
|
+
...minimalTurnOptions,
|
|
467
484
|
turnContext: makeTurnContext(),
|
|
468
485
|
mode: "minimal",
|
|
469
|
-
unifiedTurnContext: "<turn_context>...</turn_context>",
|
|
470
486
|
},
|
|
471
487
|
);
|
|
472
488
|
|
|
@@ -475,10 +491,8 @@ describe("injector chain", () => {
|
|
|
475
491
|
.filter((b): b is { type: "text"; text: string } => b.type === "text")
|
|
476
492
|
.map((b) => b.text);
|
|
477
493
|
|
|
478
|
-
expect(texts).toEqual([
|
|
479
|
-
expect(result.blocks.unifiedTurnContext).toBe(
|
|
480
|
-
"<turn_context>...</turn_context>",
|
|
481
|
-
);
|
|
494
|
+
expect(texts).toEqual([minimalTurnBlock, "hi"]);
|
|
495
|
+
expect(result.blocks.unifiedTurnContext).toBe(minimalTurnBlock);
|
|
482
496
|
expect(result.blocks.workspaceBlock).toBeUndefined();
|
|
483
497
|
expect(result.blocks.pkbContextBlock).toBeUndefined();
|
|
484
498
|
expect(result.blocks.nowScratchpadBlock).toBeUndefined();
|
|
@@ -14,6 +14,10 @@ import {
|
|
|
14
14
|
defaultInjectors,
|
|
15
15
|
DISK_PRESSURE_WARNING_PROMPT,
|
|
16
16
|
} from "../plugins/defaults/memory-retrieval/injectors.js";
|
|
17
|
+
import {
|
|
18
|
+
buildUnifiedTurnContextBlock,
|
|
19
|
+
type UnifiedTurnContextOptions,
|
|
20
|
+
} from "../plugins/defaults/memory-retrieval/unified-turn-context.js";
|
|
17
21
|
import type { Injector, TurnContext } from "../plugins/types.js";
|
|
18
22
|
import type { Message } from "../providers/types.js";
|
|
19
23
|
|
|
@@ -140,13 +144,17 @@ Do not work on unrelated tasks until enough space is freed to clear the lock or
|
|
|
140
144
|
{ role: "user", content: [{ type: "text", text: "clean up space" }] },
|
|
141
145
|
];
|
|
142
146
|
const workspace = "<workspace>\nRoot: /workspace\n</workspace>";
|
|
143
|
-
const
|
|
147
|
+
const turnContextOptions: UnifiedTurnContextOptions = {
|
|
148
|
+
timestamp: "2026-04-02T12:00:00Z",
|
|
149
|
+
interfaceName: "macos",
|
|
150
|
+
};
|
|
151
|
+
const turnContext = buildUnifiedTurnContextBlock(turnContextOptions);
|
|
144
152
|
|
|
145
153
|
seedWorkspaceContext(workspace);
|
|
146
154
|
seedDiskPressure(true);
|
|
147
155
|
const result = await applyRuntimeInjections(runMessages, {
|
|
156
|
+
...turnContextOptions,
|
|
148
157
|
turnContext: makeContext(),
|
|
149
|
-
unifiedTurnContext: turnContext,
|
|
150
158
|
});
|
|
151
159
|
|
|
152
160
|
expect(tailTexts(result.messages).slice(0, 4)).toEqual([
|
|
@@ -163,19 +171,24 @@ Do not work on unrelated tasks until enough space is freed to clear the lock or
|
|
|
163
171
|
});
|
|
164
172
|
|
|
165
173
|
test("survives minimal mode as safety-critical context", async () => {
|
|
174
|
+
const turnContextOptions: UnifiedTurnContextOptions = {
|
|
175
|
+
timestamp: "2026-04-02T12:00:00Z",
|
|
176
|
+
interfaceName: "macos",
|
|
177
|
+
};
|
|
178
|
+
const turnContext = buildUnifiedTurnContextBlock(turnContextOptions);
|
|
166
179
|
seedDiskPressure(true);
|
|
167
180
|
const result = await applyRuntimeInjections(
|
|
168
181
|
[{ role: "user", content: [{ type: "text", text: "status" }] }],
|
|
169
182
|
{
|
|
183
|
+
...turnContextOptions,
|
|
170
184
|
turnContext: makeContext(),
|
|
171
185
|
mode: "minimal",
|
|
172
|
-
unifiedTurnContext: "<turn_context>...</turn_context>",
|
|
173
186
|
},
|
|
174
187
|
);
|
|
175
188
|
|
|
176
189
|
expect(tailTexts(result.messages)).toEqual([
|
|
177
190
|
DISK_PRESSURE_WARNING_PROMPT,
|
|
178
|
-
|
|
191
|
+
turnContext,
|
|
179
192
|
"status",
|
|
180
193
|
]);
|
|
181
194
|
});
|