@keystrokehq/keystroke 0.0.99 → 0.0.101

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 (51) hide show
  1. package/dist/action.cjs +1 -1
  2. package/dist/action.mjs +1 -1
  3. package/dist/agent.cjs +5 -5
  4. package/dist/agent.cjs.map +1 -1
  5. package/dist/agent.d.cts +3 -274
  6. package/dist/agent.d.mts +3 -274
  7. package/dist/agent.mjs +5 -5
  8. package/dist/agent.mjs.map +1 -1
  9. package/dist/credentials.cjs +1 -1
  10. package/dist/credentials.mjs +1 -1
  11. package/dist/{dist-B1fqDXYa.mjs → dist-CAGgGvND.mjs} +41 -8
  12. package/dist/dist-CAGgGvND.mjs.map +1 -0
  13. package/dist/{dist-T7a5DjzV.cjs → dist-DG2RS68d.cjs} +41 -8
  14. package/dist/dist-DG2RS68d.cjs.map +1 -0
  15. package/dist/{dist-ByV6mHKd.cjs → dist-DJhg5KTL.cjs} +120 -41
  16. package/dist/{dist-ByV6mHKd.cjs.map → dist-DJhg5KTL.cjs.map} +1 -1
  17. package/dist/{dist-CxaI84Ch.cjs → dist-DKGeSeMa.cjs} +3 -3
  18. package/dist/{dist-CxaI84Ch.cjs.map → dist-DKGeSeMa.cjs.map} +1 -1
  19. package/dist/{dist-BML_gJSh.mjs → dist-DzfOPx7X.mjs} +115 -42
  20. package/dist/{dist-BML_gJSh.mjs.map → dist-DzfOPx7X.mjs.map} +1 -1
  21. package/dist/{dist-CiaGdqFg.mjs → dist-cDEt5yzO.mjs} +3 -3
  22. package/dist/{dist-CiaGdqFg.mjs.map → dist-cDEt5yzO.mjs.map} +1 -1
  23. package/dist/index-CBgXyNH2.d.mts +275 -0
  24. package/dist/index-CBgXyNH2.d.mts.map +1 -0
  25. package/dist/index-CiuCYKLw.d.cts.map +1 -1
  26. package/dist/index-CiuCYKLw.d.mts.map +1 -1
  27. package/dist/index-L5a2mf72.d.cts +275 -0
  28. package/dist/index-L5a2mf72.d.cts.map +1 -0
  29. package/dist/{mistral-BLRy436m.cjs → mistral-9mfXttcp.cjs} +2 -2
  30. package/dist/{mistral-BLRy436m.cjs.map → mistral-9mfXttcp.cjs.map} +1 -1
  31. package/dist/{mistral-CI7CQc_C.mjs → mistral-CGHbHFQG.mjs} +2 -2
  32. package/dist/{mistral-CI7CQc_C.mjs.map → mistral-CGHbHFQG.mjs.map} +1 -1
  33. package/dist/{sse-Bxvdniu5.mjs → sse-CcbP5P9d.mjs} +2 -2
  34. package/dist/{sse-Bxvdniu5.mjs.map → sse-CcbP5P9d.mjs.map} +1 -1
  35. package/dist/{sse-DGaTY14k.cjs → sse-DSHssCpN.cjs} +2 -2
  36. package/dist/{sse-DGaTY14k.cjs.map → sse-DSHssCpN.cjs.map} +1 -1
  37. package/dist/trigger.cjs +67 -30
  38. package/dist/trigger.cjs.map +1 -1
  39. package/dist/trigger.d.cts +37 -22
  40. package/dist/trigger.d.cts.map +1 -1
  41. package/dist/trigger.d.mts +37 -22
  42. package/dist/trigger.d.mts.map +1 -1
  43. package/dist/trigger.mjs +65 -31
  44. package/dist/trigger.mjs.map +1 -1
  45. package/dist/workflow.cjs +1 -1
  46. package/dist/workflow.mjs +1 -1
  47. package/package.json +1 -1
  48. package/dist/agent.d.cts.map +0 -1
  49. package/dist/agent.d.mts.map +0 -1
  50. package/dist/dist-B1fqDXYa.mjs.map +0 -1
  51. package/dist/dist-T7a5DjzV.cjs.map +0 -1
package/dist/agent.d.cts CHANGED
@@ -1,275 +1,4 @@
1
- import { c as CredentialRunContext, h as OAuthTokenAdapter } from "./index-CiuCYKLw.cjs";
2
- import { a as AgentState, i as AgentMessage, l as ThinkingLevel, n as AgentOptions, o as AgentTool, p as Model, t as Agent$1, u as getModel } from "./index-BcMCpDKh.cjs";
3
- import { n as ActionDefinition } from "./index-CfK7yBQI.cjs";
1
+ import { l as ThinkingLevel, u as getModel } from "./index-BcMCpDKh.cjs";
2
+ import { A as messages, B as AgentCreateInputSchema, C as createAgent, D as errorMessage, E as defineTool, F as resolveAgentTools, G as parseAgentCreateInput, H as ModelRef, I as resolveAgentWorkspaceRoot, K as resolveThinkingLevel, L as runAgentPrompt, M as prepareAgentSession, N as prompt, O as getSubagentToolMetadata, P as resolveAgentAssets, R as snapshot, S as buildAgentRuntime, T as defineSubagentTool, U as ModelRefSchema, V as DEFAULT_THINKING_LEVEL, W as ThinkingLevelSchema, _ as SessionAgentMismatchError, a as AgentDefinitionInput, b as SubagentToolInherit, c as BuildAgentRuntimeContext, d as PromptInput, f as PromptResponse, g as SandboxedAgentRuntime, h as SUBAGENT_TOOL, i as AgentDefinition, j as normalizeAgentDefinition, k as loadAssetManifest, l as DefineAgentOptions, m as RunAgentPromptOptions, n as AgentAssetInput, o as AgentRuntime, p as ResolvedAgentAssets, r as AgentConfig, s as AgentSnapshot, t as Agent, u as DefineSubagentToolInput, v as SubagentTool, w as defineAgent, x as SubagentToolMetadata, y as SubagentToolDetails, z as AgentCreateInput } from "./index-L5a2mf72.cjs";
4
3
  import { a as McpDefinition, c as McpServerOptions, d as McpTransport, f as connectMcpDefinition, g as isMcp, h as defineMcp, i as McpConnection, l as McpStdioOptions, m as connectMcpStdio, n as McpAuthOptions, o as McpDefinitionInput, p as connectMcpServer, r as McpCallToolOptions, s as McpHttpTransport, t as ToolCredentialResolver, u as McpStdioTransport } from "./index-MfPRY7cK.cjs";
