@powerhousedao/clint 6.4.0-next.2 → 6.4.0-next.4
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-skills-Bpbbnin0.mjs → build-skills-BTkuL8ne.mjs} +2 -2
- package/dist/{build-skills-Bpbbnin0.mjs.map → build-skills-BTkuL8ne.mjs.map} +1 -1
- package/dist/command-control-Dp41aY0o.mjs +224 -0
- package/dist/command-control-Dp41aY0o.mjs.map +1 -0
- package/dist/{dist-Bd6hUl0J.mjs → dist-BTVqrpN4.mjs} +2 -2
- package/dist/{dist-Bd6hUl0J.mjs.map → dist-BTVqrpN4.mjs.map} +1 -1
- package/dist/{index-CfHcet4v.d.mts → index-DJlqIVLv.d.mts} +13 -10
- package/dist/{index-CfHcet4v.d.mts.map → index-DJlqIVLv.d.mts.map} +1 -1
- package/dist/index.d.mts +227 -8
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6 -5
- package/dist/integrations/mastra/index.d.mts +20 -3
- package/dist/integrations/mastra/index.d.mts.map +1 -1
- package/dist/integrations/mastra/index.mjs +25 -3
- package/dist/integrations/mastra/index.mjs.map +1 -1
- package/dist/integrations/powerhouse/index.d.mts +3 -3
- package/dist/integrations/powerhouse/index.mjs +1 -1
- package/dist/{markdown-BUeGwhbR.mjs → markdown-B-HyDpvO.mjs} +471 -39
- package/dist/markdown-B-HyDpvO.mjs.map +1 -0
- package/dist/{powerhouse-3XZmdY3_.mjs → powerhouse-C4O-raTW.mjs} +168 -12
- package/dist/powerhouse-C4O-raTW.mjs.map +1 -0
- package/dist/{proxy-ji3EHzLn.mjs → proxy-DgnOKu1A.mjs} +2 -2
- package/dist/proxy-DgnOKu1A.mjs.map +1 -0
- package/dist/remote-reactor-oBsHphPT.mjs.map +1 -1
- package/dist/{repl-Czb7u0x_.mjs → repl-C4gHgy6P.mjs} +2 -2
- package/dist/{repl-Czb7u0x_.mjs.map → repl-C4gHgy6P.mjs.map} +1 -1
- package/dist/runners/cli-runner.d.mts +5 -2
- package/dist/runners/cli-runner.d.mts.map +1 -1
- package/dist/runners/cli-runner.mjs +21 -7
- package/dist/runners/cli-runner.mjs.map +1 -1
- package/dist/runners/mastra-runner.mjs +1 -1
- package/dist/runners/proxy-runner.mjs +1 -1
- package/dist/{src-BmMd0Wl4.mjs → src-FF3zDJY7.mjs} +606 -53
- package/dist/src-FF3zDJY7.mjs.map +1 -0
- package/dist/{start-BHn9LIyX.mjs → start-CCegR8Pi.mjs} +2 -2
- package/dist/{start-BHn9LIyX.mjs.map → start-CCegR8Pi.mjs.map} +1 -1
- package/dist/testing/index.d.mts +2 -2
- package/dist/testing/index.mjs +1 -1
- package/dist/{types-3TnDjQ1w.d.mts → types-BnPpIAL6.d.mts} +2 -2
- package/dist/{types-3TnDjQ1w.d.mts.map → types-BnPpIAL6.d.mts.map} +1 -1
- package/dist/{types-DbQKfvWc.d.mts → types-CIZtG2TY.d.mts} +219 -13
- package/dist/types-CIZtG2TY.d.mts.map +1 -0
- package/package.json +13 -13
- package/dist/markdown-BUeGwhbR.mjs.map +0 -1
- package/dist/powerhouse-3XZmdY3_.mjs.map +0 -1
- package/dist/proxy-ji3EHzLn.mjs.map +0 -1
- package/dist/src-BmMd0Wl4.mjs.map +0 -1
- package/dist/types-DbQKfvWc.d.mts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as IAttachmentService, Gt as TriggerContext, J as EmitFn, U as CommandContext, V as Command, Wt as Trigger, _ as SubscriptionConfig, c as FolderOperations, d as ReactorContext, f as ReactorSetupContext, g as RemoteReactorSource, h as RemoteReactorConfig, i as DriveConfig, l as LazySigner, m as RegistryEntry, n as AttachmentRef$1, o as EnsureDriveClient, p as ReactorWrites, qt as WorkItem, r as DocumentRegistry, st as Logger, t as AnyRegistry, y as TypedReactorClient } from "./types-CIZtG2TY.mjs";
|
|
2
2
|
import { ReactorProtocol } from "@powerhousedao/host-core";
|
|
3
3
|
import { IReactorClient } from "@powerhousedao/reactor";
|
|
4
4
|
import { DocumentModelModule, ISigner, SignaturePolicy } from "@powerhousedao/shared/document-model";
|
|
@@ -194,10 +194,11 @@ interface AttachRemoteReactorOptions {
|
|
|
194
194
|
/**
|
|
195
195
|
* Signs the actions the client pushes. A function is called per push (see
|
|
196
196
|
* `createReactorWrites`, whose `signer` refuses while the identity has no
|
|
197
|
-
* user)
|
|
198
|
-
*
|
|
197
|
+
* user), and may resolve asynchronously (a forwarded command's caller).
|
|
198
|
+
* Omitted, the client falls back to the ambient Renown signer, which does
|
|
199
|
+
* not exist in Node: actions then go out unsigned.
|
|
199
200
|
*/
|
|
200
|
-
signer?: ISigner | (() => ISigner | undefined);
|
|
201
|
+
signer?: ISigner | (() => ISigner | undefined | Promise<ISigner | undefined>);
|
|
201
202
|
/** Reachability probe budget. */
|
|
202
203
|
timeoutMs?: number;
|
|
203
204
|
}
|
|
@@ -262,10 +263,11 @@ interface WriteRules {
|
|
|
262
263
|
interface ReactorWritesOptions {
|
|
263
264
|
/**
|
|
264
265
|
* 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.
|
|
266
|
-
*
|
|
266
|
+
* later (a sign-in) takes effect without rebuilding the reactor. A
|
|
267
|
+
* {@link LazySigner} is opened at the first write it signs. Without one
|
|
268
|
+
* there is nothing to wait for: `ready()` is always true.
|
|
267
269
|
*/
|
|
268
|
-
signer?: ISigner;
|
|
270
|
+
signer?: ISigner | LazySigner;
|
|
269
271
|
/** See `WriteRules.legacyDocuments`. Default: `sign-when-ready`. */
|
|
270
272
|
legacyDocuments?: WriteRules["legacyDocuments"];
|
|
271
273
|
/**
|
|
@@ -299,7 +301,7 @@ interface ReactorWritesHandle {
|
|
|
299
301
|
* Passing the target document to the resolver would lift it; until then
|
|
300
302
|
* give a signer only where the documents written are v2.
|
|
301
303
|
*/
|
|
302
|
-
signer?: () => ISigner
|
|
304
|
+
signer?: () => ISigner | Promise<ISigner>;
|
|
303
305
|
/** Stops watching the signer; call it from `ReactorContext.shutdown`. */
|
|
304
306
|
stop(): void;
|
|
305
307
|
}
|
|
@@ -379,11 +381,12 @@ declare function resolveRemoteReactorConfig<R extends DocumentRegistry = AnyRegi
|
|
|
379
381
|
* a signer change also reconnects the realtime socket with the current
|
|
380
382
|
* bearer. Without `ctx.attachments` the context gets the switchboard's own
|
|
381
383
|
* attachment service, authenticated by `ctx.attachmentJwtHandler`, else by
|
|
382
|
-
*
|
|
384
|
+
* the bearer the writes carry (a forwarded command's caller's, else
|
|
385
|
+
* `tokenProvider`'s). `shutdown` releases only this process's side (the
|
|
383
386
|
* bridged subscriptions, the signer watch, the client) and runs once.
|
|
384
387
|
*/
|
|
385
388
|
declare function attachDefaultReactor<R extends DocumentRegistry = AnyRegistry>(ctx: ReactorSetupContext<R>, options: AttachDefaultReactorOptions<R>): Promise<ReactorContext<R>>;
|
|
386
389
|
//#endregion
|
|
387
390
|
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
391
|
export {};
|
|
389
|
-
//# sourceMappingURL=index-
|
|
392
|
+
//# sourceMappingURL=index-DJlqIVLv.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-DJlqIVLv.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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AAmB,aAE7B,QAAQ,oBAAoB,gBAC5B,OAAO,oBAAoB,KAC1B,QAAQ,oBAAoB;;;;;;;;;;;;;;iBAkDT,qBACpB,UAAU,mBAAmB,aAE7B,KAAK,oBAAoB,IACzB,SAAS,4BAA4B,KACpC,QAAQ,eAAe"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { A as createDocumentChangeTrigger, D as InferRegistry, E as ActionOf, O as defineRegistry, _ as SignerNotReadyError, b as signerReady, f as isDocType, g as SignaturePolicy, k as DocumentChangeTriggerOptions, n as attachDefaultReactor, r as resolveRemoteReactorConfig, t as AttachDefaultReactorOptions, y as policyOfHeader } from "./index-
|
|
3
|
-
import { i as ReplSessionOptions, n as ReplOutput, r as ReplSession, t as HistoryEntry } from "./types-
|
|
1
|
+
import { $ as HostServiceDefinition, $t as scanProjects, A as AgentSetupContext, At as ServiceDefinition, B as CliOptions, Bt as TextDeltaChunk, C as IAttachmentService, Ct as ResolvedInteractiveConfig, D as AgentProfileConfig, Dt as RunOptions, E as AgentLoader, Et as RoutineStatus, F as CallerIdentity, Ft as ServiceManager, G as CommandServiceDefinition, Gt as TriggerContext, H as CommandCaller, Ht as ToolOutputChunk, I as CallerSession, It as ServiceStartOptions, J as EmitFn, Jt as WorkdirStore, K as ConfigEnvVar, Kt as TriggerOptions, L as CaptureDefinition, Lt as ServiceStatus, M as BootTimings, Mt as ServiceHostRun, N as BootstrapOptions, Nt as ServiceInstanceStatus, O as AgentPromptInput, Ot as RunReactor, P as BootstrapResult, Pt as ServiceLifetime, Q as ForwardOptions, Qt as PROJECT_INDICATORS, R as Cli, Rt as SkillConfig, S as AttachmentUploadResult, St as Resolvable, T as AgentContentPart, Tt as RoutineConfig, U as CommandContext, Ut as ToolResultChunk, V as Command, Vt as ToolCallChunk, W as CommandNeeds, Wt as Trigger, X as ErrorChunk, Xt as SkillInfo, Y as EndpointType, Yt as WrapRegistry, Z as EventBus, Zt as readSkills, _ as SubscriptionConfig, _t as ProjectScanner, a as DriveEntry, at as LifecycleInitContext, b as AttachmentHeader, bt as ReadinessConfig, c as FolderOperations, ct as OnFn, d as ReactorContext, dt as PreflightContext, et as IdentityConfiguration, f as ReactorSetupContext, ft as PreflightResult, g as RemoteReactorSource, gt as ProjectScanResult, h as RemoteReactorConfig, ht as ProcessRunOptions, i as DriveConfig, it as LifecycleHook, j as AgentStreamOptions, jt as ServiceDefinitionBase, k as AgentProvider, kt as ServiceBuildContext, l as LazySigner, lt as PhClintEvents, m as RegistryEntry, mt as ProcessManager, n as AttachmentRef, nt as InteractiveConfig, o as EnsureDriveClient, ot as LogLevel, p as ReactorWrites, pt as ProcessHandle, q as CoreContext, qt as WorkItem, r as DocumentRegistry, rt as LifecycleHandle, s as FolderEntry, st as Logger, t as AnyRegistry, tt as InferConfig, u as ReactorConfiguration, ut as PreflightCheck, v as TypedDocumentChangeEvent, vt as PromptConfig, w as ReserveAttachmentOptions, wt as Routine, x as AttachmentResponse, xt as ReadinessPattern, y as TypedReactorClient, yt as PromptsConfig, z as CliMetadata, zt as StreamChunk } from "./types-CIZtG2TY.mjs";
|
|
2
|
+
import { A as createDocumentChangeTrigger, D as InferRegistry, E as ActionOf, O as defineRegistry, _ as SignerNotReadyError, b as signerReady, f as isDocType, g as SignaturePolicy, k as DocumentChangeTriggerOptions, n as attachDefaultReactor, r as resolveRemoteReactorConfig, t as AttachDefaultReactorOptions, y as policyOfHeader } from "./index-DJlqIVLv.mjs";
|
|
3
|
+
import { i as ReplSessionOptions, n as ReplOutput, r as ReplSession, t as HistoryEntry } from "./types-BnPpIAL6.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { ControlChannel, ControlRecord } from "@powerhousedao/host-core/control-channel";
|
|
6
|
-
import Handlebars from "handlebars";
|
|
5
|
+
import { CallControlOptions, ControlChannel, ControlRecord } from "@powerhousedao/host-core/control-channel";
|
|
7
6
|
import http from "node:http";
|
|
7
|
+
import { ISigner } from "@powerhousedao/shared/document-model";
|
|
8
|
+
import Handlebars from "handlebars";
|
|
8
9
|
//#region src/core/pkg.d.ts
|
|
9
10
|
interface PackageInfo {
|
|
10
11
|
/** Project root directory: the directory of the nearest package.json above the calling file. */
|
|
@@ -366,14 +367,221 @@ export declare function serveServices(channel: ControlChannel, services: Service
|
|
|
366
367
|
export declare function connectRemoteServices(local: ServiceManager, control: ControlRecord): Promise<ServiceManager | undefined>;
|
|
367
368
|
/** Thrown by a start that cannot outlive its command. */
|
|
368
369
|
export declare class ServiceStartRefused extends Error {
|
|
369
|
-
constructor(id: string, serveCommand: string | undefined
|
|
370
|
+
constructor(id: string, serveCommand: string | undefined, supervisor?: {
|
|
371
|
+
pid: number;
|
|
372
|
+
});
|
|
370
373
|
}
|
|
371
374
|
/**
|
|
372
375
|
* The manager of a command that ends with nothing running to forward to:
|
|
373
|
-
* everything but `start`, which is refused with where to run instead.
|
|
376
|
+
* everything but `start`, which is refused with where to run instead. A
|
|
377
|
+
* start that lives with the user's supervisor outlives the command, and is
|
|
378
|
+
* the local manager's to pass on.
|
|
374
379
|
*/
|
|
375
380
|
export declare function refuseServiceStarts(local: ServiceManager, serveCommand: string | undefined): ServiceManager;
|
|
376
381
|
//#endregion
|
|
382
|
+
//#region src/core/command-control.d.ts
|
|
383
|
+
/**
|
|
384
|
+
* A CLI's commands over the control channel of the instance that keeps
|
|
385
|
+
* running. A command that needs the reactor or the agent, typed in a second
|
|
386
|
+
* terminal, is sent to that instance ({@link sendCommand}); the instance runs
|
|
387
|
+
* it with what it holds and sends the output and the exit code back
|
|
388
|
+
* ({@link serveCommands}). The calling process starts no reactor and no agent.
|
|
389
|
+
*/
|
|
390
|
+
/** The method of the control channel that runs a command. */
|
|
391
|
+
export declare const COMMAND_METHOD = "command";
|
|
392
|
+
/** What the calling process sends. */
|
|
393
|
+
export declare const commandRequestSchema: z.ZodObject<{
|
|
394
|
+
cli: z.ZodString;
|
|
395
|
+
version: z.ZodString;
|
|
396
|
+
command: z.ZodOptional<z.ZodString>;
|
|
397
|
+
input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
398
|
+
prompt: z.ZodOptional<z.ZodString>;
|
|
399
|
+
resume: z.ZodOptional<z.ZodString>;
|
|
400
|
+
workdir: z.ZodString;
|
|
401
|
+
cwd: z.ZodString;
|
|
402
|
+
tty: z.ZodBoolean;
|
|
403
|
+
columns: z.ZodOptional<z.ZodNumber>;
|
|
404
|
+
color: z.ZodBoolean;
|
|
405
|
+
verbose: z.ZodOptional<z.ZodBoolean>;
|
|
406
|
+
stdin: z.ZodOptional<z.ZodString>;
|
|
407
|
+
caller: z.ZodObject<{
|
|
408
|
+
user: z.ZodString;
|
|
409
|
+
pid: z.ZodNumber;
|
|
410
|
+
}, z.core.$strict>;
|
|
411
|
+
signer: z.ZodOptional<z.ZodObject<{
|
|
412
|
+
user: z.ZodObject<{
|
|
413
|
+
address: z.ZodString;
|
|
414
|
+
networkId: z.ZodString;
|
|
415
|
+
chainId: z.ZodNumber;
|
|
416
|
+
}, z.core.$strict>;
|
|
417
|
+
app: z.ZodObject<{
|
|
418
|
+
name: z.ZodString;
|
|
419
|
+
key: z.ZodString;
|
|
420
|
+
}, z.core.$strict>;
|
|
421
|
+
}, z.core.$strict>>;
|
|
422
|
+
}, z.core.$strict>;
|
|
423
|
+
type CommandRequest = z.infer<typeof commandRequestSchema>;
|
|
424
|
+
/**
|
|
425
|
+
* Where a serving instance's writes are checked (its `hello` says): the
|
|
426
|
+
* switchboard's base URL, and its data folder when the caller may write its
|
|
427
|
+
* credential's record there.
|
|
428
|
+
*/
|
|
429
|
+
export declare const commandStoreSchema: z.ZodObject<{
|
|
430
|
+
url: z.ZodOptional<z.ZodString>;
|
|
431
|
+
dataDir: z.ZodOptional<z.ZodString>;
|
|
432
|
+
}, z.core.$strip>;
|
|
433
|
+
type CommandStore = z.infer<typeof commandStoreSchema>;
|
|
434
|
+
/** One command an instance runs for a caller. */
|
|
435
|
+
interface ForwardedCommand {
|
|
436
|
+
request: CommandRequest;
|
|
437
|
+
caller: CommandCaller;
|
|
438
|
+
/** Aborted when the caller cancels or goes away. */
|
|
439
|
+
signal: AbortSignal;
|
|
440
|
+
/** Raw output to the caller's stdout and stderr. */
|
|
441
|
+
stdout(text: string): void;
|
|
442
|
+
stderr(text: string): void;
|
|
443
|
+
/** What the caller answers while the command runs (`ControlCall.asks`). */
|
|
444
|
+
asks: ReadonlySet<string>;
|
|
445
|
+
/** Asks the caller (`ControlCall.ask`). */
|
|
446
|
+
ask(kind: string, payload?: unknown): Promise<unknown>;
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* Who a forwarded command acts as, as its request names it: the address and
|
|
450
|
+
* session it signs with. Undefined when the request names none (the caller
|
|
451
|
+
* is asked at the first write, or cannot sign).
|
|
452
|
+
*/
|
|
453
|
+
export declare function callerIdentityOf(request: CommandRequest): CallerIdentity | undefined;
|
|
454
|
+
/**
|
|
455
|
+
* Answers `command` on `channel`: `run` executes one and resolves with its
|
|
456
|
+
* exit code. A request of another CLI, or for another working folder than
|
|
457
|
+
* the instance's, is refused before anything runs.
|
|
458
|
+
*/
|
|
459
|
+
export declare function serveCommands(channel: ControlChannel, cli: {
|
|
460
|
+
name: string;
|
|
461
|
+
version: string;
|
|
462
|
+
workdir: string;
|
|
463
|
+
store?: CommandStore;
|
|
464
|
+
}, run: (command: ForwardedCommand) => Promise<number>): void;
|
|
465
|
+
/** Thrown when a request is too long to send; the message says what to do. */
|
|
466
|
+
export declare class CommandTooLarge extends Error {
|
|
467
|
+
constructor(what: string, hasStdin: boolean);
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Runs `request` in the instance behind `control`: its output goes to
|
|
471
|
+
* `stdout` and `stderr` as it arrives, and the promise resolves with the
|
|
472
|
+
* command's exit code. Aborting `signal` cancels the command there. Rejects
|
|
473
|
+
* with a `ControlError` as `callControl` does, or {@link CommandTooLarge}
|
|
474
|
+
* before anything is sent.
|
|
475
|
+
*/
|
|
476
|
+
export declare function sendCommand(control: ControlRecord, request: CommandRequest, io: {
|
|
477
|
+
stdout: (text: string) => void;
|
|
478
|
+
stderr: (text: string) => void;
|
|
479
|
+
signal?: AbortSignal;
|
|
480
|
+
/** Answers what the instance asks while the command runs. */
|
|
481
|
+
onAsk?: CallControlOptions["onAsk"];
|
|
482
|
+
asks?: readonly string[];
|
|
483
|
+
}): Promise<number>;
|
|
484
|
+
//#endregion
|
|
485
|
+
//#region src/core/forwarded-signing.d.ts
|
|
486
|
+
/**
|
|
487
|
+
* A forwarded command signs as its caller. The command runs in the instance
|
|
488
|
+
* (see `command-control.ts`); the caller's key stays in the caller's process.
|
|
489
|
+
* While the command runs, each action the instance's reactor client signs is
|
|
490
|
+
* sent back over the open control connection (`sign-action`), and the caller
|
|
491
|
+
* signs it, as an SSH agent signs for a forwarded session. The bearer of the
|
|
492
|
+
* command's requests is the caller's too (`bearer`).
|
|
493
|
+
*
|
|
494
|
+
* The scope follows the command's asynchronous calls, as its output scope
|
|
495
|
+
* does (`forwarded-output.ts`). Once the command ended, work it left running
|
|
496
|
+
* cannot sign: it gets {@link CommandEndedError}, never the instance's own
|
|
497
|
+
* signer. Outside any command, and in {@link asOwnSigner}, the instance signs
|
|
498
|
+
* as itself (for a Cli, the signer its reactor configuration gives: its
|
|
499
|
+
* agent's session).
|
|
500
|
+
*/
|
|
501
|
+
/** What an action's `context.signer` names, apart from its signatures. */
|
|
502
|
+
interface SignerIdentity {
|
|
503
|
+
user: {
|
|
504
|
+
address: string;
|
|
505
|
+
networkId: string;
|
|
506
|
+
chainId: number;
|
|
507
|
+
};
|
|
508
|
+
app: {
|
|
509
|
+
name: string;
|
|
510
|
+
key: string;
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
/** The asks a caller answers so that its command signs as the caller. */
|
|
514
|
+
export declare const SIGNING_ASKS: readonly ["signer", "sign-action", "bearer"];
|
|
515
|
+
/** What `hello` says when this instance's commands sign as their callers. */
|
|
516
|
+
export declare const COMMAND_SIGNING = 1;
|
|
517
|
+
/** Work a forwarded command left running tried to sign after the command ended. */
|
|
518
|
+
export declare class CommandEndedError extends Error {
|
|
519
|
+
constructor();
|
|
520
|
+
}
|
|
521
|
+
/** How a running command reaches its caller. */
|
|
522
|
+
interface CallerAsks {
|
|
523
|
+
/** The identity the request carried, when the caller knew it already. */
|
|
524
|
+
signer?: SignerIdentity;
|
|
525
|
+
asks: ReadonlySet<string>;
|
|
526
|
+
ask(kind: string, payload?: unknown): Promise<unknown>;
|
|
527
|
+
}
|
|
528
|
+
/** The caller's signer and bearer, for the command that runs for it. */
|
|
529
|
+
interface CallerSigning {
|
|
530
|
+
signer(): Promise<ISigner>;
|
|
531
|
+
/** Undefined when the caller does not lend its bearer. */
|
|
532
|
+
bearer(): Promise<string | undefined>;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* An `ISigner` whose actions the caller signs. Only actions are forwarded:
|
|
536
|
+
* raw bytes would make the caller sign whatever it is handed.
|
|
537
|
+
*/
|
|
538
|
+
export declare function forwardedSigner(identity: SignerIdentity, ask: CallerAsks["ask"]): ISigner;
|
|
539
|
+
/** The signing of a command whose caller lists the {@link SIGNING_ASKS}. */
|
|
540
|
+
export declare function callerSigningOf(caller: CallerAsks): CallerSigning | undefined;
|
|
541
|
+
/** Runs `work` signing as `caller` until it settles. */
|
|
542
|
+
export declare function withCallerSigning<T>(caller: CallerSigning | undefined, work: () => Promise<T>): Promise<T>;
|
|
543
|
+
/** Runs `fn` signing as the instance, whatever command called (an agent's turn, a listener). */
|
|
544
|
+
export declare function asOwnSigner<T>(fn: () => T): T;
|
|
545
|
+
/**
|
|
546
|
+
* The signer of a write made now: the caller's while its command runs,
|
|
547
|
+
* {@link CommandEndedError} once it ended, else `own`.
|
|
548
|
+
*/
|
|
549
|
+
export declare function signerForWrite(own: (() => ISigner | undefined | Promise<ISigner | undefined>) | undefined): ISigner | undefined | Promise<ISigner | undefined>;
|
|
550
|
+
/**
|
|
551
|
+
* The bearer of a request made now: the caller's while its command runs and
|
|
552
|
+
* the caller lends one, else `own`'s.
|
|
553
|
+
*/
|
|
554
|
+
export declare function bearerForRequest(own: (() => Promise<string | undefined>) | undefined): Promise<string | undefined>;
|
|
555
|
+
//#endregion
|
|
556
|
+
//#region src/core/caller-signing.d.ts
|
|
557
|
+
/**
|
|
558
|
+
* The caller's side of a forwarded command that signs as the caller: what it
|
|
559
|
+
* tells the instance it answers, and the answers. The session opens on the
|
|
560
|
+
* first ask, so a command that writes nothing loads no signing code, and a
|
|
561
|
+
* password is asked here, on the caller's terminal, never by the instance.
|
|
562
|
+
*/
|
|
563
|
+
interface CallerAnswers {
|
|
564
|
+
asks: readonly string[];
|
|
565
|
+
onAsk(kind: string, payload: unknown): Promise<unknown>;
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* How this process answers the asks of a command it forwards. `hold` is
|
|
569
|
+
* called with true while the session opens (a password may be asked) and
|
|
570
|
+
* false after: the command's output waits meanwhile.
|
|
571
|
+
*
|
|
572
|
+
* Nothing is read before the instance asks: whom the caller signs as is
|
|
573
|
+
* answered to `signer`, at the first write, so a command that writes nothing
|
|
574
|
+
* reads no identity and loads none of the code that would.
|
|
575
|
+
*/
|
|
576
|
+
export declare function callerAnswers(o: {
|
|
577
|
+
identity: IdentityConfiguration;
|
|
578
|
+
workdir: string;
|
|
579
|
+
dataDir: string;
|
|
580
|
+
interactive: boolean;
|
|
581
|
+
store?: CommandStore;
|
|
582
|
+
hold?: (on: boolean) => void;
|
|
583
|
+
}): CallerAnswers;
|
|
584
|
+
//#endregion
|
|
377
585
|
//#region src/core/project-mapping.d.ts
|
|
378
586
|
interface ProjectMapping {
|
|
379
587
|
/** Project name. */
|
|
@@ -497,6 +705,11 @@ export declare function isSkillInvocation(v: unknown): v is SkillInvocation;
|
|
|
497
705
|
export declare function createSkillCommands(skills: SkillInfo[], skillConfigs?: Record<string, string | SkillConfig>): Command<any, SkillInvocation>[];
|
|
498
706
|
//#endregion
|
|
499
707
|
//#region src/core/templates.d.ts
|
|
708
|
+
/**
|
|
709
|
+
* Load Handlebars ahead of a render. Handlebars stays off the start path:
|
|
710
|
+
* it loads here or on the first sync call.
|
|
711
|
+
*/
|
|
712
|
+
export declare function loadTemplates(): Promise<void>;
|
|
500
713
|
/**
|
|
501
714
|
* Register the 8 standard Handlebars helpers on a Handlebars instance.
|
|
502
715
|
*/
|
|
@@ -731,6 +944,12 @@ export declare function getGhostSuggestion(input: string, commands: Command[]):
|
|
|
731
944
|
export declare function applyCompletion(input: string, completion: string): string;
|
|
732
945
|
//#endregion
|
|
733
946
|
//#region src/interactive/markdown.d.ts
|
|
947
|
+
/**
|
|
948
|
+
* Load the markdown renderer ahead of a render. marked, marked-terminal and
|
|
949
|
+
* cli-highlight stay off the start path: they load here or on the first
|
|
950
|
+
* sync call.
|
|
951
|
+
*/
|
|
952
|
+
export declare function loadMarkdown(): Promise<void>;
|
|
734
953
|
/**
|
|
735
954
|
* Render a markdown string for terminal display.
|
|
736
955
|
* Returns ANSI-formatted text suitable for terminal output.
|
|
@@ -782,6 +1001,6 @@ interface LifecycleResult {
|
|
|
782
1001
|
*/
|
|
783
1002
|
export declare function initLifecycle(hooks: LifecycleHook[], ctx: LifecycleInitContext): Promise<LifecycleResult>;
|
|
784
1003
|
//#endregion
|
|
785
|
-
export { type ActionOf, type AgentContentPart, type AgentLoader, type AgentProfileConfig, type AgentPromptInput, type AgentProvider, type AgentSetupContext, type AgentStreamOptions, type AnyRegistry, type AttachDefaultReactorOptions, type AttachmentHeader, type AttachmentRef, type AttachmentResponse, type AttachmentUploadResult, type BootTimings, type BootstrapOptions, type BootstrapResult, type CaptureDefinition, type Cli, type CliMetadata, type CliOptions, type Command, type CommandContext, type CommandServiceDefinition, type ConfigEnvVar, type CoreContext, type CreateTypesOptions, type DocumentChangeTriggerOptions, type DocumentRegistry, type DriveConfig, type DriveEntry, type EmitFn, type EndpointType, type EnsureDriveClient, type ErrorChunk, type EventBus, type FieldInfo, type FolderEntry, type FolderOperations, type HistoryEntry, type HostServiceDefinition, type IAttachmentService, type InferConfig, type InferRegistry, type InstallSkillsOptions, type InteractiveConfig, type LifecycleHandle, type LifecycleHook, type LifecycleInitContext, type LifecycleResult, type LogLevel, type Logger, type OnFn, PROJECT_INDICATORS, type PackageInfo, type ParsedReplInput, type PhClintEvents, type PreflightCheck, type PreflightContext, type PreflightResult, type ProcessHandle, type ProcessManager, type ProcessRunOptions, type ProjectMapping, type ProjectScanResult, type ProjectScanner, type PromptConfig, type PromptsConfig, type ProxyRoute, type ProxyServerInstance, type ProxyServerOptions, type ReactorConfiguration, type ReactorContext, type ReactorSetupContext, type ReactorWrites, type ReadinessConfig, type ReadinessPattern, type RegistryEntry, type RemoteReactorConfig, type RemoteReactorSource, type RenderOptions, type RenderResult, type RenderedChunk, type ReplOutput, type ReplSession, type ReplSessionOptions, type ReserveAttachmentOptions, type Resolvable, type ResolvedInteractiveConfig, type Routine, type RoutineConfig, type RoutineStatus, type RunOptions, type RunReactor, type ServiceBuildContext, type ServiceDefinition, type ServiceDefinitionBase, type ServiceHostRun, type ServiceInstanceStatus, type ServiceManager, type ServiceStartOptions, type ServiceStatus, type SignaturePolicy, SignerNotReadyError, type SkillConfig, type SkillInfo, type SkillInvocation, type StreamChunk, type SubscriptionConfig, type TextDeltaChunk, type ToolCallChunk, type ToolOutputChunk, type ToolResultChunk, type Trigger, type TriggerContext, type TriggerOptions, type TypedDocumentChangeEvent, type TypedFactory, type TypedReactorClient, type WorkItem, type WorkdirStore, type WrapRegistry, attachDefaultReactor, createDocumentChangeTrigger, defineRegistry, isDocType, policyOfHeader, readSkills, resolveRemoteReactorConfig, scanProjects, signerReady };
|
|
1004
|
+
export { type ActionOf, type AgentContentPart, type AgentLoader, type AgentProfileConfig, type AgentPromptInput, type AgentProvider, type AgentSetupContext, type AgentStreamOptions, type AnyRegistry, type AttachDefaultReactorOptions, type AttachmentHeader, type AttachmentRef, type AttachmentResponse, type AttachmentUploadResult, type BootTimings, type BootstrapOptions, type BootstrapResult, type CallerAnswers, type CallerAsks, type CallerIdentity, type CallerSession, type CallerSigning, type CaptureDefinition, type Cli, type CliMetadata, type CliOptions, type Command, type CommandCaller, type CommandContext, type CommandNeeds, type CommandRequest, type CommandServiceDefinition, type CommandStore, type ConfigEnvVar, type CoreContext, type CreateTypesOptions, type DocumentChangeTriggerOptions, type DocumentRegistry, type DriveConfig, type DriveEntry, type EmitFn, type EndpointType, type EnsureDriveClient, type ErrorChunk, type EventBus, type FieldInfo, type FolderEntry, type FolderOperations, type ForwardOptions, type ForwardedCommand, type HistoryEntry, type HostServiceDefinition, type IAttachmentService, type IdentityConfiguration, type InferConfig, type InferRegistry, type InstallSkillsOptions, type InteractiveConfig, type LazySigner, type LifecycleHandle, type LifecycleHook, type LifecycleInitContext, type LifecycleResult, type LogLevel, type Logger, type OnFn, PROJECT_INDICATORS, type PackageInfo, type ParsedReplInput, type PhClintEvents, type PreflightCheck, type PreflightContext, type PreflightResult, type ProcessHandle, type ProcessManager, type ProcessRunOptions, type ProjectMapping, type ProjectScanResult, type ProjectScanner, type PromptConfig, type PromptsConfig, type ProxyRoute, type ProxyServerInstance, type ProxyServerOptions, type ReactorConfiguration, type ReactorContext, type ReactorSetupContext, type ReactorWrites, type ReadinessConfig, type ReadinessPattern, type RegistryEntry, type RemoteReactorConfig, type RemoteReactorSource, type RenderOptions, type RenderResult, type RenderedChunk, type ReplOutput, type ReplSession, type ReplSessionOptions, type ReserveAttachmentOptions, type Resolvable, type ResolvedInteractiveConfig, type Routine, type RoutineConfig, type RoutineStatus, type RunOptions, type RunReactor, type ServiceBuildContext, type ServiceDefinition, type ServiceDefinitionBase, type ServiceHostRun, type ServiceInstanceStatus, type ServiceLifetime, type ServiceManager, type ServiceStartOptions, type ServiceStatus, type SignaturePolicy, type SignerIdentity, SignerNotReadyError, type SkillConfig, type SkillInfo, type SkillInvocation, type StreamChunk, type SubscriptionConfig, type TextDeltaChunk, type ToolCallChunk, type ToolOutputChunk, type ToolResultChunk, type Trigger, type TriggerContext, type TriggerOptions, type TypedDocumentChangeEvent, type TypedFactory, type TypedReactorClient, type WorkItem, type WorkdirStore, type WrapRegistry, attachDefaultReactor, createDocumentChangeTrigger, defineRegistry, isDocType, policyOfHeader, readSkills, resolveRemoteReactorConfig, scanProjects, signerReady };
|
|
786
1005
|
export {};
|
|
787
1006
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/core/pkg.ts","../src/core/command.ts","../src/core/errors.ts","../src/core/logger.ts","../src/core/cli.ts","../src/core/trigger.ts","../src/core/types-binding.ts","../src/core/schema.ts","../src/core/store.ts","../src/core/config.ts","../src/core/config-command.ts","../src/core/workdir.ts","../src/core/events.ts","../src/core/processes.ts","../src/core/services.ts","../src/core/service-command.ts","../src/core/service-control.ts","../src/core/project-mapping.ts","../src/core/preflight.ts","../src/core/help-command.ts","../src/core/init.ts","../src/core/skill-commands.ts","../src/core/templates.ts","../src/core/routine.ts","../src/core/routine-service.ts","../src/core/stream.ts","../src/core/proxy-routes.ts","../src/core/proxy.ts","../src/interactive/session.ts","../src/interactive/router.ts","../src/interactive/completions.ts","../src/interactive/markdown.ts","../src/core/wraps.ts","../src/core/lifecycle.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/core/pkg.ts","../src/core/command.ts","../src/core/errors.ts","../src/core/logger.ts","../src/core/cli.ts","../src/core/trigger.ts","../src/core/types-binding.ts","../src/core/schema.ts","../src/core/store.ts","../src/core/config.ts","../src/core/config-command.ts","../src/core/workdir.ts","../src/core/events.ts","../src/core/processes.ts","../src/core/services.ts","../src/core/service-command.ts","../src/core/service-control.ts","../src/core/command-control.ts","../src/core/forwarded-signing.ts","../src/core/caller-signing.ts","../src/core/project-mapping.ts","../src/core/preflight.ts","../src/core/help-command.ts","../src/core/init.ts","../src/core/skill-commands.ts","../src/core/templates.ts","../src/core/routine.ts","../src/core/routine-service.ts","../src/core/stream.ts","../src/core/proxy-routes.ts","../src/core/proxy.ts","../src/interactive/session.ts","../src/interactive/router.ts","../src/interactive/completions.ts","../src/interactive/markdown.ts","../src/core/wraps.ts","../src/core/lifecycle.ts"],"mappings":";;;;;;;;;UAgBiB;;EAEf;;EAEA;;EAEA;;;;;;;;;;wBAWc,gBAAgB,wBAAwB;;;;;;;wBCxBxC,cACd,eAAe,EAAE,SACjB,mBACA,UAAU,yBACV,UAAU,wBAEV,SAAS,QAAQ,QAAQ,SAAS,SAAS,KAC1C,QAAQ,QAAQ,SAAS,SAAS;;;wBCdrB,eAAe,cAAc;;;wBCc7B,aACd,QAAO,UACP,QAAO,uBAEN;;;;;;;;;;wBC6Ia,UACd,8BAA8B,wBAAwB,QACpD,0BAEF,+BAA+B,wBAAwB,QACrD,0BAEF,SAAS,WAAW,SAAS,YAAY;;;;;;;;;;;wBC1J3B,cACd,SAAS,yBACT,UAAU,yBACV,UAAU,mBAAmB,aAC7B,SAAS,eAAe,QAAQ,SAAS,KAAK,QAAQ,QAAQ,SAAS;;;;;;;;;;UCoBxD,mBACf,gBAAgB,EAAE,SAClB,UAAU;EAEV,cAAc;EACd,WAAW;;;;;;;;;UAUI,aAAa,SAAS,UAAU;;;;;EAK/C,cAAc,eAAe,EAAE,SAAS,mBAAmB;IACzD;IACA;IACA,aAAa;IACb,eAAe,EAAE,QAAQ;IACzB,SAAS;IACT,UACE,OAAO,EAAE,OAAO,SAChB,KAAK,eAAe,SAAS,OAC1B,QAAQ;MACX,QAAQ,QAAQ,SAAS,SAAS;;;;;;EAOtC,cAAc,SAAS,yBACrB,SAAS,eAAe,QAAQ,SAAS,KACxC,QAAQ,QAAQ,SAAS;;;;;;EAO5B,cACE,SAAS,kBAAkB,WAC1B,kBAAkB;;;;;;EAOrB,4BACE,gBAAgB,YAChB;IAAiB;;IAAsB;KAEvC,SAAS,6BAA6B,GAAG,G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kBACrB;;;;;;;;;;;;wBChKa,kBAAkB,OAAO;;UAyCxB;EACf,OAAO;EACP;;;;;;;;wBASqB,aACrB,QAAQ,eAAe,eACtB,eAAe;;;;;;;UClED;;EAEf;;;;;EAKA,WAAW;;EAEX;;EAEA;;;;;EAKA;;;;;;EAMA;;;;;;EAMA;;;;UCnBe;;EAEf;;EAEA;;;;;;;;;;;;EAYA;EACA,QAAQ;;UAGO;WACN;WACA;WACA;EACT,SAAS,OAAO;EAChB,qBAAqB;EACrB,aAAa,cAAc,SAAS;EACpC,QAAQ;;;;;wBAwGY,kBACpB,SAAS,qBACR,QAAQ;;;;;;;;;;wBCCK,kBAAkB,MAAM,qBAAqB;;;;;;;UC/I5C;EACf;EACA;EACA;EACA;;;;;;;;;;wBAWc,eACd,eACA,sBACA,8BACC;;;;;;;;;wBAyCa,aAAa;;;;;;;;;;;;;wBCGb,eAAe,eAAe,UAAU;;;;;;wBA6FxC,oBACd,oBACA,eACA,UAAU;;;;;;;wBA4BI,mBACd,eACA,UAAU;;;;;;;;;;wBAyBI,gBAAgB,eAAe;;;;;;;;wBCtJzB,gBAAgB;;;;;;;;wBAmCtB,eAAe;;;;;;;;;;qBC/FlB,gBAAgB;;;;;;;;wBAuCb,aAAa,SAAS,oBAAoB;;;UCxCzC;;EAEf,OAAO;;;;;;EAMP,gBAAgB;;EAEhB,SAAS;;;;;;;;;;;wBAYW,cACpB,OAAO,iBACP,KAAK,uBACJ,QAAQ"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as connectRemoteServices, B as resolveConfig, C as readSkills, D as createServiceCommands, E as callerAnswers, F as generateConfigCommandHelp, G as formatZodError, H as userConfigPath, I as resolveWorkdir, K as readPackageInfo, L as configKeyToEnvVar, M as restartService, N as serveServices, O as formatStatus, P as createConfigCommand, R as getMissingRequiredFields, S as renderSkillTemplate, T as createHelpCommand, U as userStoreFolder, V as toUpperSnake, W as createLogger, _ as createSkillCommands, a as initLifecycle, b as loadTemplates, c as tokenizeArgs, d as createRoutine, f as IDENTITY_WRAPS, g as DEFAULT_SKILL_INSTRUCTION, h as createEventBus, i as defineCli, j as refuseServiceStarts, k as ServiceStartRefused, l as createCompositeServiceManager, m as createProcessManager, n as createTypes, o as createReplSession, p as composeWraps, r as defineTrigger, s as parseReplInput, t as getProjectMapping, u as createRoutineServiceAdapter, v as isSkillInvocation, w as installSkills, x as registerDefaultHelpers, y as extractTemplateVars, z as localConfigPath } from "./src-FF3zDJY7.mjs";
|
|
2
2
|
import { n as slugToTitle, t as getSchemaFields } from "./schema-BEKAZGyT.mjs";
|
|
3
|
-
import { C as isDocType, D as policyOfHeader, M as createDocumentChangeTrigger, N as
|
|
4
|
-
import {
|
|
3
|
+
import { B as signerForWrite, C as isDocType, D as policyOfHeader, F as SIGNING_ASKS, H as defineCommand, I as asOwnSigner, L as bearerForRequest, M as createDocumentChangeTrigger, N as COMMAND_SIGNING, O as signerReady, P as CommandEndedError, R as callerSigningOf, T as SignerNotReadyError, V as withCallerSigning, j as defineRegistry, n as resolveRemoteReactorConfig, t as attachDefaultReactor, z as forwardedSigner } from "./powerhouse-C4O-raTW.mjs";
|
|
4
|
+
import { C as renderStream, S as formatStreamChunk, _ as checkWorkdir, a as getCompletions, c as defineService, g as checkPort, h as checkCommand, i as getCompletionSuffix, m as scanProjects, n as renderMarkdown, o as getGhostSuggestion, p as PROJECT_INDICATORS, r as applyCompletion, s as createServiceManager, t as loadMarkdown, u as resolveServiceName, v as isPortFree } from "./markdown-B-HyDpvO.mjs";
|
|
5
5
|
import { n as createWorkdirStore, t as createMemoryWorkdirStore } from "./store-CxqB-OrX.mjs";
|
|
6
|
-
import { t as
|
|
7
|
-
|
|
6
|
+
import { i as commandRequestSchema, l as sendCommand, n as CommandTooLarge, o as commandStoreSchema, r as callerIdentityOf, t as COMMAND_METHOD, u as serveCommands } from "./command-control-Dp41aY0o.mjs";
|
|
7
|
+
import { t as createProxyServer } from "./proxy-DgnOKu1A.mjs";
|
|
8
|
+
export { COMMAND_METHOD, COMMAND_SIGNING, CommandEndedError, CommandTooLarge, DEFAULT_SKILL_INSTRUCTION, IDENTITY_WRAPS, PROJECT_INDICATORS, SIGNING_ASKS, ServiceStartRefused, SignerNotReadyError, applyCompletion, asOwnSigner, attachDefaultReactor, bearerForRequest, callerAnswers, callerIdentityOf, callerSigningOf, checkCommand, checkPort, checkWorkdir, commandRequestSchema, commandStoreSchema, composeWraps, configKeyToEnvVar, connectRemoteServices, createCompositeServiceManager, createConfigCommand, createDocumentChangeTrigger, createEventBus, createHelpCommand, createLogger, createMemoryWorkdirStore, createProcessManager, createProxyServer, createReplSession, createRoutine, createRoutineServiceAdapter, createServiceCommands, createServiceManager, createSkillCommands, createTypes, createWorkdirStore, defineCli, defineCommand, defineRegistry, defineService, defineTrigger, extractTemplateVars, formatStatus, formatStreamChunk, formatZodError, forwardedSigner, generateConfigCommandHelp, getCompletionSuffix, getCompletions, getGhostSuggestion, getMissingRequiredFields, getProjectMapping, getSchemaFields, initLifecycle, installSkills, isDocType, isPortFree, isSkillInvocation, loadMarkdown, loadTemplates, localConfigPath, parseReplInput, policyOfHeader, readPackageInfo, readSkills, refuseServiceStarts, registerDefaultHelpers, renderMarkdown, renderSkillTemplate, renderStream, resolveConfig, resolveRemoteReactorConfig, resolveServiceName, resolveWorkdir, restartService, scanProjects, sendCommand, serveCommands, serveServices, signerForWrite, signerReady, slugToTitle, toUpperSnake, tokenizeArgs, userConfigPath, userStoreFolder, withCallerSigning };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as AgentSetupContext, Ft as ServiceManager, Jt as WorkdirStore, U as CommandContext, V as Command, k as AgentProvider, st as Logger, zt as StreamChunk } from "../../types-CIZtG2TY.mjs";
|
|
2
2
|
//#region src/integrations/mastra/types.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Options for getTools().
|
|
@@ -12,6 +12,15 @@ interface GetToolsOptions {
|
|
|
12
12
|
* consumer's node_modules, not from ph-clint's.
|
|
13
13
|
*/
|
|
14
14
|
MCPClient?: any;
|
|
15
|
+
/**
|
|
16
|
+
* The bearer each discovered MCP endpoint's requests carry, minted per
|
|
17
|
+
* request: the agent's session, so the endpoint's door knows who calls.
|
|
18
|
+
* The endpoint's host signs the writes. Omitted: requests go anonymous.
|
|
19
|
+
*/
|
|
20
|
+
mcpBearer?: (endpoint: {
|
|
21
|
+
url: string;
|
|
22
|
+
serviceId: string;
|
|
23
|
+
}) => Promise<string | undefined>;
|
|
15
24
|
/**
|
|
16
25
|
* Glob-style patterns matched against the final tool names (CLI + MCP).
|
|
17
26
|
*
|
|
@@ -201,6 +210,11 @@ export declare function mapMastraStream(fullStream: AsyncIterable<{
|
|
|
201
210
|
export declare function commandsToMastraTools(commands: Command[], context: CommandContext): Promise<Record<string, import("@mastra/core/tools").Tool<any, any, any, any, import("@mastra/core/tools").ToolExecutionContext<any, any, unknown>, string, unknown>>>;
|
|
202
211
|
//#endregion
|
|
203
212
|
//#region src/integrations/mastra/mcp.d.ts
|
|
213
|
+
/** The bearer of a discovered endpoint's requests; undefined sends none. */
|
|
214
|
+
type McpBearer = (endpoint: {
|
|
215
|
+
url: string;
|
|
216
|
+
serviceId: string;
|
|
217
|
+
}) => Promise<string | undefined>;
|
|
204
218
|
/**
|
|
205
219
|
* Discover MCP tools from running services that have `api-mcp` endpoints.
|
|
206
220
|
*
|
|
@@ -213,8 +227,11 @@ export declare function commandsToMastraTools(commands: Command[], context: Comm
|
|
|
213
227
|
*
|
|
214
228
|
* @param MCPClient — Constructor from `@mastra/mcp`, must be provided by the consumer.
|
|
215
229
|
* Throws if MCP endpoints exist but no MCPClient is provided.
|
|
230
|
+
* @param bearer — The bearer each endpoint's requests carry: the agent's
|
|
231
|
+
* session, so the endpoint's door knows who calls. Its writes are signed by
|
|
232
|
+
* that endpoint's host. Omitted: requests go anonymous.
|
|
216
233
|
*/
|
|
217
|
-
export declare function discoverMcpTools(services: ServiceManager, log?: Logger, MCPClient?: any): Promise<Record<string, any>>;
|
|
234
|
+
export declare function discoverMcpTools(services: ServiceManager, log?: Logger, MCPClient?: any, bearer?: McpBearer): Promise<Record<string, any>>;
|
|
218
235
|
/**
|
|
219
236
|
* Disconnect all cached MCP clients. Call during teardown.
|
|
220
237
|
*/
|
|
@@ -243,6 +260,6 @@ export declare const CLINT_THREAD_ID_KEY = "clint.threadId";
|
|
|
243
260
|
*/
|
|
244
261
|
export declare function createMastraHelpers(ctx: AgentSetupContext): MastraHelpers;
|
|
245
262
|
//#endregion
|
|
246
|
-
export type { ConversationLoggerOptions, GetToolsOptions, IConversationLogger, MastraHelpers, MastraPathOptions, MastraPaths, WrapAgentOptions };
|
|
263
|
+
export type { ConversationLoggerOptions, GetToolsOptions, IConversationLogger, MastraHelpers, MastraPathOptions, MastraPaths, McpBearer, WrapAgentOptions };
|
|
247
264
|
export {};
|
|
248
265
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/integrations/mastra/types.ts","../../../src/integrations/mastra/paths.ts","../../../src/integrations/mastra/logging.ts","../../../src/integrations/mastra/stream.ts","../../../src/integrations/mastra/tools.ts","../../../src/integrations/mastra/mcp.ts","../../../src/integrations/mastra/index.ts"],"mappings":";;;;;UAKiB;;EAEf;;;;;;EAMA;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/integrations/mastra/types.ts","../../../src/integrations/mastra/paths.ts","../../../src/integrations/mastra/logging.ts","../../../src/integrations/mastra/stream.ts","../../../src/integrations/mastra/tools.ts","../../../src/integrations/mastra/mcp.ts","../../../src/integrations/mastra/index.ts"],"mappings":";;;;;UAKiB;;EAEf;;;;;;EAMA;;;;;;EAMA,aAAa;IACX;IACA;QACI;;;;;;;;;;;;;EAaN;;;;;;;;;UAUe;;EAEf;;;;;;;;;;;;EAYA;IAAwB;;;EAEx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ly invalidate the stale client.
|
|
68
68
|
*/
|
|
69
69
|
const clients = /* @__PURE__ */ new Map();
|
|
70
|
+
/** `fetch` that adds the bearer `bearer` mints for `endpoint`, per request. */
|
|
71
|
+
function fetchWithBearer(bearer, endpoint) {
|
|
72
|
+
return async (url, init) => {
|
|
73
|
+
const token = await bearer(endpoint);
|
|
74
|
+
if (!token) return fetch(url, init);
|
|
75
|
+
const headers = new Headers(init?.headers);
|
|
76
|
+
headers.set("authorization", `Bearer ${token}`);
|
|
77
|
+
return fetch(url, {
|
|
78
|
+
...init,
|
|
79
|
+
headers
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
}
|
|
70
83
|
/**
|
|
71
84
|
* Discover MCP tools from running services that have `api-mcp` endpoints.
|
|
72
85
|
*
|
|
@@ -79,8 +92,11 @@ const clients = /* @__PURE__ */ new Map();
|
|
|
79
92
|
*
|
|
80
93
|
* @param MCPClient — Constructor from `@mastra/mcp`, must be provided by the consumer.
|
|
81
94
|
* Throws if MCP endpoints exist but no MCPClient is provided.
|
|
95
|
+
* @param bearer — The bearer each endpoint's requests carry: the agent's
|
|
96
|
+
* session, so the endpoint's door knows who calls. Its writes are signed by
|
|
97
|
+
* that endpoint's host. Omitted: requests go anonymous.
|
|
82
98
|
*/
|
|
83
|
-
async function discoverMcpTools(services, log, MCPClient) {
|
|
99
|
+
async function discoverMcpTools(services, log, MCPClient, bearer) {
|
|
84
100
|
const instances = services.list();
|
|
85
101
|
const activeEndpoints = [];
|
|
86
102
|
for (const inst of instances) {
|
|
@@ -119,7 +135,13 @@ async function discoverMcpTools(services, log, MCPClient) {
|
|
|
119
135
|
entry = {
|
|
120
136
|
client: new MCPClient({
|
|
121
137
|
id: `ph-clint-mcp-${ep.serviceId}`,
|
|
122
|
-
servers: { [serverKey]: {
|
|
138
|
+
servers: { [serverKey]: {
|
|
139
|
+
url: new URL(ep.url),
|
|
140
|
+
...bearer ? { fetch: fetchWithBearer(bearer, {
|
|
141
|
+
url: ep.url,
|
|
142
|
+
serviceId: ep.serviceId
|
|
143
|
+
}) } : {}
|
|
144
|
+
} }
|
|
123
145
|
}),
|
|
124
146
|
instanceId: ep.instanceId
|
|
125
147
|
};
|
|
@@ -354,7 +376,7 @@ function createMastraHelpers(ctx) {
|
|
|
354
376
|
merged = cliTools;
|
|
355
377
|
} else {
|
|
356
378
|
log?.debug("[getTools] Discovering MCP tools from services...");
|
|
357
|
-
const mcpTools = await discoverMcpTools(services, log, options?.MCPClient);
|
|
379
|
+
const mcpTools = await discoverMcpTools(services, log, options?.MCPClient, options?.mcpBearer);
|
|
358
380
|
log?.debug(`[getTools] CLI tools: ${Object.keys(cliTools).length}, MCP tools: ${Object.keys(mcpTools).length}`);
|
|
359
381
|
merged = {
|
|
360
382
|
...cliTools,
|