@amalgm/chat 0.2.2 → 0.2.4
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/AGENTS.md +1 -0
- package/PURPOSE.md +44 -2
- package/README.md +10 -0
- package/dist/api/conversations.d.ts +7 -0
- package/dist/api/conversations.d.ts.map +1 -1
- package/dist/api/conversations.js +39 -1
- package/dist/api/conversations.js.map +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js.map +1 -1
- package/dist/execution/contract.d.ts +1 -1
- package/dist/execution/contract.d.ts.map +1 -1
- package/dist/execution/index.d.ts +2 -0
- package/dist/execution/index.d.ts.map +1 -1
- package/dist/execution/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +3 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +2 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +7 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +136 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/types.d.ts +17 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +2 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/normalizers/claude.d.ts +46 -46
- package/dist/normalizers/codex.d.ts +23 -23
- package/docs/contracts/capabilities-and-instructions.md +103 -0
- package/docs/contracts/conversation-persistence.md +3 -0
- package/docs/contracts/input-and-execution.md +8 -3
- package/host/adapters/acp-capabilities.js +32 -0
- package/host/adapters/acp.js +8 -12
- package/host/adapters/claude.js +3 -2
- package/host/adapters/codex.js +19 -6
- package/host/adapters/cursor.js +9 -15
- package/host/adapters/input-capabilities.js +1 -0
- package/host/adapters/opencode.js +4 -3
- package/host/adapters/pi.js +3 -2
- package/host/adapters/prompt.js +2 -3
- package/host/auth.js +1 -1
- package/host/http.d.ts +4 -0
- package/host/http.js +43 -0
- package/host/index.d.ts +45 -3
- package/host/index.js +3 -0
- package/host/native-contract.js +26 -4
- package/host/native-runtime.js +8 -0
- package/host/platform-egress.js +46 -25
- package/host/title-generator.js +110 -0
- package/host/tooling/mcp-bundle.js +107 -56
- package/host/tooling/system-prompt.js +7 -4
- package/package.json +6 -1
- package/skills/chat/SKILL.md +300 -89
- package/skills/chat/references/contracts.md +73 -47
|
@@ -235,29 +235,6 @@ export declare function createClaudeNormalizer(events: EventConstructors): {
|
|
|
235
235
|
method?: string | undefined;
|
|
236
236
|
payload?: unknown;
|
|
237
237
|
} | undefined;
|
|
238
|
-
} | {
|
|
239
|
-
ts: number;
|
|
240
|
-
type: "compaction.started";
|
|
241
|
-
trigger: "auto" | "manual" | "model_triggered";
|
|
242
|
-
providerSessionId?: string | null | undefined;
|
|
243
|
-
raw?: {
|
|
244
|
-
source: string;
|
|
245
|
-
method?: string | undefined;
|
|
246
|
-
payload?: unknown;
|
|
247
|
-
} | undefined;
|
|
248
|
-
} | {
|
|
249
|
-
ts: number;
|
|
250
|
-
type: "compaction.finished";
|
|
251
|
-
trigger: "auto" | "manual" | "model_triggered";
|
|
252
|
-
providerSessionId?: string | null | undefined;
|
|
253
|
-
raw?: {
|
|
254
|
-
source: string;
|
|
255
|
-
method?: string | undefined;
|
|
256
|
-
payload?: unknown;
|
|
257
|
-
} | undefined;
|
|
258
|
-
preTokens?: number | null | undefined;
|
|
259
|
-
postTokens?: number | null | undefined;
|
|
260
|
-
durationMs?: number | null | undefined;
|
|
261
238
|
} | {
|
|
262
239
|
ts: number;
|
|
263
240
|
type: "warning";
|
|
@@ -333,6 +310,29 @@ export declare function createClaudeNormalizer(events: EventConstructors): {
|
|
|
333
310
|
source: string;
|
|
334
311
|
exact: boolean;
|
|
335
312
|
} | undefined;
|
|
313
|
+
} | {
|
|
314
|
+
ts: number;
|
|
315
|
+
type: "compaction.started";
|
|
316
|
+
trigger: "auto" | "manual" | "model_triggered";
|
|
317
|
+
providerSessionId?: string | null | undefined;
|
|
318
|
+
raw?: {
|
|
319
|
+
source: string;
|
|
320
|
+
method?: string | undefined;
|
|
321
|
+
payload?: unknown;
|
|
322
|
+
} | undefined;
|
|
323
|
+
} | {
|
|
324
|
+
ts: number;
|
|
325
|
+
type: "compaction.finished";
|
|
326
|
+
trigger: "auto" | "manual" | "model_triggered";
|
|
327
|
+
providerSessionId?: string | null | undefined;
|
|
328
|
+
raw?: {
|
|
329
|
+
source: string;
|
|
330
|
+
method?: string | undefined;
|
|
331
|
+
payload?: unknown;
|
|
332
|
+
} | undefined;
|
|
333
|
+
preTokens?: number | null | undefined;
|
|
334
|
+
postTokens?: number | null | undefined;
|
|
335
|
+
durationMs?: number | null | undefined;
|
|
336
336
|
})[];
|
|
337
337
|
normalizeClaudeMessage: (message: AnyRecord | null | undefined, state?: ClaudeNormalizerState | null) => ({
|
|
338
338
|
ts: number;
|
|
@@ -514,29 +514,6 @@ export declare function createClaudeNormalizer(events: EventConstructors): {
|
|
|
514
514
|
method?: string | undefined;
|
|
515
515
|
payload?: unknown;
|
|
516
516
|
} | undefined;
|
|
517
|
-
} | {
|
|
518
|
-
ts: number;
|
|
519
|
-
type: "compaction.started";
|
|
520
|
-
trigger: "auto" | "manual" | "model_triggered";
|
|
521
|
-
providerSessionId?: string | null | undefined;
|
|
522
|
-
raw?: {
|
|
523
|
-
source: string;
|
|
524
|
-
method?: string | undefined;
|
|
525
|
-
payload?: unknown;
|
|
526
|
-
} | undefined;
|
|
527
|
-
} | {
|
|
528
|
-
ts: number;
|
|
529
|
-
type: "compaction.finished";
|
|
530
|
-
trigger: "auto" | "manual" | "model_triggered";
|
|
531
|
-
providerSessionId?: string | null | undefined;
|
|
532
|
-
raw?: {
|
|
533
|
-
source: string;
|
|
534
|
-
method?: string | undefined;
|
|
535
|
-
payload?: unknown;
|
|
536
|
-
} | undefined;
|
|
537
|
-
preTokens?: number | null | undefined;
|
|
538
|
-
postTokens?: number | null | undefined;
|
|
539
|
-
durationMs?: number | null | undefined;
|
|
540
517
|
} | {
|
|
541
518
|
ts: number;
|
|
542
519
|
type: "warning";
|
|
@@ -612,6 +589,29 @@ export declare function createClaudeNormalizer(events: EventConstructors): {
|
|
|
612
589
|
source: string;
|
|
613
590
|
exact: boolean;
|
|
614
591
|
} | undefined;
|
|
592
|
+
} | {
|
|
593
|
+
ts: number;
|
|
594
|
+
type: "compaction.started";
|
|
595
|
+
trigger: "auto" | "manual" | "model_triggered";
|
|
596
|
+
providerSessionId?: string | null | undefined;
|
|
597
|
+
raw?: {
|
|
598
|
+
source: string;
|
|
599
|
+
method?: string | undefined;
|
|
600
|
+
payload?: unknown;
|
|
601
|
+
} | undefined;
|
|
602
|
+
} | {
|
|
603
|
+
ts: number;
|
|
604
|
+
type: "compaction.finished";
|
|
605
|
+
trigger: "auto" | "manual" | "model_triggered";
|
|
606
|
+
providerSessionId?: string | null | undefined;
|
|
607
|
+
raw?: {
|
|
608
|
+
source: string;
|
|
609
|
+
method?: string | undefined;
|
|
610
|
+
payload?: unknown;
|
|
611
|
+
} | undefined;
|
|
612
|
+
preTokens?: number | null | undefined;
|
|
613
|
+
postTokens?: number | null | undefined;
|
|
614
|
+
durationMs?: number | null | undefined;
|
|
615
615
|
})[];
|
|
616
616
|
stableStringify: typeof stableStringify;
|
|
617
617
|
stringifyClaudeContent: typeof stringifyClaudeContent;
|
|
@@ -243,29 +243,6 @@ export declare function createCodexNormalizer(events: EventConstructors): {
|
|
|
243
243
|
method?: string | undefined;
|
|
244
244
|
payload?: unknown;
|
|
245
245
|
} | undefined;
|
|
246
|
-
} | {
|
|
247
|
-
ts: number;
|
|
248
|
-
type: "compaction.started";
|
|
249
|
-
trigger: "auto" | "manual" | "model_triggered";
|
|
250
|
-
providerSessionId?: string | null | undefined;
|
|
251
|
-
raw?: {
|
|
252
|
-
source: string;
|
|
253
|
-
method?: string | undefined;
|
|
254
|
-
payload?: unknown;
|
|
255
|
-
} | undefined;
|
|
256
|
-
} | {
|
|
257
|
-
ts: number;
|
|
258
|
-
type: "compaction.finished";
|
|
259
|
-
trigger: "auto" | "manual" | "model_triggered";
|
|
260
|
-
providerSessionId?: string | null | undefined;
|
|
261
|
-
raw?: {
|
|
262
|
-
source: string;
|
|
263
|
-
method?: string | undefined;
|
|
264
|
-
payload?: unknown;
|
|
265
|
-
} | undefined;
|
|
266
|
-
preTokens?: number | null | undefined;
|
|
267
|
-
postTokens?: number | null | undefined;
|
|
268
|
-
durationMs?: number | null | undefined;
|
|
269
246
|
} | {
|
|
270
247
|
ts: number;
|
|
271
248
|
type: "warning";
|
|
@@ -341,6 +318,29 @@ export declare function createCodexNormalizer(events: EventConstructors): {
|
|
|
341
318
|
source: string;
|
|
342
319
|
exact: boolean;
|
|
343
320
|
} | undefined;
|
|
321
|
+
} | {
|
|
322
|
+
ts: number;
|
|
323
|
+
type: "compaction.started";
|
|
324
|
+
trigger: "auto" | "manual" | "model_triggered";
|
|
325
|
+
providerSessionId?: string | null | undefined;
|
|
326
|
+
raw?: {
|
|
327
|
+
source: string;
|
|
328
|
+
method?: string | undefined;
|
|
329
|
+
payload?: unknown;
|
|
330
|
+
} | undefined;
|
|
331
|
+
} | {
|
|
332
|
+
ts: number;
|
|
333
|
+
type: "compaction.finished";
|
|
334
|
+
trigger: "auto" | "manual" | "model_triggered";
|
|
335
|
+
providerSessionId?: string | null | undefined;
|
|
336
|
+
raw?: {
|
|
337
|
+
source: string;
|
|
338
|
+
method?: string | undefined;
|
|
339
|
+
payload?: unknown;
|
|
340
|
+
} | undefined;
|
|
341
|
+
preTokens?: number | null | undefined;
|
|
342
|
+
postTokens?: number | null | undefined;
|
|
343
|
+
durationMs?: number | null | undefined;
|
|
344
344
|
})[];
|
|
345
345
|
};
|
|
346
346
|
/** The Codex normalizer set, closed over injected constructors. */
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Capabilities and instructions
|
|
2
|
+
|
|
3
|
+
This contract defines the two session inputs that must remain equivalent when
|
|
4
|
+
an Amalgm conversation switches among native and ACP agents: callable
|
|
5
|
+
capabilities and system instructions.
|
|
6
|
+
|
|
7
|
+
## Purpose
|
|
8
|
+
|
|
9
|
+
A host should prepare one agent session without knowing which product supplied
|
|
10
|
+
a capability or teaching each caller provider-specific system-prompt fields.
|
|
11
|
+
Tools, Agents, Chat, and third-party integrations therefore enter through the
|
|
12
|
+
same capability boundary, while every instruction source is composed once and
|
|
13
|
+
applied at its real privilege level.
|
|
14
|
+
|
|
15
|
+
## Capability injection
|
|
16
|
+
|
|
17
|
+
ACP v1 standardizes tool injection as `mcpServers: McpServer[]` on
|
|
18
|
+
`session/new`, `session/load`, and `session/resume`. Chat imports the official
|
|
19
|
+
`McpServer` union from `@agentclientprotocol/sdk`; it does not maintain an
|
|
20
|
+
Amalgm copy.
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
immutable Toolbox selection
|
|
24
|
+
-> host resolves official ACP McpServer[]
|
|
25
|
+
-> prepared Chat binding
|
|
26
|
+
-> native adapter transport projection
|
|
27
|
+
-> agent session
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
The selected list is complete. Chat adds no ambient server, and an adapter may
|
|
31
|
+
not discover, drop, rename, or broaden it silently. A transport the selected
|
|
32
|
+
agent did not advertise is a typed preparation/session-admission error.
|
|
33
|
+
Chat currently admits ACP's stable stdio, HTTP, and SSE variants. The
|
|
34
|
+
experimental ACP-channel transport is rejected until Chat owns the matching
|
|
35
|
+
`mcp/connect`, `mcp/message`, and `mcp/disconnect` lifecycle.
|
|
36
|
+
|
|
37
|
+
An Amalgm product is a platform capability because its MCP server is supplied
|
|
38
|
+
by the authenticated host and its actions are selected from Toolbox. It is not
|
|
39
|
+
a new protocol primitive. The Tools, Agents, and Chat MCP servers use the same
|
|
40
|
+
ACP injection path as any other selected server. Product identity and display
|
|
41
|
+
metadata may use namespaced `_meta`; metadata never grants authority.
|
|
42
|
+
|
|
43
|
+
SDKs own the behavior behind those servers. MCP, HTTP API, CLI, and Skill
|
|
44
|
+
surfaces are adapters over the corresponding public SDK and may not grow a
|
|
45
|
+
second implementation.
|
|
46
|
+
|
|
47
|
+
## Instruction injection
|
|
48
|
+
|
|
49
|
+
Instruction sources resolve during Chat preparation into one immutable bundle:
|
|
50
|
+
|
|
51
|
+
1. machine-level user instructions;
|
|
52
|
+
2. prepared project/workspace context;
|
|
53
|
+
3. the exact immutable Agent revision instructions.
|
|
54
|
+
|
|
55
|
+
The resulting text and its digest are host-only prepared facts. Starting,
|
|
56
|
+
resuming, and prompting consume them without rereading files or rediscovering
|
|
57
|
+
an Agent revision. Native adapters translate the exact text into their genuine
|
|
58
|
+
system or developer-instruction field.
|
|
59
|
+
|
|
60
|
+
Stable ACP v1 deliberately has no arbitrary system-prompt field. Amalgm uses
|
|
61
|
+
ACP's official extensibility mechanism for agents that opt in:
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
"agentCapabilities": {
|
|
66
|
+
"_meta": {
|
|
67
|
+
"amalgm.dev": { "sessionInstructions": true }
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
For an advertising agent, Chat attaches the prepared bundle to the lifecycle
|
|
74
|
+
request (`session/new`, `session/load`, or `session/resume`):
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"_meta": {
|
|
79
|
+
"amalgm.dev": {
|
|
80
|
+
"sessionInstructions": {
|
|
81
|
+
"revisionId": "sha256 digest",
|
|
82
|
+
"text": "prepared instructions"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
An ACP agent that does not advertise the extension is admitted only when the
|
|
90
|
+
prepared instruction text is empty. Instructions are never represented as a
|
|
91
|
+
text block in `session/prompt`; doing so would turn privileged configuration
|
|
92
|
+
into user-authored conversation content and corrupt transcript semantics.
|
|
93
|
+
|
|
94
|
+
## Predictable behavior
|
|
95
|
+
|
|
96
|
+
Changing a Toolbox selection or immutable Agent revision creates a different
|
|
97
|
+
prepared binding. Machine and project instruction changes must likewise enter
|
|
98
|
+
preparation through a new execution revision before they affect a new session;
|
|
99
|
+
wiring that source revision through the control plane remains follow-up work.
|
|
100
|
+
An already-prepared session retains the exact MCP servers and instructions it
|
|
101
|
+
was given. Reconnect or resume reapplies the same lifecycle inputs. Switching
|
|
102
|
+
adapters can change only the native projection, never the selected capability
|
|
103
|
+
set, instruction text, ACP output grammar, or SDK ownership boundary.
|
|
@@ -44,6 +44,9 @@ database.
|
|
|
44
44
|
moves logical records and immutable batches, never a live SQLite file.
|
|
45
45
|
12. Catalog, history, title, seen-state, replay, and archival read the durable
|
|
46
46
|
store directly. They never start or resume a provider session.
|
|
47
|
+
13. The HTTP client reports turn acceptance only after the host has committed
|
|
48
|
+
the running turn. A surface may advance durable navigation at that point;
|
|
49
|
+
an unsuccessful request never reports acceptance.
|
|
47
50
|
|
|
48
51
|
The canonical application projection uses camelCase `ConversationRecord`,
|
|
49
52
|
`ConversationMessage`, and `ConversationTurn` values from this package.
|
|
@@ -34,9 +34,10 @@ discovery and resolution; start and send consume its result.
|
|
|
34
34
|
defaults or fallback auth modes.
|
|
35
35
|
4. A model is identified by `(agent revision, provider id, model id)`. Model
|
|
36
36
|
settings are ACP session-config selections scoped inside that model choice.
|
|
37
|
-
5. Ordinary tools and MCP tools are selected through one immutable
|
|
38
|
-
revision. `amalgm-tools` resolves that
|
|
39
|
-
|
|
37
|
+
5. Ordinary tools and MCP tools are selected through one immutable deployment-
|
|
38
|
+
head revision, never a local SQLite sequence. `amalgm-tools` resolves that
|
|
39
|
+
exact revision to the complete official ACP `McpServer[]` configuration
|
|
40
|
+
during preparation; Chat adds no ambient server or latest-version fallback.
|
|
40
41
|
6. Secrets are not execution-contract values. Auth names an opaque binding; the
|
|
41
42
|
authorized host resolves secrets into the opaque prepared binding.
|
|
42
43
|
7. A cwd is an absolute, already-materialized path on the selected computer. A
|
|
@@ -57,6 +58,10 @@ discovery and resolution; start and send consume its result.
|
|
|
57
58
|
before prompting. No adapter may silently ignore an attachment, auth mode,
|
|
58
59
|
tool, permission mode, model setting, provider/model choice, cwd, agent
|
|
59
60
|
revision, or computer placement.
|
|
61
|
+
13. Machine, project, and exact Agent-revision instructions compose once during
|
|
62
|
+
preparation. They are not prompt parts. Native adapters use a real
|
|
63
|
+
system/developer channel; ACP agents must advertise the `amalgm.dev`
|
|
64
|
+
session-instructions extension.
|
|
60
65
|
|
|
61
66
|
## Public path
|
|
62
67
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { UnsupportedExecutionInputError } from './input-capabilities.js';
|
|
2
2
|
|
|
3
|
+
export const AMALGM_ACP_META_KEY = 'amalgm.dev';
|
|
4
|
+
|
|
3
5
|
/** Validate optional ACP inputs against the capabilities negotiated at initialize. */
|
|
4
6
|
export function assertAcpMcpCapabilities(adapterId, capabilities, servers) {
|
|
5
7
|
const mcp = capabilities?.mcpCapabilities || {};
|
|
@@ -28,3 +30,33 @@ export function assertAcpPromptCapabilities(adapterId, capabilities, prompt) {
|
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* ACP v1 has no system-prompt field. Apply instructions only through the
|
|
36
|
+
* advertised Amalgm lifecycle extension; never turn them into prompt content.
|
|
37
|
+
*/
|
|
38
|
+
export function acpSessionParams(adapterId, capabilities, contract, mcpServers) {
|
|
39
|
+
const instructions = contract?.instructions || { text: '', revisionId: null };
|
|
40
|
+
const text = String(instructions.text || '').trim();
|
|
41
|
+
if (!text) return { cwd: contract.cwd, mcpServers };
|
|
42
|
+
const extension = capabilities?._meta?.[AMALGM_ACP_META_KEY];
|
|
43
|
+
if (extension?.sessionInstructions !== true) {
|
|
44
|
+
throw new UnsupportedExecutionInputError(
|
|
45
|
+
adapterId,
|
|
46
|
+
'instructions',
|
|
47
|
+
`agent does not advertise the ACP ${AMALGM_ACP_META_KEY} sessionInstructions extension`,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
cwd: contract.cwd,
|
|
52
|
+
mcpServers,
|
|
53
|
+
_meta: {
|
|
54
|
+
[AMALGM_ACP_META_KEY]: {
|
|
55
|
+
sessionInstructions: {
|
|
56
|
+
revisionId: instructions.revisionId,
|
|
57
|
+
text,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
}
|
package/host/adapters/acp.js
CHANGED
|
@@ -3,10 +3,13 @@
|
|
|
3
3
|
import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk';
|
|
4
4
|
import { toAcpMcpServers } from '../tooling/mcp-bundle.js';
|
|
5
5
|
import { prepareHarnessRuntime } from '../tooling/runtime-home.js';
|
|
6
|
-
import { composeSystemPrompt } from '../tooling/system-prompt.js';
|
|
7
6
|
import { requestPermission } from '../permissions.js';
|
|
8
7
|
import { AcpClient } from './acp-client.js';
|
|
9
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
acpSessionParams,
|
|
10
|
+
assertAcpMcpCapabilities,
|
|
11
|
+
assertAcpPromptCapabilities,
|
|
12
|
+
} from './acp-capabilities.js';
|
|
10
13
|
import { nativeInputCapabilities, UnsupportedExecutionInputError } from './input-capabilities.js';
|
|
11
14
|
import { acpPromptParts } from './prompt.js';
|
|
12
15
|
|
|
@@ -125,6 +128,7 @@ export class AcpAdapter {
|
|
|
125
128
|
authModes: ['platform', 'subscription', 'byok'],
|
|
126
129
|
modelSettings: 'negotiated',
|
|
127
130
|
tools: true,
|
|
131
|
+
instructions: 'acp_extension',
|
|
128
132
|
});
|
|
129
133
|
}
|
|
130
134
|
|
|
@@ -149,7 +153,6 @@ export class AcpAdapter {
|
|
|
149
153
|
client,
|
|
150
154
|
capabilities: {},
|
|
151
155
|
permissionMode: contract.permissionMode,
|
|
152
|
-
needsSystemPrompt: false,
|
|
153
156
|
activePrompt: false,
|
|
154
157
|
};
|
|
155
158
|
client.onRequest((method, params) => this.handleRequest(session, method, params));
|
|
@@ -170,7 +173,7 @@ export class AcpAdapter {
|
|
|
170
173
|
|
|
171
174
|
const mcpServers = toAcpMcpServers(contract);
|
|
172
175
|
assertAcpMcpCapabilities('acp', session.capabilities, mcpServers);
|
|
173
|
-
const sessionParams =
|
|
176
|
+
const sessionParams = acpSessionParams('acp', session.capabilities, contract, mcpServers);
|
|
174
177
|
let response;
|
|
175
178
|
if (session.providerSessionId) {
|
|
176
179
|
if (session.capabilities.loadSession === true) {
|
|
@@ -189,7 +192,6 @@ export class AcpAdapter {
|
|
|
189
192
|
} else {
|
|
190
193
|
response = await client.request('session/new', sessionParams, 600000);
|
|
191
194
|
session.providerSessionId = response?.sessionId || null;
|
|
192
|
-
session.needsSystemPrompt = true;
|
|
193
195
|
}
|
|
194
196
|
if (!session.providerSessionId) throw new Error('ACP agent did not return a sessionId');
|
|
195
197
|
await applyConfiguration(client, session.providerSessionId, response, contract, launch);
|
|
@@ -244,16 +246,10 @@ export class AcpAdapter {
|
|
|
244
246
|
if (message.params?.update) queue.push(message.params.update);
|
|
245
247
|
wakeLoop();
|
|
246
248
|
});
|
|
247
|
-
let preamble = '';
|
|
248
|
-
if (session.needsSystemPrompt) {
|
|
249
|
-
const systemPrompt = composeSystemPrompt(contract);
|
|
250
|
-
if (systemPrompt) preamble = `<system-instructions>\n${systemPrompt}\n</system-instructions>`;
|
|
251
|
-
session.needsSystemPrompt = false;
|
|
252
|
-
}
|
|
253
249
|
session.activePrompt = true;
|
|
254
250
|
session.client.request('session/prompt', {
|
|
255
251
|
sessionId: session.providerSessionId,
|
|
256
|
-
prompt: acpPromptParts(prompt
|
|
252
|
+
prompt: acpPromptParts(prompt),
|
|
257
253
|
}, 0).then(() => {
|
|
258
254
|
finished = true;
|
|
259
255
|
wakeLoop();
|
package/host/adapters/claude.js
CHANGED
|
@@ -21,7 +21,7 @@ import { toClaudeMcpServers } from '../tooling/mcp-bundle.js';
|
|
|
21
21
|
import { bundledClaudeBinary } from '../tooling/native-binaries.js';
|
|
22
22
|
import { importPackage } from '../tooling/package-import.js';
|
|
23
23
|
import { prepareHarnessRuntime } from '../tooling/runtime-home.js';
|
|
24
|
-
import {
|
|
24
|
+
import { preparedSystemPrompt } from '../tooling/system-prompt.js';
|
|
25
25
|
import { allowed, requestPermission } from '../permissions.js';
|
|
26
26
|
import {
|
|
27
27
|
COMMON_REASONING_SETTINGS,
|
|
@@ -55,6 +55,7 @@ class ClaudeAdapter {
|
|
|
55
55
|
authModes: ['platform', 'subscription', 'byok'],
|
|
56
56
|
modelSettings: [...COMMON_REASONING_SETTINGS, ...COMMON_SPEED_SETTINGS],
|
|
57
57
|
tools: true,
|
|
58
|
+
instructions: 'native',
|
|
58
59
|
});
|
|
59
60
|
}
|
|
60
61
|
|
|
@@ -70,7 +71,7 @@ class ClaudeAdapter {
|
|
|
70
71
|
|
|
71
72
|
options(contract, extra = {}) {
|
|
72
73
|
const runtime = prepareHarnessRuntime(contract);
|
|
73
|
-
const systemPrompt =
|
|
74
|
+
const systemPrompt = preparedSystemPrompt(contract);
|
|
74
75
|
const pathToClaudeCodeExecutable = process.env.CLAUDE_CODE_BINARY || bundledClaudeBinary();
|
|
75
76
|
const settings = {
|
|
76
77
|
...this.renderers.toClaudeSettings(contract.agentConfig),
|
package/host/adapters/codex.js
CHANGED
|
@@ -17,11 +17,11 @@ import path from 'node:path';
|
|
|
17
17
|
import { createEventConstructors } from '../../dist/events/index.js';
|
|
18
18
|
import { codexErrorMessage, createCodexNormalizer } from '../../dist/normalizers/codex.js';
|
|
19
19
|
import { recordNativeEvent } from '../recorder.js';
|
|
20
|
-
import { relayedMcpServers, toCodexMcpToml } from '../tooling/mcp-bundle.js';
|
|
20
|
+
import { codexMcpSectionName, relayedMcpServers, toCodexMcpToml } from '../tooling/mcp-bundle.js';
|
|
21
21
|
import { bundledCodexBinary, bundledCodexPathDirs, executableExists, findOnPath } from '../tooling/native-binaries.js';
|
|
22
22
|
import { syncCodexProviderAuth } from '../tooling/native-config.js';
|
|
23
23
|
import { prepareHarnessRuntime } from '../tooling/runtime-home.js';
|
|
24
|
-
import {
|
|
24
|
+
import { preparedSystemPrompt } from '../tooling/system-prompt.js';
|
|
25
25
|
import { requestPermission } from '../permissions.js';
|
|
26
26
|
import {
|
|
27
27
|
COMMON_REASONING_SETTINGS,
|
|
@@ -447,7 +447,7 @@ function generatedCodexHookTrust(contract, renderers = defaultRenderers) {
|
|
|
447
447
|
}
|
|
448
448
|
|
|
449
449
|
function generatedMcpSectionNames(contract) {
|
|
450
|
-
return relayedMcpServers(contract).map((server) =>
|
|
450
|
+
return relayedMcpServers(contract).map((server) => codexMcpSectionName(server.name));
|
|
451
451
|
}
|
|
452
452
|
|
|
453
453
|
function buildCodexConfig(contract, existingConfig, syncInfo, renderers = defaultRenderers) {
|
|
@@ -524,6 +524,7 @@ class CodexAdapter {
|
|
|
524
524
|
authModes: ['platform', 'subscription', 'byok'],
|
|
525
525
|
modelSettings: [...COMMON_REASONING_SETTINGS, ...COMMON_SPEED_SETTINGS],
|
|
526
526
|
tools: true,
|
|
527
|
+
instructions: 'native',
|
|
527
528
|
});
|
|
528
529
|
}
|
|
529
530
|
|
|
@@ -541,7 +542,7 @@ class CodexAdapter {
|
|
|
541
542
|
sandbox: fullAccess ? 'danger-full-access' : 'workspace-write',
|
|
542
543
|
modelProvider: contract.authMethod === 'amalgm' ? 'amalgm' : 'openai',
|
|
543
544
|
serviceTier: serviceTierForContract(contract),
|
|
544
|
-
developerInstructions:
|
|
545
|
+
developerInstructions: preparedSystemPrompt(contract) || null,
|
|
545
546
|
persistExtendedHistory: true,
|
|
546
547
|
};
|
|
547
548
|
const session = {
|
|
@@ -571,6 +572,7 @@ class CodexAdapter {
|
|
|
571
572
|
'item/commandExecution/requestApproval',
|
|
572
573
|
'item/fileChange/requestApproval',
|
|
573
574
|
'item/permissions/requestApproval',
|
|
575
|
+
'mcpServer/elicitation/request',
|
|
574
576
|
'execCommandApproval',
|
|
575
577
|
'applyPatchApproval',
|
|
576
578
|
]);
|
|
@@ -580,8 +582,12 @@ class CodexAdapter {
|
|
|
580
582
|
: await requestPermission(this.permissionPort, {
|
|
581
583
|
adapterId: 'codex',
|
|
582
584
|
providerSessionId: session.providerSessionId,
|
|
583
|
-
kind: method
|
|
584
|
-
|
|
585
|
+
kind: method === 'mcpServer/elicitation/request'
|
|
586
|
+
? 'mcp_tool'
|
|
587
|
+
: method.includes('fileChange') || method === 'applyPatchApproval'
|
|
588
|
+
? 'file_change'
|
|
589
|
+
: 'command',
|
|
590
|
+
title: params.message || params.reason || params.command || 'Codex requests permission',
|
|
585
591
|
input: params,
|
|
586
592
|
});
|
|
587
593
|
const allow = decision.outcome === 'allow_once' || decision.outcome === 'allow_always';
|
|
@@ -603,6 +609,13 @@ class CodexAdapter {
|
|
|
603
609
|
scope: always ? 'session' : 'turn',
|
|
604
610
|
};
|
|
605
611
|
}
|
|
612
|
+
if (method === 'mcpServer/elicitation/request') {
|
|
613
|
+
return {
|
|
614
|
+
action: allow ? 'accept' : decision.outcome === 'cancel' ? 'cancel' : 'decline',
|
|
615
|
+
content: allow ? decision.updatedInput || null : null,
|
|
616
|
+
_meta: null,
|
|
617
|
+
};
|
|
618
|
+
}
|
|
606
619
|
return {
|
|
607
620
|
decision: allow
|
|
608
621
|
? (always ? 'approved_for_session' : 'approved')
|
package/host/adapters/cursor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Cursor Agent Client Protocol adapter. The generic ACP transport lives in
|
|
2
2
|
// ./acp-client.js; this file is the
|
|
3
3
|
// cursor parameterization (binary resolution, model translation, permission
|
|
4
|
-
//
|
|
4
|
+
// handling, and ACP lifecycle inputs).
|
|
5
5
|
//
|
|
6
6
|
// Laws come from ../../dist: event constructors via `createEventConstructors`,
|
|
7
7
|
// the normalizer via `createCursorNormalizer`, `cursorStopReason`, and
|
|
@@ -16,10 +16,13 @@ import { recordNativeEvent } from '../recorder.js';
|
|
|
16
16
|
import { toAcpMcpServers } from '../tooling/mcp-bundle.js';
|
|
17
17
|
import { executableExists, findOnPath } from '../tooling/native-binaries.js';
|
|
18
18
|
import { prepareHarnessRuntime } from '../tooling/runtime-home.js';
|
|
19
|
-
import { composeSystemPrompt } from '../tooling/system-prompt.js';
|
|
20
19
|
import { requestPermission } from '../permissions.js';
|
|
21
20
|
import { AcpClient } from './acp-client.js';
|
|
22
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
acpSessionParams,
|
|
23
|
+
assertAcpMcpCapabilities,
|
|
24
|
+
assertAcpPromptCapabilities,
|
|
25
|
+
} from './acp-capabilities.js';
|
|
23
26
|
import {
|
|
24
27
|
COMMON_REASONING_SETTINGS,
|
|
25
28
|
COMMON_SPEED_SETTINGS,
|
|
@@ -140,6 +143,7 @@ class CursorAdapter {
|
|
|
140
143
|
authModes: ['subscription', 'byok'],
|
|
141
144
|
modelSettings: [...COMMON_REASONING_SETTINGS, ...COMMON_SPEED_SETTINGS],
|
|
142
145
|
tools: true,
|
|
146
|
+
instructions: 'acp_extension',
|
|
143
147
|
});
|
|
144
148
|
}
|
|
145
149
|
|
|
@@ -157,7 +161,6 @@ class CursorAdapter {
|
|
|
157
161
|
sessionId: contract.sessionId,
|
|
158
162
|
providerSessionId: contract.providerSessionId || null,
|
|
159
163
|
client,
|
|
160
|
-
needsSystemPrompt: false,
|
|
161
164
|
modelWarning: null,
|
|
162
165
|
activePrompt: null,
|
|
163
166
|
cancelRequested: false,
|
|
@@ -173,7 +176,7 @@ class CursorAdapter {
|
|
|
173
176
|
session.capabilities = initialized?.agentCapabilities || {};
|
|
174
177
|
const mcpServers = toAcpMcpServers(contract);
|
|
175
178
|
assertAcpMcpCapabilities('cursor', session.capabilities, mcpServers);
|
|
176
|
-
const sessionParams =
|
|
179
|
+
const sessionParams = acpSessionParams('cursor', session.capabilities, contract, mcpServers);
|
|
177
180
|
let acpSession = null;
|
|
178
181
|
if (session.providerSessionId) {
|
|
179
182
|
// session/load replays history as session/update notifications; nothing is
|
|
@@ -189,7 +192,6 @@ class CursorAdapter {
|
|
|
189
192
|
if (!acpSession) {
|
|
190
193
|
acpSession = await client.request('session/new', sessionParams);
|
|
191
194
|
session.providerSessionId = acpSession.sessionId;
|
|
192
|
-
session.needsSystemPrompt = true;
|
|
193
195
|
}
|
|
194
196
|
await this.selectModel(session, acpSession, contract);
|
|
195
197
|
return session;
|
|
@@ -296,17 +298,9 @@ class CursorAdapter {
|
|
|
296
298
|
});
|
|
297
299
|
for (const e of normalizeCursorUpdate(params.update || {}, state)) push(e);
|
|
298
300
|
});
|
|
299
|
-
let preamble = '';
|
|
300
|
-
if (session.needsSystemPrompt) {
|
|
301
|
-
// ACP has no system-prompt slot; a fresh native session gets the composed
|
|
302
|
-
// instructions as a preamble on its first prompt only.
|
|
303
|
-
const systemPrompt = composeSystemPrompt(contract);
|
|
304
|
-
if (systemPrompt) preamble = `<system-instructions>\n${systemPrompt}\n</system-instructions>`;
|
|
305
|
-
session.needsSystemPrompt = false;
|
|
306
|
-
}
|
|
307
301
|
session.client.request('session/prompt', {
|
|
308
302
|
sessionId: session.providerSessionId,
|
|
309
|
-
prompt: acpPromptParts(input
|
|
303
|
+
prompt: acpPromptParts(input),
|
|
310
304
|
}, 0).then((result) => {
|
|
311
305
|
recordNativeEvent('cursor.acp.prompt_result', result, {
|
|
312
306
|
providerSessionId: session.providerSessionId,
|
|
@@ -29,6 +29,7 @@ export function nativeInputCapabilities(input = {}) {
|
|
|
29
29
|
? 'negotiated'
|
|
30
30
|
: Object.freeze([...(input.modelSettings || [])]),
|
|
31
31
|
tools: input.tools === true,
|
|
32
|
+
instructions: input.instructions || 'unsupported',
|
|
32
33
|
permissionModes: Object.freeze([...(input.permissionModes || ['ask', 'full_access'])]),
|
|
33
34
|
});
|
|
34
35
|
}
|
|
@@ -12,7 +12,7 @@ import { toOpenCodeMcpConfig } from '../tooling/mcp-bundle.js';
|
|
|
12
12
|
import { bundledOpenCodeBinary, executableExists, findOnPath } from '../tooling/native-binaries.js';
|
|
13
13
|
import { importPackage } from '../tooling/package-import.js';
|
|
14
14
|
import { prepareHarnessRuntime } from '../tooling/runtime-home.js';
|
|
15
|
-
import {
|
|
15
|
+
import { preparedSystemPrompt } from '../tooling/system-prompt.js';
|
|
16
16
|
import { requestPermission } from '../permissions.js';
|
|
17
17
|
import { nativeInputCapabilities, UnsupportedExecutionInputError } from './input-capabilities.js';
|
|
18
18
|
import { openCodePromptParts } from './prompt.js';
|
|
@@ -58,7 +58,7 @@ function selectedVariant(contract) {
|
|
|
58
58
|
function configFor(contract) {
|
|
59
59
|
const model = splitModel(contract.cliModel || contract.usageModelId, contract.auth);
|
|
60
60
|
const variant = selectedVariant(contract);
|
|
61
|
-
const systemPrompt =
|
|
61
|
+
const systemPrompt = preparedSystemPrompt(contract);
|
|
62
62
|
const permission = contract.permissionMode === 'full_access' ? 'allow' : 'ask';
|
|
63
63
|
const config = {
|
|
64
64
|
logLevel: process.env.OPENCODE_LOG_LEVEL || 'ERROR',
|
|
@@ -241,6 +241,7 @@ class OpenCodeAdapter {
|
|
|
241
241
|
authModes: ['platform', 'subscription', 'byok'],
|
|
242
242
|
modelSettings: ['variant'],
|
|
243
243
|
tools: true,
|
|
244
|
+
instructions: 'native',
|
|
244
245
|
});
|
|
245
246
|
}
|
|
246
247
|
|
|
@@ -423,7 +424,7 @@ class OpenCodeAdapter {
|
|
|
423
424
|
model,
|
|
424
425
|
...(variant ? { variant } : {}),
|
|
425
426
|
agent: process.env.AMALGM_CHAT_OPENCODE_AGENT || 'build',
|
|
426
|
-
system:
|
|
427
|
+
system: preparedSystemPrompt(contract) || undefined,
|
|
427
428
|
parts: openCodePromptParts(input),
|
|
428
429
|
},
|
|
429
430
|
});
|
package/host/adapters/pi.js
CHANGED
|
@@ -15,7 +15,7 @@ import { recordNativeEvent } from '../recorder.js';
|
|
|
15
15
|
import { relayedMcpServers } from '../tooling/mcp-bundle.js';
|
|
16
16
|
import { executableExists, findOnPath } from '../tooling/native-binaries.js';
|
|
17
17
|
import { prepareHarnessRuntime } from '../tooling/runtime-home.js';
|
|
18
|
-
import {
|
|
18
|
+
import { preparedSystemPrompt } from '../tooling/system-prompt.js';
|
|
19
19
|
import {
|
|
20
20
|
COMMON_REASONING_SETTINGS,
|
|
21
21
|
nativeInputCapabilities,
|
|
@@ -344,7 +344,7 @@ function buildArgs(contract, runtimeHome) {
|
|
|
344
344
|
const args = ['--mode', 'rpc', '--provider', provider, '--model', piModel(contract, provider)];
|
|
345
345
|
const thinking = thinkingLevelFor(contract);
|
|
346
346
|
if (thinking) args.push('--thinking', thinking);
|
|
347
|
-
const systemPrompt =
|
|
347
|
+
const systemPrompt = preparedSystemPrompt(contract);
|
|
348
348
|
if (systemPrompt) args.push('--system-prompt', systemPrompt);
|
|
349
349
|
if (contract.providerSessionId) args.push('--session', contract.providerSessionId);
|
|
350
350
|
if (contract.authMethod === 'amalgm') args.push('--extension', ensureEgressExtension(runtimeHome));
|
|
@@ -362,6 +362,7 @@ class PiAdapter {
|
|
|
362
362
|
authModes: ['platform', 'subscription', 'byok'],
|
|
363
363
|
modelSettings: COMMON_REASONING_SETTINGS,
|
|
364
364
|
tools: true,
|
|
365
|
+
instructions: 'native',
|
|
365
366
|
});
|
|
366
367
|
}
|
|
367
368
|
|