@powerhousedao/clint 6.3.0-dev.9 → 6.4.0-next.1
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/dist/build-DZIv63eB.mjs +77 -0
- package/dist/build-DZIv63eB.mjs.map +1 -0
- package/dist/{build-skills-BnqGyuCH.mjs → build-skills-XkfkDhWl.mjs} +15 -6
- package/dist/build-skills-XkfkDhWl.mjs.map +1 -0
- package/dist/dist-Bd6hUl0J.mjs +655 -0
- package/dist/dist-Bd6hUl0J.mjs.map +1 -0
- package/dist/glob-CGjvhxgW.mjs +48 -0
- package/dist/glob-CGjvhxgW.mjs.map +1 -0
- package/dist/index-C3-HSfKb.d.mts +389 -0
- package/dist/index-C3-HSfKb.d.mts.map +1 -0
- package/dist/index.d.mts +55 -303
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +7 -8
- package/dist/integrations/mastra/index.d.mts +248 -0
- package/dist/integrations/mastra/index.d.mts.map +1 -0
- package/dist/integrations/mastra/index.mjs +509 -0
- package/dist/integrations/mastra/index.mjs.map +1 -0
- package/dist/integrations/powerhouse/index.d.mts +4 -0
- package/dist/integrations/powerhouse/index.mjs +3 -0
- package/dist/markdown-BUeGwhbR.mjs +1588 -0
- package/dist/markdown-BUeGwhbR.mjs.map +1 -0
- package/dist/powerhouse-3XZmdY3_.mjs +1922 -0
- package/dist/powerhouse-3XZmdY3_.mjs.map +1 -0
- package/dist/{proxy-BFR8GScT.mjs → proxy-ji3EHzLn.mjs} +128 -28
- package/dist/proxy-ji3EHzLn.mjs.map +1 -0
- package/dist/remote-reactor-oBsHphPT.mjs +69 -0
- package/dist/remote-reactor-oBsHphPT.mjs.map +1 -0
- package/dist/{start-b7Mn2cxB.mjs → repl-Czb7u0x_.mjs} +6 -29
- package/dist/repl-Czb7u0x_.mjs.map +1 -0
- package/dist/runners/cli-runner.d.mts +339 -0
- package/dist/runners/cli-runner.d.mts.map +1 -0
- package/dist/runners/cli-runner.mjs +324 -0
- package/dist/runners/cli-runner.mjs.map +1 -0
- package/dist/runners/mastra-runner.d.mts +5 -3
- package/dist/runners/mastra-runner.d.mts.map +1 -1
- package/dist/runners/mastra-runner.mjs +10 -60
- package/dist/runners/mastra-runner.mjs.map +1 -1
- package/dist/runners/proxy-runner.d.mts +281 -0
- package/dist/runners/proxy-runner.d.mts.map +1 -0
- package/dist/runners/proxy-runner.mjs +91 -0
- package/dist/runners/proxy-runner.mjs.map +1 -0
- package/dist/schema-BEKAZGyT.mjs +47 -0
- package/dist/schema-BEKAZGyT.mjs.map +1 -0
- package/dist/{src-BebNN3xc.mjs → src-055YwI8s.mjs} +395 -1481
- package/dist/src-055YwI8s.mjs.map +1 -0
- package/dist/start-BHn9LIyX.mjs +37 -0
- package/dist/start-BHn9LIyX.mjs.map +1 -0
- package/dist/store-CxqB-OrX.mjs +101 -0
- package/dist/store-CxqB-OrX.mjs.map +1 -0
- package/dist/{stream-DVuufwIj.mjs → stream-BguHx7vC.mjs} +4 -2
- package/dist/{stream-DVuufwIj.mjs.map → stream-BguHx7vC.mjs.map} +1 -1
- package/dist/testing/index.d.mts +81 -0
- package/dist/testing/index.d.mts.map +1 -0
- package/dist/testing/index.mjs +131 -0
- package/dist/testing/index.mjs.map +1 -0
- package/dist/{types-CRkoD-Mm.d.mts → types-CF6GuPJd.d.mts} +241 -261
- package/dist/types-CF6GuPJd.d.mts.map +1 -0
- package/dist/types-CbHJ-ZnH.d.mts +60 -0
- package/dist/types-CbHJ-ZnH.d.mts.map +1 -0
- package/package.json +44 -25
- package/dist/build-skills-BnqGyuCH.mjs.map +0 -1
- package/dist/dist-CUltriBW.mjs +0 -1628
- package/dist/dist-CUltriBW.mjs.map +0 -1
- package/dist/drive-Bu9zoFrO.mjs +0 -85
- package/dist/drive-Bu9zoFrO.mjs.map +0 -1
- package/dist/esm-C1DOsF1a.mjs +0 -13140
- package/dist/esm-C1DOsF1a.mjs.map +0 -1
- package/dist/events-BnwGFTjv.mjs +0 -237
- package/dist/events-BnwGFTjv.mjs.map +0 -1
- package/dist/folders-BYO1Wqqb.mjs +0 -256
- package/dist/folders-BYO1Wqqb.mjs.map +0 -1
- package/dist/local-signer-EFzJV3bn.mjs +0 -128
- package/dist/local-signer-EFzJV3bn.mjs.map +0 -1
- package/dist/markdown-D-sP2zw_.mjs +0 -275
- package/dist/markdown-D-sP2zw_.mjs.map +0 -1
- package/dist/proxy-BFR8GScT.mjs.map +0 -1
- package/dist/proxy-routes-DP3ztsnS.mjs +0 -215
- package/dist/proxy-routes-DP3ztsnS.mjs.map +0 -1
- package/dist/reactor-C9VIUX1H.mjs +0 -51
- package/dist/reactor-C9VIUX1H.mjs.map +0 -1
- package/dist/runners/clint-runner.d.mts +0 -398
- package/dist/runners/clint-runner.d.mts.map +0 -1
- package/dist/runners/clint-runner.mjs +0 -519
- package/dist/runners/clint-runner.mjs.map +0 -1
- package/dist/services-9E-r0nWl.mjs +0 -999
- package/dist/services-9E-r0nWl.mjs.map +0 -1
- package/dist/src-BebNN3xc.mjs.map +0 -1
- package/dist/start-b7Mn2cxB.mjs.map +0 -1
- package/dist/subscriptions-CfiflAsI.mjs +0 -38
- package/dist/subscriptions-CfiflAsI.mjs.map +0 -1
- package/dist/switchboard-CyvOavqL.mjs +0 -57
- package/dist/switchboard-CyvOavqL.mjs.map +0 -1
- package/dist/types-CRkoD-Mm.d.mts.map +0 -1
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import { It as Trigger, Lt as TriggerContext, R as Command, S as IAttachmentService, U as EmitFn, c as FolderOperations, d as ReactorSetupContext, et as Logger, f as ReactorWrites, g as SubscriptionConfig, h as RemoteReactorSource, i as DriveConfig, m as RemoteReactorConfig, n as AttachmentRef$1, o as EnsureDriveClient, p as RegistryEntry, r as DocumentRegistry, t as AnyRegistry, u as ReactorContext, v as TypedReactorClient, z as CommandContext, zt as WorkItem } from "./types-CF6GuPJd.mjs";
|
|
2
|
+
import { ReactorProtocol } from "@powerhousedao/host-core";
|
|
3
|
+
import { IReactorClient } from "@powerhousedao/reactor";
|
|
4
|
+
import { DocumentModelModule, ISigner, SignaturePolicy } from "@powerhousedao/shared/document-model";
|
|
5
|
+
import { Action as Action$1, DocumentModelModule as DocumentModelModule$1 } from "document-model";
|
|
6
|
+
import { BearerTokenProvider } from "@powerhousedao/reactor-browser/graphql-client";
|
|
7
|
+
//#region src/integrations/powerhouse/change-trigger.d.ts
|
|
8
|
+
interface DocumentChangeTriggerOptions<R extends DocumentRegistry, T extends keyof R & string, TConfig = Record<string, unknown>, TState extends {
|
|
9
|
+
pending: number;
|
|
10
|
+
} = {
|
|
11
|
+
pending: number;
|
|
12
|
+
}> {
|
|
13
|
+
/** Unique trigger id for logging/routing. */
|
|
14
|
+
id: string;
|
|
15
|
+
/** The document type(s) to watch. Must be key(s) in the registry. */
|
|
16
|
+
documentType: T | T[];
|
|
17
|
+
/**
|
|
18
|
+
* The specific document id (or a function that resolves one from context).
|
|
19
|
+
* When omitted, the helper loads ALL documents of the watched type(s)
|
|
20
|
+
* via `client.find()` and passes the full array to `onChange`.
|
|
21
|
+
*
|
|
22
|
+
* When a function is provided, it's resolved lazily on each poll. Returning
|
|
23
|
+
* `undefined` skips the tick.
|
|
24
|
+
*/
|
|
25
|
+
documentId?: string | ((ctx: TriggerContext<TState, TConfig, R>) => Promise<string | undefined>);
|
|
26
|
+
/**
|
|
27
|
+
* Fire once on startup before any event arrives — useful for reconciling
|
|
28
|
+
* against the current document state. Default: true.
|
|
29
|
+
*/
|
|
30
|
+
initialReconcile?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Optional predicate: called per-document after loading, before onChange.
|
|
33
|
+
* Return false to exclude a document from the batch. If all documents
|
|
34
|
+
* are filtered out, onChange is not called.
|
|
35
|
+
*/
|
|
36
|
+
filter?: (doc: R[T]["document"], ctx: TriggerContext<TState, TConfig, R>) => boolean | Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* User's change handler. Receives an array of loaded, type-narrowed
|
|
39
|
+
* documents and the full trigger context. Returns a work item for the
|
|
40
|
+
* routine loop to execute (or null to skip).
|
|
41
|
+
*/
|
|
42
|
+
onChange: (docs: Array<R[T]["document"]>, ctx: TriggerContext<TState, TConfig, R>) => Promise<WorkItem | null>;
|
|
43
|
+
/**
|
|
44
|
+
* Call `onChange` even when zero documents are found. Default: false.
|
|
45
|
+
* Useful for triggers that need to perform work (e.g. bootstrapping from
|
|
46
|
+
* disk) regardless of whether any documents exist yet.
|
|
47
|
+
*/
|
|
48
|
+
callOnEmpty?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Optional initial state for the trigger's private slot. Defaults to
|
|
51
|
+
* `{ pending: 0 }`. When supplied, the shape MUST include a `pending:
|
|
52
|
+
* number` field — the helper bumps and drains it internally.
|
|
53
|
+
*/
|
|
54
|
+
state?: () => TState;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Build a Trigger that listens for document change events on the event bus,
|
|
58
|
+
* coalesces them, loads matching documents, narrows to the registered type,
|
|
59
|
+
* and hands them to the user's onChange handler.
|
|
60
|
+
*
|
|
61
|
+
* Runtime behavior:
|
|
62
|
+
* 1. `setup()` subscribes to `powerhouse:document:changed`. For each event,
|
|
63
|
+
* if any documentType matches (and, when `documentId` is a literal
|
|
64
|
+
* string, the id also matches), bump the pending counter.
|
|
65
|
+
* 2. If `initialReconcile !== false`, `setup()` bumps pending once on
|
|
66
|
+
* startup so the first poll reconciles without waiting for an event.
|
|
67
|
+
* 3. `poll()` returns null unless pending > 0. When pending > 0:
|
|
68
|
+
* - If `documentId` is set: load single doc, wrap in `[doc]`
|
|
69
|
+
* - If `documentId` is omitted: `find()` all docs of matching type(s)
|
|
70
|
+
* Applies `filter` per-doc, then calls `onChange(docs, ctx)`.
|
|
71
|
+
* 4. pending is reset to 0 at the start of each poll drain — multiple
|
|
72
|
+
* events within a tick coalesce to one `onChange` call.
|
|
73
|
+
*/
|
|
74
|
+
declare function createDocumentChangeTrigger<R extends DocumentRegistry = AnyRegistry, T extends keyof R & string = keyof R & string, TConfig = Record<string, unknown>, TState extends {
|
|
75
|
+
pending: number;
|
|
76
|
+
} = {
|
|
77
|
+
pending: number;
|
|
78
|
+
}>(options: DocumentChangeTriggerOptions<R, T, TConfig, TState>): Trigger<TState, TConfig, R>;
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/integrations/powerhouse/registry.d.ts
|
|
81
|
+
/**
|
|
82
|
+
* Extract the action union from a DocumentModelModule.
|
|
83
|
+
*
|
|
84
|
+
* `DocumentModelModule.actions` is `{ [actionName]: (input) => Action }` — the
|
|
85
|
+
* return types of those creators form the module's action union.
|
|
86
|
+
*
|
|
87
|
+
* If a module's actions map isn't typed tightly enough (because the module
|
|
88
|
+
* was annotated with `: DocumentModelModule<…>` instead of `satisfies`), the
|
|
89
|
+
* union collapses to `Action`. Not a correctness problem — just a DX
|
|
90
|
+
* degradation for that one module's execute/executeAsync narrowing.
|
|
91
|
+
*/
|
|
92
|
+
type ActionOf<M> = M extends {
|
|
93
|
+
actions: infer Actions;
|
|
94
|
+
} ? Actions extends Record<string, (...args: never[]) => infer A> ? A : Action$1 : Action$1;
|
|
95
|
+
/**
|
|
96
|
+
* Infer a DocumentRegistry from a readonly tuple of DocumentModelModule instances.
|
|
97
|
+
*
|
|
98
|
+
* Literal inference requires each module's `documentModel.id` to be a literal
|
|
99
|
+
* type. Phase 4 changes codegen to emit modules with `as const satisfies
|
|
100
|
+
* DocumentModelModule<…>` so inference produces a typed registry. Modules
|
|
101
|
+
* typed with `:` annotations erase `id` to `string` and produce a
|
|
102
|
+
* single-keyed `{ [x: string]: RegistryEntry<...> }` registry — narrowing
|
|
103
|
+
* still works when callers pass a literal `T`, but `keyof R & string`
|
|
104
|
+
* collapses to `string` (no autocomplete for documentTypes lists).
|
|
105
|
+
*/
|
|
106
|
+
type InferRegistry<T extends ReadonlyArray<DocumentModelModule$1<any>>> = { [M in T[number] as Extract<M["documentModel"]["global"]["id"], string>]: M extends DocumentModelModule$1<infer S> ? RegistryEntry<S, ActionOf<M>> : never; };
|
|
107
|
+
/**
|
|
108
|
+
* Build a DocumentRegistry from a tuple of DocumentModelModules.
|
|
109
|
+
*
|
|
110
|
+
* ```ts
|
|
111
|
+
* const registry = defineRegistry([PhClintProject, DocumentDrive] as const);
|
|
112
|
+
* // typeof registry:
|
|
113
|
+
* // {
|
|
114
|
+
* // 'powerhouse/ph-clint-project': RegistryEntry<PhClintProjectPHState, PhClintProjectAction>;
|
|
115
|
+
* // 'powerhouse/document-drive': RegistryEntry<DocumentDrivePHState, DocumentDriveAction>;
|
|
116
|
+
* // }
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
* Runtime value is a plain object keyed by `documentModel.id`. Consumers can
|
|
120
|
+
* introspect it to list registered types; Phase 3's
|
|
121
|
+
* `createDocumentChangeTrigger` also uses it for runtime lookup.
|
|
122
|
+
*/
|
|
123
|
+
declare function defineRegistry<const T extends ReadonlyArray<DocumentModelModule$1<any>>>(modules: T): InferRegistry<T>;
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/integrations/powerhouse/subscriptions.d.ts
|
|
126
|
+
/**
|
|
127
|
+
* Bridge Reactor document subscriptions to the ph-clint event bus.
|
|
128
|
+
*
|
|
129
|
+
* @param client - The reactor client (in-process or remote)
|
|
130
|
+
* @param subscriptions - Filter configuration for which document changes to bridge
|
|
131
|
+
* @param emit - Event bus emit function from CommandContext
|
|
132
|
+
* @returns Unsubscribe function
|
|
133
|
+
*/
|
|
134
|
+
declare function bridgeSubscriptions<R extends DocumentRegistry = AnyRegistry>(client: IReactorClient, subscriptions: SubscriptionConfig<R>, emit: EmitFn<R>): () => void;
|
|
135
|
+
//#endregion
|
|
136
|
+
//#region src/integrations/powerhouse/drive.d.ts
|
|
137
|
+
/**
|
|
138
|
+
* Ensure a drive exists, matching by name. On first run, creates a new drive.
|
|
139
|
+
* On subsequent runs, finds the existing one by name.
|
|
140
|
+
*
|
|
141
|
+
* Works on a client alone, in-process or remote: drives are documents of type
|
|
142
|
+
* `powerhouse/document-drive`, listed with `client.find({ type })`, built
|
|
143
|
+
* with `client.newDocument()` and created, already named, with one
|
|
144
|
+
* `client.write.create()`. Those three are what both the in-process
|
|
145
|
+
* `IReactorClient` and `GraphQLReactorClient` (which has no
|
|
146
|
+
* `write.createEmpty` or `write.rename`) offer. A Cli passes its own
|
|
147
|
+
* `ReactorContext.client` as it is (see `EnsureDriveClient`).
|
|
148
|
+
*
|
|
149
|
+
* @param client - The reactor client the drive is looked up and created with
|
|
150
|
+
* @param driveConfig - Optional drive name/icon configuration and hooks
|
|
151
|
+
* @returns The drive ID and name; `deferred` (and id '') when `canCreate`
|
|
152
|
+
* held back a drive that does not exist yet
|
|
153
|
+
*/
|
|
154
|
+
declare function ensureDrive(client: EnsureDriveClient, driveConfig?: DriveConfig): Promise<{
|
|
155
|
+
id: string;
|
|
156
|
+
name: string;
|
|
157
|
+
deferred?: boolean;
|
|
158
|
+
}>;
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/integrations/powerhouse/remote-reactor.d.ts
|
|
161
|
+
/**
|
|
162
|
+
* P5.5 — the agent host's reactor is a REMOTE attach: a running switchboard,
|
|
163
|
+
* reached over GraphQL, with nothing of it glued to the CLI's lifetime. N
|
|
164
|
+
* agents attach to ONE reactor as clients; the switchboard
|
|
165
|
+
* outlives agent sessions. The agent DEPENDS on the switchboard — an
|
|
166
|
+
* unreachable remote fails the attach loudly with the start hint, it never
|
|
167
|
+
* auto-starts one.
|
|
168
|
+
*/
|
|
169
|
+
interface AttachRemoteReactorOptions {
|
|
170
|
+
/**
|
|
171
|
+
* Where the switchboard lives: its GraphQL endpoint
|
|
172
|
+
* (`http://localhost:4001/graphql`), a drive url (`…/d/<drive>`), or a bare
|
|
173
|
+
* origin — the endpoint is derived.
|
|
174
|
+
*/
|
|
175
|
+
url: string;
|
|
176
|
+
/** Document models the client signs/reduces with. */
|
|
177
|
+
documentModels: readonly DocumentModelModule<any>[];
|
|
178
|
+
/**
|
|
179
|
+
* What this agent expects of the fleet it joins (the host file's
|
|
180
|
+
* reactor.protocol). Reachability and inspection facts are checked at
|
|
181
|
+
* attach; flag-level comparison engages once the inspection subgraph
|
|
182
|
+
* exposes the enforcement flags (upstream note in the phase-5 WBS) — until
|
|
183
|
+
* then the expectation is carried for the error message and future use.
|
|
184
|
+
*/
|
|
185
|
+
expectedProtocol?: ReactorProtocol;
|
|
186
|
+
/** Bearer for authenticated switchboards; omitted = unauthenticated. */
|
|
187
|
+
token?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Resolves the bearer per request, for a token that expires (a Renown
|
|
190
|
+
* token). Takes precedence over `token`. Returning undefined sends the
|
|
191
|
+
* request unauthenticated.
|
|
192
|
+
*/
|
|
193
|
+
tokenProvider?: BearerTokenProvider;
|
|
194
|
+
/**
|
|
195
|
+
* Signs the actions the client pushes. A function is called per push (see
|
|
196
|
+
* `createReactorWrites`, whose `signer` refuses while the identity has no
|
|
197
|
+
* user). Omitted, the client falls back to the ambient Renown signer, which
|
|
198
|
+
* does not exist in Node: actions then go out unsigned.
|
|
199
|
+
*/
|
|
200
|
+
signer?: ISigner | (() => ISigner | undefined);
|
|
201
|
+
/** Reachability probe budget. */
|
|
202
|
+
timeoutMs?: number;
|
|
203
|
+
}
|
|
204
|
+
interface RemoteReactorAttachment {
|
|
205
|
+
/** The derived GraphQL endpoint actually dialed. */
|
|
206
|
+
endpoint: string;
|
|
207
|
+
/** IReactorClient-compatible GraphQL client (reactor-browser). */
|
|
208
|
+
client: unknown;
|
|
209
|
+
/** Remote facts from the inspection subgraph, when it answers. */
|
|
210
|
+
remoteInfo?: Record<string, unknown>;
|
|
211
|
+
}
|
|
212
|
+
declare function attachRemoteReactor(options: AttachRemoteReactorOptions): Promise<RemoteReactorAttachment>;
|
|
213
|
+
//#endregion
|
|
214
|
+
//#region src/integrations/powerhouse/signing.d.ts
|
|
215
|
+
/** Structural slice of document-model's `ISigner` this module touches. */
|
|
216
|
+
interface SignerLike {
|
|
217
|
+
user?: {
|
|
218
|
+
address: string;
|
|
219
|
+
networkId?: string;
|
|
220
|
+
chainId?: number;
|
|
221
|
+
};
|
|
222
|
+
app?: {
|
|
223
|
+
name?: string;
|
|
224
|
+
key: string;
|
|
225
|
+
};
|
|
226
|
+
signAction: (...args: never[]) => Promise<unknown>;
|
|
227
|
+
}
|
|
228
|
+
/** A document header as far as the write rules read it. */
|
|
229
|
+
interface DocumentHeaderLike {
|
|
230
|
+
header: {
|
|
231
|
+
id: string;
|
|
232
|
+
documentType?: string;
|
|
233
|
+
protocolVersions?: Record<string, number> | null;
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/** The agent cannot sign yet: its signer has no user. */
|
|
237
|
+
declare class SignerNotReadyError extends Error {
|
|
238
|
+
constructor(what?: string);
|
|
239
|
+
}
|
|
240
|
+
/** True when the signer can sign as a user. */
|
|
241
|
+
declare function signerReady(signer: SignerLike): boolean;
|
|
242
|
+
/** The policy a header carries (same rule as document-model's `signaturePolicyOf`). */
|
|
243
|
+
declare function policyOfHeader(header: DocumentHeaderLike["header"] | undefined): SignaturePolicy;
|
|
244
|
+
/**
|
|
245
|
+
* The signer, refusing to sign while it has no user. Everything else is read
|
|
246
|
+
* through to the live signer.
|
|
247
|
+
*/
|
|
248
|
+
declare function createGatedSigner<S extends SignerLike>(signer: S): S;
|
|
249
|
+
interface WriteRules {
|
|
250
|
+
ready(): boolean;
|
|
251
|
+
/**
|
|
252
|
+
* `refuse`: the agent leaves legacy documents alone.
|
|
253
|
+
* `sign-when-ready`: legacy documents are writable whether or not the
|
|
254
|
+
* signer has a user.
|
|
255
|
+
*/
|
|
256
|
+
legacyDocuments: "refuse" | "sign-when-ready";
|
|
257
|
+
/** Which documents the agent acts on by itself. Only read by `canWrite`. */
|
|
258
|
+
accepts?: (document: DocumentHeaderLike) => boolean;
|
|
259
|
+
}
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/integrations/powerhouse/writes.d.ts
|
|
262
|
+
interface ReactorWritesOptions {
|
|
263
|
+
/**
|
|
264
|
+
* The agent's signer. Read on every write, so a signer whose `user` is set
|
|
265
|
+
* later (a sign-in) takes effect without rebuilding the reactor. Without
|
|
266
|
+
* one there is nothing to wait for: `ready()` is always true.
|
|
267
|
+
*/
|
|
268
|
+
signer?: ISigner;
|
|
269
|
+
/** See `WriteRules.legacyDocuments`. Default: `sign-when-ready`. */
|
|
270
|
+
legacyDocuments?: WriteRules["legacyDocuments"];
|
|
271
|
+
/**
|
|
272
|
+
* Which documents the agent acts on by itself (`writes.canWrite`, read by
|
|
273
|
+
* triggers such as the chat watch). Writes the agent is asked to make
|
|
274
|
+
* follow only the signature rules.
|
|
275
|
+
*/
|
|
276
|
+
accepts?: (document: DocumentHeaderLike) => boolean;
|
|
277
|
+
/**
|
|
278
|
+
* Subscribe to changes of the signer's user; `powerhouse:writes:ready` is
|
|
279
|
+
* emitted when writes become possible. Returns an unsubscribe function.
|
|
280
|
+
*/
|
|
281
|
+
onSignerChange?: (listener: () => void) => () => void;
|
|
282
|
+
/** Where `powerhouse:writes:ready` goes: the factory's `ctx.emit`. */
|
|
283
|
+
emit?: (event: "powerhouse:writes:ready", data: Record<string, never>) => void;
|
|
284
|
+
}
|
|
285
|
+
interface ReactorWritesHandle {
|
|
286
|
+
/** For `ReactorContext.writes`. */
|
|
287
|
+
writes: ReactorWrites;
|
|
288
|
+
/**
|
|
289
|
+
* The signer to give the reactor client (`attachRemoteReactor({ signer })`),
|
|
290
|
+
* resolved per push: the gated signer, or `SignerNotReadyError` while it
|
|
291
|
+
* has no user. The resolver throws rather than returning undefined because
|
|
292
|
+
* `GraphQLReactorClient` pushes unsigned when it gets no signer, and checks
|
|
293
|
+
* `user` itself before it would call the gated `signAction`. Undefined
|
|
294
|
+
* without a signer.
|
|
295
|
+
*
|
|
296
|
+
* Limit: the client resolves its signer before it knows the document, so
|
|
297
|
+
* while there is no user this refuses a push to a legacy document too,
|
|
298
|
+
* though `legacyDocuments: "sign-when-ready"` lets `canWrite` pass it.
|
|
299
|
+
* Passing the target document to the resolver would lift it; until then
|
|
300
|
+
* give a signer only where the documents written are v2.
|
|
301
|
+
*/
|
|
302
|
+
signer?: () => ISigner;
|
|
303
|
+
/** Stops watching the signer; call it from `ReactorContext.shutdown`. */
|
|
304
|
+
stop(): void;
|
|
305
|
+
}
|
|
306
|
+
/** See {@link ReactorWritesOptions} and {@link ReactorWritesHandle}. */
|
|
307
|
+
declare function createReactorWrites(options?: ReactorWritesOptions): ReactorWritesHandle;
|
|
308
|
+
//#endregion
|
|
309
|
+
//#region src/integrations/powerhouse/type-guard.d.ts
|
|
310
|
+
/**
|
|
311
|
+
* Type guard for discriminated narrowing in multi-type onChange handlers.
|
|
312
|
+
*
|
|
313
|
+
* Usage:
|
|
314
|
+
* onChange(docs, ctx) {
|
|
315
|
+
* for (const doc of docs) {
|
|
316
|
+
* if (isDocType(doc, 'powerhouse/ph-clint-project')) {
|
|
317
|
+
* // doc is narrowed to R['powerhouse/ph-clint-project']['document']
|
|
318
|
+
* }
|
|
319
|
+
* }
|
|
320
|
+
* }
|
|
321
|
+
*/
|
|
322
|
+
declare function isDocType<R extends DocumentRegistry, T extends keyof R & string>(doc: R[keyof R & string]["document"], type: T): doc is R[T]["document"];
|
|
323
|
+
//#endregion
|
|
324
|
+
//#region src/integrations/powerhouse/folders.d.ts
|
|
325
|
+
/**
|
|
326
|
+
* Create a FolderOperations instance backed by the reactor client.
|
|
327
|
+
*
|
|
328
|
+
* Folders are nodes inside the drive document's `state.global.nodes` array,
|
|
329
|
+
* created via `ADD_FOLDER` and `ADD_FILE` drive operations executed on the
|
|
330
|
+
* personal drive. This is separate from the document relationship graph.
|
|
331
|
+
* Only calls the remote `GraphQLReactorClient` has too are made, so the same
|
|
332
|
+
* operations work on an in-process and on an attached reactor.
|
|
333
|
+
*/
|
|
334
|
+
declare function createFolderOperations(client: TypedReactorClient<any>, personalDriveId: string, log?: Logger): FolderOperations;
|
|
335
|
+
/**
|
|
336
|
+
* Auto-generate CLI commands that wrap FolderOperations.
|
|
337
|
+
*/
|
|
338
|
+
declare function createFolderCommands(folderOps: FolderOperations): Command[];
|
|
339
|
+
//#endregion
|
|
340
|
+
//#region src/integrations/powerhouse/attachment-commands.d.ts
|
|
341
|
+
declare function createAttachmentCommands(): Command[];
|
|
342
|
+
//#endregion
|
|
343
|
+
//#region src/integrations/powerhouse/attachment.d.ts
|
|
344
|
+
/**
|
|
345
|
+
* The attachment service of the run's reactor. Never builds the reactor for
|
|
346
|
+
* it: only where the Cli serves (`folders` marks that) or where its reactor
|
|
347
|
+
* is attached to a switchboard, which reaching builds nothing.
|
|
348
|
+
*/
|
|
349
|
+
declare function getAttachmentService(ctx: Pick<CommandContext, "folders" | "reactor" | "reactorAttached">): Promise<IAttachmentService | undefined>;
|
|
350
|
+
declare function asRef(ref: string): AttachmentRef$1;
|
|
351
|
+
declare function isAttachmentAlreadyExists(err: unknown): err is {
|
|
352
|
+
ref: string;
|
|
353
|
+
hash: string;
|
|
354
|
+
};
|
|
355
|
+
declare function inferMimeType(filePath: string, override?: string): string;
|
|
356
|
+
declare function fileToBlob(filePath: string, mimeType: string): Promise<Blob>;
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/integrations/powerhouse/index.d.ts
|
|
359
|
+
/**
|
|
360
|
+
* Options for attachDefaultReactor(): where the switchboard is, how the
|
|
361
|
+
* client signs and authenticates, and what the CLI's reactor holds there.
|
|
362
|
+
*/
|
|
363
|
+
interface AttachDefaultReactorOptions<R extends DocumentRegistry = AnyRegistry> extends RemoteReactorConfig<R> {
|
|
364
|
+
/** A switchboard drive address, `<switchboard>/d/<slug>`; its GraphQL
|
|
365
|
+
* endpoint or bare origin attach too, but name no drive. */
|
|
366
|
+
url: string;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* The `ReactorConfiguration.remote` a runner attaches with: the config as
|
|
370
|
+
* given, or the function's answer for this setup context. None: `{}`.
|
|
371
|
+
*/
|
|
372
|
+
declare function resolveRemoteReactorConfig<R extends DocumentRegistry = AnyRegistry>(source: RemoteReactorSource<R> | undefined, setup: ReactorSetupContext<R>): Promise<RemoteReactorConfig<R>>;
|
|
373
|
+
/**
|
|
374
|
+
* Build a ReactorContext on a RUNNING switchboard, with the drives and
|
|
375
|
+
* subscriptions the options ask for. The default drive is the first personal
|
|
376
|
+
* drive the options ask for, else the first, else the one the address names.
|
|
377
|
+
* The signer, its rules and its watch go to
|
|
378
|
+
* `createReactorWrites`, which emits `powerhouse:writes:ready` on `ctx.emit`;
|
|
379
|
+
* a signer change also reconnects the realtime socket with the current
|
|
380
|
+
* bearer. Without `ctx.attachments` the context gets the switchboard's own
|
|
381
|
+
* attachment service, authenticated by `ctx.attachmentJwtHandler`, else by
|
|
382
|
+
* `tokenProvider`. `shutdown` releases only this process's side (the
|
|
383
|
+
* bridged subscriptions, the signer watch, the client) and runs once.
|
|
384
|
+
*/
|
|
385
|
+
declare function attachDefaultReactor<R extends DocumentRegistry = AnyRegistry>(ctx: ReactorSetupContext<R>, options: AttachDefaultReactorOptions<R>): Promise<ReactorContext<R>>;
|
|
386
|
+
//#endregion
|
|
387
|
+
export { createDocumentChangeTrigger as A, attachRemoteReactor as C, InferRegistry as D, ActionOf as E, defineRegistry as O, RemoteReactorAttachment as S, bridgeSubscriptions as T, SignerNotReadyError as _, fileToBlob as a, signerReady as b, isAttachmentAlreadyExists as c, createFolderOperations as d, isDocType as f, SignaturePolicy as g, createReactorWrites as h, asRef as i, DocumentChangeTriggerOptions as k, createAttachmentCommands as l, ReactorWritesOptions as m, attachDefaultReactor as n, getAttachmentService as o, ReactorWritesHandle as p, resolveRemoteReactorConfig as r, inferMimeType as s, AttachDefaultReactorOptions as t, createFolderCommands as u, createGatedSigner as v, ensureDrive as w, AttachRemoteReactorOptions as x, policyOfHeader as y };
|
|
388
|
+
export {};
|
|
389
|
+
//# sourceMappingURL=index-C3-HSfKb.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-C3-HSfKb.d.mts","names":[],"sources":["../src/integrations/powerhouse/change-trigger.ts","../src/integrations/powerhouse/registry.ts","../src/integrations/powerhouse/subscriptions.ts","../src/integrations/powerhouse/drive.ts","../src/integrations/powerhouse/remote-reactor.ts","../src/integrations/powerhouse/signing.ts","../src/integrations/powerhouse/writes.ts","../src/integrations/powerhouse/type-guard.ts","../src/integrations/powerhouse/folders.ts","../src/integrations/powerhouse/attachment-commands.ts","../src/integrations/powerhouse/attachment.ts","../src/integrations/powerhouse/index.ts"],"mappings":";;;;;;;UAkBiB,6BACf,UAAU,kBACV,gBAAgB,YAChB,UAAU,yBACV;EAAiB;;EAAsB;;;EAGvC;;EAGA,cAAc,IAAI;;;;;;;;;EAUlB,wBAGM,KAAK,eAAe,QAAQ,SAAS,OAClC;;;;;EAMT;;;;;;EAOA,UACE,KAAK,EAAE,gBACP,KAAK,eAAe,QAAQ,SAAS,iBACxB;;;;;;EAOf,WACE,MAAM,MAAM,EAAE,iBACd,KAAK,eAAe,QAAQ,SAAS,OAClC,QAAQ;;;;;;EAOb;;;;;;EAOA,cAAc;;;;;;;;;;;;;;;;;;;;iBAqBA,4BACd,UAAU,mBAAmB,aAC7B,gBAAgB,mBAAmB,YACnC,UAAU,yBACV;EAAiB;;EAAsB;GAEvC,SAAS,6BAA6B,GAAG,GAAG,SAAS,UACpD,QAAQ,QAAQ,SAAS;;;;;;;;;;;;;;KCnFhB,SAAS,KAAK;EAAY,eAAe;IACjD,gBAAgB,mBAAmB,wBAAwB,KACzD,IACA,WACF;;;;;;;;;;;;KAaQ,cAAc,UAAU,cAAc,kCAE9C,KAAK,aAAa,QAAQ,8CACzB,UAAU,4BAA0B,KACnC,cAAc,GAAG,SAAS;;;;;;;;;;;;;;;;;iBAoBhB,qBACR,UAAU,cAAc,6BAC9B,SAAS,IAAI,cAAc;;;;;;;;;;;iBC7Cb,oBAAoB,UAAU,mBAAmB,aAC/D,QAAQ,gBACR,eAAe,mBAAmB,IAClC,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;iBCFO,YACpB,QAAQ,mBACR,cAAc,cACb;EAAU;EAAY;EAAc;;;;;;;;;;;;UCVtB;;;;;;EAMf;;EAEA,yBAAyB;;;;;;;;EAQzB,mBAAmB;;EAEnB;;;;;;EAMA,gBAAgB;;;;;;;EAOhB,SAAS,iBAAiB;;EAE1B;;UAGe;;EAEf;;EAEA;;EAEA,aAAa;;iBAsEO,oBACpB,SAAS,6BACR,QAAQ;;;;UCrHM;EACf;IAAS;IAAiB;IAAoB;;EAC9C;IAAQ;IAAe;;EACvB,gBAAgB,kBAAkB;;;UAInB;EACf;IACE;IACA;IACA,mBAAmB;;;;cAKV,4BAA4B;EACvC,YAAY;;;iBAOE,YAAY,QAAQ;;iBAKpB,eACd,QAAQ,2CACP;;;;;iBASa,kBAAkB,UAAU,YAAY,QAAQ,IAAI;UAiBnD;EACf;;;;;;EAMA;;EAEA,WAAW,UAAU;;;;UCjEN;;;;;;EAMf,SAAS;;EAET,kBAAkB;;;;;;EAMlB,WAAW,UAAU;;;;;EAKrB,kBAAkB;;EAElB,QACE,kCACA,MAAM;;UAIO;;EAEf,QAAQ;;;;;;;;;;;;;;;EAeR,eAAe;;EAEf;;;iBAIc,oBACd,UAAS,uBACR;;;;;;;;;;;;;;;iBCvDa,UACd,UAAU,kBACV,gBAAgB,YAChB,KAAK,QAAQ,yBAAyB,MAAM,IAAI,OAAO,EAAE;;;;;;;;;;;;iBCqC3C,uBACd,QAAQ,yBACR,yBACA,MAAM,SACL;;;;iBA2Sa,qBAAqB,WAAW,mBAAmB;;;iBCrUnD,4BAA4B;;;;;;;;iBCrBtB,qBACpB,KAAK,KAAK,6DACT,QAAQ;iBAcK,MAAM,cAAc;iBAKpB,0BACd,eACC;EAAS;EAAa;;iBAwBT,cAAc,kBAAkB;iBAO1B,WACpB,kBACA,mBACC,QAAQ;;;;;;;UCmBM,4BACf,UAAU,mBAAmB,qBACrB,oBAAoB;;;EAG5B;;;;;;iBAOoB,2BACpB,UAAU,mBAAmB,aAE7B,QAAQ,oBAAoB,gBAC5B,OAAO,oBAAoB,KAC1B,QAAQ,oBAAoB;;;;;;;;;;;;;iBAiDT,qBACpB,UAAU,mBAAmB,aAE7B,KAAK,oBAAoB,IACzB,SAAS,4BAA4B,KACpC,QAAQ,eAAe"}
|