@fabric-harness/sdk 6.1.0 → 6.3.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/NOTICE +1 -1
- package/README.md +9 -9
- package/connector-spec/channel.md +2 -2
- package/connector-spec/sandbox.md +1 -1
- package/connector-spec/tooling.md +1 -1
- package/connector-spec/voice-telephony.md +1 -1
- package/dist/action.d.ts +2 -2
- package/dist/action.js +1 -1
- package/dist/agent-route.d.ts +76 -0
- package/dist/agent-route.d.ts.map +1 -0
- package/dist/agent-route.js +78 -0
- package/dist/agent-route.js.map +1 -0
- package/dist/agent-router.d.ts +128 -0
- package/dist/agent-router.d.ts.map +1 -0
- package/dist/agent-router.js +193 -0
- package/dist/agent-router.js.map +1 -0
- package/dist/ai-gateway.d.ts +1 -1
- package/dist/ai-gateway.js +1 -1
- package/dist/attachment-store.d.ts +3 -3
- package/dist/attachment-store.js +2 -2
- package/dist/channel.d.ts +3 -3
- package/dist/channel.js +2 -2
- package/dist/conversation-projection.d.ts +2 -2
- package/dist/conversation-projection.js +2 -2
- package/dist/conversation-stream.d.ts +5 -5
- package/dist/conversation-stream.js +1 -1
- package/dist/cost-budget.d.ts +3 -3
- package/dist/cost-budget.js +1 -1
- package/dist/delivered-message.d.ts +3 -3
- package/dist/error.js +2 -2
- package/dist/error.js.map +1 -1
- package/dist/events.d.ts +1 -1
- package/dist/events.js +1 -1
- package/dist/filesystem-source.d.ts +3 -3
- package/dist/filesystem-source.js +1 -1
- package/dist/governed-voice.d.ts +55 -0
- package/dist/governed-voice.d.ts.map +1 -0
- package/dist/governed-voice.js +357 -0
- package/dist/governed-voice.js.map +1 -0
- package/dist/history.d.ts +3 -3
- package/dist/history.js +3 -3
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/langfuse.d.ts +2 -2
- package/dist/local-confinement.d.ts +31 -0
- package/dist/local-confinement.d.ts.map +1 -0
- package/dist/local-confinement.js +297 -0
- package/dist/local-confinement.js.map +1 -0
- package/dist/loop.d.ts +10 -0
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js.map +1 -1
- package/dist/mcp.d.ts +1 -0
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +2 -0
- package/dist/mcp.js.map +1 -1
- package/dist/model-pricing.d.ts +7 -4
- package/dist/model-pricing.d.ts.map +1 -1
- package/dist/model-pricing.js +8 -7
- package/dist/model-pricing.js.map +1 -1
- package/dist/model.d.ts +44 -1
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +123 -13
- package/dist/model.js.map +1 -1
- package/dist/persistent-agent.d.ts +1 -1
- package/dist/pi-loop-runtime.d.ts.map +1 -1
- package/dist/pi-loop-runtime.js +2 -6
- package/dist/pi-loop-runtime.js.map +1 -1
- package/dist/policied-sandbox.js +5 -5
- package/dist/policied-sandbox.js.map +1 -1
- package/dist/policy.d.ts +1 -1
- package/dist/rate-limiter.d.ts +2 -2
- package/dist/rate-limiter.js +2 -2
- package/dist/retrieval.d.ts +1 -1
- package/dist/sandbox-ref.d.ts +2 -2
- package/dist/sandbox-ref.d.ts.map +1 -1
- package/dist/sandbox-ref.js +9 -6
- package/dist/sandbox-ref.js.map +1 -1
- package/dist/sandbox.d.ts +10 -0
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +28 -12
- package/dist/sandbox.js.map +1 -1
- package/dist/session-memory.d.ts +4 -3
- package/dist/session-memory.d.ts.map +1 -1
- package/dist/session-memory.js +4 -3
- package/dist/session-memory.js.map +1 -1
- package/dist/session.d.ts +19 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +76 -6
- package/dist/session.js.map +1 -1
- package/dist/skill-definition.d.ts +40 -0
- package/dist/skill-definition.d.ts.map +1 -0
- package/dist/skill-definition.js +37 -0
- package/dist/skill-definition.js.map +1 -0
- package/dist/store.d.ts +1 -1
- package/dist/store.js +1 -1
- package/dist/strict.d.ts +12 -3
- package/dist/strict.d.ts.map +1 -1
- package/dist/strict.js +6 -1
- package/dist/strict.js.map +1 -1
- package/dist/submission-runner.d.ts +1 -1
- package/dist/submission-runner.d.ts.map +1 -1
- package/dist/submission-runner.js +15 -1
- package/dist/submission-runner.js.map +1 -1
- package/dist/submission-state.d.ts +3 -3
- package/dist/submission-state.js +3 -3
- package/dist/submission-store.d.ts +4 -4
- package/dist/submission-store.js +2 -2
- package/dist/suspending-sandbox.js +3 -3
- package/dist/suspending-sandbox.js.map +1 -1
- package/dist/testing.d.ts +2 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/tool-execution.d.ts +11 -0
- package/dist/tool-execution.d.ts.map +1 -0
- package/dist/tool-execution.js +36 -0
- package/dist/tool-execution.js.map +1 -0
- package/dist/tools.d.ts +6 -0
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +5 -0
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/vercel-ai-gateway.d.ts +4 -4
- package/dist/vercel-ai-gateway.js +4 -4
- package/dist/voice-openai-realtime.d.ts +2 -2
- package/dist/voice-openai-realtime.d.ts.map +1 -1
- package/dist/voice-openai-realtime.js +48 -41
- package/dist/voice-openai-realtime.js.map +1 -1
- package/dist/voice-pipeline.d.ts +3 -0
- package/dist/voice-pipeline.d.ts.map +1 -1
- package/dist/voice-pipeline.js +71 -23
- package/dist/voice-pipeline.js.map +1 -1
- package/dist/voice-stt-cartesia.d.ts +1 -0
- package/dist/voice-stt-cartesia.d.ts.map +1 -1
- package/dist/voice-stt-cartesia.js +8 -1
- package/dist/voice-stt-cartesia.js.map +1 -1
- package/dist/voice-stt-deepgram.d.ts +1 -0
- package/dist/voice-stt-deepgram.d.ts.map +1 -1
- package/dist/voice-stt-deepgram.js +8 -1
- package/dist/voice-stt-deepgram.js.map +1 -1
- package/dist/voice-stt.d.ts +2 -0
- package/dist/voice-stt.d.ts.map +1 -1
- package/dist/voice-tts-cartesia.d.ts +1 -0
- package/dist/voice-tts-cartesia.d.ts.map +1 -1
- package/dist/voice-tts-cartesia.js +2 -1
- package/dist/voice-tts-cartesia.js.map +1 -1
- package/dist/voice-tts-elevenlabs.d.ts +1 -0
- package/dist/voice-tts-elevenlabs.d.ts.map +1 -1
- package/dist/voice-tts-elevenlabs.js +4 -1
- package/dist/voice-tts-elevenlabs.js.map +1 -1
- package/dist/voice-tts.d.ts +2 -0
- package/dist/voice-tts.d.ts.map +1 -1
- package/dist/voice-ws-client.d.ts +6 -4
- package/dist/voice-ws-client.d.ts.map +1 -1
- package/dist/voice-ws-client.js +11 -6
- package/dist/voice-ws-client.js.map +1 -1
- package/dist/voice-ws-shared.d.ts +10 -3
- package/dist/voice-ws-shared.d.ts.map +1 -1
- package/dist/voice-ws-shared.js +45 -9
- package/dist/voice-ws-shared.js.map +1 -1
- package/dist/voice.d.ts +6 -7
- package/dist/voice.d.ts.map +1 -1
- package/dist/webhook-subscription.d.ts +1 -1
- package/dist/ws-client.d.ts +1 -1
- package/package.json +14 -4
- package/types/markdown.d.ts +35 -0
package/NOTICE
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @fabric-harness/sdk
|
|
2
2
|
|
|
3
|
-
> Core SDK for [
|
|
3
|
+
> Core SDK for [TechFabric Harness](https://github.com/Fabric-Pro/fabric-harness) — a headless TypeScript framework for building durable, deployable autonomous agents.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -102,15 +102,15 @@ use direct provider endpoints and never silently fall back to a gateway or mock
|
|
|
102
102
|
|
|
103
103
|
## Documentation
|
|
104
104
|
|
|
105
|
-
- [Headless agents with the minimal entrypoint](https://harness.
|
|
106
|
-
- [SDK entrypoints, runtimes, and targets](https://harness.
|
|
107
|
-
- [Runtime modes](https://harness.
|
|
108
|
-
- [Dynamic agents and hooks](https://harness.
|
|
109
|
-
- [Filesystem sources](https://harness.
|
|
110
|
-
- [Policies and approvals](https://harness.
|
|
111
|
-
- [Telemetry](https://harness.
|
|
105
|
+
- [Headless agents with the minimal entrypoint](https://harness.techfabric.com/docs/getting-started/headless-mode)
|
|
106
|
+
- [SDK entrypoints, runtimes, and targets](https://harness.techfabric.com/docs/reference/sdk-entrypoints-runtimes-targets)
|
|
107
|
+
- [Runtime modes](https://harness.techfabric.com/docs/reference/runtime-modes) — including the direct `temporalSessionRuntime` API.
|
|
108
|
+
- [Dynamic agents and hooks](https://harness.techfabric.com/docs/building/dynamic-agents)
|
|
109
|
+
- [Filesystem sources](https://harness.techfabric.com/docs/reference/filesystem-sources) — `session.mount()` and source connectors.
|
|
110
|
+
- [Policies and approvals](https://harness.techfabric.com/docs/reference/policies-approvals) — capability policy, network policy, mount permissions, custom approvals.
|
|
111
|
+
- [Telemetry](https://harness.techfabric.com/docs/reference/telemetry) — events, transports, metrics.
|
|
112
112
|
- [Roadmap](https://github.com/Fabric-Pro/fabric-harness/blob/main/docs/ROADMAP.md)
|
|
113
|
-
- [Full reference](https://harness.
|
|
113
|
+
- [Full reference](https://harness.techfabric.com/docs)
|
|
114
114
|
|
|
115
115
|
## License
|
|
116
116
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
<!-- Canonical
|
|
1
|
+
<!-- Canonical TechFabric Harness channel connector contract. Shipped with @fabric-harness/sdk. -->
|
|
2
2
|
|
|
3
|
-
#
|
|
3
|
+
# TechFabric Harness Channel Connector Spec
|
|
4
4
|
|
|
5
5
|
A channel turns an authenticated provider event into a durable dispatch to a persistent agent. Produce a TypeScript module under `.fabricharness/channels/<provider>.ts` that exports a `Channel` created with `defineChannel()`.
|
|
6
6
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Shipped with @fabric-harness/sdk so it's available offline.
|
|
4
4
|
|
|
5
5
|
Mirrored at the docs site:
|
|
6
|
-
https://harness.
|
|
6
|
+
https://harness.techfabric.com/docs/building/sandbox-connectors
|
|
7
7
|
|
|
8
8
|
Raw GitHub URL (must remain valid):
|
|
9
9
|
https://raw.githubusercontent.com/Fabric-Pro/fabric-harness/main/packages/sdk/connector-spec/sandbox.md
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# TechFabric Harness Tooling Connector Spec
|
|
2
2
|
|
|
3
3
|
A tooling connector observes Fabric events, traces, metrics, or eval results without changing agent behavior. Produce a project-local module that uses public Fabric event, telemetry, or eval APIs.
|
|
4
4
|
|
|
@@ -124,7 +124,7 @@ The OpenAI Realtime server-side VAD detects when the caller starts speaking and
|
|
|
124
124
|
|
|
125
125
|
## Cost
|
|
126
126
|
|
|
127
|
-
Realtime audio is billed per audio token.
|
|
127
|
+
Realtime audio is billed per audio token. TechFabric Harness records `audioInputTokens` /
|
|
128
128
|
`audioOutputTokens` on `usage` and rolls them into `costUsd`. Use `gpt-realtime` as the stable
|
|
129
129
|
general-purpose model or `gpt-realtime-mini` when cost and latency matter more than maximum quality.
|
|
130
130
|
|
package/dist/action.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ declare const actionSymbol: unique symbol;
|
|
|
5
5
|
/**
|
|
6
6
|
* What an action runs against: the harness entry point (`init` can prompt
|
|
7
7
|
* models, spawn sessions, and call tools) plus the platform environment.
|
|
8
|
-
* Jobs, agents, and servers all satisfy this
|
|
8
|
+
* Jobs, agents, and servers all satisfy this. It is the harness slice of
|
|
9
9
|
* `FabricContext`.
|
|
10
10
|
*/
|
|
11
11
|
export interface ActionHost {
|
|
@@ -45,7 +45,7 @@ export declare class ActionError extends Error {
|
|
|
45
45
|
constructor(code: ActionError['code'], action: string, message: string, issues?: SchemaIssue[]);
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* Define an action
|
|
48
|
+
* Define an action, the harness-context counterpart to `defineTool`.
|
|
49
49
|
* A tool is a leaf capability the model calls; an action holds the harness
|
|
50
50
|
* (`context.init`) and can prompt, spawn sessions, and compose other work.
|
|
51
51
|
* Input/output use the harness `schema` builders and are validated on every
|
package/dist/action.js
CHANGED
|
@@ -13,7 +13,7 @@ export class ActionError extends Error {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Define an action
|
|
16
|
+
* Define an action, the harness-context counterpart to `defineTool`.
|
|
17
17
|
* A tool is a leaf capability the model calls; an action holds the harness
|
|
18
18
|
* (`context.init`) and can prompt, spawn sessions, and compose other work.
|
|
19
19
|
* Input/output use the harness `schema` builders and are validated on every
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The persistent-agent HTTP route contract, shared by every runtime target.
|
|
3
|
+
*
|
|
4
|
+
* Node boots `server.ts` directly; Cloudflare runs a worker generated by the
|
|
5
|
+
* build. Both must expose the same URLs, parse them the same way, and return
|
|
6
|
+
* the same admission receipt — a client cannot be expected to special-case the
|
|
7
|
+
* backend it happens to be talking to. Parsing and receipt construction live
|
|
8
|
+
* here so there is one definition rather than one per target.
|
|
9
|
+
*
|
|
10
|
+
* Runtime-neutral by construction: this module touches only URLs and plain
|
|
11
|
+
* objects, never a store, a submission runner, or a platform binding.
|
|
12
|
+
*/
|
|
13
|
+
/** Subroutes under `/agents/:name/:instanceId`. */
|
|
14
|
+
export type AgentRouteSection = "submissions" | "conversation" | "abort" | "schedules" | "stream";
|
|
15
|
+
export interface AgentRouteMatch {
|
|
16
|
+
/** Registered agent name, percent-decoded. */
|
|
17
|
+
agent: string;
|
|
18
|
+
/** Caller-chosen durable instance id, percent-decoded. */
|
|
19
|
+
instanceId: string;
|
|
20
|
+
/** Absent for the instance root (`POST`/`GET`/`DELETE`). */
|
|
21
|
+
section?: AgentRouteSection;
|
|
22
|
+
/** Trailing identifier, e.g. the submission id under `submissions`. */
|
|
23
|
+
resourceId?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Parse a pathname against the agent route surface.
|
|
27
|
+
*
|
|
28
|
+
* Returns `undefined` when the path is not an agent route, so a caller can
|
|
29
|
+
* fall through to its other route families. Percent-decoding happens here: a
|
|
30
|
+
* target that matched the raw segments would treat `ticket%2F1` as a different
|
|
31
|
+
* instance than the one the client addressed.
|
|
32
|
+
*/
|
|
33
|
+
export declare function matchAgentRoute(pathname: string): AgentRouteMatch | undefined;
|
|
34
|
+
/** Session name carried by `?session=`, defaulting to `default`. */
|
|
35
|
+
export declare function agentRouteSession(searchParams: URLSearchParams): string;
|
|
36
|
+
export interface AgentSubmissionReceiptInput {
|
|
37
|
+
submissionId: string;
|
|
38
|
+
agent: string;
|
|
39
|
+
instanceId: string;
|
|
40
|
+
session: string;
|
|
41
|
+
/**
|
|
42
|
+
* Stream position captured *before* admission, so reading from it returns
|
|
43
|
+
* this delivery and everything the agent produces answering it. A target
|
|
44
|
+
* that cannot determine the position must not substitute `"0"` — that
|
|
45
|
+
* silently re-reads the whole conversation on every send.
|
|
46
|
+
*/
|
|
47
|
+
offset: string;
|
|
48
|
+
/** Resolved persistent-instance generation, when the target has one. */
|
|
49
|
+
uid?: string;
|
|
50
|
+
/** ISO-8601 admission timestamp, when the target records one. */
|
|
51
|
+
acceptedAt?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Whether this target serves the SSE updates route. Targets without one
|
|
54
|
+
* omit `updatesUrl` rather than advertising a URL that 404s.
|
|
55
|
+
*/
|
|
56
|
+
updates?: boolean;
|
|
57
|
+
}
|
|
58
|
+
export interface AgentSubmissionReceipt {
|
|
59
|
+
submissionId: string;
|
|
60
|
+
uid?: string;
|
|
61
|
+
acceptedAt?: string;
|
|
62
|
+
streamUrl: string;
|
|
63
|
+
conversationUrl: string;
|
|
64
|
+
updatesUrl?: string;
|
|
65
|
+
offset: string;
|
|
66
|
+
}
|
|
67
|
+
/** Base path for one persistent instance, with both segments escaped. */
|
|
68
|
+
export declare function agentInstancePath(agent: string, instanceId: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* Build the `202` admission receipt.
|
|
71
|
+
*
|
|
72
|
+
* `streamUrl` and `conversationUrl` are the same URL; the former is retained
|
|
73
|
+
* for compatibility with clients written against the earlier shape.
|
|
74
|
+
*/
|
|
75
|
+
export declare function agentSubmissionReceipt(input: AgentSubmissionReceiptInput): AgentSubmissionReceipt;
|
|
76
|
+
//# sourceMappingURL=agent-route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-route.d.ts","sourceRoot":"","sources":["../src/agent-route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,mDAAmD;AACnD,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG,cAAc,GAAG,OAAO,GAAG,WAAW,GAAG,QAAQ,CAAC;AAKlG,MAAM,WAAW,eAAe;IAC9B,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,uEAAuE;IACvE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAuB7E;AAED,oEAAoE;AACpE,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,eAAe,GAAG,MAAM,CAGvE;AAED,MAAM,WAAW,2BAA2B;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,yEAAyE;AACzE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAE3E;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,2BAA2B,GAAG,sBAAsB,CAajG"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The persistent-agent HTTP route contract, shared by every runtime target.
|
|
3
|
+
*
|
|
4
|
+
* Node boots `server.ts` directly; Cloudflare runs a worker generated by the
|
|
5
|
+
* build. Both must expose the same URLs, parse them the same way, and return
|
|
6
|
+
* the same admission receipt — a client cannot be expected to special-case the
|
|
7
|
+
* backend it happens to be talking to. Parsing and receipt construction live
|
|
8
|
+
* here so there is one definition rather than one per target.
|
|
9
|
+
*
|
|
10
|
+
* Runtime-neutral by construction: this module touches only URLs and plain
|
|
11
|
+
* objects, never a store, a submission runner, or a platform binding.
|
|
12
|
+
*/
|
|
13
|
+
const AGENT_ROUTE_PATTERN = /^\/agents\/([^/]+)\/([^/]+)(?:\/(submissions|conversation|abort|schedules|stream)(?:\/([^/]+))?)?$/;
|
|
14
|
+
/**
|
|
15
|
+
* Parse a pathname against the agent route surface.
|
|
16
|
+
*
|
|
17
|
+
* Returns `undefined` when the path is not an agent route, so a caller can
|
|
18
|
+
* fall through to its other route families. Percent-decoding happens here: a
|
|
19
|
+
* target that matched the raw segments would treat `ticket%2F1` as a different
|
|
20
|
+
* instance than the one the client addressed.
|
|
21
|
+
*/
|
|
22
|
+
export function matchAgentRoute(pathname) {
|
|
23
|
+
const match = AGENT_ROUTE_PATTERN.exec(pathname);
|
|
24
|
+
if (!match)
|
|
25
|
+
return undefined;
|
|
26
|
+
const [, agent, instanceId, section, resourceId] = match;
|
|
27
|
+
if (!agent || !instanceId)
|
|
28
|
+
return undefined;
|
|
29
|
+
let decodedAgent;
|
|
30
|
+
let decodedInstance;
|
|
31
|
+
let decodedResource;
|
|
32
|
+
try {
|
|
33
|
+
decodedAgent = decodeURIComponent(agent);
|
|
34
|
+
decodedInstance = decodeURIComponent(instanceId);
|
|
35
|
+
decodedResource = resourceId === undefined ? undefined : decodeURIComponent(resourceId);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// A malformed escape is not a route we can serve; let the caller 404 it
|
|
39
|
+
// rather than throwing out of a router.
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
agent: decodedAgent,
|
|
44
|
+
instanceId: decodedInstance,
|
|
45
|
+
...(section ? { section: section } : {}),
|
|
46
|
+
...(decodedResource !== undefined ? { resourceId: decodedResource } : {}),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** Session name carried by `?session=`, defaulting to `default`. */
|
|
50
|
+
export function agentRouteSession(searchParams) {
|
|
51
|
+
const value = searchParams.get("session");
|
|
52
|
+
return value && value.length > 0 ? value : "default";
|
|
53
|
+
}
|
|
54
|
+
/** Base path for one persistent instance, with both segments escaped. */
|
|
55
|
+
export function agentInstancePath(agent, instanceId) {
|
|
56
|
+
return `/agents/${encodeURIComponent(agent)}/${encodeURIComponent(instanceId)}`;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Build the `202` admission receipt.
|
|
60
|
+
*
|
|
61
|
+
* `streamUrl` and `conversationUrl` are the same URL; the former is retained
|
|
62
|
+
* for compatibility with clients written against the earlier shape.
|
|
63
|
+
*/
|
|
64
|
+
export function agentSubmissionReceipt(input) {
|
|
65
|
+
const base = agentInstancePath(input.agent, input.instanceId);
|
|
66
|
+
const query = `session=${encodeURIComponent(input.session)}&offset=${encodeURIComponent(input.offset)}`;
|
|
67
|
+
const conversationUrl = `${base}/conversation?${query}`;
|
|
68
|
+
return {
|
|
69
|
+
submissionId: input.submissionId,
|
|
70
|
+
...(input.uid ? { uid: input.uid } : {}),
|
|
71
|
+
...(input.acceptedAt ? { acceptedAt: input.acceptedAt } : {}),
|
|
72
|
+
streamUrl: conversationUrl,
|
|
73
|
+
conversationUrl,
|
|
74
|
+
...(input.updates ? { updatesUrl: `${base}/stream?${query}` } : {}),
|
|
75
|
+
offset: input.offset,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=agent-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-route.js","sourceRoot":"","sources":["../src/agent-route.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,MAAM,mBAAmB,GACvB,oGAAoG,CAAC;AAavG;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,MAAM,KAAK,GAAG,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjD,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,MAAM,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC;IACzD,IAAI,CAAC,KAAK,IAAI,CAAC,UAAU;QAAE,OAAO,SAAS,CAAC;IAC5C,IAAI,YAAoB,CAAC;IACzB,IAAI,eAAuB,CAAC;IAC5B,IAAI,eAAmC,CAAC;IACxC,IAAI,CAAC;QACH,YAAY,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;QACzC,eAAe,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACjD,eAAe,GAAG,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC1F,CAAC;IAAC,MAAM,CAAC;QACP,wEAAwE;QACxE,wCAAwC;QACxC,OAAO,SAAS,CAAC;IACnB,CAAC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AG,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7D,SAAS,EAAE,eAAe;QAC1B,eAAe;QACf,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,IAAI,WAAW,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnE,MAAM,EAAE,KAAK,CAAC,MAAM;KACrB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A mountable fetch router for the persistent-agent HTTP surface.
|
|
3
|
+
*
|
|
4
|
+
* Harness serves agents from its own runtimes (`fh dev`, the Node artifact,
|
|
5
|
+
* the Cloudflare worker). This router covers the other direction: an
|
|
6
|
+
* application that already owns an HTTP surface and wants Harness agents on it,
|
|
7
|
+
* under its own paths, behind its own middleware.
|
|
8
|
+
*
|
|
9
|
+
* The router owns routing, method dispatch, request parsing, response shape,
|
|
10
|
+
* and status codes — everything a client observes. A {@link FabricAgentRouterBackend}
|
|
11
|
+
* owns durable submission, conversation reads, and lifecycle. That split is
|
|
12
|
+
* what lets one definition of the wire contract serve hosts whose storage and
|
|
13
|
+
* execution differ.
|
|
14
|
+
*
|
|
15
|
+
* Runtime-neutral: only `Request`, `Response`, `URL`, and plain objects. It runs
|
|
16
|
+
* on Node, Cloudflare, Deno, Bun, or any fetch-capable host.
|
|
17
|
+
*/
|
|
18
|
+
import type { DeliveredMessage } from "./delivered-message.js";
|
|
19
|
+
/** Identity of one addressed conversation. */
|
|
20
|
+
export interface FabricAgentAddress {
|
|
21
|
+
agent: string;
|
|
22
|
+
instanceId: string;
|
|
23
|
+
session: string;
|
|
24
|
+
}
|
|
25
|
+
export interface FabricAgentAdmission extends FabricAgentAddress {
|
|
26
|
+
message: DeliveredMessage;
|
|
27
|
+
initialData?: unknown;
|
|
28
|
+
uid?: string | null;
|
|
29
|
+
/** Tenant from `x-fabric-tenant`, when the host forwards one. */
|
|
30
|
+
tenantId?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface FabricAgentAdmissionResult {
|
|
33
|
+
submissionId: string;
|
|
34
|
+
/**
|
|
35
|
+
* Stream position captured before admission. Reading from it returns this
|
|
36
|
+
* delivery and the reply. Never substitute `"0"`: that re-reads the whole
|
|
37
|
+
* conversation on every send.
|
|
38
|
+
*/
|
|
39
|
+
offset: string;
|
|
40
|
+
uid?: string;
|
|
41
|
+
acceptedAt?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface FabricAgentConversationPage {
|
|
44
|
+
incarnation: string | null;
|
|
45
|
+
batches: Array<{
|
|
46
|
+
offset: string;
|
|
47
|
+
records: unknown[];
|
|
48
|
+
}>;
|
|
49
|
+
nextOffset: string;
|
|
50
|
+
upToDate: boolean;
|
|
51
|
+
}
|
|
52
|
+
export interface FabricAgentSubmissionStatus {
|
|
53
|
+
submissionId: string;
|
|
54
|
+
status: string;
|
|
55
|
+
uid?: string;
|
|
56
|
+
outcome?: string;
|
|
57
|
+
result?: string;
|
|
58
|
+
error?: string;
|
|
59
|
+
answeredBySubmissionId?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface FabricAgentDeletion {
|
|
62
|
+
deleted: boolean;
|
|
63
|
+
aborted?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The host-specific half of the router.
|
|
67
|
+
*
|
|
68
|
+
* Every method may throw; the router maps a thrown error to `500` with a
|
|
69
|
+
* generic body rather than leaking host internals to the caller.
|
|
70
|
+
*/
|
|
71
|
+
export interface FabricAgentRouterBackend {
|
|
72
|
+
/**
|
|
73
|
+
* Whether the named agent exists and may be served over HTTP. Returning
|
|
74
|
+
* `exposed: false` produces the same `404` as an unknown agent, so probing
|
|
75
|
+
* cannot distinguish a private agent from a missing one.
|
|
76
|
+
*/
|
|
77
|
+
resolveAgent(name: string): Promise<{
|
|
78
|
+
found: boolean;
|
|
79
|
+
exposed?: boolean;
|
|
80
|
+
}>;
|
|
81
|
+
admit(input: FabricAgentAdmission): Promise<FabricAgentAdmissionResult>;
|
|
82
|
+
readConversation(address: FabricAgentAddress & {
|
|
83
|
+
offset: string;
|
|
84
|
+
limit: number;
|
|
85
|
+
}): Promise<FabricAgentConversationPage>;
|
|
86
|
+
getSubmission(address: FabricAgentAddress & {
|
|
87
|
+
submissionId: string;
|
|
88
|
+
}): Promise<FabricAgentSubmissionStatus | undefined>;
|
|
89
|
+
abort(address: FabricAgentAddress): Promise<boolean>;
|
|
90
|
+
/** Instance state for `GET`, or `undefined` when the instance does not exist. */
|
|
91
|
+
loadInstance?(address: FabricAgentAddress): Promise<unknown | undefined>;
|
|
92
|
+
deleteInstance?(address: FabricAgentAddress): Promise<FabricAgentDeletion>;
|
|
93
|
+
/** Live updates over SSE. Hosts without one omit it and the route 404s. */
|
|
94
|
+
streamUpdates?(address: FabricAgentAddress & {
|
|
95
|
+
offset: string;
|
|
96
|
+
}, request: Request): Promise<Response>;
|
|
97
|
+
/** Per-instance schedules, where the host supports them. */
|
|
98
|
+
handleSchedules?(address: FabricAgentAddress, request: Request): Promise<Response | undefined>;
|
|
99
|
+
}
|
|
100
|
+
export interface FabricAgentRouterOptions {
|
|
101
|
+
/**
|
|
102
|
+
* Path prefix this router is mounted under, e.g. `/api`. Stripped before
|
|
103
|
+
* matching, so the router works at any mount point without the backend
|
|
104
|
+
* knowing where it lives.
|
|
105
|
+
*/
|
|
106
|
+
basePath?: string;
|
|
107
|
+
/** Largest `limit` a conversation read may request. Defaults to 1000. */
|
|
108
|
+
maxReadLimit?: number;
|
|
109
|
+
}
|
|
110
|
+
export interface FabricAgentRouter {
|
|
111
|
+
/** Always returns a `Response`, 404-ing paths outside the agent surface. */
|
|
112
|
+
fetch(request: Request): Promise<Response>;
|
|
113
|
+
/**
|
|
114
|
+
* Returns `undefined` for paths outside the agent surface, so a host can
|
|
115
|
+
* fall through to its own routes.
|
|
116
|
+
*/
|
|
117
|
+
handle(request: Request): Promise<Response | undefined>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Mount the persistent-agent HTTP surface on any fetch-capable host.
|
|
121
|
+
*
|
|
122
|
+
* ```ts
|
|
123
|
+
* const router = createFabricAgentRouter(backend, { basePath: '/api' });
|
|
124
|
+
* app.all('/api/agents/*', (c) => router.fetch(c.req.raw));
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
export declare function createFabricAgentRouter(backend: FabricAgentRouterBackend, options?: FabricAgentRouterOptions): FabricAgentRouter;
|
|
128
|
+
//# sourceMappingURL=agent-router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-router.d.ts","sourceRoot":"","sources":["../src/agent-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AASH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,8CAA8C;AAC9C,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAqB,SAAQ,kBAAkB;IAC9D,OAAO,EAAE,gBAAgB,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,0BAA0B;IACzC,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,2BAA2B;IAC1C,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,KAAK,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OAAO,GAAG,SAAS,CAAC,CAAC;IACzE,cAAc,CAAC,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC3E,2EAA2E;IAC3E,aAAa,CAAC,CACZ,OAAO,EAAE,kBAAkB,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,EAChD,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrB,4DAA4D;IAC5D,eAAe,CAAC,CAAC,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC;CAChG;AAED,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,4EAA4E;IAC5E,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3C;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC;CACzD;AA4BD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,wBAAwB,EACjC,OAAO,GAAE,wBAA6B,GACrC,iBAAiB,CAyJnB"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A mountable fetch router for the persistent-agent HTTP surface.
|
|
3
|
+
*
|
|
4
|
+
* Harness serves agents from its own runtimes (`fh dev`, the Node artifact,
|
|
5
|
+
* the Cloudflare worker). This router covers the other direction: an
|
|
6
|
+
* application that already owns an HTTP surface and wants Harness agents on it,
|
|
7
|
+
* under its own paths, behind its own middleware.
|
|
8
|
+
*
|
|
9
|
+
* The router owns routing, method dispatch, request parsing, response shape,
|
|
10
|
+
* and status codes — everything a client observes. A {@link FabricAgentRouterBackend}
|
|
11
|
+
* owns durable submission, conversation reads, and lifecycle. That split is
|
|
12
|
+
* what lets one definition of the wire contract serve hosts whose storage and
|
|
13
|
+
* execution differ.
|
|
14
|
+
*
|
|
15
|
+
* Runtime-neutral: only `Request`, `Response`, `URL`, and plain objects. It runs
|
|
16
|
+
* on Node, Cloudflare, Deno, Bun, or any fetch-capable host.
|
|
17
|
+
*/
|
|
18
|
+
import { agentRouteSession, agentSubmissionReceipt, matchAgentRoute, } from "./agent-route.js";
|
|
19
|
+
import { normalizeDeliveredMessage } from "./delivered-message.js";
|
|
20
|
+
const DEFAULT_MAX_READ_LIMIT = 1000;
|
|
21
|
+
function json(value, status = 200) {
|
|
22
|
+
return new Response(JSON.stringify(value, null, 2), {
|
|
23
|
+
status,
|
|
24
|
+
headers: { "content-type": "application/json; charset=utf-8" },
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const notFound = () => json({ error: "not_found" }, 404);
|
|
28
|
+
const methodNotAllowed = () => json({ error: "method_not_allowed" }, 405);
|
|
29
|
+
function readLimit(searchParams, max) {
|
|
30
|
+
const raw = Number.parseInt(searchParams.get("limit") ?? "", 10);
|
|
31
|
+
if (!Number.isFinite(raw))
|
|
32
|
+
return Math.min(100, max);
|
|
33
|
+
return Math.min(max, Math.max(1, raw));
|
|
34
|
+
}
|
|
35
|
+
function stripBasePath(pathname, basePath) {
|
|
36
|
+
if (!basePath)
|
|
37
|
+
return pathname;
|
|
38
|
+
const normalized = basePath.endsWith("/") ? basePath.slice(0, -1) : basePath;
|
|
39
|
+
if (!normalized)
|
|
40
|
+
return pathname;
|
|
41
|
+
if (pathname === normalized)
|
|
42
|
+
return "/";
|
|
43
|
+
return pathname.startsWith(`${normalized}/`) ? pathname.slice(normalized.length) : undefined;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Mount the persistent-agent HTTP surface on any fetch-capable host.
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* const router = createFabricAgentRouter(backend, { basePath: '/api' });
|
|
50
|
+
* app.all('/api/agents/*', (c) => router.fetch(c.req.raw));
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export function createFabricAgentRouter(backend, options = {}) {
|
|
54
|
+
const maxReadLimit = options.maxReadLimit ?? DEFAULT_MAX_READ_LIMIT;
|
|
55
|
+
async function handle(request) {
|
|
56
|
+
const url = new URL(request.url);
|
|
57
|
+
const pathname = stripBasePath(url.pathname, options.basePath);
|
|
58
|
+
if (pathname === undefined)
|
|
59
|
+
return undefined;
|
|
60
|
+
const route = matchAgentRoute(pathname);
|
|
61
|
+
if (!route)
|
|
62
|
+
return undefined;
|
|
63
|
+
const resolved = await backend.resolveAgent(route.agent);
|
|
64
|
+
// An agent that exists but is not exposed answers exactly like one that
|
|
65
|
+
// does not exist, so probing cannot enumerate private agents.
|
|
66
|
+
if (!resolved.found || resolved.exposed === false) {
|
|
67
|
+
return json({ error: "agent_not_found", agent: route.agent }, 404);
|
|
68
|
+
}
|
|
69
|
+
const address = {
|
|
70
|
+
agent: route.agent,
|
|
71
|
+
instanceId: route.instanceId,
|
|
72
|
+
session: agentRouteSession(url.searchParams),
|
|
73
|
+
};
|
|
74
|
+
return dispatch(request, url, route, address);
|
|
75
|
+
}
|
|
76
|
+
async function dispatch(request, url, route, address) {
|
|
77
|
+
switch (route.section) {
|
|
78
|
+
case "submissions": {
|
|
79
|
+
if (request.method !== "GET")
|
|
80
|
+
return methodNotAllowed();
|
|
81
|
+
if (!route.resourceId)
|
|
82
|
+
return notFound();
|
|
83
|
+
const submission = await backend.getSubmission({
|
|
84
|
+
...address,
|
|
85
|
+
submissionId: route.resourceId,
|
|
86
|
+
});
|
|
87
|
+
return submission ? json(submission) : json({ error: "submission_not_found" }, 404);
|
|
88
|
+
}
|
|
89
|
+
case "conversation": {
|
|
90
|
+
if (request.method !== "GET")
|
|
91
|
+
return methodNotAllowed();
|
|
92
|
+
return json(await backend.readConversation({
|
|
93
|
+
...address,
|
|
94
|
+
offset: url.searchParams.get("offset") ?? "0",
|
|
95
|
+
limit: readLimit(url.searchParams, maxReadLimit),
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
case "abort": {
|
|
99
|
+
if (request.method !== "POST")
|
|
100
|
+
return methodNotAllowed();
|
|
101
|
+
return json({ aborted: await backend.abort(address) });
|
|
102
|
+
}
|
|
103
|
+
case "stream": {
|
|
104
|
+
if (request.method !== "GET")
|
|
105
|
+
return methodNotAllowed();
|
|
106
|
+
if (!backend.streamUpdates)
|
|
107
|
+
return notFound();
|
|
108
|
+
return backend.streamUpdates({ ...address, offset: url.searchParams.get("offset") ?? "0" }, request);
|
|
109
|
+
}
|
|
110
|
+
case "schedules": {
|
|
111
|
+
if (!backend.handleSchedules)
|
|
112
|
+
return notFound();
|
|
113
|
+
return (await backend.handleSchedules(address, request)) ?? methodNotAllowed();
|
|
114
|
+
}
|
|
115
|
+
default:
|
|
116
|
+
return instanceRoot(request, address);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async function instanceRoot(request, address) {
|
|
120
|
+
if (request.method === "GET") {
|
|
121
|
+
if (!backend.loadInstance)
|
|
122
|
+
return methodNotAllowed();
|
|
123
|
+
const data = await backend.loadInstance(address);
|
|
124
|
+
return data === undefined ? json({ error: "session_not_found" }, 404) : json(data);
|
|
125
|
+
}
|
|
126
|
+
if (request.method === "DELETE") {
|
|
127
|
+
if (!backend.deleteInstance)
|
|
128
|
+
return methodNotAllowed();
|
|
129
|
+
const outcome = await backend.deleteInstance(address);
|
|
130
|
+
if (!outcome.deleted) {
|
|
131
|
+
return json({ error: "session_busy", aborted: outcome.aborted ?? false }, 409);
|
|
132
|
+
}
|
|
133
|
+
return json({
|
|
134
|
+
deleted: true,
|
|
135
|
+
agent: address.agent,
|
|
136
|
+
instanceId: address.instanceId,
|
|
137
|
+
session: address.session,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
if (request.method !== "POST")
|
|
141
|
+
return methodNotAllowed();
|
|
142
|
+
let body;
|
|
143
|
+
try {
|
|
144
|
+
body = (await request.json());
|
|
145
|
+
}
|
|
146
|
+
catch {
|
|
147
|
+
return json({ error: { type: "invalid_request", message: "Body must be JSON." } }, 400);
|
|
148
|
+
}
|
|
149
|
+
const message = body.message;
|
|
150
|
+
if (typeof message !== "string" && (!message || typeof message !== "object")) {
|
|
151
|
+
return json({ error: "message_required" }, 400);
|
|
152
|
+
}
|
|
153
|
+
if (body.uid !== undefined &&
|
|
154
|
+
body.uid !== null &&
|
|
155
|
+
(typeof body.uid !== "string" || body.uid.trim() === "")) {
|
|
156
|
+
return json({
|
|
157
|
+
error: { type: "invalid_request", message: "uid must be a non-empty string or null." },
|
|
158
|
+
}, 400);
|
|
159
|
+
}
|
|
160
|
+
const tenantId = request.headers.get("x-fabric-tenant") ?? undefined;
|
|
161
|
+
const admitted = await backend.admit({
|
|
162
|
+
...address,
|
|
163
|
+
message: normalizeDeliveredMessage(message),
|
|
164
|
+
...(body.initialData !== undefined ? { initialData: body.initialData } : {}),
|
|
165
|
+
...(body.uid !== undefined ? { uid: body.uid } : {}),
|
|
166
|
+
...(tenantId ? { tenantId } : {}),
|
|
167
|
+
});
|
|
168
|
+
return json(agentSubmissionReceipt({
|
|
169
|
+
submissionId: admitted.submissionId,
|
|
170
|
+
agent: address.agent,
|
|
171
|
+
instanceId: address.instanceId,
|
|
172
|
+
session: address.session,
|
|
173
|
+
offset: admitted.offset,
|
|
174
|
+
...(admitted.uid ? { uid: admitted.uid } : {}),
|
|
175
|
+
...(admitted.acceptedAt ? { acceptedAt: admitted.acceptedAt } : {}),
|
|
176
|
+
updates: backend.streamUpdates !== undefined,
|
|
177
|
+
}), 202);
|
|
178
|
+
}
|
|
179
|
+
async function guarded(request) {
|
|
180
|
+
try {
|
|
181
|
+
return await handle(request);
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
// Host failures must not leak storage or execution internals to callers.
|
|
185
|
+
return json({ error: { type: "internal_error", message: "Request failed." } }, 500);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
handle: guarded,
|
|
190
|
+
fetch: async (request) => (await guarded(request)) ?? notFound(),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=agent-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-router.js","sourceRoot":"","sources":["../src/agent-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAEL,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AA0GnE,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAEpC,SAAS,IAAI,CAAC,KAAc,EAAE,MAAM,GAAG,GAAG;IACxC,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;QAClD,MAAM;QACN,OAAO,EAAE,EAAE,cAAc,EAAE,iCAAiC,EAAE;KAC/D,CAAC,CAAC;AACL,CAAC;AAED,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,GAAG,CAAC,CAAC;AACzD,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,EAAE,GAAG,CAAC,CAAC;AAE1E,SAAS,SAAS,CAAC,YAA6B,EAAE,GAAW;IAC3D,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IACjE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC,GAAG,CAAC,G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Gateway} preset
|
|
44
|
+
* For Vercel AI Gateway, prefer the {@link vercelAIGateway} preset: same
|
|
45
45
|
* factory under the hood with the gateway URL pre-baked.
|
|
46
46
|
*/
|
|
47
47
|
export declare function aiGateway(options: AIGatewayOptions): OpenAICompatibleModelProvider;
|
package/dist/ai-gateway.js
CHANGED
|
@@ -29,7 +29,7 @@ import { OpenAICompatibleModelProvider } from './model.js';
|
|
|
29
29
|
* });
|
|
30
30
|
* ```
|
|
31
31
|
*
|
|
32
|
-
* For Vercel AI Gateway, prefer the {@link vercelAIGateway} preset
|
|
32
|
+
* For Vercel AI Gateway, prefer the {@link vercelAIGateway} preset: same
|
|
33
33
|
* factory under the hood with the gateway URL pre-baked.
|
|
34
34
|
*/
|
|
35
35
|
export function aiGateway(options) {
|