@sema-agent/sdk 0.0.46
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/LICENSE +103 -0
- package/README.md +53 -0
- package/dist/client.d.ts +55 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +113 -0
- package/dist/client.js.map +1 -0
- package/dist/control-client.d.ts +36 -0
- package/dist/control-client.d.ts.map +1 -0
- package/dist/control-client.js +72 -0
- package/dist/control-client.js.map +1 -0
- package/dist/control-types.d.ts +282 -0
- package/dist/control-types.d.ts.map +1 -0
- package/dist/control-types.js +2 -0
- package/dist/control-types.js.map +1 -0
- package/dist/errors.d.ts +99 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +190 -0
- package/dist/errors.js.map +1 -0
- package/dist/events.d.ts +87 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +4 -0
- package/dist/events.js.map +1 -0
- package/dist/idempotency.d.ts +3 -0
- package/dist/idempotency.d.ts.map +1 -0
- package/dist/idempotency.js +9 -0
- package/dist/idempotency.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/approvals.d.ts +40 -0
- package/dist/resources/approvals.d.ts.map +1 -0
- package/dist/resources/approvals.js +83 -0
- package/dist/resources/approvals.js.map +1 -0
- package/dist/resources/assistant.d.ts +23 -0
- package/dist/resources/assistant.d.ts.map +1 -0
- package/dist/resources/assistant.js +59 -0
- package/dist/resources/assistant.js.map +1 -0
- package/dist/resources/control/auth-providers.d.ts +18 -0
- package/dist/resources/control/auth-providers.d.ts.map +1 -0
- package/dist/resources/control/auth-providers.js +16 -0
- package/dist/resources/control/auth-providers.js.map +1 -0
- package/dist/resources/control/config.d.ts +31 -0
- package/dist/resources/control/config.d.ts.map +1 -0
- package/dist/resources/control/config.js +28 -0
- package/dist/resources/control/config.js.map +1 -0
- package/dist/resources/control/fleet.d.ts +31 -0
- package/dist/resources/control/fleet.d.ts.map +1 -0
- package/dist/resources/control/fleet.js +31 -0
- package/dist/resources/control/fleet.js.map +1 -0
- package/dist/resources/control/images.d.ts +19 -0
- package/dist/resources/control/images.d.ts.map +1 -0
- package/dist/resources/control/images.js +28 -0
- package/dist/resources/control/images.js.map +1 -0
- package/dist/resources/control/lifecycle.d.ts +15 -0
- package/dist/resources/control/lifecycle.d.ts.map +1 -0
- package/dist/resources/control/lifecycle.js +15 -0
- package/dist/resources/control/lifecycle.js.map +1 -0
- package/dist/resources/control/publish.d.ts +20 -0
- package/dist/resources/control/publish.d.ts.map +1 -0
- package/dist/resources/control/publish.js +20 -0
- package/dist/resources/control/publish.js.map +1 -0
- package/dist/resources/control/secrets.d.ts +27 -0
- package/dist/resources/control/secrets.d.ts.map +1 -0
- package/dist/resources/control/secrets.js +26 -0
- package/dist/resources/control/secrets.js.map +1 -0
- package/dist/resources/control/users.d.ts +27 -0
- package/dist/resources/control/users.d.ts.map +1 -0
- package/dist/resources/control/users.js +23 -0
- package/dist/resources/control/users.js.map +1 -0
- package/dist/resources/control/versioning.d.ts +21 -0
- package/dist/resources/control/versioning.d.ts.map +1 -0
- package/dist/resources/control/versioning.js +23 -0
- package/dist/resources/control/versioning.js.map +1 -0
- package/dist/resources/control/workers.d.ts +18 -0
- package/dist/resources/control/workers.d.ts.map +1 -0
- package/dist/resources/control/workers.js +17 -0
- package/dist/resources/control/workers.js.map +1 -0
- package/dist/resources/elicitations.d.ts +28 -0
- package/dist/resources/elicitations.d.ts.map +1 -0
- package/dist/resources/elicitations.js +15 -0
- package/dist/resources/elicitations.js.map +1 -0
- package/dist/resources/fleet.d.ts +65 -0
- package/dist/resources/fleet.d.ts.map +1 -0
- package/dist/resources/fleet.js +55 -0
- package/dist/resources/fleet.js.map +1 -0
- package/dist/resources/images.d.ts +24 -0
- package/dist/resources/images.d.ts.map +1 -0
- package/dist/resources/images.js +28 -0
- package/dist/resources/images.js.map +1 -0
- package/dist/resources/leader.d.ts +19 -0
- package/dist/resources/leader.d.ts.map +1 -0
- package/dist/resources/leader.js +18 -0
- package/dist/resources/leader.js.map +1 -0
- package/dist/resources/memory.d.ts +29 -0
- package/dist/resources/memory.d.ts.map +1 -0
- package/dist/resources/memory.js +36 -0
- package/dist/resources/memory.js.map +1 -0
- package/dist/resources/models.d.ts +13 -0
- package/dist/resources/models.d.ts.map +1 -0
- package/dist/resources/models.js +10 -0
- package/dist/resources/models.js.map +1 -0
- package/dist/resources/policy.d.ts +10 -0
- package/dist/resources/policy.d.ts.map +1 -0
- package/dist/resources/policy.js +10 -0
- package/dist/resources/policy.js.map +1 -0
- package/dist/resources/questions.d.ts +38 -0
- package/dist/resources/questions.d.ts.map +1 -0
- package/dist/resources/questions.js +15 -0
- package/dist/resources/questions.js.map +1 -0
- package/dist/resources/runs.d.ts +43 -0
- package/dist/resources/runs.d.ts.map +1 -0
- package/dist/resources/runs.js +72 -0
- package/dist/resources/runs.js.map +1 -0
- package/dist/resources/session-sync.d.ts +38 -0
- package/dist/resources/session-sync.d.ts.map +1 -0
- package/dist/resources/session-sync.js +97 -0
- package/dist/resources/session-sync.js.map +1 -0
- package/dist/resources/sessions.d.ts +46 -0
- package/dist/resources/sessions.d.ts.map +1 -0
- package/dist/resources/sessions.js +70 -0
- package/dist/resources/sessions.js.map +1 -0
- package/dist/resources/tasks.d.ts +19 -0
- package/dist/resources/tasks.d.ts.map +1 -0
- package/dist/resources/tasks.js +53 -0
- package/dist/resources/tasks.js.map +1 -0
- package/dist/resources/trace.d.ts +43 -0
- package/dist/resources/trace.d.ts.map +1 -0
- package/dist/resources/trace.js +65 -0
- package/dist/resources/trace.js.map +1 -0
- package/dist/resources/usage.d.ts +10 -0
- package/dist/resources/usage.d.ts.map +1 -0
- package/dist/resources/usage.js +10 -0
- package/dist/resources/usage.js.map +1 -0
- package/dist/resources/workflows.d.ts +20 -0
- package/dist/resources/workflows.d.ts.map +1 -0
- package/dist/resources/workflows.js +43 -0
- package/dist/resources/workflows.js.map +1 -0
- package/dist/settings.d.ts +44 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/settings.js +2 -0
- package/dist/settings.js.map +1 -0
- package/dist/sse.d.ts +26 -0
- package/dist/sse.d.ts.map +1 -0
- package/dist/sse.js +244 -0
- package/dist/sse.js.map +1 -0
- package/dist/sync.d.ts +34 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +143 -0
- package/dist/sync.js.map +1 -0
- package/dist/transport.d.ts +37 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +134 -0
- package/dist/transport.js.map +1 -0
- package/dist/types.d.ts +574 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/openapi.yaml +3434 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
Business Source License 1.1
|
|
2
|
+
|
|
3
|
+
Parameters
|
|
4
|
+
|
|
5
|
+
Licensor: clay (github.com/clayboby)
|
|
6
|
+
Licensed Work: @sema-agent/clients
|
|
7
|
+
The Licensed Work is (c) 2026 clay.
|
|
8
|
+
Additional Use Grant: You may make production use of the Licensed Work for
|
|
9
|
+
personal, educational, research, or other
|
|
10
|
+
non-commercial purposes. Commercial production use
|
|
11
|
+
requires a commercial license from the Licensor.
|
|
12
|
+
Change Date: 2030-07-13
|
|
13
|
+
Change License: Apache License, Version 2.0
|
|
14
|
+
|
|
15
|
+
For information about alternative licensing arrangements for the Licensed
|
|
16
|
+
Work, please contact the Licensor.
|
|
17
|
+
|
|
18
|
+
Notice
|
|
19
|
+
|
|
20
|
+
The Business Source License (this document, or the "License") is not an Open
|
|
21
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
22
|
+
under an Open Source License, as stated in this License.
|
|
23
|
+
|
|
24
|
+
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
25
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
26
|
+
|
|
27
|
+
-----------------------------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
Terms
|
|
30
|
+
|
|
31
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
32
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
33
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
34
|
+
production use.
|
|
35
|
+
|
|
36
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
37
|
+
available distribution of a specific version of the Licensed Work under this
|
|
38
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
39
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
40
|
+
above terminate.
|
|
41
|
+
|
|
42
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
43
|
+
currently in effect as described in this License, you must purchase a
|
|
44
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
45
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
46
|
+
|
|
47
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
48
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
49
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
50
|
+
for each version of the Licensed Work released by Licensor.
|
|
51
|
+
|
|
52
|
+
You must conspicuously display this License on each original or modified copy
|
|
53
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
54
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
55
|
+
License apply to your use of that work.
|
|
56
|
+
|
|
57
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
58
|
+
terminate your rights under this License for the current and all other
|
|
59
|
+
versions of the Licensed Work.
|
|
60
|
+
|
|
61
|
+
This License does not grant you any right in any trademark or logo of
|
|
62
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
63
|
+
Licensor as expressly required by this License).
|
|
64
|
+
|
|
65
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
66
|
+
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
67
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
68
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
69
|
+
TITLE.
|
|
70
|
+
|
|
71
|
+
MariaDB hereby grants you permission to use this License's text to license
|
|
72
|
+
your works, and to refer to it using the trademark "Business Source License",
|
|
73
|
+
as long as you comply with the Covenants of Licensor below.
|
|
74
|
+
|
|
75
|
+
Covenants of Licensor
|
|
76
|
+
|
|
77
|
+
In consideration of the right to use this License's text and the "Business
|
|
78
|
+
Source License" name and trademark, Licensor covenants to MariaDB, and to all
|
|
79
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
80
|
+
|
|
81
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
82
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
83
|
+
where "compatible" means that software provided under the Change License can
|
|
84
|
+
be included in a program with software provided under GPL Version 2.0 or a
|
|
85
|
+
later version. Licensor may specify additional Change Licenses without
|
|
86
|
+
limitation.
|
|
87
|
+
|
|
88
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
89
|
+
impose any additional restriction on the right granted in this License, as
|
|
90
|
+
the Additional Use Grant; or (b) insert the text "None".
|
|
91
|
+
|
|
92
|
+
3. To specify a Change Date.
|
|
93
|
+
|
|
94
|
+
4. Not to modify this License in any other way.
|
|
95
|
+
|
|
96
|
+
-----------------------------------------------------------------------------
|
|
97
|
+
|
|
98
|
+
Third-party notices
|
|
99
|
+
|
|
100
|
+
Versions of this package up to and including 1.277.1 were published under the
|
|
101
|
+
MIT License; those published copies remain governed by the license they were
|
|
102
|
+
distributed under. This package incorporates design and (where noted) prompt
|
|
103
|
+
content adapted from MIT-licensed projects — see NOTICE.md for attributions.
|
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# @sema-agent/sdk
|
|
2
|
+
|
|
3
|
+
Typed, zero-runtime-dependency SDK for the Sema agent fleet **usage plane** — the single contract entry for driving agents from business systems, AIs, and humans. Ships the `openapi.yaml` spec it is generated against so producer and consumer anchor the same wire.
|
|
4
|
+
|
|
5
|
+
**Server-side only** — bearer tokens never enter the browser. Browser surfaces go through a BFF that holds the token (see `docs/browser.md` in the repository).
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @sema-agent/sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Requires Node >= 20.
|
|
14
|
+
|
|
15
|
+
## Quick start
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { AgentClient } from "@sema-agent/sdk";
|
|
19
|
+
|
|
20
|
+
const client = new AgentClient({
|
|
21
|
+
baseUrl: process.env.SEMA_BASE_URL!, // your worker / gateway endpoint
|
|
22
|
+
authToken: process.env.SEMA_TOKEN!, // service bearer token (never hardcode)
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Submit a task and tail its durable, resumable event stream
|
|
26
|
+
const task = await client.tasks.submit({ objective: "summarize the repo" });
|
|
27
|
+
for await (const ev of client.runs.events(task.taskId)) {
|
|
28
|
+
if (ev.type === "text") console.log(ev.text);
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Surface
|
|
33
|
+
|
|
34
|
+
- `client.tasks` / `client.runs` — submit, durable runs, SSE event streams with resume.
|
|
35
|
+
- `client.sessions` — session read/manage; `pushSessionBundle` / `pullSessionBundle` (top-level exports) move sessions between peers.
|
|
36
|
+
- `client.approvals` — HITL: pending checkpoints, `decide` (approve/deny/answer), live `stream()`, per-session exemptions (`listExemptions` / `revokeExemption`).
|
|
37
|
+
- `client.questions` — answer a live `AskUserQuestion` (`questions.respond`).
|
|
38
|
+
- `client.elicitations` — answer an inbound MCP elicitation form.
|
|
39
|
+
- `client.workflows`, `client.fleet`, `client.models`, `client.usage`, `client.trace`, … — see the typed exports in `dist/index.d.ts` and the bundled `openapi.yaml`.
|
|
40
|
+
|
|
41
|
+
Typed errors (`APIError` hierarchy: `AuthError`, `RateLimitedError`, `ConflictError`, `ApprovalStaleError`, …) let callers branch on semantics instead of strings.
|
|
42
|
+
|
|
43
|
+
## Contract
|
|
44
|
+
|
|
45
|
+
The bundled spec is importable:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import specPath from "@sema-agent/sdk/openapi.yaml";
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## License
|
|
52
|
+
|
|
53
|
+
[BUSL-1.1](./LICENSE)
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { TasksResource } from "./resources/tasks.js";
|
|
2
|
+
import { RunsResource } from "./resources/runs.js";
|
|
3
|
+
import { SessionsResource } from "./resources/sessions.js";
|
|
4
|
+
import { ApprovalsResource } from "./resources/approvals.js";
|
|
5
|
+
import { ElicitationsResource } from "./resources/elicitations.js";
|
|
6
|
+
import { QuestionsResource } from "./resources/questions.js";
|
|
7
|
+
import { AssistantResource } from "./resources/assistant.js";
|
|
8
|
+
import { TraceResource } from "./resources/trace.js";
|
|
9
|
+
import { LeaderResource } from "./resources/leader.js";
|
|
10
|
+
import { MemoryResource } from "./resources/memory.js";
|
|
11
|
+
import { ImagesResource } from "./resources/images.js";
|
|
12
|
+
import { ModelsResource } from "./resources/models.js";
|
|
13
|
+
import { UsageResource } from "./resources/usage.js";
|
|
14
|
+
import { PolicyResource } from "./resources/policy.js";
|
|
15
|
+
import { WorkflowsResource } from "./resources/workflows.js";
|
|
16
|
+
import { FleetResource } from "./resources/fleet.js";
|
|
17
|
+
import type { Principal, Capabilities } from "./types.js";
|
|
18
|
+
export type AgentAuthToken = string | {
|
|
19
|
+
mode: "loopback-unauthed";
|
|
20
|
+
};
|
|
21
|
+
export interface AgentClientConfig {
|
|
22
|
+
baseUrl: string;
|
|
23
|
+
authToken: AgentAuthToken;
|
|
24
|
+
principal: Principal;
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
maxRetries?: number;
|
|
27
|
+
allowBrowser?: boolean;
|
|
28
|
+
fetch?: typeof fetch;
|
|
29
|
+
}
|
|
30
|
+
export declare class AgentClient {
|
|
31
|
+
readonly tasks: TasksResource;
|
|
32
|
+
readonly runs: RunsResource;
|
|
33
|
+
readonly sessions: SessionsResource;
|
|
34
|
+
readonly approvals: ApprovalsResource;
|
|
35
|
+
readonly elicitations: ElicitationsResource;
|
|
36
|
+
readonly questions: QuestionsResource;
|
|
37
|
+
readonly assistant: AssistantResource;
|
|
38
|
+
readonly trace: TraceResource;
|
|
39
|
+
readonly leader: LeaderResource;
|
|
40
|
+
readonly memory: MemoryResource;
|
|
41
|
+
readonly images: ImagesResource;
|
|
42
|
+
readonly models: ModelsResource;
|
|
43
|
+
readonly usage: UsageResource;
|
|
44
|
+
readonly policy: PolicyResource;
|
|
45
|
+
readonly workflows: WorkflowsResource;
|
|
46
|
+
readonly fleet: FleetResource;
|
|
47
|
+
private readonly config;
|
|
48
|
+
private readonly transport;
|
|
49
|
+
capabilities(opts?: {
|
|
50
|
+
signal?: AbortSignal;
|
|
51
|
+
}): Promise<Capabilities>;
|
|
52
|
+
withPrincipal(principal: Principal): AgentClient;
|
|
53
|
+
constructor(config: AgentClientConfig);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC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E,oBAAoB,CAAC;IAK5C,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IAEtC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAEhC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAEhC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAEhC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAE9B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAEhC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;IAItC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAE9B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IAItC,YAAY,CAAC,IAAI,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,YAAY,CAAC;IAOpE,aAAa,CAAC,SAAS,EAAE,SAAS,GAAG,WAAW;gBAKpC,MAAM,EAAE,iBAAiB;CA4DtC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Transport } from "./transport.js";
|
|
2
|
+
import { TasksResource } from "./resources/tasks.js";
|
|
3
|
+
import { RunsResource } from "./resources/runs.js";
|
|
4
|
+
import { SessionsResource } from "./resources/sessions.js";
|
|
5
|
+
import { ApprovalsResource } from "./resources/approvals.js";
|
|
6
|
+
import { ElicitationsResource } from "./resources/elicitations.js";
|
|
7
|
+
import { QuestionsResource } from "./resources/questions.js";
|
|
8
|
+
import { AssistantResource } from "./resources/assistant.js";
|
|
9
|
+
import { TraceResource } from "./resources/trace.js";
|
|
10
|
+
import { LeaderResource } from "./resources/leader.js";
|
|
11
|
+
import { MemoryResource } from "./resources/memory.js";
|
|
12
|
+
import { ImagesResource } from "./resources/images.js";
|
|
13
|
+
import { ModelsResource } from "./resources/models.js";
|
|
14
|
+
import { UsageResource } from "./resources/usage.js";
|
|
15
|
+
import { PolicyResource } from "./resources/policy.js";
|
|
16
|
+
import { WorkflowsResource } from "./resources/workflows.js";
|
|
17
|
+
import { FleetResource } from "./resources/fleet.js";
|
|
18
|
+
function isLoopbackBaseUrl(baseUrl) {
|
|
19
|
+
let hostname;
|
|
20
|
+
try {
|
|
21
|
+
hostname = new URL(baseUrl).hostname;
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
const h = hostname.toLowerCase();
|
|
27
|
+
return h === "localhost" || h === "[::1]" || h === "::1" || /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(h);
|
|
28
|
+
}
|
|
29
|
+
export class AgentClient {
|
|
30
|
+
tasks;
|
|
31
|
+
runs;
|
|
32
|
+
sessions;
|
|
33
|
+
approvals;
|
|
34
|
+
elicitations;
|
|
35
|
+
questions;
|
|
36
|
+
assistant;
|
|
37
|
+
trace;
|
|
38
|
+
leader;
|
|
39
|
+
memory;
|
|
40
|
+
images;
|
|
41
|
+
models;
|
|
42
|
+
usage;
|
|
43
|
+
policy;
|
|
44
|
+
workflows;
|
|
45
|
+
fleet;
|
|
46
|
+
config;
|
|
47
|
+
transport;
|
|
48
|
+
capabilities(opts) {
|
|
49
|
+
return this.transport.request({ method: "GET", path: "/v1/capabilities", signal: opts?.signal });
|
|
50
|
+
}
|
|
51
|
+
withPrincipal(principal) {
|
|
52
|
+
if (!principal)
|
|
53
|
+
throw new Error("AgentClient.withPrincipal: principal is required (use 'anon:<id>' to be explicitly anonymous).");
|
|
54
|
+
return new AgentClient({ ...this.config, principal });
|
|
55
|
+
}
|
|
56
|
+
constructor(config) {
|
|
57
|
+
this.config = { ...config };
|
|
58
|
+
if (!config.principal)
|
|
59
|
+
throw new Error("AgentClient: `principal` is required (principal-first). Use 'anon:<id>' to be explicitly anonymous.");
|
|
60
|
+
const loopbackUnauthed = typeof config.authToken === "object" && config.authToken !== null;
|
|
61
|
+
if (loopbackUnauthed) {
|
|
62
|
+
if (config.authToken.mode !== "loopback-unauthed") {
|
|
63
|
+
throw new Error("AgentClient: unknown authToken shape — expected a SERVICE_AUTH_TOKEN string or { mode: \"loopback-unauthed\" }.");
|
|
64
|
+
}
|
|
65
|
+
if (!isLoopbackBaseUrl(config.baseUrl)) {
|
|
66
|
+
throw new Error("AgentClient: `loopback-unauthed` requires a loopback baseUrl (127.0.0.1 / localhost / ::1). A non-loopback worker is fail-closed — pass the real `authToken`.");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else if (!config.authToken) {
|
|
70
|
+
throw new Error("AgentClient: `authToken` is required (worker is fail-closed).");
|
|
71
|
+
}
|
|
72
|
+
if (!config.allowBrowser && typeof globalThis.window !== "undefined") {
|
|
73
|
+
throw new Error("AgentClient: refusing to construct a token-bearing client in a browser (secret discipline). A browser must call its own BFF; only the server holds SERVICE_AUTH_TOKEN.");
|
|
74
|
+
}
|
|
75
|
+
const authToken = typeof config.authToken === "string" ? config.authToken : undefined;
|
|
76
|
+
const principal = config.principal;
|
|
77
|
+
const opts = {
|
|
78
|
+
baseUrl: config.baseUrl,
|
|
79
|
+
timeoutMs: config.timeoutMs ?? 60_000,
|
|
80
|
+
maxRetries: config.maxRetries ?? 2,
|
|
81
|
+
fetchImpl: config.fetch ?? fetch,
|
|
82
|
+
buildHeaders: (idempotencyKey) => {
|
|
83
|
+
const h = {};
|
|
84
|
+
if (authToken !== undefined)
|
|
85
|
+
h.authorization = `Bearer ${authToken}`;
|
|
86
|
+
h["x-agent-principal"] = principal;
|
|
87
|
+
h["content-type"] = "application/json";
|
|
88
|
+
if (idempotencyKey)
|
|
89
|
+
h["idempotency-key"] = idempotencyKey;
|
|
90
|
+
return h;
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
const t = new Transport(opts);
|
|
94
|
+
this.transport = t;
|
|
95
|
+
this.tasks = new TasksResource(t);
|
|
96
|
+
this.runs = new RunsResource(t);
|
|
97
|
+
this.sessions = new SessionsResource(t);
|
|
98
|
+
this.approvals = new ApprovalsResource(t);
|
|
99
|
+
this.elicitations = new ElicitationsResource(t);
|
|
100
|
+
this.questions = new QuestionsResource(t);
|
|
101
|
+
this.assistant = new AssistantResource(t);
|
|
102
|
+
this.trace = new TraceResource(t);
|
|
103
|
+
this.leader = new LeaderResource(t);
|
|
104
|
+
this.memory = new MemoryResource(t);
|
|
105
|
+
this.images = new ImagesResource(t);
|
|
106
|
+
this.models = new ModelsResource(t);
|
|
107
|
+
this.usage = new UsageResource(t);
|
|
108
|
+
this.policy = new PolicyResource(t);
|
|
109
|
+
this.workflows = new WorkflowsResource(t);
|
|
110
|
+
this.fleet = new FleetResource(t);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAyB,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OA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,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK,GAAG,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC;QACpC,IAAI,CAAC,SAAS,GAAG,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ControlConfigResource } from "./resources/control/config.js";
|
|
2
|
+
import { ControlVersioningResource } from "./resources/control/versioning.js";
|
|
3
|
+
import { ControlPublishResource } from "./resources/control/publish.js";
|
|
4
|
+
import { ControlFleetResource } from "./resources/control/fleet.js";
|
|
5
|
+
import { ControlWorkersResource } from "./resources/control/workers.js";
|
|
6
|
+
import { ControlLifecycleResource } from "./resources/control/lifecycle.js";
|
|
7
|
+
import { ControlImagesResource } from "./resources/control/images.js";
|
|
8
|
+
import { ControlSecretsResource } from "./resources/control/secrets.js";
|
|
9
|
+
import { ControlAuthProvidersResource } from "./resources/control/auth-providers.js";
|
|
10
|
+
import { ControlUsersResource } from "./resources/control/users.js";
|
|
11
|
+
export interface ControlClientConfig {
|
|
12
|
+
baseUrl: string;
|
|
13
|
+
token: string;
|
|
14
|
+
principal?: string;
|
|
15
|
+
timeoutMs?: number;
|
|
16
|
+
maxRetries?: number;
|
|
17
|
+
allowBrowser?: boolean;
|
|
18
|
+
fetch?: typeof fetch;
|
|
19
|
+
}
|
|
20
|
+
export declare class ControlClient {
|
|
21
|
+
readonly config: ControlConfigResource;
|
|
22
|
+
readonly versioning: ControlVersioningResource;
|
|
23
|
+
readonly publish: ControlPublishResource;
|
|
24
|
+
readonly fleet: ControlFleetResource;
|
|
25
|
+
readonly workers: ControlWorkersResource;
|
|
26
|
+
readonly lifecycle: ControlLifecycleResource;
|
|
27
|
+
readonly images: ControlImagesResource;
|
|
28
|
+
readonly secrets: ControlSecretsResource;
|
|
29
|
+
readonly authProviders: ControlAuthProvidersResource;
|
|
30
|
+
readonly users: ControlUsersResource;
|
|
31
|
+
private readonly config_;
|
|
32
|
+
private readonly transport;
|
|
33
|
+
withPrincipal(principal: string): ControlClient;
|
|
34
|
+
constructor(config: ControlClientConfig);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=control-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-client.d.ts","sourceRoot":"","sources":["../src/control-client.ts"],"names":[],"mappings":"AA2BA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,MAAM,WAAW,mBAAmB;IAGlC,OAAO,EAAE,MAAM,CAAC;IAIhB,KAAK,EAAE,MAAM,CAAC;IAId,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,qBAAa,aAAa;IAExB,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IAEvC,QAAQ,CAAC,UAAU,EAAE,yBAAyB,CAAC;IAE/C,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;IAEzC,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC;IAErC,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;IAEzC,QAAQ,CAAC,SAAS,EAAE,wBAAwB,CAAC;IAE7C,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IAEvC,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;IAEzC,QAAQ,CAAC,aAAa,EAAE,4BAA4B,CAAC;IAErD,QAAQ,CAAC,KAAK,EAAE,oBAAoB,CAAC;IAErC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsB;IAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IAItC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,aAAa;gBAInC,MAAM,EAAE,mBAAmB;CA0CxC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Transport } from "./transport.js";
|
|
2
|
+
import { toControlError } from "./errors.js";
|
|
3
|
+
import { ControlConfigResource } from "./resources/control/config.js";
|
|
4
|
+
import { ControlVersioningResource } from "./resources/control/versioning.js";
|
|
5
|
+
import { ControlPublishResource } from "./resources/control/publish.js";
|
|
6
|
+
import { ControlFleetResource } from "./resources/control/fleet.js";
|
|
7
|
+
import { ControlWorkersResource } from "./resources/control/workers.js";
|
|
8
|
+
import { ControlLifecycleResource } from "./resources/control/lifecycle.js";
|
|
9
|
+
import { ControlImagesResource } from "./resources/control/images.js";
|
|
10
|
+
import { ControlSecretsResource } from "./resources/control/secrets.js";
|
|
11
|
+
import { ControlAuthProvidersResource } from "./resources/control/auth-providers.js";
|
|
12
|
+
import { ControlUsersResource } from "./resources/control/users.js";
|
|
13
|
+
export class ControlClient {
|
|
14
|
+
config;
|
|
15
|
+
versioning;
|
|
16
|
+
publish;
|
|
17
|
+
fleet;
|
|
18
|
+
workers;
|
|
19
|
+
lifecycle;
|
|
20
|
+
images;
|
|
21
|
+
secrets;
|
|
22
|
+
authProviders;
|
|
23
|
+
users;
|
|
24
|
+
config_;
|
|
25
|
+
transport;
|
|
26
|
+
withPrincipal(principal) {
|
|
27
|
+
return new ControlClient({ ...this.config_, principal });
|
|
28
|
+
}
|
|
29
|
+
constructor(config) {
|
|
30
|
+
this.config_ = { ...config };
|
|
31
|
+
if (!config.baseUrl)
|
|
32
|
+
throw new Error("ControlClient: `baseUrl` is required (the sema-registry base URL).");
|
|
33
|
+
if (!config.token)
|
|
34
|
+
throw new Error("ControlClient: `token` is required (the registry is fail-closed). Read it from the env-NAME SEMA_REGISTRY_TOKEN (legacy CONFIG_CENTER_TOKEN) and pass the value in.");
|
|
35
|
+
if (!config.allowBrowser && typeof globalThis.window !== "undefined") {
|
|
36
|
+
throw new Error("ControlClient: refusing to construct a token-bearing control-plane client in a browser (secret discipline). The browser must call its own BFF; only the server holds SEMA_REGISTRY_TOKEN.");
|
|
37
|
+
}
|
|
38
|
+
const token = config.token;
|
|
39
|
+
const principal = config.principal;
|
|
40
|
+
const opts = {
|
|
41
|
+
baseUrl: config.baseUrl,
|
|
42
|
+
timeoutMs: config.timeoutMs ?? 60_000,
|
|
43
|
+
maxRetries: config.maxRetries ?? 2,
|
|
44
|
+
fetchImpl: config.fetch ?? fetch,
|
|
45
|
+
buildHeaders: (idempotencyKey) => {
|
|
46
|
+
const h = {
|
|
47
|
+
authorization: `Bearer ${token}`,
|
|
48
|
+
"content-type": "application/json",
|
|
49
|
+
};
|
|
50
|
+
if (principal)
|
|
51
|
+
h["x-agent-principal"] = principal;
|
|
52
|
+
if (idempotencyKey)
|
|
53
|
+
h["idempotency-key"] = idempotencyKey;
|
|
54
|
+
return h;
|
|
55
|
+
},
|
|
56
|
+
mapError: toControlError,
|
|
57
|
+
};
|
|
58
|
+
const t = new Transport(opts);
|
|
59
|
+
this.transport = t;
|
|
60
|
+
this.config = new ControlConfigResource(t);
|
|
61
|
+
this.versioning = new ControlVersioningResource(t);
|
|
62
|
+
this.publish = new ControlPublishResource(t);
|
|
63
|
+
this.fleet = new ControlFleetResource(t);
|
|
64
|
+
this.workers = new ControlWorkersResource(t);
|
|
65
|
+
this.lifecycle = new ControlLifecycleResource(t);
|
|
66
|
+
this.images = new ControlImagesResource(t);
|
|
67
|
+
this.secrets = new ControlSecretsResource(t);
|
|
68
|
+
this.authProviders = new ControlAuthProvidersResource(t);
|
|
69
|
+
this.users = new ControlUsersResource(t);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=control-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-client.js","sourceRoot":"","sources":["../src/control-client.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,SAAS,EAAyB,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,wBAAw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