pilotswarm-sdk 0.5.73 → 0.5.74
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/README.md +7 -0
- package/api/src/admin-diagnostics.js +1 -1
- package/dist/agent-discovery.d.ts.map +1 -1
- package/dist/agent-discovery.js +2 -4
- package/dist/agent-discovery.js.map +1 -1
- package/dist/agent-package-format.d.ts +2 -2
- package/dist/agent-package-format.js +3 -3
- package/dist/agent-package-format.js.map +1 -1
- package/dist/base-agent-policy.d.ts +13 -0
- package/dist/base-agent-policy.d.ts.map +1 -0
- package/dist/base-agent-policy.js +26 -0
- package/dist/base-agent-policy.js.map +1 -0
- package/dist/capability-catalog.d.ts +99 -0
- package/dist/capability-catalog.d.ts.map +1 -0
- package/dist/capability-catalog.js +198 -0
- package/dist/capability-catalog.js.map +1 -0
- package/dist/capability-runtime.d.ts +124 -0
- package/dist/capability-runtime.d.ts.map +1 -0
- package/dist/capability-runtime.js +163 -0
- package/dist/capability-runtime.js.map +1 -0
- package/dist/cms-migrations.d.ts.map +1 -1
- package/dist/cms-migrations.js +2 -8
- package/dist/cms-migrations.js.map +1 -1
- package/dist/cms.d.ts +5 -9
- package/dist/cms.d.ts.map +1 -1
- package/dist/cms.js +24 -0
- package/dist/cms.js.map +1 -1
- package/dist/feature-flag-cache.d.ts.map +1 -1
- package/dist/feature-flag-cache.js +5 -2
- package/dist/feature-flag-cache.js.map +1 -1
- package/dist/feature-flags.d.ts +10 -1
- package/dist/feature-flags.d.ts.map +1 -1
- package/dist/feature-flags.js +13 -0
- package/dist/feature-flags.js.map +1 -1
- package/dist/feature-store.d.ts +2 -1
- package/dist/feature-store.d.ts.map +1 -1
- package/dist/feature-store.js +4 -2
- package/dist/feature-store.js.map +1 -1
- package/dist/managed-session.d.ts.map +1 -1
- package/dist/managed-session.js +56 -33
- package/dist/managed-session.js.map +1 -1
- package/dist/migrations/base-agent-v2-0079.d.ts +3 -0
- package/dist/migrations/base-agent-v2-0079.d.ts.map +1 -0
- package/dist/migrations/base-agent-v2-0079.js +19 -0
- package/dist/migrations/base-agent-v2-0079.js.map +1 -0
- package/dist/native-subagents.d.ts +2 -1
- package/dist/native-subagents.d.ts.map +1 -1
- package/dist/native-subagents.js +22 -4
- package/dist/native-subagents.js.map +1 -1
- package/dist/reserved-tool-names.d.ts.map +1 -1
- package/dist/reserved-tool-names.js +1 -0
- package/dist/reserved-tool-names.js.map +1 -1
- package/dist/session-manager.d.ts +2 -0
- package/dist/session-manager.d.ts.map +1 -1
- package/dist/session-manager.js +102 -5
- package/dist/session-manager.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/worker.d.ts +4 -0
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +66 -2
- package/dist/worker.js.map +1 -1
- package/package.json +3 -3
- package/plugins/system/prompts/base-v2.md +130 -0
package/dist/feature-store.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Pool } from "pg";
|
|
2
|
-
import { type FeatureDefinition, type FeatureOwner, type FeatureSetting, type FeatureSnapshot } from "./feature-flags.js";
|
|
2
|
+
import { type FeatureDecision, type FeatureDefinition, type FeatureOwner, type FeatureSetting, type FeatureSnapshot } from "./feature-flags.js";
|
|
3
3
|
/** Trusted transport/worker identity, never deserialized from a request body. */
|
|
4
4
|
export interface FeatureViewer {
|
|
5
5
|
principal: FeatureOwner | null;
|
|
@@ -19,6 +19,7 @@ export interface FeatureView {
|
|
|
19
19
|
user: FeatureSetting | null;
|
|
20
20
|
effective: boolean;
|
|
21
21
|
source: string;
|
|
22
|
+
reason?: FeatureDecision["reason"];
|
|
22
23
|
userOverrideIgnored: boolean;
|
|
23
24
|
supported: boolean;
|
|
24
25
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-store.d.ts","sourceRoot":"","sources":["../src/feature-store.ts"],"names":[],"mappings":"AAAA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FeatureFlagError, isFeatureKey, resolveFeatureDefinition } from "./feature-flags.js";
|
|
1
|
+
import { FeatureFlagError, applyBaseAgentPrerequisite, isFeatureKey, resolveFeatureDefinition } from "./feature-flags.js";
|
|
2
2
|
export class FeatureStore {
|
|
3
3
|
pool;
|
|
4
4
|
schema;
|
|
@@ -72,11 +72,13 @@ export class FeatureStore {
|
|
|
72
72
|
if (userId !== undefined && (!Number.isSafeInteger(userId) || userId <= 0))
|
|
73
73
|
throw new FeatureFlagError("FEATURE_INVALID", "Invalid user ID");
|
|
74
74
|
const result = await this.call("cms_feature_read", [...this.actor(viewer), scope, userId ?? null]);
|
|
75
|
+
const decisions = new Map(result.definitions.map(definition => [definition.featureKey, resolveFeatureDefinition(definition, result.settings.find(setting => setting.featureKey === definition.featureKey && setting.scope === "cluster"), result.settings.find(setting => setting.featureKey === definition.featureKey && setting.scope === "user"))]));
|
|
75
76
|
return { userId: result.userId, flags: result.definitions.map(definition => {
|
|
76
77
|
const cluster = result.settings.find(setting => setting.featureKey === definition.featureKey && setting.scope === "cluster");
|
|
77
78
|
const user = result.settings.find(setting => setting.featureKey === definition.featureKey && setting.scope === "user");
|
|
78
|
-
const decision =
|
|
79
|
+
const decision = applyBaseAgentPrerequisite(definition.featureKey, decisions.get(definition.featureKey), decisions.get("copilot.native_tasks"));
|
|
79
80
|
return { ...definition, cluster: cluster ?? null, user: user ?? null, effective: decision.enabled,
|
|
81
|
+
...(decision.reason ? { reason: decision.reason } : {}),
|
|
80
82
|
source: decision.source, supported: isFeatureKey(definition.featureKey),
|
|
81
83
|
userOverrideIgnored: Boolean(user && !(cluster?.allowUserOverride ?? definition.defaultAllowUserOverride)) };
|
|
82
84
|
}) };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-store.js","sourceRoot":"","sources":["../src/feature-store.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"feature-store.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AC,MAAM,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IAChG,CAAC;CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managed-session.d.ts","sourceRoot":"","sources":["../src/managed-session.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"managed-session.d.ts","sourceRoot":"","sources":["../src/managed-session.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,KAAK,IAAI,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAQlE,OAAO,KAAK,EAA2B,UAAU,EAAE,WAAW,EAAE,oBAAoB,EAAiB,MAAM,YAAY,CAAC;AAqExH;;;;;;;;GAQG;AACH;;;;;;;;;GASG;AAKH,OAAO,EAAE,+BAA+B,EAAE,MAAM,0BAA0B,CAAC;AAsR3E,8DAA8D;AAC9D,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3D;AAsKD,eAAO,MAAM,uBAAuB,QAAc,CAAC;AACnD,eAAO,MAAM,kCAAkC,QAAa,CAAC;AAK7D,eAAO,MAAM,4BAA4B,qDAAqD,CAAC;AAgF/F;;;;;;;;;;;;;GAaG;AACH,qBAAa,cAAc;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,cAAc,CAAiB;IACvC,OAAO,CAAC,MAAM,CAAuB;IACrC,6EAA6E;IAC7E,OAAO,CAAC,YAAY,CAAoE;IAIxF,OAAO,CAAC,aAAa,CAAkC;IACvD,gBAAgB,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,GAAG,IAAI;IAI1D,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC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;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAIvC;;OAEG;IACH,mBAAmB;IAEnB,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,IAAI;IAgBzD,mBAAmB,CAAC,MAAM,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,OAAO;IA8BnE,yEAAyE;IACzE,iBAAiB,IAAI,cAAc;CAGtC"}
|
package/dist/managed-session.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { CAPABILITY_TOOL_SPECS, capabilityToolDeclarations } from "./capability-runtime.js";
|
|
2
|
+
import { DURABLE_SPAWN_DESCRIPTION } from "./base-agent-policy.js";
|
|
1
3
|
import { isNativeChildEvent, settleNativeSubagents, guardNativeExternalTools } from "./native-subagents.js";
|
|
2
4
|
import { defineTool } from "@github/copilot-sdk";
|
|
3
5
|
import { normalizeCanvasResponseContract as normalizeCanvasContractShared } from "./canvas-app-manifest.js";
|
|
@@ -282,7 +284,7 @@ const LOAD_SKILL_TOOL_SPEC = {
|
|
|
282
284
|
parameters: {
|
|
283
285
|
type: "object",
|
|
284
286
|
properties: {
|
|
285
|
-
name: { type: "string", description: "Skill name exactly as listed in the system prompt's skills index." },
|
|
287
|
+
name: { type: "string", description: "Skill name exactly as listed in the system prompt's skills index, or an exact skill ref returned by search_capabilities." },
|
|
286
288
|
},
|
|
287
289
|
required: ["name"],
|
|
288
290
|
},
|
|
@@ -906,7 +908,7 @@ export class ManagedSession {
|
|
|
906
908
|
const publishCanvasAppTool = defineTool("publish_canvas_app", PUBLISH_CANVAS_APP_TOOL_SPEC);
|
|
907
909
|
const findCanvasAppTool = defineTool("find_canvas_app", FIND_CANVAS_APP_TOOL_SPEC);
|
|
908
910
|
const loadSkillTool = defineTool("load_skill", LOAD_SKILL_TOOL_SPEC);
|
|
909
|
-
return [waitTool, waitOnWorkerTool, cronTool, cronAtTool, askUserTool, reportCycleTool, listModelsTool, setSessionModelTool, regenerateContextTool, regenerateAgentTool, sendSessionMessageTool, replySessionMessageTool, showArtifactTool, drawCanvasTool, updateCanvasTool, readCanvasTool, showCanvasTool, canvasKvTool, publishCanvasAppTool, findCanvasAppTool, loadSkillTool,
|
|
911
|
+
return [waitTool, waitOnWorkerTool, cronTool, cronAtTool, askUserTool, reportCycleTool, listModelsTool, setSessionModelTool, regenerateContextTool, regenerateAgentTool, sendSessionMessageTool, replySessionMessageTool, showArtifactTool, drawCanvasTool, updateCanvasTool, readCanvasTool, showCanvasTool, canvasKvTool, publishCanvasAppTool, findCanvasAppTool, loadSkillTool, ...capabilityToolDeclarations(),
|
|
910
912
|
...(holdsProviderTools(opts?.agentIdentity) ? providerToolDefs() : [])];
|
|
911
913
|
}
|
|
912
914
|
/**
|
|
@@ -916,23 +918,7 @@ export class ManagedSession {
|
|
|
916
918
|
*/
|
|
917
919
|
static subAgentToolDefs() {
|
|
918
920
|
const spawnAgentTool = defineTool("spawn_agent", {
|
|
919
|
-
description:
|
|
920
|
-
"The sub-agent is a full Copilot session with its own conversation and tools. " +
|
|
921
|
-
"Returns an agent ID you can use to check status, send messages, or wait for completion. " +
|
|
922
|
-
"If the user explicitly asks you to use sub-agents, delegation, fan-out, or parallel processing, you should comply within runtime limits instead of collapsing the work into a direct answer. " +
|
|
923
|
-
"If the user did not explicitly ask for delegation, use your judgment about whether parallel work is actually helpful. " +
|
|
924
|
-
"Each agent adds cost, so avoid unnecessary fan-out when delegation was not requested. " +
|
|
925
|
-
"For KNOWN user-creatable agents, pass agent_name. The agent's instructions, tools, and startup requirement load automatically; task supplies your assignment. " +
|
|
926
|
-
"Before choosing a custom child, check the available static and published agent definitions with ps_list_agents unless the current catalog already identifies a suitable specialist. Select by role, source access, and capabilities, then pass the exact agent_name from the list and task for the assignment. Prefer a suitable named specialist over recreating it as a generic child. " +
|
|
927
|
-
"You MAY spawn multiple concurrent instances of the same agent_name (e.g. one per bug or per shard); they each get their own conversation. The only caps are the global maximum concurrent sub-agents and the maximum nesting depth. " +
|
|
928
|
-
"Sub-agents do NOT auto-terminate when they finish their task \u2014 they stay alive idle, ready for follow-up via message_agent. YOU are responsible for closing each child with complete_agent (graceful), cancel_agent (interrupt), or delete_agent (forceful) when you no longer need it. " +
|
|
929
|
-
"Worker-managed system agents are NOT valid spawn_agent targets; if one is missing, the workers likely need to be restarted. " +
|
|
930
|
-
"For CUSTOM agents (ad-hoc tasks), pass task instead. Do not attach package-owned names through tool_names; select their named agent through ps_list_agents so its instructions, tools, and startup requirement stay together. " +
|
|
931
|
-
"Call ps_list_agents to see all available named agents you CAN spawn. " +
|
|
932
|
-
"By default, sub-agents inherit the parent's model. " +
|
|
933
|
-
"If you want to override the model, call list_available_models first and use only an exact provider:model value returned there. " +
|
|
934
|
-
"If you want to override reasoning power, also use only a reasoning_effort value listed for that model. " +
|
|
935
|
-
"Never invent, guess, or shorten model names.",
|
|
921
|
+
description: DURABLE_SPAWN_DESCRIPTION,
|
|
936
922
|
parameters: {
|
|
937
923
|
type: "object",
|
|
938
924
|
properties: {
|
|
@@ -1824,6 +1810,16 @@ export class ManagedSession {
|
|
|
1824
1810
|
...LOAD_SKILL_TOOL_SPEC,
|
|
1825
1811
|
handler: async (args) => {
|
|
1826
1812
|
const name = String(args?.name ?? "").trim();
|
|
1813
|
+
if (name.startsWith("cap1.")) {
|
|
1814
|
+
if (!this.config.capabilityServices)
|
|
1815
|
+
return "Error: capability service unavailable.";
|
|
1816
|
+
try {
|
|
1817
|
+
return JSON.stringify(await this.config.capabilityServices.load(name, "skill"));
|
|
1818
|
+
}
|
|
1819
|
+
catch (error) {
|
|
1820
|
+
return failureToolResult(error);
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1827
1823
|
if (!name)
|
|
1828
1824
|
return "Error: name is required.";
|
|
1829
1825
|
const catalog = this.skillCatalog;
|
|
@@ -1836,6 +1832,39 @@ export class ManagedSession {
|
|
|
1836
1832
|
return `[SKILL: ${skill.name}]\n${skill.description ? `${skill.description}\n\n` : ""}${skill.prompt}`;
|
|
1837
1833
|
},
|
|
1838
1834
|
});
|
|
1835
|
+
const capabilityTools = Object.entries(CAPABILITY_TOOL_SPECS).map(([name, spec]) => defineTool(name, {
|
|
1836
|
+
...spec,
|
|
1837
|
+
handler: async (args) => {
|
|
1838
|
+
if (hasTerminalTurnBoundary(turnState))
|
|
1839
|
+
return blockedAfterTurnBoundary(name);
|
|
1840
|
+
const service = this.config.capabilityServices;
|
|
1841
|
+
if (!service)
|
|
1842
|
+
return "Error: capability service unavailable.";
|
|
1843
|
+
try {
|
|
1844
|
+
if (name === "search_capabilities")
|
|
1845
|
+
return JSON.stringify(await service.search(args));
|
|
1846
|
+
if (name === "load_agent_guidelines")
|
|
1847
|
+
return JSON.stringify(await service.load(args.ref, "agent"));
|
|
1848
|
+
if (name === "list_session_capabilities")
|
|
1849
|
+
return JSON.stringify(await service.list());
|
|
1850
|
+
if (this.config.nativeSubagents === "sync") {
|
|
1851
|
+
const tasks = (await this.copilotSession.rpc.tasks.list()).tasks;
|
|
1852
|
+
if (tasks.some(task => task.type === "agent" && (task.status === "running" || task.status === "idle"))) {
|
|
1853
|
+
return "Error: finish native tasks before changing package capabilities.";
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
const result = await service.use(args);
|
|
1857
|
+
if (!result.changed)
|
|
1858
|
+
return JSON.stringify(result);
|
|
1859
|
+
turnState.pendingActions.push({ type: "completed", content: "Package capability selections updated.",
|
|
1860
|
+
forceContinuePrompt: "Package capability selections changed. The same session has refreshed its tools and MCP servers. Continue the user's original task using the selected capabilities; do not repeat the completed activation." });
|
|
1861
|
+
return `${JSON.stringify(result)}\n${acknowledgeTurnBoundary("use_package")}`;
|
|
1862
|
+
}
|
|
1863
|
+
catch (error) {
|
|
1864
|
+
return failureToolResult(error);
|
|
1865
|
+
}
|
|
1866
|
+
},
|
|
1867
|
+
}));
|
|
1839
1868
|
// list_available_models — returns data inline (no abort/continuation needed)
|
|
1840
1869
|
const listModelsTool = defineTool("list_available_models", {
|
|
1841
1870
|
description: "List all available LLM models across all configured providers. " +
|
|
@@ -2018,18 +2047,7 @@ export class ManagedSession {
|
|
|
2018
2047
|
});
|
|
2019
2048
|
// Build sub-agent tools
|
|
2020
2049
|
const spawnAgentTool = defineTool("spawn_agent", {
|
|
2021
|
-
description:
|
|
2022
|
-
"The agent's instructions, tools, and startup requirement load automatically; task supplies your assignment. " +
|
|
2023
|
-
"Do not override system_message or tool_names when using agent_name. " +
|
|
2024
|
-
"Before choosing a custom child, check the available static and published agent definitions with ps_list_agents unless the current catalog already identifies a suitable specialist. Select by role, source access, and capabilities, then pass the exact agent_name from the list and task for the assignment. Prefer a suitable named specialist over recreating it as a generic child. " +
|
|
2025
|
-
"Calling spawn_agent does NOT finish your turn. After it succeeds, continue executing the rest of your workflow in the SAME turn unless you intentionally call wait, wait_for_agents, ask_user, or give your final answer. " +
|
|
2026
|
-
"Call ps_list_agents to see all available named agents you CAN spawn. " +
|
|
2027
|
-
"Worker-managed system agents are not valid spawn_agent targets; if one is missing, the workers likely need to be restarted. " +
|
|
2028
|
-
"For CUSTOM agents (ad-hoc tasks), pass task instead — no agent_name is needed. Do not attach package-owned names through tool_names; select their named agent through ps_list_agents so its instructions, tools, and startup requirement stay together. " +
|
|
2029
|
-
"Use a custom agent when no available named definition fits the task. " +
|
|
2030
|
-
"If you want a different model, call list_available_models first and use only an exact provider:model value from that list. " +
|
|
2031
|
-
"If you want different reasoning power, also use only a reasoning_effort value listed for that model. " +
|
|
2032
|
-
"Never invent, guess, or shorten model names.",
|
|
2050
|
+
description: DURABLE_SPAWN_DESCRIPTION,
|
|
2033
2051
|
parameters: {
|
|
2034
2052
|
type: "object",
|
|
2035
2053
|
properties: {
|
|
@@ -2330,7 +2348,7 @@ export class ManagedSession {
|
|
|
2330
2348
|
},
|
|
2331
2349
|
});
|
|
2332
2350
|
const SYSTEM_TOOL_NAMES = new Set([
|
|
2333
|
-
"update_canvas", "wait", "wait_on_worker", "cron", "cron_at", "ask_user", "report_cycle", "list_available_models", "set_session_model", "send_session_message", "reply_session_message", "show_artifact", "draw_canvas", "read_canvas", "show_canvas", "canvas_kv", "publish_canvas_app", "find_canvas_app", "load_skill", "spawn_agent", "message_agent", "check_agents", "wait_for_agents", "list_sessions", "complete_agent", "cancel_agent", "delete_agent"
|
|
2351
|
+
"update_canvas", "wait", "wait_on_worker", "cron", "cron_at", "ask_user", "report_cycle", "list_available_models", "set_session_model", "send_session_message", "reply_session_message", "show_artifact", "draw_canvas", "read_canvas", "show_canvas", "canvas_kv", "publish_canvas_app", "find_canvas_app", "load_skill", "search_capabilities", "load_agent_guidelines", "list_session_capabilities", "use_package", "spawn_agent", "message_agent", "check_agents", "wait_for_agents", "list_sessions", "complete_agent", "cancel_agent", "delete_agent"
|
|
2334
2352
|
]);
|
|
2335
2353
|
// Merge user tools with system tools
|
|
2336
2354
|
const userTools = this.config.tools ?? [];
|
|
@@ -2377,7 +2395,7 @@ export class ManagedSession {
|
|
|
2377
2395
|
// the schema. Gate both halves on the same list so there is no tool
|
|
2378
2396
|
// that exists-but-is-hidden in an ordinary session.
|
|
2379
2397
|
const isManagerSession = holdsManagerBundle(this.config.agentIdentity);
|
|
2380
|
-
const mutatingSystemToolNames = new Set(["send_session_message", "reply_session_message", "draw_canvas", "show_canvas", "canvas_kv", "publish_canvas_app",
|
|
2398
|
+
const mutatingSystemToolNames = new Set(["send_session_message", "reply_session_message", "draw_canvas", "show_canvas", "canvas_kv", "publish_canvas_app", "use_package",
|
|
2381
2399
|
"update_canvas"]);
|
|
2382
2400
|
const systemToolsForTurn = isServiceSession ? [] : [
|
|
2383
2401
|
waitTool,
|
|
@@ -2390,6 +2408,7 @@ export class ManagedSession {
|
|
|
2390
2408
|
setSessionModelTool,
|
|
2391
2409
|
regenerateContextTool,
|
|
2392
2410
|
regenerateAgentTool,
|
|
2411
|
+
...capabilityTools,
|
|
2393
2412
|
sendSessionMessageTool,
|
|
2394
2413
|
replySessionMessageTool,
|
|
2395
2414
|
showArtifactTool,
|
|
@@ -3237,6 +3256,10 @@ export class ManagedSession {
|
|
|
3237
3256
|
*/
|
|
3238
3257
|
getNativeTaskAccess() { return this.config.nativeTaskAccess; }
|
|
3239
3258
|
updateConfig(config) {
|
|
3259
|
+
this.config.capabilityServices = config.capabilityServices;
|
|
3260
|
+
this.config.capabilityFingerprint = config.capabilityFingerprint;
|
|
3261
|
+
if (config.baseAgentPolicy !== undefined)
|
|
3262
|
+
this.config.baseAgentPolicy = config.baseAgentPolicy;
|
|
3240
3263
|
if (config.nativeFeatureAllowed !== undefined)
|
|
3241
3264
|
this.config.nativeFeatureAllowed = config.nativeFeatureAllowed;
|
|
3242
3265
|
if (config.featureToolFingerprint !== undefined)
|