@copilotkit/runtime 1.81.0 → 1.83.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/dist/agent/index.cjs +18 -10
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +41 -1
- package/dist/agent/index.d.cts.map +1 -1
- package/dist/agent/index.d.mts +42 -2
- package/dist/agent/index.d.mts.map +1 -1
- package/dist/agent/index.mjs +18 -10
- package/dist/agent/index.mjs.map +1 -1
- package/dist/agent/url-download.cjs +504 -0
- package/dist/agent/url-download.cjs.map +1 -0
- package/dist/agent/url-download.d.cts +80 -0
- package/dist/agent/url-download.d.cts.map +1 -0
- package/dist/agent/url-download.d.mts +80 -0
- package/dist/agent/url-download.d.mts.map +1 -0
- package/dist/agent/url-download.mjs +501 -0
- package/dist/agent/url-download.mjs.map +1 -0
- package/dist/lib/runtime/copilot-runtime.cjs +2 -1
- package/dist/lib/runtime/copilot-runtime.cjs.map +1 -1
- package/dist/lib/runtime/copilot-runtime.d.cts +5 -0
- package/dist/lib/runtime/copilot-runtime.d.cts.map +1 -1
- package/dist/lib/runtime/copilot-runtime.d.mts +5 -0
- package/dist/lib/runtime/copilot-runtime.d.mts.map +1 -1
- package/dist/lib/runtime/copilot-runtime.mjs +2 -1
- package/dist/lib/runtime/copilot-runtime.mjs.map +1 -1
- package/dist/lib/runtime/telemetry-agent-runner.cjs +4 -1
- package/dist/lib/runtime/telemetry-agent-runner.cjs.map +1 -1
- package/dist/lib/runtime/telemetry-agent-runner.d.cts +7 -1
- package/dist/lib/runtime/telemetry-agent-runner.d.cts.map +1 -1
- package/dist/lib/runtime/telemetry-agent-runner.d.mts +7 -1
- package/dist/lib/runtime/telemetry-agent-runner.d.mts.map +1 -1
- package/dist/lib/runtime/telemetry-agent-runner.mjs +4 -1
- package/dist/lib/runtime/telemetry-agent-runner.mjs.map +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/v2/index.cjs +12 -3
- package/dist/v2/index.d.cts +5 -3
- package/dist/v2/index.d.mts +5 -3
- package/dist/v2/index.mjs +6 -5
- package/dist/v2/runtime/core/channel-manager.cjs +2 -1
- package/dist/v2/runtime/core/channel-manager.cjs.map +1 -1
- package/dist/v2/runtime/core/channel-manager.mjs +2 -1
- package/dist/v2/runtime/core/channel-manager.mjs.map +1 -1
- package/dist/v2/runtime/core/fetch-handler.cjs +3 -3
- package/dist/v2/runtime/core/fetch-handler.cjs.map +1 -1
- package/dist/v2/runtime/core/fetch-handler.mjs +3 -3
- package/dist/v2/runtime/core/fetch-handler.mjs.map +1 -1
- package/dist/v2/runtime/core/package-info.cjs +1 -1
- package/dist/v2/runtime/core/package-info.mjs +1 -1
- package/dist/v2/runtime/core/runtime.cjs +12 -2
- package/dist/v2/runtime/core/runtime.cjs.map +1 -1
- package/dist/v2/runtime/core/runtime.d.cts +40 -1
- package/dist/v2/runtime/core/runtime.d.cts.map +1 -1
- package/dist/v2/runtime/core/runtime.d.mts +40 -1
- package/dist/v2/runtime/core/runtime.d.mts.map +1 -1
- package/dist/v2/runtime/core/runtime.mjs +12 -2
- package/dist/v2/runtime/core/runtime.mjs.map +1 -1
- package/dist/v2/runtime/handlers/get-runtime-info.cjs +6 -6
- package/dist/v2/runtime/handlers/get-runtime-info.cjs.map +1 -1
- package/dist/v2/runtime/handlers/get-runtime-info.mjs +6 -6
- package/dist/v2/runtime/handlers/get-runtime-info.mjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-connect.cjs +9 -1
- package/dist/v2/runtime/handlers/handle-connect.cjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-connect.mjs +9 -1
- package/dist/v2/runtime/handlers/handle-connect.mjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-inspector-learning.cjs +1 -1
- package/dist/v2/runtime/handlers/handle-inspector-learning.mjs +1 -1
- package/dist/v2/runtime/handlers/handle-run.cjs +16 -2
- package/dist/v2/runtime/handlers/handle-run.cjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-run.mjs +16 -2
- package/dist/v2/runtime/handlers/handle-run.mjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-stop.cjs +14 -3
- package/dist/v2/runtime/handlers/handle-stop.cjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-stop.mjs +14 -3
- package/dist/v2/runtime/handlers/handle-stop.mjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-trajectory-connect.cjs +1 -1
- package/dist/v2/runtime/handlers/handle-trajectory-connect.mjs +1 -1
- package/dist/v2/runtime/handlers/intelligence/annotate.cjs +2 -2
- package/dist/v2/runtime/handlers/intelligence/annotate.mjs +2 -2
- package/dist/v2/runtime/handlers/intelligence/memories.cjs +1 -1
- package/dist/v2/runtime/handlers/intelligence/memories.mjs +1 -1
- package/dist/v2/runtime/handlers/intelligence/run.cjs +7 -4
- package/dist/v2/runtime/handlers/intelligence/run.cjs.map +1 -1
- package/dist/v2/runtime/handlers/intelligence/run.mjs +7 -4
- package/dist/v2/runtime/handlers/intelligence/run.mjs.map +1 -1
- package/dist/v2/runtime/handlers/intelligence/threads.cjs +137 -31
- package/dist/v2/runtime/handlers/intelligence/threads.cjs.map +1 -1
- package/dist/v2/runtime/handlers/intelligence/threads.mjs +138 -32
- package/dist/v2/runtime/handlers/intelligence/threads.mjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/agent-utils.cjs +3 -3
- package/dist/v2/runtime/handlers/shared/agent-utils.mjs +3 -3
- package/dist/v2/runtime/handlers/shared/mcp-apps-servers.cjs +2 -1
- package/dist/v2/runtime/handlers/shared/mcp-apps-servers.cjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/mcp-apps-servers.mjs +3 -1
- package/dist/v2/runtime/handlers/shared/mcp-apps-servers.mjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/platform-error.cjs +1 -1
- package/dist/v2/runtime/handlers/shared/platform-error.mjs +1 -1
- package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.cjs +22 -3
- package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.cjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.mjs +22 -4
- package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.mjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/sse-response.cjs +20 -3
- package/dist/v2/runtime/handlers/shared/sse-response.cjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/sse-response.mjs +20 -3
- package/dist/v2/runtime/handlers/shared/sse-response.mjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/thread-access.cjs +138 -0
- package/dist/v2/runtime/handlers/shared/thread-access.cjs.map +1 -0
- package/dist/v2/runtime/handlers/shared/thread-access.d.cts +29 -0
- package/dist/v2/runtime/handlers/shared/thread-access.d.cts.map +1 -0
- package/dist/v2/runtime/handlers/shared/thread-access.d.mts +29 -0
- package/dist/v2/runtime/handlers/shared/thread-access.d.mts.map +1 -0
- package/dist/v2/runtime/handlers/shared/thread-access.mjs +133 -0
- package/dist/v2/runtime/handlers/shared/thread-access.mjs.map +1 -0
- package/dist/v2/runtime/handlers/sse/connect.cjs +2 -1
- package/dist/v2/runtime/handlers/sse/connect.cjs.map +1 -1
- package/dist/v2/runtime/handlers/sse/connect.mjs +2 -1
- package/dist/v2/runtime/handlers/sse/connect.mjs.map +1 -1
- package/dist/v2/runtime/handlers/sse/run.cjs +23 -6
- package/dist/v2/runtime/handlers/sse/run.cjs.map +1 -1
- package/dist/v2/runtime/handlers/sse/run.mjs +23 -6
- package/dist/v2/runtime/handlers/sse/run.mjs.map +1 -1
- package/dist/v2/runtime/index.d.cts +3 -2
- package/dist/v2/runtime/index.d.cts.map +1 -1
- package/dist/v2/runtime/index.d.mts +3 -2
- package/dist/v2/runtime/index.d.mts.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.cjs +17 -4
- package/dist/v2/runtime/intelligence-platform/client.cjs.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.d.cts +9 -37
- package/dist/v2/runtime/intelligence-platform/client.d.cts.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.d.mts +9 -37
- package/dist/v2/runtime/intelligence-platform/client.d.mts.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.mjs +17 -4
- package/dist/v2/runtime/intelligence-platform/client.mjs.map +1 -1
- package/dist/v2/runtime/runner/agent-runner.cjs +55 -0
- package/dist/v2/runtime/runner/agent-runner.cjs.map +1 -1
- package/dist/v2/runtime/runner/agent-runner.d.cts +90 -6
- package/dist/v2/runtime/runner/agent-runner.d.cts.map +1 -1
- package/dist/v2/runtime/runner/agent-runner.d.mts +90 -6
- package/dist/v2/runtime/runner/agent-runner.d.mts.map +1 -1
- package/dist/v2/runtime/runner/agent-runner.mjs +50 -1
- package/dist/v2/runtime/runner/agent-runner.mjs.map +1 -1
- package/dist/v2/runtime/runner/in-memory.cjs +205 -25
- package/dist/v2/runtime/runner/in-memory.cjs.map +1 -1
- package/dist/v2/runtime/runner/in-memory.d.cts +112 -15
- package/dist/v2/runtime/runner/in-memory.d.cts.map +1 -1
- package/dist/v2/runtime/runner/in-memory.d.mts +112 -15
- package/dist/v2/runtime/runner/in-memory.d.mts.map +1 -1
- package/dist/v2/runtime/runner/in-memory.mjs +206 -27
- package/dist/v2/runtime/runner/in-memory.mjs.map +1 -1
- package/dist/v2/runtime/runner/index.d.cts +2 -2
- package/dist/v2/runtime/runner/index.d.mts +2 -2
- package/dist/v2/runtime/runner/index.mjs +2 -2
- package/dist/v2/runtime/telemetry/telemetry-client.cjs +1 -1
- package/dist/v2/runtime/telemetry/telemetry-client.cjs.map +1 -1
- package/dist/v2/runtime/telemetry/telemetry-client.mjs +1 -1
- package/dist/v2/runtime/telemetry/telemetry-client.mjs.map +1 -1
- package/package.json +6 -6
|
@@ -16,13 +16,68 @@ var ThreadAlreadyRunningError = class extends Error {
|
|
|
16
16
|
this.name = "ThreadAlreadyRunningError";
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
|
+
/** `code` of {@link ThreadAccessDeniedError}, also sent on the SSE `RUN_ERROR`. */
|
|
20
|
+
const THREAD_ACCESS_DENIED_ERROR_CODE = "THREAD_ACCESS_DENIED";
|
|
21
|
+
/**
|
|
22
|
+
* Thrown by a runner when a run targets a Thread that another identity owns.
|
|
23
|
+
*
|
|
24
|
+
* Defense in depth: the run handler checks `isThreadAccessible` first and
|
|
25
|
+
* refuses with an HTTP error, so the runner throws this only when another
|
|
26
|
+
* identity claims the Thread between that check and the run, or for direct
|
|
27
|
+
* runner callers. A synchronous throw from `run()` is still mapped to the
|
|
28
|
+
* HTTP error; a later one reaches the client as a `RUN_ERROR` with
|
|
29
|
+
* {@link THREAD_ACCESS_DENIED_ERROR_CODE}. Neither is reported as an agent
|
|
30
|
+
* failure. Matched on `code`, so a copy of this class from another package
|
|
31
|
+
* version still counts.
|
|
32
|
+
*/
|
|
33
|
+
var ThreadAccessDeniedError = class extends Error {
|
|
34
|
+
constructor() {
|
|
35
|
+
super("Thread access denied");
|
|
36
|
+
this.code = THREAD_ACCESS_DENIED_ERROR_CODE;
|
|
37
|
+
this.name = "ThreadAccessDeniedError";
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
/** True for a {@link ThreadAccessDeniedError}, from any package version. */
|
|
41
|
+
function isThreadAccessDeniedError(error) {
|
|
42
|
+
return error instanceof Error && error.code === THREAD_ACCESS_DENIED_ERROR_CODE;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Owner of a Thread created, or reached, by a runner call that names no owner:
|
|
46
|
+
* a run, connect, stop or isRunning without `ownerId`, or a Thread endpoint call
|
|
47
|
+
* without a scope. Such calls come only from trusted server-side code (for
|
|
48
|
+
* example a Channel listener), and they act as this one server identity.
|
|
49
|
+
*
|
|
50
|
+
* No HTTP caller can act as it: request identities are `""` (anonymous) or an
|
|
51
|
+
* id that `identifyUser` returned, and a valid id cannot hold a NUL character.
|
|
52
|
+
* So an omitted owner never means "every Thread", and a Thread created
|
|
53
|
+
* server-side is never reachable by an anonymous caller.
|
|
54
|
+
*/
|
|
55
|
+
const ɵSERVER_THREAD_OWNER = "\0server";
|
|
56
|
+
/** The owner a runner call acts as: `ownerId`, or the server owner when omitted. */
|
|
57
|
+
function ɵresolveThreadOwner(ownerId) {
|
|
58
|
+
return ownerId ?? ɵSERVER_THREAD_OWNER;
|
|
59
|
+
}
|
|
19
60
|
function supportsLocalThreadEndpoints(runner) {
|
|
20
61
|
return runner.ɵsupportsLocalThreadEndpoints === true;
|
|
21
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* True when `runner` enforces Thread owners. Checks the method itself, so a
|
|
65
|
+
* runner built against an older interface (one that sets the endpoint flag
|
|
66
|
+
* but has no `isThreadAccessible`) is not taken to enforce them.
|
|
67
|
+
*/
|
|
68
|
+
function enforcesThreadOwnership(runner) {
|
|
69
|
+
return typeof runner.isThreadAccessible === "function";
|
|
70
|
+
}
|
|
22
71
|
var AgentRunner = class {};
|
|
23
72
|
|
|
24
73
|
//#endregion
|
|
25
74
|
exports.AgentRunner = AgentRunner;
|
|
75
|
+
exports.THREAD_ACCESS_DENIED_ERROR_CODE = THREAD_ACCESS_DENIED_ERROR_CODE;
|
|
76
|
+
exports.ThreadAccessDeniedError = ThreadAccessDeniedError;
|
|
26
77
|
exports.ThreadAlreadyRunningError = ThreadAlreadyRunningError;
|
|
78
|
+
exports.enforcesThreadOwnership = enforcesThreadOwnership;
|
|
79
|
+
exports.isThreadAccessDeniedError = isThreadAccessDeniedError;
|
|
27
80
|
exports.supportsLocalThreadEndpoints = supportsLocalThreadEndpoints;
|
|
81
|
+
exports.ɵSERVER_THREAD_OWNER = ɵSERVER_THREAD_OWNER;
|
|
82
|
+
exports.ɵresolveThreadOwner = ɵresolveThreadOwner;
|
|
28
83
|
//# sourceMappingURL=agent-runner.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-runner.cjs","names":["THREAD_ALREADY_RUNNING_ERROR_CODE"],"sources":["../../../../src/v2/runtime/runner/agent-runner.ts"],"sourcesContent":["import type {\n AbstractAgent,\n BaseEvent,\n Message,\n RunAgentInput,\n} from \"@ag-ui/client\";\nimport type { Observable } from \"rxjs\";\nimport { THREAD_ALREADY_RUNNING_ERROR_CODE } from \"@copilotkit/shared\";\n\n/**\n * Thrown by a runner when the thread already has a run in flight. The SSE\n * handler sends it to the client as a `RUN_ERROR` with\n * {@link THREAD_ALREADY_RUNNING_ERROR_CODE}, matched on `code` so a copy of\n * this class from another package version still counts.\n */\nexport class ThreadAlreadyRunningError extends Error {\n readonly code = THREAD_ALREADY_RUNNING_ERROR_CODE;\n\n constructor() {\n super(\"Thread already running\");\n this.name = \"ThreadAlreadyRunningError\";\n }\n}\n\nexport interface AgentRunnerRunRequest {\n threadId: string;\n /** Backend execution ID supplied by Intelligence for imported non-UUID sessions. */\n backendThreadId?: string;\n agent: AbstractAgent;\n input: RunAgentInput;\n persistedInputMessages?: Message[];\n /** Short-lived token scoped to this runner invocation. */\n authToken?: string;\n}\n\nexport interface AgentRunnerConnectRequest {\n threadId: string;\n agentId?: string;\n headers?: Record<string, string>;\n joinCode?: string;\n}\n\nexport interface AgentRunnerIsRunningRequest {\n threadId: string;\n}\n\nexport interface AgentRunnerStopRequest {\n threadId: string;\n /** When present, stop only this exact run and never a newer run on the Thread. */\n runId?: string;\n}\n\nexport interface LocalThreadEndpointRecord {\n id: string;\n name: string | null;\n agentId: string;\n organizationId: string;\n createdById: string;\n archived: boolean;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface LocalThreadEndpointRunner extends AgentRunner {\n readonly ɵsupportsLocalThreadEndpoints: true;\n listThreads(): LocalThreadEndpointRecord[];\n getThreadMessages(threadId: string): Message[];\n getThreadEvents(threadId: string): BaseEvent[];\n getThreadState(threadId: string): Record<string, unknown> | null;\n clearThreads(): void;\n}\n\nexport function supportsLocalThreadEndpoints(\n runner: AgentRunner,\n): runner is LocalThreadEndpointRunner {\n return runner.ɵsupportsLocalThreadEndpoints === true;\n}\n\nexport abstract class AgentRunner {\n readonly ɵsupportsLocalThreadEndpoints?: boolean;\n\n abstract run(request: AgentRunnerRunRequest): Observable<BaseEvent>;\n abstract connect(request: AgentRunnerConnectRequest): Observable<BaseEvent>;\n abstract isRunning(request: AgentRunnerIsRunningRequest): Promise<boolean>;\n abstract stop(request: AgentRunnerStopRequest): Promise<boolean | undefined>;\n}\n"],"mappings":";;;;;;;;;;;AAeA,IAAa,4BAAb,cAA+C,MAAM;CAGnD,cAAc;AACZ,QAAM,yBAAyB;cAHjBA;AAId,OAAK,OAAO
|
|
1
|
+
{"version":3,"file":"agent-runner.cjs","names":["THREAD_ALREADY_RUNNING_ERROR_CODE"],"sources":["../../../../src/v2/runtime/runner/agent-runner.ts"],"sourcesContent":["import type {\n AbstractAgent,\n BaseEvent,\n Message,\n RunAgentInput,\n} from \"@ag-ui/client\";\nimport type { Observable } from \"rxjs\";\nimport { THREAD_ALREADY_RUNNING_ERROR_CODE } from \"@copilotkit/shared\";\n\n/**\n * Thrown by a runner when the thread already has a run in flight. The SSE\n * handler sends it to the client as a `RUN_ERROR` with\n * {@link THREAD_ALREADY_RUNNING_ERROR_CODE}, matched on `code` so a copy of\n * this class from another package version still counts.\n */\nexport class ThreadAlreadyRunningError extends Error {\n readonly code = THREAD_ALREADY_RUNNING_ERROR_CODE;\n\n constructor() {\n super(\"Thread already running\");\n this.name = \"ThreadAlreadyRunningError\";\n }\n}\n\n/** `code` of {@link ThreadAccessDeniedError}, also sent on the SSE `RUN_ERROR`. */\nexport const THREAD_ACCESS_DENIED_ERROR_CODE = \"THREAD_ACCESS_DENIED\";\n\n/**\n * Thrown by a runner when a run targets a Thread that another identity owns.\n *\n * Defense in depth: the run handler checks `isThreadAccessible` first and\n * refuses with an HTTP error, so the runner throws this only when another\n * identity claims the Thread between that check and the run, or for direct\n * runner callers. A synchronous throw from `run()` is still mapped to the\n * HTTP error; a later one reaches the client as a `RUN_ERROR` with\n * {@link THREAD_ACCESS_DENIED_ERROR_CODE}. Neither is reported as an agent\n * failure. Matched on `code`, so a copy of this class from another package\n * version still counts.\n */\nexport class ThreadAccessDeniedError extends Error {\n readonly code = THREAD_ACCESS_DENIED_ERROR_CODE;\n\n constructor() {\n super(\"Thread access denied\");\n this.name = \"ThreadAccessDeniedError\";\n }\n}\n\n/** True for a {@link ThreadAccessDeniedError}, from any package version. */\nexport function isThreadAccessDeniedError(error: unknown): boolean {\n return (\n error instanceof Error &&\n (error as { code?: unknown }).code === THREAD_ACCESS_DENIED_ERROR_CODE\n );\n}\n\n/**\n * Owner of a Thread created, or reached, by a runner call that names no owner:\n * a run, connect, stop or isRunning without `ownerId`, or a Thread endpoint call\n * without a scope. Such calls come only from trusted server-side code (for\n * example a Channel listener), and they act as this one server identity.\n *\n * No HTTP caller can act as it: request identities are `\"\"` (anonymous) or an\n * id that `identifyUser` returned, and a valid id cannot hold a NUL character.\n * So an omitted owner never means \"every Thread\", and a Thread created\n * server-side is never reachable by an anonymous caller.\n */\nexport const ɵSERVER_THREAD_OWNER = \"\\u0000server\";\n\n/** The owner a runner call acts as: `ownerId`, or the server owner when omitted. */\nexport function ɵresolveThreadOwner(ownerId: string | undefined): string {\n return ownerId ?? ɵSERVER_THREAD_OWNER;\n}\n\nexport interface AgentRunnerRunRequest {\n threadId: string;\n /** Backend execution ID supplied by Intelligence for imported non-UUID sessions. */\n backendThreadId?: string;\n agent: AbstractAgent;\n input: RunAgentInput;\n persistedInputMessages?: Message[];\n /** Short-lived token scoped to this runner invocation. */\n authToken?: string;\n /**\n * Identity the run acts as. A runner that tracks owners records it on the\n * Thread's first run and refuses a run from any other identity. `\"\"` is the\n * anonymous owner. When omitted, the run acts as {@link ɵSERVER_THREAD_OWNER}.\n */\n ownerId?: string;\n}\n\nexport interface AgentRunnerConnectRequest {\n threadId: string;\n agentId?: string;\n headers?: Record<string, string>;\n joinCode?: string;\n /**\n * Caller identity. A Thread owned by another identity is treated as unknown.\n * When omitted, the call acts as {@link ɵSERVER_THREAD_OWNER}.\n */\n ownerId?: string;\n}\n\nexport interface AgentRunnerIsRunningRequest {\n threadId: string;\n /**\n * Caller identity. A Thread owned by another identity reports \"not running\".\n * When omitted, the call acts as {@link ɵSERVER_THREAD_OWNER}.\n */\n ownerId?: string;\n}\n\nexport interface AgentRunnerStopRequest {\n threadId: string;\n /** When present, stop only this exact run and never a newer run on the Thread. */\n runId?: string;\n /**\n * Caller identity. A run on a Thread owned by another identity is not\n * stopped. When omitted, the call acts as {@link ɵSERVER_THREAD_OWNER}.\n */\n ownerId?: string;\n}\n\nexport interface LocalThreadEndpointRecord {\n id: string;\n name: string | null;\n agentId: string;\n organizationId: string;\n createdById: string;\n archived: boolean;\n createdAt: string;\n updatedAt: string;\n}\n\n/**\n * Limits a local Thread endpoint call to the Threads of one owner. `\"\"` is the\n * anonymous owner. A call without a scope acts as\n * {@link ɵSERVER_THREAD_OWNER}: it sees only Threads created server-side, never\n * every Thread.\n */\nexport interface LocalThreadEndpointScope {\n ownerId: string;\n}\n\nexport interface LocalThreadEndpointRunner extends AgentRunner {\n readonly ɵsupportsLocalThreadEndpoints: true;\n listThreads(scope?: LocalThreadEndpointScope): LocalThreadEndpointRecord[];\n getThreadMessages(\n threadId: string,\n scope?: LocalThreadEndpointScope,\n ): Message[];\n getThreadEvents(\n threadId: string,\n scope?: LocalThreadEndpointScope,\n ): BaseEvent[];\n getThreadState(\n threadId: string,\n scope?: LocalThreadEndpointScope,\n ): Record<string, unknown> | null;\n clearThreads(scope?: LocalThreadEndpointScope): void;\n /** See {@link ThreadOwnershipRunner.isThreadAccessible}. */\n isThreadAccessible(\n threadId: string,\n scope: LocalThreadEndpointScope,\n ): boolean;\n}\n\nexport function supportsLocalThreadEndpoints(\n runner: AgentRunner,\n): runner is LocalThreadEndpointRunner {\n return runner.ɵsupportsLocalThreadEndpoints === true;\n}\n\n/**\n * A runner that records each Thread's owner and enforces it. Implementing\n * `isThreadAccessible` is the promise that `run`, `connect`, `stop` and\n * `isRunning` honor `ownerId` the same way: a call never reaches a Thread that\n * another owner holds.\n */\nexport interface ThreadOwnershipRunner extends AgentRunner {\n /** False when the Thread id is held by an owner other than `scope`'s. */\n isThreadAccessible(\n threadId: string,\n scope: LocalThreadEndpointScope,\n ): boolean | Promise<boolean>;\n}\n\n/**\n * True when `runner` enforces Thread owners. Checks the method itself, so a\n * runner built against an older interface (one that sets the endpoint flag\n * but has no `isThreadAccessible`) is not taken to enforce them.\n */\nexport function enforcesThreadOwnership(\n runner: AgentRunner,\n): runner is ThreadOwnershipRunner {\n return typeof runner.isThreadAccessible === \"function\";\n}\n\nexport abstract class AgentRunner {\n readonly ɵsupportsLocalThreadEndpoints?: boolean;\n\n /** See {@link ThreadOwnershipRunner}. Optional: not every runner tracks owners. */\n isThreadAccessible?(\n threadId: string,\n scope: LocalThreadEndpointScope,\n ): boolean | Promise<boolean>;\n\n abstract run(request: AgentRunnerRunRequest): Observable<BaseEvent>;\n abstract connect(request: AgentRunnerConnectRequest): Observable<BaseEvent>;\n abstract isRunning(request: AgentRunnerIsRunningRequest): Promise<boolean>;\n abstract stop(request: AgentRunnerStopRequest): Promise<boolean | undefined>;\n}\n"],"mappings":";;;;;;;;;;;AAeA,IAAa,4BAAb,cAA+C,MAAM;CAGnD,cAAc;AACZ,QAAM,yBAAyB;cAHjBA;AAId,OAAK,OAAO;;;;AAKhB,MAAa,kCAAkC;;;;;;;;;;;;;AAc/C,IAAa,0BAAb,cAA6C,MAAM;CAGjD,cAAc;AACZ,QAAM,uBAAuB;cAHf;AAId,OAAK,OAAO;;;;AAKhB,SAAgB,0BAA0B,OAAyB;AACjE,QACE,iBAAiB,SAChB,MAA6B,SAAS;;;;;;;;;;;;;AAe3C,MAAa,uBAAuB;;AAGpC,SAAgB,oBAAoB,SAAqC;AACvE,QAAO,WAAW;;AAgGpB,SAAgB,6BACd,QACqC;AACrC,QAAO,OAAO,kCAAkC;;;;;;;AAsBlD,SAAgB,wBACd,QACiC;AACjC,QAAO,OAAO,OAAO,uBAAuB;;AAG9C,IAAsB,cAAtB,MAAkC"}
|
|
@@ -13,6 +13,40 @@ declare class ThreadAlreadyRunningError extends Error {
|
|
|
13
13
|
readonly code = "THREAD_ALREADY_RUNNING";
|
|
14
14
|
constructor();
|
|
15
15
|
}
|
|
16
|
+
/** `code` of {@link ThreadAccessDeniedError}, also sent on the SSE `RUN_ERROR`. */
|
|
17
|
+
declare const THREAD_ACCESS_DENIED_ERROR_CODE = "THREAD_ACCESS_DENIED";
|
|
18
|
+
/**
|
|
19
|
+
* Thrown by a runner when a run targets a Thread that another identity owns.
|
|
20
|
+
*
|
|
21
|
+
* Defense in depth: the run handler checks `isThreadAccessible` first and
|
|
22
|
+
* refuses with an HTTP error, so the runner throws this only when another
|
|
23
|
+
* identity claims the Thread between that check and the run, or for direct
|
|
24
|
+
* runner callers. A synchronous throw from `run()` is still mapped to the
|
|
25
|
+
* HTTP error; a later one reaches the client as a `RUN_ERROR` with
|
|
26
|
+
* {@link THREAD_ACCESS_DENIED_ERROR_CODE}. Neither is reported as an agent
|
|
27
|
+
* failure. Matched on `code`, so a copy of this class from another package
|
|
28
|
+
* version still counts.
|
|
29
|
+
*/
|
|
30
|
+
declare class ThreadAccessDeniedError extends Error {
|
|
31
|
+
readonly code = "THREAD_ACCESS_DENIED";
|
|
32
|
+
constructor();
|
|
33
|
+
}
|
|
34
|
+
/** True for a {@link ThreadAccessDeniedError}, from any package version. */
|
|
35
|
+
declare function isThreadAccessDeniedError(error: unknown): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Owner of a Thread created, or reached, by a runner call that names no owner:
|
|
38
|
+
* a run, connect, stop or isRunning without `ownerId`, or a Thread endpoint call
|
|
39
|
+
* without a scope. Such calls come only from trusted server-side code (for
|
|
40
|
+
* example a Channel listener), and they act as this one server identity.
|
|
41
|
+
*
|
|
42
|
+
* No HTTP caller can act as it: request identities are `""` (anonymous) or an
|
|
43
|
+
* id that `identifyUser` returned, and a valid id cannot hold a NUL character.
|
|
44
|
+
* So an omitted owner never means "every Thread", and a Thread created
|
|
45
|
+
* server-side is never reachable by an anonymous caller.
|
|
46
|
+
*/
|
|
47
|
+
declare const ɵSERVER_THREAD_OWNER = "\0server";
|
|
48
|
+
/** The owner a runner call acts as: `ownerId`, or the server owner when omitted. */
|
|
49
|
+
declare function ɵresolveThreadOwner(ownerId: string | undefined): string;
|
|
16
50
|
interface AgentRunnerRunRequest {
|
|
17
51
|
threadId: string;
|
|
18
52
|
/** Backend execution ID supplied by Intelligence for imported non-UUID sessions. */
|
|
@@ -22,20 +56,41 @@ interface AgentRunnerRunRequest {
|
|
|
22
56
|
persistedInputMessages?: Message[];
|
|
23
57
|
/** Short-lived token scoped to this runner invocation. */
|
|
24
58
|
authToken?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Identity the run acts as. A runner that tracks owners records it on the
|
|
61
|
+
* Thread's first run and refuses a run from any other identity. `""` is the
|
|
62
|
+
* anonymous owner. When omitted, the run acts as {@link ɵSERVER_THREAD_OWNER}.
|
|
63
|
+
*/
|
|
64
|
+
ownerId?: string;
|
|
25
65
|
}
|
|
26
66
|
interface AgentRunnerConnectRequest {
|
|
27
67
|
threadId: string;
|
|
28
68
|
agentId?: string;
|
|
29
69
|
headers?: Record<string, string>;
|
|
30
70
|
joinCode?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Caller identity. A Thread owned by another identity is treated as unknown.
|
|
73
|
+
* When omitted, the call acts as {@link ɵSERVER_THREAD_OWNER}.
|
|
74
|
+
*/
|
|
75
|
+
ownerId?: string;
|
|
31
76
|
}
|
|
32
77
|
interface AgentRunnerIsRunningRequest {
|
|
33
78
|
threadId: string;
|
|
79
|
+
/**
|
|
80
|
+
* Caller identity. A Thread owned by another identity reports "not running".
|
|
81
|
+
* When omitted, the call acts as {@link ɵSERVER_THREAD_OWNER}.
|
|
82
|
+
*/
|
|
83
|
+
ownerId?: string;
|
|
34
84
|
}
|
|
35
85
|
interface AgentRunnerStopRequest {
|
|
36
86
|
threadId: string;
|
|
37
87
|
/** When present, stop only this exact run and never a newer run on the Thread. */
|
|
38
88
|
runId?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Caller identity. A run on a Thread owned by another identity is not
|
|
91
|
+
* stopped. When omitted, the call acts as {@link ɵSERVER_THREAD_OWNER}.
|
|
92
|
+
*/
|
|
93
|
+
ownerId?: string;
|
|
39
94
|
}
|
|
40
95
|
interface LocalThreadEndpointRecord {
|
|
41
96
|
id: string;
|
|
@@ -47,22 +102,51 @@ interface LocalThreadEndpointRecord {
|
|
|
47
102
|
createdAt: string;
|
|
48
103
|
updatedAt: string;
|
|
49
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Limits a local Thread endpoint call to the Threads of one owner. `""` is the
|
|
107
|
+
* anonymous owner. A call without a scope acts as
|
|
108
|
+
* {@link ɵSERVER_THREAD_OWNER}: it sees only Threads created server-side, never
|
|
109
|
+
* every Thread.
|
|
110
|
+
*/
|
|
111
|
+
interface LocalThreadEndpointScope {
|
|
112
|
+
ownerId: string;
|
|
113
|
+
}
|
|
50
114
|
interface LocalThreadEndpointRunner extends AgentRunner {
|
|
51
115
|
readonly ɵsupportsLocalThreadEndpoints: true;
|
|
52
|
-
listThreads(): LocalThreadEndpointRecord[];
|
|
53
|
-
getThreadMessages(threadId: string): Message[];
|
|
54
|
-
getThreadEvents(threadId: string): BaseEvent[];
|
|
55
|
-
getThreadState(threadId: string): Record<string, unknown> | null;
|
|
56
|
-
clearThreads(): void;
|
|
116
|
+
listThreads(scope?: LocalThreadEndpointScope): LocalThreadEndpointRecord[];
|
|
117
|
+
getThreadMessages(threadId: string, scope?: LocalThreadEndpointScope): Message[];
|
|
118
|
+
getThreadEvents(threadId: string, scope?: LocalThreadEndpointScope): BaseEvent[];
|
|
119
|
+
getThreadState(threadId: string, scope?: LocalThreadEndpointScope): Record<string, unknown> | null;
|
|
120
|
+
clearThreads(scope?: LocalThreadEndpointScope): void;
|
|
121
|
+
/** See {@link ThreadOwnershipRunner.isThreadAccessible}. */
|
|
122
|
+
isThreadAccessible(threadId: string, scope: LocalThreadEndpointScope): boolean;
|
|
57
123
|
}
|
|
58
124
|
declare function supportsLocalThreadEndpoints(runner: AgentRunner): runner is LocalThreadEndpointRunner;
|
|
125
|
+
/**
|
|
126
|
+
* A runner that records each Thread's owner and enforces it. Implementing
|
|
127
|
+
* `isThreadAccessible` is the promise that `run`, `connect`, `stop` and
|
|
128
|
+
* `isRunning` honor `ownerId` the same way: a call never reaches a Thread that
|
|
129
|
+
* another owner holds.
|
|
130
|
+
*/
|
|
131
|
+
interface ThreadOwnershipRunner extends AgentRunner {
|
|
132
|
+
/** False when the Thread id is held by an owner other than `scope`'s. */
|
|
133
|
+
isThreadAccessible(threadId: string, scope: LocalThreadEndpointScope): boolean | Promise<boolean>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* True when `runner` enforces Thread owners. Checks the method itself, so a
|
|
137
|
+
* runner built against an older interface (one that sets the endpoint flag
|
|
138
|
+
* but has no `isThreadAccessible`) is not taken to enforce them.
|
|
139
|
+
*/
|
|
140
|
+
declare function enforcesThreadOwnership(runner: AgentRunner): runner is ThreadOwnershipRunner;
|
|
59
141
|
declare abstract class AgentRunner {
|
|
60
142
|
readonly ɵsupportsLocalThreadEndpoints?: boolean;
|
|
143
|
+
/** See {@link ThreadOwnershipRunner}. Optional: not every runner tracks owners. */
|
|
144
|
+
isThreadAccessible?(threadId: string, scope: LocalThreadEndpointScope): boolean | Promise<boolean>;
|
|
61
145
|
abstract run(request: AgentRunnerRunRequest): Observable<BaseEvent>;
|
|
62
146
|
abstract connect(request: AgentRunnerConnectRequest): Observable<BaseEvent>;
|
|
63
147
|
abstract isRunning(request: AgentRunnerIsRunningRequest): Promise<boolean>;
|
|
64
148
|
abstract stop(request: AgentRunnerStopRequest): Promise<boolean | undefined>;
|
|
65
149
|
}
|
|
66
150
|
//#endregion
|
|
67
|
-
export { AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest, LocalThreadEndpointRecord, LocalThreadEndpointRunner, ThreadAlreadyRunningError, supportsLocalThreadEndpoints };
|
|
151
|
+
export { AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest, LocalThreadEndpointRecord, LocalThreadEndpointRunner, LocalThreadEndpointScope, THREAD_ACCESS_DENIED_ERROR_CODE, ThreadAccessDeniedError, ThreadAlreadyRunningError, ThreadOwnershipRunner, enforcesThreadOwnership, isThreadAccessDeniedError, supportsLocalThreadEndpoints, ɵSERVER_THREAD_OWNER, ɵresolveThreadOwner };
|
|
68
152
|
//# sourceMappingURL=agent-runner.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-runner.d.cts","names":[],"sources":["../../../../src/v2/runtime/runner/agent-runner.ts"],"mappings":";;;;;;;AAeA;;;;cAAa,yBAAA,SAAkC,KAAA;EAAA,SACpC,IAAA
|
|
1
|
+
{"version":3,"file":"agent-runner.d.cts","names":[],"sources":["../../../../src/v2/runtime/runner/agent-runner.ts"],"mappings":";;;;;;;AAeA;;;;cAAa,yBAAA,SAAkC,KAAA;EAAA,SACpC,IAAA;;;;cASE,+BAAA;;;;;AAcb;;;;;;;;cAAa,uBAAA,SAAgC,KAAA;EAAA,SAClC,IAAA;;;;iBASK,yBAAA,CAA0B,KAAA;AAkB1C;;;;;AAGA;;;;;AAIA;AAPA,cAAa,oBAAA;;iBAGG,mBAAA,CAAoB,OAAA;AAAA,UAInB,qBAAA;EACf,QAAA;EAKgC;EAHhC,eAAA;EACA,KAAA,EAAO,aAAA;EACP,KAAA,EAAO,aAAA;EACP,sBAAA,GAAyB,OAAA;EAFlB;EAIP,SAAA;EAHO;;;;;EASP,OAAA;AAAA;AAAA,UAGe,yBAAA;EACf,QAAA;EACA,OAAA;EACA,OAAA,GAAU,MAAA;EACV,QAAA;EAFA;;;;EAOA,OAAA;AAAA;AAAA,UAGe,2BAAA;EACf,QAAA;EAD0C;;;;EAM1C,OAAA;AAAA;AAAA,UAGe,sBAAA;EACf,QAAA;EAAA;EAEA,KAAA;EAKA;;;AAGF;EAHE,OAAA;AAAA;AAAA,UAGe,yBAAA;EACf,EAAA;EACA,IAAA;EACA,OAAA;EACA,cAAA;EACA,WAAA;EACA,QAAA;EACA,SAAA;EACA,SAAA;AAAA;;AASF;;;;;UAAiB,wBAAA;EACf,OAAA;AAAA;AAAA,UAGe,yBAAA,SAAkC,WAAA;EAAA,SACxC,6BAAA;EACT,WAAA,CAAY,KAAA,GAAQ,wBAAA,GAA2B,yBAAA;EAC/C,iBAAA,CACE,QAAA,UACA,KAAA,GAAQ,wBAAA,GACP,OAAA;EACH,eAAA,CACE,QAAA,UACA,KAAA,GAAQ,wBAAA,GACP,SAAA;EACH,cAAA,CACE,QAAA,UACA,KAAA,GAAQ,wBAAA,GACP,MAAA;EACH,YAAA,CAAa,KAAA,GAAQ,wBAAA;EADlB;EAGH,kBAAA,CACE,QAAA,UACA,KAAA,EAAO,wBAAA;AAAA;AAAA,iBAIK,4BAAA,CACd,MAAA,EAAQ,WAAA,GACP,MAAA,IAAU,yBAAA;;;;;;;UAUI,qBAAA,SAA8B,WAAA;EAjCE;EAmC/C,kBAAA,CACE,QAAA,UACA,KAAA,EAAO,wBAAA,aACI,OAAA;AAAA;;;;;;iBAQC,uBAAA,CACd,MAAA,EAAQ,WAAA,GACP,MAAA,IAAU,qBAAA;AAAA,uBAIS,WAAA;EAAA,SACX,6BAAA;EA5CT;EA+CA,kBAAA,CAAA,CACE,QAAA,UACA,KAAA,EAAO,wBAAA,aACI,OAAA;EAAA,SAEJ,GAAA,CAAI,OAAA,EAAS,qBAAA,GAAwB,UAAA,CAAW,SAAA;EAAA,SAChD,OAAA,CAAQ,OAAA,EAAS,yBAAA,GAA4B,UAAA,CAAW,SAAA;EAAA,SACxD,SAAA,CAAU,OAAA,EAAS,2BAAA,GAA8B,OAAA;EAAA,SACjD,IAAA,CAAK,OAAA,EAAS,sBAAA,GAAyB,OAAA;AAAA"}
|
|
@@ -13,6 +13,40 @@ declare class ThreadAlreadyRunningError extends Error {
|
|
|
13
13
|
readonly code = "THREAD_ALREADY_RUNNING";
|
|
14
14
|
constructor();
|
|
15
15
|
}
|
|
16
|
+
/** `code` of {@link ThreadAccessDeniedError}, also sent on the SSE `RUN_ERROR`. */
|
|
17
|
+
declare const THREAD_ACCESS_DENIED_ERROR_CODE = "THREAD_ACCESS_DENIED";
|
|
18
|
+
/**
|
|
19
|
+
* Thrown by a runner when a run targets a Thread that another identity owns.
|
|
20
|
+
*
|
|
21
|
+
* Defense in depth: the run handler checks `isThreadAccessible` first and
|
|
22
|
+
* refuses with an HTTP error, so the runner throws this only when another
|
|
23
|
+
* identity claims the Thread between that check and the run, or for direct
|
|
24
|
+
* runner callers. A synchronous throw from `run()` is still mapped to the
|
|
25
|
+
* HTTP error; a later one reaches the client as a `RUN_ERROR` with
|
|
26
|
+
* {@link THREAD_ACCESS_DENIED_ERROR_CODE}. Neither is reported as an agent
|
|
27
|
+
* failure. Matched on `code`, so a copy of this class from another package
|
|
28
|
+
* version still counts.
|
|
29
|
+
*/
|
|
30
|
+
declare class ThreadAccessDeniedError extends Error {
|
|
31
|
+
readonly code = "THREAD_ACCESS_DENIED";
|
|
32
|
+
constructor();
|
|
33
|
+
}
|
|
34
|
+
/** True for a {@link ThreadAccessDeniedError}, from any package version. */
|
|
35
|
+
declare function isThreadAccessDeniedError(error: unknown): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Owner of a Thread created, or reached, by a runner call that names no owner:
|
|
38
|
+
* a run, connect, stop or isRunning without `ownerId`, or a Thread endpoint call
|
|
39
|
+
* without a scope. Such calls come only from trusted server-side code (for
|
|
40
|
+
* example a Channel listener), and they act as this one server identity.
|
|
41
|
+
*
|
|
42
|
+
* No HTTP caller can act as it: request identities are `""` (anonymous) or an
|
|
43
|
+
* id that `identifyUser` returned, and a valid id cannot hold a NUL character.
|
|
44
|
+
* So an omitted owner never means "every Thread", and a Thread created
|
|
45
|
+
* server-side is never reachable by an anonymous caller.
|
|
46
|
+
*/
|
|
47
|
+
declare const ɵSERVER_THREAD_OWNER = "\0server";
|
|
48
|
+
/** The owner a runner call acts as: `ownerId`, or the server owner when omitted. */
|
|
49
|
+
declare function ɵresolveThreadOwner(ownerId: string | undefined): string;
|
|
16
50
|
interface AgentRunnerRunRequest {
|
|
17
51
|
threadId: string;
|
|
18
52
|
/** Backend execution ID supplied by Intelligence for imported non-UUID sessions. */
|
|
@@ -22,20 +56,41 @@ interface AgentRunnerRunRequest {
|
|
|
22
56
|
persistedInputMessages?: Message[];
|
|
23
57
|
/** Short-lived token scoped to this runner invocation. */
|
|
24
58
|
authToken?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Identity the run acts as. A runner that tracks owners records it on the
|
|
61
|
+
* Thread's first run and refuses a run from any other identity. `""` is the
|
|
62
|
+
* anonymous owner. When omitted, the run acts as {@link ɵSERVER_THREAD_OWNER}.
|
|
63
|
+
*/
|
|
64
|
+
ownerId?: string;
|
|
25
65
|
}
|
|
26
66
|
interface AgentRunnerConnectRequest {
|
|
27
67
|
threadId: string;
|
|
28
68
|
agentId?: string;
|
|
29
69
|
headers?: Record<string, string>;
|
|
30
70
|
joinCode?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Caller identity. A Thread owned by another identity is treated as unknown.
|
|
73
|
+
* When omitted, the call acts as {@link ɵSERVER_THREAD_OWNER}.
|
|
74
|
+
*/
|
|
75
|
+
ownerId?: string;
|
|
31
76
|
}
|
|
32
77
|
interface AgentRunnerIsRunningRequest {
|
|
33
78
|
threadId: string;
|
|
79
|
+
/**
|
|
80
|
+
* Caller identity. A Thread owned by another identity reports "not running".
|
|
81
|
+
* When omitted, the call acts as {@link ɵSERVER_THREAD_OWNER}.
|
|
82
|
+
*/
|
|
83
|
+
ownerId?: string;
|
|
34
84
|
}
|
|
35
85
|
interface AgentRunnerStopRequest {
|
|
36
86
|
threadId: string;
|
|
37
87
|
/** When present, stop only this exact run and never a newer run on the Thread. */
|
|
38
88
|
runId?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Caller identity. A run on a Thread owned by another identity is not
|
|
91
|
+
* stopped. When omitted, the call acts as {@link ɵSERVER_THREAD_OWNER}.
|
|
92
|
+
*/
|
|
93
|
+
ownerId?: string;
|
|
39
94
|
}
|
|
40
95
|
interface LocalThreadEndpointRecord {
|
|
41
96
|
id: string;
|
|
@@ -47,22 +102,51 @@ interface LocalThreadEndpointRecord {
|
|
|
47
102
|
createdAt: string;
|
|
48
103
|
updatedAt: string;
|
|
49
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Limits a local Thread endpoint call to the Threads of one owner. `""` is the
|
|
107
|
+
* anonymous owner. A call without a scope acts as
|
|
108
|
+
* {@link ɵSERVER_THREAD_OWNER}: it sees only Threads created server-side, never
|
|
109
|
+
* every Thread.
|
|
110
|
+
*/
|
|
111
|
+
interface LocalThreadEndpointScope {
|
|
112
|
+
ownerId: string;
|
|
113
|
+
}
|
|
50
114
|
interface LocalThreadEndpointRunner extends AgentRunner {
|
|
51
115
|
readonly ɵsupportsLocalThreadEndpoints: true;
|
|
52
|
-
listThreads(): LocalThreadEndpointRecord[];
|
|
53
|
-
getThreadMessages(threadId: string): Message[];
|
|
54
|
-
getThreadEvents(threadId: string): BaseEvent[];
|
|
55
|
-
getThreadState(threadId: string): Record<string, unknown> | null;
|
|
56
|
-
clearThreads(): void;
|
|
116
|
+
listThreads(scope?: LocalThreadEndpointScope): LocalThreadEndpointRecord[];
|
|
117
|
+
getThreadMessages(threadId: string, scope?: LocalThreadEndpointScope): Message[];
|
|
118
|
+
getThreadEvents(threadId: string, scope?: LocalThreadEndpointScope): BaseEvent[];
|
|
119
|
+
getThreadState(threadId: string, scope?: LocalThreadEndpointScope): Record<string, unknown> | null;
|
|
120
|
+
clearThreads(scope?: LocalThreadEndpointScope): void;
|
|
121
|
+
/** See {@link ThreadOwnershipRunner.isThreadAccessible}. */
|
|
122
|
+
isThreadAccessible(threadId: string, scope: LocalThreadEndpointScope): boolean;
|
|
57
123
|
}
|
|
58
124
|
declare function supportsLocalThreadEndpoints(runner: AgentRunner): runner is LocalThreadEndpointRunner;
|
|
125
|
+
/**
|
|
126
|
+
* A runner that records each Thread's owner and enforces it. Implementing
|
|
127
|
+
* `isThreadAccessible` is the promise that `run`, `connect`, `stop` and
|
|
128
|
+
* `isRunning` honor `ownerId` the same way: a call never reaches a Thread that
|
|
129
|
+
* another owner holds.
|
|
130
|
+
*/
|
|
131
|
+
interface ThreadOwnershipRunner extends AgentRunner {
|
|
132
|
+
/** False when the Thread id is held by an owner other than `scope`'s. */
|
|
133
|
+
isThreadAccessible(threadId: string, scope: LocalThreadEndpointScope): boolean | Promise<boolean>;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* True when `runner` enforces Thread owners. Checks the method itself, so a
|
|
137
|
+
* runner built against an older interface (one that sets the endpoint flag
|
|
138
|
+
* but has no `isThreadAccessible`) is not taken to enforce them.
|
|
139
|
+
*/
|
|
140
|
+
declare function enforcesThreadOwnership(runner: AgentRunner): runner is ThreadOwnershipRunner;
|
|
59
141
|
declare abstract class AgentRunner {
|
|
60
142
|
readonly ɵsupportsLocalThreadEndpoints?: boolean;
|
|
143
|
+
/** See {@link ThreadOwnershipRunner}. Optional: not every runner tracks owners. */
|
|
144
|
+
isThreadAccessible?(threadId: string, scope: LocalThreadEndpointScope): boolean | Promise<boolean>;
|
|
61
145
|
abstract run(request: AgentRunnerRunRequest): Observable<BaseEvent>;
|
|
62
146
|
abstract connect(request: AgentRunnerConnectRequest): Observable<BaseEvent>;
|
|
63
147
|
abstract isRunning(request: AgentRunnerIsRunningRequest): Promise<boolean>;
|
|
64
148
|
abstract stop(request: AgentRunnerStopRequest): Promise<boolean | undefined>;
|
|
65
149
|
}
|
|
66
150
|
//#endregion
|
|
67
|
-
export { AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest, LocalThreadEndpointRecord, LocalThreadEndpointRunner, ThreadAlreadyRunningError, supportsLocalThreadEndpoints };
|
|
151
|
+
export { AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest, LocalThreadEndpointRecord, LocalThreadEndpointRunner, LocalThreadEndpointScope, THREAD_ACCESS_DENIED_ERROR_CODE, ThreadAccessDeniedError, ThreadAlreadyRunningError, ThreadOwnershipRunner, enforcesThreadOwnership, isThreadAccessDeniedError, supportsLocalThreadEndpoints, ɵSERVER_THREAD_OWNER, ɵresolveThreadOwner };
|
|
68
152
|
//# sourceMappingURL=agent-runner.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-runner.d.mts","names":[],"sources":["../../../../src/v2/runtime/runner/agent-runner.ts"],"mappings":";;;;;;;AAeA;;;;cAAa,yBAAA,SAAkC,KAAA;EAAA,SACpC,IAAA
|
|
1
|
+
{"version":3,"file":"agent-runner.d.mts","names":[],"sources":["../../../../src/v2/runtime/runner/agent-runner.ts"],"mappings":";;;;;;;AAeA;;;;cAAa,yBAAA,SAAkC,KAAA;EAAA,SACpC,IAAA;;;;cASE,+BAAA;;;;;AAcb;;;;;;;;cAAa,uBAAA,SAAgC,KAAA;EAAA,SAClC,IAAA;;;;iBASK,yBAAA,CAA0B,KAAA;AAkB1C;;;;;AAGA;;;;;AAIA;AAPA,cAAa,oBAAA;;iBAGG,mBAAA,CAAoB,OAAA;AAAA,UAInB,qBAAA;EACf,QAAA;EAKgC;EAHhC,eAAA;EACA,KAAA,EAAO,aAAA;EACP,KAAA,EAAO,aAAA;EACP,sBAAA,GAAyB,OAAA;EAFlB;EAIP,SAAA;EAHO;;;;;EASP,OAAA;AAAA;AAAA,UAGe,yBAAA;EACf,QAAA;EACA,OAAA;EACA,OAAA,GAAU,MAAA;EACV,QAAA;EAFA;;;;EAOA,OAAA;AAAA;AAAA,UAGe,2BAAA;EACf,QAAA;EAD0C;;;;EAM1C,OAAA;AAAA;AAAA,UAGe,sBAAA;EACf,QAAA;EAAA;EAEA,KAAA;EAKA;;;AAGF;EAHE,OAAA;AAAA;AAAA,UAGe,yBAAA;EACf,EAAA;EACA,IAAA;EACA,OAAA;EACA,cAAA;EACA,WAAA;EACA,QAAA;EACA,SAAA;EACA,SAAA;AAAA;;AASF;;;;;UAAiB,wBAAA;EACf,OAAA;AAAA;AAAA,UAGe,yBAAA,SAAkC,WAAA;EAAA,SACxC,6BAAA;EACT,WAAA,CAAY,KAAA,GAAQ,wBAAA,GAA2B,yBAAA;EAC/C,iBAAA,CACE,QAAA,UACA,KAAA,GAAQ,wBAAA,GACP,OAAA;EACH,eAAA,CACE,QAAA,UACA,KAAA,GAAQ,wBAAA,GACP,SAAA;EACH,cAAA,CACE,QAAA,UACA,KAAA,GAAQ,wBAAA,GACP,MAAA;EACH,YAAA,CAAa,KAAA,GAAQ,wBAAA;EADlB;EAGH,kBAAA,CACE,QAAA,UACA,KAAA,EAAO,wBAAA;AAAA;AAAA,iBAIK,4BAAA,CACd,MAAA,EAAQ,WAAA,GACP,MAAA,IAAU,yBAAA;;;;;;;UAUI,qBAAA,SAA8B,WAAA;EAjCE;EAmC/C,kBAAA,CACE,QAAA,UACA,KAAA,EAAO,wBAAA,aACI,OAAA;AAAA;;;;;;iBAQC,uBAAA,CACd,MAAA,EAAQ,WAAA,GACP,MAAA,IAAU,qBAAA;AAAA,uBAIS,WAAA;EAAA,SACX,6BAAA;EA5CT;EA+CA,kBAAA,CAAA,CACE,QAAA,UACA,KAAA,EAAO,wBAAA,aACI,OAAA;EAAA,SAEJ,GAAA,CAAI,OAAA,EAAS,qBAAA,GAAwB,UAAA,CAAW,SAAA;EAAA,SAChD,OAAA,CAAQ,OAAA,EAAS,yBAAA,GAA4B,UAAA,CAAW,SAAA;EAAA,SACxD,SAAA,CAAU,OAAA,EAAS,2BAAA,GAA8B,OAAA;EAAA,SACjD,IAAA,CAAK,OAAA,EAAS,sBAAA,GAAyB,OAAA;AAAA"}
|
|
@@ -15,11 +15,60 @@ var ThreadAlreadyRunningError = class extends Error {
|
|
|
15
15
|
this.name = "ThreadAlreadyRunningError";
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
|
+
/** `code` of {@link ThreadAccessDeniedError}, also sent on the SSE `RUN_ERROR`. */
|
|
19
|
+
const THREAD_ACCESS_DENIED_ERROR_CODE = "THREAD_ACCESS_DENIED";
|
|
20
|
+
/**
|
|
21
|
+
* Thrown by a runner when a run targets a Thread that another identity owns.
|
|
22
|
+
*
|
|
23
|
+
* Defense in depth: the run handler checks `isThreadAccessible` first and
|
|
24
|
+
* refuses with an HTTP error, so the runner throws this only when another
|
|
25
|
+
* identity claims the Thread between that check and the run, or for direct
|
|
26
|
+
* runner callers. A synchronous throw from `run()` is still mapped to the
|
|
27
|
+
* HTTP error; a later one reaches the client as a `RUN_ERROR` with
|
|
28
|
+
* {@link THREAD_ACCESS_DENIED_ERROR_CODE}. Neither is reported as an agent
|
|
29
|
+
* failure. Matched on `code`, so a copy of this class from another package
|
|
30
|
+
* version still counts.
|
|
31
|
+
*/
|
|
32
|
+
var ThreadAccessDeniedError = class extends Error {
|
|
33
|
+
constructor() {
|
|
34
|
+
super("Thread access denied");
|
|
35
|
+
this.code = THREAD_ACCESS_DENIED_ERROR_CODE;
|
|
36
|
+
this.name = "ThreadAccessDeniedError";
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
/** True for a {@link ThreadAccessDeniedError}, from any package version. */
|
|
40
|
+
function isThreadAccessDeniedError(error) {
|
|
41
|
+
return error instanceof Error && error.code === THREAD_ACCESS_DENIED_ERROR_CODE;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Owner of a Thread created, or reached, by a runner call that names no owner:
|
|
45
|
+
* a run, connect, stop or isRunning without `ownerId`, or a Thread endpoint call
|
|
46
|
+
* without a scope. Such calls come only from trusted server-side code (for
|
|
47
|
+
* example a Channel listener), and they act as this one server identity.
|
|
48
|
+
*
|
|
49
|
+
* No HTTP caller can act as it: request identities are `""` (anonymous) or an
|
|
50
|
+
* id that `identifyUser` returned, and a valid id cannot hold a NUL character.
|
|
51
|
+
* So an omitted owner never means "every Thread", and a Thread created
|
|
52
|
+
* server-side is never reachable by an anonymous caller.
|
|
53
|
+
*/
|
|
54
|
+
const ɵSERVER_THREAD_OWNER = "\0server";
|
|
55
|
+
/** The owner a runner call acts as: `ownerId`, or the server owner when omitted. */
|
|
56
|
+
function ɵresolveThreadOwner(ownerId) {
|
|
57
|
+
return ownerId ?? ɵSERVER_THREAD_OWNER;
|
|
58
|
+
}
|
|
18
59
|
function supportsLocalThreadEndpoints(runner) {
|
|
19
60
|
return runner.ɵsupportsLocalThreadEndpoints === true;
|
|
20
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* True when `runner` enforces Thread owners. Checks the method itself, so a
|
|
64
|
+
* runner built against an older interface (one that sets the endpoint flag
|
|
65
|
+
* but has no `isThreadAccessible`) is not taken to enforce them.
|
|
66
|
+
*/
|
|
67
|
+
function enforcesThreadOwnership(runner) {
|
|
68
|
+
return typeof runner.isThreadAccessible === "function";
|
|
69
|
+
}
|
|
21
70
|
var AgentRunner = class {};
|
|
22
71
|
|
|
23
72
|
//#endregion
|
|
24
|
-
export { AgentRunner, ThreadAlreadyRunningError, supportsLocalThreadEndpoints };
|
|
73
|
+
export { AgentRunner, THREAD_ACCESS_DENIED_ERROR_CODE, ThreadAccessDeniedError, ThreadAlreadyRunningError, enforcesThreadOwnership, isThreadAccessDeniedError, supportsLocalThreadEndpoints, ɵSERVER_THREAD_OWNER, ɵresolveThreadOwner };
|
|
25
74
|
//# sourceMappingURL=agent-runner.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-runner.mjs","names":[],"sources":["../../../../src/v2/runtime/runner/agent-runner.ts"],"sourcesContent":["import type {\n AbstractAgent,\n BaseEvent,\n Message,\n RunAgentInput,\n} from \"@ag-ui/client\";\nimport type { Observable } from \"rxjs\";\nimport { THREAD_ALREADY_RUNNING_ERROR_CODE } from \"@copilotkit/shared\";\n\n/**\n * Thrown by a runner when the thread already has a run in flight. The SSE\n * handler sends it to the client as a `RUN_ERROR` with\n * {@link THREAD_ALREADY_RUNNING_ERROR_CODE}, matched on `code` so a copy of\n * this class from another package version still counts.\n */\nexport class ThreadAlreadyRunningError extends Error {\n readonly code = THREAD_ALREADY_RUNNING_ERROR_CODE;\n\n constructor() {\n super(\"Thread already running\");\n this.name = \"ThreadAlreadyRunningError\";\n }\n}\n\nexport interface AgentRunnerRunRequest {\n threadId: string;\n /** Backend execution ID supplied by Intelligence for imported non-UUID sessions. */\n backendThreadId?: string;\n agent: AbstractAgent;\n input: RunAgentInput;\n persistedInputMessages?: Message[];\n /** Short-lived token scoped to this runner invocation. */\n authToken?: string;\n}\n\nexport interface AgentRunnerConnectRequest {\n threadId: string;\n agentId?: string;\n headers?: Record<string, string>;\n joinCode?: string;\n}\n\nexport interface AgentRunnerIsRunningRequest {\n threadId: string;\n}\n\nexport interface AgentRunnerStopRequest {\n threadId: string;\n /** When present, stop only this exact run and never a newer run on the Thread. */\n runId?: string;\n}\n\nexport interface LocalThreadEndpointRecord {\n id: string;\n name: string | null;\n agentId: string;\n organizationId: string;\n createdById: string;\n archived: boolean;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface LocalThreadEndpointRunner extends AgentRunner {\n readonly ɵsupportsLocalThreadEndpoints: true;\n listThreads(): LocalThreadEndpointRecord[];\n getThreadMessages(threadId: string): Message[];\n getThreadEvents(threadId: string): BaseEvent[];\n getThreadState(threadId: string): Record<string, unknown> | null;\n clearThreads(): void;\n}\n\nexport function supportsLocalThreadEndpoints(\n runner: AgentRunner,\n): runner is LocalThreadEndpointRunner {\n return runner.ɵsupportsLocalThreadEndpoints === true;\n}\n\nexport abstract class AgentRunner {\n readonly ɵsupportsLocalThreadEndpoints?: boolean;\n\n abstract run(request: AgentRunnerRunRequest): Observable<BaseEvent>;\n abstract connect(request: AgentRunnerConnectRequest): Observable<BaseEvent>;\n abstract isRunning(request: AgentRunnerIsRunningRequest): Promise<boolean>;\n abstract stop(request: AgentRunnerStopRequest): Promise<boolean | undefined>;\n}\n"],"mappings":";;;;;;;;;;AAeA,IAAa,4BAAb,cAA+C,MAAM;CAGnD,cAAc;AACZ,QAAM,yBAAyB;cAHjB;AAId,OAAK,OAAO
|
|
1
|
+
{"version":3,"file":"agent-runner.mjs","names":[],"sources":["../../../../src/v2/runtime/runner/agent-runner.ts"],"sourcesContent":["import type {\n AbstractAgent,\n BaseEvent,\n Message,\n RunAgentInput,\n} from \"@ag-ui/client\";\nimport type { Observable } from \"rxjs\";\nimport { THREAD_ALREADY_RUNNING_ERROR_CODE } from \"@copilotkit/shared\";\n\n/**\n * Thrown by a runner when the thread already has a run in flight. The SSE\n * handler sends it to the client as a `RUN_ERROR` with\n * {@link THREAD_ALREADY_RUNNING_ERROR_CODE}, matched on `code` so a copy of\n * this class from another package version still counts.\n */\nexport class ThreadAlreadyRunningError extends Error {\n readonly code = THREAD_ALREADY_RUNNING_ERROR_CODE;\n\n constructor() {\n super(\"Thread already running\");\n this.name = \"ThreadAlreadyRunningError\";\n }\n}\n\n/** `code` of {@link ThreadAccessDeniedError}, also sent on the SSE `RUN_ERROR`. */\nexport const THREAD_ACCESS_DENIED_ERROR_CODE = \"THREAD_ACCESS_DENIED\";\n\n/**\n * Thrown by a runner when a run targets a Thread that another identity owns.\n *\n * Defense in depth: the run handler checks `isThreadAccessible` first and\n * refuses with an HTTP error, so the runner throws this only when another\n * identity claims the Thread between that check and the run, or for direct\n * runner callers. A synchronous throw from `run()` is still mapped to the\n * HTTP error; a later one reaches the client as a `RUN_ERROR` with\n * {@link THREAD_ACCESS_DENIED_ERROR_CODE}. Neither is reported as an agent\n * failure. Matched on `code`, so a copy of this class from another package\n * version still counts.\n */\nexport class ThreadAccessDeniedError extends Error {\n readonly code = THREAD_ACCESS_DENIED_ERROR_CODE;\n\n constructor() {\n super(\"Thread access denied\");\n this.name = \"ThreadAccessDeniedError\";\n }\n}\n\n/** True for a {@link ThreadAccessDeniedError}, from any package version. */\nexport function isThreadAccessDeniedError(error: unknown): boolean {\n return (\n error instanceof Error &&\n (error as { code?: unknown }).code === THREAD_ACCESS_DENIED_ERROR_CODE\n );\n}\n\n/**\n * Owner of a Thread created, or reached, by a runner call that names no owner:\n * a run, connect, stop or isRunning without `ownerId`, or a Thread endpoint call\n * without a scope. Such calls come only from trusted server-side code (for\n * example a Channel listener), and they act as this one server identity.\n *\n * No HTTP caller can act as it: request identities are `\"\"` (anonymous) or an\n * id that `identifyUser` returned, and a valid id cannot hold a NUL character.\n * So an omitted owner never means \"every Thread\", and a Thread created\n * server-side is never reachable by an anonymous caller.\n */\nexport const ɵSERVER_THREAD_OWNER = \"\\u0000server\";\n\n/** The owner a runner call acts as: `ownerId`, or the server owner when omitted. */\nexport function ɵresolveThreadOwner(ownerId: string | undefined): string {\n return ownerId ?? ɵSERVER_THREAD_OWNER;\n}\n\nexport interface AgentRunnerRunRequest {\n threadId: string;\n /** Backend execution ID supplied by Intelligence for imported non-UUID sessions. */\n backendThreadId?: string;\n agent: AbstractAgent;\n input: RunAgentInput;\n persistedInputMessages?: Message[];\n /** Short-lived token scoped to this runner invocation. */\n authToken?: string;\n /**\n * Identity the run acts as. A runner that tracks owners records it on the\n * Thread's first run and refuses a run from any other identity. `\"\"` is the\n * anonymous owner. When omitted, the run acts as {@link ɵSERVER_THREAD_OWNER}.\n */\n ownerId?: string;\n}\n\nexport interface AgentRunnerConnectRequest {\n threadId: string;\n agentId?: string;\n headers?: Record<string, string>;\n joinCode?: string;\n /**\n * Caller identity. A Thread owned by another identity is treated as unknown.\n * When omitted, the call acts as {@link ɵSERVER_THREAD_OWNER}.\n */\n ownerId?: string;\n}\n\nexport interface AgentRunnerIsRunningRequest {\n threadId: string;\n /**\n * Caller identity. A Thread owned by another identity reports \"not running\".\n * When omitted, the call acts as {@link ɵSERVER_THREAD_OWNER}.\n */\n ownerId?: string;\n}\n\nexport interface AgentRunnerStopRequest {\n threadId: string;\n /** When present, stop only this exact run and never a newer run on the Thread. */\n runId?: string;\n /**\n * Caller identity. A run on a Thread owned by another identity is not\n * stopped. When omitted, the call acts as {@link ɵSERVER_THREAD_OWNER}.\n */\n ownerId?: string;\n}\n\nexport interface LocalThreadEndpointRecord {\n id: string;\n name: string | null;\n agentId: string;\n organizationId: string;\n createdById: string;\n archived: boolean;\n createdAt: string;\n updatedAt: string;\n}\n\n/**\n * Limits a local Thread endpoint call to the Threads of one owner. `\"\"` is the\n * anonymous owner. A call without a scope acts as\n * {@link ɵSERVER_THREAD_OWNER}: it sees only Threads created server-side, never\n * every Thread.\n */\nexport interface LocalThreadEndpointScope {\n ownerId: string;\n}\n\nexport interface LocalThreadEndpointRunner extends AgentRunner {\n readonly ɵsupportsLocalThreadEndpoints: true;\n listThreads(scope?: LocalThreadEndpointScope): LocalThreadEndpointRecord[];\n getThreadMessages(\n threadId: string,\n scope?: LocalThreadEndpointScope,\n ): Message[];\n getThreadEvents(\n threadId: string,\n scope?: LocalThreadEndpointScope,\n ): BaseEvent[];\n getThreadState(\n threadId: string,\n scope?: LocalThreadEndpointScope,\n ): Record<string, unknown> | null;\n clearThreads(scope?: LocalThreadEndpointScope): void;\n /** See {@link ThreadOwnershipRunner.isThreadAccessible}. */\n isThreadAccessible(\n threadId: string,\n scope: LocalThreadEndpointScope,\n ): boolean;\n}\n\nexport function supportsLocalThreadEndpoints(\n runner: AgentRunner,\n): runner is LocalThreadEndpointRunner {\n return runner.ɵsupportsLocalThreadEndpoints === true;\n}\n\n/**\n * A runner that records each Thread's owner and enforces it. Implementing\n * `isThreadAccessible` is the promise that `run`, `connect`, `stop` and\n * `isRunning` honor `ownerId` the same way: a call never reaches a Thread that\n * another owner holds.\n */\nexport interface ThreadOwnershipRunner extends AgentRunner {\n /** False when the Thread id is held by an owner other than `scope`'s. */\n isThreadAccessible(\n threadId: string,\n scope: LocalThreadEndpointScope,\n ): boolean | Promise<boolean>;\n}\n\n/**\n * True when `runner` enforces Thread owners. Checks the method itself, so a\n * runner built against an older interface (one that sets the endpoint flag\n * but has no `isThreadAccessible`) is not taken to enforce them.\n */\nexport function enforcesThreadOwnership(\n runner: AgentRunner,\n): runner is ThreadOwnershipRunner {\n return typeof runner.isThreadAccessible === \"function\";\n}\n\nexport abstract class AgentRunner {\n readonly ɵsupportsLocalThreadEndpoints?: boolean;\n\n /** See {@link ThreadOwnershipRunner}. Optional: not every runner tracks owners. */\n isThreadAccessible?(\n threadId: string,\n scope: LocalThreadEndpointScope,\n ): boolean | Promise<boolean>;\n\n abstract run(request: AgentRunnerRunRequest): Observable<BaseEvent>;\n abstract connect(request: AgentRunnerConnectRequest): Observable<BaseEvent>;\n abstract isRunning(request: AgentRunnerIsRunningRequest): Promise<boolean>;\n abstract stop(request: AgentRunnerStopRequest): Promise<boolean | undefined>;\n}\n"],"mappings":";;;;;;;;;;AAeA,IAAa,4BAAb,cAA+C,MAAM;CAGnD,cAAc;AACZ,QAAM,yBAAyB;cAHjB;AAId,OAAK,OAAO;;;;AAKhB,MAAa,kCAAkC;;;;;;;;;;;;;AAc/C,IAAa,0BAAb,cAA6C,MAAM;CAGjD,cAAc;AACZ,QAAM,uBAAuB;cAHf;AAId,OAAK,OAAO;;;;AAKhB,SAAgB,0BAA0B,OAAyB;AACjE,QACE,iBAAiB,SAChB,MAA6B,SAAS;;;;;;;;;;;;;AAe3C,MAAa,uBAAuB;;AAGpC,SAAgB,oBAAoB,SAAqC;AACvE,QAAO,WAAW;;AAgGpB,SAAgB,6BACd,QACqC;AACrC,QAAO,OAAO,kCAAkC;;;;;;;AAsBlD,SAAgB,wBACd,QACiC;AACjC,QAAO,OAAO,OAAO,uBAAuB;;AAG9C,IAAsB,cAAtB,MAAkC"}
|