@ycodium-ai/agent-claude 0.2.3192 → 0.2.3208
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +55 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -22417,16 +22417,27 @@ var makeSdkStream = (deps) => {
|
|
|
22417
22417
|
}
|
|
22418
22418
|
}
|
|
22419
22419
|
};
|
|
22420
|
+
const claimTurnResult = (context, message) => {
|
|
22421
|
+
const turnState = context.turnState;
|
|
22422
|
+
if (message.type !== "result" || turnState === void 0) return () => {
|
|
22423
|
+
};
|
|
22424
|
+
const claim = Promise.withResolvers();
|
|
22425
|
+
turnState.resultClaim = claim.promise;
|
|
22426
|
+
return claim.resolve;
|
|
22427
|
+
};
|
|
22420
22428
|
const runSdkStream = async (context) => {
|
|
22421
22429
|
let handlerThrew = false;
|
|
22422
22430
|
try {
|
|
22423
22431
|
for await (const message of context.query) {
|
|
22424
22432
|
if (context.stopped) break;
|
|
22433
|
+
const releaseClaim = claimTurnResult(context, message);
|
|
22425
22434
|
try {
|
|
22426
22435
|
await handleSdkMessage(context, message);
|
|
22427
22436
|
} catch (cause) {
|
|
22428
22437
|
handlerThrew = true;
|
|
22429
22438
|
throw cause;
|
|
22439
|
+
} finally {
|
|
22440
|
+
releaseClaim();
|
|
22430
22441
|
}
|
|
22431
22442
|
}
|
|
22432
22443
|
await handleStreamExit(context, null, false);
|
|
@@ -23505,10 +23516,30 @@ var makeSessionControls = (deps) => {
|
|
|
23505
23516
|
};
|
|
23506
23517
|
|
|
23507
23518
|
// src/adapter/sessionLifecycle.ts
|
|
23519
|
+
var RESULT_CLAIM_WAIT_MS = 1e3;
|
|
23508
23520
|
var makeSessionLifecycle = (deps) => {
|
|
23509
23521
|
const { emitter, log, completeTurn } = deps;
|
|
23510
23522
|
const { nowIso, makeEventStamp, eventHeader, offerRuntimeEvent } = emitter;
|
|
23511
23523
|
const sessions = /* @__PURE__ */ new Map();
|
|
23524
|
+
const awaitClaimedResult = async (context) => {
|
|
23525
|
+
const claim = context.turnState?.resultClaim;
|
|
23526
|
+
if (claim === void 0) return;
|
|
23527
|
+
let timer;
|
|
23528
|
+
const timeout = new Promise((resolve4) => {
|
|
23529
|
+
timer = setTimeout(() => resolve4("timeout"), RESULT_CLAIM_WAIT_MS);
|
|
23530
|
+
});
|
|
23531
|
+
try {
|
|
23532
|
+
const outcome = await Promise.race([claim.then(() => "settled"), timeout]);
|
|
23533
|
+
if (outcome === "timeout") {
|
|
23534
|
+
log.warn("claude.session.stop-result-claim-timeout", {
|
|
23535
|
+
threadId: context.session.threadId,
|
|
23536
|
+
waitedMs: RESULT_CLAIM_WAIT_MS
|
|
23537
|
+
});
|
|
23538
|
+
}
|
|
23539
|
+
} finally {
|
|
23540
|
+
clearTimeout(timer);
|
|
23541
|
+
}
|
|
23542
|
+
};
|
|
23512
23543
|
const stopSessionInternal = async (context, stopOptions) => {
|
|
23513
23544
|
if (context.stopWork) {
|
|
23514
23545
|
await context.stopWork;
|
|
@@ -23561,7 +23592,10 @@ var makeSessionLifecycle = (deps) => {
|
|
|
23561
23592
|
pending.cancel();
|
|
23562
23593
|
}
|
|
23563
23594
|
if (context.turnState) {
|
|
23564
|
-
await
|
|
23595
|
+
await awaitClaimedResult(context);
|
|
23596
|
+
if (context.turnState) {
|
|
23597
|
+
await completeTurn(context, "interrupted", "Session stopped.");
|
|
23598
|
+
}
|
|
23565
23599
|
}
|
|
23566
23600
|
if (closeFailure) throw closeFailure;
|
|
23567
23601
|
await context.cliProcess.clear();
|
|
@@ -25179,7 +25213,7 @@ var makeTurnLifecycle = (deps) => {
|
|
|
25179
25213
|
}
|
|
25180
25214
|
});
|
|
25181
25215
|
};
|
|
25182
|
-
const
|
|
25216
|
+
const publishTurnCompletion = async (context, status, errorMessage, result, failureCategory) => {
|
|
25183
25217
|
const resultContextWindow = maxClaudeContextWindowFromModelUsage(result?.modelUsage);
|
|
25184
25218
|
if (resultContextWindow !== void 0) {
|
|
25185
25219
|
context.lastKnownContextWindow = resultContextWindow;
|
|
@@ -25304,6 +25338,23 @@ var makeTurnLifecycle = (deps) => {
|
|
|
25304
25338
|
context.interruptSettled.resolve(void 0);
|
|
25305
25339
|
}
|
|
25306
25340
|
};
|
|
25341
|
+
const completeTurn = (context, status, errorMessage, result, failureCategory) => {
|
|
25342
|
+
const turnState = context.turnState;
|
|
25343
|
+
if (!turnState)
|
|
25344
|
+
return publishTurnCompletion(context, status, errorMessage, result, failureCategory);
|
|
25345
|
+
if (turnState.completion) return turnState.completion;
|
|
25346
|
+
const completion = Promise.withResolvers();
|
|
25347
|
+
const work = completion.promise;
|
|
25348
|
+
turnState.completion = work;
|
|
25349
|
+
void work.catch(() => {
|
|
25350
|
+
if (turnState.completion === work) delete turnState.completion;
|
|
25351
|
+
});
|
|
25352
|
+
publishTurnCompletion(context, status, errorMessage, result, failureCategory).then(
|
|
25353
|
+
completion.resolve,
|
|
25354
|
+
completion.reject
|
|
25355
|
+
);
|
|
25356
|
+
return work;
|
|
25357
|
+
};
|
|
25307
25358
|
return { ensureSyntheticTurn, completeTurn };
|
|
25308
25359
|
};
|
|
25309
25360
|
|
|
@@ -28001,7 +28052,7 @@ function createClaudeAdapter(recipe, host, options) {
|
|
|
28001
28052
|
events: runtimeEventQueue,
|
|
28002
28053
|
dispose: async () => {
|
|
28003
28054
|
const results = await Promise.allSettled(
|
|
28004
|
-
[...sessions.values()].map((ctx) => stopSessionInternal(ctx
|
|
28055
|
+
[...sessions.values()].map((ctx) => stopSessionInternal(ctx))
|
|
28005
28056
|
);
|
|
28006
28057
|
runtimeEventQueue.close();
|
|
28007
28058
|
const failures = results.flatMap(
|
|
@@ -28116,7 +28167,7 @@ var executors = [
|
|
|
28116
28167
|
];
|
|
28117
28168
|
var index_default = definePlugin({
|
|
28118
28169
|
id: "agent-claude",
|
|
28119
|
-
apiVersion:
|
|
28170
|
+
apiVersion: 19,
|
|
28120
28171
|
executors,
|
|
28121
28172
|
activate(ctx) {
|
|
28122
28173
|
capturedAttachments = ctx.attachments;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/agent-claude",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3208",
|
|
4
4
|
"description": "Claude executor: Claude Code CLI via @anthropic-ai/claude-agent-sdk.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
"@types/node": "24.12.4",
|
|
25
25
|
"esbuild": "0.28.1",
|
|
26
26
|
"vite-plus": "0.2.2",
|
|
27
|
-
"@ycodium-ai/plugin-api": "0.2.3192",
|
|
28
27
|
"ycodium-composer-tokens": "0.0.0",
|
|
28
|
+
"@ycodium-ai/plugin-api": "0.2.3208",
|
|
29
29
|
"ycodium-executor-testing": "0.0.0",
|
|
30
30
|
"ycodium-jsonl-stream": "0.0.0"
|
|
31
31
|
},
|