@serverless-dna/sop-agents 0.1.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/LICENSE +21 -0
- package/README.md +145 -0
- package/dist/agent-discovery.d.ts +21 -0
- package/dist/agent-discovery.d.ts.map +1 -0
- package/dist/agent-discovery.js +97 -0
- package/dist/agent-discovery.js.map +1 -0
- package/dist/agents/discovery.d.ts +21 -0
- package/dist/agents/discovery.d.ts.map +1 -0
- package/dist/agents/discovery.js +97 -0
- package/dist/agents/discovery.js.map +1 -0
- package/dist/agents/sop-loader.d.ts +20 -0
- package/dist/agents/sop-loader.d.ts.map +1 -0
- package/dist/agents/sop-loader.js +150 -0
- package/dist/agents/sop-loader.js.map +1 -0
- package/dist/agents/tool-generator.d.ts +66 -0
- package/dist/agents/tool-generator.d.ts.map +1 -0
- package/dist/agents/tool-generator.js +171 -0
- package/dist/agents/tool-generator.js.map +1 -0
- package/dist/default-orchestrator.d.ts +7 -0
- package/dist/default-orchestrator.d.ts.map +1 -0
- package/dist/default-orchestrator.js +50 -0
- package/dist/default-orchestrator.js.map +1 -0
- package/dist/errors.d.ts +51 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +80 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +26 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +89 -0
- package/dist/logger.js.map +1 -0
- package/dist/model-factory.d.ts +36 -0
- package/dist/model-factory.d.ts.map +1 -0
- package/dist/model-factory.js +55 -0
- package/dist/model-factory.js.map +1 -0
- package/dist/orchestrator/default-orchestrator.d.ts +7 -0
- package/dist/orchestrator/default-orchestrator.d.ts.map +1 -0
- package/dist/orchestrator/default-orchestrator.js +50 -0
- package/dist/orchestrator/default-orchestrator.js.map +1 -0
- package/dist/orchestrator/orchestrator.d.ts +47 -0
- package/dist/orchestrator/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator/orchestrator.js +276 -0
- package/dist/orchestrator/orchestrator.js.map +1 -0
- package/dist/orchestrator.d.ts +50 -0
- package/dist/orchestrator.d.ts.map +1 -0
- package/dist/orchestrator.js +281 -0
- package/dist/orchestrator.js.map +1 -0
- package/dist/sop-loader.d.ts +20 -0
- package/dist/sop-loader.d.ts.map +1 -0
- package/dist/sop-loader.js +150 -0
- package/dist/sop-loader.js.map +1 -0
- package/dist/tool-generator.d.ts +66 -0
- package/dist/tool-generator.d.ts.map +1 -0
- package/dist/tool-generator.js +171 -0
- package/dist/tool-generator.js.map +1 -0
- package/dist/types/errors.d.ts +51 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +80 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/types.d.ts +160 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +2 -0
- package/dist/types/types.js.map +1 -0
- package/dist/types.d.ts +157 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { Agent, tool } from "@strands-agents/sdk";
|
|
2
|
+
import { createModelFromSpec, parseModelSpec, } from "./model-factory.js";
|
|
3
|
+
/**
|
|
4
|
+
* Cache for agent instances to avoid recreating agents for repeated invocations
|
|
5
|
+
*/
|
|
6
|
+
const agentCache = new Map();
|
|
7
|
+
/**
|
|
8
|
+
* Current default model spec for creating agents (undefined = use Strands default)
|
|
9
|
+
*/
|
|
10
|
+
let currentDefaultModelSpec;
|
|
11
|
+
/**
|
|
12
|
+
* Current default provider when model spec has no provider prefix
|
|
13
|
+
*/
|
|
14
|
+
let currentDefaultProvider = "bedrock";
|
|
15
|
+
/**
|
|
16
|
+
* Whether to print agent output to console (default: true, set false for non-debug)
|
|
17
|
+
*/
|
|
18
|
+
let printerEnabled = true;
|
|
19
|
+
/**
|
|
20
|
+
* Builds a structured prompt for the agent from task and input parameters
|
|
21
|
+
* @param task - The specific task to perform
|
|
22
|
+
* @param inputs - Input parameters for the task
|
|
23
|
+
* @returns Formatted prompt string
|
|
24
|
+
*/
|
|
25
|
+
export function buildAgentPrompt(task, inputs) {
|
|
26
|
+
const inputEntries = Object.entries(inputs).filter(([key]) => key !== "task");
|
|
27
|
+
if (inputEntries.length === 0) {
|
|
28
|
+
return `## Task\n${task}`;
|
|
29
|
+
}
|
|
30
|
+
const inputSection = inputEntries
|
|
31
|
+
.map(([key, value]) => `- ${key}: ${JSON.stringify(value)}`)
|
|
32
|
+
.join("\n");
|
|
33
|
+
return `## Task\n${task}\n\n## Input Parameters\n${inputSection}`;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Gets or creates a cached agent instance for the given SOP
|
|
37
|
+
* @param sop - The SOP definition to create an agent for
|
|
38
|
+
* @param logger - Optional logger for logging agent creation
|
|
39
|
+
* @returns The agent instance (cached or newly created)
|
|
40
|
+
*/
|
|
41
|
+
export function getOrCreateAgent(sop, logger) {
|
|
42
|
+
const cached = agentCache.get(sop.name);
|
|
43
|
+
if (cached) {
|
|
44
|
+
return cached;
|
|
45
|
+
}
|
|
46
|
+
// Use SOP-specific model, then default, then Strands default (undefined)
|
|
47
|
+
const modelSpec = sop.model ?? currentDefaultModelSpec;
|
|
48
|
+
let modelDisplay;
|
|
49
|
+
const agentConfig = {
|
|
50
|
+
systemPrompt: sop.body,
|
|
51
|
+
tools: [],
|
|
52
|
+
printer: printerEnabled,
|
|
53
|
+
};
|
|
54
|
+
if (modelSpec) {
|
|
55
|
+
const parsed = parseModelSpec(modelSpec, currentDefaultProvider);
|
|
56
|
+
modelDisplay = `${parsed.provider}/${parsed.modelId}`;
|
|
57
|
+
agentConfig.model = createModelFromSpec(modelSpec, currentDefaultProvider);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
modelDisplay = "default (Strands SDK)";
|
|
61
|
+
}
|
|
62
|
+
if (logger) {
|
|
63
|
+
logger.info(`Creating agent with model: ${modelDisplay}`);
|
|
64
|
+
}
|
|
65
|
+
const agent = new Agent(agentConfig);
|
|
66
|
+
agentCache.set(sop.name, agent);
|
|
67
|
+
return agent;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Sets the default model spec for creating new agents
|
|
71
|
+
* @param modelSpec - The model spec to use as default (e.g., "bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0")
|
|
72
|
+
*/
|
|
73
|
+
export function setDefaultModelSpec(modelSpec) {
|
|
74
|
+
currentDefaultModelSpec = modelSpec;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Gets the current default model spec (undefined means Strands default)
|
|
78
|
+
*/
|
|
79
|
+
export function getDefaultModelSpec() {
|
|
80
|
+
return currentDefaultModelSpec;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Sets the default provider when model spec has no provider prefix
|
|
84
|
+
* @param provider - The default provider ("bedrock" or "openai")
|
|
85
|
+
*/
|
|
86
|
+
export function setDefaultProvider(provider) {
|
|
87
|
+
currentDefaultProvider = provider;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Gets the current default provider
|
|
91
|
+
*/
|
|
92
|
+
export function getDefaultProvider() {
|
|
93
|
+
return currentDefaultProvider;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Sets whether agent output should be printed to console
|
|
97
|
+
* @param enabled - true to print output (debug), false to suppress (production)
|
|
98
|
+
*/
|
|
99
|
+
export function setPrinterEnabled(enabled) {
|
|
100
|
+
printerEnabled = enabled;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Gets whether printer is enabled
|
|
104
|
+
*/
|
|
105
|
+
export function isPrinterEnabled() {
|
|
106
|
+
return printerEnabled;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Clears the agent cache
|
|
110
|
+
*/
|
|
111
|
+
export function clearCache() {
|
|
112
|
+
agentCache.clear();
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Creates a Strands tool from an SOP definition
|
|
116
|
+
* Tool name follows pattern: agent_{sop.name}
|
|
117
|
+
* Uses async generator to stream sub-agent output
|
|
118
|
+
* @param sop - The SOP definition to create a tool from
|
|
119
|
+
* @returns An InvokableTool that delegates to the agent
|
|
120
|
+
*/
|
|
121
|
+
export function createTool(sop) {
|
|
122
|
+
return tool({
|
|
123
|
+
name: `agent_${sop.name}`,
|
|
124
|
+
description: sop.description,
|
|
125
|
+
inputSchema: sop.zodSchema,
|
|
126
|
+
callback: async function* (input) {
|
|
127
|
+
const task = input.task;
|
|
128
|
+
const agent = getOrCreateAgent(sop);
|
|
129
|
+
const prompt = buildAgentPrompt(task, input);
|
|
130
|
+
// Stream from the sub-agent
|
|
131
|
+
const generator = agent.stream(prompt);
|
|
132
|
+
let result = await generator.next();
|
|
133
|
+
let fullText = "";
|
|
134
|
+
while (!result.done) {
|
|
135
|
+
// Process events from the sub-agent
|
|
136
|
+
// biome-ignore lint/suspicious/noExplicitAny: SDK event types vary
|
|
137
|
+
const event = result.value;
|
|
138
|
+
if (event.type === "modelContentBlockDeltaEvent" &&
|
|
139
|
+
event.delta?.type === "textDelta") {
|
|
140
|
+
const text = event.delta.text ?? "";
|
|
141
|
+
fullText += text;
|
|
142
|
+
yield text;
|
|
143
|
+
}
|
|
144
|
+
result = await generator.next();
|
|
145
|
+
}
|
|
146
|
+
// Return the full text as the final result
|
|
147
|
+
const lastMessage = result.value.lastMessage;
|
|
148
|
+
if (lastMessage?.content?.[0]) {
|
|
149
|
+
const content = lastMessage.content[0];
|
|
150
|
+
if (content.type === "textBlock") {
|
|
151
|
+
return content.text;
|
|
152
|
+
}
|
|
153
|
+
return String(content);
|
|
154
|
+
}
|
|
155
|
+
return fullText;
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Creates tools for all agents in a registry
|
|
161
|
+
* @param registry - Map of agent names to SOP definitions
|
|
162
|
+
* @returns Array of InvokableTool instances
|
|
163
|
+
*/
|
|
164
|
+
export function createAllTools(registry) {
|
|
165
|
+
const tools = [];
|
|
166
|
+
for (const sop of registry.values()) {
|
|
167
|
+
tools.push(createTool(sop));
|
|
168
|
+
}
|
|
169
|
+
return tools;
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=tool-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-generator.js","sourceRoot":"","sources":["../src/tool-generator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EACN,mBAAmB,EAEnB,cAAc,GACd,MAAM,oBAAoB,CAAC;AAG5B;;GAEG;AACH,MAAM,UAAU,GAAG,IAAI,GAAG,EAAiB,CAAC;AAE5C;;GAEG;AACH,IAAI,uBAA2C,CAAC;AAEhD;;GAEG;AACH,IAAI,sBAAsB,GAAkB,SAAS,CAAC;AAEtD;;GAEG;AACH,IAAI,cAAc,GAAG,IAAI,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC/B,IAAY,EACZ,MAA+B;IAE/B,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC;IAE9E,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,OAAO,YAAY,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,MAAM,YAAY,GAAG,YAAY;SAC/B,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,GAAG,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;SAC3D,IAAI,CAAC,IAAI,CAAC,CAAC;IA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;oBAC5C,KAAK,CAAC,KAAK,EAAE,IAAI,KAAK,WAAW,EAChC,CAAC;oBACF,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC;oBACpC,QAAQ,IAAI,IAAI,CAAC;oBACjB,MAAM,IAAI,CAAC;gBACZ,CAAC;gBACD,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC;YACjC,CAAC;YAED,2CAA2C;YAC3C,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC;YAC7C,IAAI,WAAW,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC/B,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBACvC,IAAI,OAAO,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;oBAClC,OAAO,OAAO,CAAC,IAAI,CAAC;gBACrB,CAAC;gBACD,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;YACxB,CAAC;YAED,OAAO,QAAQ,CAAC;QACjB,CAAC;KACD,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC7B,QAAoC;IAEpC,MAAM,KAAK,GAAqD,EAAE,CAAC;IAEnE,KAAK,MAAM,GAAG,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC;QACrC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all SOP-related errors
|
|
3
|
+
*/
|
|
4
|
+
export declare class SOPError extends Error {
|
|
5
|
+
readonly code: string;
|
|
6
|
+
readonly context: Record<string, unknown>;
|
|
7
|
+
constructor(message: string, code: string, context: Record<string, unknown>);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Thrown when an SOP file cannot be found
|
|
11
|
+
*/
|
|
12
|
+
export declare class FileNotFoundError extends SOPError {
|
|
13
|
+
constructor(filepath: string);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Thrown when frontmatter YAML is malformed
|
|
17
|
+
*/
|
|
18
|
+
export declare class FrontmatterParseError extends SOPError {
|
|
19
|
+
constructor(filepath: string, parseError: string);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Thrown when frontmatter fails validation
|
|
23
|
+
*/
|
|
24
|
+
export declare class FrontmatterValidationError extends SOPError {
|
|
25
|
+
constructor(filepath: string, field: string, reason: string);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Thrown when discovery directory doesn't exist
|
|
29
|
+
*/
|
|
30
|
+
export declare class DirectoryNotFoundError extends SOPError {
|
|
31
|
+
constructor(directory: string);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Thrown when no orchestrator SOP is found
|
|
35
|
+
*/
|
|
36
|
+
export declare class OrchestratorNotFoundError extends SOPError {
|
|
37
|
+
constructor(directory: string);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Thrown when multiple orchestrator SOPs are found
|
|
41
|
+
*/
|
|
42
|
+
export declare class MultipleOrchestratorsError extends SOPError {
|
|
43
|
+
constructor(directory: string, files: string[]);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Thrown when an agent invocation fails
|
|
47
|
+
*/
|
|
48
|
+
export declare class AgentInvocationError extends SOPError {
|
|
49
|
+
constructor(agentName: string, task: string, originalError: Error);
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;aAGjB,IAAI,EAAE,MAAM;aACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAFhD,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAKjD;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,QAAQ;gBAClC,QAAQ,EAAE,MAAM;CAI5B;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,QAAQ;gBACtC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAQhD;AAED;;GAEG;AACH,qBAAa,0BAA2B,SAAQ,QAAQ;gBAC3C,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAQ3D;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,QAAQ;gBACvC,SAAS,EAAE,MAAM;CAM7B;AAED;;GAEG;AACH,qBAAa,yBAA0B,SAAQ,QAAQ;gBAC1C,SAAS,EAAE,MAAM;CAQ7B;AAED;;GAEG;AACH,qBAAa,0BAA2B,SAAQ,QAAQ;gBAC3C,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;CAQ9C;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,QAAQ;gBACrC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK;CASjE"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all SOP-related errors
|
|
3
|
+
*/
|
|
4
|
+
export class SOPError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
context;
|
|
7
|
+
constructor(message, code, context) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.context = context;
|
|
11
|
+
this.name = "SOPError";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Thrown when an SOP file cannot be found
|
|
16
|
+
*/
|
|
17
|
+
export class FileNotFoundError extends SOPError {
|
|
18
|
+
constructor(filepath) {
|
|
19
|
+
super(`SOP file not found: ${filepath}`, "FILE_NOT_FOUND", { filepath });
|
|
20
|
+
this.name = "FileNotFoundError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Thrown when frontmatter YAML is malformed
|
|
25
|
+
*/
|
|
26
|
+
export class FrontmatterParseError extends SOPError {
|
|
27
|
+
constructor(filepath, parseError) {
|
|
28
|
+
super(`Failed to parse frontmatter in ${filepath}: ${parseError}`, "FRONTMATTER_PARSE_ERROR", { filepath, parseError });
|
|
29
|
+
this.name = "FrontmatterParseError";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Thrown when frontmatter fails validation
|
|
34
|
+
*/
|
|
35
|
+
export class FrontmatterValidationError extends SOPError {
|
|
36
|
+
constructor(filepath, field, reason) {
|
|
37
|
+
super(`Invalid frontmatter in ${filepath}: ${field} - ${reason}`, "FRONTMATTER_VALIDATION_ERROR", { filepath, field, reason });
|
|
38
|
+
this.name = "FrontmatterValidationError";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Thrown when discovery directory doesn't exist
|
|
43
|
+
*/
|
|
44
|
+
export class DirectoryNotFoundError extends SOPError {
|
|
45
|
+
constructor(directory) {
|
|
46
|
+
super(`Directory not found: ${directory}`, "DIRECTORY_NOT_FOUND", {
|
|
47
|
+
directory,
|
|
48
|
+
});
|
|
49
|
+
this.name = "DirectoryNotFoundError";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Thrown when no orchestrator SOP is found
|
|
54
|
+
*/
|
|
55
|
+
export class OrchestratorNotFoundError extends SOPError {
|
|
56
|
+
constructor(directory) {
|
|
57
|
+
super(`No orchestrator SOP found in ${directory}`, "ORCHESTRATOR_NOT_FOUND", { directory });
|
|
58
|
+
this.name = "OrchestratorNotFoundError";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Thrown when multiple orchestrator SOPs are found
|
|
63
|
+
*/
|
|
64
|
+
export class MultipleOrchestratorsError extends SOPError {
|
|
65
|
+
constructor(directory, files) {
|
|
66
|
+
super(`Multiple orchestrator SOPs found in ${directory}: ${files.join(", ")}`, "MULTIPLE_ORCHESTRATORS", { directory, files });
|
|
67
|
+
this.name = "MultipleOrchestratorsError";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Thrown when an agent invocation fails
|
|
72
|
+
*/
|
|
73
|
+
export class AgentInvocationError extends SOPError {
|
|
74
|
+
constructor(agentName, task, originalError) {
|
|
75
|
+
super(`Agent '${agentName}' failed: ${originalError.message}`, "AGENT_INVOCATION_ERROR", { agentName, task, originalError: originalError.message });
|
|
76
|
+
this.name = "AgentInvocationError";
|
|
77
|
+
this.cause = originalError;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IAGjB;IACA;IAHjB,YACC,OAAe,EACC,IAAY,EACZ,OAAgC;QAEhD,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAyB;QAGhD,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACxB,CAAC;CACD;AAED;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,QAAQ;IAC9C,YAAY,QAAgB;QAC3B,KAAK,CAAC,uBAAuB,QAAQ,EAAE,EAAE,gBAAgB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QACzE,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IACjC,CAAC;CACD;AAED;;GAE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,CAAC,IAAI,GAAG,4BAA4B,CAAC;IAC1C,CAAC;CACD;AAED;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,QAAQ;IACjD,YAAY,SAAiB,EAAE,IAAY,EAAE,aAAoB;QAChE,KAAK,CACJ,UAAU,SAAS,aAAa,aAAa,CAAC,OAAO,EAAE,EACvD,wBAAwB,EACxB,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,aAAa,CAAC,OAAO,EAAE,CACzD,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,aAAa,CAAC;IAC5B,CAAC;CACD"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Supported input types for SOP parameters
|
|
4
|
+
*/
|
|
5
|
+
export type InputType = "string" | "number" | "boolean" | "enum" | "list";
|
|
6
|
+
/**
|
|
7
|
+
* Definition for a single input parameter in an SOP
|
|
8
|
+
*/
|
|
9
|
+
export interface InputDef {
|
|
10
|
+
type: InputType;
|
|
11
|
+
description: string;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
default?: unknown;
|
|
14
|
+
values?: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* YAML frontmatter structure for SOP files
|
|
18
|
+
*/
|
|
19
|
+
export interface SOPFrontmatter {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
version?: string;
|
|
23
|
+
tools?: string[];
|
|
24
|
+
inputs?: Record<string, InputDef>;
|
|
25
|
+
type?: "agent" | "orchestrator";
|
|
26
|
+
model?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Complete parsed SOP definition
|
|
30
|
+
*/
|
|
31
|
+
export interface SOPDefinition {
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
version: string;
|
|
35
|
+
tools: string[];
|
|
36
|
+
inputs: Record<string, InputDef>;
|
|
37
|
+
body: string;
|
|
38
|
+
filepath: string;
|
|
39
|
+
type: "agent" | "orchestrator";
|
|
40
|
+
zodSchema: z.ZodObject<z.ZodRawShape>;
|
|
41
|
+
model?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Error handling mode for orchestrator
|
|
45
|
+
*/
|
|
46
|
+
export type ErrorMode = "fail-fast" | "continue";
|
|
47
|
+
/**
|
|
48
|
+
* Log level for orchestrator logging
|
|
49
|
+
*/
|
|
50
|
+
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
51
|
+
/**
|
|
52
|
+
* Supported model providers
|
|
53
|
+
*/
|
|
54
|
+
export type ModelProvider = "bedrock" | "openai";
|
|
55
|
+
/**
|
|
56
|
+
* Configuration options for the orchestrator
|
|
57
|
+
*/
|
|
58
|
+
export interface OrchestratorConfig {
|
|
59
|
+
directory?: string;
|
|
60
|
+
errorMode?: ErrorMode;
|
|
61
|
+
logLevel?: LogLevel;
|
|
62
|
+
defaultModel?: string;
|
|
63
|
+
defaultProvider?: ModelProvider;
|
|
64
|
+
showThinking?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Options for invoke method
|
|
68
|
+
*/
|
|
69
|
+
export interface InvokeOptions {
|
|
70
|
+
/** Include thinking/reasoning in the result */
|
|
71
|
+
showThinking?: boolean;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Result from orchestrator invocation
|
|
75
|
+
*/
|
|
76
|
+
export interface InvokeResult {
|
|
77
|
+
/** The final response text */
|
|
78
|
+
response: string;
|
|
79
|
+
/** Orchestrator's thinking/reasoning (only populated if showThinking is enabled) */
|
|
80
|
+
thinking?: string[];
|
|
81
|
+
/** Tool calls made during execution */
|
|
82
|
+
toolCalls?: Array<{
|
|
83
|
+
name: string;
|
|
84
|
+
input: Record<string, unknown>;
|
|
85
|
+
}>;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Stream event from orchestrator (re-exported from SDK)
|
|
89
|
+
*/
|
|
90
|
+
export type OrchestratorStreamEvent = {
|
|
91
|
+
type: string;
|
|
92
|
+
[key: string]: unknown;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Orchestrator interface for managing multi-agent orchestration
|
|
96
|
+
*/
|
|
97
|
+
export interface Orchestrator {
|
|
98
|
+
/**
|
|
99
|
+
* Initialize the orchestrator by discovering agents and creating tools
|
|
100
|
+
*/
|
|
101
|
+
initialize(): Promise<void>;
|
|
102
|
+
/**
|
|
103
|
+
* Process a request through the orchestrator agent
|
|
104
|
+
* @returns Response string when no options, InvokeResult when options provided
|
|
105
|
+
*/
|
|
106
|
+
invoke(request: string): Promise<string>;
|
|
107
|
+
invoke(request: string, options: InvokeOptions): Promise<InvokeResult>;
|
|
108
|
+
/**
|
|
109
|
+
* Stream events from the orchestrator in real-time
|
|
110
|
+
* @returns AsyncGenerator of stream events
|
|
111
|
+
*/
|
|
112
|
+
stream(request: string): AsyncGenerator<OrchestratorStreamEvent>;
|
|
113
|
+
/**
|
|
114
|
+
* Clear agent cache
|
|
115
|
+
*/
|
|
116
|
+
clearCache(): void;
|
|
117
|
+
/**
|
|
118
|
+
* Get the agent registry (for inspection/debugging)
|
|
119
|
+
*/
|
|
120
|
+
getRegistry(): Map<string, SOPDefinition>;
|
|
121
|
+
/**
|
|
122
|
+
* Current configuration (readonly for inspection)
|
|
123
|
+
*/
|
|
124
|
+
readonly config: OrchestratorConfig;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Log entry structure for orchestrator logging
|
|
128
|
+
*/
|
|
129
|
+
export interface LogEntry {
|
|
130
|
+
timestamp: Date;
|
|
131
|
+
correlationId: string;
|
|
132
|
+
level: LogLevel;
|
|
133
|
+
agentName?: string;
|
|
134
|
+
message: string;
|
|
135
|
+
duration?: number;
|
|
136
|
+
error?: Error;
|
|
137
|
+
metadata?: Record<string, unknown>;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Logger interface for orchestrator logging
|
|
141
|
+
*/
|
|
142
|
+
export interface Logger {
|
|
143
|
+
debug(message: string, metadata?: Record<string, unknown>): void;
|
|
144
|
+
info(message: string, metadata?: Record<string, unknown>): void;
|
|
145
|
+
warn(message: string, metadata?: Record<string, unknown>): void;
|
|
146
|
+
error(message: string, error?: Error, metadata?: Record<string, unknown>): void;
|
|
147
|
+
/**
|
|
148
|
+
* Create a child logger with correlation ID
|
|
149
|
+
*/
|
|
150
|
+
withCorrelationId(correlationId: string): Logger;
|
|
151
|
+
/**
|
|
152
|
+
* Create a child logger with agent context
|
|
153
|
+
*/
|
|
154
|
+
withAgent(agentName: string): Logger;
|
|
155
|
+
/**
|
|
156
|
+
* Set the minimum log level
|
|
157
|
+
*/
|
|
158
|
+
setLevel(level: LogLevel): void;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB,IAAI,EAAE,SAAS,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CA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AAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACtB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACjE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAChE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAChE,KAAK,CACJ,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,KAAK,EACb,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,IAAI,CAAC;IAER;;OAEG;IACH,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC;IAEjD;;OAEG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAErC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAC;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":""}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Supported input types for SOP parameters
|
|
4
|
+
*/
|
|
5
|
+
export type InputType = "string" | "number" | "boolean" | "enum" | "list";
|
|
6
|
+
/**
|
|
7
|
+
* Definition for a single input parameter in an SOP
|
|
8
|
+
*/
|
|
9
|
+
export interface InputDef {
|
|
10
|
+
type: InputType;
|
|
11
|
+
description: string;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
default?: unknown;
|
|
14
|
+
values?: string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* YAML frontmatter structure for SOP files
|
|
18
|
+
*/
|
|
19
|
+
export interface SOPFrontmatter {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
version?: string;
|
|
23
|
+
tools?: string[];
|
|
24
|
+
inputs?: Record<string, InputDef>;
|
|
25
|
+
type?: "agent" | "orchestrator";
|
|
26
|
+
model?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Complete parsed SOP definition
|
|
30
|
+
*/
|
|
31
|
+
export interface SOPDefinition {
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
version: string;
|
|
35
|
+
tools: string[];
|
|
36
|
+
inputs: Record<string, InputDef>;
|
|
37
|
+
body: string;
|
|
38
|
+
filepath: string;
|
|
39
|
+
type: "agent" | "orchestrator";
|
|
40
|
+
zodSchema: z.ZodObject<z.ZodRawShape>;
|
|
41
|
+
model?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Error handling mode for orchestrator
|
|
45
|
+
*/
|
|
46
|
+
export type ErrorMode = "fail-fast" | "continue";
|
|
47
|
+
/**
|
|
48
|
+
* Log level for orchestrator logging
|
|
49
|
+
*/
|
|
50
|
+
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
51
|
+
/**
|
|
52
|
+
* Supported model providers
|
|
53
|
+
*/
|
|
54
|
+
export type ModelProvider = "bedrock" | "openai";
|
|
55
|
+
/**
|
|
56
|
+
* Configuration options for the orchestrator
|
|
57
|
+
*/
|
|
58
|
+
export interface OrchestratorConfig {
|
|
59
|
+
directory?: string;
|
|
60
|
+
errorMode?: ErrorMode;
|
|
61
|
+
logLevel?: LogLevel;
|
|
62
|
+
defaultModel?: string;
|
|
63
|
+
defaultProvider?: ModelProvider;
|
|
64
|
+
showThinking?: boolean;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Result from orchestrator invocation
|
|
68
|
+
*/
|
|
69
|
+
export interface InvokeResult {
|
|
70
|
+
/** The final response text */
|
|
71
|
+
response: string;
|
|
72
|
+
/** Orchestrator's thinking/reasoning (only populated if showThinking is enabled) */
|
|
73
|
+
thinking?: string[];
|
|
74
|
+
/** Tool calls made during execution */
|
|
75
|
+
toolCalls?: Array<{
|
|
76
|
+
name: string;
|
|
77
|
+
input: Record<string, unknown>;
|
|
78
|
+
}>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Stream event from orchestrator (re-exported from SDK)
|
|
82
|
+
*/
|
|
83
|
+
export type OrchestratorStreamEvent = {
|
|
84
|
+
type: string;
|
|
85
|
+
[key: string]: unknown;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Orchestrator interface for managing multi-agent orchestration
|
|
89
|
+
*/
|
|
90
|
+
export interface Orchestrator {
|
|
91
|
+
/**
|
|
92
|
+
* Initialize the orchestrator by discovering agents and creating tools
|
|
93
|
+
*/
|
|
94
|
+
initialize(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Process a request through the orchestrator agent
|
|
97
|
+
* @returns Final response string (for backward compatibility)
|
|
98
|
+
*/
|
|
99
|
+
invoke(request: string): Promise<string>;
|
|
100
|
+
/**
|
|
101
|
+
* Process a request and return detailed result including thinking
|
|
102
|
+
* @returns InvokeResult with response, thinking, and tool calls
|
|
103
|
+
*/
|
|
104
|
+
invokeWithDetails(request: string): Promise<InvokeResult>;
|
|
105
|
+
/**
|
|
106
|
+
* Stream events from the orchestrator in real-time
|
|
107
|
+
* @returns AsyncGenerator of stream events
|
|
108
|
+
*/
|
|
109
|
+
stream(request: string): AsyncGenerator<OrchestratorStreamEvent>;
|
|
110
|
+
/**
|
|
111
|
+
* Clear agent cache
|
|
112
|
+
*/
|
|
113
|
+
clearCache(): void;
|
|
114
|
+
/**
|
|
115
|
+
* Get the agent registry (for inspection/debugging)
|
|
116
|
+
*/
|
|
117
|
+
getRegistry(): Map<string, SOPDefinition>;
|
|
118
|
+
/**
|
|
119
|
+
* Current configuration (readonly for inspection)
|
|
120
|
+
*/
|
|
121
|
+
readonly config: OrchestratorConfig;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Log entry structure for orchestrator logging
|
|
125
|
+
*/
|
|
126
|
+
export interface LogEntry {
|
|
127
|
+
timestamp: Date;
|
|
128
|
+
correlationId: string;
|
|
129
|
+
level: LogLevel;
|
|
130
|
+
agentName?: string;
|
|
131
|
+
message: string;
|
|
132
|
+
duration?: number;
|
|
133
|
+
error?: Error;
|
|
134
|
+
metadata?: Record<string, unknown>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Logger interface for orchestrator logging
|
|
138
|
+
*/
|
|
139
|
+
export interface Logger {
|
|
140
|
+
debug(message: string, metadata?: Record<string, unknown>): void;
|
|
141
|
+
info(message: string, metadata?: Record<string, unknown>): void;
|
|
142
|
+
warn(message: string, metadata?: Record<string, unknown>): void;
|
|
143
|
+
error(message: string, error?: Error, metadata?: Record<string, unknown>): void;
|
|
144
|
+
/**
|
|
145
|
+
* Create a child logger with correlation ID
|
|
146
|
+
*/
|
|
147
|
+
withCorrelationId(correlationId: string): Logger;
|
|
148
|
+
/**
|
|
149
|
+
* Create a child logger with agent context
|
|
150
|
+
*/
|
|
151
|
+
withAgent(agentName: string): Logger;
|
|
152
|
+
/**
|
|
153
|
+
* Set the minimum log level
|
|
154
|
+
*/
|
|
155
|
+
setLevel(level: LogLevel): void;
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,QAAQ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