@powerhousedao/clint 6.3.0-dev.8 → 6.4.0-next.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.
Files changed (93) hide show
  1. package/dist/build-DZIv63eB.mjs +77 -0
  2. package/dist/build-DZIv63eB.mjs.map +1 -0
  3. package/dist/{build-skills-BnqGyuCH.mjs → build-skills-BNEOn-cl.mjs} +15 -6
  4. package/dist/build-skills-BNEOn-cl.mjs.map +1 -0
  5. package/dist/dist--xzirmg-.mjs +655 -0
  6. package/dist/dist--xzirmg-.mjs.map +1 -0
  7. package/dist/glob-CGjvhxgW.mjs +48 -0
  8. package/dist/glob-CGjvhxgW.mjs.map +1 -0
  9. package/dist/index-C3-HSfKb.d.mts +389 -0
  10. package/dist/index-C3-HSfKb.d.mts.map +1 -0
  11. package/dist/index.d.mts +55 -303
  12. package/dist/index.d.mts.map +1 -1
  13. package/dist/index.mjs +7 -8
  14. package/dist/integrations/mastra/index.d.mts +248 -0
  15. package/dist/integrations/mastra/index.d.mts.map +1 -0
  16. package/dist/integrations/mastra/index.mjs +509 -0
  17. package/dist/integrations/mastra/index.mjs.map +1 -0
  18. package/dist/integrations/powerhouse/index.d.mts +4 -0
  19. package/dist/integrations/powerhouse/index.mjs +3 -0
  20. package/dist/markdown-BUeGwhbR.mjs +1588 -0
  21. package/dist/markdown-BUeGwhbR.mjs.map +1 -0
  22. package/dist/powerhouse-BDnj7kqd.mjs +1922 -0
  23. package/dist/powerhouse-BDnj7kqd.mjs.map +1 -0
  24. package/dist/{proxy-BFR8GScT.mjs → proxy-ji3EHzLn.mjs} +128 -28
  25. package/dist/proxy-ji3EHzLn.mjs.map +1 -0
  26. package/dist/remote-reactor-BQzq4yfO.mjs +69 -0
  27. package/dist/remote-reactor-BQzq4yfO.mjs.map +1 -0
  28. package/dist/{start-b7Mn2cxB.mjs → repl-Czb7u0x_.mjs} +6 -29
  29. package/dist/repl-Czb7u0x_.mjs.map +1 -0
  30. package/dist/runners/cli-runner.d.mts +339 -0
  31. package/dist/runners/cli-runner.d.mts.map +1 -0
  32. package/dist/runners/cli-runner.mjs +324 -0
  33. package/dist/runners/cli-runner.mjs.map +1 -0
  34. package/dist/runners/mastra-runner.d.mts +5 -3
  35. package/dist/runners/mastra-runner.d.mts.map +1 -1
  36. package/dist/runners/mastra-runner.mjs +10 -60
  37. package/dist/runners/mastra-runner.mjs.map +1 -1
  38. package/dist/runners/proxy-runner.d.mts +281 -0
  39. package/dist/runners/proxy-runner.d.mts.map +1 -0
  40. package/dist/runners/proxy-runner.mjs +91 -0
  41. package/dist/runners/proxy-runner.mjs.map +1 -0
  42. package/dist/schema-BEKAZGyT.mjs +47 -0
  43. package/dist/schema-BEKAZGyT.mjs.map +1 -0
  44. package/dist/{src-BebNN3xc.mjs → src-BehwgLP6.mjs} +395 -1481
  45. package/dist/src-BehwgLP6.mjs.map +1 -0
  46. package/dist/start-BHn9LIyX.mjs +37 -0
  47. package/dist/start-BHn9LIyX.mjs.map +1 -0
  48. package/dist/store-CxqB-OrX.mjs +101 -0
  49. package/dist/store-CxqB-OrX.mjs.map +1 -0
  50. package/dist/{stream-DVuufwIj.mjs → stream-BguHx7vC.mjs} +4 -2
  51. package/dist/{stream-DVuufwIj.mjs.map → stream-BguHx7vC.mjs.map} +1 -1
  52. package/dist/testing/index.d.mts +81 -0
  53. package/dist/testing/index.d.mts.map +1 -0
  54. package/dist/testing/index.mjs +131 -0
  55. package/dist/testing/index.mjs.map +1 -0
  56. package/dist/{types-CRkoD-Mm.d.mts → types-CF6GuPJd.d.mts} +241 -261
  57. package/dist/types-CF6GuPJd.d.mts.map +1 -0
  58. package/dist/types-CbHJ-ZnH.d.mts +60 -0
  59. package/dist/types-CbHJ-ZnH.d.mts.map +1 -0
  60. package/package.json +44 -25
  61. package/dist/build-skills-BnqGyuCH.mjs.map +0 -1
  62. package/dist/dist-CUltriBW.mjs +0 -1628
  63. package/dist/dist-CUltriBW.mjs.map +0 -1
  64. package/dist/drive-Bu9zoFrO.mjs +0 -85
  65. package/dist/drive-Bu9zoFrO.mjs.map +0 -1
  66. package/dist/esm-C1DOsF1a.mjs +0 -13140
  67. package/dist/esm-C1DOsF1a.mjs.map +0 -1
  68. package/dist/events-BnwGFTjv.mjs +0 -237
  69. package/dist/events-BnwGFTjv.mjs.map +0 -1
  70. package/dist/folders-BYO1Wqqb.mjs +0 -256
  71. package/dist/folders-BYO1Wqqb.mjs.map +0 -1
  72. package/dist/local-signer-EFzJV3bn.mjs +0 -128
  73. package/dist/local-signer-EFzJV3bn.mjs.map +0 -1
  74. package/dist/markdown-D-sP2zw_.mjs +0 -275
  75. package/dist/markdown-D-sP2zw_.mjs.map +0 -1
  76. package/dist/proxy-BFR8GScT.mjs.map +0 -1
  77. package/dist/proxy-routes-DP3ztsnS.mjs +0 -215
  78. package/dist/proxy-routes-DP3ztsnS.mjs.map +0 -1
  79. package/dist/reactor-C9VIUX1H.mjs +0 -51
  80. package/dist/reactor-C9VIUX1H.mjs.map +0 -1
  81. package/dist/runners/clint-runner.d.mts +0 -398
  82. package/dist/runners/clint-runner.d.mts.map +0 -1
  83. package/dist/runners/clint-runner.mjs +0 -519
  84. package/dist/runners/clint-runner.mjs.map +0 -1
  85. package/dist/services-9E-r0nWl.mjs +0 -999
  86. package/dist/services-9E-r0nWl.mjs.map +0 -1
  87. package/dist/src-BebNN3xc.mjs.map +0 -1
  88. package/dist/start-b7Mn2cxB.mjs.map +0 -1
  89. package/dist/subscriptions-CfiflAsI.mjs +0 -38
  90. package/dist/subscriptions-CfiflAsI.mjs.map +0 -1
  91. package/dist/switchboard-CyvOavqL.mjs +0 -57
  92. package/dist/switchboard-CyvOavqL.mjs.map +0 -1
  93. package/dist/types-CRkoD-Mm.d.mts.map +0 -1
