shrimsource 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/README.md ADDED
@@ -0,0 +1,178 @@
1
+ # Shrimsource
2
+
3
+ **Build AI agents in minutes.**
4
+
5
+ Shrimsource is a tiny open-source runtime for building agent workflows with tools, plugins, and templates.
6
+
7
+ It is designed for developers who want the fastest path from idea to a working AI agent.
8
+
9
+ ---
10
+
11
+ ## Two commands to your first agent
12
+
13
+ ```bash
14
+ npx create-aquarium research-agent
15
+ npm run agent
16
+ ```
17
+
18
+ Create a working agent project from a template, then run it instantly.
19
+
20
+ ---
21
+
22
+ ## What is Shrimsource?
23
+
24
+ Shrimsource is a minimal runtime for building AI agents.
25
+
26
+ It helps developers:
27
+
28
+ - create agents
29
+ - define workflows
30
+ - run workflows
31
+ - register plugins
32
+ - use tools
33
+
34
+ Aquarium is intentionally small.
35
+ The goal is to make building and running agents extremely simple.
36
+
37
+ ---
38
+
39
+ ## Core API
40
+
41
+ Shrimsource exposes only five core functions:
42
+
43
+ ```
44
+ createAgent()
45
+ createWorkflow()
46
+ runWorkflow()
47
+ registerPlugin()
48
+ useTool()
49
+ ```
50
+
51
+ That's the whole mental model.
52
+
53
+ ---
54
+
55
+ ## Example: Company Research Agent
56
+
57
+ Input:
58
+
59
+ ```
60
+ stripe.com
61
+ ```
62
+
63
+ Workflow:
64
+
65
+ ```
66
+ 1. research company
67
+ 2. analyze product
68
+ 3. summarize business model
69
+ 4. generate report
70
+ ```
71
+
72
+ Output:
73
+
74
+ ```
75
+ Company: Stripe
76
+
77
+ Industry: Fintech
78
+ Core Product: Online payment infrastructure
79
+
80
+ Key offerings:
81
+ - Payment processing
82
+ - Billing
83
+ - Marketplace infrastructure
84
+
85
+ Summary:
86
+ Stripe provides developer-first financial infrastructure for internet businesses.
87
+ ```
88
+
89
+ This entire workflow can be created and run with Aquarium.
90
+
91
+ ---
92
+
93
+ ## Why Aquarium?
94
+
95
+ Shrimsource focuses on developer experience.
96
+
97
+ - **Tiny core**
98
+ No framework monster.
99
+
100
+ - **Fast start**
101
+ Create a working agent with one command.
102
+
103
+ - **Template-first**
104
+ Download real working workflows instantly.
105
+
106
+ - **Extensible**
107
+ Add tools and plugins easily.
108
+
109
+ - **Open ecosystem**
110
+ Built for future developer ecosystems.
111
+
112
+ ---
113
+
114
+ ## Repositories
115
+
116
+ Aquarium Source is organized into multiple repositories.
117
+
118
+ ```
119
+ aquarium-core
120
+ → tiny runtime for agent workflows
121
+
122
+ aquarium-templates
123
+ → ready-to-run agent templates
124
+
125
+ awesome-aquarium
126
+ → curated ecosystem resources
127
+ ```
128
+
129
+ ---
130
+
131
+ ## Developer Path
132
+
133
+ Typical developer workflow:
134
+
135
+ ```
136
+ 1. Pick a template
137
+ 2. Create your agent project
138
+ 3. Run it instantly
139
+ 4. Modify the workflow
140
+ 5. Build your own agent
141
+ ```
142
+
143
+ Aquarium aims to reduce the time from idea to working agent to minutes.
144
+
145
+ ---
146
+
147
+ ## Philosophy
148
+
149
+ Shrimsource is intentionally minimal.
150
+
151
+ Instead of building a huge framework, Aquarium focuses on:
152
+
153
+ - a tiny runtime
154
+ - simple workflows
155
+ - instant templates
156
+ - fast experimentation
157
+
158
+ The ecosystem can grow later through templates, tools, and plugins.
159
+
160
+ ---
161
+
162
+ ## Status
163
+
164
+ Shrimsource is in early development.
165
+
166
+ The project focuses on:
167
+
168
+ - core runtime stability
169
+ - developer experience
170
+ - template ecosystem
171
+
172
+ Contributions and feedback are welcome.
173
+
174
+ ---
175
+
176
+ ## License
177
+
178
+ MIT License
@@ -0,0 +1,3 @@
1
+ import { Agent, RuntimeHooks } from "./types";
2
+ export declare function createAgent(hooks?: RuntimeHooks): Agent;
3
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE7C,wBAAgB,WAAW,CAAC,KAAK,GAAE,YAAiB,GAAG,KAAK,CAO3D"}
package/dist/agent.js ADDED
@@ -0,0 +1,10 @@
1
+ import { createMemory } from "./memory";
2
+ export function createAgent(hooks = {}) {
3
+ return {
4
+ tools: new Map(),
5
+ memory: createMemory(),
6
+ plugins: new Set(),
7
+ hooks
8
+ };
9
+ }
10
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGvC,MAAM,UAAU,WAAW,CAAC,QAAsB,EAAE;IAChD,OAAO;QACH,KAAK,EAAE,IAAI,GAAG,EAAE;QAChB,MAAM,EAAE,YAAY,EAAE;QACtB,OAAO,EAAE,IAAI,GAAG,EAAE;QAClB,KAAK;KACR,CAAA;AACL,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { createAgent } from "./agent";
2
+ export { createWorkflow } from "./workflow";
3
+ export { runWorkflow } from "./runtime";
4
+ export { registerPlugin } from "./plugin";
5
+ export { useTool } from "./tool";
6
+ export * from "./types";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAEhC,cAAc,SAAS,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export { createAgent } from "./agent";
2
+ export { createWorkflow } from "./workflow";
3
+ export { runWorkflow } from "./runtime";
4
+ export { registerPlugin } from "./plugin";
5
+ export { useTool } from "./tool";
6
+ export * from "./types";
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAEhC,cAAc,SAAS,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { AgentMemory } from "./types";
2
+ export declare function createMemory(): AgentMemory;
3
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAErC,wBAAgB,YAAY,IAAI,WAAW,CAE1C"}
package/dist/memory.js ADDED
@@ -0,0 +1,4 @@
1
+ export function createMemory() {
2
+ return new Map();
3
+ }
4
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","sourceRoot":"","sources":["../src/memory.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,YAAY;IACxB,OAAO,IAAI,GAAG,EAAmB,CAAA;AACrC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Agent, Plugin } from "./types";
2
+ export declare function registerPlugin(agent: Agent, plugin: Plugin): Agent;
3
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEvC,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAYlE"}
package/dist/plugin.js ADDED
@@ -0,0 +1,11 @@
1
+ export function registerPlugin(agent, plugin) {
2
+ if (agent.plugins.has(plugin.name)) {
3
+ return agent;
4
+ }
5
+ agent.plugins.add(plugin.name);
6
+ for (const tool of plugin.tools ?? []) {
7
+ agent.tools.set(tool.name, tool);
8
+ }
9
+ return agent;
10
+ }
11
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,cAAc,CAAC,KAAY,EAAE,MAAc;IACvD,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACjC,OAAO,KAAK,CAAA;IAChB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAE9B,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;QACpC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACpC,CAAC;IAED,OAAO,KAAK,CAAA;AAChB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Agent, RunWorkflowOptions, Workflow, WorkflowRunResult } from "./types";
2
+ export declare function runWorkflow(agent: Agent, workflow: Workflow, input: unknown, options?: RunWorkflowOptions): Promise<WorkflowRunResult>;
3
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,EACL,kBAAkB,EAClB,QAAQ,EACR,iBAAiB,EAEpB,MAAM,SAAS,CAAA;AAkEhB,wBAAsB,WAAW,CAC7B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,kBAAuB,GACjC,OAAO,CAAC,iBAAiB,CAAC,CA4D5B"}
@@ -0,0 +1,87 @@
1
+ import { retry, withTimeout } from "./utils";
2
+ function canRunStep(step, completed) {
3
+ return (step.dependsOn ?? []).every((dep) => completed.has(dep));
4
+ }
5
+ async function executeStep(agent, workflow, step, state) {
6
+ const tool = agent.tools.get(step.tool);
7
+ if (!tool) {
8
+ throw new Error(`Tool not found: ${step.tool}`);
9
+ }
10
+ await agent.hooks.onStepStart?.({
11
+ workflowId: workflow.id,
12
+ stepId: step.id,
13
+ tool: step.tool
14
+ });
15
+ try {
16
+ const result = await retry(() => withTimeout(tool.run({
17
+ input: step.input ?? state,
18
+ state,
19
+ memory: agent.memory,
20
+ stepId: step.id,
21
+ workflowId: workflow.id
22
+ }), step.timeoutMs), step.retry ?? 0);
23
+ state[step.id] = result;
24
+ await agent.hooks.onStepEnd?.({
25
+ workflowId: workflow.id,
26
+ stepId: step.id,
27
+ tool: step.tool,
28
+ result
29
+ });
30
+ return result;
31
+ }
32
+ catch (error) {
33
+ const normalized = error instanceof Error ? error : new Error(String(error));
34
+ await agent.hooks.onStepError?.({
35
+ workflowId: workflow.id,
36
+ stepId: step.id,
37
+ tool: step.tool,
38
+ error: normalized
39
+ });
40
+ throw normalized;
41
+ }
42
+ }
43
+ export async function runWorkflow(agent, workflow, input, options = {}) {
44
+ const state = {
45
+ input,
46
+ ...(options.state ?? {})
47
+ };
48
+ const completed = new Set();
49
+ const pending = new Map(workflow.steps.map((step) => [step.id, step]));
50
+ await agent.hooks.onWorkflowStart?.({
51
+ workflowId: workflow.id
52
+ });
53
+ while (pending.size > 0) {
54
+ const runnable = [];
55
+ for (const step of pending.values()) {
56
+ if (canRunStep(step, completed)) {
57
+ runnable.push(step);
58
+ }
59
+ }
60
+ if (runnable.length === 0) {
61
+ throw new Error("Workflow deadlock detected. Check dependsOn relationships.");
62
+ }
63
+ const parallelSteps = runnable.filter((step) => step.parallel);
64
+ const sequentialSteps = runnable.filter((step) => !step.parallel);
65
+ for (const step of sequentialSteps) {
66
+ await executeStep(agent, workflow, step, state);
67
+ completed.add(step.id);
68
+ pending.delete(step.id);
69
+ }
70
+ if (parallelSteps.length > 0) {
71
+ await Promise.all(parallelSteps.map((step) => executeStep(agent, workflow, step, state)));
72
+ for (const step of parallelSteps) {
73
+ completed.add(step.id);
74
+ pending.delete(step.id);
75
+ }
76
+ }
77
+ }
78
+ await agent.hooks.onWorkflowEnd?.({
79
+ workflowId: workflow.id
80
+ });
81
+ return {
82
+ workflowId: workflow.id,
83
+ state,
84
+ completedSteps: [...completed]
85
+ };
86
+ }
87
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAE5C,SAAS,UAAU,CAAC,IAAkB,EAAE,SAAsB;IAC1D,OAAO,CAAC,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;AACpE,CAAC;AAED,KAAK,UAAU,WAAW,CACtB,KAAY,EACZ,QAAkB,EAClB,IAAkB,EAClB,KAA8B;IAE9B,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAEvC,IAAI,CAAC,IAAI,EAAE,CAAC;QACR,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;IACnD,CAAC;IAED,MAAM,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QAC5B,UAAU,EAAE,QAAQ,CAAC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C/C,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACtB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QAC3B,CAAC;QAED,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,MAAM,OAAO,CAAC,GAAG,CACb,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CACvB,WAAW,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,CAAC,CAC5C,CACJ,CAAA;YAED,KAAK,MAAM,IAAI,IAAI,aAAa,EAAE,CAAC;gBAC/B,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;gBACtB,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YAC3B,CAAC;QACL,CAAC;IACL,CAAC;IAED,MAAM,KAAK,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;QAC9B,UAAU,EAAE,QAAQ,CAAC,EAAE;KAC1B,CAAC,CAAA;IAEF,OAAO;QACH,UAAU,EAAE,QAAQ,CAAC,EAAE;QACvB,KAAK;QACL,cAAc,EAAE,CAAC,GAAG,SAAS,CAAC;KACjC,CAAA;AACL,CAAC"}
package/dist/tool.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { Agent, Tool } from "./types";
2
+ export declare function useTool(agent: Agent, tool: Tool): Agent;
3
+ //# sourceMappingURL=tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.d.ts","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAErC,wBAAgB,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,GAAG,KAAK,CAGvD"}
package/dist/tool.js ADDED
@@ -0,0 +1,5 @@
1
+ export function useTool(agent, tool) {
2
+ agent.tools.set(tool.name, tool);
3
+ return agent;
4
+ }
5
+ //# sourceMappingURL=tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.js","sourceRoot":"","sources":["../src/tool.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,OAAO,CAAC,KAAY,EAAE,IAAU;IAC5C,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAChC,OAAO,KAAK,CAAA;AAChB,CAAC"}
@@ -0,0 +1,65 @@
1
+ export type JsonValue = string | number | boolean | null | JsonValue[] | {
2
+ [key: string]: JsonValue;
3
+ };
4
+ export type AgentState = Record<string, unknown>;
5
+ export type AgentMemory = Map<string, unknown>;
6
+ export type ToolContext = {
7
+ input: unknown;
8
+ state: AgentState;
9
+ memory: AgentMemory;
10
+ stepId: string;
11
+ workflowId: string;
12
+ };
13
+ export type ToolResult = unknown;
14
+ export type Tool = {
15
+ name: string;
16
+ description?: string;
17
+ run: (ctx: ToolContext) => Promise<ToolResult>;
18
+ };
19
+ export type Plugin = {
20
+ name: string;
21
+ version?: string;
22
+ tools?: Tool[];
23
+ };
24
+ export type WorkflowStep = {
25
+ id: string;
26
+ tool: string;
27
+ input?: unknown;
28
+ parallel?: boolean;
29
+ dependsOn?: string[];
30
+ retry?: number;
31
+ timeoutMs?: number;
32
+ };
33
+ export type Workflow = {
34
+ id: string;
35
+ steps: WorkflowStep[];
36
+ };
37
+ export type RuntimeHookPayload = {
38
+ workflowId: string;
39
+ stepId?: string;
40
+ tool?: string;
41
+ error?: Error;
42
+ result?: unknown;
43
+ };
44
+ export type RuntimeHooks = {
45
+ onWorkflowStart?: (payload: RuntimeHookPayload) => void | Promise<void>;
46
+ onWorkflowEnd?: (payload: RuntimeHookPayload) => void | Promise<void>;
47
+ onStepStart?: (payload: RuntimeHookPayload) => void | Promise<void>;
48
+ onStepEnd?: (payload: RuntimeHookPayload) => void | Promise<void>;
49
+ onStepError?: (payload: RuntimeHookPayload) => void | Promise<void>;
50
+ };
51
+ export type Agent = {
52
+ tools: Map<string, Tool>;
53
+ memory: AgentMemory;
54
+ plugins: Set<string>;
55
+ hooks: RuntimeHooks;
56
+ };
57
+ export type RunWorkflowOptions = {
58
+ state?: AgentState;
59
+ };
60
+ export type WorkflowRunResult = {
61
+ workflowId: string;
62
+ state: AgentState;
63
+ completedSteps: string[];
64
+ };
65
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACf,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,EAAE,GACX;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAA;AAElC,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAEhD,MAAM,MAAM,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAE9C,MAAM,MAAM,WAAW,GAAG;IACtB,KAAK,EAAE,OAAO,CAAA;IACd,KAAK,EAAE,UAAU,CAAA;IACjB,MAAM,EAAE,WAAW,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,OAAO,CAAA;AAEhC,MAAM,MAAM,IAAI,GAAG;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,GAAG,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;CACjD,CAAA;AAED,MAAM,MAAM,MAAM,GAAG;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAA;CACjB,CAAA;AAED,MAAM,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EAAE,WAAW,CAAA;IACnB,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACpB,KAAK,EAAE,YAAY,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC7B,KAAK,CAAC,EAAE,UAAU,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC5B,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,UAAU,CAAA;IACjB,cAAc,EAAE,MAAM,EAAE,CAAA;CAC3B,CAAA"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export declare function withTimeout<T>(promise: Promise<T>, timeoutMs?: number): Promise<T>;
2
+ export declare function retry<T>(fn: () => Promise<T>, retryCount: number): Promise<T>;
3
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAsB,WAAW,CAAC,CAAC,EAC/B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,SAAS,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,CAAC,CAkBZ;AAED,wBAAsB,KAAK,CAAC,CAAC,EACzB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,UAAU,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,CAAC,CAYZ"}
package/dist/utils.js ADDED
@@ -0,0 +1,31 @@
1
+ export async function withTimeout(promise, timeoutMs) {
2
+ if (!timeoutMs || timeoutMs <= 0) {
3
+ return promise;
4
+ }
5
+ let timer;
6
+ const timeoutPromise = new Promise((_, reject) => {
7
+ timer = setTimeout(() => {
8
+ reject(new Error(`Execution timed out after ${timeoutMs}ms`));
9
+ }, timeoutMs);
10
+ });
11
+ try {
12
+ return await Promise.race([promise, timeoutPromise]);
13
+ }
14
+ finally {
15
+ if (timer)
16
+ clearTimeout(timer);
17
+ }
18
+ }
19
+ export async function retry(fn, retryCount) {
20
+ let lastError;
21
+ for (let attempt = 0; attempt <= retryCount; attempt++) {
22
+ try {
23
+ return await fn();
24
+ }
25
+ catch (error) {
26
+ lastError = error;
27
+ }
28
+ }
29
+ throw lastError instanceof Error ? lastError : new Error(String(lastError));
30
+ }
31
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,WAAW,CAC7B,OAAmB,EACnB,SAAkB;IAElB,IAAI,CAAC,SAAS,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QAC/B,OAAO,OAAO,CAAA;IAClB,CAAC;IAED,IAAI,KAAgD,CAAA;IAEpD,MAAM,cAAc,GAAG,IAAI,OAAO,CAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;QAChD,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YACpB,MAAM,CAAC,IAAI,KAAK,CAAC,6BAA6B,SAAS,IAAI,CAAC,CAAC,CAAA;QACjE,CAAC,EAAE,SAAS,CAAC,CAAA;IACjB,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC;QACD,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAA;IACxD,CAAC;YAAS,CAAC;QACP,IAAI,KAAK;YAAE,YAAY,CAAC,KAAK,CAAC,CAAA;IAClC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,KAAK,CACvB,EAAoB,EACpB,UAAkB;IAElB,IAAI,SAAkB,CAAA;IAEtB,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC;QACrD,IAAI,CAAC;YACD,OAAO,MAAM,EAAE,EAAE,CAAA;QACrB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,SAAS,GAAG,KAAK,CAAA;QACrB,CAAC;IACL,CAAC;IAED,MAAM,SAAS,YAAY,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAA;AAC/E,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Workflow, WorkflowStep } from "./types";
2
+ export declare function createWorkflow(steps: WorkflowStep[], workflowId?: string): Workflow;
3
+ //# sourceMappingURL=workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AA8BhD,wBAAgB,cAAc,CAC1B,KAAK,EAAE,YAAY,EAAE,EACrB,UAAU,SAAa,GACxB,QAAQ,CAOV"}
@@ -0,0 +1,30 @@
1
+ function validateWorkflowSteps(steps) {
2
+ const ids = new Set();
3
+ for (const step of steps) {
4
+ if (!step.id) {
5
+ throw new Error("Each workflow step must have an id");
6
+ }
7
+ if (!step.tool) {
8
+ throw new Error(`Workflow step "${step.id}" must have a tool`);
9
+ }
10
+ if (ids.has(step.id)) {
11
+ throw new Error(`Duplicate workflow step id: ${step.id}`);
12
+ }
13
+ ids.add(step.id);
14
+ }
15
+ for (const step of steps) {
16
+ for (const dep of step.dependsOn ?? []) {
17
+ if (!ids.has(dep)) {
18
+ throw new Error(`Step "${step.id}" depends on missing step "${dep}"`);
19
+ }
20
+ }
21
+ }
22
+ }
23
+ export function createWorkflow(steps, workflowId = "workflow") {
24
+ validateWorkflowSteps(steps);
25
+ return {
26
+ id: workflowId,
27
+ steps
28
+ };
29
+ }
30
+ //# sourceMappingURL=workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.js","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAEA,SAAS,qBAAqB,CAAC,KAAqB;IAChD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAA;IAE7B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAA;QACzD,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,CAAC,EAAE,oBAAoB,CAAC,CAAA;QAClE,CAAC;QAED,IAAI,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,+BAA+B,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;QAC7D,CAAC;QAED,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACpB,CAAC;IAED,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACvB,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS,IAAI,EAAE,EAAE,CAAC;YACrC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAChB,MAAM,IAAI,KAAK,CAAC,SAAS,IAAI,CAAC,EAAE,8BAA8B,GAAG,GAAG,CAAC,CAAA;YACzE,CAAC;QACL,CAAC;IACL,CAAC;AACL,CAAC;AAED,MAAM,UAAU,cAAc,CAC1B,KAAqB,EACrB,UAAU,GAAG,UAAU;IAEvB,qBAAqB,CAAC,KAAK,CAAC,CAAA;IAE5B,OAAO;QACH,EAAE,EAAE,UAAU;QACd,KAAK;KACR,CAAA;AACL,CAAC"}
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "shrimsource",
3
+ "version": "0.1.0",
4
+ "description": "A lightweight AI agent workflow framework",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "test": "vitest run",
20
+ "test:watch": "vitest",
21
+ "typecheck": "tsc --noEmit"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^25.3.5",
25
+ "typescript": "^5.7.0",
26
+ "vitest": "^3.0.0"
27
+ },
28
+ "license": "MIT"
29
+ }