@ironflow/node 0.20.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/agent.d.ts +60 -0
- package/dist/agent/agent.d.ts.map +1 -0
- package/dist/agent/agent.js +133 -0
- package/dist/agent/agent.js.map +1 -0
- package/dist/agent/approve.d.ts +23 -0
- package/dist/agent/approve.d.ts.map +1 -0
- package/dist/agent/approve.js +42 -0
- package/dist/agent/approve.js.map +1 -0
- package/dist/agent/dispatch.d.ts +63 -0
- package/dist/agent/dispatch.d.ts.map +1 -0
- package/dist/agent/dispatch.js +130 -0
- package/dist/agent/dispatch.js.map +1 -0
- package/dist/agent/errors.d.ts +90 -0
- package/dist/agent/errors.d.ts.map +1 -0
- package/dist/agent/errors.js +136 -0
- package/dist/agent/errors.js.map +1 -0
- package/dist/agent/index.d.ts +35 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +32 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/internal-registry.d.ts +27 -0
- package/dist/agent/internal-registry.d.ts.map +1 -0
- package/dist/agent/internal-registry.js +36 -0
- package/dist/agent/internal-registry.js.map +1 -0
- package/dist/agent/internal.d.ts +24 -0
- package/dist/agent/internal.d.ts.map +1 -0
- package/dist/agent/internal.js +29 -0
- package/dist/agent/internal.js.map +1 -0
- package/dist/agent/llm.d.ts +39 -0
- package/dist/agent/llm.d.ts.map +1 -0
- package/dist/agent/llm.js +59 -0
- package/dist/agent/llm.js.map +1 -0
- package/dist/agent/mcp.d.ts +51 -0
- package/dist/agent/mcp.d.ts.map +1 -0
- package/dist/agent/mcp.js +155 -0
- package/dist/agent/mcp.js.map +1 -0
- package/dist/agent/memory.d.ts +74 -0
- package/dist/agent/memory.d.ts.map +1 -0
- package/dist/agent/memory.js +130 -0
- package/dist/agent/memory.js.map +1 -0
- package/dist/agent/spawn.d.ts +20 -0
- package/dist/agent/spawn.d.ts.map +1 -0
- package/dist/agent/spawn.js +29 -0
- package/dist/agent/spawn.js.map +1 -0
- package/dist/agent/tool.d.ts +39 -0
- package/dist/agent/tool.d.ts.map +1 -0
- package/dist/agent/tool.js +103 -0
- package/dist/agent/tool.js.map +1 -0
- package/dist/agent/types.d.ts +363 -0
- package/dist/agent/types.d.ts.map +1 -0
- package/dist/agent/types.js +9 -0
- package/dist/agent/types.js.map +1 -0
- package/dist/client.d.ts +942 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +1557 -0
- package/dist/client.js.map +1 -0
- package/dist/command-dedup.d.ts +61 -0
- package/dist/command-dedup.d.ts.map +1 -0
- package/dist/command-dedup.js +129 -0
- package/dist/command-dedup.js.map +1 -0
- package/dist/config-client.d.ts +58 -0
- package/dist/config-client.d.ts.map +1 -0
- package/dist/config-client.js +171 -0
- package/dist/config-client.js.map +1 -0
- package/dist/function.d.ts +53 -0
- package/dist/function.d.ts.map +1 -0
- package/dist/function.js +72 -0
- package/dist/function.js.map +1 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +70 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/assert-defined.d.ts +10 -0
- package/dist/internal/assert-defined.d.ts.map +1 -0
- package/dist/internal/assert-defined.js +15 -0
- package/dist/internal/assert-defined.js.map +1 -0
- package/dist/internal/context.d.ts +142 -0
- package/dist/internal/context.d.ts.map +1 -0
- package/dist/internal/context.js +306 -0
- package/dist/internal/context.js.map +1 -0
- package/dist/internal/errors.d.ts +66 -0
- package/dist/internal/errors.d.ts.map +1 -0
- package/dist/internal/errors.js +29 -0
- package/dist/internal/errors.js.map +1 -0
- package/dist/internal/run-context.d.ts +10 -0
- package/dist/internal/run-context.d.ts.map +1 -0
- package/dist/internal/run-context.js +23 -0
- package/dist/internal/run-context.js.map +1 -0
- package/dist/kv.d.ts +86 -0
- package/dist/kv.d.ts.map +1 -0
- package/dist/kv.js +261 -0
- package/dist/kv.js.map +1 -0
- package/dist/projection-runner.d.ts +83 -0
- package/dist/projection-runner.d.ts.map +1 -0
- package/dist/projection-runner.js +498 -0
- package/dist/projection-runner.js.map +1 -0
- package/dist/projection.d.ts +36 -0
- package/dist/projection.d.ts.map +1 -0
- package/dist/projection.js +55 -0
- package/dist/projection.js.map +1 -0
- package/dist/secrets.d.ts +6 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +19 -0
- package/dist/secrets.js.map +1 -0
- package/dist/serve.d.ts +71 -0
- package/dist/serve.d.ts.map +1 -0
- package/dist/serve.js +460 -0
- package/dist/serve.js.map +1 -0
- package/dist/step.d.ts +18 -0
- package/dist/step.d.ts.map +1 -0
- package/dist/step.js +581 -0
- package/dist/step.js.map +1 -0
- package/dist/subscribe.d.ts +164 -0
- package/dist/subscribe.d.ts.map +1 -0
- package/dist/subscribe.js +487 -0
- package/dist/subscribe.js.map +1 -0
- package/dist/test/index.d.ts +22 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +112 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/test-step.d.ts +21 -0
- package/dist/test/test-step.d.ts.map +1 -0
- package/dist/test/test-step.js +83 -0
- package/dist/test/test-step.js.map +1 -0
- package/dist/types.d.ts +108 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +4 -0
- package/dist/version.js.map +1 -0
- package/dist/webhook.d.ts +22 -0
- package/dist/webhook.d.ts.map +1 -0
- package/dist/webhook.js +23 -0
- package/dist/webhook.js.map +1 -0
- package/dist/worker-streaming.d.ts +17 -0
- package/dist/worker-streaming.d.ts.map +1 -0
- package/dist/worker-streaming.js +510 -0
- package/dist/worker-streaming.js.map +1 -0
- package/dist/worker.d.ts +28 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +559 -0
- package/dist/worker.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent module error classes.
|
|
3
|
+
*
|
|
4
|
+
* All extend IronflowError. Codes are stable for programmatic handling.
|
|
5
|
+
*/
|
|
6
|
+
import { IronflowError } from "@ironflow/core";
|
|
7
|
+
/**
|
|
8
|
+
* Thrown when an agent exceeds its configured turn budget.
|
|
9
|
+
*
|
|
10
|
+
* Default budget is 20 turns. Configurable via AgentConfig.maxTurns.
|
|
11
|
+
*/
|
|
12
|
+
export class MaxTurnsExceededError extends IronflowError {
|
|
13
|
+
constructor(maxTurns, options) {
|
|
14
|
+
super(`agent exceeded maxTurns (${maxTurns})`, {
|
|
15
|
+
code: "AGENT_MAX_TURNS_EXCEEDED",
|
|
16
|
+
retryable: false,
|
|
17
|
+
details: { maxTurns },
|
|
18
|
+
cause: options?.cause,
|
|
19
|
+
});
|
|
20
|
+
this.name = "MaxTurnsExceededError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Base class for classified LLM errors emitted by llm().
|
|
25
|
+
*/
|
|
26
|
+
export class LLMError extends IronflowError {
|
|
27
|
+
constructor(message, options) {
|
|
28
|
+
super(message, options);
|
|
29
|
+
this.name = "LLMError";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Provider refused the request (safety, policy, etc.).
|
|
34
|
+
*/
|
|
35
|
+
export class LLMRefusalError extends LLMError {
|
|
36
|
+
constructor(message, options) {
|
|
37
|
+
super(message, {
|
|
38
|
+
code: "LLM_REFUSAL",
|
|
39
|
+
retryable: false,
|
|
40
|
+
details: options?.details,
|
|
41
|
+
cause: options?.cause,
|
|
42
|
+
});
|
|
43
|
+
this.name = "LLMRefusalError";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Provider returned content that failed JSON parsing when JSON was required.
|
|
48
|
+
*/
|
|
49
|
+
export class LLMInvalidJSONError extends LLMError {
|
|
50
|
+
constructor(message, options) {
|
|
51
|
+
super(message, {
|
|
52
|
+
code: "LLM_INVALID_JSON",
|
|
53
|
+
retryable: true,
|
|
54
|
+
details: options?.details,
|
|
55
|
+
cause: options?.cause,
|
|
56
|
+
});
|
|
57
|
+
this.name = "LLMInvalidJSONError";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Provider truncated the response by hitting max_tokens.
|
|
62
|
+
*/
|
|
63
|
+
export class LLMMaxTokensError extends LLMError {
|
|
64
|
+
constructor(message, options) {
|
|
65
|
+
super(message, {
|
|
66
|
+
code: "LLM_MAX_TOKENS",
|
|
67
|
+
retryable: false,
|
|
68
|
+
details: options?.details,
|
|
69
|
+
cause: options?.cause,
|
|
70
|
+
});
|
|
71
|
+
this.name = "LLMMaxTokensError";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Thrown when tool() input fails Zod validation.
|
|
76
|
+
*
|
|
77
|
+
* Distinct from generic ValidationError so callers can differentiate
|
|
78
|
+
* agent-tool input failures from event-payload schema failures.
|
|
79
|
+
*/
|
|
80
|
+
export class ToolValidationError extends IronflowError {
|
|
81
|
+
constructor(toolName, issues, options) {
|
|
82
|
+
super(`tool "${toolName}" input validation failed`, {
|
|
83
|
+
code: "AGENT_TOOL_VALIDATION",
|
|
84
|
+
retryable: false,
|
|
85
|
+
details: { toolName, issues },
|
|
86
|
+
cause: options?.cause,
|
|
87
|
+
});
|
|
88
|
+
this.name = "ToolValidationError";
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Thrown when AgentConfig.tools contains two or more definitions sharing
|
|
93
|
+
* the same name. Silent overwrite would let LLM-driven dispatch route to
|
|
94
|
+
* an unintended handler — so we fail loudly at agent construction.
|
|
95
|
+
*/
|
|
96
|
+
export class DuplicateToolError extends IronflowError {
|
|
97
|
+
constructor(toolName) {
|
|
98
|
+
super(`duplicate tool "${toolName}" registered on AgentConfig.tools`, {
|
|
99
|
+
code: "AGENT_DUPLICATE_TOOL",
|
|
100
|
+
retryable: false,
|
|
101
|
+
details: { toolName },
|
|
102
|
+
});
|
|
103
|
+
this.name = "DuplicateToolError";
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Thrown when ctx.tool(name, args) is called with a name that isn't
|
|
108
|
+
* registered on AgentConfig.tools.
|
|
109
|
+
*/
|
|
110
|
+
export class ToolNotFoundError extends IronflowError {
|
|
111
|
+
constructor(toolName) {
|
|
112
|
+
super(`tool "${toolName}" not registered on AgentConfig.tools — register it or call by reference`, {
|
|
113
|
+
code: "AGENT_TOOL_NOT_FOUND",
|
|
114
|
+
retryable: false,
|
|
115
|
+
details: { toolName },
|
|
116
|
+
});
|
|
117
|
+
this.name = "ToolNotFoundError";
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Thrown when memory.entityStream() is called without a projection.
|
|
122
|
+
*
|
|
123
|
+
* Per architecture decision: raw event replay is not exposed through
|
|
124
|
+
* the agent memory API. Consumers must define a projection.
|
|
125
|
+
*/
|
|
126
|
+
export class MemoryProjectionRequiredError extends IronflowError {
|
|
127
|
+
constructor(streamId) {
|
|
128
|
+
super(`memory.entityStream("${streamId}") requires a projection — raw replay is not exposed via the agent API`, {
|
|
129
|
+
code: "AGENT_MEMORY_PROJECTION_REQUIRED",
|
|
130
|
+
retryable: false,
|
|
131
|
+
details: { streamId },
|
|
132
|
+
});
|
|
133
|
+
this.name = "MemoryProjectionRequiredError";
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/agent/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,OAAO,qBAAsB,SAAQ,aAAa;IACtD,Y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kCAAkC;YACxC,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,EAAE,QAAQ,EAAE;SACtB,CACF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;IAC9C,CAAC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ironflow/node/agent — durable agent primitives.
|
|
3
|
+
*
|
|
4
|
+
* The agent module is sugar over the existing step client. Each helper
|
|
5
|
+
* (tool, llm, approve, memory, spawn) records durable steps under the
|
|
6
|
+
* hood, so agents inherit Ironflow's crash-resume, replay, audit, and
|
|
7
|
+
* scoped-injection semantics with no new server primitives.
|
|
8
|
+
*
|
|
9
|
+
* Anti-scope (locked in CEO + eng review):
|
|
10
|
+
* - No LLM provider router. Callers bring their own provider SDK and
|
|
11
|
+
* pass the provider call into llm() — the wrapper memoizes the result.
|
|
12
|
+
* - No prompt templating. Reasoning frameworks (LangGraph, Claude SDK,
|
|
13
|
+
* CrewAI) own that surface. Ironflow hosts them, not replaces them.
|
|
14
|
+
* - No graph execution. agent() runs a plain async handler.
|
|
15
|
+
*
|
|
16
|
+
* Public API:
|
|
17
|
+
*
|
|
18
|
+
* import { agent, defineTool, exposeMcp } from "@ironflow/node/agent";
|
|
19
|
+
*
|
|
20
|
+
* // tool / llm / approve / memory / spawn are ctx-injected helpers,
|
|
21
|
+
* // destructured inside the agent handler:
|
|
22
|
+
* agent({ id: "..." }, async ({ step, tool, llm, approve, memory, spawn }) => {
|
|
23
|
+
* // ...
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* See docs/explanation/comparison-agents.md for the layering model.
|
|
27
|
+
*/
|
|
28
|
+
export type { AgentConfig, AgentContext, AgentHandler, ApproveFn, ApproveOptions, ApproveResult, ExposeMcpConfig, IronflowAgent, LLMClient, LLMCompleteRequest, LLMCompleteResult, McpToolDef, MemoryAppendOptions, MemoryClient, MemoryGetOptions, MemoryConfig, SpawnFn, SpawnOptions, SpawnResult, AnyToolDefinition, ToolDefinition, ToolFn, ToolIdempotency, } from "./types.js";
|
|
29
|
+
export { DuplicateToolError, LLMError, LLMInvalidJSONError, LLMMaxTokensError, LLMRefusalError, MaxTurnsExceededError, MemoryProjectionRequiredError, ToolNotFoundError, ToolValidationError, } from "./errors.js";
|
|
30
|
+
export { agent } from "./agent.js";
|
|
31
|
+
export { defineTool } from "./tool.js";
|
|
32
|
+
export { exposeMcp } from "./mcp.js";
|
|
33
|
+
export type { ExposeMcpHandle } from "./mcp.js";
|
|
34
|
+
export type { MemoryBackend } from "./memory.js";
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,YAAY,EACV,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,cAAc,EACd,aAAa,EACb,eAAe,EACf,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,MAAM,EACN,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,6BAA6B,EAC7B,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ironflow/node/agent — durable agent primitives.
|
|
3
|
+
*
|
|
4
|
+
* The agent module is sugar over the existing step client. Each helper
|
|
5
|
+
* (tool, llm, approve, memory, spawn) records durable steps under the
|
|
6
|
+
* hood, so agents inherit Ironflow's crash-resume, replay, audit, and
|
|
7
|
+
* scoped-injection semantics with no new server primitives.
|
|
8
|
+
*
|
|
9
|
+
* Anti-scope (locked in CEO + eng review):
|
|
10
|
+
* - No LLM provider router. Callers bring their own provider SDK and
|
|
11
|
+
* pass the provider call into llm() — the wrapper memoizes the result.
|
|
12
|
+
* - No prompt templating. Reasoning frameworks (LangGraph, Claude SDK,
|
|
13
|
+
* CrewAI) own that surface. Ironflow hosts them, not replaces them.
|
|
14
|
+
* - No graph execution. agent() runs a plain async handler.
|
|
15
|
+
*
|
|
16
|
+
* Public API:
|
|
17
|
+
*
|
|
18
|
+
* import { agent, defineTool, exposeMcp } from "@ironflow/node/agent";
|
|
19
|
+
*
|
|
20
|
+
* // tool / llm / approve / memory / spawn are ctx-injected helpers,
|
|
21
|
+
* // destructured inside the agent handler:
|
|
22
|
+
* agent({ id: "..." }, async ({ step, tool, llm, approve, memory, spawn }) => {
|
|
23
|
+
* // ...
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* See docs/explanation/comparison-agents.md for the layering model.
|
|
27
|
+
*/
|
|
28
|
+
export { DuplicateToolError, LLMError, LLMInvalidJSONError, LLMMaxTokensError, LLMRefusalError, MaxTurnsExceededError, MemoryProjectionRequiredError, ToolNotFoundError, ToolValidationError, } from "./errors.js";
|
|
29
|
+
export { agent } from "./agent.js";
|
|
30
|
+
export { defineTool } from "./tool.js";
|
|
31
|
+
export { exposeMcp } from "./mcp.js";
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AA4BH,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,6BAA6B,EAC7B,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-local registry that links exposeMcp() to serve()'s dispatch
|
|
3
|
+
* handler. Keyed by qualified name (`{agentName}.{toolName}`).
|
|
4
|
+
*
|
|
5
|
+
* The Ironflow server holds the canonical registry (NATS KV in cluster
|
|
6
|
+
* mode, in-memory in single-node). This map is the SDK's local mirror —
|
|
7
|
+
* we need the McpToolDef closure (handler + Zod schemas) and the HMAC
|
|
8
|
+
* secret to validate inbound dispatches.
|
|
9
|
+
*
|
|
10
|
+
* Single instance per Node.js process. Re-registering the same agent
|
|
11
|
+
* name overwrites the prior entries; unregister removes them. HMR may
|
|
12
|
+
* leave stale entries until the next exposeMcp() call rotates them —
|
|
13
|
+
* acceptable for dev, documented in the README.
|
|
14
|
+
*/
|
|
15
|
+
import type { AnyMcpToolDef } from "./types.js";
|
|
16
|
+
export interface RegisteredTool {
|
|
17
|
+
agentName: string;
|
|
18
|
+
qualifiedName: string;
|
|
19
|
+
hmacSecret: string;
|
|
20
|
+
def: AnyMcpToolDef;
|
|
21
|
+
}
|
|
22
|
+
export declare function registerLocal(entry: RegisteredTool): void;
|
|
23
|
+
export declare function unregisterLocal(agentName: string): string[];
|
|
24
|
+
export declare function lookupLocal(qualifiedName: string): RegisteredTool | undefined;
|
|
25
|
+
/** Test-only — drop all entries. */
|
|
26
|
+
export declare function clearLocalForTests(): void;
|
|
27
|
+
//# sourceMappingURL=internal-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-registry.d.ts","sourceRoot":"","sources":["../../src/agent/internal-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,aAAa,CAAC;CACpB;AAID,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,CAEzD;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,CAS3D;AAED,wBAAgB,WAAW,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAE7E;AAED,oCAAoC;AACpC,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process-local registry that links exposeMcp() to serve()'s dispatch
|
|
3
|
+
* handler. Keyed by qualified name (`{agentName}.{toolName}`).
|
|
4
|
+
*
|
|
5
|
+
* The Ironflow server holds the canonical registry (NATS KV in cluster
|
|
6
|
+
* mode, in-memory in single-node). This map is the SDK's local mirror —
|
|
7
|
+
* we need the McpToolDef closure (handler + Zod schemas) and the HMAC
|
|
8
|
+
* secret to validate inbound dispatches.
|
|
9
|
+
*
|
|
10
|
+
* Single instance per Node.js process. Re-registering the same agent
|
|
11
|
+
* name overwrites the prior entries; unregister removes them. HMR may
|
|
12
|
+
* leave stale entries until the next exposeMcp() call rotates them —
|
|
13
|
+
* acceptable for dev, documented in the README.
|
|
14
|
+
*/
|
|
15
|
+
const registry = new Map();
|
|
16
|
+
export function registerLocal(entry) {
|
|
17
|
+
registry.set(entry.qualifiedName, entry);
|
|
18
|
+
}
|
|
19
|
+
export function unregisterLocal(agentName) {
|
|
20
|
+
const removed = [];
|
|
21
|
+
for (const [qualifiedName, entry] of registry) {
|
|
22
|
+
if (entry.agentName === agentName) {
|
|
23
|
+
registry.delete(qualifiedName);
|
|
24
|
+
removed.push(qualifiedName);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return removed;
|
|
28
|
+
}
|
|
29
|
+
export function lookupLocal(qualifiedName) {
|
|
30
|
+
return registry.get(qualifiedName);
|
|
31
|
+
}
|
|
32
|
+
/** Test-only — drop all entries. */
|
|
33
|
+
export function clearLocalForTests() {
|
|
34
|
+
registry.clear();
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=internal-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal-registry.js","sourceRoot":"","sources":["../../src/agent/internal-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAWH,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;AAEnD,MAAM,UAAU,aAAa,CAAC,KAAqB;IACjD,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,KAAK,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,IAAI,QAAQ,EAAE,CAAC;QAC9C,IAAI,KAAK,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YAClC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;YAC/B,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,aAAqB;IAC/C,OAAO,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AACrC,CAAC;AAED,oCAAoC;AACpC,MAAM,UAAU,kBAAkB;IAChC,QAAQ,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal utilities shared by agent module wrappers.
|
|
3
|
+
*
|
|
4
|
+
* Not part of the public API surface — `index.ts` does not re-export.
|
|
5
|
+
*/
|
|
6
|
+
import type { Duration } from "@ironflow/core";
|
|
7
|
+
/**
|
|
8
|
+
* Normalize a Duration (string | number) into the ms-suffixed string form
|
|
9
|
+
* that step.run options.timeout expects.
|
|
10
|
+
*
|
|
11
|
+
* normalizeDuration("30s") → "30s"
|
|
12
|
+
* normalizeDuration(5000) → "5000ms"
|
|
13
|
+
* normalizeDuration(undefined) → undefined
|
|
14
|
+
*/
|
|
15
|
+
export declare function normalizeDuration(value: Duration | undefined): string | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Escape a value for safe interpolation into a CEL-style match expression
|
|
18
|
+
* (`data.field == "<value>"`). Replaces `\` and `"` with escaped forms.
|
|
19
|
+
*
|
|
20
|
+
* Internal IDs are unlikely to contain quotes, but defending against it
|
|
21
|
+
* prevents broken filters if upstream ever loosens the format.
|
|
22
|
+
*/
|
|
23
|
+
export declare function escapeMatchValue(value: string): string;
|
|
24
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/agent/internal.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAGjF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEtD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal utilities shared by agent module wrappers.
|
|
3
|
+
*
|
|
4
|
+
* Not part of the public API surface — `index.ts` does not re-export.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Normalize a Duration (string | number) into the ms-suffixed string form
|
|
8
|
+
* that step.run options.timeout expects.
|
|
9
|
+
*
|
|
10
|
+
* normalizeDuration("30s") → "30s"
|
|
11
|
+
* normalizeDuration(5000) → "5000ms"
|
|
12
|
+
* normalizeDuration(undefined) → undefined
|
|
13
|
+
*/
|
|
14
|
+
export function normalizeDuration(value) {
|
|
15
|
+
if (value === undefined)
|
|
16
|
+
return undefined;
|
|
17
|
+
return typeof value === "number" ? `${value}ms` : value;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Escape a value for safe interpolation into a CEL-style match expression
|
|
21
|
+
* (`data.field == "<value>"`). Replaces `\` and `"` with escaped forms.
|
|
22
|
+
*
|
|
23
|
+
* Internal IDs are unlikely to contain quotes, but defending against it
|
|
24
|
+
* prevents broken filters if upstream ever loosens the format.
|
|
25
|
+
*/
|
|
26
|
+
export function escapeMatchValue(value) {
|
|
27
|
+
return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/agent/internal.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAA2B;IAC3D,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AAC1D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* llm() — memoized completion sugar with classified error surface.
|
|
3
|
+
*
|
|
4
|
+
* The wrapper does not own a provider router. Callers pass a closure
|
|
5
|
+
* (request.call) that talks to their provider of choice and returns a
|
|
6
|
+
* normalized LLMCompleteResult. The wrapper:
|
|
7
|
+
*
|
|
8
|
+
* 1. Increments the agent turn counter and gates against maxTurns.
|
|
9
|
+
* 2. Wraps the closure in step.run so the assistant response is
|
|
10
|
+
* memoized for crash-resume.
|
|
11
|
+
* 3. Inspects result.finishReason to raise classified errors:
|
|
12
|
+
* "refusal" → LLMRefusalError
|
|
13
|
+
* "max_tokens"/"length" → LLMMaxTokensError
|
|
14
|
+
* JSON-parse failures must be raised by the caller, by detecting
|
|
15
|
+
* invalid JSON in their closure and throwing LLMInvalidJSONError.
|
|
16
|
+
*
|
|
17
|
+
* Anti-scope: provider routing, prompt templating, and streaming all
|
|
18
|
+
* stay out of this module. See module README.
|
|
19
|
+
*/
|
|
20
|
+
import type { StepClient } from "@ironflow/core";
|
|
21
|
+
import type { LLMClient } from "./types.js";
|
|
22
|
+
/**
|
|
23
|
+
* Turn counter shared between llm() invocations and AgentContext.turn.
|
|
24
|
+
*
|
|
25
|
+
* Plain mutable object so the AgentContext getter can read the live value
|
|
26
|
+
* without callers needing a reactive abstraction.
|
|
27
|
+
*/
|
|
28
|
+
export interface TurnCounter {
|
|
29
|
+
value: number;
|
|
30
|
+
}
|
|
31
|
+
/** Construct a fresh turn counter. */
|
|
32
|
+
export declare function createTurnCounter(): TurnCounter;
|
|
33
|
+
/**
|
|
34
|
+
* Build an LLMClient bound to the given step + counter.
|
|
35
|
+
*
|
|
36
|
+
* Exported for use by agent.ts; not part of the public API surface.
|
|
37
|
+
*/
|
|
38
|
+
export declare function makeLlm(step: StepClient, counter: TurnCounter, maxTurns: number): LLMClient;
|
|
39
|
+
//# sourceMappingURL=llm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/agent/llm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAMjD,OAAO,KAAK,EACV,SAAS,EAGV,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;CACf;AAED,sCAAsC;AACtC,wBAAgB,iBAAiB,IAAI,WAAW,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CACrB,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,MAAM,GACf,SAAS,CAYX"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* llm() — memoized completion sugar with classified error surface.
|
|
3
|
+
*
|
|
4
|
+
* The wrapper does not own a provider router. Callers pass a closure
|
|
5
|
+
* (request.call) that talks to their provider of choice and returns a
|
|
6
|
+
* normalized LLMCompleteResult. The wrapper:
|
|
7
|
+
*
|
|
8
|
+
* 1. Increments the agent turn counter and gates against maxTurns.
|
|
9
|
+
* 2. Wraps the closure in step.run so the assistant response is
|
|
10
|
+
* memoized for crash-resume.
|
|
11
|
+
* 3. Inspects result.finishReason to raise classified errors:
|
|
12
|
+
* "refusal" → LLMRefusalError
|
|
13
|
+
* "max_tokens"/"length" → LLMMaxTokensError
|
|
14
|
+
* JSON-parse failures must be raised by the caller, by detecting
|
|
15
|
+
* invalid JSON in their closure and throwing LLMInvalidJSONError.
|
|
16
|
+
*
|
|
17
|
+
* Anti-scope: provider routing, prompt templating, and streaming all
|
|
18
|
+
* stay out of this module. See module README.
|
|
19
|
+
*/
|
|
20
|
+
import { LLMMaxTokensError, LLMRefusalError, MaxTurnsExceededError, } from "./errors.js";
|
|
21
|
+
/** Construct a fresh turn counter. */
|
|
22
|
+
export function createTurnCounter() {
|
|
23
|
+
return { value: 0 };
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Build an LLMClient bound to the given step + counter.
|
|
27
|
+
*
|
|
28
|
+
* Exported for use by agent.ts; not part of the public API surface.
|
|
29
|
+
*/
|
|
30
|
+
export function makeLlm(step, counter, maxTurns) {
|
|
31
|
+
return {
|
|
32
|
+
async complete(request) {
|
|
33
|
+
counter.value += 1;
|
|
34
|
+
if (counter.value > maxTurns) {
|
|
35
|
+
throw new MaxTurnsExceededError(maxTurns);
|
|
36
|
+
}
|
|
37
|
+
const result = await step.run(`llm.turn`, () => request.call());
|
|
38
|
+
classifyResult(result);
|
|
39
|
+
return result;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function classifyResult(result) {
|
|
44
|
+
const reason = result.finishReason;
|
|
45
|
+
if (!reason)
|
|
46
|
+
return;
|
|
47
|
+
const normalized = reason.toLowerCase();
|
|
48
|
+
if (normalized === "refusal" || normalized === "safety" || normalized === "content_filter") {
|
|
49
|
+
throw new LLMRefusalError(`provider refused: ${reason}`, {
|
|
50
|
+
details: { finishReason: reason, metadata: result.metadata },
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (normalized === "max_tokens" || normalized === "length") {
|
|
54
|
+
throw new LLMMaxTokensError(`provider hit max_tokens (${reason})`, {
|
|
55
|
+
details: { finishReason: reason, metadata: result.metadata },
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=llm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm.js","sourceRoot":"","sources":["../../src/agent/llm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EACL,iBAAiB,EACjB,eAAe,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AAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;SAC7D,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* exposeMcp() — register agent tools with Ironflow's AgentToolsService
|
|
3
|
+
* and serve dispatched invocations over the existing serve() mount.
|
|
4
|
+
*
|
|
5
|
+
* Boot-time flow:
|
|
6
|
+
*
|
|
7
|
+
* 1. Convert each McpToolDef.input (Zod) → JSON Schema (Draft 2020-12)
|
|
8
|
+
* via z.toJSONSchema().
|
|
9
|
+
* 2. POST `/ironflow.v1.AgentToolsService/RegisterTool` with
|
|
10
|
+
* {agentName, callbackUrl, tools[]}.
|
|
11
|
+
* 3. Stash the returned HMAC secret + def closures in the local
|
|
12
|
+
* registry so serve()'s dispatch route can validate inbound calls.
|
|
13
|
+
*
|
|
14
|
+
* Callback flow lives in `dispatch.ts` (HMAC verify + Zod parse + handler).
|
|
15
|
+
*
|
|
16
|
+
* Authoritative authorization stays server-side: scopes on McpToolDef
|
|
17
|
+
* are advisory hints to MCP clients. The server enforces api_key.tool_scopes
|
|
18
|
+
* superset against ToolDef.required_scopes. RegisterTool requires the
|
|
19
|
+
* `agent:tools:register` action on the calling key.
|
|
20
|
+
*/
|
|
21
|
+
import type { ExposeMcpConfig } from "./types.js";
|
|
22
|
+
/**
|
|
23
|
+
* Handle returned from exposeMcp(). `unregister()` removes the tools
|
|
24
|
+
* from both the Ironflow server's registry and the local SDK mirror.
|
|
25
|
+
*/
|
|
26
|
+
export interface ExposeMcpHandle {
|
|
27
|
+
/** Server name (== agent namespace) reported to MCP clients. */
|
|
28
|
+
readonly name: string;
|
|
29
|
+
/** Number of tools registered with the server. */
|
|
30
|
+
readonly toolCount: number;
|
|
31
|
+
/** Status indicator. "active" once RegisterTool succeeds. */
|
|
32
|
+
readonly status: "active";
|
|
33
|
+
/** Qualified names registered (`{agentName}.{toolName}`). */
|
|
34
|
+
readonly toolNames: ReadonlyArray<string>;
|
|
35
|
+
/**
|
|
36
|
+
* Remove all tools registered under this agent name. Idempotent —
|
|
37
|
+
* server returns 200 with removed_count=0 if the agent was already
|
|
38
|
+
* gone. Local registry entries are cleared even if the server call
|
|
39
|
+
* fails so handler closures don't leak.
|
|
40
|
+
*/
|
|
41
|
+
unregister(): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Register the supplied MCP tool definitions with the Ironflow server.
|
|
45
|
+
*
|
|
46
|
+
* Returns an active handle once RegisterTool succeeds. Throws on
|
|
47
|
+
* empty tool lists, missing config (server URL / API key / callback URL),
|
|
48
|
+
* or transport failure.
|
|
49
|
+
*/
|
|
50
|
+
export declare function exposeMcp(config: ExposeMcpConfig): Promise<ExposeMcpHandle>;
|
|
51
|
+
//# sourceMappingURL=mcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/agent/mcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AASH,OAAO,KAAK,EAAiB,eAAe,EAAE,MAAM,YAAY,CAAC;AAKjE;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,gEAAgE;IAChE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,6DAA6D;IAC7D,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,6DAA6D;IAC7D,QAAQ,CAAC,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C;;;;;OAKG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAOD;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAmGjF"}
|