@@ -0,0 +1,248 @@
1
+ import { Bt as WorkdirStore, Dt as ServiceManager, O as AgentProvider, R as Command, et as Logger, jt as StreamChunk, k as AgentSetupContext, z as CommandContext } from "../../types-CF6GuPJd.mjs";
2
+ //#region src/integrations/mastra/types.d.ts
3
+ /**
4
+ * Options for getTools().
5
+ */
6
+ interface GetToolsOptions {
7
+ /** Include MCP tools from running services with api-mcp endpoints. Default: true */
8
+ includeMcp?: boolean;
9
+ /**
10
+ * MCPClient constructor from `@mastra/mcp`. Required for MCP tool discovery.
11
+ * Must be passed by the consumer because `@mastra/mcp` is resolved from the
12
+ * consumer's node_modules, not from ph-clint's.
13
+ */
14
+ MCPClient?: any;
15
+ /**
16
+ * Glob-style patterns matched against the final tool names (CLI + MCP).
17
+ *
18
+ * Pattern syntax: `*` matches any run of characters, `?` matches one char,
19
+ * `[abc]` matches one char from the set. Patterns are anchored to the full
20
+ * tool name (no implicit wildcards on either side).
21
+ *
22
+ * Semantics:
23
+ * - `undefined` → include every tool (default).
24
+ * - `[]` (empty array) → include none (used for sub-agents with no tool patterns).
25
+ * - Non-empty array → include tools whose name matches at least one pattern.
26
+ */
27
+ include?: string[];
28
+ }
29
+ /**
30
+ * Helpers returned by createMastraHelpers().
31
+ * All Mastra imports happen inside these functions (lazy loading).
32
+ */
33
+ /**
34
+ * Options for wrapAgent().
35
+ */
36
+ interface WrapAgentOptions {
37
+ /** Maximum number of tool-call steps per stream() invocation. Default: 30 */
38
+ maxSteps?: number;
39
+ /**
40
+ * Keep the stream open across background-task continuations (Mastra's
41
+ * `stream({ untilIdle })`). The fullStream stays open and emits follow-up
42
+ * turns as the agent's background tasks complete, closing only once none
43
+ * remain. `true` uses the default 5-minute idle timeout; pass
44
+ * `{ maxIdleMs }` to override it.
45
+ *
46
+ * Only takes effect when the agent has memory configured and a `threadId`
47
+ * is passed to stream() (continuations need conversation persistence);
48
+ * otherwise Mastra falls through to a regular stream() call. Default: off.
49
+ */
50
+ untilIdle?: boolean | {
51
+ maxIdleMs?: number;
52
+ };
53
+ /** Enable conversation logging to disk. Default: false */
54
+ enableLogging?: boolean;
55
+ /** Directory to write log files. Required when enableLogging is true. */
56
+ logDirectory?: string;
57
+ /**
58
+ * Enable Anthropic prompt caching. Passes `providerOptions.anthropic.cacheControl`
59
+ * on every stream() call, enabling automatic cache breakpoint placement.
60
+ *
61
+ * Set to `true` for default 5-minute TTL, or specify `{ ttl: '1h' }` for extended caching.
62
+ * Only effective when the model is Anthropic and the prompt exceeds the model's
63
+ * minimum cacheable token threshold (e.g. 4,096 for Haiku 4.5).
64
+ */
65
+ cacheControl?: boolean | {
66
+ ttl?: "5m" | "1h";
67
+ };
68
+ /** Agent description (forwarded to AgentProvider.description). */
69
+ description?: string;
70
+ /** Agent avatar image — data URI or URL (forwarded to AgentProvider.image). */
71
+ image?: string;
72
+ }
73
+ interface MastraHelpers {
74
+ /** Convert CLI commands to Mastra createTool() format, optionally including MCP tools from running services. */
75
+ getTools(options?: GetToolsOptions): Promise<Record<string, any>>;
76
+ /** Resolve pre-built agent profile instructions by agent ID. */
77
+ getAgentInstructions(agentId: string): string;
78
+ /** Create a Mastra Workspace rooted at ctx.workdir. */
79
+ createWorkspace(): Promise<any>;
80
+ /**
81
+ * Create Memory with LibSQL at .ph/{cliName}/mastra/mastra.db.
82
+ *
83
+ * `options` is forwarded to Mastra's `new Memory({ options })` — memory
84
+ * behavior config such as `lastMessages`, `workingMemory`, `semanticRecall`,
85
+ * or `observationalMemory` (background compression of long histories).
86
+ */
87
+ createMemory(options?: Record<string, unknown>): Promise<any>;
88
+ /** Wrap a Mastra Agent as an AgentProvider (handles stream mapping). */
89
+ wrapAgent(agent: any, options?: WrapAgentOptions): AgentProvider;
90
+ }
91
+ //#endregion
92
+ //#region src/integrations/mastra/paths.d.ts
93
+ /**
94
+ * Options for getMastraPaths.
95
+ */
96
+ interface MastraPathOptions {
97
+ /** Pre-packaged skill names under `.mastra/skills/`. */
98
+ prePackagedSkills?: string[];
99
+ }
100
+ /**
101
+ * Structured Mastra paths computed from a WorkdirStore.
102
+ */
103
+ interface MastraPaths {
104
+ /** Root of the `.mastra` folder: `store.getStoreFolder('.mastra')`. */
105
+ rootFolder: string;
106
+ /** Database folder: `store.getStoreFolder('.mastra/db')`. */
107
+ dbFolder: string;
108
+ /** LibSQL database file path. */
109
+ dbPath: string;
110
+ /** The working directory — passed to Mastra as the Workspace basePath. */
111
+ workspaceBasePath: string;
112
+ /** Absolute skill paths: pre-packaged + runtime glob. */
113
+ skillPaths: string[];
114
+ /** Allowed paths for LocalFilesystem containment (the workdir itself). */
115
+ allowedPaths: string[];
116
+ }
117
+ /**
118
+ * Compute Mastra paths from a WorkdirStore.
119
+ *
120
+ * Layout:
121
+ * {workdir}/ ← workspaceBasePath
122
+ * .ph/{cliName}/ ← store root
123
+ * skills/ ← runtime skills (glob **)
124
+ * .mastra/
125
+ * db/
126
+ * mastra.db ← LibSQL database
127
+ * skills/{skill}/SKILL.md ← pre-packaged skills
128
+ */
129
+ export declare function getMastraPaths(store: WorkdirStore, options?: MastraPathOptions): MastraPaths;
130
+ //#endregion
131
+ //#region src/integrations/mastra/logging.d.ts
132
+ /**
133
+ * Interface for logging agent conversations to disk.
134
+ *
135
+ * Framework-agnostic — works with any agent provider that produces
136
+ * StreamChunks (Mastra, raw Anthropic SDK, etc.).
137
+ */
138
+ interface IConversationLogger {
139
+ startSession(sessionId: string, agentId: string, agentName?: string, instructions?: string): void;
140
+ endSession(sessionId: string): void;
141
+ logUserMessage(sessionId: string, message: string): void;
142
+ logAssistantMessage(sessionId: string, message: string): void;
143
+ logToolUse(sessionId: string, toolName: string, args: unknown, toolCallId?: string): void;
144
+ logToolResult(sessionId: string, toolName: string, result: unknown, isError?: boolean, toolCallId?: string): void;
145
+ logError(sessionId: string, error: string): void;
146
+ cleanup(): void;
147
+ }
148
+ interface ConversationLoggerOptions {
149
+ /** Base directory for log files. */
150
+ directory: string;
151
+ }
152
+ /**
153
+ * Append-only markdown logger that writes one file per session.
154
+ *
155
+ * File layout: {directory}/{agentName}/{YYYYMMDD_HHMM_NNN}.md
156
+ */
157
+ export declare class MarkdownConversationLogger implements IConversationLogger {
158
+ private sessions;
159
+ private agentCounters;
160
+ private readonly directory;
161
+ constructor(options: ConversationLoggerOptions);
162
+ startSession(sessionId: string, agentId: string, agentName?: string, instructions?: string): void;
163
+ endSession(sessionId: string): void;
164
+ logUserMessage(sessionId: string, message: string): void;
165
+ logAssistantMessage(sessionId: string, message: string): void;
166
+ logToolUse(sessionId: string, toolName: string, args: unknown, toolCallId?: string): void;
167
+ logToolResult(sessionId: string, toolName: string, result: unknown, isError?: boolean, toolCallId?: string): void;
168
+ logError(sessionId: string, error: string): void;
169
+ cleanup(): void;
170
+ }
171
+ /**
172
+ * Wrap an agent stream generator to log every chunk to a conversation logger.
173
+ *
174
+ * Text-delta chunks are accumulated and flushed as an assistant message
175
+ * whenever a non-text chunk arrives (tool-call, tool-result, error), and
176
+ * again when the stream ends. This preserves the interleaved order of
177
+ * text and tool activity in the log, matching the interactive output.
178
+ */
179
+ export declare function loggedStream(stream: AsyncGenerator<StreamChunk>, logger: IConversationLogger, sessionId: string): AsyncGenerator<StreamChunk>;
180
+ //#endregion
181
+ //#region src/integrations/mastra/stream.d.ts
182
+ /**
183
+ * Map a Mastra Agent fullStream to ph-clint StreamChunks.
184
+ *
185
+ * Handles both the direct property format (chunk.textDelta, chunk.toolName)
186
+ * and the payload-wrapped format (chunk.payload.text) that Mastra uses
187
+ * when Memory is attached to the agent.
188
+ */
189
+ export declare function mapMastraStream(fullStream: AsyncIterable<{
190
+ type: string;
191
+ [key: string]: unknown;
192
+ }>): AsyncGenerator<StreamChunk>;
193
+ //#endregion
194
+ //#region src/integrations/mastra/tools.d.ts
195
+ /**
196
+ * Convert ph-clint commands to Mastra tool definitions.
197
+ *
198
+ * The returned tools are passed to the Agent constructor so the agent
199
+ * can call ph-clint commands during conversation.
200
+ */
201
+ 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
+ //#endregion
203
+ //#region src/integrations/mastra/mcp.d.ts
204
+ /**
205
+ * Discover MCP tools from running services that have `api-mcp` endpoints.
206
+ *
207
+ * Queries the ServiceManager for running instances, finds endpoints typed as
208
+ * `api-mcp`, creates/reuses MCPClient connections, and returns the merged tool set.
209
+ *
210
+ * Tool names are prefixed with `{serviceId}-mcp__` (e.g. `vetra-mcp__getDocument`).
211
+ * For services with multiple active instances, the instance suffix is included
212
+ * (e.g. `vetra-abc123-mcp__getDocument`).
213
+ *
214
+ * @param MCPClient — Constructor from `@mastra/mcp`, must be provided by the consumer.
215
+ * Throws if MCP endpoints exist but no MCPClient is provided.
216
+ */
217
+ export declare function discoverMcpTools(services: ServiceManager, log?: Logger, MCPClient?: any): Promise<Record<string, any>>;
218
+ /**
219
+ * Disconnect all cached MCP clients. Call during teardown.
220
+ */
221
+ export declare function disconnectAllMcp(): Promise<void>;
222
+ //#endregion
223
+ //#region src/integrations/mastra/index.d.ts
224
+ /** RequestContext key holding the chat thread id of an agent stream. */
225
+ export declare const CLINT_THREAD_ID_KEY = "clint.threadId";
226
+ /**
227
+ * Create convenience helpers for building Mastra agents.
228
+ *
229
+ * All Mastra imports happen lazily inside the helper functions,
230
+ * so the ph-clint library works without Mastra installed.
231
+ *
232
+ * Usage (inside an agent factory callback):
233
+ * ```ts
234
+ * agent: {
235
+ * default: async (ctx) => {
236
+ * const { createMastraHelpers } = await import('ph-clint/mastra');
237
+ * const m = createMastraHelpers(ctx);
238
+ * const { Agent } = await import('@mastra/core/agent');
239
+ * return m.wrapAgent(new Agent({ ... }));
240
+ * }
241
+ * }
242
+ * ```
243
+ */
244
+ export declare function createMastraHelpers(ctx: AgentSetupContext): MastraHelpers;
245
+ //#endregion
246
+ export type { ConversationLoggerOptions, GetToolsOptions, IConversationLogger, MastraHelpers, MastraPathOptions, MastraPaths, WrapAgentOptions };
247
+ export {};
248
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +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;;;;;;;;;;;;;EAaA;;;;;;;;;UAUe;;EAEf;;;;;;;;;;;;EAYA;IAAwB;;;EAExB;;EAEA;;;;;;;;;EASA;IAA2B;;;EAE3B;;EAEA;;UAGe;;EAEf,SAAS,UAAU,kBAAkB,QAAQ;;EAE7C,qBAAqB;;EAErB,mBAAmB;;;;;;;;EAQnB,aAAa,UAAU,0BAA0B;;EAEjD,UAAU,YAAY,UAAU,mBAAmB;;;;;;;UChFpC;;EAEf;;;;;UAMe;;EAEf;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;;;;;;;;wBAec,eACd,OAAO,cACP,UAAU,oBACT;;;;;;;;;UCEc;EACf,aACE,mBACA,iBACA,oBACA;EAEF,WAAW;EACX,eAAe,mBAAmB;EAClC,oBAAoB,mBAAmB;EACvC,WACE,mBACA,kBACA,eACA;EAEF,cACE,mBACA,kBACA,iBACA,mBACA;EAEF,SAAS,mBAAmB;EAC5B;;UAgBe;;EAEf;;;;;;;qBAUW,sCAAsC;UACzC;UACA;mBACS;EAEjB,YAAY,SAAS;EAMrB,aACE,mBACA,iBACA,oBACA;EAwCF,WAAW;EAoBX,eAAe,mBAAmB;EAiBlC,oBAAoB,mBAAmB;EAavC,WACE,mBACA,kBACA,eACA;EAgBF,cACE,mBACA,kBACA,iBACA,mBACA;EAeF,SAAS,mBAAmB;EAU5B;;;;;;;;;;wBAkBqB,aACrB,QAAQ,eAAe,cACvB,QAAQ,qBACR,oBACC,eAAe;;;;;;;;;;wBC1QK,gBACrB,YAAY;EAAgB;GAAe;KAC1C,eAAe;;;;;;;;;wBCHI,sBACpB,UAAU,WACV,SAAS,iBAAc,QAAA,4CAAA,sDAAA;;;;;;;;;;;;;;;;wBCqBH,iBACpB,UAAU,gBACV,MAAM,QACN,kBACC,QAAQ;;;;wBAsIW,oBAAoB;;;;qBCpI7B;;;;;;;;;;;;;;;;;;;wBAoBG,oBAAoB,KAAK,oBAAoB"}