@opencow-ai/opencow-agent-sdk 0.4.18 → 0.4.19
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/capabilities/tools/AgentTool/agentLifecycleFinalizer.d.ts +3 -0
- package/dist/cli.mjs +430 -222
- package/dist/client.d.ts +3 -2
- package/dist/client.js +578 -251
- package/dist/entrypoints/sdk/runtimeTypes.d.ts +5 -7
- package/dist/sdk.js +578 -251
- package/dist/session/backgroundAbortRegistry.d.ts +15 -7
- package/dist/session/backgroundTaskScope.d.ts +29 -0
- package/package.json +1 -1
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
type BackgroundAgentStopActions = {
|
|
2
|
+
abort: () => void;
|
|
3
|
+
stopShells: () => void;
|
|
4
|
+
};
|
|
5
|
+
export declare function registerBackgroundAgentAbort(agentId: string, actions: BackgroundAgentStopActions): void;
|
|
2
6
|
export declare function unregisterBackgroundAgentAbort(agentId: string): void;
|
|
3
7
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* The
|
|
7
|
-
*
|
|
8
|
-
*
|
|
8
|
+
* Stop a background sub-agent by id and wait for its runAgent finalizer.
|
|
9
|
+
*
|
|
10
|
+
* The first caller synchronously aborts the run and stops its owned shells.
|
|
11
|
+
* Later callers share the same Promise. The Promise resolves only when
|
|
12
|
+
* runAgent unregisters after MCP cleanup and all remaining finalizers.
|
|
13
|
+
* Unknown or already-settled agents are an idempotent completed stop.
|
|
9
14
|
*/
|
|
10
|
-
export declare function abortBackgroundAgentById(agentId: string):
|
|
15
|
+
export declare function abortBackgroundAgentById(agentId: string): Promise<void>;
|
|
16
|
+
export declare function hasBackgroundAgent(agentId: string): boolean;
|
|
17
|
+
export declare function stopBackgroundAgentShellsById(agentId: string): void;
|
|
11
18
|
/**
|
|
12
19
|
* Record that the natural-stop path delivered SubagentStop for this run.
|
|
13
20
|
* No-op when the run is gone (e.g. the fallback delivery in runAgent's
|
|
@@ -21,3 +28,4 @@ export declare function markSubagentStopFired(agentId: string): void;
|
|
|
21
28
|
* is still needed. Purely a read — the per-run state dies with the entry.
|
|
22
29
|
*/
|
|
23
30
|
export declare function hasSubagentStopFired(agentId: string): boolean;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { SetAppState } from '../tasks/Task.js';
|
|
2
|
+
type OwnedBackgroundTask = {
|
|
3
|
+
stop: () => Promise<void>;
|
|
4
|
+
settled: Promise<void>;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Query/Session 维度的后台任务所有权。
|
|
8
|
+
*
|
|
9
|
+
* stop() 会先触发每个任务的 stop,再等待任务自身 settled;重复调用共享
|
|
10
|
+
* 同一个 Promise。任务自然结束时会从 scope 自动注销。
|
|
11
|
+
*/
|
|
12
|
+
export declare class BackgroundTaskScope {
|
|
13
|
+
private readonly tasks;
|
|
14
|
+
private stopPromise;
|
|
15
|
+
private stopped;
|
|
16
|
+
register(task: OwnedBackgroundTask): () => void;
|
|
17
|
+
stop(): Promise<void>;
|
|
18
|
+
private drain;
|
|
19
|
+
private stopTask;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* 用每个 SDK Query 独有的 setAppState 函数作为窄 owner key。
|
|
23
|
+
*
|
|
24
|
+
* 这只负责把深层 shell spawn 路由到已有 scope,不保存 QueryContext,
|
|
25
|
+
* 也不创建第二套 AsyncLocalStorage。
|
|
26
|
+
*/
|
|
27
|
+
export declare function bindBackgroundTaskScope(setAppState: SetAppState, scope: BackgroundTaskScope): () => void;
|
|
28
|
+
export declare function getBackgroundTaskScope(setAppState: SetAppState): BackgroundTaskScope | undefined;
|
|
29
|
+
export {};
|
package/package.json
CHANGED