5
- import { C as AssetManifest, T as SandboxDefinition, a as RuntimeHooks, c as SkillDefinition, o as RuntimeProvider, s as Sandbox } from "./index-B61sMU7a.cjs";
6
- import { z } from "zod";
7
- import { DatabaseSync } from "node:sqlite";
8
-
9
- //#region ../agent/dist/schemas.d.mts
10
- //#region src/schemas.d.ts
11
- /** Wire-format model reference — resolve with `getModel(provider, id)`. */
12
- declare const ModelRefSchema: z.ZodObject<{
13
- provider: z.ZodString;
14
- id: z.ZodString;
15
- }, z.core.$strip>;
16
- declare const ThinkingLevelSchema: z.ZodEnum<{
17
- off: "off";
18
- minimal: "minimal";
19
- low: "low";
20
- medium: "medium";
21
- high: "high";
22
- xhigh: "xhigh";
23
- }>;
24
- declare const DEFAULT_THINKING_LEVEL: "medium";
25
- /** Serializable subset of {@link AgentConfig} for JSON/env/CLI boundaries. */
26
- declare const AgentCreateInputSchema: z.ZodObject<{
27
- systemPrompt: z.ZodString;
28
- model: z.ZodObject<{
29
- provider: z.ZodString;
30
- id: z.ZodString;
31
- }, z.core.$strip>;
32
- thinkingLevel: z.ZodOptional<z.ZodEnum<{
33
- off: "off";
34
- minimal: "minimal";
35
- low: "low";
36
- medium: "medium";
37
- high: "high";
38
- xhigh: "xhigh";
39
- }>>;
40
- }, z.core.$strip>;
41
- type ModelRef = z.infer<typeof ModelRefSchema>;
42
- type AgentCreateInput = z.infer<typeof AgentCreateInputSchema>;
43
- declare function parseAgentCreateInput(input: unknown): AgentCreateInput;
44
- declare function resolveThinkingLevel(level?: ThinkingLevel): ThinkingLevel; //#endregion
45
- //#endregion
46
- //#region ../memory/dist/index.d.mts
47
- //#region src/config.d.ts
48
- type MemoryConfig = {
49
- enabled: boolean;
50
- dir: string;
51
- memoryFile: string;
52
- userFile: string;
53
- archiveDir: string;
54
- dbFile: string;
55
- sessionsDir: string;
56
- memoryCharLimit: number;
57
- userCharLimit: number;
58
- archiveTocLimit: number;
59
- securityScan: boolean;
60
- };
61
- //#endregion
62
- //#region src/prepare.d.ts
63
- type MemoryHandle = {
64
- config: MemoryConfig;
65
- db: DatabaseSync;
66
- reindexSessions: () => void;
67
- close: () => void;
68
- };
69
- type MemoryOptions = false | Partial<MemoryConfig>;
70
- //#endregion
71
- //#region ../agent/dist/index.d.mts
72
- //#region src/agent.d.ts
73
- type AgentConfig = {
74
- systemPrompt: string;
75
- model: Model<string>;
76
- thinkingLevel?: ThinkingLevel;
77
- messages?: AgentMessage[];
78
- tools?: AgentTool[];
79
- } & Omit<AgentOptions, "initialState">;
80
- type AgentRuntime = Readonly<{
81
- pi: Agent$1;
82
- }>;
83
- type AgentSnapshot = Readonly<{
84
- state: AgentState;
85
- }>;
86
- declare function createAgent(config: AgentConfig): AgentRuntime;
87
- declare function prompt(runtime: AgentRuntime, message: string): Promise<AgentSnapshot>;
88
- declare function snapshot(runtime: AgentRuntime): AgentSnapshot;
89
- declare function messages(snapshot: AgentSnapshot): AgentMessage[];
90
- declare function errorMessage(snapshot: AgentSnapshot): string | undefined; //#endregion
91
- //#region src/tool.d.ts
92
- declare function defineTool<T extends AgentTool>(tool: T): T; //#endregion
93
- //#region src/define/types.d.ts
94
- /** MCP defs vary by credential shape at authoring time. */
95
- type AgentMcpTool = McpDefinition<any>;
96
- /** Author-facing agent input — asset keys resolve from src/skills/ and src/files/. */
97
- type AgentDefinitionAuthorInput = AgentCreateInput & {
98
- tools?: Array<ActionDefinition | AgentTool | AgentMcpTool>;
99
- runtimeHooks?: RuntimeHooks; /** Skill folder names under `src/skills/{key}/`. */
100
- skills?: string[]; /** `true` uses agent `{ key }`; string uses `src/files/{setKey}/`. */
101
- files?: boolean | string; /** Advanced inline or shared sandbox layout. Merged with resolved `files`. */
102
- sandbox?: SandboxDefinition;
103
- runtimeProvider?: RuntimeProvider; /** Persistent memory (default on). Pass `false` to disable. */
104
- memory?: MemoryOptions;
105
- };
106
- /** Input to {@link defineAgent}. */
107
- type AgentDefinitionInput = AgentDefinitionAuthorInput;
108
- /** Normalized agent definition used by the server (defaults applied). */
109
- type AgentDefinition = AgentCreateInput & {
110
- tools?: Array<ActionDefinition | AgentTool | AgentMcpTool>;
111
- runtimeHooks?: RuntimeHooks;
112
- sandbox?: SandboxDefinition;
113
- skills?: SkillDefinition[];
114
- runtimeProvider?: RuntimeProvider;
115
- memory?: MemoryOptions;
116
- };
117
- type PromptInput = {
118
- message: string;
119
- sessionId?: string;
120
- subscriptionId?: string;
121
- context?: CredentialRunContext;
122
- };
123
- /** Server-level overrides when mounting an agent or calling {@link Agent.prompt}. */
124
- type RunAgentPromptOptions = {
125
- workspacesRoot?: string;
126
- /**
127
- * Explicit host root backing `/workspace`.
128
- * When set (typically by a workflow action), the agent's own `sandbox` definition is not materialized.
129
- */
130
- workspaceRoot?: string; /** Overrides {@link AgentDefinition.runtimeProvider} for this call. */
131
- runtimeProvider?: RuntimeProvider;
132
- runtimeHooks?: RuntimeHooks;
133
- credentials?: CredentialRunContext;
134
- oauthAdapter?: OAuthTokenAdapter;
135
- memory?: MemoryOptions; /** Overrides {@link AgentDefinition.thinkingLevel} for this call. */
136
- thinkingLevel?: ThinkingLevel;
137
- tracing?: {
138
- trigger?: "api" | "gateway" | "subagent" | "workflow";
139
- gatewayAttachmentId?: string;
140
- gatewayAttachmentKey?: string;
141
- agentKey?: string;
142
- }; /** When set by {@link withManualAgentTrace}, skips the outer agent_session span. */
143
- skipAgentSessionSpan?: boolean;
144
- invocationRoute?: string;
145
- };
146
- type PromptResponse = {
147
- sessionId: string;
148
- messages: AgentMessage[];
149
- error: string | null;
150
- }; //#endregion
151
- //#region src/define/build-agent-runtime.d.ts
152
- type BuildAgentRuntimeContext = {
153
- agentId: string;
154
- sessionId: string;
155
- messages?: AgentMessage[];
156
- };
157
- /** Pi agent plus sandbox — dispose {@link SandboxedAgentRuntime.sandbox} after each prompt. */
158
- type SandboxedAgentRuntime = AgentRuntime & {
159
- sandbox: Sandbox;
160
- tools: AgentTool[];
161
- mcpConnections: McpConnection[];
162
- workspaceRoot: string;
163
- memory?: MemoryHandle;
164
- takeCredentialError?: () => unknown;
165
- };
166
- /** Sandbox tools + host tools → pi agent from a {@link AgentDefinition}. */
167
- declare function buildAgentRuntime(def: AgentDefinition, ctx: BuildAgentRuntimeContext, runPrompt?: RunAgentPromptOptions): Promise<SandboxedAgentRuntime>; //#endregion
168
- //#region src/define/define-agent.d.ts
169
- type DefineAgentOptions = {
170
- /** Discovery key — resolves agentId from the DB registry after createServer sync. */key?: string; /** Server overrides for sandbox/workspace when prompting. */
171
- runPrompt?: RunAgentPromptOptions; /** Agent module URL (`import.meta.url`) — resolves `src/skills/` and `src/files/` in dev. */
172
- module?: string;
173
- };
174
- type Agent = AgentDefinition & {
175
- /** Discovery and route id for this agent (`POST /agents/{key}`). */key: string; /** Per-request pi agent + sandbox from this definition. */
176
- buildRuntime: (ctx: BuildAgentRuntimeContext, runPrompt?: RunAgentPromptOptions) => Promise<SandboxedAgentRuntime>;
177
- prompt(input: {
178
- message: string;
179
- sessionId?: string;
180
- agentId?: string;
181
- }, runPrompt?: RunAgentPromptOptions): Promise<PromptResponse>;
182
- };
183
- /**
184
- * Define an agent: normalized config plus a pipeline that builds sandbox + pi runtime on demand.
185
- */
186
- declare function defineAgent(input: AgentDefinitionInput, options?: DefineAgentOptions): Agent; //#endregion
187
- //#region src/define/define-subagent-tool.d.ts
188
- declare const SUBAGENT_TOOL: unique symbol;
189
- /** Reserved for parent→child passthrough (credentials, workspace, etc.). Not wired yet. */
190
- type SubagentToolInherit = {
191
- credentials?: boolean;
192
- workspace?: boolean;
193
- };
194
- type SubagentToolMetadata = {
195
- agent: Agent;
196
- inherit?: SubagentToolInherit;
197
- };
198
- type SubagentToolDetails = {
199
- sessionId: string;
200
- error: string | null;
201
- };
202
- type SubagentTool = AgentTool & {
203
- [SUBAGENT_TOOL]: SubagentToolMetadata;
204
- };
205
- type DefineSubagentToolInput = {
206
- agent: Agent;
207
- name: string;
208
- label: string;
209
- description?: string;
210
- parameters: AgentTool["parameters"];
211
- inherit?: SubagentToolInherit; /** Defaults to `params.message`. Override when tool params use a different shape. */
212
- toMessage?: (params: unknown) => string;
213
- };
214
- declare function getSubagentToolMetadata(tool: AgentTool): SubagentToolMetadata | undefined;
215
- declare function defineSubagentTool(input: DefineSubagentToolInput): SubagentTool; //#endregion
216
- //#region src/define/run-prompt.d.ts
217
- declare function runAgentPrompt(agent: Agent, agentId: string, input: {
218
- message: string;
219
- sessionId?: string;
220
- context?: RunAgentPromptOptions["credentials"];
221
- }, options?: RunAgentPromptOptions): Promise<PromptResponse>;
222
- declare class SessionAgentMismatchError extends Error {
223
- constructor(sessionId: string);
224
- } //#endregion
225
- //#region src/define/prepare-session.d.ts
226
- declare function prepareAgentSession(agentId: string, sessionId?: string): Promise<{
227
- sessionId: string;
228
- }>; //#endregion
229
- //#region src/define/normalize-definition.d.ts
230
- /** Normalizes optional agent fields for the server runtime. */
231
- declare function normalizeAgentDefinition(input: AgentDefinitionInput, options?: {
232
- agentKey?: string;
233
- appRoot?: string;
234
- module?: string;
235
- }): AgentDefinition; //#endregion
236
- //#region src/define/resolve-agent-workspace-root.d.ts
237
- /**
238
- * Resolve the host directory backing `/workspace` for an agent prompt.
239
- *
240
- * Precedence:
241
- * 1. Explicit `workspaceRoot` override (workflow handoff) — skips agent sandbox materialization.
242
- * 2. Agent `sandbox` definition — materialize to `{workspacesRoot}/{agentId}/`.
243
- * 3. Default agent dir — `{workspacesRoot}/{agentId}/`.
244
- *
245
- * Agent skills always materialize into the resolved workspace when configured.
246
- */
247
- declare function resolveAgentWorkspaceRoot(agentId: string, options: {
248
- workspacesRoot?: string;
249
- workspaceRoot?: string;
250
- sandbox?: SandboxDefinition;
251
- skills?: SkillDefinition[];
252
- }): Promise<string>; //#endregion
253
- //#region src/define/resolve-agent-assets.d.ts
254
- type AgentAssetInput = {
255
- skillKeys?: string[];
256
- files?: boolean | string;
257
- agentKey?: string;
258
- appRoot?: string;
259
- };
260
- type ResolvedAgentAssets = {
261
- skills?: SkillDefinition[];
262
- sandbox?: SandboxDefinition;
263
- };
264
- declare function loadAssetManifest(appRoot: string): AssetManifest;
265
- /** Resolve author-facing skill/file keys into packed sandbox + skill definitions. */
266
- declare function resolveAgentAssets(input: AgentAssetInput): ResolvedAgentAssets; //#endregion
267
- //#region src/define/resolve-tools.d.ts
268
- type ResolvedAgentTools = {
269
- tools: AgentTool[];
270
- mcpConnections: McpConnection[];
271
- };
272
- declare function resolveAgentTools(tools: Array<ActionDefinition | AgentTool | AgentMcpTool>, resolver: ToolCredentialResolver): Promise<ResolvedAgentTools>; //#endregion
273
- //#endregion
274
- export { type Agent, type AgentAssetInput, type AgentConfig, type AgentCreateInput, AgentCreateInputSchema, type AgentDefinition, type AgentDefinitionInput, type AgentRuntime, type AgentSnapshot, type BuildAgentRuntimeContext, DEFAULT_THINKING_LEVEL, type DefineAgentOptions, type DefineSubagentToolInput, type McpAuthOptions, type McpCallToolOptions, type McpConnection, type McpDefinition, type McpDefinitionInput, type McpHttpTransport, type McpServerOptions, type McpStdioOptions, type McpStdioTransport, type McpTransport, type ModelRef, ModelRefSchema, type PromptInput, type PromptResponse, type ResolvedAgentAssets, type RunAgentPromptOptions, SUBAGENT_TOOL, type SandboxedAgentRuntime, SessionAgentMismatchError, type SubagentTool, type SubagentToolDetails, type SubagentToolInherit, type SubagentToolMetadata, type ThinkingLevel, ThinkingLevelSchema, type ToolCredentialResolver, buildAgentRuntime, connectMcpDefinition, connectMcpServer, connectMcpStdio, createAgent, defineAgent, defineMcp, defineSubagentTool, defineTool, errorMessage, getModel, getSubagentToolMetadata, isMcp, loadAssetManifest, messages, normalizeAgentDefinition, parseAgentCreateInput, prepareAgentSession, prompt, resolveAgentAssets, resolveAgentTools, resolveAgentWorkspaceRoot, resolveThinkingLevel, runAgentPrompt, snapshot };
275
- //# sourceMappingURL=agent.d.cts.map
4
+ export { type Agent, type AgentAssetInput, type AgentConfig, type AgentCreateInput, AgentCreateInputSchema, type AgentDefinition, type AgentDefinitionInput, type AgentRuntime, type AgentSnapshot, type BuildAgentRuntimeContext, DEFAULT_THINKING_LEVEL, type DefineAgentOptions, type DefineSubagentToolInput, type McpAuthOptions, type McpCallToolOptions, type McpConnection, type McpDefinition, type McpDefinitionInput, type McpHttpTransport, type McpServerOptions, type McpStdioOptions, type McpStdioTransport, type McpTransport, type ModelRef, ModelRefSchema, type PromptInput, type PromptResponse, type ResolvedAgentAssets, type RunAgentPromptOptions, SUBAGENT_TOOL, type SandboxedAgentRuntime, SessionAgentMismatchError, type SubagentTool, type SubagentToolDetails, type SubagentToolInherit, type SubagentToolMetadata, type ThinkingLevel, ThinkingLevelSchema, type ToolCredentialResolver, buildAgentRuntime, connectMcpDefinition, connectMcpServer, connectMcpStdio, createAgent, defineAgent, defineMcp, defineSubagentTool, defineTool, errorMessage, getModel, getSubagentToolMetadata, isMcp, loadAssetManifest, messages, normalizeAgentDefinition, parseAgentCreateInput, prepareAgentSession, prompt, resolveAgentAssets, resolveAgentTools, resolveAgentWorkspaceRoot, resolveThinkingLevel, runAgentPrompt, snapshot };
package/dist/agent.d.mts CHANGED
@@ -1,275 +1,4 @@
1
- import { c as CredentialRunContext, h as OAuthTokenAdapter } from "./index-CiuCYKLw.mjs";
2
- import { a as AgentState, i as AgentMessage, l as ThinkingLevel, n as AgentOptions, o as AgentTool, p as Model, t as Agent$1, u as getModel } from "./index-Bd_asjgz.mjs";
3
- import { n as ActionDefinition } from "./index-by6PXA-8.mjs";
1
+ import { l as ThinkingLevel, u as getModel } from "./index-Bd_asjgz.mjs";
2
+ import { A as messages, B as AgentCreateInputSchema, C as createAgent, D as errorMessage, E as defineTool, F as resolveAgentTools, G as parseAgentCreateInput, H as ModelRef, I as resolveAgentWorkspaceRoot, K as resolveThinkingLevel, L as runAgentPrompt, M as prepareAgentSession, N as prompt, O as getSubagentToolMetadata, P as resolveAgentAssets, R as snapshot, S as buildAgentRuntime, T as defineSubagentTool, U as ModelRefSchema, V as DEFAULT_THINKING_LEVEL, W as ThinkingLevelSchema, _ as SessionAgentMismatchError, a as AgentDefinitionInput, b as SubagentToolInherit, c as BuildAgentRuntimeContext, d as PromptInput, f as PromptResponse, g as SandboxedAgentRuntime, h as SUBAGENT_TOOL, i as AgentDefinition, j as normalizeAgentDefinition, k as loadAssetManifest, l as DefineAgentOptions, m as RunAgentPromptOptions, n as AgentAssetInput, o as AgentRuntime, p as ResolvedAgentAssets, r as AgentConfig, s as AgentSnapshot, t as Agent, u as DefineSubagentToolInput, v as SubagentTool, w as defineAgent, x as SubagentToolMetadata, y as SubagentToolDetails, z as AgentCreateInput } from "./index-CBgXyNH2.mjs";
4
3
  import { a as McpDefinition, c as McpServerOptions, d as McpTransport, f as connectMcpDefinition, g as isMcp, h as defineMcp, i as McpConnection, l as McpStdioOptions, m as connectMcpStdio, n as McpAuthOptions, o as McpDefinitionInput, p as connectMcpServer, r as McpCallToolOptions, s as McpHttpTransport, t as ToolCredentialResolver, u as McpStdioTransport } from "./index-ptRM3z9H.mjs";
