@agentclientprotocol/claude-agent-acp 0.99.1 → 0.99.2-preview.10
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 -0
- package/dist/acp-agent.d.ts +50 -7
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +315 -87
- package/dist/clear-context-coordinator.d.ts +4 -1
- package/dist/clear-context-coordinator.d.ts.map +1 -1
- package/dist/clear-context-coordinator.js +1 -1
- package/dist/diff.d.ts +1 -1
- package/dist/diff.js +5 -5
- package/dist/elicitation.d.ts +1 -2
- package/dist/elicitation.d.ts.map +1 -1
- package/dist/elicitation.js +34 -16
- package/dist/exit-plan.d.ts.map +1 -1
- package/dist/exit-plan.js +7 -1
- package/dist/fork-session.d.ts.map +1 -1
- package/dist/fork-session.js +23 -0
- package/dist/native-subagents.d.ts +49 -3
- package/dist/native-subagents.d.ts.map +1 -1
- package/dist/native-subagents.js +118 -4
- package/dist/session-index/service.d.ts +3 -1
- package/dist/session-index/service.d.ts.map +1 -1
- package/dist/session-index/service.js +5 -10
- package/dist/startup-failure.d.ts +16 -0
- package/dist/startup-failure.d.ts.map +1 -0
- package/dist/startup-failure.js +38 -0
- package/dist/subagent-history.d.ts +8 -1
- package/dist/subagent-history.d.ts.map +1 -1
- package/dist/subagent-history.js +40 -1
- package/dist/subagent-replay.d.ts +19 -3
- package/dist/subagent-replay.d.ts.map +1 -1
- package/dist/subagent-replay.js +46 -4
- package/dist/tool-calls/reporters/interaction.d.ts.map +1 -1
- package/dist/tool-calls/reporters/interaction.js +8 -3
- package/dist/v2/agent.d.ts.map +1 -1
- package/dist/v2/agent.js +40 -15
- package/dist/v2/initialize.d.ts +16 -1
- package/dist/v2/initialize.d.ts.map +1 -1
- package/dist/v2/initialize.js +26 -3
- package/dist/v2/permission.d.ts +5 -2
- package/dist/v2/permission.d.ts.map +1 -1
- package/dist/v2/permission.js +5 -2
- package/dist/v2/prompt.d.ts +2 -1
- package/dist/v2/prompt.d.ts.map +1 -1
- package/dist/v2/prompt.js +5 -1
- package/dist/v2/session.d.ts.map +1 -1
- package/dist/v2/session.js +21 -9
- package/package.json +6 -6
|
@@ -37,6 +37,7 @@ export type ClearContextSession<Turn extends ClearContextTurn = ClearContextTurn
|
|
|
37
37
|
turnQueue?: Turn[];
|
|
38
38
|
pendingExitPlanContextReset?: ClearContextReset;
|
|
39
39
|
contextUsedTokens?: number;
|
|
40
|
+
contextWindowSize: number;
|
|
40
41
|
sentUserUuids?: Set<string>;
|
|
41
42
|
input: {
|
|
42
43
|
push(message: SDKUserMessage): unknown;
|
|
@@ -51,7 +52,9 @@ export type ClearContextCoordinatorHost<Session extends ClearContextSession<Turn
|
|
|
51
52
|
}): Promise<Session>;
|
|
52
53
|
applyFastMode(session: Session, enabled: boolean): Promise<void>;
|
|
53
54
|
applyUltracode(session: Session, enabled: boolean): Promise<void>;
|
|
54
|
-
|
|
55
|
+
/** Publishes the fresh context's mode, config options, and usage: the
|
|
56
|
+
* context starts empty in a window of `contextWindowSize` tokens. */
|
|
57
|
+
publishSessionState(sessionId: string, mode: PermissionMode, configOptions: SessionConfigOption[], contextWindowSize: number): Promise<void>;
|
|
55
58
|
continuationMessage(sessionId: string, plan: string, promptUuid: string): SDKUserMessage;
|
|
56
59
|
ensureConsumer(session: Session, sessionId: string): void;
|
|
57
60
|
logError(message: string, error: unknown): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clear-context-coordinator.d.ts","sourceRoot":"","sources":["../src/clear-context-coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAChG,OAAO,KAAK,EAGV,cAAc,EACd,cAAc,EACf,MAAM,gCAAgC,CAAC;AAGxC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,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shSession.contextUsedTokens = 0;
|
|
80
80
|
try {
|
|
81
|
-
await host.publishSessionState(sessionId, reset.mode, freshSession.configOptions);
|
|
81
|
+
await host.publishSessionState(sessionId, reset.mode, freshSession.configOptions, freshSession.contextWindowSize);
|
|
82
82
|
}
|
|
83
83
|
catch (error) {
|
|
84
84
|
host.logError("Failed to publish clear-context session state:", error);
|
package/dist/diff.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export type PatchForm = "air" | "v2";
|
|
|
31
31
|
/**
|
|
32
32
|
* How a git patch names its file. `git` is git's own form: the leading slash
|
|
33
33
|
* dropped and the `a/` and `b/` prefixes added. `absolute` is the form of an
|
|
34
|
-
* ACP v2 `git_patch`, whose paths must be absolute: the path itself.
|
|
34
|
+
* ACP v2 `git_patch`, whose paths must be absolute: the native path itself.
|
|
35
35
|
*/
|
|
36
36
|
type GitPatchPaths = "git" | "absolute";
|
|
37
37
|
/**
|
package/dist/diff.js
CHANGED
|
@@ -338,11 +338,11 @@ export function gitPatchText(filePath, change, hunks, paths = "git") {
|
|
|
338
338
|
].join("\n");
|
|
339
339
|
}
|
|
340
340
|
function gitPatchHeader(filePath, change, paths) {
|
|
341
|
-
//
|
|
342
|
-
// every platform.
|
|
343
|
-
|
|
344
|
-
//
|
|
345
|
-
const name = paths === "git" ?
|
|
341
|
+
// git's form uses forward slashes, so the header names the same file on
|
|
342
|
+
// every platform, and drops one leading slash of an absolute path. An ACP v2
|
|
343
|
+
// patch keeps the native path so that, once unquoted, it equals the `changes`
|
|
344
|
+
// entry: `C:\work\App.ts` is written `"C:\\work\\App.ts"`.
|
|
345
|
+
const name = paths === "git" ? filePath.replaceAll("\\", "/").replace(/^\/+/u, "") : filePath;
|
|
346
346
|
const oldName = quoteGitPath(paths === "git" ? "a/" : "", name);
|
|
347
347
|
const newName = quoteGitPath(paths === "git" ? "b/" : "", name);
|
|
348
348
|
// git ends a ---/+++ name that contains a space with a tab, for GNU patch.
|
package/dist/elicitation.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { CreateElicitationResponse } from "@agentclientprotocol/sdk/unstable";
|
|
2
|
-
import type { CreateElicitationRequest } from "@agentclientprotocol/sdk/unstable";
|
|
1
|
+
import type { CreateElicitationRequest, CreateElicitationResponse } from "@agentclientprotocol/sdk/unstable";
|
|
3
2
|
import type { ElicitationRequest, ElicitationResult } from "@anthropic-ai/claude-agent-sdk";
|
|
4
3
|
import type { AskUserQuestionInput } from "@anthropic-ai/claude-agent-sdk/sdk-tools.js";
|
|
5
4
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../src/elicitation.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"elicitation.d.ts","sourceRoot":"","sources":["../src/elicitation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EAI1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAC5F,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,6CAA6C,CAAC;AAOrD;;;;;;;;;;;;;GAaG;AAEH,yDAAyD;AACzD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,GAAG,EAAE,OAAO,CAAC;CACd,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,kBAAkB,EAC3B,SAAS,EAAE,MAAM,GAChB,wBAAwB,GAAG,IAAI,CAyBjC;AAqBD;;;GAGG;AACH,wBAAgB,uCAAuC,CACrD,QAAQ,EAAE,yBAAyB,GAClC,iBAAiB,CAcnB;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC;AAExE;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,K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A+B1B;AAED;;;;;;GAMG;AACH,wBAAgB,iCAAiC,CAAC,QAAQ,EAAE,yBAAyB,GAAG,MAAM,CAG7F"}
|
package/dist/elicitation.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { CreateElicitationResponse } from "@agentclientprotocol/sdk/unstable";
|
|
3
2
|
import { AIR_CUSTOM_ANSWER_KEY, LEGACY_AIR_CUSTOM_ANSWER_KEY, withAirMeta, } from "./air-extension.js";
|
|
4
3
|
/**
|
|
5
4
|
* Convert an MCP elicitation request (from the SDK's `onElicitation` callback)
|
|
@@ -32,15 +31,23 @@ export function mcpElicitationToCreateRequest(request, sessionId) {
|
|
|
32
31
|
};
|
|
33
32
|
}
|
|
34
33
|
/**
|
|
35
|
-
* Content of an accepted elicitation response
|
|
34
|
+
* Content of an accepted elicitation response, or `{}` when the response is
|
|
35
|
+
* no accept or its `content` is no JSON object.
|
|
36
36
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* the
|
|
40
|
-
*
|
|
37
|
+
* The values are not checked. v1 allows a string, number, boolean, or string
|
|
38
|
+
* array; v2 also allows any other JSON value, such as an object. An MCP
|
|
39
|
+
* server checks the content against its own `requestedSchema`, so it gets the
|
|
40
|
+
* content as the client sent it: before, an accept whose content held an
|
|
41
|
+
* object reached the server as `{ action: "accept", content: {} }`. Callers
|
|
42
|
+
* that read a field must check its type.
|
|
41
43
|
*/
|
|
42
44
|
function acceptedElicitationContent(response) {
|
|
43
|
-
|
|
45
|
+
if (response.action !== "accept")
|
|
46
|
+
return {};
|
|
47
|
+
const content = response.content;
|
|
48
|
+
return content !== null && typeof content === "object" && !Array.isArray(content)
|
|
49
|
+
? content
|
|
50
|
+
: {};
|
|
44
51
|
}
|
|
45
52
|
/**
|
|
46
53
|
* Map an ACP elicitation response back to the MCP `ElicitResult` the SDK expects
|
|
@@ -49,7 +56,11 @@ function acceptedElicitationContent(response) {
|
|
|
49
56
|
export function createElicitationResponseToElicitResult(response) {
|
|
50
57
|
switch (response.action) {
|
|
51
58
|
case "accept":
|
|
52
|
-
|
|
59
|
+
// `ElicitResult` types the values as v1 does. The MCP server checks them.
|
|
60
|
+
return {
|
|
61
|
+
action: "accept",
|
|
62
|
+
content: acceptedElicitationContent(response),
|
|
63
|
+
};
|
|
53
64
|
case "decline":
|
|
54
65
|
return { action: "decline" };
|
|
55
66
|
case "cancel":
|
|
@@ -205,7 +216,7 @@ function joinMultiSelectAnswer(items) {
|
|
|
205
216
|
* can refuse the whole answer over it, so it is left out there.
|
|
206
217
|
*/
|
|
207
218
|
export function applyAskElicitationResponse(response, toolInput, questions, options = {}) {
|
|
208
|
-
// Typed against the output schema: as of SDK 0.3.
|
|
219
|
+
// Typed against the output schema: as of SDK 0.3.316 only it lists
|
|
209
220
|
// `unanswered`, though the tool reads the same annotations from its input.
|
|
210
221
|
const annotations = {};
|
|
211
222
|
const withAnnotations = (answers) => ({
|
|
@@ -231,12 +242,13 @@ export function applyAskElicitationResponse(response, toolInput, questions, opti
|
|
|
231
242
|
questions.forEach((question, index) => {
|
|
232
243
|
const custom = content[questionCustomFieldKey(index)];
|
|
233
244
|
const customText = typeof custom === "string" ? custom.trim() : "";
|
|
245
|
+
// A pick is a string, number, or boolean. Other values, such as an object
|
|
246
|
+
// that a v2 client may send, are dropped instead of read as "[object Object]".
|
|
234
247
|
const value = content[questionFieldKey(index)];
|
|
235
|
-
const picks = value
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
: [String(value)];
|
|
248
|
+
const picks = (Array.isArray(value) ? value : [value])
|
|
249
|
+
.filter(isElicitationScalar)
|
|
250
|
+
.map(String)
|
|
251
|
+
.filter((item) => item !== "");
|
|
240
252
|
// A multi-select is additive, and the form offers the selection and the
|
|
241
253
|
// custom box as independent fields — a user who fills both means both, so
|
|
242
254
|
// the typed answer joins the checked options.
|
|
@@ -274,16 +286,22 @@ export function applyAskElicitationResponse(response, toolInput, questions, opti
|
|
|
274
286
|
}
|
|
275
287
|
return { action: "answered", updatedInput: withAnnotations(answers) };
|
|
276
288
|
}
|
|
289
|
+
function isElicitationScalar(value) {
|
|
290
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
291
|
+
}
|
|
277
292
|
/**
|
|
278
293
|
* Coerce an arbitrary MCP `requestedSchema` into an ACP `ElicitationSchema`.
|
|
279
294
|
* The two are structurally compatible JSON Schemas; we just guarantee the
|
|
280
|
-
* `type: "object"` discriminator
|
|
295
|
+
* `type: "object"` discriminator and a `properties` map are present. The v2
|
|
296
|
+
* schema requires both, so a client on SDK 2.2.0 or later rejects an MCP
|
|
297
|
+
* schema such as `{ type: "object" }` that has no `properties`.
|
|
281
298
|
*/
|
|
282
299
|
function normalizeElicitationSchema(schema) {
|
|
283
300
|
if (!schema || typeof schema !== "object") {
|
|
284
301
|
return { type: "object", properties: {} };
|
|
285
302
|
}
|
|
286
|
-
|
|
303
|
+
const { properties } = schema;
|
|
304
|
+
return { ...schema, type: "object", properties: properties ?? {} };
|
|
287
305
|
}
|
|
288
306
|
/**
|
|
289
307
|
* The `request_user_dialog` kind the CLI emits when a model refusal has a
|
package/dist/exit-plan.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exit-plan.d.ts","sourceRoot":"","sources":["../src/exit-plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EAEtB,MAAM,gCAAgC,CAAC;AAGxC,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,mBAAmB,EACjC,SAAS,EAAE,MAAM,GAAG,SAAS,GAC5B,mBAAmB,CAarB;AAeD,KAAK,aAAa,GA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jF;AAED,MAAM,MAAM,mBAAmB,CAC7B,OAAO,SAAS,mBAAmB,CAAC,IAAI,CAAC,EACzC,IAAI,SAAS,gBAAgB,IAC3B,IAAI,CACN,2BAA2B,CAAC,OAAO,EAAE,IAAI,CAAC,EAC1C,qBAAqB,GAAG,qBAAqB,CAC9C,GAAG;IACF,aAAa,CAAC,YAAY,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE,qEAAqE;IACrE,sBAAsB,IAAI,OAAO,CAAC;IAClC,WAAW,IAAI,OAAO,CAAC;IACvB,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9D,mBAAmB,CAAC,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IACjF,gBAAgB,CAAC,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CAC1E,CAAC;AAEF;;oEAEoE;AACpE,qBAAa,mBAAmB,CAC9B,OAAO,SAAS,mBAAmB,CAAC,IAAI,CAAC,EACzC,IAAI,SAAS,gBAAgB;IAIjB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAFjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsC;gBAElC,IAAI,EAAE,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC;IAErE,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAIzB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;CAmF/F"}
|
package/dist/exit-plan.js
CHANGED
|
@@ -138,7 +138,7 @@ export class ExitPlanCoordinator {
|
|
|
138
138
|
try {
|
|
139
139
|
const clearContextHost = {
|
|
140
140
|
...this.host,
|
|
141
|
-
publishSessionState: async (id, mode, configOptions) => {
|
|
141
|
+
publishSessionState: async (id, mode, configOptions, contextWindowSize) => {
|
|
142
142
|
await this.host.sessionUpdate({
|
|
143
143
|
sessionId: id,
|
|
144
144
|
update: { sessionUpdate: "current_mode_update", currentModeId: mode },
|
|
@@ -147,6 +147,12 @@ export class ExitPlanCoordinator {
|
|
|
147
147
|
sessionId: id,
|
|
148
148
|
update: { sessionUpdate: "config_option_update", configOptions },
|
|
149
149
|
});
|
|
150
|
+
// Otherwise the client shows the old context's usage until the fresh
|
|
151
|
+
// context first reports its own.
|
|
152
|
+
await this.host.sessionUpdate({
|
|
153
|
+
sessionId: id,
|
|
154
|
+
update: { sessionUpdate: "usage_update", used: 0, size: contextWindowSize },
|
|
155
|
+
});
|
|
150
156
|
// The approved plan becomes the session's plan once the fresh
|
|
151
157
|
// context that carries it out exists. Its ExitPlanMode ended with
|
|
152
158
|
// an error result, so toAcpNotifications did not publish it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fork-session.d.ts","sourceRoot":"","sources":["../src/fork-session.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EAEpB,MAAM,mCAAmC,CAAC;AA0B3C,KAAK,uBAAuB,GAAG;IAC7B,mBAAmB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD,MAAM,CAAC,EAAE;QAAE,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;KAAE,CAAC;IAC/C,oBAAoB,EAAE,CAAC,OAAO,EAAE;QAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,KAAK,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;
|
|
1
|
+
{"version":3,"file":"fork-session.d.ts","sourceRoot":"","sources":["../src/fork-session.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EAEpB,MAAM,mCAAmC,CAAC;AA0B3C,KAAK,uBAAuB,GAAG;IAC7B,mBAAmB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClD,MAAM,CAAC,EAAE;QAAE,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;KAAE,CAAC;IAC/C,oBAAoB,EAAE,CAAC,OAAO,EAAE;QAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,KAAK,MAAM,GAAG,SAAS,CAAC;CAC1B,CAAC;AA0JF,wBAAsB,WAAW,CAC/B,MAAM,EAAE,kBAAkB,EAC1B,YAAY,EAAE,uBAAuB,GACpC,OAAO,CAAC,mBAAmB,CAAC,CAS9B"}
|
package/dist/fork-session.js
CHANGED
|
@@ -104,7 +104,30 @@ function resolveFromFullHistory(entries, candidates, point, messageIdForGrouping
|
|
|
104
104
|
fingerprintOccurrenceOnBranch(group.uuid, point.messageFingerprint, entries, groups, messageIdForGrouping) === point.messageOccurrence);
|
|
105
105
|
return occurrenceMatches.length === 1 ? occurrenceMatches[0]?.uuid : undefined;
|
|
106
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Whether `error` is the Claude SDK's report that `sessionId` has no
|
|
109
|
+
* transcript: `forkSession` and `importSessionToStore` throw
|
|
110
|
+
* `Error("Session <id> not found")`, and both throw
|
|
111
|
+
* `"Invalid sessionId: <id>"` for an id that is not a UUID.
|
|
112
|
+
*/
|
|
113
|
+
function isUnknownSessionError(error, sessionId) {
|
|
114
|
+
if (!(error instanceof Error))
|
|
115
|
+
return false;
|
|
116
|
+
return (error.message === `Session ${sessionId} not found` ||
|
|
117
|
+
error.message === `Invalid sessionId: ${sessionId}`);
|
|
118
|
+
}
|
|
107
119
|
export async function forkSession(params, dependencies) {
|
|
120
|
+
try {
|
|
121
|
+
return await forkTranscript(params, dependencies);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
if (isUnknownSessionError(error, params.sessionId)) {
|
|
125
|
+
throw RequestError.sessionNotFound(params.sessionId);
|
|
126
|
+
}
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async function forkTranscript(params, dependencies) {
|
|
108
131
|
const timing = new SessionTiming(dependencies.logger, "fork", params.sessionId);
|
|
109
132
|
const point = forkPoint(params._meta);
|
|
110
133
|
// SDK `dir` scopes source lookup, not the fork's working directory. Search
|
|
@@ -47,13 +47,22 @@ export type NativeSubagent = {
|
|
|
47
47
|
/** The RFD form: the calls that delegated to the child, whose runs handed back a report. */
|
|
48
48
|
handedBack?: Set<string>;
|
|
49
49
|
announced?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The RFD form: the `cwd` that the client holds for the child. Undefined or
|
|
52
|
+
* null while the child inherits its parent's working directory.
|
|
53
|
+
*/
|
|
54
|
+
reportedCwd?: string | null;
|
|
50
55
|
terminalState?: SubagentState;
|
|
51
56
|
/** Connection-local single-flight state; never serialized on the wire. */
|
|
52
57
|
announcePromise?: Promise<void>;
|
|
58
|
+
/** Connection-local: serializes the child's `cwd` reports; never serialized on the wire. */
|
|
59
|
+
cwdPublishing?: Promise<void>;
|
|
53
60
|
/** Connection-local single-flight state; never serialized on the wire. */
|
|
54
61
|
terminalPromise?: Promise<void>;
|
|
55
62
|
};
|
|
56
63
|
export type NativeSubagentSession = {
|
|
64
|
+
/** The working directory of the root session, which a child inherits unless it reports its own. */
|
|
65
|
+
cwd?: string;
|
|
57
66
|
nativeSubagentsByTaskId?: Map<string, NativeSubagent>;
|
|
58
67
|
nativeSubagentTaskIdByToolUseId?: Map<string, string>;
|
|
59
68
|
nativeSubagentParentByToolUseId?: Map<string, string>;
|
|
@@ -107,6 +116,8 @@ export type HistoricalSubagent = {
|
|
|
107
116
|
launchId: string;
|
|
108
117
|
/** The agent that made that call. None means the root session. */
|
|
109
118
|
parentAgentId?: string;
|
|
119
|
+
/** Its working directory, when Claude Code placed it elsewhere, e.g. in a worktree. */
|
|
120
|
+
cwd?: string;
|
|
110
121
|
name?: string;
|
|
111
122
|
agentType?: string;
|
|
112
123
|
description?: string;
|
|
@@ -143,6 +154,11 @@ export declare class NativeSubagentRuntime {
|
|
|
143
154
|
private readonly identityByToolUse;
|
|
144
155
|
private readonly controlByToolUse;
|
|
145
156
|
private readonly configBySession;
|
|
157
|
+
/**
|
|
158
|
+
* The RFD form: the working directory of each child, by session id, as its
|
|
159
|
+
* hooks last reported it. A hook can come before the child is announced.
|
|
160
|
+
*/
|
|
161
|
+
private readonly cwdBySession;
|
|
146
162
|
private readonly childByParentToolUse;
|
|
147
163
|
/**
|
|
148
164
|
* The child session of each tool call that went to a child session. A later
|
|
@@ -219,6 +235,30 @@ export declare class NativeSubagentRuntime {
|
|
|
219
235
|
*/
|
|
220
236
|
reportConfiguration(agentId: string, options: SessionConfigOption[], meta?: SessionNotification["update"]["_meta"]): Promise<void>;
|
|
221
237
|
private publishConfiguration;
|
|
238
|
+
/**
|
|
239
|
+
* The RFD form: takes the working directory of the child `agentId`, the
|
|
240
|
+
* `cwd` of one of its hooks. A child that Claude Code runs in its own
|
|
241
|
+
* worktree (Agent `isolation: "worktree"`) reports the worktree. The client
|
|
242
|
+
* gets the `cwd` only when it differs from the parent's, in the
|
|
243
|
+
* announcement or in a `subagent_update` right after it. Claude Code runs a
|
|
244
|
+
* child's SubagentStart hook before its first model request, so the `cwd`
|
|
245
|
+
* reaches the client before the child's first tool call.
|
|
246
|
+
*/
|
|
247
|
+
reportCwd(agentId: string, cwd: string): Promise<void>;
|
|
248
|
+
/**
|
|
249
|
+
* The `cwd` of `child` that the client does not hold yet: its working
|
|
250
|
+
* directory when that differs from its parent's, `null` when it is back in
|
|
251
|
+
* the parent's after it reported another, else undefined.
|
|
252
|
+
*/
|
|
253
|
+
private unreportedCwd;
|
|
254
|
+
/**
|
|
255
|
+
* The working directory of the session `sessionId` as the client holds it:
|
|
256
|
+
* the root's from session setup, a child's reported `cwd`, else its
|
|
257
|
+
* parent's.
|
|
258
|
+
*/
|
|
259
|
+
private effectiveCwd;
|
|
260
|
+
/** The RFD form: sends the `cwd` of the announced `child` that the client does not hold. */
|
|
261
|
+
private publishCwd;
|
|
222
262
|
private routeUpdate;
|
|
223
263
|
taskStarted(task: TaskStarted, deliver: Publish): Promise<void>;
|
|
224
264
|
/**
|
|
@@ -373,8 +413,8 @@ export declare class NativeSubagentRuntime {
|
|
|
373
413
|
*/
|
|
374
414
|
private supplyError;
|
|
375
415
|
/**
|
|
376
|
-
* Announces `child` in the client's form,
|
|
377
|
-
* without a form never does.
|
|
416
|
+
* Announces `child` in the client's form, with its `cwd` in the RFD form,
|
|
417
|
+
* then its configuration. A runtime without a form never does.
|
|
378
418
|
*/
|
|
379
419
|
private announce;
|
|
380
420
|
/** The RFD form: publishes the work state of `child` on its parent. */
|
|
@@ -495,7 +535,7 @@ export declare function responseModelEntry(model: unknown, models: SubagentModel
|
|
|
495
535
|
* `NativeSubagentRuntime.cancelChild`), and nothing else. AIR's draft grants
|
|
496
536
|
* no capabilities.
|
|
497
537
|
*/
|
|
498
|
-
export declare function announceNativeSubagent(child: NativeSubagent, publish: Publish, form: SubagentForm): Promise<void>;
|
|
538
|
+
export declare function announceNativeSubagent(child: NativeSubagent, publish: Publish, form: SubagentForm, cwd?: string): Promise<void>;
|
|
499
539
|
export declare function finishNativeSubagent(session: NativeSubagentSession, taskId: string, state: SubagentState, publish: Publish): Promise<void>;
|
|
500
540
|
/**
|
|
501
541
|
* The RFD form: a message that a tool call sent, which the client is not
|
|
@@ -584,5 +624,11 @@ export declare function isNativeSubagentControlUpdate(update: AcpSessionNotifica
|
|
|
584
624
|
sessionUpdate: "tool_call" | "tool_call_update";
|
|
585
625
|
}>;
|
|
586
626
|
export declare function isNativeSubagentControlTool(toolName: unknown): boolean;
|
|
627
|
+
/**
|
|
628
|
+
* Whether `left` and `right` are the same directory, also when one is
|
|
629
|
+
* spelled through a symlink, e.g. `/tmp/project` and `/private/tmp/project`
|
|
630
|
+
* on macOS. A path that does not exist is compared as written.
|
|
631
|
+
*/
|
|
632
|
+
export declare function sameDirectory(left: string, right: string): Promise<boolean>;
|
|
587
633
|
export {};
|
|
588
634
|
//# sourceMappingURL=native-subagents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-subagents.d.ts","sourceRoot":"","sources":["../src/native-subagents.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACzB,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"native-subagents.d.ts","sourceRoot":"","sources":["../src/native-subagents.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACzB,MAAM,mCAAmC,CAAC;AAG3C,OAAO,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAK9F,kFAAkF;AAClF,MAAM,MAAM,SAAS,GAAG,WAAW,CACjC,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE;IAAE,aAAa,EAAE,iBAAiB,CAAA;CAAE,CAAC,CAAC,OAAO,CAAC,CACtF,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2DAA2D;IAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;IAC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E,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAAC,EACtE,OAAO,EAAE,MAAM,EACf,gBAAgB,GAAE,SAAS,MAAM,EAAO,GACvC,MAAM,GAAG,SAAS,CAEpB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAAC,EACtE,OAAO,EAAE,MAAM,EACf,gBAAgB,GAAE,SAAS,MAAM,EAAO,GACvC;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAkBlD;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAM9E;AAED,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,sBAAsB,CAAC,QAAQ,CAAC,GACvC,MAAM,IAAI,OAAO,CAClB,sBAAsB,CAAC,QAAQ,CAAC,EAChC;IAAE,aAAa,EAAE,WAAW,GAAG,kBAAkB,CAAA;CAAE,CACpD,CASA;AAED,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAEtE;AA4LD;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAKjF"}
|
package/dist/native-subagents.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { RequestError, } from "@agentclientprotocol/sdk/unstable";
|
|
2
|
+
import { realpath } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
2
4
|
import { AIR_SUBAGENT_KEY, airExtensionMeta } from "./air-extension.js";
|
|
3
5
|
import { MODEL_CONFIG_ID } from "./session-model.js";
|
|
4
6
|
import { isFinalToolCallStatus } from "./tool-calls/renderer.js";
|
|
@@ -28,6 +30,11 @@ export class NativeSubagentRuntime {
|
|
|
28
30
|
identityByToolUse = new Map();
|
|
29
31
|
controlByToolUse = new Map();
|
|
30
32
|
configBySession = new Map();
|
|
33
|
+
/**
|
|
34
|
+
* The RFD form: the working directory of each child, by session id, as its
|
|
35
|
+
* hooks last reported it. A hook can come before the child is announced.
|
|
36
|
+
*/
|
|
37
|
+
cwdBySession = new Map();
|
|
31
38
|
childByParentToolUse = new Map();
|
|
32
39
|
/**
|
|
33
40
|
* The child session of each tool call that went to a child session. A later
|
|
@@ -224,6 +231,85 @@ export class NativeSubagentRuntime {
|
|
|
224
231
|
config.publishing = publishing.catch(() => { });
|
|
225
232
|
await publishing;
|
|
226
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* The RFD form: takes the working directory of the child `agentId`, the
|
|
236
|
+
* `cwd` of one of its hooks. A child that Claude Code runs in its own
|
|
237
|
+
* worktree (Agent `isolation: "worktree"`) reports the worktree. The client
|
|
238
|
+
* gets the `cwd` only when it differs from the parent's, in the
|
|
239
|
+
* announcement or in a `subagent_update` right after it. Claude Code runs a
|
|
240
|
+
* child's SubagentStart hook before its first model request, so the `cwd`
|
|
241
|
+
* reaches the client before the child's first tool call.
|
|
242
|
+
*/
|
|
243
|
+
async reportCwd(agentId, cwd) {
|
|
244
|
+
if (this.form !== "rfd" || agentId === this.rootSessionId || !path.isAbsolute(cwd))
|
|
245
|
+
return;
|
|
246
|
+
const known = this.children.get(agentId) ?? this.childOfSession(agentId);
|
|
247
|
+
const sessionId = known?.sessionId ?? agentId;
|
|
248
|
+
if (!known && !this.cwdBySession.has(sessionId)) {
|
|
249
|
+
const pending = [...this.cwdBySession.keys()].filter((id) => !this.childOfSession(id)).length;
|
|
250
|
+
if (pending >= MAX_PENDING_PARENTS) {
|
|
251
|
+
this.logger.log(`Session ${this.rootSessionId}: dropping cwd for unannounced subagent ${agentId}; pending buffer limit reached`);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
this.cwdBySession.set(sessionId, cwd);
|
|
256
|
+
if (!known)
|
|
257
|
+
return;
|
|
258
|
+
// An announcement in flight may have been built without this `cwd`.
|
|
259
|
+
if (known.announcePromise)
|
|
260
|
+
await known.announcePromise.catch(() => { });
|
|
261
|
+
if (known.announced)
|
|
262
|
+
await this.publishCwd(known);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* The `cwd` of `child` that the client does not hold yet: its working
|
|
266
|
+
* directory when that differs from its parent's, `null` when it is back in
|
|
267
|
+
* the parent's after it reported another, else undefined.
|
|
268
|
+
*/
|
|
269
|
+
async unreportedCwd(child) {
|
|
270
|
+
const cwd = this.cwdBySession.get(child.sessionId);
|
|
271
|
+
if (cwd === undefined)
|
|
272
|
+
return undefined;
|
|
273
|
+
const inherited = this.effectiveCwd(child.parentSessionId);
|
|
274
|
+
if (inherited !== undefined && (await sameDirectory(cwd, inherited))) {
|
|
275
|
+
return child.reportedCwd ? null : undefined;
|
|
276
|
+
}
|
|
277
|
+
return cwd === child.reportedCwd ? undefined : cwd;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* The working directory of the session `sessionId` as the client holds it:
|
|
281
|
+
* the root's from session setup, a child's reported `cwd`, else its
|
|
282
|
+
* parent's.
|
|
283
|
+
*/
|
|
284
|
+
effectiveCwd(sessionId) {
|
|
285
|
+
const seen = new Set();
|
|
286
|
+
let child = this.childOfSession(sessionId);
|
|
287
|
+
while (child && !seen.has(child.sessionId)) {
|
|
288
|
+
if (child.reportedCwd)
|
|
289
|
+
return child.reportedCwd;
|
|
290
|
+
seen.add(child.sessionId);
|
|
291
|
+
child = this.childOfSession(child.parentSessionId);
|
|
292
|
+
}
|
|
293
|
+
return this.session.cwd;
|
|
294
|
+
}
|
|
295
|
+
/** The RFD form: sends the `cwd` of the announced `child` that the client does not hold. */
|
|
296
|
+
async publishCwd(child) {
|
|
297
|
+
if (this.form !== "rfd")
|
|
298
|
+
return;
|
|
299
|
+
// Concurrent hooks of one child report the same `cwd` once.
|
|
300
|
+
const publishing = (child.cwdPublishing ?? Promise.resolve()).then(async () => {
|
|
301
|
+
const cwd = await this.unreportedCwd(child);
|
|
302
|
+
if (cwd === undefined)
|
|
303
|
+
return;
|
|
304
|
+
await this.publish({
|
|
305
|
+
sessionId: child.parentSessionId,
|
|
306
|
+
update: { sessionUpdate: "subagent_update", sessionId: child.sessionId, cwd },
|
|
307
|
+
});
|
|
308
|
+
child.reportedCwd = cwd;
|
|
309
|
+
});
|
|
310
|
+
child.cwdPublishing = publishing.catch(() => { });
|
|
311
|
+
await publishing;
|
|
312
|
+
}
|
|
227
313
|
async routeUpdate(notification, deliver, forcedSessionId) {
|
|
228
314
|
const { update } = notification;
|
|
229
315
|
const claudeMeta = update._meta?.claudeCode;
|
|
@@ -686,10 +772,15 @@ export class NativeSubagentRuntime {
|
|
|
686
772
|
}
|
|
687
773
|
if (child.announced)
|
|
688
774
|
continue;
|
|
775
|
+
// A hook of the resumed agent may have reported a newer `cwd`.
|
|
776
|
+
if (entry.cwd && !this.cwdBySession.has(child.sessionId)) {
|
|
777
|
+
this.cwdBySession.set(child.sessionId, entry.cwd);
|
|
778
|
+
}
|
|
689
779
|
if (entry.agentId === agentId) {
|
|
690
780
|
await this.announce(child);
|
|
691
781
|
}
|
|
692
782
|
else {
|
|
783
|
+
const cwd = await this.unreportedCwd(child);
|
|
693
784
|
await this.publish({
|
|
694
785
|
sessionId: child.parentSessionId,
|
|
695
786
|
update: {
|
|
@@ -697,8 +788,11 @@ export class NativeSubagentRuntime {
|
|
|
697
788
|
sessionId: child.sessionId,
|
|
698
789
|
...(child.title ? { title: child.title } : {}),
|
|
699
790
|
...(child.description ? { description: child.description } : {}),
|
|
791
|
+
...(cwd ? { cwd } : {}),
|
|
700
792
|
},
|
|
701
793
|
});
|
|
794
|
+
if (cwd)
|
|
795
|
+
child.reportedCwd = cwd;
|
|
702
796
|
child.announced = true;
|
|
703
797
|
}
|
|
704
798
|
for (const pending of this.takePending(entry.launchId))
|
|
@@ -846,6 +940,7 @@ export class NativeSubagentRuntime {
|
|
|
846
940
|
withdraw(taskId, child) {
|
|
847
941
|
this.children.delete(taskId);
|
|
848
942
|
this.configBySession.delete(child.sessionId);
|
|
943
|
+
this.cwdBySession.delete(child.sessionId);
|
|
849
944
|
if (child.parentToolUseId) {
|
|
850
945
|
this.takePending(child.parentToolUseId);
|
|
851
946
|
this.cleanupControl(child.parentToolUseId);
|
|
@@ -863,13 +958,16 @@ export class NativeSubagentRuntime {
|
|
|
863
958
|
await this.reportState(child, rfdEndState("failed", { error }));
|
|
864
959
|
}
|
|
865
960
|
/**
|
|
866
|
-
* Announces `child` in the client's form,
|
|
867
|
-
* without a form never does.
|
|
961
|
+
* Announces `child` in the client's form, with its `cwd` in the RFD form,
|
|
962
|
+
* then its configuration. A runtime without a form never does.
|
|
868
963
|
*/
|
|
869
964
|
async announce(child) {
|
|
870
965
|
if (!this.form)
|
|
871
966
|
return;
|
|
872
|
-
|
|
967
|
+
const cwd = this.form === "rfd" && !child.announced ? await this.unreportedCwd(child) : undefined;
|
|
968
|
+
await announceNativeSubagent(child, this.publish, this.form, cwd ?? undefined);
|
|
969
|
+
// A hook that reported a `cwd` while the announcement was being built.
|
|
970
|
+
await this.publishCwd(child);
|
|
873
971
|
await this.publishConfiguration(child);
|
|
874
972
|
}
|
|
875
973
|
/** The RFD form: publishes the work state of `child` on its parent. */
|
|
@@ -1105,6 +1203,7 @@ export class NativeSubagentRuntime {
|
|
|
1105
1203
|
this.identityByToolUse.clear();
|
|
1106
1204
|
this.controlByToolUse.clear();
|
|
1107
1205
|
this.configBySession.clear();
|
|
1206
|
+
this.cwdBySession.clear();
|
|
1108
1207
|
this.childByParentToolUse.clear();
|
|
1109
1208
|
this.taskFinishPromises.clear();
|
|
1110
1209
|
this.senderByToolUse.clear();
|
|
@@ -1272,7 +1371,7 @@ export function responseModelEntry(model, models) {
|
|
|
1272
1371
|
* `NativeSubagentRuntime.cancelChild`), and nothing else. AIR's draft grants
|
|
1273
1372
|
* no capabilities.
|
|
1274
1373
|
*/
|
|
1275
|
-
export async function announceNativeSubagent(child, publish, form) {
|
|
1374
|
+
export async function announceNativeSubagent(child, publish, form, cwd) {
|
|
1276
1375
|
if (child.announced)
|
|
1277
1376
|
return;
|
|
1278
1377
|
if (child.announcePromise)
|
|
@@ -1287,10 +1386,13 @@ export async function announceNativeSubagent(child, publish, form) {
|
|
|
1287
1386
|
sessionId: child.sessionId,
|
|
1288
1387
|
...(child.title ? { title: child.title } : {}),
|
|
1289
1388
|
...(child.description ? { description: child.description } : {}),
|
|
1389
|
+
...(cwd ? { cwd } : {}),
|
|
1290
1390
|
capabilities: { cancel: {} },
|
|
1291
1391
|
state: { state: "running" },
|
|
1292
1392
|
},
|
|
1293
1393
|
});
|
|
1394
|
+
if (cwd)
|
|
1395
|
+
child.reportedCwd = cwd;
|
|
1294
1396
|
child.announced = true;
|
|
1295
1397
|
// The immediate parent made the Agent/Task call that launched the child.
|
|
1296
1398
|
if (child.prompt) {
|
|
@@ -1723,3 +1825,15 @@ function promptField(prompt) {
|
|
|
1723
1825
|
function nonBlankString(value) {
|
|
1724
1826
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
|
1725
1827
|
}
|
|
1828
|
+
/**
|
|
1829
|
+
* Whether `left` and `right` are the same directory, also when one is
|
|
1830
|
+
* spelled through a symlink, e.g. `/tmp/project` and `/private/tmp/project`
|
|
1831
|
+
* on macOS. A path that does not exist is compared as written.
|
|
1832
|
+
*/
|
|
1833
|
+
export async function sameDirectory(left, right) {
|
|
1834
|
+
if (path.resolve(left) === path.resolve(right))
|
|
1835
|
+
return true;
|
|
1836
|
+
const real = (dir) => realpath(dir).catch(() => path.resolve(dir));
|
|
1837
|
+
const [realLeft, realRight] = await Promise.all([real(left), real(right)]);
|
|
1838
|
+
return realLeft === realRight;
|
|
1839
|
+
}
|
|
@@ -77,7 +77,9 @@ export declare function deleteSessionIfStored(sessionId: string, deleteSession?:
|
|
|
77
77
|
/**
|
|
78
78
|
* `session/delete` of an AIR client without `sessionIndex`, which uses delete
|
|
79
79
|
* to mark a session done: archives it instead, so the transcript survives. A
|
|
80
|
-
* session without a transcript
|
|
80
|
+
* session without a transcript has nothing to archive and succeeds, as ACP
|
|
81
|
+
* asks of a delete of a session that never existed (see
|
|
82
|
+
* {@link deleteSessionIfStored}).
|
|
81
83
|
*/
|
|
82
84
|
export declare function archiveInsteadOfDelete(sessionId: string, service: SessionIndexService): Promise<void>;
|
|
83
85
|
/** How {@link SessionIndexService.retitle} reaches the session. */
|