@maiaos/sdk 0.1.0-canary.10
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/README.md +62 -0
- package/dist/agent-permission/agent-permission.d.ts +9 -0
- package/dist/agent-permission/agent-permission.js +5 -0
- package/dist/agent-permission/effect.d.ts +4 -0
- package/dist/agent-permission/effect.js +34 -0
- package/dist/agent-permission/index.d.ts +2 -0
- package/dist/agent-permission/index.js +2 -0
- package/dist/agents/agents.d.ts +11 -0
- package/dist/agents/agents.js +5 -0
- package/dist/agents/effect.d.ts +5 -0
- package/dist/agents/effect.js +59 -0
- package/dist/agents/index.d.ts +2 -0
- package/dist/agents/index.js +2 -0
- package/dist/approval/approval.d.ts +10 -0
- package/dist/approval/approval.js +5 -0
- package/dist/approval/effect.d.ts +5 -0
- package/dist/approval/effect.js +43 -0
- package/dist/approval/index.d.ts +2 -0
- package/dist/approval/index.js +2 -0
- package/dist/call/call.d.ts +26 -0
- package/dist/call/call.js +6 -0
- package/dist/call/effect.d.ts +5 -0
- package/dist/call/effect.js +46 -0
- package/dist/call/index.d.ts +2 -0
- package/dist/call/index.js +2 -0
- package/dist/client/effect.d.ts +8 -0
- package/dist/client/effect.js +298 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +2 -0
- package/dist/client/local-node-client.d.ts +106 -0
- package/dist/client/local-node-client.js +4 -0
- package/dist/connection/connection.d.ts +28 -0
- package/dist/connection/connection.js +5 -0
- package/dist/connection/effect.d.ts +5 -0
- package/dist/connection/effect.js +211 -0
- package/dist/connection/index.d.ts +2 -0
- package/dist/connection/index.js +2 -0
- package/dist/container/container.d.ts +14 -0
- package/dist/container/container.js +5 -0
- package/dist/container/effect.d.ts +4 -0
- package/dist/container/effect.js +90 -0
- package/dist/container/index.d.ts +2 -0
- package/dist/container/index.js +2 -0
- package/dist/discovery/discovery.d.ts +11 -0
- package/dist/discovery/discovery.js +5 -0
- package/dist/discovery/effect.d.ts +5 -0
- package/dist/discovery/effect.js +44 -0
- package/dist/discovery/index.d.ts +2 -0
- package/dist/discovery/index.js +2 -0
- package/dist/execution/effect.d.ts +4 -0
- package/dist/execution/effect.js +8 -0
- package/dist/execution/index.d.ts +2 -0
- package/dist/execution/index.js +2 -0
- package/dist/execution/relocation.d.ts +10 -0
- package/dist/execution/relocation.js +4 -0
- package/dist/feature-bindings/feature-bindings.d.ts +10 -0
- package/dist/feature-bindings/feature-bindings.js +2 -0
- package/dist/feature-bindings/index.d.ts +2 -0
- package/dist/feature-bindings/index.js +2 -0
- package/dist/hold/effect.d.ts +5 -0
- package/dist/hold/effect.js +61 -0
- package/dist/hold/hold.d.ts +12 -0
- package/dist/hold/hold.js +5 -0
- package/dist/hold/index.d.ts +2 -0
- package/dist/hold/index.js +2 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +24 -0
- package/dist/interaction/effect.d.ts +5 -0
- package/dist/interaction/effect.js +79 -0
- package/dist/interaction/index.d.ts +2 -0
- package/dist/interaction/index.js +2 -0
- package/dist/interaction/interaction.d.ts +12 -0
- package/dist/interaction/interaction.js +5 -0
- package/dist/node/attach.d.ts +11 -0
- package/dist/node/attach.js +33 -0
- package/dist/node/bridge-frame.d.ts +18 -0
- package/dist/node/bridge-frame.js +67 -0
- package/dist/node/bridge.d.ts +55 -0
- package/dist/node/bridge.js +286 -0
- package/dist/node/deadlines.d.ts +5 -0
- package/dist/node/deadlines.js +32 -0
- package/dist/node/discovery.d.ts +192 -0
- package/dist/node/discovery.js +408 -0
- package/dist/node/effect.d.ts +10 -0
- package/dist/node/effect.js +10 -0
- package/dist/node/fetch.d.ts +2 -0
- package/dist/node/fetch.js +2 -0
- package/dist/node/http.d.ts +27 -0
- package/dist/node/http.js +270 -0
- package/dist/node/index.d.ts +3 -0
- package/dist/node/index.js +3 -0
- package/dist/node/local-node.d.ts +26 -0
- package/dist/node/local-node.js +67 -0
- package/dist/node/session.d.ts +15 -0
- package/dist/node/session.js +27 -0
- package/dist/node/ssh.d.ts +29 -0
- package/dist/node/ssh.js +122 -0
- package/dist/node/transport.d.ts +52 -0
- package/dist/node/transport.js +211 -0
- package/dist/node-changes/change.d.ts +16 -0
- package/dist/node-changes/change.js +16 -0
- package/dist/node-changes/effect.d.ts +11 -0
- package/dist/node-changes/effect.js +62 -0
- package/dist/node-changes/index.d.ts +3 -0
- package/dist/node-changes/index.js +3 -0
- package/dist/node-changes/node-changes.d.ts +7 -0
- package/dist/node-changes/node-changes.js +8 -0
- package/dist/port-lease/effect.d.ts +5 -0
- package/dist/port-lease/effect.js +53 -0
- package/dist/port-lease/index.d.ts +2 -0
- package/dist/port-lease/index.js +2 -0
- package/dist/port-lease/port-lease.d.ts +11 -0
- package/dist/port-lease/port-lease.js +5 -0
- package/dist/presentation/client.d.ts +10 -0
- package/dist/presentation/client.js +4 -0
- package/dist/presentation/effect.d.ts +5 -0
- package/dist/presentation/effect.js +30 -0
- package/dist/presentation/index.d.ts +5 -0
- package/dist/presentation/index.js +3 -0
- package/dist/presentation/project-list.d.ts +7 -0
- package/dist/presentation/project-list.js +24 -0
- package/dist/presentation/session-list.d.ts +7 -0
- package/dist/presentation/session-list.js +32 -0
- package/dist/project-guard/effect.d.ts +5 -0
- package/dist/project-guard/effect.js +39 -0
- package/dist/project-guard/index.d.ts +2 -0
- package/dist/project-guard/index.js +2 -0
- package/dist/project-guard/project-guard.d.ts +10 -0
- package/dist/project-guard/project-guard.js +5 -0
- package/dist/project-workspace/effect.d.ts +5 -0
- package/dist/project-workspace/effect.js +124 -0
- package/dist/project-workspace/index.d.ts +2 -0
- package/dist/project-workspace/index.js +2 -0
- package/dist/project-workspace/project-workspace.d.ts +23 -0
- package/dist/project-workspace/project-workspace.js +4 -0
- package/dist/provider-pool/effect.d.ts +4 -0
- package/dist/provider-pool/effect.js +5 -0
- package/dist/provider-pool/index.d.ts +2 -0
- package/dist/provider-pool/index.js +2 -0
- package/dist/provider-pool/provider-pool.d.ts +7 -0
- package/dist/provider-pool/provider-pool.js +4 -0
- package/dist/remote-node/effect.d.ts +4 -0
- package/dist/remote-node/effect.js +83 -0
- package/dist/remote-node/index.d.ts +2 -0
- package/dist/remote-node/index.js +2 -0
- package/dist/remote-node/remote-node.d.ts +14 -0
- package/dist/remote-node/remote-node.js +5 -0
- package/dist/request/classify.d.ts +15 -0
- package/dist/request/classify.js +97 -0
- package/dist/request/client-error.d.ts +11 -0
- package/dist/request/client-error.js +20 -0
- package/dist/request/effect.d.ts +22 -0
- package/dist/request/effect.js +104 -0
- package/dist/request/envelope-schema.d.ts +2 -0
- package/dist/request/envelope-schema.js +2 -0
- package/dist/request/index.d.ts +5 -0
- package/dist/request/index.js +4 -0
- package/dist/request/maia-client.d.ts +21 -0
- package/dist/request/maia-client.js +9 -0
- package/dist/request/options.d.ts +10 -0
- package/dist/request/options.js +2 -0
- package/dist/routine/effect.d.ts +5 -0
- package/dist/routine/effect.js +115 -0
- package/dist/routine/index.d.ts +2 -0
- package/dist/routine/index.js +2 -0
- package/dist/routine/routine.d.ts +17 -0
- package/dist/routine/routine.js +5 -0
- package/dist/run-ledger/effect.d.ts +5 -0
- package/dist/run-ledger/effect.js +72 -0
- package/dist/run-ledger/index.d.ts +2 -0
- package/dist/run-ledger/index.js +2 -0
- package/dist/run-ledger/run-ledger.d.ts +12 -0
- package/dist/run-ledger/run-ledger.js +2 -0
- package/dist/session/effect.d.ts +4 -0
- package/dist/session/effect.js +7 -0
- package/dist/session/index.d.ts +2 -0
- package/dist/session/index.js +2 -0
- package/dist/session/mailbox.d.ts +9 -0
- package/dist/session/mailbox.js +4 -0
- package/dist/session-creation/effect.d.ts +25 -0
- package/dist/session-creation/effect.js +269 -0
- package/dist/session-creation/index.d.ts +3 -0
- package/dist/session-creation/index.js +3 -0
- package/dist/session-creation/session-creation.d.ts +18 -0
- package/dist/session-creation/session-creation.js +24 -0
- package/dist/session-creation/tasks.d.ts +69 -0
- package/dist/session-creation/tasks.js +37 -0
- package/dist/session-view/index.d.ts +2 -0
- package/dist/session-view/index.js +2 -0
- package/dist/session-view/view.d.ts +42 -0
- package/dist/session-view/view.js +137 -0
- package/dist/stream/effect.d.ts +29 -0
- package/dist/stream/effect.js +77 -0
- package/dist/stream/index.d.ts +2 -0
- package/dist/stream/index.js +2 -0
- package/dist/stream/stream.d.ts +9 -0
- package/dist/stream/stream.js +2 -0
- package/dist/team-workspace/effect.d.ts +5 -0
- package/dist/team-workspace/effect.js +25 -0
- package/dist/team-workspace/index.d.ts +2 -0
- package/dist/team-workspace/index.js +2 -0
- package/dist/team-workspace/team-workspace.d.ts +9 -0
- package/dist/team-workspace/team-workspace.js +5 -0
- package/dist/voice/effect.d.ts +7 -0
- package/dist/voice/effect.js +71 -0
- package/dist/voice/index.d.ts +4 -0
- package/dist/voice/index.js +3 -0
- package/dist/voice/managed-turn.d.ts +9 -0
- package/dist/voice/managed-turn.js +4 -0
- package/dist/voice/orchestrator-contract.d.ts +5 -0
- package/dist/voice/orchestrator-contract.js +4 -0
- package/dist/voice/orchestrator.d.ts +25 -0
- package/dist/voice/orchestrator.js +169 -0
- package/dist/voice/pi-relay-contract.d.ts +4 -0
- package/dist/voice/pi-relay-contract.js +2 -0
- package/dist/voice/pi-relay.d.ts +12 -0
- package/dist/voice/pi-relay.js +9 -0
- package/dist/voice/wire-schema.d.ts +215 -0
- package/dist/voice/wire-schema.js +16 -0
- package/package.json +84 -0
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @maiaos/sdk
|
|
2
|
+
|
|
3
|
+
The TypeScript SDK for Maia Node: typed, validated calls to create and drive
|
|
4
|
+
AI coding agent Sessions, send turns, wait for results, read receipts and
|
|
5
|
+
observe events.
|
|
6
|
+
|
|
7
|
+
> **Pre-release.** npm carries only `nightly` and `canary` builds, which are
|
|
8
|
+
> not release-qualified. No stable release exists
|
|
9
|
+
> ([D-132](https://github.com/vllnt/maia/blob/main/docs/decisions.md#d-132)).
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
- Node.js 24.22.1.
|
|
14
|
+
- A running Maia Node on the same machine. See the
|
|
15
|
+
[quick start](https://github.com/vllnt/maia#quick-start).
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
pnpm add @maiaos/sdk@nightly
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { connectNodeApi } from "@maiaos/sdk/node";
|
|
27
|
+
|
|
28
|
+
const { client, status } = await connectNodeApi({ profile: "default" });
|
|
29
|
+
console.log(status.lifecycle); // "ready"
|
|
30
|
+
|
|
31
|
+
const projects = await client.listProjects(
|
|
32
|
+
{ afterCursor: "0", limit: 20 },
|
|
33
|
+
{ messageId: "request_projects_1" },
|
|
34
|
+
);
|
|
35
|
+
for (const project of projects.items) console.log(project.id, project.name);
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`connectNodeApi` finds the profile's private connection descriptor, reads its
|
|
39
|
+
credential and proves the Node's identity before it returns the client. A
|
|
40
|
+
mutation takes a revision and a command ID you choose; after an unknown outcome,
|
|
41
|
+
retry with the same command ID and read the receipt with `client.getReceipt`.
|
|
42
|
+
|
|
43
|
+
Every call takes request options: a `messageId`, an optional `signal` to cancel
|
|
44
|
+
and an optional `deadlineAt`, a `bigint` on your own `Clock.monotonicTimeNanos`
|
|
45
|
+
for an in-process requester that bounds its waiting. The SDK's own requesters
|
|
46
|
+
ignore `deadlineAt`.
|
|
47
|
+
|
|
48
|
+
## Status
|
|
49
|
+
|
|
50
|
+
**Source candidate.** This is the only request boundary between product
|
|
51
|
+
clients and Maia Node: the `maia` CLI, the MCP server and the Desktop and
|
|
52
|
+
Expo clients use it. It transports typed operations and never owns business
|
|
53
|
+
authority. Many methods mirror operations that are release-disabled at the
|
|
54
|
+
Node.
|
|
55
|
+
|
|
56
|
+
## Links
|
|
57
|
+
|
|
58
|
+
- [SDK reference](https://github.com/vllnt/maia/blob/main/docs/reference/sdk.md)
|
|
59
|
+
- [Normative contracts](https://github.com/vllnt/maia/blob/main/docs/reference/contracts.md)
|
|
60
|
+
- [`@maiaos/protocol`](https://github.com/vllnt/maia/blob/main/packages/protocol/README.md)
|
|
61
|
+
- [Security policy](https://github.com/vllnt/maia/blob/main/SECURITY.md)
|
|
62
|
+
- [Repository](https://github.com/vllnt/maia)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AgentPermissionConfirmParameters, AgentPermissionConfirmResult, AgentPermissionPreviewParameters, AgentPermissionPreviewResult } from "@maiaos/protocol";
|
|
2
|
+
import type { LocalNodeRequester, LocalNodeRequestOptions } from "../request/index.js";
|
|
3
|
+
export declare const makeAgentPermissionClient: (request: LocalNodeRequester) => AgentPermissionClient;
|
|
4
|
+
export type AgentPermissionClient = {
|
|
5
|
+
readonly confirmAgentPermission: (parameters: AgentPermissionConfirmParameters, options: LocalNodeRequestOptions) => Promise<AgentPermissionConfirmResult>;
|
|
6
|
+
readonly previewAgentPermission: (parameters: AgentPermissionPreviewParameters, options: LocalNodeRequestOptions) => Promise<AgentPermissionPreviewResult>;
|
|
7
|
+
};
|
|
8
|
+
export { type AgentPermissionConfirmParameters, agentPermissionConfirmParametersSchema, type AgentPermissionConfirmResult, type AgentPermissionPreviewParameters, agentPermissionPreviewParametersSchema, type AgentPermissionPreviewResult, } from "@maiaos/protocol";
|
|
9
|
+
//# sourceMappingURL=agent-permission.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { fromPromiseRequester, toPromiseClient } from "../request/effect.js";
|
|
2
|
+
import { makeAgentPermissionOperations } from "./effect.js";
|
|
3
|
+
export const makeAgentPermissionClient = (request) => toPromiseClient(makeAgentPermissionOperations(fromPromiseRequester(request)));
|
|
4
|
+
export { agentPermissionConfirmParametersSchema, agentPermissionPreviewParametersSchema, } from "@maiaos/protocol";
|
|
5
|
+
//# sourceMappingURL=agent-permission.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EffectClient, LocalNodeEffectRequester } from "../request/effect.js";
|
|
2
|
+
import type { AgentPermissionClient } from "./agent-permission.js";
|
|
3
|
+
export declare const makeAgentPermissionOperations: <TError>(request: LocalNodeEffectRequester<TError>) => EffectClient<AgentPermissionClient, TError>;
|
|
4
|
+
//# sourceMappingURL=effect.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { agentPermissionConfirmResultSchema, agentPermissionPreviewResultSchema, } from "@maiaos/protocol";
|
|
2
|
+
import { MaiaClientError } from "../request/index.js";
|
|
3
|
+
const requireBinding = (result, parameters) => {
|
|
4
|
+
const operations = [...new Set(parameters.operationIds)].sort();
|
|
5
|
+
if (result.commandId !== parameters.commandId ||
|
|
6
|
+
result.sessionId !== parameters.sessionId ||
|
|
7
|
+
result.workspaceId !== parameters.workspaceId ||
|
|
8
|
+
result.expectedSessionRevision !== parameters.expectedSessionRevision ||
|
|
9
|
+
result.expectedWorkspaceRevision !== parameters.expectedWorkspaceRevision ||
|
|
10
|
+
result.definitionRef.key !== parameters.definitionRef.key ||
|
|
11
|
+
result.definitionRef.version !== parameters.definitionRef.version ||
|
|
12
|
+
result.definitionRef.contentDigest !==
|
|
13
|
+
parameters.definitionRef.contentDigest ||
|
|
14
|
+
result.operationIds.length !== operations.length ||
|
|
15
|
+
result.operationIds.some((id, index) => id !== operations[index]))
|
|
16
|
+
throw new MaiaClientError("invalid_response", "The Agent permission response did not match the request.");
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
19
|
+
const parseConfirmation = (value, parameters) => {
|
|
20
|
+
const result = agentPermissionConfirmResultSchema.parse(value);
|
|
21
|
+
requireBinding(result.grant, parameters);
|
|
22
|
+
if (result.grant.inputDigest !== parameters.inputDigest)
|
|
23
|
+
throw new MaiaClientError("invalid_response", "The Agent permission digest did not match the request.");
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
export const makeAgentPermissionOperations = (request) => ({
|
|
27
|
+
confirmAgentPermission: (parameters, options) => request({ method: "session.agent-permission.confirm", parameters }, {
|
|
28
|
+
parse: (value) => parseConfirmation(value, parameters),
|
|
29
|
+
}, options),
|
|
30
|
+
previewAgentPermission: (parameters, options) => request({ method: "session.agent-permission.preview", parameters }, {
|
|
31
|
+
parse: (value) => requireBinding(agentPermissionPreviewResultSchema.parse(value), parameters),
|
|
32
|
+
}, options),
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=effect.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { type AgentPermissionClient, type AgentPermissionConfirmParameters, agentPermissionConfirmParametersSchema, type AgentPermissionConfirmResult, type AgentPermissionPreviewParameters, agentPermissionPreviewParametersSchema, type AgentPermissionPreviewResult, makeAgentPermissionClient, } from "./agent-permission.js";
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AgentsChangeConfirmParameters, AgentsChangeConfirmResult, AgentsChangePreviewParameters, AgentsChangePreviewResult, AgentsListParameters, AgentsListResult, AgentsShowParameters, AgentsShowResult } from "@maiaos/protocol";
|
|
2
|
+
import type { LocalNodeRequester, LocalNodeRequestOptions } from "../request/index.js";
|
|
3
|
+
export type AgentsClient = {
|
|
4
|
+
readonly confirmAgentChange: (parameters: AgentsChangeConfirmParameters, options: LocalNodeRequestOptions) => Promise<AgentsChangeConfirmResult>;
|
|
5
|
+
readonly listAgents: (parameters: AgentsListParameters, options: LocalNodeRequestOptions) => Promise<AgentsListResult>;
|
|
6
|
+
readonly previewAgentChange: (parameters: AgentsChangePreviewParameters, options: LocalNodeRequestOptions) => Promise<AgentsChangePreviewResult>;
|
|
7
|
+
readonly showAgent: (parameters: AgentsShowParameters, options: LocalNodeRequestOptions) => Promise<AgentsShowResult>;
|
|
8
|
+
};
|
|
9
|
+
export declare const makeAgentsClient: (request: LocalNodeRequester) => AgentsClient;
|
|
10
|
+
export { AGENT_AGGREGATE_TYPE, type AgentChange, agentChangeSchema, type AgentRecord, type AgentsChangeConfirmParameters, agentsChangeConfirmParametersSchema, type AgentsChangeConfirmResult, type AgentsChangePreviewParameters, agentsChangePreviewParametersSchema, type AgentsChangePreviewResult, type AgentsListParameters, agentsListParametersSchema, type AgentsListResult, type AgentSpec, agentSpecSchema, type AgentsShowParameters, agentsShowParametersSchema, type AgentsShowResult, MAX_AGENT_PAGE_SIZE, } from "@maiaos/protocol";
|
|
11
|
+
//# sourceMappingURL=agents.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { fromPromiseRequester, toPromiseClient } from "../request/effect.js";
|
|
2
|
+
import { makeAgentsOperations } from "./effect.js";
|
|
3
|
+
export const makeAgentsClient = (request) => toPromiseClient(makeAgentsOperations(fromPromiseRequester(request)));
|
|
4
|
+
export { AGENT_AGGREGATE_TYPE, agentChangeSchema, agentsChangeConfirmParametersSchema, agentsChangePreviewParametersSchema, agentsListParametersSchema, agentSpecSchema, agentsShowParametersSchema, MAX_AGENT_PAGE_SIZE, } from "@maiaos/protocol";
|
|
5
|
+
//# sourceMappingURL=agents.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type EffectClient, type LocalNodeEffectRequester } from "../request/effect.js";
|
|
2
|
+
import { MaiaClientError } from "../request/index.js";
|
|
3
|
+
import type { AgentsClient } from "./agents.js";
|
|
4
|
+
export declare const makeAgentsOperations: <TError>(request: LocalNodeEffectRequester<TError>) => EffectClient<AgentsClient, MaiaClientError | TError>;
|
|
5
|
+
//# sourceMappingURL=effect.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { agentChangeSchema, agentsChangeConfirmResultSchema, agentsChangePreviewResultSchema, agentsListResultSchema, agentsShowResultSchema, } from "@maiaos/protocol";
|
|
2
|
+
import { verifiedMutation, } from "../request/effect.js";
|
|
3
|
+
import { MaiaClientError } from "../request/index.js";
|
|
4
|
+
const requireMatch = (matches) => {
|
|
5
|
+
if (!matches)
|
|
6
|
+
throw new MaiaClientError("invalid_response", "The Agent response did not match the request.");
|
|
7
|
+
};
|
|
8
|
+
const canonical = (value) => JSON.stringify(value, (_key, nested) => typeof nested !== "object" || nested === null || Array.isArray(nested)
|
|
9
|
+
? nested
|
|
10
|
+
: Object.fromEntries(Object.entries(nested).toSorted(([left], [right]) => left.localeCompare(right))));
|
|
11
|
+
const sameChange = (echo, sent) => canonical(echo) === canonical(agentChangeSchema.parse(sent));
|
|
12
|
+
const parseList = (value, input) => {
|
|
13
|
+
const result = agentsListResultSchema.parse(value);
|
|
14
|
+
requireMatch(result.items.length <= input.limit &&
|
|
15
|
+
result.items.every((agent) => agent.projectId === input.projectId &&
|
|
16
|
+
(input.state === undefined || agent.state === input.state)));
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
19
|
+
const parseShow = (value, input) => {
|
|
20
|
+
const result = agentsShowResultSchema.parse(value);
|
|
21
|
+
requireMatch(result.agent.id === input.agentId &&
|
|
22
|
+
(input.revision === undefined ||
|
|
23
|
+
result.agent.revision === input.revision));
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
const parsePreview = (value, input) => {
|
|
27
|
+
const result = agentsChangePreviewResultSchema.parse(value);
|
|
28
|
+
requireMatch(result.commandId === input.commandId &&
|
|
29
|
+
sameChange(result.change, input.change));
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
const confirmMatches = (result, change) => {
|
|
33
|
+
if (result.kind !== change.kind)
|
|
34
|
+
return false;
|
|
35
|
+
if (change.kind === "create")
|
|
36
|
+
return (result.agent.projectId === change.projectId &&
|
|
37
|
+
canonical(result.agent.spec) === canonical(change.spec));
|
|
38
|
+
return (result.agent.id === change.agentId &&
|
|
39
|
+
BigInt(result.agent.revision) === BigInt(change.expectedRevision) + 1n &&
|
|
40
|
+
(change.kind === "disable" ||
|
|
41
|
+
canonical(result.agent.spec) === canonical(change.spec)));
|
|
42
|
+
};
|
|
43
|
+
const parseConfirm = (value, input) => {
|
|
44
|
+
const result = agentsChangeConfirmResultSchema.parse(value);
|
|
45
|
+
requireMatch(result.commandId === input.commandId &&
|
|
46
|
+
result.inputDigest === input.inputDigest &&
|
|
47
|
+
confirmMatches(result, agentChangeSchema.parse(input.change)));
|
|
48
|
+
return result;
|
|
49
|
+
};
|
|
50
|
+
const makeAgentChangeOperations = (request) => ({
|
|
51
|
+
confirmAgentChange: (parameters, options) => verifiedMutation(request({ method: "agents.change.confirm", parameters }, { parse: (value) => parseConfirm(value, parameters) }, options), options),
|
|
52
|
+
previewAgentChange: (parameters, options) => request({ method: "agents.change.preview", parameters }, { parse: (value) => parsePreview(value, parameters) }, options),
|
|
53
|
+
});
|
|
54
|
+
export const makeAgentsOperations = (request) => ({
|
|
55
|
+
...makeAgentChangeOperations(request),
|
|
56
|
+
listAgents: (parameters, options) => request({ method: "agents.list", parameters }, { parse: (value) => parseList(value, parameters) }, options),
|
|
57
|
+
showAgent: (parameters, options) => request({ method: "agents.show", parameters }, { parse: (value) => parseShow(value, parameters) }, options),
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=effect.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { AGENT_AGGREGATE_TYPE, type AgentChange, agentChangeSchema, type AgentRecord, type AgentsChangeConfirmParameters, agentsChangeConfirmParametersSchema, type AgentsChangeConfirmResult, type AgentsChangePreviewParameters, agentsChangePreviewParametersSchema, type AgentsChangePreviewResult, type AgentsClient, type AgentsListParameters, agentsListParametersSchema, type AgentsListResult, type AgentSpec, agentSpecSchema, type AgentsShowParameters, agentsShowParametersSchema, type AgentsShowResult, makeAgentsClient, MAX_AGENT_PAGE_SIZE, } from "./agents.js";
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { AGENT_AGGREGATE_TYPE, agentChangeSchema, agentsChangeConfirmParametersSchema, agentsChangePreviewParametersSchema, agentsListParametersSchema, agentSpecSchema, agentsShowParametersSchema, makeAgentsClient, MAX_AGENT_PAGE_SIZE, } from "./agents.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ApprovalListParameters, ApprovalListResult, ApprovalRespondParameters, ApprovalRespondResult, ApprovalShowParameters, ApprovalShowResult } from "@maiaos/protocol";
|
|
2
|
+
import type { LocalNodeRequester, LocalNodeRequestOptions } from "../request/index.js";
|
|
3
|
+
export type ApprovalClient = {
|
|
4
|
+
readonly listApprovals: (parameters: ApprovalListParameters, options: LocalNodeRequestOptions) => Promise<ApprovalListResult>;
|
|
5
|
+
readonly respondToApproval: (parameters: ApprovalRespondParameters, options: LocalNodeRequestOptions) => Promise<ApprovalRespondResult>;
|
|
6
|
+
readonly showApproval: (parameters: ApprovalShowParameters, options: LocalNodeRequestOptions) => Promise<ApprovalShowResult>;
|
|
7
|
+
};
|
|
8
|
+
export declare const makeApprovalClient: (request: LocalNodeRequester) => ApprovalClient;
|
|
9
|
+
export { type Approval, APPROVAL_ERROR_CODES, APPROVAL_SCHEMA_VERSION, APPROVAL_TTL_MILLISECONDS, type ApprovalErrorCode, type ApprovalListParameters, approvalListParametersSchema, type ApprovalListResult, approvalListResultSchema, type ApprovalRespondParameters, approvalRespondParametersSchema, type ApprovalRespondResult, approvalRespondResultSchema, approvalSchema, type ApprovalShowParameters, approvalShowParametersSchema, type ApprovalShowResult, approvalShowResultSchema, MAX_APPROVAL_PAGE_SIZE, } from "@maiaos/protocol";
|
|
10
|
+
//# sourceMappingURL=approval.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { fromPromiseRequester, toPromiseClient } from "../request/effect.js";
|
|
2
|
+
import { makeApprovalOperations } from "./effect.js";
|
|
3
|
+
export const makeApprovalClient = (request) => toPromiseClient(makeApprovalOperations(fromPromiseRequester(request)));
|
|
4
|
+
export { APPROVAL_ERROR_CODES, APPROVAL_SCHEMA_VERSION, APPROVAL_TTL_MILLISECONDS, approvalListParametersSchema, approvalListResultSchema, approvalRespondParametersSchema, approvalRespondResultSchema, approvalSchema, approvalShowParametersSchema, approvalShowResultSchema, MAX_APPROVAL_PAGE_SIZE, } from "@maiaos/protocol";
|
|
5
|
+
//# sourceMappingURL=approval.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type EffectClient, type LocalNodeEffectRequester } from "../request/effect.js";
|
|
2
|
+
import { MaiaClientError } from "../request/index.js";
|
|
3
|
+
import type { ApprovalClient } from "./approval.js";
|
|
4
|
+
export declare const makeApprovalOperations: <TError>(request: LocalNodeEffectRequester<TError>) => EffectClient<ApprovalClient, MaiaClientError | TError>;
|
|
5
|
+
//# sourceMappingURL=effect.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { approvalListResultSchema, approvalRespondResultSchema, approvalShowResultSchema, } from "@maiaos/protocol";
|
|
2
|
+
import { verifiedMutation, } from "../request/effect.js";
|
|
3
|
+
import { MaiaClientError } from "../request/index.js";
|
|
4
|
+
const requireMatch = (matches) => {
|
|
5
|
+
if (!matches)
|
|
6
|
+
throw new MaiaClientError("invalid_response", "The approval response did not match the request.");
|
|
7
|
+
};
|
|
8
|
+
const parseList = (value, input) => {
|
|
9
|
+
const result = approvalListResultSchema.parse(value);
|
|
10
|
+
requireMatch(result.items.length <= input.limit &&
|
|
11
|
+
result.items.every((item) => (input.sessionId === undefined ||
|
|
12
|
+
item.sessionId === input.sessionId) &&
|
|
13
|
+
(input.pendingOnly === false || item.status === "pending")));
|
|
14
|
+
return result;
|
|
15
|
+
};
|
|
16
|
+
const parseShow = (value, input) => {
|
|
17
|
+
const result = approvalShowResultSchema.parse(value);
|
|
18
|
+
requireMatch(result.approval.approvalId === input.approvalId);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
const decided = (status, input, forSession) => {
|
|
22
|
+
if (input.decision === "answer")
|
|
23
|
+
return status === "answered";
|
|
24
|
+
if (input.decision === "deny")
|
|
25
|
+
return status === "denied";
|
|
26
|
+
return (status === "approved" &&
|
|
27
|
+
forSession === (input.decision === "approve_for_session"));
|
|
28
|
+
};
|
|
29
|
+
const parseRespond = (value, input) => {
|
|
30
|
+
const result = approvalRespondResultSchema.parse(value);
|
|
31
|
+
const { approval, commandId } = result;
|
|
32
|
+
requireMatch(commandId === input.commandId &&
|
|
33
|
+
approval.approvalId === input.approvalId &&
|
|
34
|
+
approval.requestDigest === input.requestDigest &&
|
|
35
|
+
decided(approval.status, input, approval.resolution?.forSession === true));
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
export const makeApprovalOperations = (request) => ({
|
|
39
|
+
listApprovals: (parameters, options) => request({ method: "approval.list", parameters }, { parse: (value) => parseList(value, parameters) }, options),
|
|
40
|
+
respondToApproval: (parameters, options) => verifiedMutation(request({ method: "approval.respond", parameters }, { parse: (value) => parseRespond(value, parameters) }, options), options),
|
|
41
|
+
showApproval: (parameters, options) => request({ method: "approval.show", parameters }, { parse: (value) => parseShow(value, parameters) }, options),
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=effect.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { type Approval, APPROVAL_ERROR_CODES, APPROVAL_SCHEMA_VERSION, APPROVAL_TTL_MILLISECONDS, type ApprovalClient, type ApprovalErrorCode, type ApprovalListParameters, approvalListParametersSchema, type ApprovalListResult, approvalListResultSchema, type ApprovalRespondParameters, approvalRespondParametersSchema, type ApprovalRespondResult, approvalRespondResultSchema, approvalSchema, type ApprovalShowParameters, approvalShowParametersSchema, type ApprovalShowResult, approvalShowResultSchema, makeApprovalClient, MAX_APPROVAL_PAGE_SIZE, } from "./approval.js";
|
|
2
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { APPROVAL_ERROR_CODES, APPROVAL_SCHEMA_VERSION, APPROVAL_TTL_MILLISECONDS, approvalListParametersSchema, approvalListResultSchema, approvalRespondParametersSchema, approvalRespondResultSchema, approvalSchema, approvalShowParametersSchema, approvalShowResultSchema, makeApprovalClient, MAX_APPROVAL_PAGE_SIZE, } from "./approval.js";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { LocalNodeRequestPayload, LocalNodeSuccessResult } from "@maiaos/protocol";
|
|
2
|
+
import type { MaiaRegisteredFeatureOperation } from "@maiaos/protocol/feature-registry";
|
|
3
|
+
import type * as Effect from "effect/Effect";
|
|
4
|
+
import type { LocalNodeRequestOptions } from "../request/index.js";
|
|
5
|
+
type CallBoundOperation = Extract<MaiaRegisteredFeatureOperation, {
|
|
6
|
+
readonly sdk: {
|
|
7
|
+
readonly operation: "call";
|
|
8
|
+
};
|
|
9
|
+
}>;
|
|
10
|
+
export type LocalNodeCallMethod = CallBoundOperation["method"];
|
|
11
|
+
export declare const LOCAL_NODE_CALL_ENTRIES: readonly [readonly ["session.rename", "command-id"], readonly ["reference.resolve", "none"]];
|
|
12
|
+
export declare const LOCAL_NODE_CALL_METHODS: readonly LocalNodeCallMethod[];
|
|
13
|
+
export type LocalNodeCallParameters<TMethod extends LocalNodeCallMethod> = Extract<LocalNodeRequestPayload, {
|
|
14
|
+
readonly method: TMethod;
|
|
15
|
+
}>["parameters"];
|
|
16
|
+
export type LocalNodeCallResult<TMethod extends LocalNodeCallMethod> = Extract<LocalNodeSuccessResult, {
|
|
17
|
+
readonly method: TMethod;
|
|
18
|
+
}>;
|
|
19
|
+
export type LocalNodeCallClient = {
|
|
20
|
+
readonly call: <TMethod extends LocalNodeCallMethod>(method: TMethod, parameters: LocalNodeCallParameters<TMethod>, options: LocalNodeRequestOptions) => Promise<LocalNodeCallResult<TMethod>>;
|
|
21
|
+
};
|
|
22
|
+
export type LocalNodeEffectCallClient<TError> = {
|
|
23
|
+
readonly call: <TMethod extends LocalNodeCallMethod>(method: TMethod, parameters: LocalNodeCallParameters<TMethod>, options: LocalNodeRequestOptions) => Effect.Effect<LocalNodeCallResult<TMethod>, TError>;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=call.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type LocalNodeEffectRequester } from "../request/effect.js";
|
|
2
|
+
import { MaiaClientError } from "../request/index.js";
|
|
3
|
+
import { type LocalNodeEffectCallClient } from "./call.js";
|
|
4
|
+
export declare const makeCallOperation: <TError>(request: LocalNodeEffectRequester<TError>) => LocalNodeEffectCallClient<MaiaClientError | TError>;
|
|
5
|
+
//# sourceMappingURL=effect.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { localNodeRequestPayloadSchema, localNodeSuccessResultSchema, } from "@maiaos/protocol";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { verifiedMutation, } from "../request/effect.js";
|
|
4
|
+
import { MaiaClientError } from "../request/index.js";
|
|
5
|
+
import { LOCAL_NODE_CALL_ENTRIES, } from "./call.js";
|
|
6
|
+
const isCallResult = (result, method) => result.method === method;
|
|
7
|
+
const field = (value, name) => typeof value === "object" && value !== null
|
|
8
|
+
? Reflect.get(value, name)
|
|
9
|
+
: undefined;
|
|
10
|
+
const receiptMatches = (parameters, receipt) => {
|
|
11
|
+
const commandId = field(parameters, "commandId");
|
|
12
|
+
if (commandId === undefined)
|
|
13
|
+
return true;
|
|
14
|
+
const target = field(receipt, "target");
|
|
15
|
+
const type = field(target, "type");
|
|
16
|
+
const named = typeof type === "string" ? field(parameters, `${type}Id`) : undefined;
|
|
17
|
+
return (field(receipt, "commandId") === commandId &&
|
|
18
|
+
typeof named === "string" &&
|
|
19
|
+
field(target, "id") === named);
|
|
20
|
+
};
|
|
21
|
+
const parseCallResult = (method, parameters, value) => {
|
|
22
|
+
const result = localNodeSuccessResultSchema.parse(value);
|
|
23
|
+
if (isCallResult(result, method) &&
|
|
24
|
+
receiptMatches(parameters, field(result, "receipt")))
|
|
25
|
+
return result;
|
|
26
|
+
throw new MaiaClientError("invalid_response", `The ${method} response did not match the request.`);
|
|
27
|
+
};
|
|
28
|
+
const invalidCall = (method, cause) => new MaiaClientError("invalid_request", `The Maia request for ${method} failed runtime validation.`, { cause });
|
|
29
|
+
export const makeCallOperation = (request) => ({
|
|
30
|
+
call: (method, parameters, options) => {
|
|
31
|
+
const idempotency = LOCAL_NODE_CALL_ENTRIES.find(([bound]) => bound === method)?.[1];
|
|
32
|
+
const payload = localNodeRequestPayloadSchema.safeParse({
|
|
33
|
+
method,
|
|
34
|
+
parameters,
|
|
35
|
+
});
|
|
36
|
+
if (!payload.success)
|
|
37
|
+
return Effect.fail(invalidCall(method, payload.error));
|
|
38
|
+
if (idempotency === undefined)
|
|
39
|
+
return Effect.fail(invalidCall(method));
|
|
40
|
+
const effect = request(payload.data, { parse: (value) => parseCallResult(method, parameters, value) }, options);
|
|
41
|
+
return idempotency === "command-id"
|
|
42
|
+
? verifiedMutation(effect, options)
|
|
43
|
+
: effect;
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
//# sourceMappingURL=effect.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { LocalNodeEffectCallClient } from "../call/index.js";
|
|
2
|
+
import { type EffectClient, type LocalNodeEffectRequester } from "../request/effect.js";
|
|
3
|
+
import { MaiaClientError, type MaiaTransport } from "../request/index.js";
|
|
4
|
+
import type { LocalNodeClient } from "./local-node-client.js";
|
|
5
|
+
export type LocalNodeEffectClient = EffectClient<Omit<LocalNodeClient, "call">> & LocalNodeEffectCallClient<MaiaClientError>;
|
|
6
|
+
export declare const makeLocalNodeEffectClient: (request: LocalNodeEffectRequester) => LocalNodeEffectClient;
|
|
7
|
+
export declare const createLocalNodeEffectClient: (transport: MaiaTransport) => LocalNodeEffectClient;
|
|
8
|
+
//# sourceMappingURL=effect.d.ts.map
|