5
- import { C as AssetManifest, T as SandboxDefinition, a as RuntimeHooks, c as SkillDefinition, o as RuntimeProvider, s as Sandbox } from "./index-BbMesmXS.mjs";
6
- import { z } from "zod";
7
- import { DatabaseSync } from "node:sqlite";
8
-
9
- //#region ../agent/dist/schemas.d.mts
10
- //#region src/schemas.d.ts
11
- /** Wire-format model reference — resolve with `getModel(provider, id)`. */
12
- declare const ModelRefSchema: z.ZodObject<{
13
- provider: z.ZodString;
14
- id: z.ZodString;
15
- }, z.core.$strip>;
16
- declare const ThinkingLevelSchema: z.ZodEnum<{
17
- off: "off";
18
- minimal: "minimal";
19
- low: "low";
20
- medium: "medium";
21
- high: "high";
22
- xhigh: "xhigh";
23
- }>;
24
- declare const DEFAULT_THINKING_LEVEL: "medium";
25
- /** Serializable subset of {@link AgentConfig} for JSON/env/CLI boundaries. */
26
- declare const AgentCreateInputSchema: z.ZodObject<{
27
- systemPrompt: z.ZodString;
28
- model: z.ZodObject<{
29
- provider: z.ZodString;
30
- id: z.ZodString;
31
- }, z.core.$strip>;
32
- thinkingLevel: z.ZodOptional<z.ZodEnum<{
33
- off: "off";
34
- minimal: "minimal";
35
- low: "low";
36
- medium: "medium";
37
- high: "high";
38
- xhigh: "xhigh";
39
- }>>;
40
- }, z.core.$strip>;
41
- type ModelRef = z.infer<typeof ModelRefSchema>;
42
- type AgentCreateInput = z.infer<typeof AgentCreateInputSchema>;
43
- declare function parseAgentCreateInput(input: unknown): AgentCreateInput;
44
- declare function resolveThinkingLevel(level?: ThinkingLevel): ThinkingLevel; //#endregion
45
- //#endregion
46
- //#region ../memory/dist/index.d.mts
47
- //#region src/config.d.ts
48
- type MemoryConfig = {
49
- enabled: boolean;
50
- dir: string;
51
- memoryFile: string;
52
- userFile: string;
53
- archiveDir: string;
54
- dbFile: string;
55
- sessionsDir: string;
56
- memoryCharLimit: number;
57
- userCharLimit: number;
58
- archiveTocLimit: number;
59
- securityScan: boolean;
60
- };
61
- //#endregion
62
- //#region src/prepare.d.ts
63
- type MemoryHandle = {
64
- config: MemoryConfig;
65
- db: DatabaseSync;
66
- reindexSessions: () => void;
67
- close: () => void;
68
- };
69
- type MemoryOptions = false | Partial<MemoryConfig>;
70
- //#endregion
71
- //#region ../agent/dist/index.d.mts
72
- //#region src/agent.d.ts
73
- type AgentConfig = {
74
- systemPrompt: string;
75
- model: Model<string>;
76
- thinkingLevel?: ThinkingLevel;
77
- messages?: AgentMessage[];
78
- tools?: AgentTool[];
79
- } & Omit<AgentOptions, "initialState">;
80
- type AgentRuntime = Readonly<{
81
- pi: Agent$1;
82
- }>;
83
- type AgentSnapshot = Readonly<{
84
- state: AgentState;
85
- }>;
86
- declare function createAgent(config: AgentConfig): AgentRuntime;
87
- declare function prompt(runtime: AgentRuntime, message: string): Promise<AgentSnapshot>;
88
- declare function snapshot(runtime: AgentRuntime): AgentSnapshot;
89
- declare function messages(snapshot: AgentSnapshot): AgentMessage[];
90
- declare function errorMessage(snapshot: AgentSnapshot): string | undefined; //#endregion
91
- //#region src/tool.d.ts
92
- declare function defineTool<T extends AgentTool>(tool: T): T; //#endregion
93
- //#region src/define/types.d.ts
94
- /** MCP defs vary by credential shape at authoring time. */
95
- type AgentMcpTool = McpDefinition<any>;
96
- /** Author-facing agent input — asset keys resolve from src/skills/ and src/files/. */
97
- type AgentDefinitionAuthorInput = AgentCreateInput & {
98
- tools?: Array<ActionDefinition | AgentTool | AgentMcpTool>;
99
- runtimeHooks?: RuntimeHooks; /** Skill folder names under `src/skills/{key}/`. */
100
- skills?: string[]; /** `true` uses agent `{ key }`; string uses `src/files/{setKey}/`. */
101
- files?: boolean | string; /** Advanced inline or shared sandbox layout. Merged with resolved `files`. */
102
- sandbox?: SandboxDefinition;
103
- runtimeProvider?: RuntimeProvider; /** Persistent memory (default on). Pass `false` to disable. */
104
- memory?: MemoryOptions;
105
- };
106
- /** Input to {@link defineAgent}. */
107
- type AgentDefinitionInput = AgentDefinitionAuthorInput;
108
- /** Normalized agent definition used by the server (defaults applied). */
109
- type AgentDefinition = AgentCreateInput & {
110
- tools?: Array<ActionDefinition | AgentTool | AgentMcpTool>;
111
- runtimeHooks?: RuntimeHooks;
112
- sandbox?: SandboxDefinition;
113
- skills?: SkillDefinition[];
114
- runtimeProvider?: RuntimeProvider;
115
- memory?: MemoryOptions;
116
- };
117
- type PromptInput = {
118
- message: string;
119
- sessionId?: string;
120
- subscriptionId?: string;
121
- context?: CredentialRunContext;
122
- };
123
- /** Server-level overrides when mounting an agent or calling {@link Agent.prompt}. */
124
- type RunAgentPromptOptions = {
125
- workspacesRoot?: string;
126
- /**
127
- * Explicit host root backing `/workspace`.
128
- * When set (typically by a workflow action), the agent's own `sandbox` definition is not materialized.
129
- */
130
- workspaceRoot?: string; /** Overrides {@link AgentDefinition.runtimeProvider} for this call. */
131
- runtimeProvider?: RuntimeProvider;
132
- runtimeHooks?: RuntimeHooks;
133
- credentials?: CredentialRunContext;
134
- oauthAdapter?: OAuthTokenAdapter;
135
- memory?: MemoryOptions; /** Overrides {@link AgentDefinition.thinkingLevel} for this call. */
136
- thinkingLevel?: ThinkingLevel;
137
- tracing?: {
138
- trigger?: "api" | "gateway" | "subagent" | "workflow";
139
- gatewayAttachmentId?: string;
140
- gatewayAttachmentKey?: string;
141
- agentKey?: string;
142
- }; /** When set by {@link withManualAgentTrace}, skips the outer agent_session span. */
143
- skipAgentSessionSpan?: boolean;
144
- invocationRoute?: string;
145
- };
146
- type PromptResponse = {
147
- sessionId: string;
148
- messages: AgentMessage[];
149
- error: string | null;
150
- }; //#endregion
151
- //#region src/define/build-agent-runtime.d.ts
152
- type BuildAgentRuntimeContext = {
153
- agentId: string;
154
- sessionId: string;
155
- messages?: AgentMessage[];
156
- };
157
- /** Pi agent plus sandbox — dispose {@link SandboxedAgentRuntime.sandbox} after each prompt. */
158
- type SandboxedAgentRuntime = AgentRuntime & {
159
- sandbox: Sandbox;
160
- tools: AgentTool[];
161
- mcpConnections: McpConnection[];
162
- workspaceRoot: string;
163
- memory?: MemoryHandle;
164
- takeCredentialError?: () => unknown;
165
- };
166
- /** Sandbox tools + host tools → pi agent from a {@link AgentDefinition}. */
167
- declare function buildAgentRuntime(def: AgentDefinition, ctx: BuildAgentRuntimeContext, runPrompt?: RunAgentPromptOptions): Promise<SandboxedAgentRuntime>; //#endregion
168
- //#region src/define/define-agent.d.ts
169
- type DefineAgentOptions = {
170
- /** Discovery key — resolves agentId from the DB registry after createServer sync. */key?: string; /** Server overrides for sandbox/workspace when prompting. */
171
- runPrompt?: RunAgentPromptOptions; /** Agent module URL (`import.meta.url`) — resolves `src/skills/` and `src/files/` in dev. */
172
- module?: string;
173
- };
174
- type Agent = AgentDefinition & {
175
- /** Discovery and route id for this agent (`POST /agents/{key}`). */key: string; /** Per-request pi agent + sandbox from this definition. */
176
- buildRuntime: (ctx: BuildAgentRuntimeContext, runPrompt?: RunAgentPromptOptions) => Promise<SandboxedAgentRuntime>;
177
- prompt(input: {
178
- message: string;
179
- sessionId?: string;
180
- agentId?: string;
181
- }, runPrompt?: RunAgentPromptOptions): Promise<PromptResponse>;
182
- };
183
- /**
184
- * Define an agent: normalized config plus a pipeline that builds sandbox + pi runtime on demand.
185
- */
186
- declare function defineAgent(input: AgentDefinitionInput, options?: DefineAgentOptions): Agent; //#endregion
187
- //#region src/define/define-subagent-tool.d.ts
188
- declare const SUBAGENT_TOOL: unique symbol;
189
- /** Reserved for parent→child passthrough (credentials, workspace, etc.). Not wired yet. */
190
- type SubagentToolInherit = {
191
- credentials?: boolean;
192
- workspace?: boolean;
193
- };
194
- type SubagentToolMetadata = {
195
- agent: Agent;
196
- inherit?: SubagentToolInherit;
197
- };
198
- type SubagentToolDetails = {
199
- sessionId: string;
200
- error: string | null;
201
- };
202
- type SubagentTool = AgentTool & {
203
- [SUBAGENT_TOOL]: SubagentToolMetadata;
204
- };
205
- type DefineSubagentToolInput = {
206
- agent: Agent;
207
- name: string;
208
- label: string;
209
- description?: string;
210
- parameters: AgentTool["parameters"];
211
- inherit?: SubagentToolInherit; /** Defaults to `params.message`. Override when tool params use a different shape. */
212
- toMessage?: (params: unknown) => string;
213
- };
214
- declare function getSubagentToolMetadata(tool: AgentTool): SubagentToolMetadata | undefined;
215
- declare function defineSubagentTool(input: DefineSubagentToolInput): SubagentTool; //#endregion
216
- //#region src/define/run-prompt.d.ts
217
- declare function runAgentPrompt(agent: Agent, agentId: string, input: {
218
- message: string;
219
- sessionId?: string;
220
- context?: RunAgentPromptOptions["credentials"];
221
- }, options?: RunAgentPromptOptions): Promise<PromptResponse>;
222
- declare class SessionAgentMismatchError extends Error {
223
- constructor(sessionId: string);
224
- } //#endregion
225
- //#region src/define/prepare-session.d.ts
226
- declare function prepareAgentSession(agentId: string, sessionId?: string): Promise<{
227
- sessionId: string;
228
- }>; //#endregion
229
- //#region src/define/normalize-definition.d.ts
230
- /** Normalizes optional agent fields for the server runtime. */
231
- declare function normalizeAgentDefinition(input: AgentDefinitionInput, options?: {
232
- agentKey?: string;
233
- appRoot?: string;
234
- module?: string;
235
- }): AgentDefinition; //#endregion
236
- //#region src/define/resolve-agent-workspace-root.d.ts
237
- /**
238
- * Resolve the host directory backing `/workspace` for an agent prompt.
239
- *
240
- * Precedence:
241
- * 1. Explicit `workspaceRoot` override (workflow handoff) — skips agent sandbox materialization.
242
- * 2. Agent `sandbox` definition — materialize to `{workspacesRoot}/{agentId}/`.
243
- * 3. Default agent dir — `{workspacesRoot}/{agentId}/`.
244
- *
245
- * Agent skills always materialize into the resolved workspace when configured.
246
- */
247
- declare function resolveAgentWorkspaceRoot(agentId: string, options: {
248
- workspacesRoot?: string;
249
- workspaceRoot?: string;
250
- sandbox?: SandboxDefinition;
251
- skills?: SkillDefinition[];
252
- }): Promise<string>; //#endregion
253
- //#region src/define/resolve-agent-assets.d.ts
254
- type AgentAssetInput = {
255
- skillKeys?: string[];
256
- files?: boolean | string;
257
- agentKey?: string;
258
- appRoot?: string;
259
- };
260
- type ResolvedAgentAssets = {
261
- skills?: SkillDefinition[];
262
- sandbox?: SandboxDefinition;
263
- };
264
- declare function loadAssetManifest(appRoot: string): AssetManifest;
265
- /** Resolve author-facing skill/file keys into packed sandbox + skill definitions. */
266
- declare function resolveAgentAssets(input: AgentAssetInput): ResolvedAgentAssets; //#endregion
267
- //#region src/define/resolve-tools.d.ts
268
- type ResolvedAgentTools = {
269
- tools: AgentTool[];
270
- mcpConnections: McpConnection[];
271
- };
272
- declare function resolveAgentTools(tools: Array<ActionDefinition | AgentTool | AgentMcpTool>, resolver: ToolCredentialResolver): Promise<ResolvedAgentTools>; //#endregion
273
- //#endregion
274
- export { type Agent, type AgentAssetInput, type AgentConfig, type AgentCreateInput, AgentCreateInputSchema, type AgentDefinition, type AgentDefinitionInput, type AgentRuntime, type AgentSnapshot, type BuildAgentRuntimeContext, DEFAULT_THINKING_LEVEL, type DefineAgentOptions, type DefineSubagentToolInput, type McpAuthOptions, type McpCallToolOptions, type McpConnection, type McpDefinition, type McpDefinitionInput, type McpHttpTransport, type McpServerOptions, type McpStdioOptions, type McpStdioTransport, type McpTransport, type ModelRef, ModelRefSchema, type PromptInput, type PromptResponse, type ResolvedAgentAssets, type RunAgentPromptOptions, SUBAGENT_TOOL, type SandboxedAgentRuntime, SessionAgentMismatchError, type SubagentTool, type SubagentToolDetails, type SubagentToolInherit, type SubagentToolMetadata, type ThinkingLevel, ThinkingLevelSchema, type ToolCredentialResolver, buildAgentRuntime, connectMcpDefinition, connectMcpServer, connectMcpStdio, createAgent, defineAgent, defineMcp, defineSubagentTool, defineTool, errorMessage, getModel, getSubagentToolMetadata, isMcp, loadAssetManifest, messages, normalizeAgentDefinition, parseAgentCreateInput, prepareAgentSession, prompt, resolveAgentAssets, resolveAgentTools, resolveAgentWorkspaceRoot, resolveThinkingLevel, runAgentPrompt, snapshot };
275
- //# sourceMappingURL=agent.d.mts.map
4
+ export { type Agent, type AgentAssetInput, type AgentConfig, type AgentCreateInput, AgentCreateInputSchema, type AgentDefinition, type AgentDefinitionInput, type AgentRuntime, type AgentSnapshot, type BuildAgentRuntimeContext, DEFAULT_THINKING_LEVEL, type DefineAgentOptions, type DefineSubagentToolInput, type McpAuthOptions, type McpCallToolOptions, type McpConnection, type McpDefinition, type McpDefinitionInput, type McpHttpTransport, type McpServerOptions, type McpStdioOptions, type McpStdioTransport, type McpTransport, type ModelRef, ModelRefSchema, type PromptInput, type PromptResponse, type ResolvedAgentAssets, type RunAgentPromptOptions, SUBAGENT_TOOL, type SandboxedAgentRuntime, SessionAgentMismatchError, type SubagentTool, type SubagentToolDetails, type SubagentToolInherit, type SubagentToolMetadata, type ThinkingLevel, ThinkingLevelSchema, type ToolCredentialResolver, buildAgentRuntime, connectMcpDefinition, connectMcpServer, connectMcpStdio, createAgent, defineAgent, defineMcp, defineSubagentTool, defineTool, errorMessage, getModel, getSubagentToolMetadata, isMcp, loadAssetManifest, messages, normalizeAgentDefinition, parseAgentCreateInput, prepareAgentSession, prompt, resolveAgentAssets, resolveAgentTools, resolveAgentWorkspaceRoot, resolveThinkingLevel, runAgentPrompt, snapshot };
package/dist/agent.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import { $ as Options, $t as IsMap, An as IsSymbol$1, At as Unreachable, Bn as __require, Bt as IsRef$1, Cn as IsMinLength$2, Ct as IsInteger$2, Dn as IsObject$1, Dt as IsCodec, En as IsNumber$1, Et as IsBigInt$2, Fn as Symbols, Ft as IsUnion, G as ensureWorkspaceDir, Gt as IsArray$2, Ht as IsFunction$2, In as guard_exports, It as Union, Jt as IsOptional, K as materializeSandbox, Kt as Base, Ln as __commonJSMin, Lt as IsObject$2, Mn as IsUnsafePropertyKey, Mt as IsEnum$1, Nn as IsValueLike, Nt as IsCyclic, On as IsObjectNotArray$1, Ot as Hash, Pn as Keys$1, Pt as Unknown, Q as Instantiate, Qt as Get$3, Rt as _Object_, Sn as IsMaxLength$2, St as IsIterator$2, Tn as IsNull$1, Tt as IsBoolean$2, Ut as IsConstructor$2, Vt as Ref$1, W as defineSandbox, Wt as IsAsyncIterator$2, X as resolveSandboxRoot, Xt as IsPromise, Y as resolveAppRootFromModule, Yt as Optional, Z as Evaluate$1, Zt as IsSchema$1, _n as IsGreaterThan$1, _t as IsLiteralBigInt, a as createSandbox, an as EveryAll, at as RecordPattern, bn as IsLessEqualThan$1, bt as IsLiteralString, c as defineTool$1, cn as IsAsyncIterator$1, ct as EnumToUnion, d as resolveRunProvider, dn as IsClassInstance, dt as String$1, en as IsSet, et as Compare, fn as IsConstructor$1, ft as IsSymbol$2, gn as IsGreaterEqualThan$1, gt as IsLiteral, hn as IsFunction$1, ht as IsNull$2, i as createJustBashProvider, in as Every$1, it as IsRecord, jn as IsUndefined$1, jt as IsIntersect, kn as IsString$1, kt as hash_exports, ln as IsBigInt$1, lt as TemplateLiteralDecode, mn as IsEqual$1, mt as Number$1, nn as Entries$2, nt as IsVoid, o as defaultWorkspacesRoot, on as HasPropertyKey$1, ot as RecordValue, pn as IsDeepEqual$1, pt as IsNumber$2, q as packAssetDirs, qt as IsBase, r as createInvokeToolBridge, rn as EntriesRegExp, rt as IsUndefined$2, s as defineSkill, sn as IsArray$1, st as IsTuple, tn as IsTypeArray, tt as IsTemplateLiteral, u as materializeSkills, un as IsBoolean$1, ut as IsString$2, vn as IsInteger$1, vt as IsLiteralBoolean, wn as IsMultipleOf$1, wt as Boolean$1, xn as IsLessThan$1, xt as Literal, yn as IsIterator$1, yt as IsLiteralNumber, zn as __exportAll, zt as IsNever } from "./dist-f_JGyGWx.mjs";
2
- import { s as isAction, u as resolveActionTool } from "./dist-B1fqDXYa.mjs";
2
+ import { s as isAction, u as resolveActionTool } from "./dist-CAGgGvND.mjs";
3
3
  import "./env-api-keys-BSMeSmLq.mjs";
