@yanlinglabs/winter-agent-runtime 0.0.38 → 0.0.39
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/embedded-worker.js +3 -3
- package/dist/embedded.js +3 -3
- package/dist/{index-8x4yjdg7.js → index-b08mghw8.js} +2 -2
- package/dist/{index-5xe59vkt.js → index-dh2xed37.js} +80 -3
- package/dist/{index-z3970wsj.js → index-es0skt5n.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/messaging/host-port.d.ts +19 -0
- package/dist/messaging/reference-adapter.d.ts +8 -1
- package/dist/store/dialect.d.ts +1 -1
- package/dist/testing.js +2 -2
- package/dist/tools/impl/task-stop.d.ts +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
package/dist/embedded-worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"./index-
|
|
1
|
+
import"./index-dh2xed37.js";
|
|
2
2
|
import {
|
|
3
3
|
liveProcessGroups,
|
|
4
4
|
onProcessGroupChange
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
import"./index-mwew595z.js";
|
|
7
7
|
import"./index-2wgfv0pa.js";
|
|
8
8
|
import"./index-bef62z3r.js";
|
|
9
|
-
import"./index-
|
|
9
|
+
import"./index-es0skt5n.js";
|
|
10
10
|
import {
|
|
11
11
|
runEmbeddedSession2
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-b08mghw8.js";
|
|
13
13
|
import {
|
|
14
14
|
Queue
|
|
15
15
|
} from "./index-97t2rmtf.js";
|
package/dist/embedded.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runEmbeddedSession2
|
|
3
|
-
} from "./index-
|
|
4
|
-
import"./index-
|
|
5
|
-
import"./index-
|
|
3
|
+
} from "./index-b08mghw8.js";
|
|
4
|
+
import"./index-es0skt5n.js";
|
|
5
|
+
import"./index-dh2xed37.js";
|
|
6
6
|
import"./index-2wgfv0pa.js";
|
|
7
7
|
import"./index-bef62z3r.js";
|
|
8
8
|
import"./index-1hef2gff.js";
|
|
@@ -9,14 +9,14 @@ import {
|
|
|
9
9
|
resolveEngineSession2,
|
|
10
10
|
resolveProductionWinterHome2,
|
|
11
11
|
resolveProductionStoreHome
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-dh2xed37.js";
|
|
13
13
|
import {
|
|
14
14
|
registerDefaultChildEngineFactory,
|
|
15
15
|
loadResumedChain,
|
|
16
16
|
buildProductionWiring,
|
|
17
17
|
withAutoSkillPermissions,
|
|
18
18
|
restoreChildRoster
|
|
19
|
-
} from "./index-
|
|
19
|
+
} from "./index-es0skt5n.js";
|
|
20
20
|
|
|
21
21
|
// src/embedded.ts
|
|
22
22
|
import { splitFrames, encodeFrame } from "@yanlinglabs/winter-agent-sdk";
|
|
@@ -5155,7 +5155,25 @@ function createDefaultMessagingRuntime(opts = {}) {
|
|
|
5155
5155
|
subscribers,
|
|
5156
5156
|
now
|
|
5157
5157
|
});
|
|
5158
|
-
|
|
5158
|
+
const hostPorts = new Map;
|
|
5159
|
+
return {
|
|
5160
|
+
seam,
|
|
5161
|
+
adapter,
|
|
5162
|
+
notifications,
|
|
5163
|
+
loopGuard: createLoopGuard(),
|
|
5164
|
+
subscribers,
|
|
5165
|
+
now,
|
|
5166
|
+
peers,
|
|
5167
|
+
classifyDeliveryError,
|
|
5168
|
+
hostMessaging: (sessionId) => hostPorts.get(sessionId),
|
|
5169
|
+
registerHostMessagingPort(sessionId, port) {
|
|
5170
|
+
hostPorts.set(sessionId, port);
|
|
5171
|
+
return () => {
|
|
5172
|
+
if (hostPorts.get(sessionId) === port)
|
|
5173
|
+
hostPorts.delete(sessionId);
|
|
5174
|
+
};
|
|
5175
|
+
}
|
|
5176
|
+
};
|
|
5159
5177
|
}
|
|
5160
5178
|
function getDefaultMessagingRuntime() {
|
|
5161
5179
|
const runtime = getMessagingRuntime();
|
|
@@ -7394,6 +7412,40 @@ function transformChildFrame(frame, correlation, forwardSubagentText) {
|
|
|
7394
7412
|
}
|
|
7395
7413
|
var SESSION_LEVEL_SYSTEM_SUBTYPES = new Set(["task_started", "task_progress", "task_notification", "task_updated", "background_tasks_changed"]);
|
|
7396
7414
|
|
|
7415
|
+
// src/messaging/host-port.ts
|
|
7416
|
+
import { HOST_MESSAGE_LIST_SUBTYPE, HOST_MESSAGE_SEND_SUBTYPE, HOST_SESSION_STOP_SUBTYPE } from "@yanlinglabs/winter-agent-sdk";
|
|
7417
|
+
import { isHostMessageSendAnswer, isHostSessionStopAnswer, normaliseHostMessageListAnswer } from "@yanlinglabs/winter-agent-sdk/messaging";
|
|
7418
|
+
var HOST_MESSAGE_SEND_TIMEOUT_MS = 180000;
|
|
7419
|
+
var HOST_MESSAGE_LIST_TIMEOUT_MS = 15000;
|
|
7420
|
+
var HOST_SESSION_STOP_TIMEOUT_MS = 30000;
|
|
7421
|
+
|
|
7422
|
+
class HostMessagingAnswerError extends Error {
|
|
7423
|
+
constructor(message) {
|
|
7424
|
+
super(message);
|
|
7425
|
+
this.name = "HostMessagingAnswerError";
|
|
7426
|
+
}
|
|
7427
|
+
}
|
|
7428
|
+
function createHostMessagingPort(sender) {
|
|
7429
|
+
return {
|
|
7430
|
+
async send(request, opts) {
|
|
7431
|
+
const answer = await sender.request(HOST_MESSAGE_SEND_SUBTYPE, request, { timeoutMs: HOST_MESSAGE_SEND_TIMEOUT_MS, ...opts?.signal !== undefined ? { signal: opts.signal } : {} });
|
|
7432
|
+
if (!isHostMessageSendAnswer(answer))
|
|
7433
|
+
throw new HostMessagingAnswerError("the host answered host_message_send with a malformed outcome");
|
|
7434
|
+
return answer;
|
|
7435
|
+
},
|
|
7436
|
+
async list(request, opts) {
|
|
7437
|
+
const answer = await sender.request(HOST_MESSAGE_LIST_SUBTYPE, request, { timeoutMs: HOST_MESSAGE_LIST_TIMEOUT_MS, ...opts?.signal !== undefined ? { signal: opts.signal } : {} });
|
|
7438
|
+
return normaliseHostMessageListAnswer(answer) ?? { sessions: [] };
|
|
7439
|
+
},
|
|
7440
|
+
async stop(request, opts) {
|
|
7441
|
+
const answer = await sender.request(HOST_SESSION_STOP_SUBTYPE, request, { timeoutMs: HOST_SESSION_STOP_TIMEOUT_MS, ...opts?.signal !== undefined ? { signal: opts.signal } : {} });
|
|
7442
|
+
if (!isHostSessionStopAnswer(answer))
|
|
7443
|
+
throw new HostMessagingAnswerError("the host answered host_session_stop with a malformed answer");
|
|
7444
|
+
return answer;
|
|
7445
|
+
}
|
|
7446
|
+
};
|
|
7447
|
+
}
|
|
7448
|
+
|
|
7397
7449
|
// src/permissions/ruleset.ts
|
|
7398
7450
|
import {
|
|
7399
7451
|
readFileSync as readFileSync6,
|
|
@@ -18802,6 +18854,7 @@ replaceExecutor("TaskOutput", taskOutputExecutor);
|
|
|
18802
18854
|
|
|
18803
18855
|
// src/tools/impl/task-stop.ts
|
|
18804
18856
|
import { randomUUID as randomUUID15 } from "node:crypto";
|
|
18857
|
+
import { boundedHostNote } from "@yanlinglabs/winter-agent-sdk/messaging";
|
|
18805
18858
|
function parseTaskStopInput(input) {
|
|
18806
18859
|
if (typeof input !== "object" || input === null)
|
|
18807
18860
|
return { error: "TaskStop: input must be an object" };
|
|
@@ -18831,6 +18884,9 @@ var taskStopExecutor = {
|
|
|
18831
18884
|
const id = parsed.task_id ?? parsed.shell_id;
|
|
18832
18885
|
const task = getTask(id);
|
|
18833
18886
|
if (!task) {
|
|
18887
|
+
const host = getMessagingRuntime()?.hostMessaging?.(ctx.sessionId);
|
|
18888
|
+
if (host !== undefined)
|
|
18889
|
+
return stopHostSession(host, id, ctx.agentId, ctx.signal);
|
|
18834
18890
|
return { output: `Error: TaskStop: unknown task_id "${id}"`, isError: true };
|
|
18835
18891
|
}
|
|
18836
18892
|
if (task.status !== "running") {
|
|
@@ -18852,6 +18908,24 @@ var taskStopExecutor = {
|
|
|
18852
18908
|
return { output: formatResult(`stopped task ${id}`, id, task.kind, task.command) };
|
|
18853
18909
|
}
|
|
18854
18910
|
};
|
|
18911
|
+
var HOST_SESSION_TASK_TYPE = "session";
|
|
18912
|
+
async function stopHostSession(host, id, agentId, signal) {
|
|
18913
|
+
let answer;
|
|
18914
|
+
try {
|
|
18915
|
+
answer = await host.stop({ id, ...agentId !== undefined ? { fromAgentId: agentId } : {} }, signal !== undefined ? { signal } : {});
|
|
18916
|
+
} catch (err) {
|
|
18917
|
+
return { output: `Error: TaskStop: the host did not answer the stop for "${id}" (${err instanceof Error ? err.name : "error"}); it may or may not have stopped`, isError: true };
|
|
18918
|
+
}
|
|
18919
|
+
const note = boundedHostNote(answer.note);
|
|
18920
|
+
const withNote = (message) => note === undefined ? message : `${message}. ${note}`;
|
|
18921
|
+
if (answer.status === "stopped")
|
|
18922
|
+
return { output: JSON.stringify({ message: withNote(`stopped session ${id}: its running turn was interrupted`), task_id: id, task_type: HOST_SESSION_TASK_TYPE }) };
|
|
18923
|
+
if (answer.status === "not_running")
|
|
18924
|
+
return { output: JSON.stringify({ message: withNote(`session ${id} has no turn running -- nothing to stop`), task_id: id, task_type: HOST_SESSION_TASK_TYPE }) };
|
|
18925
|
+
if (answer.status === "not_found")
|
|
18926
|
+
return { output: `Error: TaskStop: unknown task_id "${id}" (${answer.reason ?? "not found"})`, isError: true };
|
|
18927
|
+
return { output: `Error: TaskStop: ${answer.reason ?? answer.status}`, isError: true };
|
|
18928
|
+
}
|
|
18855
18929
|
replaceExecutor("TaskStop", taskStopExecutor);
|
|
18856
18930
|
|
|
18857
18931
|
// src/tools/impl/todo-write.ts
|
|
@@ -19448,7 +19522,8 @@ function callerContextFrom(ctx) {
|
|
|
19448
19522
|
return {
|
|
19449
19523
|
sessionId: ctx.sessionId,
|
|
19450
19524
|
...ctx.agentId !== undefined ? { agentId: ctx.agentId } : {},
|
|
19451
|
-
...ctx.toolUseId !== undefined ? { toolUseId: ctx.toolUseId } : {}
|
|
19525
|
+
...ctx.toolUseId !== undefined ? { toolUseId: ctx.toolUseId } : {},
|
|
19526
|
+
...ctx.signal !== undefined ? { signal: ctx.signal } : {}
|
|
19452
19527
|
};
|
|
19453
19528
|
}
|
|
19454
19529
|
|
|
@@ -23233,6 +23308,7 @@ ${escapeAttributionText(msg.body)}
|
|
|
23233
23308
|
opts.onChildRosterReady?.(() => childRoster);
|
|
23234
23309
|
opts.onForegroundChildrenReady?.(() => [...foregroundChildren]);
|
|
23235
23310
|
const removeChildRosterSource = ensureDefaultMessagingRuntimeRegistered().addChildRosterSource(() => childRoster);
|
|
23311
|
+
const removeHostMessagingPort = config.hostMessaging === true && config.agentId === undefined ? getDefaultMessagingRuntime()?.registerHostMessagingPort?.(config.sessionId, createHostMessagingPort(bridge)) : undefined;
|
|
23236
23312
|
const sandboxSettingsForSession = config.sandbox ?? DEFAULT_SANDBOX_SETTINGS;
|
|
23237
23313
|
const bashPostureFor = (call, dangerouslyDisableSandbox) => {
|
|
23238
23314
|
const command = call.input["command"];
|
|
@@ -26439,6 +26515,7 @@ ${reason}` : ""}` : `${promptStop.hookName} hook stopped continuation${reason.le
|
|
|
26439
26515
|
if (config.agentId === undefined)
|
|
26440
26516
|
clearNotificationQueue(config.sessionId);
|
|
26441
26517
|
removeChildRosterSource();
|
|
26518
|
+
removeHostMessagingPort?.();
|
|
26442
26519
|
facetSelfPeer?.();
|
|
26443
26520
|
facetNoticeForwarder?.();
|
|
26444
26521
|
disposeSessionMcpLifecycle?.();
|
|
@@ -27598,7 +27675,7 @@ class TranscriptWriter2 {
|
|
|
27598
27675
|
return entries;
|
|
27599
27676
|
}
|
|
27600
27677
|
}
|
|
27601
|
-
var RUNTIME_ENGINE_VERSION2 = "0.0.
|
|
27678
|
+
var RUNTIME_ENGINE_VERSION2 = "0.0.39";
|
|
27602
27679
|
function withPermissionJournal(writer, location) {
|
|
27603
27680
|
return {
|
|
27604
27681
|
transcriptPath: join26(location.winterHome, "projects", location.projectKey, `${location.sessionId}.jsonl`),
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type HostMessagingPort } from "@yanlinglabs/winter-agent-sdk/messaging";
|
|
2
|
+
import type { RpcBridge } from "../rpc/bridge.js";
|
|
3
|
+
/**
|
|
4
|
+
* How long one delivery may take. Generous on purpose: a host may RESUME a finished session for the
|
|
5
|
+
* message (start its runtime, replay its transcript, connect its MCP servers) before it can answer. A
|
|
6
|
+
* timeout is `delivery_uncertain`, never `not_found` -- by then the host may well have delivered.
|
|
7
|
+
*/
|
|
8
|
+
export declare const HOST_MESSAGE_SEND_TIMEOUT_MS = 180000;
|
|
9
|
+
/** How long a listing may take; a slow one lists nothing more (ListAgents still shows the subagents). */
|
|
10
|
+
export declare const HOST_MESSAGE_LIST_TIMEOUT_MS = 15000;
|
|
11
|
+
/** How long a session stop may take (an interrupt is quick; the host answers once it is requested). */
|
|
12
|
+
export declare const HOST_SESSION_STOP_TIMEOUT_MS = 30000;
|
|
13
|
+
/** Thrown for a malformed send answer, so the router core reports it as `delivery_uncertain`. */
|
|
14
|
+
export declare class HostMessagingAnswerError extends Error {
|
|
15
|
+
constructor(message: string);
|
|
16
|
+
}
|
|
17
|
+
/** The bridge's own `request`, whose options carry the `signal` the host requests ride. */
|
|
18
|
+
export type HostMessagingSender = Pick<RpcBridge, "request">;
|
|
19
|
+
export declare function createHostMessagingPort(sender: HostMessagingSender): HostMessagingPort;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PermissionMode } from "@yanlinglabs/winter-agent-sdk";
|
|
2
|
-
import { type ChildLike, type RuntimeAddress, type DeliveryOutcome, type GlobalAgentMessage, type RuntimeMessagingAdapter, type CrossSessionInbound, type NotificationQueue, type MessagingRouterSeamWithRoster, type MessagingRuntimeDeps, type SubscriberDirectory } from "@yanlinglabs/winter-agent-sdk/messaging";
|
|
2
|
+
import { type ChildLike, type RuntimeAddress, type DeliveryOutcome, type GlobalAgentMessage, type RuntimeMessagingAdapter, type CrossSessionInbound, type NotificationQueue, type MessagingRouterSeamWithRoster, type MessagingRuntimeDeps, type SubscriberDirectory, type HostMessagingPort } from "@yanlinglabs/winter-agent-sdk/messaging";
|
|
3
3
|
export interface PeerSessionHandle {
|
|
4
4
|
readonly address: RuntimeAddress;
|
|
5
5
|
readonly name?: string;
|
|
@@ -41,6 +41,13 @@ export interface DefaultMessagingRuntime extends MessagingRuntimeDeps {
|
|
|
41
41
|
adapter: ReferenceMessagingAdapter;
|
|
42
42
|
peers: PeerDirectory;
|
|
43
43
|
seam: MessagingRouterSeamWithRoster;
|
|
44
|
+
/**
|
|
45
|
+
* Host messaging: register `port` as the host line of the OWNING session `sessionId` (a top-level run
|
|
46
|
+
* whose config says `hostMessaging: true`). Returns the withdrawal, which removes only this exact
|
|
47
|
+
* registration. Keyed by session, never one process slot: the in-memory leg runs several sessions in
|
|
48
|
+
* one realm, and each must reach only its own host handler.
|
|
49
|
+
*/
|
|
50
|
+
registerHostMessagingPort(sessionId: string, port: HostMessagingPort): () => void;
|
|
44
51
|
}
|
|
45
52
|
/**
|
|
46
53
|
* R-7b-4: THIS RUNTIME's answer to "was that throw a policy refusal, or a crash window?"
|
package/dist/store/dialect.d.ts
CHANGED
|
@@ -478,7 +478,7 @@ export declare class TranscriptWriter implements SessionPersistence {
|
|
|
478
478
|
private dialectRecord;
|
|
479
479
|
static readBack(store: SessionStore, key: SessionKey): Promise<SessionStoreEntry[]>;
|
|
480
480
|
}
|
|
481
|
-
export declare const RUNTIME_ENGINE_VERSION = "0.0.
|
|
481
|
+
export declare const RUNTIME_ENGINE_VERSION = "0.0.39";
|
|
482
482
|
export interface ResolvedEngineSession {
|
|
483
483
|
config: RuntimeConfig;
|
|
484
484
|
store: SessionPersistence | undefined;
|
package/dist/testing.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
runEngine2,
|
|
4
4
|
echoProvider2,
|
|
5
5
|
resolveEngineSession2
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-dh2xed37.js";
|
|
7
7
|
import"./index-1hef2gff.js";
|
|
8
8
|
import"./index-mwew595z.js";
|
|
9
9
|
import"./index-2wgfv0pa.js";
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
buildProductionWiring,
|
|
15
15
|
withAutoSkillPermissions,
|
|
16
16
|
restoreChildRoster
|
|
17
|
-
} from "./index-
|
|
17
|
+
} from "./index-es0skt5n.js";
|
|
18
18
|
import {
|
|
19
19
|
Queue
|
|
20
20
|
} from "./index-97t2rmtf.js";
|
|
@@ -8,4 +8,6 @@ declare function parseTaskStopInput(input: unknown): TaskStopInput | {
|
|
|
8
8
|
error: string;
|
|
9
9
|
};
|
|
10
10
|
declare const taskStopExecutor: ToolExecutor;
|
|
11
|
+
/** `task_type` for a host session in TaskStop's pinned result shape. */
|
|
12
|
+
export declare const HOST_SESSION_TASK_TYPE = "session";
|
|
11
13
|
export { parseTaskStopInput, taskStopExecutor };
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const RUNTIME_VERSION = "0.0.
|
|
1
|
+
export declare const RUNTIME_VERSION = "0.0.39";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yanlinglabs/winter-agent-runtime",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.39",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -73,9 +73,9 @@
|
|
|
73
73
|
"@modelcontextprotocol/client": "^2.1.0",
|
|
74
74
|
"ajv": "^8.20.0",
|
|
75
75
|
"ignore": "7.0.5",
|
|
76
|
-
"@yanlinglabs/winter-agent-sdk": "0.0.
|
|
77
|
-
"@yanlinglabs/winter-provider-
|
|
78
|
-
"@yanlinglabs/winter-provider-
|
|
76
|
+
"@yanlinglabs/winter-agent-sdk": "0.0.39",
|
|
77
|
+
"@yanlinglabs/winter-provider-catalog": "0.0.39",
|
|
78
|
+
"@yanlinglabs/winter-provider-runtime": "0.0.39"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
81
|
"@modelcontextprotocol/server": "^2.1.0"
|