@agentclientprotocol/claude-agent-acp 0.81.3-preview.1 → 0.82.0
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 +8 -5
- package/dist/acp-agent.d.ts +31 -37
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +546 -534
- package/dist/acp-subagents.d.ts +6 -0
- package/dist/acp-subagents.d.ts.map +1 -1
- package/dist/air-extension.d.ts +31 -1
- package/dist/air-extension.d.ts.map +1 -1
- package/dist/air-extension.js +35 -1
- package/dist/async-tasks.d.ts +39 -2
- package/dist/async-tasks.d.ts.map +1 -1
- package/dist/async-tasks.js +147 -44
- package/dist/context-compaction-meta.d.ts +6 -5
- package/dist/context-compaction-meta.d.ts.map +1 -1
- package/dist/context-compaction-meta.js +10 -10
- package/dist/context-compaction.d.ts +3 -0
- package/dist/context-compaction.d.ts.map +1 -1
- package/dist/context-compaction.js +23 -57
- package/dist/diff.d.ts +73 -5
- package/dist/diff.d.ts.map +1 -1
- package/dist/diff.js +435 -64
- package/dist/elicitation.d.ts +1 -1
- package/dist/elicitation.d.ts.map +1 -1
- package/dist/elicitation.js +12 -14
- package/dist/native-subagents.d.ts +58 -0
- package/dist/native-subagents.d.ts.map +1 -1
- package/dist/native-subagents.js +186 -34
- package/dist/paths.d.ts +3 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +6 -0
- package/dist/permissions/presentation.d.ts +13 -2
- package/dist/permissions/presentation.d.ts.map +1 -1
- package/dist/permissions/presentation.js +49 -44
- package/dist/resumed-session.d.ts +11 -0
- package/dist/resumed-session.d.ts.map +1 -1
- package/dist/resumed-session.js +106 -4
- package/dist/session-mode.d.ts +2 -0
- package/dist/session-mode.d.ts.map +1 -1
- package/dist/session-mode.js +12 -5
- package/dist/settings.js +2 -2
- package/dist/subagent-history.d.ts +20 -0
- package/dist/subagent-history.d.ts.map +1 -0
- package/dist/subagent-history.js +46 -0
- package/dist/tool-calls/background.d.ts +20 -0
- package/dist/tool-calls/background.d.ts.map +1 -0
- package/dist/tool-calls/background.js +41 -0
- package/dist/tool-calls/changed-meta-filter.d.ts +27 -0
- package/dist/tool-calls/changed-meta-filter.d.ts.map +1 -0
- package/dist/tool-calls/changed-meta-filter.js +102 -0
- package/dist/tool-calls/client-capabilities.d.ts +51 -0
- package/dist/tool-calls/client-capabilities.d.ts.map +1 -0
- package/dist/tool-calls/client-capabilities.js +43 -0
- package/dist/tool-calls/content.d.ts +59 -0
- package/dist/tool-calls/content.d.ts.map +1 -0
- package/dist/tool-calls/content.js +194 -0
- package/dist/tool-calls/facts.d.ts +116 -0
- package/dist/tool-calls/facts.d.ts.map +1 -0
- package/dist/tool-calls/facts.js +1 -0
- package/dist/tool-calls/field-tracker.d.ts +58 -0
- package/dist/tool-calls/field-tracker.d.ts.map +1 -0
- package/dist/tool-calls/field-tracker.js +167 -0
- package/dist/tool-calls/renderer.d.ts +216 -0
- package/dist/tool-calls/renderer.d.ts.map +1 -0
- package/dist/tool-calls/renderer.js +487 -0
- package/dist/tool-calls/reporters/agent.d.ts +7 -0
- package/dist/tool-calls/reporters/agent.d.ts.map +1 -0
- package/dist/tool-calls/reporters/agent.js +190 -0
- package/dist/tool-calls/reporters/bash.d.ts +9 -0
- package/dist/tool-calls/reporters/bash.d.ts.map +1 -0
- package/dist/tool-calls/reporters/bash.js +83 -0
- package/dist/tool-calls/reporters/compaction.d.ts +24 -0
- package/dist/tool-calls/reporters/compaction.d.ts.map +1 -0
- package/dist/tool-calls/reporters/compaction.js +66 -0
- package/dist/tool-calls/reporters/file-edit.d.ts +46 -0
- package/dist/tool-calls/reporters/file-edit.d.ts.map +1 -0
- package/dist/tool-calls/reporters/file-edit.js +180 -0
- package/dist/tool-calls/reporters/index.d.ts +4 -0
- package/dist/tool-calls/reporters/index.d.ts.map +1 -0
- package/dist/tool-calls/reporters/index.js +40 -0
- package/dist/tool-calls/reporters/interaction.d.ts +71 -0
- package/dist/tool-calls/reporters/interaction.d.ts.map +1 -0
- package/dist/tool-calls/reporters/interaction.js +222 -0
- package/dist/tool-calls/reporters/read.d.ts +7 -0
- package/dist/tool-calls/reporters/read.d.ts.map +1 -0
- package/dist/tool-calls/reporters/read.js +64 -0
- package/dist/tool-calls/reporters/search.d.ts +10 -0
- package/dist/tool-calls/reporters/search.d.ts.map +1 -0
- package/dist/tool-calls/reporters/search.js +50 -0
- package/dist/tool-calls/reporters/web.d.ts +11 -0
- package/dist/tool-calls/reporters/web.d.ts.map +1 -0
- package/dist/tool-calls/reporters/web.js +42 -0
- package/dist/tools.d.ts +32 -37
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +48 -970
- package/package.json +4 -1
package/dist/acp-subagents.d.ts
CHANGED
|
@@ -18,6 +18,12 @@ export type SubagentSpawnedUpdate = {
|
|
|
18
18
|
subagentSessionId: string;
|
|
19
19
|
name: string;
|
|
20
20
|
task: string;
|
|
21
|
+
/**
|
|
22
|
+
* Adapter extension: the exact prompt of the subagent. A client can show it
|
|
23
|
+
* as the first user message of the subagent session. It is absent when the
|
|
24
|
+
* adapter does not know the prompt.
|
|
25
|
+
*/
|
|
26
|
+
prompt?: string;
|
|
21
27
|
capabilities: SubagentSessionCapabilities;
|
|
22
28
|
_meta?: Record<string, unknown> | null;
|
|
23
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acp-subagents.d.ts","sourceRoot":"","sources":["../src/acp-subagents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAAE,uCAAuC,EAAE,MAAM,oBAAoB,CAAC;AAE7E;;;;;;;GAOG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAA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B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GACxB,mBAAmB,CAAC,QAAQ,CAAC,GAC7B,qBAAqB,GACrB,mBAAmB,GACnB,sBAAsB,GACtB,uBAAuB,GACvB,oBAAoB,CAAC;AAEzB,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC,GAAG;IACzE,MAAM,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,gCAAgC,GAAG,mBAAmB,GAAG;IACnE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;CACnC,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,YAAY,CAAC,EAAE,kBAAkB,GAAG,IAAI,GAAG,OAAO,CASzF;AAED,wEAAwE;AACxE,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,sBAAsB,GACnC,mBAAmB,CAErB"}
|
package/dist/air-extension.d.ts
CHANGED
|
@@ -2,7 +2,23 @@ export declare const AIR_NATIVE_SUBAGENT_SESSIONS_CAPABILITY = "nativeSubagentSe
|
|
|
2
2
|
export declare const AIR_ASYNC_TASKS_CAPABILITY = "asyncTasks";
|
|
3
3
|
export declare const AIR_SESSION_FAILURE_CAPABILITY = "sessionFailure";
|
|
4
4
|
export declare const AIR_RECOMMENDED_CONFIG_VALUE_CAPABILITY = "recommendedValue";
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const AIR_DIFF_PATCH_CAPABILITY = "diffPatch";
|
|
6
|
+
/** AIR renders `rawInput` itself and needs no display copy of the input. */
|
|
7
|
+
export declare const AIR_RAW_INPUT_RENDERING_CAPABILITY = "rawInputRendering";
|
|
8
|
+
/**
|
|
9
|
+
* The plan of an ExitPlanMode is a file. `rawInput.planFilePath` names the
|
|
10
|
+
* file, and AIR reads the plan from it.
|
|
11
|
+
*/
|
|
12
|
+
export declare const AIR_PLAN_FILE_CAPABILITY = "planFile";
|
|
13
|
+
/** The `_meta.jetbrains.air` keys that the ACP tool call contract defines. */
|
|
14
|
+
export declare const AIR_COMMAND_TITLE_KEY = "commandTitle";
|
|
15
|
+
export declare const AIR_SUBAGENT_KEY = "subagent";
|
|
16
|
+
export declare const AIR_SKILL_KEY = "skill";
|
|
17
|
+
export declare const AIR_CONTEXT_COMPACTION_KEY = "contextCompaction";
|
|
18
|
+
export declare const AIR_GOAL_KEY = "goal";
|
|
19
|
+
export declare const AIR_KIND_KEY = "kind";
|
|
20
|
+
export declare const AIR_PERMISSION_KEY = "permission";
|
|
21
|
+
export declare const AIR_CUSTOM_ANSWER_KEY = "customAnswer";
|
|
6
22
|
/** The capability list this side advertises, as its own `_meta` object. */
|
|
7
23
|
export declare function airCapabilityMeta(...capabilities: string[]): Record<string, unknown>;
|
|
8
24
|
/**
|
|
@@ -13,6 +29,20 @@ export declare function airCapabilityMeta(...capabilities: string[]): Record<str
|
|
|
13
29
|
* same `air` object. Pass `undefined` to build a fresh `_meta`.
|
|
14
30
|
*/
|
|
15
31
|
export declare function withAirMeta(meta: Record<string, unknown> | null | undefined, capability: string, payload: unknown): Record<string, unknown>;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the client is JetBrains AIR: it declared `_meta.jetbrains.air` in
|
|
34
|
+
* its capabilities.
|
|
35
|
+
*
|
|
36
|
+
* Only AIR gets the AIR extensions of `docs/air-extensions.md`. Every other
|
|
37
|
+
* client, Zed too, gets the fields and the upstream `_meta` keys of the
|
|
38
|
+
* upstream adapter, and no key that exists only for AIR.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isAirClient(capabilities: unknown): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* The `_meta` of an AIR client with one more AIR payload, or undefined for
|
|
43
|
+
* every other client: a client that is not AIR gets no AIR key.
|
|
44
|
+
*/
|
|
45
|
+
export declare function airOnlyMeta(airClient: boolean, capability: string, payload: unknown, meta?: Record<string, unknown> | null): Record<string, unknown> | undefined;
|
|
16
46
|
/** The `air` object inside a `_meta`, or undefined when the peer sent no AIR extension. */
|
|
17
47
|
export declare function airExtensionMeta(meta: unknown): Record<string, unknown> | undefined;
|
|
18
48
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"air-extension.d.ts","sourceRoot":"","sources":["../src/air-extension.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uCAAuC,2BAA2B,CAAC;AAChF,eAAO,MAAM,0BAA0B,eAAe,CAAC;AACvD,eAAO,MAAM,8BAA8B,mBAAmB,CAAC;AAC/D,eAAO,MAAM,uCAAuC,qBAAqB,CAAC;AAC1E,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"air-extension.d.ts","sourceRoot":"","sources":["../src/air-extension.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uCAAuC,2BAA2B,CAAC;AAChF,eAAO,MAAM,0BAA0B,eAAe,CAAC;AACvD,eAAO,MAAM,8BAA8B,mBAAmB,CAAC;AAC/D,eAAO,MAAM,uCAAuC,qBAAqB,CAAC;AAC1E,eAAO,MAAM,yBAAyB,cAAc,CAAC;AACrD,4EAA4E;AAC5E,eAAO,MAAM,kCAAkC,sBAAsB,CAAC;AACtE;;;GAGG;AACH,eAAO,MAAM,wBAAwB,aAAa,CAAC;AAEnD,8EAA8E;AAC9E,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AACpD,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAC3C,eAAO,MAAM,aAAa,UAAU,CAAC;AACrC,eAAO,MAAM,0BAA0B,sBAAsB,CAAC;AAC9D,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,eAAO,MAAM,kBAAkB,eAAe,CAAC;AAC/C,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AAQpD,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,GAAG,YAAY,EAAE,MAAM,EAAE,2BAE1D;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,EAChD,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,OAAO,GACf,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAczB;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,OAAO,GAAG,OAAO,CAE1D;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,OAAO,EAClB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GACpC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAErC;AAED,2FAA2F;AAC3F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAKnF;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAY9F"}
|
package/dist/air-extension.js
CHANGED
|
@@ -2,7 +2,23 @@ export const AIR_NATIVE_SUBAGENT_SESSIONS_CAPABILITY = "nativeSubagentSessions";
|
|
|
2
2
|
export const AIR_ASYNC_TASKS_CAPABILITY = "asyncTasks";
|
|
3
3
|
export const AIR_SESSION_FAILURE_CAPABILITY = "sessionFailure";
|
|
4
4
|
export const AIR_RECOMMENDED_CONFIG_VALUE_CAPABILITY = "recommendedValue";
|
|
5
|
-
export const
|
|
5
|
+
export const AIR_DIFF_PATCH_CAPABILITY = "diffPatch";
|
|
6
|
+
/** AIR renders `rawInput` itself and needs no display copy of the input. */
|
|
7
|
+
export const AIR_RAW_INPUT_RENDERING_CAPABILITY = "rawInputRendering";
|
|
8
|
+
/**
|
|
9
|
+
* The plan of an ExitPlanMode is a file. `rawInput.planFilePath` names the
|
|
10
|
+
* file, and AIR reads the plan from it.
|
|
11
|
+
*/
|
|
12
|
+
export const AIR_PLAN_FILE_CAPABILITY = "planFile";
|
|
13
|
+
/** The `_meta.jetbrains.air` keys that the ACP tool call contract defines. */
|
|
14
|
+
export const AIR_COMMAND_TITLE_KEY = "commandTitle";
|
|
15
|
+
export const AIR_SUBAGENT_KEY = "subagent";
|
|
16
|
+
export const AIR_SKILL_KEY = "skill";
|
|
17
|
+
export const AIR_CONTEXT_COMPACTION_KEY = "contextCompaction";
|
|
18
|
+
export const AIR_GOAL_KEY = "goal";
|
|
19
|
+
export const AIR_KIND_KEY = "kind";
|
|
20
|
+
export const AIR_PERMISSION_KEY = "permission";
|
|
21
|
+
export const AIR_CUSTOM_ANSWER_KEY = "customAnswer";
|
|
6
22
|
const JETBRAINS_META_KEY = "jetbrains";
|
|
7
23
|
const AIR_META_KEY = "air";
|
|
8
24
|
const AIR_EXTENSION_VERSION_KEY = "version";
|
|
@@ -34,6 +50,24 @@ export function withAirMeta(meta, capability, payload) {
|
|
|
34
50
|
},
|
|
35
51
|
};
|
|
36
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Whether the client is JetBrains AIR: it declared `_meta.jetbrains.air` in
|
|
55
|
+
* its capabilities.
|
|
56
|
+
*
|
|
57
|
+
* Only AIR gets the AIR extensions of `docs/air-extensions.md`. Every other
|
|
58
|
+
* client, Zed too, gets the fields and the upstream `_meta` keys of the
|
|
59
|
+
* upstream adapter, and no key that exists only for AIR.
|
|
60
|
+
*/
|
|
61
|
+
export function isAirClient(capabilities) {
|
|
62
|
+
return airExtensionMeta(asRecord(capabilities)._meta) !== undefined;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The `_meta` of an AIR client with one more AIR payload, or undefined for
|
|
66
|
+
* every other client: a client that is not AIR gets no AIR key.
|
|
67
|
+
*/
|
|
68
|
+
export function airOnlyMeta(airClient, capability, payload, meta) {
|
|
69
|
+
return airClient ? withAirMeta(meta, capability, payload) : (meta ?? undefined);
|
|
70
|
+
}
|
|
37
71
|
/** The `air` object inside a `_meta`, or undefined when the peer sent no AIR extension. */
|
|
38
72
|
export function airExtensionMeta(meta) {
|
|
39
73
|
const air = asRecord(asRecord(meta)[JETBRAINS_META_KEY])[AIR_META_KEY];
|
package/dist/async-tasks.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ClientCapabilities } from "@agentclientprotocol/sdk";
|
|
2
2
|
import type { AcpSessionNotification, AsyncTaskState } from "./acp-subagents.js";
|
|
3
3
|
type Publish = (notification: AcpSessionNotification) => Promise<void>;
|
|
4
|
+
/** Moves an update to its owner session, or drops it with `null`. */
|
|
5
|
+
type Route = (notification: AcpSessionNotification) => AcpSessionNotification | null;
|
|
4
6
|
type TaskIdentity = {
|
|
5
7
|
taskId?: unknown;
|
|
6
8
|
task_id?: unknown;
|
|
@@ -36,12 +38,16 @@ type TaskPatch = {
|
|
|
36
38
|
};
|
|
37
39
|
export type AsyncTaskNotification = TaskIdentity & {
|
|
38
40
|
status?: unknown;
|
|
41
|
+
toolCallId?: unknown;
|
|
42
|
+
tool_use_id?: unknown;
|
|
39
43
|
summary?: unknown;
|
|
40
44
|
outputFilePath?: unknown;
|
|
41
45
|
output_file?: unknown;
|
|
42
46
|
};
|
|
43
47
|
type TaskProgress = TaskIdentity & {
|
|
44
48
|
description?: unknown;
|
|
49
|
+
toolCallId?: unknown;
|
|
50
|
+
tool_use_id?: unknown;
|
|
45
51
|
summary?: unknown;
|
|
46
52
|
lastToolName?: unknown;
|
|
47
53
|
last_tool_name?: unknown;
|
|
@@ -61,7 +67,9 @@ export declare class AsyncTaskRuntime {
|
|
|
61
67
|
private readonly sessionId;
|
|
62
68
|
private readonly publish;
|
|
63
69
|
/** `notices`: the client can present `notice` updates, so the stop
|
|
64
|
-
* acknowledgement need not be a transcript line.
|
|
70
|
+
* acknowledgement need not be a transcript line. `routeOf`: the route of
|
|
71
|
+
* the tasks that a tool call in another session started, for example in
|
|
72
|
+
* a native subagent session. */
|
|
65
73
|
private readonly options;
|
|
66
74
|
/**
|
|
67
75
|
* One registry owns both active tasks and terminal tombstones. Keeping an
|
|
@@ -71,9 +79,12 @@ export declare class AsyncTaskRuntime {
|
|
|
71
79
|
private readonly tasks;
|
|
72
80
|
constructor(enabled: boolean, sessionId: string, publish: Publish,
|
|
73
81
|
/** `notices`: the client can present `notice` updates, so the stop
|
|
74
|
-
* acknowledgement need not be a transcript line.
|
|
82
|
+
* acknowledgement need not be a transcript line. `routeOf`: the route of
|
|
83
|
+
* the tasks that a tool call in another session started, for example in
|
|
84
|
+
* a native subagent session. */
|
|
75
85
|
options?: {
|
|
76
86
|
notices?: boolean;
|
|
87
|
+
routeOf?: (toolCallId: string) => Route | undefined;
|
|
77
88
|
});
|
|
78
89
|
taskStarted(message: AsyncTaskStarted): Promise<void>;
|
|
79
90
|
taskBackgrounded(message: AsyncTaskStarted): Promise<void>;
|
|
@@ -96,17 +107,43 @@ export declare class AsyncTaskRuntime {
|
|
|
96
107
|
claimStop(taskId: string): boolean;
|
|
97
108
|
releaseStop(taskId: string): void;
|
|
98
109
|
taskStopped(taskId: string): Promise<void>;
|
|
110
|
+
/**
|
|
111
|
+
* Sends the spawn of each held task without a tool call id. The prompt
|
|
112
|
+
* result ends the model turn, and the result of the tool call that started a
|
|
113
|
+
* task comes before it. So a held task is never held for longer than one turn.
|
|
114
|
+
*/
|
|
115
|
+
releaseHeld(): Promise<void>;
|
|
99
116
|
clear(): void;
|
|
100
117
|
private task;
|
|
101
118
|
private mergeStarted;
|
|
119
|
+
/** Keeps the first tool call id that a later SDK message brings. */
|
|
120
|
+
private mergeToolCallId;
|
|
121
|
+
/** Sends an update of an announced task. A held task sends it after its spawn. */
|
|
122
|
+
private whenAnnounced;
|
|
102
123
|
private mergePatch;
|
|
103
124
|
private mergeLevel;
|
|
104
125
|
private mergeOutputFilePath;
|
|
126
|
+
/**
|
|
127
|
+
* Sends the spawn of the task. The spawn names the tool call that started the
|
|
128
|
+
* task, so it waits for the tool call id: the task is held until the id
|
|
129
|
+
* arrives. The id comes as `tool_use_id` of the SDK `task_started`,
|
|
130
|
+
* `task_progress`, or `task_notification`, or from the Bash result of a
|
|
131
|
+
* backgrounded command. A held task gets its spawn without the id when it
|
|
132
|
+
* ends first, or when the prompt result ends the model turn
|
|
133
|
+
* ({@link releaseHeld}). No guess by the command text binds a task.
|
|
134
|
+
*/
|
|
105
135
|
private announce;
|
|
106
136
|
private finish;
|
|
107
137
|
private publishMetadata;
|
|
138
|
+
/**
|
|
139
|
+
* Publishes the progress fields that changed since the last report of the
|
|
140
|
+
* task. A beat with nothing new is not sent.
|
|
141
|
+
*/
|
|
108
142
|
private publishProgress;
|
|
143
|
+
/** Publishes a state, with the output path and the tool call only when they changed. */
|
|
109
144
|
private publishState;
|
|
145
|
+
/** Publishes an update of the task in the session that owns the task. */
|
|
146
|
+
private send;
|
|
110
147
|
}
|
|
111
148
|
/** Recovers background Bash lifecycle data exposed only on its tool result. */
|
|
112
149
|
export declare function backgroundBashTaskFromToolResult(content: unknown, toolUseResult: unknown, toolUses: Record<string, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-tasks.d.ts","sourceRoot":"","sources":["../src/async-tasks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAIjF,KAAK,OAAO,GAAG,CAAC,YAAY,EAAE,sBAAsB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"async-tasks.d.ts","sourceRoot":"","sources":["../src/async-tasks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,sBAAsB,E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AG,IAAI;IAK3B,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA8BhD;;;;OAIG;IACG,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAOlC,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,IAAI;IAwBZ,OAAO,CAAC,YAAY;IAuBpB,oEAAoE;IACpE,OAAO,CAAC,eAAe;IAOvB,kFAAkF;YACpE,aAAa;IAK3B,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,mBAAmB;IAQ3B;;;;;;;;OAQG;YACW,QAAQ;YAkCR,MAAM;YAiCN,eAAe;IAa7B;;;OAGG;YACW,eAAe;IAqB7B,wFAAwF;YAC1E,YAAY;IAmB1B,yEAAyE;YAC3D,IAAI;CAKnB;AAyBD,+EAA+E;AAC/E,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,OAAO,EACtB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,GACzD,gBAAgB,GAAG,SAAS,CA4C9B"}
|
package/dist/async-tasks.js
CHANGED
|
@@ -17,7 +17,9 @@ export class AsyncTaskRuntime {
|
|
|
17
17
|
tasks = new Map();
|
|
18
18
|
constructor(enabled, sessionId, publish,
|
|
19
19
|
/** `notices`: the client can present `notice` updates, so the stop
|
|
20
|
-
* acknowledgement need not be a transcript line.
|
|
20
|
+
* acknowledgement need not be a transcript line. `routeOf`: the route of
|
|
21
|
+
* the tasks that a tool call in another session started, for example in
|
|
22
|
+
* a native subagent session. */
|
|
21
23
|
options = {}) {
|
|
22
24
|
this.enabled = enabled;
|
|
23
25
|
this.sessionId = sessionId;
|
|
@@ -39,7 +41,8 @@ export class AsyncTaskRuntime {
|
|
|
39
41
|
const previousToolCallId = task.toolCallId;
|
|
40
42
|
const wasAnnounced = task.announced;
|
|
41
43
|
this.mergeStarted(task, message);
|
|
42
|
-
if (isBackgroundTask(field(message, "isBackgrounded", "is_backgrounded"), field(message, "taskType", "task_type"))
|
|
44
|
+
if (isBackgroundTask(field(message, "isBackgrounded", "is_backgrounded"), field(message, "taskType", "task_type")) ||
|
|
45
|
+
task.held) {
|
|
43
46
|
await this.announce(task);
|
|
44
47
|
}
|
|
45
48
|
if (wasAnnounced &&
|
|
@@ -97,8 +100,8 @@ export class AsyncTaskRuntime {
|
|
|
97
100
|
}
|
|
98
101
|
if (task.state !== state) {
|
|
99
102
|
task.state = state;
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
const error = nonBlankString(patch.error);
|
|
104
|
+
await this.whenAnnounced(task, () => this.publishState(task, state, error));
|
|
102
105
|
}
|
|
103
106
|
else if (task.announced && task.outputFilePath !== previousOutputFilePath) {
|
|
104
107
|
await this.publishMetadata(task);
|
|
@@ -114,10 +117,12 @@ export class AsyncTaskRuntime {
|
|
|
114
117
|
if (!taskId)
|
|
115
118
|
return;
|
|
116
119
|
const task = this.tasks.get(taskId);
|
|
117
|
-
if (!task || !task.announced || task.
|
|
120
|
+
if (!task || task.ignored || !(task.announced || task.held))
|
|
118
121
|
return;
|
|
119
122
|
const previousOutputFilePath = task.outputFilePath;
|
|
123
|
+
const previousToolCallId = task.toolCallId;
|
|
120
124
|
this.mergeOutputFilePath(task, message);
|
|
125
|
+
this.mergeToolCallId(task, message);
|
|
121
126
|
const outputChanged = task.outputFilePath !== previousOutputFilePath;
|
|
122
127
|
if (isTerminal(task.state)) {
|
|
123
128
|
if (outputChanged)
|
|
@@ -128,13 +133,21 @@ export class AsyncTaskRuntime {
|
|
|
128
133
|
const description = nonBlankString(message.description);
|
|
129
134
|
const summary = nonBlankString(message.summary);
|
|
130
135
|
const lastToolName = nonBlankString(field(message, "lastToolName", "last_tool_name"));
|
|
131
|
-
|
|
136
|
+
const progress = {
|
|
132
137
|
...(description ? { description } : {}),
|
|
133
138
|
...(summary ? { summary } : {}),
|
|
134
139
|
...(lastToolName ? { lastToolName } : {}),
|
|
135
140
|
...(usage ? { usage } : {}),
|
|
136
141
|
...(outputChanged && task.outputFilePath ? { outputFilePath: task.outputFilePath } : {}),
|
|
137
|
-
|
|
142
|
+
...(task.toolCallId !== previousToolCallId && task.toolCallId
|
|
143
|
+
? { toolCallId: task.toolCallId }
|
|
144
|
+
: {}),
|
|
145
|
+
};
|
|
146
|
+
await this.whenAnnounced(task, () => this.publishProgress(task, progress));
|
|
147
|
+
// The progress brought the tool call id of a held task: send the spawn,
|
|
148
|
+
// then the progress beats that waited for it.
|
|
149
|
+
if (task.held && task.toolCallId)
|
|
150
|
+
await this.announce(task);
|
|
138
151
|
}
|
|
139
152
|
async taskNotification(taskOrId, legacyStatus, legacySummary, legacyOutputFilePath) {
|
|
140
153
|
if (!this.enabled)
|
|
@@ -156,6 +169,7 @@ export class AsyncTaskRuntime {
|
|
|
156
169
|
const correctsLevelState = wasTerminal && task.terminalSource === "level";
|
|
157
170
|
const previousOutputFilePath = task.outputFilePath;
|
|
158
171
|
this.mergeOutputFilePath(task, message);
|
|
172
|
+
this.mergeToolCallId(task, message);
|
|
159
173
|
await this.finish(task, state, nonBlankString(message.summary), "event");
|
|
160
174
|
if (wasTerminal &&
|
|
161
175
|
!correctsLevelState &&
|
|
@@ -207,7 +221,10 @@ export class AsyncTaskRuntime {
|
|
|
207
221
|
await this.announce(task);
|
|
208
222
|
}
|
|
209
223
|
for (const task of this.tasks.values()) {
|
|
210
|
-
if (task.announced
|
|
224
|
+
if ((task.announced || task.held) &&
|
|
225
|
+
!task.ignored &&
|
|
226
|
+
!isTerminal(task.state) &&
|
|
227
|
+
!live.has(task.id)) {
|
|
211
228
|
// This replace-semantics level is itself the authoritative liveness
|
|
212
229
|
// boundary. Close immediately so a lost terminal edge cannot leave a
|
|
213
230
|
// permanent running card; a following task_notification may correct
|
|
@@ -219,7 +236,7 @@ export class AsyncTaskRuntime {
|
|
|
219
236
|
async finishAll(state) {
|
|
220
237
|
const errors = [];
|
|
221
238
|
for (const task of this.tasks.values()) {
|
|
222
|
-
if (task.announced && !task.ignored && !isTerminal(task.state)) {
|
|
239
|
+
if ((task.announced || task.held) && !task.ignored && !isTerminal(task.state)) {
|
|
223
240
|
try {
|
|
224
241
|
await this.finish(task, state, undefined, "shutdown");
|
|
225
242
|
}
|
|
@@ -270,10 +287,20 @@ export class AsyncTaskRuntime {
|
|
|
270
287
|
// `showInTranscript` does not gate it either: that flag decides whether the
|
|
271
288
|
// task owns a transcript *card* (a background Bash task is already drawn as
|
|
272
289
|
// its tool call), not whether the agent may answer a direct user action.
|
|
273
|
-
await this.
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
290
|
+
await this.send(task, noticeOrTranscriptUpdate({ severity: "info", title: "Task stopped by user", description: `${task.name}.` }, this.options.notices ?? false));
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Sends the spawn of each held task without a tool call id. The prompt
|
|
294
|
+
* result ends the model turn, and the result of the tool call that started a
|
|
295
|
+
* task comes before it. So a held task is never held for longer than one turn.
|
|
296
|
+
*/
|
|
297
|
+
async releaseHeld() {
|
|
298
|
+
if (!this.enabled)
|
|
299
|
+
return;
|
|
300
|
+
for (const task of this.tasks.values()) {
|
|
301
|
+
if (task.held)
|
|
302
|
+
await this.announce(task, { withoutToolCall: true });
|
|
303
|
+
}
|
|
277
304
|
}
|
|
278
305
|
clear() {
|
|
279
306
|
this.tasks.clear();
|
|
@@ -289,12 +316,15 @@ export class AsyncTaskRuntime {
|
|
|
289
316
|
description: "Background task",
|
|
290
317
|
showInTranscript: true,
|
|
291
318
|
announced: false,
|
|
319
|
+
held: false,
|
|
320
|
+
deferred: [],
|
|
292
321
|
ignored: false,
|
|
293
322
|
startedObserved: false,
|
|
294
323
|
panelOnlyRecovery: false,
|
|
295
324
|
stopping: false,
|
|
296
325
|
stopAnnounced: false,
|
|
297
326
|
state: "running",
|
|
327
|
+
published: new Map(),
|
|
298
328
|
};
|
|
299
329
|
this.tasks.set(taskId, task);
|
|
300
330
|
return task;
|
|
@@ -325,6 +355,17 @@ export class AsyncTaskRuntime {
|
|
|
325
355
|
if (toolCallId)
|
|
326
356
|
task.toolCallId = toolCallId;
|
|
327
357
|
}
|
|
358
|
+
/** Keeps the first tool call id that a later SDK message brings. */
|
|
359
|
+
mergeToolCallId(task, value) {
|
|
360
|
+
task.toolCallId ??= nonBlankString(field(value, "toolCallId", "tool_use_id"));
|
|
361
|
+
}
|
|
362
|
+
/** Sends an update of an announced task. A held task sends it after its spawn. */
|
|
363
|
+
async whenAnnounced(task, send) {
|
|
364
|
+
if (task.announced)
|
|
365
|
+
await send();
|
|
366
|
+
else if (task.held)
|
|
367
|
+
task.deferred.push(send);
|
|
368
|
+
}
|
|
328
369
|
mergePatch(task, patch) {
|
|
329
370
|
const description = nonBlankString(patch.description);
|
|
330
371
|
if (description) {
|
|
@@ -348,24 +389,44 @@ export class AsyncTaskRuntime {
|
|
|
348
389
|
if (outputFilePath)
|
|
349
390
|
task.outputFilePath = outputFilePath;
|
|
350
391
|
}
|
|
351
|
-
|
|
392
|
+
/**
|
|
393
|
+
* Sends the spawn of the task. The spawn names the tool call that started the
|
|
394
|
+
* task, so it waits for the tool call id: the task is held until the id
|
|
395
|
+
* arrives. The id comes as `tool_use_id` of the SDK `task_started`,
|
|
396
|
+
* `task_progress`, or `task_notification`, or from the Bash result of a
|
|
397
|
+
* backgrounded command. A held task gets its spawn without the id when it
|
|
398
|
+
* ends first, or when the prompt result ends the model turn
|
|
399
|
+
* ({@link releaseHeld}). No guess by the command text binds a task.
|
|
400
|
+
*/
|
|
401
|
+
async announce(task, options = {}) {
|
|
352
402
|
if (task.announced || task.ignored)
|
|
353
403
|
return;
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
404
|
+
if (!task.toolCallId && !options.withoutToolCall && !isTerminal(task.state)) {
|
|
405
|
+
task.held = true;
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
if (task.toolCallId)
|
|
409
|
+
task.route ??= this.options.routeOf?.(task.toolCallId);
|
|
410
|
+
await this.send(task, {
|
|
411
|
+
sessionUpdate: "async_task_spawned",
|
|
412
|
+
asyncTaskId: task.id,
|
|
413
|
+
name: task.name,
|
|
414
|
+
taskType: task.taskType,
|
|
415
|
+
description: task.description,
|
|
416
|
+
showInTranscript: task.showInTranscript,
|
|
417
|
+
canStop: true,
|
|
418
|
+
...(task.outputFilePath ? { outputFilePath: task.outputFilePath } : {}),
|
|
419
|
+
...(task.toolCallId ? { toolCallId: task.toolCallId } : {}),
|
|
367
420
|
});
|
|
368
421
|
task.announced = true;
|
|
422
|
+
task.held = false;
|
|
423
|
+
recordPublished(task, {
|
|
424
|
+
description: task.description,
|
|
425
|
+
outputFilePath: task.outputFilePath,
|
|
426
|
+
toolCallId: task.toolCallId,
|
|
427
|
+
});
|
|
428
|
+
for (const send of task.deferred.splice(0))
|
|
429
|
+
await send();
|
|
369
430
|
if (isTerminal(task.state)) {
|
|
370
431
|
await this.publishState(task, task.state, task.terminalSummary);
|
|
371
432
|
}
|
|
@@ -390,6 +451,10 @@ export class AsyncTaskRuntime {
|
|
|
390
451
|
try {
|
|
391
452
|
if (task.announced)
|
|
392
453
|
await this.publishState(task, state, summary);
|
|
454
|
+
// The task ended before its tool call id arrived. The spawn goes out now
|
|
455
|
+
// without the id, so the task still appears.
|
|
456
|
+
else if (task.held)
|
|
457
|
+
await this.announce(task);
|
|
393
458
|
}
|
|
394
459
|
catch (error) {
|
|
395
460
|
task.state = previous.state;
|
|
@@ -411,28 +476,66 @@ export class AsyncTaskRuntime {
|
|
|
411
476
|
}
|
|
412
477
|
}
|
|
413
478
|
}
|
|
479
|
+
/**
|
|
480
|
+
* Publishes the progress fields that changed since the last report of the
|
|
481
|
+
* task. A beat with nothing new is not sent.
|
|
482
|
+
*/
|
|
414
483
|
async publishProgress(task, update) {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
484
|
+
const changed = changedFields(task, update);
|
|
485
|
+
if (Object.keys(changed).length === 0)
|
|
486
|
+
return;
|
|
487
|
+
await this.send(task, {
|
|
488
|
+
sessionUpdate: "async_task_progress",
|
|
489
|
+
asyncTaskId: task.id,
|
|
490
|
+
...changed,
|
|
422
491
|
});
|
|
492
|
+
recordPublished(task, changed);
|
|
423
493
|
}
|
|
494
|
+
/** Publishes a state, with the output path and the tool call only when they changed. */
|
|
424
495
|
async publishState(task, state, summary) {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
496
|
+
const changed = changedFields(task, {
|
|
497
|
+
outputFilePath: task.outputFilePath,
|
|
498
|
+
toolCallId: task.toolCallId,
|
|
499
|
+
});
|
|
500
|
+
await this.send(task, {
|
|
501
|
+
sessionUpdate: "async_task_state_update",
|
|
502
|
+
asyncTaskId: task.id,
|
|
503
|
+
state,
|
|
504
|
+
...(summary ? { summary } : {}),
|
|
505
|
+
...changed,
|
|
435
506
|
});
|
|
507
|
+
recordPublished(task, changed);
|
|
508
|
+
}
|
|
509
|
+
/** Publishes an update of the task in the session that owns the task. */
|
|
510
|
+
async send(task, update) {
|
|
511
|
+
const notification = { sessionId: this.sessionId, update };
|
|
512
|
+
const routed = task.route ? task.route(notification) : notification;
|
|
513
|
+
if (routed)
|
|
514
|
+
await this.publish(routed);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* The fields whose value differs from what the client holds. An undefined
|
|
519
|
+
* value is not a field. The caller records the fields with
|
|
520
|
+
* {@link recordPublished} after the send succeeds, so a retry after a failed
|
|
521
|
+
* send carries them again.
|
|
522
|
+
*/
|
|
523
|
+
function changedFields(task, fields) {
|
|
524
|
+
const changed = {};
|
|
525
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
526
|
+
if (value === undefined)
|
|
527
|
+
continue;
|
|
528
|
+
if (task.published.get(key) === JSON.stringify(value))
|
|
529
|
+
continue;
|
|
530
|
+
changed[key] = value;
|
|
531
|
+
}
|
|
532
|
+
return changed;
|
|
533
|
+
}
|
|
534
|
+
/** Records the fields that the client holds now. An undefined value is not a field. */
|
|
535
|
+
function recordPublished(task, fields) {
|
|
536
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
537
|
+
if (value !== undefined)
|
|
538
|
+
task.published.set(key, JSON.stringify(value));
|
|
436
539
|
}
|
|
437
540
|
}
|
|
438
541
|
/** Recovers background Bash lifecycle data exposed only on its tool result. */
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare const CONTEXT_COMPACTION_META_KEY = "contextCompaction";
|
|
2
1
|
export declare const CONTEXT_COMPACTION_META_VERSION = 1;
|
|
3
2
|
export type ContextCompactionTrigger = "manual" | "automatic";
|
|
4
3
|
export interface ContextCompactionMetadata {
|
|
@@ -10,9 +9,11 @@ export interface ContextCompactionMetadata {
|
|
|
10
9
|
error?: string;
|
|
11
10
|
}
|
|
12
11
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* The `_meta` of a context compaction report:
|
|
13
|
+
* `_meta.jetbrains.air.contextCompaction`, as `docs/air-extensions.md`
|
|
14
|
+
* defines. The standard toolCallId and status fields own lifecycle identity
|
|
15
|
+
* and phase; this extension carries only compaction-specific facts. Only AIR
|
|
16
|
+
* gets it.
|
|
16
17
|
*/
|
|
17
|
-
export declare function createContextCompactionMeta(metadata?: Omit<ContextCompactionMetadata, "version">): Record<
|
|
18
|
+
export declare function createContextCompactionMeta(metadata?: Omit<ContextCompactionMetadata, "version">): Record<string, unknown>;
|
|
18
19
|
//# sourceMappingURL=context-compaction-meta.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-compaction-meta.d.ts","sourceRoot":"","sources":["../src/context-compaction-meta.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"context-compaction-meta.d.ts","sourceRoot":"","sources":["../src/context-compaction-meta.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,+BAA+B,IAAI,CAAC;AAEjD,MAAM,MAAM,wBAAwB,GAAG,QAAQ,GAAG,WAAW,CAAC;AAE9D,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,OAAO,+BAA+B,CAAC;IAChD,OAAO,CAAC,EAAE,wBAAwB,CAAC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,GAAE,IAAI,CAAC,yBAAyB,EAAE,SAAS,CAAM,GACxD,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAKzB"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { AIR_CONTEXT_COMPACTION_KEY, withAirMeta } from "./air-extension.js";
|
|
2
2
|
export const CONTEXT_COMPACTION_META_VERSION = 1;
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* The `_meta` of a context compaction report:
|
|
5
|
+
* `_meta.jetbrains.air.contextCompaction`, as `docs/air-extensions.md`
|
|
6
|
+
* defines. The standard toolCallId and status fields own lifecycle identity
|
|
7
|
+
* and phase; this extension carries only compaction-specific facts. Only AIR
|
|
8
|
+
* gets it.
|
|
7
9
|
*/
|
|
8
10
|
export function createContextCompactionMeta(metadata = {}) {
|
|
9
|
-
return {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
};
|
|
11
|
+
return withAirMeta(undefined, AIR_CONTEXT_COMPACTION_KEY, {
|
|
12
|
+
version: CONTEXT_COMPACTION_META_VERSION,
|
|
13
|
+
...metadata,
|
|
14
|
+
});
|
|
15
15
|
}
|
|
@@ -18,6 +18,8 @@ export type ContextCompactionLifecycleOptions = {
|
|
|
18
18
|
/** Receives failures of the send that must not propagate: the turn-boundary
|
|
19
19
|
* `cancelled` terminal. */
|
|
20
20
|
logError?: (message: string, error: unknown) => void;
|
|
21
|
+
/** The client is AIR. Only AIR gets the compaction facts, under `_meta.jetbrains.air`. */
|
|
22
|
+
airClient?: boolean;
|
|
21
23
|
};
|
|
22
24
|
export declare function clientSupportsCompactionUpdates(capabilities?: ClientCapabilities | null): boolean;
|
|
23
25
|
/**
|
|
@@ -60,6 +62,7 @@ export declare class ContextCompactionLifecycle {
|
|
|
60
62
|
private readonly sessionId;
|
|
61
63
|
readonly presentation: CompactionPresentation;
|
|
62
64
|
private readonly logError;
|
|
65
|
+
private readonly airClient;
|
|
63
66
|
constructor(sendUpdate: SendUpdate, options: ContextCompactionLifecycleOptions);
|
|
64
67
|
get hasDeliveredOutput(): boolean;
|
|
65
68
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-compaction.d.ts","sourceRoot":"","sources":["../src/context-compaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EACL,yBAAyB,EAE1B,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"context-compaction.d.ts","sourceRoot":"","sources":["../src/context-compaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EACL,yBAAyB,EAE1B,MAAM,8BAA8B,CAAC;AAGtC,KAAK,gBAAgB,GAAG,WAAW,GAAG,QAAQ,CAAC;AAG/C;;;;;;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