4
4
  import { i as getModel, t as AssistantMessageEventStream } from "./event-stream-C7YBbzsc.mjs";
5
5
  import "./json-parse-BhvKZ346.mjs";
6
- import { S as isMcp, _ as touchSession, a as buildCredentialRunContext, b as connectMcpStdio, c as isCredentialError, d as MESSAGE_EVENT_TYPE$1, f as appendEvent, g as listMessageEvents, h as getSession, i as withSpan, l as resolveActionCredentials, m as getAgentByRoute, n as getTraceContext, o as captureCredentialToolErrors, p as createSession, s as createCredentialResolver, t as captureConsole, u as resolveMcpTools, v as connectMcpDefinition, x as defineMcp, y as connectMcpServer } from "./dist-BML_gJSh.mjs";
6
+ import { C as isMcp, S as defineMcp, a as resolveActionCredentials, b as connectMcpServer, c as appendEvent, d as getSession, f as listMessageEvents, g as getTraceContext, h as captureConsole, i as isCredentialError, l as createSession, m as touchSession, n as captureCredentialToolErrors, o as resolveMcpTools, p as resolveRunSourceFromTraceContext, r as createCredentialResolver, s as MESSAGE_EVENT_TYPE$1, t as buildCredentialRunContext, u as getAgentByRoute, v as withSpan, x as connectMcpStdio, y as connectMcpDefinition } from "./dist-DzfOPx7X.mjs";
7
7
  import { createRequire } from "node:module";
