@vellumai/assistant 0.10.5-dev.202607031934.26016be → 0.10.5-dev.202607032030.d15600c
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/package.json +1 -1
- package/src/__tests__/conversation-runtime-assembly.test.ts +16 -0
- package/src/__tests__/injector-chain.test.ts +4 -0
- package/src/__tests__/mcp-config-secret-boundary.test.ts +1 -0
- package/src/__tests__/plugin-effective-enabled-set.test.ts +7 -49
- package/src/daemon/conversation-runtime-assembly.ts +18 -36
- package/src/daemon/conversation-tool-setup.ts +31 -12
- package/src/daemon/conversation.ts +15 -0
- package/src/plugin-api/index.ts +5 -1
- package/src/plugins/injector-registry.ts +6 -12
- package/src/runtime/background-job-runner.ts +9 -1
- package/src/plugins/defaults/default-plugin-names.ts +0 -60
package/package.json
CHANGED
|
@@ -2645,6 +2645,22 @@ describe("applyRuntimeInjections — subagent status", () => {
|
|
|
2645
2645
|
content: [{ type: "text", text: "user message" }],
|
|
2646
2646
|
};
|
|
2647
2647
|
|
|
2648
|
+
// The `<active_subagents>` block is sourced from the live conversation
|
|
2649
|
+
// (Conversation.getSubagentChildren delegates to the manager), so register
|
|
2650
|
+
// a fallback fake carrying that delegation for the seeded children to
|
|
2651
|
+
// surface.
|
|
2652
|
+
beforeEach(() => {
|
|
2653
|
+
setConversation(FALLBACK_CONVERSATION_ID, {
|
|
2654
|
+
conversationId: FALLBACK_CONVERSATION_ID,
|
|
2655
|
+
workingDir: "/sandbox",
|
|
2656
|
+
workspaceTopLevelContext: "",
|
|
2657
|
+
workspaceTopLevelDirty: false,
|
|
2658
|
+
surfaceState: new Map(),
|
|
2659
|
+
getSubagentChildren: () =>
|
|
2660
|
+
getSubagentManager().getChildrenOf(FALLBACK_CONVERSATION_ID),
|
|
2661
|
+
} as never);
|
|
2662
|
+
});
|
|
2663
|
+
|
|
2648
2664
|
afterEach(() => {
|
|
2649
2665
|
clearSeededSubagents();
|
|
2650
2666
|
clearConversations();
|
|
@@ -164,6 +164,10 @@ function seedWorkspaceContext(
|
|
|
164
164
|
assistantMessageInterface: interfaceName,
|
|
165
165
|
}
|
|
166
166
|
: undefined,
|
|
167
|
+
// Mirrors Conversation.getSubagentChildren: the `<active_subagents>` block
|
|
168
|
+
// is sourced from the live conversation, which delegates to the manager.
|
|
169
|
+
getSubagentChildren: () =>
|
|
170
|
+
getSubagentManager().getChildrenOf(TEST_CONVERSATION_ID),
|
|
167
171
|
} as never);
|
|
168
172
|
}
|
|
169
173
|
|
|
@@ -132,6 +132,7 @@ mock.module("../persistence/embeddings/embedding-backend.js", () => ({
|
|
|
132
132
|
model: null,
|
|
133
133
|
}),
|
|
134
134
|
resetLocalEmbeddingFailureState: () => {},
|
|
135
|
+
resolveBackendDimension: async () => null,
|
|
135
136
|
selectEmbeddingBackend: async () => null,
|
|
136
137
|
selectedBackendSupportsMultimodal: async () => false,
|
|
137
138
|
}));
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tests for per-chat plugin scope (`enabledPlugins`) filtering at the
|
|
3
|
-
*
|
|
2
|
+
* Tests for per-chat plugin scope (`enabledPlugins`) filtering at the
|
|
3
|
+
* lifecycle-hook gather sites.
|
|
4
4
|
*
|
|
5
5
|
* A conversation may restrict which plugins' capabilities it uses. That scope
|
|
6
6
|
* is expressed as an effective-enabled-plugin Set (see
|
|
7
7
|
* `getEffectiveEnabledPluginSet` in `daemon/conversation-tool-setup.ts`): a
|
|
8
8
|
* non-null Set is an allowlist, `null` means no restriction. This suite locks
|
|
9
|
-
* the contract that
|
|
10
|
-
* - `getRegisteredInjectors(set)` excludes injectors from plugins outside the
|
|
11
|
-
* set, and is unchanged for `null`/omitted.
|
|
9
|
+
* the contract that the hook gather sites honor it:
|
|
12
10
|
* - `getHooksFor(name, { conversationId })` resolves the conversation's scope
|
|
13
11
|
* and excludes in-process default-plugin hooks outside it; omitting the
|
|
14
12
|
* conversationId imposes no restriction.
|
|
@@ -17,6 +15,9 @@
|
|
|
17
15
|
*
|
|
18
16
|
* The per-chat scope layers on top of (does not replace) the global
|
|
19
17
|
* `.disabled` sentinel check — a plugin excluded by either is excluded.
|
|
18
|
+
* Injectors are intentionally NOT per-chat scoped (see
|
|
19
|
+
* `getRegisteredInjectors`): they run inside already-scoped plugin hooks, and
|
|
20
|
+
* every injector-contributing plugin is a first-party default.
|
|
20
21
|
*/
|
|
21
22
|
|
|
22
23
|
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
@@ -35,16 +36,11 @@ mock.module("../daemon/conversation-plugin-scope.js", () => ({
|
|
|
35
36
|
|
|
36
37
|
import { collectUserHooks } from "../hooks/hook-loader.js";
|
|
37
38
|
import { getHooksFor } from "../hooks/registry.js";
|
|
38
|
-
import {
|
|
39
|
-
clearInjectorRegistry,
|
|
40
|
-
getRegisteredInjectors,
|
|
41
|
-
registerPluginInjectors,
|
|
42
|
-
} from "../plugins/injector-registry.js";
|
|
43
39
|
import {
|
|
44
40
|
registerPlugin,
|
|
45
41
|
resetPluginRegistryForTests,
|
|
46
42
|
} from "../plugins/registry.js";
|
|
47
|
-
import type { HookFunction,
|
|
43
|
+
import type { HookFunction, Plugin } from "../plugins/types.js";
|
|
48
44
|
|
|
49
45
|
// Point the workspace at an empty temp dir so `getHooksFor` -> `getUserHooksFor`
|
|
50
46
|
// finds no user-land plugins; the in-process hook tests then observe only the
|
|
@@ -55,10 +51,6 @@ const TEST_WORKSPACE_DIR = join(
|
|
|
55
51
|
);
|
|
56
52
|
process.env.VELLUM_WORKSPACE_DIR = TEST_WORKSPACE_DIR;
|
|
57
53
|
|
|
58
|
-
function injector(name: string, order: number): Injector {
|
|
59
|
-
return { name, order, produce: () => Promise.resolve(null) };
|
|
60
|
-
}
|
|
61
|
-
|
|
62
54
|
function buildPlugin(
|
|
63
55
|
name: string,
|
|
64
56
|
hooks: Record<string, HookFunction>,
|
|
@@ -66,40 +58,6 @@ function buildPlugin(
|
|
|
66
58
|
return { manifest: { name, version: "1.0.0" }, hooks };
|
|
67
59
|
}
|
|
68
60
|
|
|
69
|
-
describe("getRegisteredInjectors per-chat plugin scope", () => {
|
|
70
|
-
beforeEach(() => clearInjectorRegistry());
|
|
71
|
-
afterEach(() => clearInjectorRegistry());
|
|
72
|
-
|
|
73
|
-
test("null set runs every globally-enabled plugin's injectors (unchanged)", () => {
|
|
74
|
-
registerPluginInjectors("plugin-a", [injector("inj-a", 1)]);
|
|
75
|
-
registerPluginInjectors("plugin-b", [injector("inj-b", 2)]);
|
|
76
|
-
|
|
77
|
-
const namesNull = getRegisteredInjectors(null).map((i) => i.name);
|
|
78
|
-
const namesOmitted = getRegisteredInjectors().map((i) => i.name);
|
|
79
|
-
|
|
80
|
-
expect(namesNull).toEqual(["inj-a", "inj-b"]);
|
|
81
|
-
expect(namesOmitted).toEqual(["inj-a", "inj-b"]);
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
test("a set excluding plugin b drops b's injectors and keeps a's", () => {
|
|
85
|
-
registerPluginInjectors("plugin-a", [injector("inj-a", 1)]);
|
|
86
|
-
registerPluginInjectors("plugin-b", [injector("inj-b", 2)]);
|
|
87
|
-
|
|
88
|
-
const names = getRegisteredInjectors(new Set(["plugin-a"])).map(
|
|
89
|
-
(i) => i.name,
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
expect(names).toEqual(["inj-a"]);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
test("an empty set excludes every plugin's injectors", () => {
|
|
96
|
-
registerPluginInjectors("plugin-a", [injector("inj-a", 1)]);
|
|
97
|
-
registerPluginInjectors("plugin-b", [injector("inj-b", 2)]);
|
|
98
|
-
|
|
99
|
-
expect(getRegisteredInjectors(new Set<string>())).toEqual([]);
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
61
|
describe("getHooksFor per-chat plugin scope (in-process default hooks)", () => {
|
|
104
62
|
beforeEach(() => {
|
|
105
63
|
resetPluginRegistryForTests();
|
|
@@ -66,12 +66,10 @@ import type {
|
|
|
66
66
|
import type { ContentBlock, Message } from "../providers/types.js";
|
|
67
67
|
import type { TrustClass } from "../runtime/actor-trust-resolver.js";
|
|
68
68
|
import { resolveCapabilities } from "../runtime/capabilities.js";
|
|
69
|
-
import { getSubagentManager } from "../subagent/index.js";
|
|
70
69
|
import type { SubagentState } from "../subagent/types.js";
|
|
71
70
|
import { TERMINAL_STATUSES } from "../subagent/types.js";
|
|
72
71
|
import { canonicalizeInboundIdentity } from "../util/canonicalize-identity.js";
|
|
73
72
|
import { findConversationOrSubagent } from "./conversation-registry.js";
|
|
74
|
-
import { getEffectiveEnabledPluginSet } from "./conversation-tool-setup.js";
|
|
75
73
|
import { canonicalizeTimeZone, formatTurnTimestamp } from "./date-context.js";
|
|
76
74
|
import type {
|
|
77
75
|
DynamicPageSurfaceData,
|
|
@@ -596,12 +594,14 @@ function escapeXml(str: string): string {
|
|
|
596
594
|
|
|
597
595
|
/**
|
|
598
596
|
* Build the `<active_subagents>` injection block from the current child states.
|
|
599
|
-
* Returns null if there are no children (zero overhead for non-subagent
|
|
597
|
+
* Returns null if there are no children (zero overhead for non-subagent
|
|
598
|
+
* parents) — `null`/`undefined` children (no live conversation, or a subagent
|
|
599
|
+
* conversation, per `Conversation.getSubagentChildren`) count as none.
|
|
600
600
|
*/
|
|
601
601
|
export function buildSubagentStatusBlock(
|
|
602
|
-
children: SubagentState[],
|
|
602
|
+
children: SubagentState[] | null | undefined,
|
|
603
603
|
): string | null {
|
|
604
|
-
if (children.length === 0) return null;
|
|
604
|
+
if (!children || children.length === 0) return null;
|
|
605
605
|
|
|
606
606
|
const now = Date.now();
|
|
607
607
|
const lines: string[] = ["<active_subagents>"];
|
|
@@ -631,7 +631,7 @@ export function buildSubagentStatusBlock(
|
|
|
631
631
|
// The `<active_subagents>` block is emitted by the `subagent-status` default
|
|
632
632
|
// injector (`plugins/defaults/memory/injectors.ts`) as an `append-user-tail`
|
|
633
633
|
// placement. `applyRuntimeInjections` resolves the block from the live
|
|
634
|
-
// subagent
|
|
634
|
+
// conversation's subagent children, so callers do not pass it in.
|
|
635
635
|
|
|
636
636
|
/**
|
|
637
637
|
* Append voice call-control protocol instructions to the last user
|
|
@@ -1596,19 +1596,13 @@ export interface RuntimeInjectionResult {
|
|
|
1596
1596
|
* preserves ascending-`order` sort so downstream callers (notably
|
|
1597
1597
|
* {@link applyRuntimeInjections}) can group blocks by `placement` and apply
|
|
1598
1598
|
* them declaratively without losing per-injector ordering within each slot.
|
|
1599
|
-
*
|
|
1600
|
-
* `effectiveEnabledPlugins` carries the conversation's per-chat plugin scope:
|
|
1601
|
-
* when non-null, injectors contributed by a plugin outside the set are excluded
|
|
1602
|
-
* for this turn (see {@link getRegisteredInjectors}). `null`/omitted means no
|
|
1603
|
-
* per-chat restriction.
|
|
1604
1599
|
*/
|
|
1605
1600
|
async function collectInjectorBlocks(
|
|
1606
1601
|
ctx: TurnContext,
|
|
1607
1602
|
runMessages?: Message[],
|
|
1608
|
-
effectiveEnabledPlugins?: Set<string> | null,
|
|
1609
1603
|
): Promise<InjectionBlock[]> {
|
|
1610
1604
|
const out: InjectionBlock[] = [];
|
|
1611
|
-
for (const injector of getRegisteredInjectors(
|
|
1605
|
+
for (const injector of getRegisteredInjectors()) {
|
|
1612
1606
|
const block = await injector.produce(ctx, runMessages);
|
|
1613
1607
|
if (block) out.push(block);
|
|
1614
1608
|
}
|
|
@@ -1798,8 +1792,8 @@ function stripTailV2DynamicMemoryPrefix(
|
|
|
1798
1792
|
* (falling back to its recorded `originInterface`, then `web`), its turn
|
|
1799
1793
|
* channel context's `userMessageChannel` (falling back to its recorded
|
|
1800
1794
|
* `originChannel`, then `vellum`), its `conversationType`, its
|
|
1801
|
-
* `currentTurnTemporalSnapshot`,
|
|
1802
|
-
* `
|
|
1795
|
+
* `currentTurnTemporalSnapshot`, its subagent children
|
|
1796
|
+
* (`getSubagentChildren`), and — for the focus block — its persisted Slack
|
|
1803
1797
|
* compaction boundary (`contextCompactedMessageCount` /
|
|
1804
1798
|
* `slackContextCompactionWatermarkTs`) and trust class) or from config (the
|
|
1805
1799
|
* configured user timezone and the detected-timezone fallback), so the
|
|
@@ -1947,14 +1941,6 @@ export async function applyRuntimeInjections(
|
|
|
1947
1941
|
// field below from it rather than from orchestrator-computed options.
|
|
1948
1942
|
const liveConversation = findConversationOrSubagent(conversationId);
|
|
1949
1943
|
|
|
1950
|
-
// Per-chat plugin scope for this turn: when the conversation restricts its
|
|
1951
|
-
// plugins (`enabledPlugins` non-null), injectors contributed by a plugin
|
|
1952
|
-
// outside the set are excluded below. `null` (no live conversation, or no
|
|
1953
|
-
// restriction) leaves the injector chain unchanged.
|
|
1954
|
-
const effectiveEnabledPlugins = liveConversation
|
|
1955
|
-
? getEffectiveEnabledPluginSet(liveConversation)
|
|
1956
|
-
: null;
|
|
1957
|
-
|
|
1958
1944
|
const channelCapabilities = liveConversation?.channelCapabilities ?? null;
|
|
1959
1945
|
const slackConversation = channelCapabilities?.channel === "slack";
|
|
1960
1946
|
|
|
@@ -2022,14 +2008,14 @@ export async function applyRuntimeInjections(
|
|
|
2022
2008
|
: undefined;
|
|
2023
2009
|
const timeSinceLastMessage = temporalSnapshot?.timeSinceLastMessage ?? null;
|
|
2024
2010
|
|
|
2025
|
-
// The `<active_subagents>` status block is sourced from the live
|
|
2026
|
-
//
|
|
2027
|
-
//
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2011
|
+
// The `<active_subagents>` status block is sourced from the live
|
|
2012
|
+
// conversation's subagent children (`getSubagentChildren` returns `null` for
|
|
2013
|
+
// a subagent conversation — no nesting — and the builder returns `null` for
|
|
2014
|
+
// no children). Optional call: tests register partial Conversation fakes via
|
|
2015
|
+
// `setConversation(..., {...} as never)` that omit the method.
|
|
2016
|
+
const subagentStatusBlock = buildSubagentStatusBlock(
|
|
2017
|
+
liveConversation?.getSubagentChildren?.(),
|
|
2018
|
+
);
|
|
2033
2019
|
|
|
2034
2020
|
// The `<active_thread>` focus block lists the messages of the thread the
|
|
2035
2021
|
// current inbound user message belongs to. The loader short-circuits to
|
|
@@ -2106,11 +2092,7 @@ export async function applyRuntimeInjections(
|
|
|
2106
2092
|
...injectionInputs,
|
|
2107
2093
|
};
|
|
2108
2094
|
|
|
2109
|
-
const chainBlocks = await collectInjectorBlocks(
|
|
2110
|
-
turnCtx,
|
|
2111
|
-
runMessages,
|
|
2112
|
-
effectiveEnabledPlugins,
|
|
2113
|
-
);
|
|
2095
|
+
const chainBlocks = await collectInjectorBlocks(turnCtx, runMessages);
|
|
2114
2096
|
|
|
2115
2097
|
// Split the chain output by placement so the downstream assembly can
|
|
2116
2098
|
// process each slot with the correct ordering rule.
|
|
@@ -17,7 +17,7 @@ import type { LLMCallSite } from "../config/schemas/llm.js";
|
|
|
17
17
|
import type { PermissionPrompter } from "../permissions/prompter.js";
|
|
18
18
|
import type { SecretPrompter } from "../permissions/secret-prompter.js";
|
|
19
19
|
import { getBindingByConversation } from "../persistence/external-conversation-store.js";
|
|
20
|
-
import {
|
|
20
|
+
import { getAllDefaultPlugins } from "../plugins/defaults/index.js";
|
|
21
21
|
import { isPluginDisabled } from "../plugins/disabled-state.js";
|
|
22
22
|
import type { Message, ToolDefinition } from "../providers/types.js";
|
|
23
23
|
import { assistantEventHub } from "../runtime/assistant-event-hub.js";
|
|
@@ -148,7 +148,7 @@ export function resolveConversationAttribution(
|
|
|
148
148
|
* silently disable core behavior. A workspace-disabled default is left out so
|
|
149
149
|
* `assistant plugins disable default-*` still takes effect; a default the
|
|
150
150
|
* conversation explicitly enabled (rule 1) stays in regardless. Unioning here
|
|
151
|
-
* fixes every consumer (tools/skills/
|
|
151
|
+
* fixes every consumer (tools/skills/hooks) at the single chokepoint.
|
|
152
152
|
*/
|
|
153
153
|
export function getEffectiveEnabledPluginSet(conv: {
|
|
154
154
|
enabledPlugins?: string[] | null;
|
|
@@ -158,7 +158,8 @@ export function getEffectiveEnabledPluginSet(conv: {
|
|
|
158
158
|
const effective = new Set(conv.enabledPlugins);
|
|
159
159
|
// Rules 2 + 3: add a default the conversation did not already decide, unless
|
|
160
160
|
// it is disabled at the workspace level.
|
|
161
|
-
for (const
|
|
161
|
+
for (const plugin of getAllDefaultPlugins()) {
|
|
162
|
+
const name = plugin.manifest.name;
|
|
162
163
|
if (!effective.has(name) && !isPluginDisabled(name)) {
|
|
163
164
|
effective.add(name);
|
|
164
165
|
}
|
|
@@ -198,9 +199,13 @@ export function createToolExecutor(
|
|
|
198
199
|
const rejectNonAllowlistedTool = (
|
|
199
200
|
toolName: string,
|
|
200
201
|
): ToolExecutionResult | null => {
|
|
201
|
-
if (ctx.subagentToolGateMode !== "execution")
|
|
202
|
+
if (ctx.subagentToolGateMode !== "execution") {
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
202
205
|
const allowlist = ctx.subagentAllowedTools;
|
|
203
|
-
if (!allowlist || allowlist.has(toolName))
|
|
206
|
+
if (!allowlist || allowlist.has(toolName)) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
204
209
|
const allowed = [...allowlist].sort().join(", ");
|
|
205
210
|
return {
|
|
206
211
|
content: `This background pass may only use: ${allowed}.`,
|
|
@@ -220,9 +225,13 @@ export function createToolExecutor(
|
|
|
220
225
|
toolName: string,
|
|
221
226
|
effectiveSet: Set<string> | null,
|
|
222
227
|
): ToolExecutionResult | null => {
|
|
223
|
-
if (effectiveSet === null)
|
|
228
|
+
if (effectiveSet === null) {
|
|
229
|
+
return null;
|
|
230
|
+
}
|
|
224
231
|
const owner = getToolOwner(toolName);
|
|
225
|
-
if (owner?.kind !== "plugin" || effectiveSet.has(owner.id))
|
|
232
|
+
if (owner?.kind !== "plugin" || effectiveSet.has(owner.id)) {
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
226
235
|
return {
|
|
227
236
|
content: `Tool "${toolName}" belongs to a plugin that is not enabled in this conversation.`,
|
|
228
237
|
isError: true,
|
|
@@ -251,7 +260,9 @@ export function createToolExecutor(
|
|
|
251
260
|
// tool, not the wrapper.
|
|
252
261
|
if (executionName !== "skill_execute") {
|
|
253
262
|
const rejection = rejectNonAllowlistedTool(executionName);
|
|
254
|
-
if (rejection)
|
|
263
|
+
if (rejection) {
|
|
264
|
+
return rejection;
|
|
265
|
+
}
|
|
255
266
|
}
|
|
256
267
|
|
|
257
268
|
if (isDoordashCommand(executionName, executionInput)) {
|
|
@@ -385,7 +396,9 @@ export function createToolExecutor(
|
|
|
385
396
|
// wrapper is dispatch indirection, mirroring how wire mode gates the
|
|
386
397
|
// underlying tool via the executor's allowedToolNames check.
|
|
387
398
|
const innerRejection = rejectNonAllowlistedTool(toolName);
|
|
388
|
-
if (innerRejection)
|
|
399
|
+
if (innerRejection) {
|
|
400
|
+
return innerRejection;
|
|
401
|
+
}
|
|
389
402
|
|
|
390
403
|
// Per-chat plugin scope: reject the resolved inner tool when it belongs
|
|
391
404
|
// to a plugin outside the conversation's effective set.
|
|
@@ -393,7 +406,9 @@ export function createToolExecutor(
|
|
|
393
406
|
toolName,
|
|
394
407
|
effectiveEnabledPluginSet,
|
|
395
408
|
);
|
|
396
|
-
if (pluginRejection)
|
|
409
|
+
if (pluginRejection) {
|
|
410
|
+
return pluginRejection;
|
|
411
|
+
}
|
|
397
412
|
|
|
398
413
|
const rawResult = await executor.execute(
|
|
399
414
|
toolName,
|
|
@@ -755,7 +770,9 @@ export function createResolveToolsCallback(
|
|
|
755
770
|
toolDefs: ToolDefinition[],
|
|
756
771
|
ctx: SkillProjectionContext,
|
|
757
772
|
): ((history: Message[]) => ToolDefinition[]) | undefined {
|
|
758
|
-
if (toolDefs.length === 0)
|
|
773
|
+
if (toolDefs.length === 0) {
|
|
774
|
+
return undefined;
|
|
775
|
+
}
|
|
759
776
|
|
|
760
777
|
// Separate the initial tool defs into core (stable) and the dynamic
|
|
761
778
|
// categories (MCP, workspace, plugin). We keep core tools from the snapshot
|
|
@@ -911,7 +928,9 @@ export function createResolveToolsCallback(
|
|
|
911
928
|
if (wireAllowlist && !wireAllowlist.has(name)) {
|
|
912
929
|
continue;
|
|
913
930
|
}
|
|
914
|
-
if (excluded.has(name))
|
|
931
|
+
if (excluded.has(name)) {
|
|
932
|
+
continue;
|
|
933
|
+
}
|
|
915
934
|
turnAllowed.add(name);
|
|
916
935
|
}
|
|
917
936
|
// Record the full resolved inventory durably for read-only queries before
|
|
@@ -92,6 +92,8 @@ import type { AuthContext } from "../runtime/auth/types.js";
|
|
|
92
92
|
import { resolveCapabilities } from "../runtime/capabilities.js";
|
|
93
93
|
import type { InteractiveUiResult } from "../runtime/interactive-ui.js";
|
|
94
94
|
import { publishSyncInvalidation } from "../runtime/sync/sync-publisher.js";
|
|
95
|
+
import { getSubagentManager } from "../subagent/index.js";
|
|
96
|
+
import type { SubagentState } from "../subagent/types.js";
|
|
95
97
|
import {
|
|
96
98
|
type ActivationMomentParam,
|
|
97
99
|
isActivationMomentParam,
|
|
@@ -1394,6 +1396,19 @@ export class Conversation {
|
|
|
1394
1396
|
this.isSubagent = value;
|
|
1395
1397
|
}
|
|
1396
1398
|
|
|
1399
|
+
/**
|
|
1400
|
+
* The live subagent-manager children of this conversation, for the
|
|
1401
|
+
* `<active_subagents>` status block. Returns `null` when this conversation
|
|
1402
|
+
* is itself a subagent (no nesting) — callers treat `null` as "no block".
|
|
1403
|
+
* Housing the subagent-manager access here keeps runtime-assembly free of a
|
|
1404
|
+
* subagent import (`subagent/manager` imports this module, so the reverse
|
|
1405
|
+
* edge would put runtime-assembly's importers on that cycle).
|
|
1406
|
+
*/
|
|
1407
|
+
getSubagentChildren(): SubagentState[] | null {
|
|
1408
|
+
if (this.isSubagent) return null;
|
|
1409
|
+
return getSubagentManager().getChildrenOf(this.conversationId);
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1397
1412
|
/**
|
|
1398
1413
|
* Prepend inherited parent messages into the in-memory message array so that
|
|
1399
1414
|
* the AgentLoop includes them in provider calls (enabling KV cache sharing).
|
package/src/plugin-api/index.ts
CHANGED
|
@@ -56,7 +56,10 @@
|
|
|
56
56
|
* every model-call outcome (a finalized reply or a provider rejection) to
|
|
57
57
|
* transform content and decide whether to retry
|
|
58
58
|
* - {@link HookFunction} — signature every lifecycle hook implements
|
|
59
|
-
* - {@link
|
|
59
|
+
* - {@link HookBroadcast} — the `ctx.broadcast(detail)` signature: emit a
|
|
60
|
+
* transient `hook_event` to any UI watching the conversation
|
|
61
|
+
* - {@link PluginLogger} — pino-compatible logger shape on the contexts,
|
|
62
|
+
* pre-tagged per hook with the hook name and owning plugin
|
|
60
63
|
* - {@link ToolDefinition} — author-facing tool spec (default-export shape
|
|
61
64
|
* for both plugin tool files and workspace tool files)
|
|
62
65
|
* - {@link ToolContext} — passed to a plugin tool's `execute` method
|
|
@@ -98,6 +101,7 @@ export type {
|
|
|
98
101
|
export type { LLMCallSite } from "../config/schemas/llm.js";
|
|
99
102
|
export type {
|
|
100
103
|
AgentLoopExitReason,
|
|
104
|
+
HookBroadcast,
|
|
101
105
|
HookFunction,
|
|
102
106
|
InitContext,
|
|
103
107
|
ModelProfileInfo,
|
|
@@ -97,15 +97,12 @@ export function unregisterPluginInjectors(pluginName: string): void {
|
|
|
97
97
|
* filter (rebuilt only on a registration change); only the small per-plugin
|
|
98
98
|
* disabled check re-runs each call.
|
|
99
99
|
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* injectors run, unchanged.
|
|
100
|
+
* The per-chat plugin scope (`getEffectiveEnabledPluginSet`) is intentionally
|
|
101
|
+
* NOT applied here: injectors run inside already-scoped plugin hooks, and every
|
|
102
|
+
* injector-contributing plugin today is a first-party default, which the
|
|
103
|
+
* per-chat scope never excludes.
|
|
105
104
|
*/
|
|
106
|
-
export function getRegisteredInjectors(
|
|
107
|
-
effectiveEnabledPlugins?: Set<string> | null,
|
|
108
|
-
): Injector[] {
|
|
105
|
+
export function getRegisteredInjectors(): Injector[] {
|
|
109
106
|
if (cachedChain === null) {
|
|
110
107
|
const pairs: Array<{ plugin: string; injector: Injector }> = [];
|
|
111
108
|
for (const [plugin, injectors] of injectorsByPlugin) {
|
|
@@ -118,10 +115,7 @@ export function getRegisteredInjectors(
|
|
|
118
115
|
const isEnabled = (plugin: string): boolean => {
|
|
119
116
|
let enabled = enabledByPlugin.get(plugin);
|
|
120
117
|
if (enabled === undefined) {
|
|
121
|
-
enabled =
|
|
122
|
-
!isPluginDisabled(plugin) &&
|
|
123
|
-
(effectiveEnabledPlugins == null ||
|
|
124
|
-
effectiveEnabledPlugins.has(plugin));
|
|
118
|
+
enabled = !isPluginDisabled(plugin);
|
|
125
119
|
enabledByPlugin.set(plugin, enabled);
|
|
126
120
|
}
|
|
127
121
|
return enabled;
|
|
@@ -19,7 +19,6 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import type { LLMCallSite } from "../config/schemas/llm.js";
|
|
22
|
-
import { processMessage } from "../daemon/process-message.js";
|
|
23
22
|
import type { TrustContext } from "../daemon/trust-context.js";
|
|
24
23
|
import {
|
|
25
24
|
commitDeferredConversation,
|
|
@@ -288,6 +287,15 @@ export async function runBackgroundJob(
|
|
|
288
287
|
);
|
|
289
288
|
}
|
|
290
289
|
|
|
290
|
+
// Loaded at call time: `processMessage` is the daemon's turn entrypoint
|
|
291
|
+
// and statically pulls the conversation stack (conversation-store →
|
|
292
|
+
// Conversation → conversation-tool-setup → the defaults barrel). Memory's
|
|
293
|
+
// job modules import this runner at module scope, so a static import here
|
|
294
|
+
// would put them on a cycle with the defaults barrel and its plugin
|
|
295
|
+
// definitions would hit their bindings mid-initialization (TDZ). By the
|
|
296
|
+
// time a job runs, the module graph has settled (and in the daemon the
|
|
297
|
+
// module is already loaded via the routes layer).
|
|
298
|
+
const { processMessage } = await import("../daemon/process-message.js");
|
|
291
299
|
const work = processMessage(conversation.id, opts.prompt, {
|
|
292
300
|
trustContext: opts.trustContext,
|
|
293
301
|
callSite: opts.callSite,
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Names of the first-party default plugins, as a leaf module.
|
|
3
|
-
*
|
|
4
|
-
* This deliberately imports ONLY each default plugin's `package.json` (pure
|
|
5
|
-
* JSON data, no code) rather than the `./index.js` barrel. The barrel statically
|
|
6
|
-
* pulls in every hook/injector implementation (the memory-v3 engine, caption
|
|
7
|
-
* caches, persistence hooks, …) and reaches back into `daemon/` modules, so
|
|
8
|
-
* importing it from `daemon/conversation-tool-setup.ts` forms a module-init
|
|
9
|
-
* cycle. Sourcing the names from this leaf keeps that consumer cycle-free while
|
|
10
|
-
* staying data-driven (names come from `package.json`, never hand-typed).
|
|
11
|
-
*
|
|
12
|
-
* The set is kept in lock-step with the canonical {@link getAllDefaultPlugins}
|
|
13
|
-
* list by a unit assertion in `daemon/conversation-tool-setup.test.ts`.
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import channelPkg from "./channel/package.json" with { type: "json" };
|
|
17
|
-
import compactionPkg from "./compaction/package.json" with { type: "json" };
|
|
18
|
-
import documentsPkg from "./documents/package.json" with { type: "json" };
|
|
19
|
-
import emptyResponsePkg from "./empty-response/package.json" with { type: "json" };
|
|
20
|
-
import explorationDriftPkg from "./exploration-drift/package.json" with { type: "json" };
|
|
21
|
-
import historyRepairPkg from "./history-repair/package.json" with { type: "json" };
|
|
22
|
-
import imageFallbackPkg from "./image-fallback/package.json" with { type: "json" };
|
|
23
|
-
import imageRecoveryPkg from "./image-recovery/package.json" with { type: "json" };
|
|
24
|
-
import maxTokensContinuePkg from "./max-tokens-continue/package.json" with { type: "json" };
|
|
25
|
-
import memoryPkg from "./memory/package.json" with { type: "json" };
|
|
26
|
-
import sessionPkg from "./session/package.json" with { type: "json" };
|
|
27
|
-
import surfaceCompletionNudgePkg from "./surface-completion-nudge/package.json" with { type: "json" };
|
|
28
|
-
import taskProgressNudgePkg from "./task-progress-nudge/package.json" with { type: "json" };
|
|
29
|
-
import titleGeneratePkg from "./title-generate/package.json" with { type: "json" };
|
|
30
|
-
import toolErrorPkg from "./tool-error/package.json" with { type: "json" };
|
|
31
|
-
import toolResultTruncatePkg from "./tool-result-truncate/package.json" with { type: "json" };
|
|
32
|
-
import turnContextPkg from "./turn-context/package.json" with { type: "json" };
|
|
33
|
-
import workspacePkg from "./workspace/package.json" with { type: "json" };
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The set of first-party default plugin names — runtime infrastructure
|
|
37
|
-
* (memory, turn-context, workspace, session, history repair, title generation,
|
|
38
|
-
* …), not user-toggleable extensions. Used by per-chat plugin scoping to ensure
|
|
39
|
-
* these are never filtered out (see `getEffectiveEnabledPluginSet`).
|
|
40
|
-
*/
|
|
41
|
-
export const DEFAULT_PLUGIN_NAMES: ReadonlySet<string> = new Set([
|
|
42
|
-
memoryPkg.name,
|
|
43
|
-
turnContextPkg.name,
|
|
44
|
-
workspacePkg.name,
|
|
45
|
-
documentsPkg.name,
|
|
46
|
-
channelPkg.name,
|
|
47
|
-
sessionPkg.name,
|
|
48
|
-
imageFallbackPkg.name,
|
|
49
|
-
toolResultTruncatePkg.name,
|
|
50
|
-
emptyResponsePkg.name,
|
|
51
|
-
maxTokensContinuePkg.name,
|
|
52
|
-
toolErrorPkg.name,
|
|
53
|
-
explorationDriftPkg.name,
|
|
54
|
-
taskProgressNudgePkg.name,
|
|
55
|
-
surfaceCompletionNudgePkg.name,
|
|
56
|
-
historyRepairPkg.name,
|
|
57
|
-
imageRecoveryPkg.name,
|
|
58
|
-
compactionPkg.name,
|
|
59
|
-
titleGeneratePkg.name,
|
|
60
|
-
]);
|