@maiaos/sdk 0.1.0-canary.7 → 0.1.0-canary.71
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 +21 -0
- package/README.md +105 -6
- package/dist/agents/agents.d.ts +3 -2
- package/dist/agents/agents.js +1 -1
- package/dist/agents/effect.js +4 -1
- package/dist/agents/index.d.ts +1 -1
- package/dist/agents/index.js +1 -1
- package/dist/approval/effect.d.ts +2 -0
- package/dist/approval/effect.js +1 -1
- package/dist/board/board.d.ts +23 -0
- package/dist/board/board.js +2 -0
- package/dist/board/effect.d.ts +5 -0
- package/dist/board/effect.js +176 -0
- package/dist/board/index.d.ts +3 -0
- package/dist/board/index.js +2 -0
- package/dist/browser/effect.d.ts +9 -0
- package/dist/browser/effect.js +8 -0
- package/dist/browser/exchange.d.ts +14 -0
- package/dist/browser/exchange.js +49 -0
- package/dist/browser/index.d.ts +3 -0
- package/dist/browser/index.js +2 -0
- package/dist/browser/observation.d.ts +9 -0
- package/dist/browser/observation.js +73 -0
- package/dist/browser/options.d.ts +19 -0
- package/dist/browser/options.js +2 -0
- package/dist/browser/paste.d.ts +5 -0
- package/dist/browser/paste.js +13 -0
- package/dist/browser/session.d.ts +32 -0
- package/dist/browser/session.js +79 -0
- package/dist/browser/sign-out.d.ts +5 -0
- package/dist/browser/sign-out.js +6 -0
- package/dist/browser/status.d.ts +9 -0
- package/dist/browser/status.js +22 -0
- package/dist/browser/transport.d.ts +4 -0
- package/dist/browser/transport.js +21 -0
- package/dist/call/call.d.ts +1 -1
- package/dist/call/call.js +29 -0
- package/dist/call/effect.js +26 -8
- package/dist/client/effect.js +63 -2
- package/dist/client/local-node-client.d.ts +30 -4
- package/dist/connection/effect.js +3 -0
- package/dist/discovery/discovery.d.ts +3 -3
- package/dist/discovery/discovery.js +1 -1
- package/dist/discovery/effect.js +28 -7
- package/dist/discovery/index.d.ts +1 -1
- package/dist/discovery/index.js +1 -1
- package/dist/executor/index.d.ts +2 -0
- package/dist/executor/index.js +2 -0
- package/dist/feature-bindings/feature-bindings.d.ts +7 -2
- package/dist/fleet-events/effect.d.ts +7 -0
- package/dist/fleet-events/effect.js +141 -0
- package/dist/fleet-events/fleet-events.d.ts +5 -0
- package/dist/fleet-events/fleet-events.js +7 -0
- package/dist/fleet-events/index.d.ts +3 -0
- package/dist/fleet-events/index.js +3 -0
- package/dist/fleet-events/item.d.ts +24 -0
- package/dist/fleet-events/item.js +16 -0
- package/dist/github/effect.d.ts +5 -0
- package/dist/github/effect.js +69 -0
- package/dist/github/github.d.ts +11 -0
- package/dist/github/github.js +2 -0
- package/dist/github/index.d.ts +3 -0
- package/dist/github/index.js +2 -0
- package/dist/goal/effect.d.ts +7 -0
- package/dist/goal/effect.js +65 -0
- package/dist/goal/goal.d.ts +11 -0
- package/dist/goal/goal.js +2 -0
- package/dist/goal/index.d.ts +3 -0
- package/dist/goal/index.js +2 -0
- package/dist/inbox/client.d.ts +4 -0
- package/dist/inbox/client.js +4 -0
- package/dist/inbox/effect.d.ts +5 -0
- package/dist/inbox/effect.js +70 -0
- package/dist/inbox/inbox.d.ts +11 -0
- package/dist/inbox/inbox.js +2 -0
- package/dist/inbox/index.d.ts +3 -0
- package/dist/inbox/index.js +3 -0
- package/dist/index.d.ts +21 -6
- package/dist/index.js +19 -5
- package/dist/node/bridge.js +2 -0
- package/dist/node/deadlines.js +8 -0
- package/dist/node/discovery.d.ts +42 -6
- package/dist/node/discovery.js +137 -87
- package/dist/node/effect.d.ts +4 -2
- package/dist/node/effect.js +4 -2
- package/dist/node/http.js +14 -6
- package/dist/node/local-node.d.ts +1 -0
- package/dist/node/session.d.ts +20 -1
- package/dist/node/session.js +85 -3
- package/dist/node/transport.d.ts +1 -1
- 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 -1
- package/dist/node-changes/effect.js +13 -17
- package/dist/node-changes/index.d.ts +2 -1
- package/dist/node-changes/index.js +2 -1
- package/dist/node-changes/node-changes.d.ts +1 -15
- package/dist/node-changes/node-changes.js +0 -15
- package/dist/node-update/effect.d.ts +7 -0
- package/dist/node-update/effect.js +69 -0
- package/dist/node-update/index.d.ts +3 -0
- package/dist/node-update/index.js +2 -0
- package/dist/node-update/node-update.d.ts +16 -0
- package/dist/node-update/node-update.js +2 -0
- package/dist/pairing/effect.d.ts +5 -0
- package/dist/pairing/effect.js +40 -0
- package/dist/pairing/index.d.ts +3 -0
- package/dist/pairing/index.js +2 -0
- package/dist/pairing/pairing.d.ts +9 -0
- package/dist/pairing/pairing.js +2 -0
- package/dist/principal/effect.d.ts +5 -0
- package/dist/principal/effect.js +36 -0
- package/dist/principal/index.d.ts +3 -0
- package/dist/principal/index.js +2 -0
- package/dist/principal/principal.d.ts +8 -0
- package/dist/principal/principal.js +2 -0
- package/dist/project-guard/effect.js +5 -2
- package/dist/project-guard/index.d.ts +1 -1
- package/dist/project-guard/index.js +1 -1
- package/dist/project-guard/project-guard.d.ts +1 -1
- package/dist/project-guard/project-guard.js +1 -1
- package/dist/project-knowledge/effect.d.ts +5 -0
- package/dist/project-knowledge/effect.js +95 -0
- package/dist/project-knowledge/index.d.ts +2 -0
- package/dist/project-knowledge/index.js +2 -0
- package/dist/project-knowledge/project-knowledge.d.ts +14 -0
- package/dist/project-knowledge/project-knowledge.js +2 -0
- package/dist/project-workspace/effect.js +32 -1
- package/dist/project-workspace/project-workspace.d.ts +4 -1
- package/dist/reach/effect.d.ts +5 -0
- package/dist/reach/effect.js +28 -0
- package/dist/reach/index.d.ts +3 -0
- package/dist/reach/index.js +2 -0
- package/dist/reach/reach.d.ts +8 -0
- package/dist/reach/reach.js +2 -0
- package/dist/request/classify.d.ts +4 -0
- package/dist/request/classify.js +11 -2
- package/dist/request/client-error.d.ts +2 -0
- package/dist/request/client-error.js +2 -0
- package/dist/request/effect.d.ts +1 -0
- package/dist/request/effect.js +9 -1
- package/dist/request/resume-claim.d.ts +5 -0
- package/dist/request/resume-claim.js +22 -0
- package/dist/routine/effect.js +127 -1
- package/dist/routine/index.d.ts +1 -1
- package/dist/routine/index.js +1 -1
- package/dist/routine/routine.d.ts +11 -2
- package/dist/routine/routine.js +1 -1
- package/dist/secret/effect.d.ts +5 -0
- package/dist/secret/effect.js +30 -0
- package/dist/secret/index.d.ts +3 -0
- package/dist/secret/index.js +2 -0
- package/dist/secret/secret.d.ts +8 -0
- package/dist/secret/secret.js +2 -0
- package/dist/session-creation/effect.d.ts +1 -0
- package/dist/session-creation/effect.js +4 -2
- package/dist/session-supervision/effect.d.ts +59 -0
- package/dist/session-supervision/effect.js +316 -0
- package/dist/session-supervision/index.d.ts +2 -0
- package/dist/session-supervision/index.js +2 -0
- package/dist/session-supervision/session-supervision.d.ts +34 -0
- package/dist/session-supervision/session-supervision.js +5 -0
- package/dist/session-watch/effect.d.ts +12 -0
- package/dist/session-watch/effect.js +43 -0
- package/dist/session-watch/index.d.ts +2 -0
- package/dist/session-watch/index.js +2 -0
- package/dist/session-watch/item.d.ts +14 -0
- package/dist/session-watch/item.js +2 -0
- package/dist/shell/change-source.d.ts +5 -0
- package/dist/shell/change-source.js +15 -0
- package/dist/shell/effect.d.ts +3 -0
- package/dist/shell/effect.js +2 -0
- package/dist/shell/index.d.ts +5 -0
- package/dist/shell/index.js +5 -0
- package/dist/shell/lifecycle.d.ts +42 -0
- package/dist/shell/lifecycle.js +83 -0
- package/dist/shell/relay.d.ts +35 -0
- package/dist/shell/relay.js +37 -0
- package/dist/shell/transport.d.ts +16 -0
- package/dist/shell/transport.js +143 -0
- package/dist/shell/update.d.ts +27 -0
- package/dist/shell/update.js +38 -0
- package/dist/skills-sync/effect.d.ts +23 -0
- package/dist/skills-sync/effect.js +126 -0
- package/dist/skills-sync/fan-out.d.ts +42 -0
- package/dist/skills-sync/fan-out.js +2 -0
- package/dist/skills-sync/index.d.ts +4 -0
- package/dist/skills-sync/index.js +3 -0
- package/dist/skills-sync/skills-sync.d.ts +8 -0
- package/dist/skills-sync/skills-sync.js +2 -0
- package/dist/stream/effect.d.ts +11 -7
- package/dist/stream/effect.js +21 -2
- package/dist/voice/wire-schema.d.ts +4 -3
- package/dist/webhooks/client.d.ts +4 -0
- package/dist/webhooks/client.js +4 -0
- package/dist/webhooks/effect.d.ts +5 -0
- package/dist/webhooks/effect.js +52 -0
- package/dist/webhooks/index.d.ts +4 -0
- package/dist/webhooks/index.js +3 -0
- package/dist/webhooks/webhooks.d.ts +9 -0
- package/dist/webhooks/webhooks.js +2 -0
- package/package.json +29 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 VLLNT
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -4,9 +4,10 @@ The TypeScript SDK for Maia Node: typed, validated calls to create and drive
|
|
|
4
4
|
AI coding agent Sessions, send turns, wait for results, read receipts and
|
|
5
5
|
observe events.
|
|
6
6
|
|
|
7
|
-
> **Pre-release.**
|
|
8
|
-
>
|
|
9
|
-
>
|
|
7
|
+
> **Pre-release.** Maia publishes `canary` builds to npm only, and `latest` follows the newest
|
|
8
|
+
> one (earlier nightly builds are historical). They are not release-qualified,
|
|
9
|
+
> and Maia has no stable release
|
|
10
|
+
> ([D-202](https://maia-os.vllnt.com/en/docs/decisions#d-202)).
|
|
10
11
|
|
|
11
12
|
## Requirements
|
|
12
13
|
|
|
@@ -17,7 +18,7 @@ observe events.
|
|
|
17
18
|
## Install
|
|
18
19
|
|
|
19
20
|
```sh
|
|
20
|
-
pnpm add @maiaos/sdk@
|
|
21
|
+
pnpm add @maiaos/sdk@canary
|
|
21
22
|
```
|
|
22
23
|
|
|
23
24
|
## Usage
|
|
@@ -45,6 +46,104 @@ and an optional `deadlineAt`, a `bigint` on your own `Clock.monotonicTimeNanos`
|
|
|
45
46
|
for an in-process requester that bounds its waiting. The SDK's own requesters
|
|
46
47
|
ignore `deadlineAt`.
|
|
47
48
|
|
|
49
|
+
## Browser
|
|
50
|
+
|
|
51
|
+
`@maiaos/sdk/browser` is the transport of a page that a Node serves at
|
|
52
|
+
`/panel/`: it posts each request to the Node's panel operation path with the
|
|
53
|
+
browser's own cookie and the session value in the Node's panel header, and
|
|
54
|
+
tells the page when the Node ends the session. `@maiaos/sdk/browser/effect`
|
|
55
|
+
holds the page's Effect programs: the `#code=` sign-in, the pasted link or
|
|
56
|
+
code, and the sign-out. It also exports the Effect client
|
|
57
|
+
(`createLocalNodeEffectClient`), browser-safe: a test fails if the entry
|
|
58
|
+
reaches a Node built-in.
|
|
59
|
+
|
|
60
|
+
For live updates instead of polling, `createBrowserNodeChangeSource` returns a
|
|
61
|
+
`NodeChangeSource`: `watchNodeChanges(instanceId)` streams the Node's change
|
|
62
|
+
signals (`observe.events`) and `watchSession(sessionId, after?)` one Session's
|
|
63
|
+
transcript items (`session.attach`). Each subscription asks for its own
|
|
64
|
+
one-use ticket, opens the panel's observation socket, checks every frame
|
|
65
|
+
against the registry's schema and, after a dropped socket or the Node's
|
|
66
|
+
`resync`, tickets again and resumes after the last record it handed on; a
|
|
67
|
+
`resync` item tells the page to rebuild from the records that follow. Another
|
|
68
|
+
platform implements the same interface over its own relay with
|
|
69
|
+
`makeNodeChangeSource`. The Node's panel integration test
|
|
70
|
+
(`services/node/src/runtime/node-api/panel/session.integration.test.ts`)
|
|
71
|
+
proves it against the built Node and measures its latency. The local web
|
|
72
|
+
panel,
|
|
73
|
+
[`@maiaos/panel`](https://github.com/vllnt/maia/blob/main/apps/panel/README.md),
|
|
74
|
+
is its first host.
|
|
75
|
+
|
|
76
|
+
## Native shell
|
|
77
|
+
|
|
78
|
+
`@maiaos/sdk/shell` is the transport, stream relay and boot calls of a page
|
|
79
|
+
that a native shell hosts and hands an `invoke` function to. The page never
|
|
80
|
+
holds a credential: the shell adds it.
|
|
81
|
+
|
|
82
|
+
- `createShellTransport(invoke, { newId, target? })` sends each request to
|
|
83
|
+
the shell's `node_request` command and an abort to `node_cancel`. It
|
|
84
|
+
refuses a request over 512 KiB or already cancelled before any native
|
|
85
|
+
call, and turns the shell's typed refusals into `MaiaClientError` codes.
|
|
86
|
+
- `createShellStreamRelay(invoke, openChannel)` is the Node's change relay
|
|
87
|
+
(`observe.events`) over `observation_subscribe` and `observation_cancel`;
|
|
88
|
+
`openChannel` opens the channel the shell sends frames on. A subscription
|
|
89
|
+
the shell refuses rejects with the `MaiaClientError` the transport gives
|
|
90
|
+
that reason, and no cancel follows: a refused duplicate must not end the
|
|
91
|
+
subscription that holds its ID. A subscription that fails with no declared
|
|
92
|
+
reason is cancelled once under the same ID. A cancel ends within 1 second,
|
|
93
|
+
whatever the shell answers.
|
|
94
|
+
- `@maiaos/sdk/shell/effect` exports `createShellNodeChangeSource(invoke,
|
|
95
|
+
openChannel, nextId)`, the same `NodeChangeSource` as the browser's, with
|
|
96
|
+
one Session's items over `session_attach` and `session_detach`.
|
|
97
|
+
- `readShellNodeLifecycle(invoke)` and `startShellNode(invoke)` read and
|
|
98
|
+
start the Node on the shell's machine over `node_lifecycle_status` and
|
|
99
|
+
`node_lifecycle_start`. Both answer a `ShellNodeLifecycle`: `detecting`,
|
|
100
|
+
`starting` (with `profile`), `ready` (with `instanceId`, `owner`, `pid`
|
|
101
|
+
and `profile`), `unavailable` or `failed` (with `reason`, and with
|
|
102
|
+
`profile` when the shell reported one of 1 to 128 characters; any other
|
|
103
|
+
`profile` is dropped and the record keeps its state and reason). An answer
|
|
104
|
+
that is not a whole record reads as `unavailable` with the reason
|
|
105
|
+
`invalid_response` and no `profile`, never as `ready`. The shell sends no
|
|
106
|
+
event: the page calls the read again, and owns the pause and the deadline.
|
|
107
|
+
- `reportShellReady(invoke)` tells the shell that the page mounted. It
|
|
108
|
+
resolves on the shell's `null` answer and rejects any other.
|
|
109
|
+
- `readShellCapabilities(invoke)` reads which Node service steps the shell
|
|
110
|
+
can offer now, over `shell_capabilities`. It answers a `ShellCapabilities`:
|
|
111
|
+
`nodeService` (the shell ran the Node's own service check and got a whole
|
|
112
|
+
answer) and `nodeServiceInstalled` (that answer). False means "not known to
|
|
113
|
+
be available now", not "no service": the shell answers false, false
|
|
114
|
+
whenever it could not finish its check, also while another read runs. Any
|
|
115
|
+
answer that is not the whole version 1 record reads false, false, and so
|
|
116
|
+
does one that says installed without a service the shell could check. The
|
|
117
|
+
SDK asks once, with no retry and no cache: read it at boot and after a
|
|
118
|
+
service step, never in a loop. A shell without the command rejects, which
|
|
119
|
+
a caller treats like false, false.
|
|
120
|
+
- `readShellUpdateStatus(invoke)` reads what the shell knows about updates,
|
|
121
|
+
over `shell_update_status`: `bundleVersion`, and `pendingBundle`,
|
|
122
|
+
`nativeUpdate` and `fallback`, each `null` when the shell reported none.
|
|
123
|
+
- `reportShellPageBusy(invoke, busy)` tells the shell whether the page is
|
|
124
|
+
busy, over `page_busy_set`, once per call with no debounce.
|
|
125
|
+
|
|
126
|
+
Both update functions ask the shell once, with no retry and no cache, and
|
|
127
|
+
reject with a `MaiaClientError`: `invalid_response` for an answer that is not
|
|
128
|
+
a whole record (or, for the busy report, not `null`), `invalid_request` when
|
|
129
|
+
the shell does not offer the command or denied the page, and
|
|
130
|
+
`transport_failure` otherwise, also when the host has not answered after 6
|
|
131
|
+
seconds.
|
|
132
|
+
|
|
133
|
+
The three boot functions and the capabilities read reject with a
|
|
134
|
+
`MaiaClientError`, mapped as the transport maps a refusal. The lifecycle
|
|
135
|
+
read, the ready report and the capabilities read also reject as a
|
|
136
|
+
`transport_failure` when the host has not answered after 6 seconds (the
|
|
137
|
+
bridge's 5-second deadline plus its 1-second cancellation deadline). The
|
|
138
|
+
start has no page-side deadline: the shell answers it only once its Node is
|
|
139
|
+
ready or failed, under a bound of its own.
|
|
140
|
+
|
|
141
|
+
The host generates every ID, and the shell admits one prefix per command
|
|
142
|
+
pair: `renderer_` for a request, `observation_` for a change subscription
|
|
143
|
+
and `attach_` for a Session's items, each followed by letters and digits.
|
|
144
|
+
The entry imports no webview framework; a test fails if it reaches a Node
|
|
145
|
+
built-in or any package but `effect`.
|
|
146
|
+
|
|
48
147
|
## Status
|
|
49
148
|
|
|
50
149
|
**Source candidate.** This is the only request boundary between product
|
|
@@ -55,8 +154,8 @@ Node.
|
|
|
55
154
|
|
|
56
155
|
## Links
|
|
57
156
|
|
|
58
|
-
- [SDK reference](https://
|
|
59
|
-
- [Normative contracts](https://
|
|
157
|
+
- [SDK reference](https://maia-os.vllnt.com/en/docs/reference/sdk)
|
|
158
|
+
- [Normative contracts](https://maia-os.vllnt.com/en/docs/reference/contracts)
|
|
60
159
|
- [`@maiaos/protocol`](https://github.com/vllnt/maia/blob/main/packages/protocol/README.md)
|
|
61
160
|
- [Security policy](https://github.com/vllnt/maia/blob/main/SECURITY.md)
|
|
62
161
|
- [Repository](https://github.com/vllnt/maia)
|
package/dist/agents/agents.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { AgentsChangeConfirmParameters, AgentsChangeConfirmResult, AgentsChangePreviewParameters, AgentsChangePreviewResult, AgentsListParameters, AgentsListResult, AgentsShowParameters, AgentsShowResult } from "@maiaos/protocol";
|
|
1
|
+
import type { AgentsChangeConfirmParameters, AgentsChangeConfirmResult, AgentsChangePreviewParameters, AgentsChangePreviewResult, AgentsDetectParameters, AgentsDetectResult, AgentsListParameters, AgentsListResult, AgentsShowParameters, AgentsShowResult } from "@maiaos/protocol";
|
|
2
2
|
import type { LocalNodeRequester, LocalNodeRequestOptions } from "../request/index.js";
|
|
3
3
|
export type AgentsClient = {
|
|
4
4
|
readonly confirmAgentChange: (parameters: AgentsChangeConfirmParameters, options: LocalNodeRequestOptions) => Promise<AgentsChangeConfirmResult>;
|
|
5
|
+
readonly detectAgents: (parameters: AgentsDetectParameters, options: LocalNodeRequestOptions) => Promise<AgentsDetectResult>;
|
|
5
6
|
readonly listAgents: (parameters: AgentsListParameters, options: LocalNodeRequestOptions) => Promise<AgentsListResult>;
|
|
6
7
|
readonly previewAgentChange: (parameters: AgentsChangePreviewParameters, options: LocalNodeRequestOptions) => Promise<AgentsChangePreviewResult>;
|
|
7
8
|
readonly showAgent: (parameters: AgentsShowParameters, options: LocalNodeRequestOptions) => Promise<AgentsShowResult>;
|
|
8
9
|
};
|
|
9
10
|
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
|
+
export { AGENT_AGGREGATE_TYPE, type AgentChange, agentChangeSchema, type AgentRecord, type AgentsChangeConfirmParameters, agentsChangeConfirmParametersSchema, type AgentsChangeConfirmResult, type AgentsChangePreviewParameters, agentsChangePreviewParametersSchema, type AgentsChangePreviewResult, type AgentsDetectParameters, agentsDetectParametersSchema, type AgentsDetectResult, type AgentsListParameters, agentsListParametersSchema, type AgentsListResult, type AgentSpec, agentSpecSchema, type AgentsShowParameters, agentsShowParametersSchema, type AgentsShowResult, MAX_AGENT_PAGE_SIZE, } from "@maiaos/protocol";
|
|
11
12
|
//# sourceMappingURL=agents.d.ts.map
|
package/dist/agents/agents.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fromPromiseRequester, toPromiseClient } from "../request/effect.js";
|
|
2
2
|
import { makeAgentsOperations } from "./effect.js";
|
|
3
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";
|
|
4
|
+
export { AGENT_AGGREGATE_TYPE, agentChangeSchema, agentsChangeConfirmParametersSchema, agentsChangePreviewParametersSchema, agentsDetectParametersSchema, agentsListParametersSchema, agentSpecSchema, agentsShowParametersSchema, MAX_AGENT_PAGE_SIZE, } from "@maiaos/protocol";
|
|
5
5
|
//# sourceMappingURL=agents.js.map
|
package/dist/agents/effect.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { agentChangeSchema, agentsChangeConfirmResultSchema, agentsChangePreviewResultSchema, agentsListResultSchema, agentsShowResultSchema, } from "@maiaos/protocol";
|
|
1
|
+
import { agentChangeSchema, agentsChangeConfirmResultSchema, agentsChangePreviewResultSchema, agentsDetectResultSchema, agentsListResultSchema, agentsShowResultSchema, } from "@maiaos/protocol";
|
|
2
2
|
import { verifiedMutation, } from "../request/effect.js";
|
|
3
3
|
import { MaiaClientError } from "../request/index.js";
|
|
4
4
|
const requireMatch = (matches) => {
|
|
@@ -53,6 +53,9 @@ const makeAgentChangeOperations = (request) => ({
|
|
|
53
53
|
});
|
|
54
54
|
export const makeAgentsOperations = (request) => ({
|
|
55
55
|
...makeAgentChangeOperations(request),
|
|
56
|
+
detectAgents: (parameters, options) => request({ method: "agents.detect", parameters }, {
|
|
57
|
+
parse: (value) => agentsDetectResultSchema.parse(value),
|
|
58
|
+
}, options),
|
|
56
59
|
listAgents: (parameters, options) => request({ method: "agents.list", parameters }, { parse: (value) => parseList(value, parameters) }, options),
|
|
57
60
|
showAgent: (parameters, options) => request({ method: "agents.show", parameters }, { parse: (value) => parseShow(value, parameters) }, options),
|
|
58
61
|
});
|
package/dist/agents/index.d.ts
CHANGED
|
@@ -1,2 +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";
|
|
1
|
+
export { AGENT_AGGREGATE_TYPE, type AgentChange, agentChangeSchema, type AgentRecord, type AgentsChangeConfirmParameters, agentsChangeConfirmParametersSchema, type AgentsChangeConfirmResult, type AgentsChangePreviewParameters, agentsChangePreviewParametersSchema, type AgentsChangePreviewResult, type AgentsClient, type AgentsDetectParameters, agentsDetectParametersSchema, type AgentsDetectResult, type AgentsListParameters, agentsListParametersSchema, type AgentsListResult, type AgentSpec, agentSpecSchema, type AgentsShowParameters, agentsShowParametersSchema, type AgentsShowResult, makeAgentsClient, MAX_AGENT_PAGE_SIZE, } from "./agents.js";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/agents/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AGENT_AGGREGATE_TYPE, agentChangeSchema, agentsChangeConfirmParametersSchema, agentsChangePreviewParametersSchema, agentsListParametersSchema, agentSpecSchema, agentsShowParametersSchema, makeAgentsClient, MAX_AGENT_PAGE_SIZE, } from "./agents.js";
|
|
1
|
+
export { AGENT_AGGREGATE_TYPE, agentChangeSchema, agentsChangeConfirmParametersSchema, agentsChangePreviewParametersSchema, agentsDetectParametersSchema, agentsListParametersSchema, agentSpecSchema, agentsShowParametersSchema, makeAgentsClient, MAX_AGENT_PAGE_SIZE, } from "./agents.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { type ApprovalRespondParameters } from "@maiaos/protocol";
|
|
1
2
|
import { type EffectClient, type LocalNodeEffectRequester } from "../request/effect.js";
|
|
2
3
|
import { MaiaClientError } from "../request/index.js";
|
|
3
4
|
import type { ApprovalClient } from "./approval.js";
|
|
5
|
+
export declare const decided: (status: string, input: Pick<ApprovalRespondParameters, "decision">, forSession: boolean) => boolean;
|
|
4
6
|
export declare const makeApprovalOperations: <TError>(request: LocalNodeEffectRequester<TError>) => EffectClient<ApprovalClient, MaiaClientError | TError>;
|
|
5
7
|
//# sourceMappingURL=effect.d.ts.map
|
package/dist/approval/effect.js
CHANGED
|
@@ -18,7 +18,7 @@ const parseShow = (value, input) => {
|
|
|
18
18
|
requireMatch(result.approval.approvalId === input.approvalId);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
const decided = (status, input, forSession) => {
|
|
21
|
+
export const decided = (status, input, forSession) => {
|
|
22
22
|
if (input.decision === "answer")
|
|
23
23
|
return status === "answered";
|
|
24
24
|
if (input.decision === "deny")
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { BoardMessagePostParameters, BoardMessagePostResult, BoardMessageReplyParameters, BoardMessageReplyResult, BoardPathReadParameters, BoardPathReadResult, BoardTaskAssignParameters, BoardTaskAssignResult, BoardTaskCancelParameters, BoardTaskCancelResult, BoardTaskClaimParameters, BoardTaskClaimResult, BoardTaskCompleteParameters, BoardTaskCompleteResult, BoardTaskCreateParameters, BoardTaskCreateResult, BoardTaskFailParameters, BoardTaskFailResult, BoardTaskListParameters, BoardTaskListResult, BoardTaskNeedsReplaceParameters, BoardTaskNeedsReplaceResult, BoardTaskPlanParameters, BoardTaskPlanResult, BoardTaskPromoteParameters, BoardTaskPromoteResult, BoardTaskReleaseParameters, BoardTaskReleaseResult, BoardTaskRenewParameters, BoardTaskRenewResult, BoardTaskReopenParameters, BoardTaskReopenResult, BoardTaskShowParameters, BoardTaskShowResult, BoardThreadShowParameters, BoardThreadShowResult } from "@maiaos/protocol";
|
|
2
|
+
import type { LocalNodeRequestOptions } from "../request/index.js";
|
|
3
|
+
export type BoardClient = {
|
|
4
|
+
readonly assignBoardTask: (parameters: BoardTaskAssignParameters, options: LocalNodeRequestOptions) => Promise<BoardTaskAssignResult>;
|
|
5
|
+
readonly cancelBoardTask: (parameters: BoardTaskCancelParameters, options: LocalNodeRequestOptions) => Promise<BoardTaskCancelResult>;
|
|
6
|
+
readonly claimBoardTask: (parameters: BoardTaskClaimParameters, options: LocalNodeRequestOptions) => Promise<BoardTaskClaimResult>;
|
|
7
|
+
readonly completeBoardTask: (parameters: BoardTaskCompleteParameters, options: LocalNodeRequestOptions) => Promise<BoardTaskCompleteResult>;
|
|
8
|
+
readonly createBoardTask: (parameters: BoardTaskCreateParameters, options: LocalNodeRequestOptions) => Promise<BoardTaskCreateResult>;
|
|
9
|
+
readonly failBoardTask: (parameters: BoardTaskFailParameters, options: LocalNodeRequestOptions) => Promise<BoardTaskFailResult>;
|
|
10
|
+
readonly listBoardTasks: (parameters: BoardTaskListParameters, options: LocalNodeRequestOptions) => Promise<BoardTaskListResult>;
|
|
11
|
+
readonly planBoardTasks: (parameters: BoardTaskPlanParameters, options: LocalNodeRequestOptions) => Promise<BoardTaskPlanResult>;
|
|
12
|
+
readonly postBoardMessage: (parameters: BoardMessagePostParameters, options: LocalNodeRequestOptions) => Promise<BoardMessagePostResult>;
|
|
13
|
+
readonly promoteBoardThread: (parameters: BoardTaskPromoteParameters, options: LocalNodeRequestOptions) => Promise<BoardTaskPromoteResult>;
|
|
14
|
+
readonly readBoardPath: (parameters: BoardPathReadParameters, options: LocalNodeRequestOptions) => Promise<BoardPathReadResult>;
|
|
15
|
+
readonly releaseBoardTask: (parameters: BoardTaskReleaseParameters, options: LocalNodeRequestOptions) => Promise<BoardTaskReleaseResult>;
|
|
16
|
+
readonly renewBoardTask: (parameters: BoardTaskRenewParameters, options: LocalNodeRequestOptions) => Promise<BoardTaskRenewResult>;
|
|
17
|
+
readonly reopenBoardTask: (parameters: BoardTaskReopenParameters, options: LocalNodeRequestOptions) => Promise<BoardTaskReopenResult>;
|
|
18
|
+
readonly replaceBoardTaskNeeds: (parameters: BoardTaskNeedsReplaceParameters, options: LocalNodeRequestOptions) => Promise<BoardTaskNeedsReplaceResult>;
|
|
19
|
+
readonly replyToBoardMessage: (parameters: BoardMessageReplyParameters, options: LocalNodeRequestOptions) => Promise<BoardMessageReplyResult>;
|
|
20
|
+
readonly showBoardTask: (parameters: BoardTaskShowParameters, options: LocalNodeRequestOptions) => Promise<BoardTaskShowResult>;
|
|
21
|
+
readonly showBoardThread: (parameters: BoardThreadShowParameters, options: LocalNodeRequestOptions) => Promise<BoardThreadShowResult>;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=board.d.ts.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 { BoardClient } from "./board.js";
|
|
4
|
+
export declare const makeBoardOperations: <TError>(request: LocalNodeEffectRequester<TError>) => EffectClient<BoardClient, MaiaClientError | TError>;
|
|
5
|
+
//# sourceMappingURL=effect.d.ts.map
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { boardMessagePostResultSchema, boardMessageReplyResultSchema, boardPathReadResultSchema, boardTaskAssignResultSchema, boardTaskCancelResultSchema, boardTaskClaimResultSchema, boardTaskCompleteResultSchema, boardTaskCreateResultSchema, boardTaskFailResultSchema, boardTaskListResultSchema, boardTaskNeedsReplaceResultSchema, boardTaskPlanResultSchema, boardTaskPromoteResultSchema, boardTaskReleaseResultSchema, boardTaskRenewResultSchema, boardTaskReopenResultSchema, boardTaskShowResultSchema, boardThreadShowResultSchema, } 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 board response did not match the request.");
|
|
7
|
+
};
|
|
8
|
+
const nextRevision = (task, expected) => BigInt(task.revision) === BigInt(expected) + 1n;
|
|
9
|
+
const underPath = (path, prefix) => path === prefix || path.startsWith(`${prefix}/`);
|
|
10
|
+
const sameNeeds = (got, wanted) => (got ?? []).join("\n") === (wanted ?? []).join("\n");
|
|
11
|
+
const parseCreate = (value, input) => {
|
|
12
|
+
const result = boardTaskCreateResultSchema.parse(value);
|
|
13
|
+
requireMatch(result.commandId === input.commandId &&
|
|
14
|
+
result.task.workspaceId === input.workspaceId &&
|
|
15
|
+
result.task.path === input.path &&
|
|
16
|
+
result.task.text === input.text &&
|
|
17
|
+
sameNeeds(result.task.needs, input.needs));
|
|
18
|
+
return result;
|
|
19
|
+
};
|
|
20
|
+
const parsePlan = (value, input) => {
|
|
21
|
+
const result = boardTaskPlanResultSchema.parse(value);
|
|
22
|
+
requireMatch(result.commandId === input.commandId &&
|
|
23
|
+
result.tasks.length === input.tasks.length &&
|
|
24
|
+
result.tasks.every((task, index) => task.key === input.tasks[index]?.key &&
|
|
25
|
+
task.path === input.tasks[index].path));
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
const claimedAs = (task, agent) => {
|
|
29
|
+
const claimant = task.claim?.claimant;
|
|
30
|
+
return (claimant !== undefined &&
|
|
31
|
+
(agent === undefined ||
|
|
32
|
+
(claimant.kind === "session" && claimant.agent === agent)));
|
|
33
|
+
};
|
|
34
|
+
const parseClaim = (value, input) => {
|
|
35
|
+
const result = boardTaskClaimResultSchema.parse(value);
|
|
36
|
+
const { commandId, task } = result;
|
|
37
|
+
const target = input.taskId === undefined
|
|
38
|
+
? task.workspaceId === input.workspaceId &&
|
|
39
|
+
underPath(task.path, input.path ?? "")
|
|
40
|
+
: task.id === input.taskId &&
|
|
41
|
+
nextRevision(task, input.expectedRevision ?? "0");
|
|
42
|
+
requireMatch(commandId === input.commandId && target && claimedAs(task, input.as));
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
const parseChange = (schema) => (value, input) => {
|
|
46
|
+
const result = schema.parse(value);
|
|
47
|
+
requireMatch(result.commandId === input.commandId &&
|
|
48
|
+
result.task.id === input.taskId &&
|
|
49
|
+
nextRevision(result.task, input.expectedRevision));
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
const parseRenew = parseChange(boardTaskRenewResultSchema);
|
|
53
|
+
const parseRelease = parseChange(boardTaskReleaseResultSchema);
|
|
54
|
+
const parseComplete = parseChange(boardTaskCompleteResultSchema);
|
|
55
|
+
const parseFail = parseChange(boardTaskFailResultSchema);
|
|
56
|
+
const parseCancel = parseChange(boardTaskCancelResultSchema);
|
|
57
|
+
const parseReopen = parseChange(boardTaskReopenResultSchema);
|
|
58
|
+
const parseAssign = (value, input) => {
|
|
59
|
+
const result = parseChange(boardTaskAssignResultSchema)(value, input);
|
|
60
|
+
requireMatch(result.task.assignee === input.assignee);
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
const parsePromote = (value, input) => {
|
|
64
|
+
const result = boardTaskPromoteResultSchema.parse(value);
|
|
65
|
+
requireMatch(result.commandId === input.commandId &&
|
|
66
|
+
result.task.id === input.threadId &&
|
|
67
|
+
result.task.workspaceId === input.workspaceId &&
|
|
68
|
+
sameNeeds(result.task.needs, input.needs));
|
|
69
|
+
return result;
|
|
70
|
+
};
|
|
71
|
+
const parseNeedsReplace = (value, input) => {
|
|
72
|
+
const result = parseChange(boardTaskNeedsReplaceResultSchema)(value, input);
|
|
73
|
+
requireMatch(sameNeeds(result.task.needs, input.needs));
|
|
74
|
+
return result;
|
|
75
|
+
};
|
|
76
|
+
const heldBy = (task, { projectId, sessionId }) => {
|
|
77
|
+
if (projectId === undefined && sessionId === undefined)
|
|
78
|
+
return true;
|
|
79
|
+
const claimant = task.claim?.claimant;
|
|
80
|
+
return (claimant?.kind === "session" &&
|
|
81
|
+
claimant.sessionId !== undefined &&
|
|
82
|
+
(sessionId === undefined || claimant.sessionId === sessionId));
|
|
83
|
+
};
|
|
84
|
+
const parseList = (value, input) => {
|
|
85
|
+
const result = boardTaskListResultSchema.parse(value);
|
|
86
|
+
requireMatch(result.items.length <= (input.limit ?? result.items.length) &&
|
|
87
|
+
result.items.every((task) => (input.workspaceId === undefined ||
|
|
88
|
+
task.workspaceId === input.workspaceId) &&
|
|
89
|
+
(input.state === undefined || task.state === input.state) &&
|
|
90
|
+
(input.path === undefined || underPath(task.path, input.path)) &&
|
|
91
|
+
heldBy(task, input)));
|
|
92
|
+
return result;
|
|
93
|
+
};
|
|
94
|
+
const parseShow = (value, input) => {
|
|
95
|
+
const result = boardTaskShowResultSchema.parse(value);
|
|
96
|
+
requireMatch(result.task.id === input.taskId &&
|
|
97
|
+
result.messages.length <= (input.limit ?? result.messages.length));
|
|
98
|
+
return result;
|
|
99
|
+
};
|
|
100
|
+
const actedAs = (actor, agent) => agent === undefined || (actor?.kind === "session" && actor.agent === agent);
|
|
101
|
+
const parsePost = (value, input) => {
|
|
102
|
+
const result = boardMessagePostResultSchema.parse(value);
|
|
103
|
+
requireMatch(result.commandId === input.commandId &&
|
|
104
|
+
result.thread.path === input.path &&
|
|
105
|
+
result.message.text === input.text &&
|
|
106
|
+
actedAs(result.message.author, input.as));
|
|
107
|
+
return result;
|
|
108
|
+
};
|
|
109
|
+
const parseReply = (value, input) => {
|
|
110
|
+
const result = boardMessageReplyResultSchema.parse(value);
|
|
111
|
+
requireMatch(result.commandId === input.commandId &&
|
|
112
|
+
result.message.threadId === input.threadId &&
|
|
113
|
+
result.message.text === input.text &&
|
|
114
|
+
actedAs(result.message.author, input.as));
|
|
115
|
+
return result;
|
|
116
|
+
};
|
|
117
|
+
const parseReadPath = (value, input) => {
|
|
118
|
+
const result = boardPathReadResultSchema.parse(value);
|
|
119
|
+
requireMatch(result.items.length <= (input.limit ?? result.items.length) &&
|
|
120
|
+
actedAs(result.actor, input.as) &&
|
|
121
|
+
result.items.every((thread) => thread.workspaceId === input.workspaceId &&
|
|
122
|
+
underPath(thread.path, input.path)));
|
|
123
|
+
return result;
|
|
124
|
+
};
|
|
125
|
+
const parseShowThread = (value, input) => {
|
|
126
|
+
const result = boardThreadShowResultSchema.parse(value);
|
|
127
|
+
requireMatch(result.thread.id === input.threadId &&
|
|
128
|
+
result.messages.length <= (input.limit ?? result.messages.length) &&
|
|
129
|
+
actedAs(result.actor, input.as));
|
|
130
|
+
return result;
|
|
131
|
+
};
|
|
132
|
+
const makeMessageMutations = (request) => ({
|
|
133
|
+
postBoardMessage: (parameters, options) => request({ method: "board.message.post", parameters }, { parse: (value) => parsePost(value, parameters) }, options),
|
|
134
|
+
replyToBoardMessage: (parameters, options) => request({ method: "board.message.reply", parameters }, { parse: (value) => parseReply(value, parameters) }, options),
|
|
135
|
+
});
|
|
136
|
+
const makeMessageReads = (request) => ({
|
|
137
|
+
readBoardPath: (parameters, options) => request({ method: "board.path.read", parameters }, { parse: (value) => parseReadPath(value, parameters) }, options),
|
|
138
|
+
showBoardThread: (parameters, options) => request({ method: "board.thread.show", parameters }, { parse: (value) => parseShowThread(value, parameters) }, options),
|
|
139
|
+
});
|
|
140
|
+
const makeClaimMutations = (request) => ({
|
|
141
|
+
claimBoardTask: (parameters, options) => request({ method: "board.task.claim", parameters }, { parse: (value) => parseClaim(value, parameters) }, options),
|
|
142
|
+
createBoardTask: (parameters, options) => request({ method: "board.task.create", parameters }, { parse: (value) => parseCreate(value, parameters) }, options),
|
|
143
|
+
planBoardTasks: (parameters, options) => request({ method: "board.task.plan", parameters }, { parse: (value) => parsePlan(value, parameters) }, options),
|
|
144
|
+
});
|
|
145
|
+
const makeHeldMutations = (request) => ({
|
|
146
|
+
completeBoardTask: (parameters, options) => request({ method: "board.task.complete", parameters }, { parse: (value) => parseComplete(value, parameters) }, options),
|
|
147
|
+
failBoardTask: (parameters, options) => request({ method: "board.task.fail", parameters }, { parse: (value) => parseFail(value, parameters) }, options),
|
|
148
|
+
...makeHandBackMutations(request),
|
|
149
|
+
});
|
|
150
|
+
const makeHandBackMutations = (request) => ({
|
|
151
|
+
releaseBoardTask: (parameters, options) => request({ method: "board.task.release", parameters }, { parse: (value) => parseRelease(value, parameters) }, options),
|
|
152
|
+
renewBoardTask: (parameters, options) => request({ method: "board.task.renew", parameters }, { parse: (value) => parseRenew(value, parameters) }, options),
|
|
153
|
+
});
|
|
154
|
+
const makeLifecycleMutations = (request) => ({
|
|
155
|
+
cancelBoardTask: (parameters, options) => request({ method: "board.task.cancel", parameters }, { parse: (value) => parseCancel(value, parameters) }, options),
|
|
156
|
+
reopenBoardTask: (parameters, options) => request({ method: "board.task.reopen", parameters }, { parse: (value) => parseReopen(value, parameters) }, options),
|
|
157
|
+
});
|
|
158
|
+
const makeManageMutations = (request) => ({
|
|
159
|
+
assignBoardTask: (parameters, options) => request({ method: "board.task.assign", parameters }, { parse: (value) => parseAssign(value, parameters) }, options),
|
|
160
|
+
promoteBoardThread: (parameters, options) => request({ method: "board.task.promote", parameters }, { parse: (value) => parsePromote(value, parameters) }, options),
|
|
161
|
+
replaceBoardTaskNeeds: (parameters, options) => request({ method: "board.task.needs.replace", parameters }, { parse: (value) => parseNeedsReplace(value, parameters) }, options),
|
|
162
|
+
});
|
|
163
|
+
export const makeBoardOperations = (request) => {
|
|
164
|
+
const verified = (payload, output, options) => verifiedMutation(request(payload, output, options), options);
|
|
165
|
+
return {
|
|
166
|
+
...makeClaimMutations(verified),
|
|
167
|
+
...makeHeldMutations(verified),
|
|
168
|
+
...makeLifecycleMutations(verified),
|
|
169
|
+
...makeManageMutations(verified),
|
|
170
|
+
...makeMessageMutations(verified),
|
|
171
|
+
...makeMessageReads(request),
|
|
172
|
+
listBoardTasks: (parameters, options) => request({ method: "board.task.list", parameters }, { parse: (value) => parseList(value, parameters) }, options),
|
|
173
|
+
showBoardTask: (parameters, options) => request({ method: "board.task.show", parameters }, { parse: (value) => parseShow(value, parameters) }, options),
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
//# sourceMappingURL=effect.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { type BoardClient } from "./board.js";
|
|
2
|
+
export { BOARD_ERROR_CODES, type BoardActor, type BoardClaim, type BoardErrorCode, type BoardMessage, type BoardMessagePostParameters, boardMessagePostParametersSchema, type BoardMessagePostResult, type BoardMessageReplyParameters, boardMessageReplyParametersSchema, type BoardMessageReplyResult, type BoardPathReadParameters, boardPathReadParametersSchema, type BoardPathReadResult, type BoardPlanTask, type BoardTask, type BoardTaskAssignParameters, boardTaskAssignParametersSchema, type BoardTaskAssignResult, type BoardTaskCancelParameters, boardTaskCancelParametersSchema, type BoardTaskCancelResult, type BoardTaskClaimParameters, boardTaskClaimParametersSchema, type BoardTaskClaimResult, type BoardTaskCompleteParameters, boardTaskCompleteParametersSchema, type BoardTaskCompleteResult, type BoardTaskCreateParameters, boardTaskCreateParametersSchema, type BoardTaskCreateResult, type BoardTaskFailParameters, boardTaskFailParametersSchema, type BoardTaskFailResult, type BoardTaskListParameters, boardTaskListParametersSchema, type BoardTaskListResult, type BoardTaskNeedsReplaceParameters, boardTaskNeedsReplaceParametersSchema, type BoardTaskNeedsReplaceResult, type BoardTaskPlanParameters, boardTaskPlanParametersSchema, type BoardTaskPlanResult, type BoardTaskPromoteParameters, boardTaskPromoteParametersSchema, type BoardTaskPromoteResult, type BoardTaskReleaseParameters, boardTaskReleaseParametersSchema, type BoardTaskReleaseResult, type BoardTaskRenewParameters, boardTaskRenewParametersSchema, type BoardTaskRenewResult, type BoardTaskReopenParameters, boardTaskReopenParametersSchema, type BoardTaskReopenResult, type BoardTaskShowParameters, boardTaskShowParametersSchema, type BoardTaskShowResult, type BoardTaskState, type BoardTaskSummary, type BoardThreadShowParameters, boardThreadShowParametersSchema, type BoardThreadShowResult, type BoardThreadSummary, DEFAULT_BOARD_LEASE_SECONDS, MAX_BOARD_LEASE_SECONDS, MAX_BOARD_PLAN_JSON_BYTES, MAX_BOARD_PLAN_TASKS, MAX_BOARD_PLAN_TEXT_BYTES, MAX_BOARD_TASK_NEEDS, MAX_BOARD_TASK_PAGE_SIZE, MAX_BOARD_THREAD_MESSAGES, MAX_BOARD_THREAD_PAGE_SIZE, MIN_BOARD_LEASE_SECONDS, } from "@maiaos/protocol";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { BOARD_ERROR_CODES, boardMessagePostParametersSchema, boardMessageReplyParametersSchema, boardPathReadParametersSchema, boardTaskAssignParametersSchema, boardTaskCancelParametersSchema, boardTaskClaimParametersSchema, boardTaskCompleteParametersSchema, boardTaskCreateParametersSchema, boardTaskFailParametersSchema, boardTaskListParametersSchema, boardTaskNeedsReplaceParametersSchema, boardTaskPlanParametersSchema, boardTaskPromoteParametersSchema, boardTaskReleaseParametersSchema, boardTaskRenewParametersSchema, boardTaskReopenParametersSchema, boardTaskShowParametersSchema, boardThreadShowParametersSchema, DEFAULT_BOARD_LEASE_SECONDS, MAX_BOARD_LEASE_SECONDS, MAX_BOARD_PLAN_JSON_BYTES, MAX_BOARD_PLAN_TASKS, MAX_BOARD_PLAN_TEXT_BYTES, MAX_BOARD_TASK_NEEDS, MAX_BOARD_TASK_PAGE_SIZE, MAX_BOARD_THREAD_MESSAGES, MAX_BOARD_THREAD_PAGE_SIZE, MIN_BOARD_LEASE_SECONDS, } from "@maiaos/protocol";
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { createLocalNodeEffectClient, type LocalNodeEffectClient, } from "../client/effect.js";
|
|
2
|
+
export { makeNodeChangeSource, type NodeChangeRelays, type NodeChangeSource, } from "../node-changes/effect.js";
|
|
3
|
+
export { createBrowserNodeChangeSource, createBrowserStreamRelay, } from "./observation.js";
|
|
4
|
+
export type { BrowserStreamOptions, BrowserWebSocket } from "./options.js";
|
|
5
|
+
export { signInWithPaste } from "./paste.js";
|
|
6
|
+
export { clearSession, codeOfPaste, endSession, PANEL_SESSION_STORAGE_KEY, readSession, redeemCode, type Revocation, type SessionPlatform, type SessionStorage, type SignIn, type SignInPlatform, startSession, } from "./session.js";
|
|
7
|
+
export { signOut } from "./sign-out.js";
|
|
8
|
+
export { makeSignInStatus, type SignInState, type SignInStatus, } from "./status.js";
|
|
9
|
+
//# sourceMappingURL=effect.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { createLocalNodeEffectClient, } from "../client/effect.js";
|
|
2
|
+
export { makeNodeChangeSource, } from "../node-changes/effect.js";
|
|
3
|
+
export { createBrowserNodeChangeSource, createBrowserStreamRelay, } from "./observation.js";
|
|
4
|
+
export { signInWithPaste } from "./paste.js";
|
|
5
|
+
export { clearSession, codeOfPaste, endSession, PANEL_SESSION_STORAGE_KEY, readSession, redeemCode, startSession, } from "./session.js";
|
|
6
|
+
export { signOut } from "./sign-out.js";
|
|
7
|
+
export { makeSignInStatus, } from "./status.js";
|
|
8
|
+
//# sourceMappingURL=effect.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Effect, Layer, Option } from "effect";
|
|
2
|
+
import * as HttpClient from "effect/http/HttpClient";
|
|
3
|
+
import { MaiaClientError, type MaiaTransport } from "../request/index.js";
|
|
4
|
+
import type { BrowserTransportOptions } from "./options.js";
|
|
5
|
+
type Envelope = Parameters<MaiaTransport["request"]>[0];
|
|
6
|
+
export declare const clientLayer: (fetch: typeof globalThis.fetch | undefined) => Layer.Layer<HttpClient.HttpClient, never, never>;
|
|
7
|
+
export declare const failure: (message: string, cause?: unknown) => MaiaClientError;
|
|
8
|
+
export declare const sessionHeaders: (session: Option.Option<string>) => {} | {
|
|
9
|
+
"x-maia-panel-session": string;
|
|
10
|
+
};
|
|
11
|
+
export declare const withDeadline: <TValue, TError, TRequirements>(effect: Effect.Effect<TValue, TError, TRequirements>) => Effect.Effect<TValue, TError | MaiaClientError, TRequirements>;
|
|
12
|
+
export declare const exchange: (options: BrowserTransportOptions, envelope: Envelope) => Effect.Effect<unknown, MaiaClientError, never>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=exchange.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { NODE_API_JSON_CONTENT_TYPE, NODE_API_PANEL_OPERATION_PATH, NODE_API_PANEL_SESSION_HEADER, protocolErrorEnvelopeSchema, protocolRequestEnvelopeSchema, protocolSuccessEnvelopeSchema, } from "@maiaos/protocol";
|
|
2
|
+
import { Effect, Layer, Option } from "effect";
|
|
3
|
+
import * as FetchHttpClient from "effect/http/FetchHttpClient";
|
|
4
|
+
import * as HttpClient from "effect/http/HttpClient";
|
|
5
|
+
import * as HttpClientRequest from "effect/http/HttpClientRequest";
|
|
6
|
+
import { MaiaClientError } from "../request/index.js";
|
|
7
|
+
const REQUEST_INIT = {
|
|
8
|
+
cache: "no-store",
|
|
9
|
+
credentials: "same-origin",
|
|
10
|
+
redirect: "error",
|
|
11
|
+
referrerPolicy: "no-referrer",
|
|
12
|
+
};
|
|
13
|
+
export const clientLayer = (fetch) => (fetch === undefined
|
|
14
|
+
? FetchHttpClient.layer
|
|
15
|
+
: FetchHttpClient.layer.pipe(Layer.provide(Layer.succeed(FetchHttpClient.Fetch, fetch)))).pipe(Layer.provide(Layer.succeed(FetchHttpClient.RequestInit, REQUEST_INIT)));
|
|
16
|
+
export const failure = (message, cause) => new MaiaClientError("transport_failure", message, { cause });
|
|
17
|
+
export const sessionHeaders = (session) => Option.match(session, {
|
|
18
|
+
onNone: () => ({}),
|
|
19
|
+
onSome: (value) => ({ [NODE_API_PANEL_SESSION_HEADER]: value }),
|
|
20
|
+
});
|
|
21
|
+
const operationRequest = (origin, session, envelope) => Effect.try({
|
|
22
|
+
catch: (cause) => failure("The Maia Node API request failed runtime validation.", cause),
|
|
23
|
+
try: () => JSON.stringify(protocolRequestEnvelopeSchema.parse(envelope)),
|
|
24
|
+
}).pipe(Effect.map((body) => HttpClientRequest.post(`${origin}${NODE_API_PANEL_OPERATION_PATH}`).pipe(HttpClientRequest.setHeaders(sessionHeaders(session)), HttpClientRequest.bodyText(body, NODE_API_JSON_CONTENT_TYPE))));
|
|
25
|
+
const responseEnvelope = (json) => {
|
|
26
|
+
const success = protocolSuccessEnvelopeSchema.safeParse(json);
|
|
27
|
+
return success.success
|
|
28
|
+
? success.data
|
|
29
|
+
: protocolErrorEnvelopeSchema.parse(json);
|
|
30
|
+
};
|
|
31
|
+
const decodeResponse = (response) => response.json.pipe(Effect.flatMap((json) => Effect.try(() => responseEnvelope(json))), Effect.mapError((cause) => new MaiaClientError("invalid_response", "The Maia Node API response failed runtime validation.", { cause })));
|
|
32
|
+
const DEADLINE = "30 seconds";
|
|
33
|
+
export const withDeadline = (effect) => effect.pipe(Effect.timeoutOrElse({
|
|
34
|
+
duration: DEADLINE,
|
|
35
|
+
orElse: () => Effect.fail(new MaiaClientError("outcome_unknown", "The Maia Node API request outcome is unknown.")),
|
|
36
|
+
}));
|
|
37
|
+
const UNAUTHORIZED = 401;
|
|
38
|
+
const send = (options, envelope) => Effect.gen(function* () {
|
|
39
|
+
const client = yield* HttpClient.HttpClient;
|
|
40
|
+
const request = yield* operationRequest(options.origin, Option.fromNullishOr(options.session?.()), envelope);
|
|
41
|
+
const response = yield* client
|
|
42
|
+
.execute(request)
|
|
43
|
+
.pipe(Effect.mapError((cause) => failure("The Maia Node API request failed.", cause)));
|
|
44
|
+
if (response.status === UNAUTHORIZED)
|
|
45
|
+
yield* Effect.sync(() => options.onSignedOut?.());
|
|
46
|
+
return yield* decodeResponse(response);
|
|
47
|
+
}).pipe(Effect.scoped, withDeadline);
|
|
48
|
+
export const exchange = (options, envelope) => send(options, envelope).pipe(Effect.provide(clientLayer(options.fetch)));
|
|
49
|
+
//# sourceMappingURL=exchange.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { type NodeChangeSource } from "../node-changes/effect.js";
|
|
3
|
+
import type { StreamRelay } from "../stream/index.js";
|
|
4
|
+
import type { BrowserStreamOptions } from "./options.js";
|
|
5
|
+
export declare const createBrowserStreamRelay: <TSubscribe extends object>(options: BrowserStreamOptions) => StreamRelay<TSubscribe>;
|
|
6
|
+
export declare const createBrowserNodeChangeSource: (options: BrowserStreamOptions & {
|
|
7
|
+
readonly nextId: (prefix: "request") => Effect.Effect<string>;
|
|
8
|
+
}) => NodeChangeSource;
|
|
9
|
+
//# sourceMappingURL=observation.d.ts.map
|