8
8
  import { z } from "zod";
9
9
  import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
@@ -927,7 +927,7 @@ function loadGoogleVertexProviderModule() {
927
927
  return googleVertexProviderModulePromise;
928
928
  }
929
929
  function loadMistralProviderModule() {
930
- mistralProviderModulePromise ||= import("./mistral-CI7CQc_C.mjs").then((module) => {
930
+ mistralProviderModulePromise ||= import("./mistral-CGHbHFQG.mjs").then((module) => {
931
931
  const provider = module;
932
932
  return {
933
933
  stream: provider.streamMistral,
@@ -13931,11 +13931,11 @@ async function persistAgentEvent(sessionId, event, memoryConfig) {
13931
13931
  async function prepareAgentSession(agentId, sessionId) {
13932
13932
  if (sessionId) {
13933
13933
  const session = await getSession(sessionId);
13934
- if (!session) await createSession(agentId, sessionId);
13934
+ if (!session) await createSession(agentId, sessionId, await resolveRunSourceFromTraceContext());
13935
13935
  else if (session.agentId !== agentId) throw new SessionAgentMismatchError(sessionId);
13936
13936
  return { sessionId };
13937
13937
  }
13938
- return { sessionId: (await createSession(agentId)).id };
13938
+ return { sessionId: (await createSession(agentId, void 0, await resolveRunSourceFromTraceContext())).id };
13939
13939
  }
13940
13940
  async function runAgentPrompt(agent, agentId, input, options = {}) {
13941
13941
  const { sessionId } = await prepareAgentSession(agentId, input.sessionId);