@geminilight/mindos 1.1.51 → 1.1.52
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/agent/global-state.d.ts +13 -0
- package/dist/agent/global-state.d.ts.map +1 -1
- package/dist/agent/global-state.js +13 -0
- package/dist/agent/global-state.js.map +1 -1
- package/dist/agent/ledger/artifact-ledger.d.ts +84 -0
- package/dist/agent/ledger/artifact-ledger.d.ts.map +1 -0
- package/dist/agent/ledger/artifact-ledger.js +421 -0
- package/dist/agent/ledger/artifact-ledger.js.map +1 -0
- package/dist/agent/ledger/index.d.ts +1 -0
- package/dist/agent/ledger/index.d.ts.map +1 -1
- package/dist/agent/ledger/index.js +1 -0
- package/dist/agent/ledger/index.js.map +1 -1
- package/dist/agent/runtime/catalog.d.ts +97 -0
- package/dist/agent/runtime/catalog.d.ts.map +1 -0
- package/dist/agent/runtime/catalog.js +261 -0
- package/dist/agent/runtime/catalog.js.map +1 -0
- package/dist/agent/runtime/compatibility.d.ts.map +1 -1
- package/dist/agent/runtime/compatibility.js +13 -11
- package/dist/agent/runtime/compatibility.js.map +1 -1
- package/dist/agent/runtime/extension-manifest.d.ts +115 -0
- package/dist/agent/runtime/extension-manifest.d.ts.map +1 -0
- package/dist/agent/runtime/extension-manifest.js +383 -0
- package/dist/agent/runtime/extension-manifest.js.map +1 -0
- package/dist/agent/runtime/index.d.ts +2 -0
- package/dist/agent/runtime/index.d.ts.map +1 -1
- package/dist/agent/runtime/index.js +2 -0
- package/dist/agent/runtime/index.js.map +1 -1
- package/dist/agent/runtime/registry.d.ts +7 -2
- package/dist/agent/runtime/registry.d.ts.map +1 -1
- package/dist/agent/runtime/registry.js +16 -5
- package/dist/agent/runtime/registry.js.map +1 -1
- package/dist/protocols/acp/index.d.ts +3 -1
- package/dist/protocols/acp/index.d.ts.map +1 -1
- package/dist/protocols/acp/index.js +26 -24
- package/dist/protocols/acp/index.js.map +1 -1
- package/dist/protocols/acp/mcp-session-inheritance.d.ts +49 -0
- package/dist/protocols/acp/mcp-session-inheritance.d.ts.map +1 -0
- package/dist/protocols/acp/mcp-session-inheritance.js +162 -0
- package/dist/protocols/acp/mcp-session-inheritance.js.map +1 -0
- package/dist/protocols/acp/session.d.ts +5 -0
- package/dist/protocols/acp/session.d.ts.map +1 -1
- package/dist/protocols/acp/session.js +159 -4
- package/dist/protocols/acp/session.js.map +1 -1
- package/dist/protocols/acp/types.d.ts +7 -0
- package/dist/protocols/acp/types.d.ts.map +1 -1
- package/dist/protocols/acp/types.js.map +1 -1
- package/dist/server/handlers/agent-runtimes.d.ts.map +1 -1
- package/dist/server/handlers/agent-runtimes.js +7 -2
- package/dist/server/handlers/agent-runtimes.js.map +1 -1
- package/dist/server/handlers/runtime-artifact-projections.d.ts +14 -0
- package/dist/server/handlers/runtime-artifact-projections.d.ts.map +1 -1
- package/dist/server/handlers/runtime-artifact-projections.js +30 -7
- package/dist/server/handlers/runtime-artifact-projections.js.map +1 -1
- package/dist/server/handlers/runtime-readiness.d.ts +5 -3
- package/dist/server/handlers/runtime-readiness.d.ts.map +1 -1
- package/dist/server/handlers/runtime-readiness.js +63 -2
- package/dist/server/handlers/runtime-readiness.js.map +1 -1
- package/dist/server/handlers/runtime-session-projections.d.ts +7 -1
- package/dist/server/handlers/runtime-session-projections.d.ts.map +1 -1
- package/dist/server/handlers/runtime-session-projections.js +23 -0
- package/dist/server/handlers/runtime-session-projections.js.map +1 -1
- package/dist/server/http.js +4 -1
- package/dist/server/http.js.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/protocols/acp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,6BAA6B,EAC7B,mBAAmB,EACnB,sBAAsB,EACtB,8BAA8B,EAC9B,mBAAmB,EACnB,YAAY,GACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,oBAAoB,EACpB,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,4BAA4B,EAC5B,sBAAsB,EACtB,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,SAAS,EACT,aAAa,EACb,aAAa,EACb,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EACzB,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,MAAM,EACN,YAAY,EACZ,eAAe,EACf,OAAO,GACR,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/protocols/acp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EACxB,uBAAuB,EACvB,6BAA6B,EAC7B,mBAAmB,EACnB,sBAAsB,EACtB,8BAA8B,EAC9B,mBAAmB,EACnB,YAAY,GACb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,YAAY,GACb,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,oBAAoB,EACpB,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,4BAA4B,EAC5B,sBAAsB,EACtB,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,kBAAkB,EAClB,UAAU,EACV,SAAS,EACT,aAAa,EACb,aAAa,EACb,eAAe,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,iCAAiC,EACjC,2BAA2B,GAC5B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,sBAAsB,EACtB,iBAAiB,EACjB,yBAAyB,EACzB,UAAU,EACV,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,MAAM,EACN,YAAY,EACZ,eAAe,EACf,OAAO,GACR,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { McpCapabilities, McpServer } from '@agentclientprotocol/sdk';
|
|
2
|
+
import type { AcpSessionMcpServerSummary } from './types.js';
|
|
3
|
+
export type AcpSessionMcpAccess = boolean | string[] | {
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
tools?: true | string[];
|
|
6
|
+
directTools?: true | string[];
|
|
7
|
+
};
|
|
8
|
+
export type AcpSessionMcpConfigEntry = {
|
|
9
|
+
command?: unknown;
|
|
10
|
+
args?: unknown;
|
|
11
|
+
env?: unknown;
|
|
12
|
+
url?: unknown;
|
|
13
|
+
headers?: unknown;
|
|
14
|
+
type?: unknown;
|
|
15
|
+
transport?: unknown;
|
|
16
|
+
mindosAgent?: AcpSessionMcpAccess;
|
|
17
|
+
agentSession?: AcpSessionMcpAccess;
|
|
18
|
+
agentSessions?: AcpSessionMcpAccess;
|
|
19
|
+
acpSession?: AcpSessionMcpAccess;
|
|
20
|
+
acpSessions?: AcpSessionMcpAccess;
|
|
21
|
+
mindos?: Record<string, unknown>;
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
};
|
|
24
|
+
export type AcpSessionMcpConfigLike = {
|
|
25
|
+
mcpServers?: Record<string, AcpSessionMcpConfigEntry>;
|
|
26
|
+
'mcp-servers'?: Record<string, AcpSessionMcpConfigEntry>;
|
|
27
|
+
settings?: Record<string, unknown>;
|
|
28
|
+
};
|
|
29
|
+
export type AcpSessionMcpInheritancePlan = {
|
|
30
|
+
servers: McpServer[];
|
|
31
|
+
summaries: AcpSessionMcpServerSummary[];
|
|
32
|
+
skipped: Array<{
|
|
33
|
+
name: string;
|
|
34
|
+
reason: string;
|
|
35
|
+
}>;
|
|
36
|
+
};
|
|
37
|
+
export declare function buildAcpSessionMcpInheritancePlan(input: {
|
|
38
|
+
config?: AcpSessionMcpConfigLike | null;
|
|
39
|
+
agentCapabilities?: {
|
|
40
|
+
mcpCapabilities?: McpCapabilities;
|
|
41
|
+
} | null;
|
|
42
|
+
}): AcpSessionMcpInheritancePlan;
|
|
43
|
+
export declare function resolveAcpSessionMcpServers(input: {
|
|
44
|
+
config?: AcpSessionMcpConfigLike | null;
|
|
45
|
+
agentCapabilities?: {
|
|
46
|
+
mcpCapabilities?: McpCapabilities;
|
|
47
|
+
} | null;
|
|
48
|
+
}): McpServer[];
|
|
49
|
+
//# sourceMappingURL=mcp-session-inheritance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-session-inheritance.d.ts","sourceRoot":"","sources":["../../../src/protocols/acp/mcp-session-inheritance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAE7D,MAAM,MAAM,mBAAmB,GAC3B,OAAO,GACP,MAAM,EAAE,GACR;IACA,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,IAAI,GAAG,MAAM,EAAE,CAAC;CAC/B,CAAC;AAEJ,MAAM,MAAM,wBAAwB,GAAG;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,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AE;IACjD,MAAM,CAAC,EAAE,uBAAuB,GAAG,IAAI,CAAC;IACxC,iBAAiB,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,eAAe,CAAA;KAAE,GAAG,IAAI,CAAC;CAClE,GAAG,SAAS,EAAE,CAEd"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
export function buildAcpSessionMcpInheritancePlan(input) {
|
|
2
|
+
const config = normalizeMcpConfig(input.config);
|
|
3
|
+
const capabilities = input.agentCapabilities?.mcpCapabilities;
|
|
4
|
+
const servers = [];
|
|
5
|
+
const summaries = [];
|
|
6
|
+
const skipped = [];
|
|
7
|
+
for (const [name, entry] of Object.entries(config.mcpServers).sort(([left], [right]) => left.localeCompare(right))) {
|
|
8
|
+
if (isUnsafeName(name)) {
|
|
9
|
+
skipped.push({ name, reason: 'unsafe-name' });
|
|
10
|
+
continue;
|
|
11
|
+
}
|
|
12
|
+
const access = resolveAgentSessionAccess(name, entry, config);
|
|
13
|
+
if (access !== true) {
|
|
14
|
+
skipped.push({ name, reason: access ? 'tool-subset-not-injectable' : 'not-allowlisted' });
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const server = toAcpMcpServer(name, entry, capabilities);
|
|
18
|
+
if (!server) {
|
|
19
|
+
skipped.push({ name, reason: 'unsupported-transport' });
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
servers.push(server);
|
|
23
|
+
summaries.push({ name, type: mcpServerType(server) });
|
|
24
|
+
}
|
|
25
|
+
return { servers, summaries, skipped };
|
|
26
|
+
}
|
|
27
|
+
export function resolveAcpSessionMcpServers(input) {
|
|
28
|
+
return buildAcpSessionMcpInheritancePlan(input).servers;
|
|
29
|
+
}
|
|
30
|
+
function normalizeMcpConfig(config) {
|
|
31
|
+
if (!config || typeof config !== 'object')
|
|
32
|
+
return { mcpServers: {} };
|
|
33
|
+
const mcpServers = readRecord(config.mcpServers) ?? readRecord(config['mcp-servers']) ?? {};
|
|
34
|
+
return {
|
|
35
|
+
mcpServers: Object.fromEntries(Object.entries(mcpServers)
|
|
36
|
+
.filter(([, entry]) => !!entry && typeof entry === 'object' && !Array.isArray(entry))),
|
|
37
|
+
...(readRecord(config.settings) ? { settings: readRecord(config.settings) } : {}),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function resolveAgentSessionAccess(name, entry, config) {
|
|
41
|
+
const settings = config.settings;
|
|
42
|
+
const agentSessions = readRecord(settings?.agentSessions);
|
|
43
|
+
const acpSessions = readRecord(settings?.acpSessions);
|
|
44
|
+
const mindosAgent = readRecord(settings?.mindosAgent);
|
|
45
|
+
const mindos = readRecord(entry.mindos);
|
|
46
|
+
return normalizeAccess(readRecord(agentSessions?.mcpServers)?.[name])
|
|
47
|
+
?? normalizeAccess(readRecord(acpSessions?.mcpServers)?.[name])
|
|
48
|
+
?? normalizeAccess(readRecord(mindosAgent?.mcpServers)?.[name])
|
|
49
|
+
?? normalizeAccess(entry.agentSessions)
|
|
50
|
+
?? normalizeAccess(entry.agentSession)
|
|
51
|
+
?? normalizeAccess(entry.acpSessions)
|
|
52
|
+
?? normalizeAccess(entry.acpSession)
|
|
53
|
+
?? normalizeAccess(entry.mindosAgent)
|
|
54
|
+
?? normalizeAccess(mindos?.agentSessions)
|
|
55
|
+
?? normalizeAccess(mindos?.agent)
|
|
56
|
+
?? null;
|
|
57
|
+
}
|
|
58
|
+
function normalizeAccess(access) {
|
|
59
|
+
if (access === true)
|
|
60
|
+
return true;
|
|
61
|
+
if (access === false || access === undefined || access === null)
|
|
62
|
+
return null;
|
|
63
|
+
if (Array.isArray(access))
|
|
64
|
+
return normalizeToolNames(access);
|
|
65
|
+
if (!access || typeof access !== 'object')
|
|
66
|
+
return null;
|
|
67
|
+
const record = access;
|
|
68
|
+
if (record.enabled === false)
|
|
69
|
+
return null;
|
|
70
|
+
if (record.tools === true || record.directTools === true || record.enabled === true)
|
|
71
|
+
return true;
|
|
72
|
+
if (Array.isArray(record.tools))
|
|
73
|
+
return normalizeToolNames(record.tools);
|
|
74
|
+
if (Array.isArray(record.directTools))
|
|
75
|
+
return normalizeToolNames(record.directTools);
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
function normalizeToolNames(value) {
|
|
79
|
+
const tools = Array.from(new Set(value.map((item) => (typeof item === 'string' ? item.trim() : '')).filter(Boolean)));
|
|
80
|
+
return tools.length > 0 ? tools : null;
|
|
81
|
+
}
|
|
82
|
+
function toAcpMcpServer(name, entry, capabilities) {
|
|
83
|
+
const url = typeof entry.url === 'string' ? entry.url.trim() : '';
|
|
84
|
+
if (url) {
|
|
85
|
+
const transport = normalizeTransport(entry.type) ?? normalizeTransport(entry.transport) ?? 'http';
|
|
86
|
+
if (transport === 'sse') {
|
|
87
|
+
if (capabilities?.sse !== true)
|
|
88
|
+
return null;
|
|
89
|
+
return { type: 'sse', name, url, headers: normalizeHeaders(entry.headers) };
|
|
90
|
+
}
|
|
91
|
+
if (transport === 'http') {
|
|
92
|
+
if (capabilities?.http !== true)
|
|
93
|
+
return null;
|
|
94
|
+
return { type: 'http', name, url, headers: normalizeHeaders(entry.headers) };
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const command = typeof entry.command === 'string' ? entry.command.trim() : '';
|
|
99
|
+
if (!command)
|
|
100
|
+
return null;
|
|
101
|
+
return {
|
|
102
|
+
name,
|
|
103
|
+
command,
|
|
104
|
+
args: normalizeStringArray(entry.args),
|
|
105
|
+
env: normalizeEnv(entry.env),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function normalizeTransport(value) {
|
|
109
|
+
if (typeof value !== 'string')
|
|
110
|
+
return null;
|
|
111
|
+
const normalized = value.trim().toLowerCase();
|
|
112
|
+
if (normalized === 'http' || normalized === 'streamable-http')
|
|
113
|
+
return 'http';
|
|
114
|
+
if (normalized === 'sse')
|
|
115
|
+
return 'sse';
|
|
116
|
+
if (normalized === 'stdio')
|
|
117
|
+
return 'stdio';
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
function normalizeHeaders(value) {
|
|
121
|
+
if (Array.isArray(value)) {
|
|
122
|
+
return value.flatMap((item) => {
|
|
123
|
+
if (!item || typeof item !== 'object' || Array.isArray(item))
|
|
124
|
+
return [];
|
|
125
|
+
const record = item;
|
|
126
|
+
const name = typeof record.name === 'string' ? record.name.trim() : '';
|
|
127
|
+
const headerValue = typeof record.value === 'string' ? record.value : '';
|
|
128
|
+
return name ? [{ name, value: headerValue }] : [];
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const record = readRecord(value);
|
|
132
|
+
if (!record)
|
|
133
|
+
return [];
|
|
134
|
+
return Object.entries(record).flatMap(([name, headerValue]) => (typeof headerValue === 'string' ? [{ name, value: headerValue }] : []));
|
|
135
|
+
}
|
|
136
|
+
function normalizeEnv(value) {
|
|
137
|
+
const record = readRecord(value);
|
|
138
|
+
if (!record)
|
|
139
|
+
return [];
|
|
140
|
+
return Object.entries(record).flatMap(([name, envValue]) => (typeof envValue === 'string' ? [{ name, value: envValue }] : []));
|
|
141
|
+
}
|
|
142
|
+
function normalizeStringArray(value) {
|
|
143
|
+
return Array.isArray(value)
|
|
144
|
+
? value.filter((item) => typeof item === 'string')
|
|
145
|
+
: [];
|
|
146
|
+
}
|
|
147
|
+
function mcpServerType(server) {
|
|
148
|
+
if ('type' in server && server.type === 'http')
|
|
149
|
+
return 'http';
|
|
150
|
+
if ('type' in server && server.type === 'sse')
|
|
151
|
+
return 'sse';
|
|
152
|
+
return 'stdio';
|
|
153
|
+
}
|
|
154
|
+
function readRecord(value) {
|
|
155
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
156
|
+
? value
|
|
157
|
+
: undefined;
|
|
158
|
+
}
|
|
159
|
+
function isUnsafeName(name) {
|
|
160
|
+
return !name.trim() || name === '__proto__' || name === 'prototype' || name === 'constructor';
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=mcp-session-inheritance.js.map
|
|
@@ -0,0 +1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AAChG,CAAC"}
|
|
@@ -3,10 +3,15 @@
|
|
|
3
3
|
* Uses @agentclientprotocol/sdk for all protocol handling.
|
|
4
4
|
* Implements: initialize → session/new → session/prompt → session/cancel → close.
|
|
5
5
|
*/
|
|
6
|
+
import type { McpServer } from '@agentclientprotocol/sdk';
|
|
6
7
|
import type { AcpSession, AcpSessionUpdate, AcpPromptResponse, AcpRegistryEntry, AcpConfigOption, AcpSessionInfo, AcpSessionSnapshot } from './types.js';
|
|
7
8
|
import { type AcpLaunchOptions } from './subprocess.js';
|
|
9
|
+
import { type AcpSessionMcpConfigLike } from './mcp-session-inheritance.js';
|
|
8
10
|
export interface AcpSessionOptions extends AcpLaunchOptions {
|
|
9
11
|
clientVersion?: string;
|
|
12
|
+
inheritMcpServers?: boolean;
|
|
13
|
+
mcpConfig?: AcpSessionMcpConfigLike | null;
|
|
14
|
+
mcpServers?: McpServer[];
|
|
10
15
|
}
|
|
11
16
|
/**
|
|
12
17
|
* Create a new ACP session by spawning an agent process.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/protocols/acp/session.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/protocols/acp/session.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAEV,SAAS,EAGV,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EACV,UAAU,EAEV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAGhB,eAAe,EACf,cAAc,EAMd,kBAAkB,EAGnB,MAAM,YAAY,CAAC;AACpB,OAAO,EAIL,KAAK,gBAAgB,EAGtB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,8BAA8B,CAAC;AAItC,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD,aAAa,CAAC,EAAE,MAAM,CA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AC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAM9E;AAED,wBAAsB,eAAe,CACnC,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,eAAe,EAAE,CAAC,CAiB5B;AAED,wBAAsB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBnE;AAID,wBAAgB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAEpE;AAED,wBAAgB,iBAAiB,IAAI,UAAU,EAAE,CAGhD;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAGpF;AAED,wBAAgB,yBAAyB,IAAI,kBAAkB,EAAE,CAGhE;AAED,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAGtD;AAsBD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,UAAU,GAAG,kBAAkB,CAgC/E"}
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
import { spawnAndConnect, killAgent, } from './subprocess.js';
|
|
7
7
|
import { findAcpAgent } from './registry.js';
|
|
8
8
|
import { resolveConfiguredAcpAgentEntry } from './agent-descriptors.js';
|
|
9
|
+
import { buildAcpSessionMcpInheritancePlan, } from './mcp-session-inheritance.js';
|
|
10
|
+
import { recordArtifactsFromAcpToolCall } from '../../agent/ledger/artifact-ledger.js';
|
|
11
|
+
import { redactSensitiveText } from '../../agent/redaction.js';
|
|
9
12
|
function withTimeout(promise, timeoutMs, message) {
|
|
10
13
|
return new Promise((resolve, reject) => {
|
|
11
14
|
const timer = setTimeout(() => reject(new Error(message)), timeoutMs);
|
|
@@ -53,6 +56,32 @@ function clientCapabilitiesForPermissionMode(mode) {
|
|
|
53
56
|
terminal: !readonly,
|
|
54
57
|
};
|
|
55
58
|
}
|
|
59
|
+
function resolveSessionMcpInheritance(options, agentCapabilities) {
|
|
60
|
+
if (options?.mcpServers) {
|
|
61
|
+
return {
|
|
62
|
+
servers: options.mcpServers,
|
|
63
|
+
summaries: options.mcpServers.map((server) => ({
|
|
64
|
+
name: server.name,
|
|
65
|
+
type: 'type' in server && server.type === 'http'
|
|
66
|
+
? 'http'
|
|
67
|
+
: 'type' in server && server.type === 'sse'
|
|
68
|
+
? 'sse'
|
|
69
|
+
: 'stdio',
|
|
70
|
+
})),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
if (options?.inheritMcpServers === false || !options?.mcpConfig) {
|
|
74
|
+
return { servers: [], summaries: [] };
|
|
75
|
+
}
|
|
76
|
+
const plan = buildAcpSessionMcpInheritancePlan({
|
|
77
|
+
config: options.mcpConfig,
|
|
78
|
+
agentCapabilities,
|
|
79
|
+
});
|
|
80
|
+
return {
|
|
81
|
+
servers: plan.servers,
|
|
82
|
+
summaries: plan.summaries,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
56
85
|
/* ── State ─────────────────────────────────────────────────────────────── */
|
|
57
86
|
const sessions = new Map();
|
|
58
87
|
const sessionConnections = new Map();
|
|
@@ -111,10 +140,11 @@ export async function createSessionFromEntry(entry, options) {
|
|
|
111
140
|
let configOptions;
|
|
112
141
|
let currentModeId;
|
|
113
142
|
let agentSessionId;
|
|
143
|
+
const mcpInheritance = resolveSessionMcpInheritance(options, agentCapabilities);
|
|
114
144
|
try {
|
|
115
145
|
const newResult = await conn.connection.newSession({
|
|
116
146
|
cwd: sessionCwd,
|
|
117
|
-
mcpServers:
|
|
147
|
+
mcpServers: mcpInheritance.servers,
|
|
118
148
|
});
|
|
119
149
|
if (typeof newResult.sessionId === 'string') {
|
|
120
150
|
agentSessionId = newResult.sessionId;
|
|
@@ -144,6 +174,7 @@ export async function createSessionFromEntry(entry, options) {
|
|
|
144
174
|
configOptions,
|
|
145
175
|
currentModeId,
|
|
146
176
|
authMethods,
|
|
177
|
+
mcpServers: mcpInheritance.summaries,
|
|
147
178
|
};
|
|
148
179
|
sessions.set(sessionId, session);
|
|
149
180
|
sessionConnections.set(sessionId, conn);
|
|
@@ -182,11 +213,12 @@ export async function loadSession(agentId, existingSessionId, options) {
|
|
|
182
213
|
let modes;
|
|
183
214
|
let configOptions;
|
|
184
215
|
let currentModeId;
|
|
216
|
+
const mcpInheritance = resolveSessionMcpInheritance(options, agentCapabilities);
|
|
185
217
|
try {
|
|
186
218
|
const loadResult = await conn.connection.loadSession({
|
|
187
219
|
sessionId: existingSessionId,
|
|
188
220
|
cwd: loadCwd,
|
|
189
|
-
mcpServers:
|
|
221
|
+
mcpServers: mcpInheritance.servers,
|
|
190
222
|
});
|
|
191
223
|
modes = parseModes(loadResult.modes);
|
|
192
224
|
currentModeId = parseCurrentModeId(loadResult.modes);
|
|
@@ -209,6 +241,7 @@ export async function loadSession(agentId, existingSessionId, options) {
|
|
|
209
241
|
modes,
|
|
210
242
|
configOptions,
|
|
211
243
|
currentModeId,
|
|
244
|
+
mcpServers: mcpInheritance.summaries,
|
|
212
245
|
};
|
|
213
246
|
sessions.set(existingSessionId, session);
|
|
214
247
|
sessionConnections.set(existingSessionId, conn);
|
|
@@ -238,6 +271,9 @@ export async function listSessions(sessionId, options) {
|
|
|
238
271
|
}
|
|
239
272
|
/* ── Public API — Prompt ──────────────────────────────────────────────── */
|
|
240
273
|
const PROMPT_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes
|
|
274
|
+
const TOOL_RAW_TEXT_LIMIT = 4000;
|
|
275
|
+
const INLINE_IMAGE_RESULT_LIMIT = 64 * 1024;
|
|
276
|
+
const INLINE_IMAGE_PREFIX_RE = /^(?:data:image\/|iVBORw0KGgo|\/9j\/|UklGR)/;
|
|
241
277
|
/**
|
|
242
278
|
* Send a prompt and collect the full response.
|
|
243
279
|
* Text arrives via session/update notifications (handled by SDK → Client.sessionUpdate).
|
|
@@ -458,6 +494,7 @@ export function buildAcpSessionSnapshot(session) {
|
|
|
458
494
|
permissionEvents,
|
|
459
495
|
pendingPermissions: permissionEvents.filter((event) => event.status === 'pending'),
|
|
460
496
|
...(session.sessionInfo ? { sessionInfo: session.sessionInfo } : {}),
|
|
497
|
+
mcpServers: session.mcpServers ?? [],
|
|
461
498
|
};
|
|
462
499
|
}
|
|
463
500
|
function applySessionUpdate(session, update) {
|
|
@@ -477,6 +514,13 @@ function applySessionUpdate(session, update) {
|
|
|
477
514
|
}
|
|
478
515
|
if ((update.type === 'tool_call' || update.type === 'tool_call_update') && update.toolCall) {
|
|
479
516
|
session.toolCalls = upsertToolCall(session.toolCalls, update.toolCall);
|
|
517
|
+
recordArtifactsFromAcpToolCall({
|
|
518
|
+
runtimeId: session.agentId,
|
|
519
|
+
sessionId: session.id,
|
|
520
|
+
...(session.agentSessionId ? { externalSessionId: session.agentSessionId } : {}),
|
|
521
|
+
...(session.cwd ? { cwd: session.cwd } : {}),
|
|
522
|
+
toolCall: update.toolCall,
|
|
523
|
+
});
|
|
480
524
|
return;
|
|
481
525
|
}
|
|
482
526
|
if (update.type === 'session_info_update' && update.sessionInfo) {
|
|
@@ -516,13 +560,20 @@ function sdkNotificationToUpdate(sessionId, params) {
|
|
|
516
560
|
case 'tool_call':
|
|
517
561
|
case 'tool_call_update': {
|
|
518
562
|
const tc = update;
|
|
563
|
+
const rawOutputPointers = extractRawOutputPointers(tc.rawOutput ?? tc.raw_output);
|
|
564
|
+
const locations = [
|
|
565
|
+
...parseToolCallLocations(tc.locations),
|
|
566
|
+
...rawOutputPointers.locations,
|
|
567
|
+
];
|
|
519
568
|
base.toolCall = {
|
|
520
569
|
toolCallId: String(tc.toolCallId ?? ''),
|
|
521
570
|
title: typeof tc.title === 'string' ? tc.title : undefined,
|
|
522
571
|
status: tc.status ?? 'pending',
|
|
523
572
|
kind: tc.kind,
|
|
524
|
-
rawInput:
|
|
525
|
-
rawOutput:
|
|
573
|
+
rawInput: safeToolRawText(tc.rawInput),
|
|
574
|
+
rawOutput: safeToolRawText(tc.rawOutput ?? tc.raw_output),
|
|
575
|
+
content: parseToolCallContent(tc.content),
|
|
576
|
+
...(locations.length > 0 ? { locations } : {}),
|
|
526
577
|
};
|
|
527
578
|
break;
|
|
528
579
|
}
|
|
@@ -557,6 +608,110 @@ function sdkNotificationToUpdate(sessionId, params) {
|
|
|
557
608
|
}
|
|
558
609
|
return base;
|
|
559
610
|
}
|
|
611
|
+
function safeToolRawText(value) {
|
|
612
|
+
if (typeof value !== 'string')
|
|
613
|
+
return undefined;
|
|
614
|
+
const trimmed = value.trim();
|
|
615
|
+
if (trimmed.length > INLINE_IMAGE_RESULT_LIMIT
|
|
616
|
+
&& INLINE_IMAGE_PREFIX_RE.test(trimmed)) {
|
|
617
|
+
return undefined;
|
|
618
|
+
}
|
|
619
|
+
const redacted = redactSensitiveText(trimmed);
|
|
620
|
+
return redacted.length > TOOL_RAW_TEXT_LIMIT
|
|
621
|
+
? `${redacted.slice(0, TOOL_RAW_TEXT_LIMIT)}...`
|
|
622
|
+
: redacted;
|
|
623
|
+
}
|
|
624
|
+
function parseToolCallLocations(value) {
|
|
625
|
+
if (!Array.isArray(value))
|
|
626
|
+
return [];
|
|
627
|
+
const locations = [];
|
|
628
|
+
const seen = new Set();
|
|
629
|
+
for (const item of value) {
|
|
630
|
+
if (!item || typeof item !== 'object' || Array.isArray(item))
|
|
631
|
+
continue;
|
|
632
|
+
const record = item;
|
|
633
|
+
const rawPath = typeof record.path === 'string'
|
|
634
|
+
? record.path
|
|
635
|
+
: typeof record.uri === 'string' && record.uri.startsWith('file://')
|
|
636
|
+
? record.uri.slice('file://'.length)
|
|
637
|
+
: '';
|
|
638
|
+
const path = rawPath.trim();
|
|
639
|
+
if (!path)
|
|
640
|
+
continue;
|
|
641
|
+
const line = typeof record.line === 'number' && Number.isFinite(record.line)
|
|
642
|
+
? Math.max(1, Math.floor(record.line))
|
|
643
|
+
: undefined;
|
|
644
|
+
const key = `${path}:${line ?? ''}`;
|
|
645
|
+
if (seen.has(key))
|
|
646
|
+
continue;
|
|
647
|
+
seen.add(key);
|
|
648
|
+
locations.push({ path, ...(line ? { line } : {}) });
|
|
649
|
+
if (locations.length >= 50)
|
|
650
|
+
break;
|
|
651
|
+
}
|
|
652
|
+
return locations;
|
|
653
|
+
}
|
|
654
|
+
function parseToolCallContent(value) {
|
|
655
|
+
if (!Array.isArray(value))
|
|
656
|
+
return undefined;
|
|
657
|
+
const blocks = [];
|
|
658
|
+
for (const item of value) {
|
|
659
|
+
const block = parseToolCallContentBlock(item);
|
|
660
|
+
if (block)
|
|
661
|
+
blocks.push(block);
|
|
662
|
+
if (blocks.length >= 50)
|
|
663
|
+
break;
|
|
664
|
+
}
|
|
665
|
+
return blocks.length > 0 ? blocks : undefined;
|
|
666
|
+
}
|
|
667
|
+
function parseToolCallContentBlock(value) {
|
|
668
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
669
|
+
return null;
|
|
670
|
+
const record = value;
|
|
671
|
+
if (record.type === 'resource_link' && typeof record.uri === 'string') {
|
|
672
|
+
return {
|
|
673
|
+
type: 'resource_link',
|
|
674
|
+
uri: record.uri,
|
|
675
|
+
name: typeof record.name === 'string' && record.name.trim() ? record.name : 'resource',
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
if (record.type === 'resource') {
|
|
679
|
+
const resource = record.resource;
|
|
680
|
+
if (!resource || typeof resource !== 'object' || Array.isArray(resource))
|
|
681
|
+
return null;
|
|
682
|
+
const resourceRecord = resource;
|
|
683
|
+
if (typeof resourceRecord.uri !== 'string')
|
|
684
|
+
return null;
|
|
685
|
+
return {
|
|
686
|
+
type: 'resource',
|
|
687
|
+
resource: {
|
|
688
|
+
uri: resourceRecord.uri,
|
|
689
|
+
...(typeof resourceRecord.text === 'string' ? { text: safeToolRawText(resourceRecord.text) ?? '' } : {}),
|
|
690
|
+
},
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
return null;
|
|
694
|
+
}
|
|
695
|
+
function extractRawOutputPointers(value) {
|
|
696
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
697
|
+
return { locations: [] };
|
|
698
|
+
const record = value;
|
|
699
|
+
const candidates = [
|
|
700
|
+
record.saved_path,
|
|
701
|
+
record.savedPath,
|
|
702
|
+
readNestedString(record.image, 'path'),
|
|
703
|
+
readNestedString(record.artifact, 'path'),
|
|
704
|
+
];
|
|
705
|
+
const locations = candidates
|
|
706
|
+
.filter((candidate) => typeof candidate === 'string' && candidate.trim().length > 0)
|
|
707
|
+
.map((candidate) => ({ path: candidate.trim() }));
|
|
708
|
+
return { locations };
|
|
709
|
+
}
|
|
710
|
+
function readNestedString(value, key) {
|
|
711
|
+
return value && typeof value === 'object' && !Array.isArray(value) && typeof value[key] === 'string'
|
|
712
|
+
? value[key]
|
|
713
|
+
: undefined;
|
|
714
|
+
}
|
|
560
715
|
/* ── Internal — Parsers ───────────────────────────────────────────────── */
|
|
561
716
|
function parseAgentCapabilities(raw) {
|
|
562
717
|
if (!raw || typeof raw !== 'object')
|