@softov/ahpc 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +296 -0
- package/dist/src/ahp/channels.d.ts +146 -0
- package/dist/src/ahp/channels.js +423 -0
- package/dist/src/ahp/connection.d.ts +656 -0
- package/dist/src/ahp/connection.js +1 -0
- package/dist/src/ahp/fake.d.ts +69 -0
- package/dist/src/ahp/fake.js +1996 -0
- package/dist/src/ahp/live.d.ts +160 -0
- package/dist/src/ahp/live.js +2641 -0
- package/dist/src/ahp/operate.d.ts +36 -0
- package/dist/src/ahp/operate.js +56 -0
- package/dist/src/ahp/publish.d.ts +39 -0
- package/dist/src/ahp/publish.js +370 -0
- package/dist/src/ahp/status.d.ts +23 -0
- package/dist/src/ahp/status.js +23 -0
- package/dist/src/ahp/types.d.ts +745 -0
- package/dist/src/ahp/types.js +27 -0
- package/dist/src/app.d.ts +54 -0
- package/dist/src/app.js +369 -0
- package/dist/src/blocks.d.ts +88 -0
- package/dist/src/blocks.js +102 -0
- package/dist/src/cli/main.d.ts +13 -0
- package/dist/src/cli/main.js +1537 -0
- package/dist/src/cli/render.d.ts +43 -0
- package/dist/src/cli/render.js +91 -0
- package/dist/src/config.d.ts +63 -0
- package/dist/src/config.js +45 -0
- package/dist/src/connect.d.ts +53 -0
- package/dist/src/connect.js +69 -0
- package/dist/src/control.d.ts +189 -0
- package/dist/src/control.js +2241 -0
- package/dist/src/diff.d.ts +44 -0
- package/dist/src/diff.js +111 -0
- package/dist/src/flags.d.ts +28 -0
- package/dist/src/flags.js +76 -0
- package/dist/src/main.d.ts +10 -0
- package/dist/src/main.js +54 -0
- package/dist/src/schedule.d.ts +46 -0
- package/dist/src/schedule.js +140 -0
- package/dist/src/screens.d.ts +79 -0
- package/dist/src/screens.js +1322 -0
- package/dist/src/state.d.ts +355 -0
- package/dist/src/state.js +531 -0
- package/dist/src/terminal.d.ts +44 -0
- package/dist/src/terminal.js +101 -0
- package/dist/src/tui.d.ts +92 -0
- package/dist/src/tui.js +372 -0
- package/dist/src/view/automations.d.ts +31 -0
- package/dist/src/view/automations.js +76 -0
- package/dist/src/view/bood/art.d.ts +90 -0
- package/dist/src/view/bood/art.js +152 -0
- package/dist/src/view/bood/beetle.d.ts +7 -0
- package/dist/src/view/bood/beetle.js +123 -0
- package/dist/src/view/bood/bunny.d.ts +8 -0
- package/dist/src/view/bood/bunny.js +228 -0
- package/dist/src/view/bood/cat.d.ts +9 -0
- package/dist/src/view/bood/cat.js +358 -0
- package/dist/src/view/bood/crab.d.ts +7 -0
- package/dist/src/view/bood/crab.js +121 -0
- package/dist/src/view/bood/index.d.ts +29 -0
- package/dist/src/view/bood/index.js +25 -0
- package/dist/src/view/bood/motion.d.ts +178 -0
- package/dist/src/view/bood/motion.js +298 -0
- package/dist/src/view/bood/owl.d.ts +9 -0
- package/dist/src/view/bood/owl.js +285 -0
- package/dist/src/view/bood/registry.d.ts +36 -0
- package/dist/src/view/bood/registry.js +218 -0
- package/dist/src/view/bood/render.d.ts +31 -0
- package/dist/src/view/bood/render.js +196 -0
- package/dist/src/view/bood/sprite.d.ts +18 -0
- package/dist/src/view/bood/sprite.js +130 -0
- package/dist/src/view/bood/sprout.d.ts +8 -0
- package/dist/src/view/bood/sprout.js +121 -0
- package/dist/src/view/bood/types.d.ts +158 -0
- package/dist/src/view/bood/types.js +57 -0
- package/dist/src/view/bubble.d.ts +75 -0
- package/dist/src/view/bubble.js +86 -0
- package/dist/src/view/changes.d.ts +35 -0
- package/dist/src/view/changes.js +22 -0
- package/dist/src/view/composer.d.ts +64 -0
- package/dist/src/view/composer.js +192 -0
- package/dist/src/view/controls.d.ts +44 -0
- package/dist/src/view/controls.js +49 -0
- package/dist/src/view/creature.d.ts +69 -0
- package/dist/src/view/creature.js +83 -0
- package/dist/src/view/customizations.d.ts +28 -0
- package/dist/src/view/customizations.js +53 -0
- package/dist/src/view/details.d.ts +65 -0
- package/dist/src/view/details.js +65 -0
- package/dist/src/view/filediff.d.ts +29 -0
- package/dist/src/view/filediff.js +24 -0
- package/dist/src/view/files.d.ts +31 -0
- package/dist/src/view/files.js +39 -0
- package/dist/src/view/hitl.d.ts +43 -0
- package/dist/src/view/hitl.js +171 -0
- package/dist/src/view/icons.d.ts +13 -0
- package/dist/src/view/icons.js +71 -0
- package/dist/src/view/picker.d.ts +42 -0
- package/dist/src/view/picker.js +71 -0
- package/dist/src/view/sessionhead.d.ts +41 -0
- package/dist/src/view/sessionhead.js +60 -0
- package/dist/src/view/sessions.d.ts +34 -0
- package/dist/src/view/sessions.js +61 -0
- package/dist/src/view/terminal.d.ts +30 -0
- package/dist/src/view/terminal.js +32 -0
- package/dist/src/view/toolcall.d.ts +27 -0
- package/dist/src/view/toolcall.js +48 -0
- package/dist/src/view/transcript.d.ts +50 -0
- package/dist/src/view/transcript.js +60 -0
- package/package.json +72 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { Published } from './publish.js';
|
|
2
|
+
import type { HostConnection } from './connection.js';
|
|
3
|
+
/**
|
|
4
|
+
* The other implementation of the seam: a real agent host, over a WebSocket.
|
|
5
|
+
*
|
|
6
|
+
* `fakeHost` is a script and this is a socket, and nothing above either of them
|
|
7
|
+
* can tell which is which - that is what `HostConnection` is for. Point it at a
|
|
8
|
+
* host with `--host ws://…` and the same screens drive somebody's editor.
|
|
9
|
+
*
|
|
10
|
+
* **Reducers are the host's, not ours.** The protocol ships a client library
|
|
11
|
+
* with the transport, the subscription fan-out and a generated reducer per
|
|
12
|
+
* channel, and reimplementing eighty typed mutations here would be inventing a
|
|
13
|
+
* second answer to "what is the state now". So the package is loaded at
|
|
14
|
+
* runtime and everything below is translation: its state shapes into the
|
|
15
|
+
* flattened ones in `types.ts`, and back out as the actions a client is
|
|
16
|
+
* allowed to dispatch.
|
|
17
|
+
*
|
|
18
|
+
* It is an **optional** dependency, because the example has to run, and be
|
|
19
|
+
* checked, with nothing installed:
|
|
20
|
+
*
|
|
21
|
+
* ```
|
|
22
|
+
* npm install @microsoft/agent-host-protocol
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* Written against protocol 0.9.0, from the package's own `src/types/`. What it
|
|
26
|
+
* speaks is the subset this client needs: `initialize`, `listSessions`,
|
|
27
|
+
* `subscribe`, `createSession`, `disposeSession`, `resolveSessionConfig`, and
|
|
28
|
+
* the seven client-dispatchable actions that drive and answer a turn.
|
|
29
|
+
*/
|
|
30
|
+
export interface LiveHostOptions {
|
|
31
|
+
/** `ws://host:port/…`, as the host advertises it. */
|
|
32
|
+
url: string;
|
|
33
|
+
/** A bearer token, if the host is behind one. Appended as `?tkn=`. */
|
|
34
|
+
token?: string;
|
|
35
|
+
clientId?: string;
|
|
36
|
+
/** Told when the socket drops, so the badge can stop claiming otherwise. */
|
|
37
|
+
onState?(state: 'connecting' | 'connected' | 'offline'): void;
|
|
38
|
+
/**
|
|
39
|
+
* Told when the host refuses one channel, in the host's own words.
|
|
40
|
+
*
|
|
41
|
+
* Separate from `onState` because they mean opposite things: a refusal is
|
|
42
|
+
* the host answering, and reporting it as a lost connection sends somebody
|
|
43
|
+
* to debug their network over a session whose agent has simply gone.
|
|
44
|
+
*/
|
|
45
|
+
onRefusal?(uri: string, message: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Open a transport, in place of a WebSocket to `url`.
|
|
48
|
+
*
|
|
49
|
+
* The seam a test drives: a connection is the one thing here that cannot be
|
|
50
|
+
* scripted from above, because `fakeHost` implements the seam this file
|
|
51
|
+
* produces rather than the protocol underneath it. Called once per attempt,
|
|
52
|
+
* so a reconnect asks for a new one.
|
|
53
|
+
*/
|
|
54
|
+
connect?(): Promise<unknown>;
|
|
55
|
+
/**
|
|
56
|
+
* How long to wait before each attempt to come back, in milliseconds.
|
|
57
|
+
*
|
|
58
|
+
* The last entry repeats for as long as the host stays away. Given in full
|
|
59
|
+
* rather than as a formula so a test can ask for no waiting at all, and so
|
|
60
|
+
* the schedule is a thing that can be read.
|
|
61
|
+
*/
|
|
62
|
+
backoff?: readonly number[];
|
|
63
|
+
/** How often to ping an otherwise silent connection. `0` sends none. */
|
|
64
|
+
keepaliveMs?: number;
|
|
65
|
+
/** How long to hold a channel nobody is reading before letting it go. */
|
|
66
|
+
lingerMs?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Told when this client stopped short of everything the host had.
|
|
69
|
+
*
|
|
70
|
+
* Not a refusal - the host answered, and answered fully. It is this client
|
|
71
|
+
* declining to walk a catalogue past the point where walking it is the
|
|
72
|
+
* wrong thing to be doing, and a person is owed the sentence.
|
|
73
|
+
*/
|
|
74
|
+
onLimit?(message: string): void;
|
|
75
|
+
/**
|
|
76
|
+
* Work the host is doing, by its own token.
|
|
77
|
+
*
|
|
78
|
+
* `null` means that token is finished. The specification's own example is a
|
|
79
|
+
* harness being downloaded before a session can start, which is exactly the
|
|
80
|
+
* wait that looked like nothing happening.
|
|
81
|
+
*/
|
|
82
|
+
onProgress?(token: string, message: string | null): void;
|
|
83
|
+
/**
|
|
84
|
+
* The host wants a token before it will go on.
|
|
85
|
+
*
|
|
86
|
+
* `reason: 'expired'` is the one that matters: `authentication.md` says the
|
|
87
|
+
* client MUST acquire a new credential and MUST NOT blindly replay the one
|
|
88
|
+
* that was challenged. Arrives either as the `auth/required` notification or
|
|
89
|
+
* as the `data` on any `-32007`, which the specification says may come back
|
|
90
|
+
* from **any** command rather than only from `authenticate`.
|
|
91
|
+
*/
|
|
92
|
+
onAuthRequired?(resources: {
|
|
93
|
+
resource: string;
|
|
94
|
+
description?: string;
|
|
95
|
+
}[], reason?: string): void;
|
|
96
|
+
/**
|
|
97
|
+
* One log record the host emitted, flattened out of OTLP.
|
|
98
|
+
*
|
|
99
|
+
* `telemetry-channel.md` is a thin pass-through: the payload is an
|
|
100
|
+
* OTLP/JSON `ExportLogsServiceRequest` verbatim, nested resource by scope by
|
|
101
|
+
* record. What a reader wants is a line, so the nesting is walked here.
|
|
102
|
+
*/
|
|
103
|
+
onLog?(record: {
|
|
104
|
+
at?: string;
|
|
105
|
+
severity?: string;
|
|
106
|
+
body: string;
|
|
107
|
+
attributes: Record<string, string>;
|
|
108
|
+
}): void;
|
|
109
|
+
/**
|
|
110
|
+
* What this client serves back, when it was told to serve anything.
|
|
111
|
+
*
|
|
112
|
+
* Absent means a `publish()` that refuses everything, which is the default
|
|
113
|
+
* and the safe one - a client that offers its filesystem to whichever host
|
|
114
|
+
* it connects to is a mistake, not a feature.
|
|
115
|
+
*/
|
|
116
|
+
publish?: Published;
|
|
117
|
+
}
|
|
118
|
+
export declare class MissingProtocolPackage extends Error {
|
|
119
|
+
constructor();
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The activity bits, from what this client can see rather than what it was told.
|
|
123
|
+
*
|
|
124
|
+
* There is no `session/statusChanged` in the protocol. A subscribed client is
|
|
125
|
+
* told `session/activityChanged` - a word - and the reducer keeps that word in
|
|
126
|
+
* `activity` and deliberately leaves `status` alone; the only actions that
|
|
127
|
+
* move `status` are the input-needed pair and the read and archived flags. So
|
|
128
|
+
* on a live session the activity bits only ever go up. Answering a question
|
|
129
|
+
* clears `InputNeeded` and leaves `InProgress` set, which the reducer's own
|
|
130
|
+
* comment calls falling back to in-progress, and nothing afterwards takes it
|
|
131
|
+
* off - a session goes on saying it is working through every turn that
|
|
132
|
+
* follows, until something re-reads the catalogue.
|
|
133
|
+
*
|
|
134
|
+
* Everything the bits are about is already here: whether a turn is running,
|
|
135
|
+
* whether something is waiting on a person, and whether the last turn failed.
|
|
136
|
+
* The order is the host's own - what is wanted, then what is happening, then
|
|
137
|
+
* what went wrong - and the session's own flags are carried through untouched,
|
|
138
|
+
* because read and archived are not about activity at all.
|
|
139
|
+
*/
|
|
140
|
+
export declare function activityOf(status: number, asked: boolean, running: boolean, failed: boolean): number;
|
|
141
|
+
/**
|
|
142
|
+
* Reduce one action, or say so and go on listening.
|
|
143
|
+
*
|
|
144
|
+
* A reducer is handed whatever the host sent, and a host that sends a
|
|
145
|
+
* malformed action throws inside it - `session/inputNeededSet` without its
|
|
146
|
+
* `request` is `action.request.id` on undefined, which is a `TypeError` and
|
|
147
|
+
* not an RPC error. Thrown out of a `for await` it rejects the whole loop and
|
|
148
|
+
* takes the subscription with it, so the session goes deaf: the block waiting
|
|
149
|
+
* on a person never clears, the status never moves, and the only sign of any
|
|
150
|
+
* of it is a sentence about a property of undefined on the status bar.
|
|
151
|
+
*
|
|
152
|
+
* One word this client cannot read is not a reason to stop reading the rest
|
|
153
|
+
* of them. The action is dropped, the state it would have changed is left as
|
|
154
|
+
* it was, and it is said out loud - because a client quietly ignoring what a
|
|
155
|
+
* host tells it is the other way to be wrong here.
|
|
156
|
+
*/
|
|
157
|
+
export declare function applyAction<T>(reduce: (state: T, action: never) => unknown, state: T, action: unknown, onBad: (message: string) => void): T;
|
|
158
|
+
export declare function liveHost(options: LiveHostOptions): Promise<HostConnection & {
|
|
159
|
+
close(): Promise<void>;
|
|
160
|
+
}>;
|