project-graph-mcp 2.3.0 → 2.3.2

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 (66) hide show
  1. package/package.json +1 -3
  2. package/project-graph-mcp-2.3.0.tgz +0 -0
  3. package/src/network/web-server.js +1 -1
  4. package/vendor/symbiote-node/engine/AgentUICommands.js +100 -0
  5. package/vendor/symbiote-node/engine/Executor.js +371 -0
  6. package/vendor/symbiote-node/engine/Graph.js +314 -0
  7. package/vendor/symbiote-node/engine/GraphServer.js +353 -0
  8. package/vendor/symbiote-node/engine/HandlerLoader.js +145 -0
  9. package/vendor/symbiote-node/engine/History.js +83 -0
  10. package/vendor/symbiote-node/engine/Lifecycle.js +118 -0
  11. package/vendor/symbiote-node/engine/Persistence.js +84 -0
  12. package/vendor/symbiote-node/engine/Registry.js +264 -0
  13. package/vendor/symbiote-node/engine/SocketTypes.js +79 -0
  14. package/vendor/symbiote-node/engine/cli.js +404 -0
  15. package/vendor/symbiote-node/engine/index.js +56 -0
  16. package/vendor/symbiote-node/engine/nanoid.js +28 -0
  17. package/vendor/symbiote-node/engine/package.json +26 -0
  18. package/vendor/symbiote-node/engine/packs/ai/beat-detect.handler.js +215 -0
  19. package/vendor/symbiote-node/engine/packs/ai/content-adapt.handler.js +238 -0
  20. package/vendor/symbiote-node/engine/packs/ai/face-detect.handler.js +287 -0
  21. package/vendor/symbiote-node/engine/packs/ai/grok-generate.handler.js +565 -0
  22. package/vendor/symbiote-node/engine/packs/ai/kling-lipsync.handler.js +414 -0
  23. package/vendor/symbiote-node/engine/packs/ai/lesson-generate.handler.js +343 -0
  24. package/vendor/symbiote-node/engine/packs/ai/opencode.handler.js +164 -0
  25. package/vendor/symbiote-node/engine/packs/ai/replicate-lipsync.handler.js +341 -0
  26. package/vendor/symbiote-node/engine/packs/ai/tts.handler.js +241 -0
  27. package/vendor/symbiote-node/engine/packs/ai/whisper.handler.js +191 -0
  28. package/vendor/symbiote-node/engine/packs/data/db-query.handler.js +67 -0
  29. package/vendor/symbiote-node/engine/packs/data/news-accumulate.handler.js +281 -0
  30. package/vendor/symbiote-node/engine/packs/data/personas.handler.js +160 -0
  31. package/vendor/symbiote-node/engine/packs/data/prompt-loader.handler.js +193 -0
  32. package/vendor/symbiote-node/engine/packs/data/roles.handler.js +216 -0
  33. package/vendor/symbiote-node/engine/packs/data/rss-feed.handler.js +244 -0
  34. package/vendor/symbiote-node/engine/packs/debug/inject.handler.js +52 -0
  35. package/vendor/symbiote-node/engine/packs/flow/agent.handler.js +73 -0
  36. package/vendor/symbiote-node/engine/packs/flow/if.handler.js +107 -0
  37. package/vendor/symbiote-node/engine/packs/flow/loop.handler.js +58 -0
  38. package/vendor/symbiote-node/engine/packs/flow/merge.handler.js +60 -0
  39. package/vendor/symbiote-node/engine/packs/flow/retry.handler.js +65 -0
  40. package/vendor/symbiote-node/engine/packs/flow/switch.handler.js +64 -0
  41. package/vendor/symbiote-node/engine/packs/flow/wait-all.handler.js +39 -0
  42. package/vendor/symbiote-node/engine/packs/io/http-request.handler.js +82 -0
  43. package/vendor/symbiote-node/engine/packs/io/read-file.handler.js +60 -0
  44. package/vendor/symbiote-node/engine/packs/io/write-file.handler.js +63 -0
  45. package/vendor/symbiote-node/engine/packs/transform/anchor-match.handler.js +494 -0
  46. package/vendor/symbiote-node/engine/packs/transform/effects-skeleton.handler.js +417 -0
  47. package/vendor/symbiote-node/engine/packs/transform/json-parse.handler.js +43 -0
  48. package/vendor/symbiote-node/engine/packs/transform/lipsync-select.handler.js +339 -0
  49. package/vendor/symbiote-node/engine/packs/transform/riopla-adapt.handler.js +432 -0
  50. package/vendor/symbiote-node/engine/packs/transform/set.handler.js +57 -0
  51. package/vendor/symbiote-node/engine/packs/transform/template-builder.handler.js +134 -0
  52. package/vendor/symbiote-node/engine/packs/transform/template.handler.js +79 -0
  53. package/vendor/symbiote-node/engine/packs/transform/timeline-build.handler.js +399 -0
  54. package/vendor/symbiote-node/engine/packs/util/delay.handler.js +39 -0
  55. package/vendor/symbiote-node/engine/packs/util/log.handler.js +44 -0
  56. package/vendor/symbiote-node/engine/packs/video-pack.js +323 -0
  57. package/vendor/symbiote-node/package.json +2 -2
  58. package/web/app.js +6 -3
  59. package/web/components/canvas-graph.js +50 -11
  60. package/web/components/code-block.js +1 -1
  61. package/web/components/event-feed/MiniGraphWidget.js +105 -15
  62. package/web/components/follow-ribbon.js +134 -0
  63. package/web/follow-controller.js +241 -0
  64. package/web/panels/code-viewer.js +1 -1
  65. package/web/panels/dep-graph.js +21 -42
  66. package/web/style.css +6 -0
@@ -0,0 +1,52 @@
1
+ /**
2
+ * debug/inject — Manual data injection node.
3
+ *
4
+ * Provides a textarea for arbitrary JSON data and a Fire button
5
+ * to push data downstream. Use for testing any part of a workflow
6
+ * by connecting to the target node's input.
7
+ *
8
+ * @module symbiote-node/packs/debug/inject
9
+ */
10
+
11
+ export default {
12
+ type: 'debug/inject',
13
+ category: 'debug',
14
+ icon: 'play_circle',
15
+
16
+ driver: {
17
+ description: 'Inject test data — connect to any node input for manual testing',
18
+ capabilities: ['debug', 'trigger'],
19
+ inputs: [],
20
+ outputs: [
21
+ { name: 'data', type: 'exec' },
22
+ ],
23
+ params: {
24
+ label: { type: 'string', default: 'Test Data', description: 'Display label' },
25
+ data: { type: 'textarea', default: '{\n "status": "created",\n "region": "RU",\n "smsCount": 100,\n "clientName": "Test Client"\n}', description: 'JSON payload to inject' },
26
+ },
27
+ /** Mark as fireable — UI shows ▶ Fire button */
28
+ fireable: true,
29
+ },
30
+
31
+ lifecycle: {
32
+ validate: (inputs, params) => {
33
+ try {
34
+ JSON.parse(params.data || '{}');
35
+ return true;
36
+ } catch {
37
+ return false;
38
+ }
39
+ },
40
+
41
+ async execute(inputs, params) {
42
+ let payload;
43
+ try {
44
+ payload = JSON.parse(params.data || '{}');
45
+ } catch {
46
+ return { data: { error: 'Invalid JSON in inject data' } };
47
+ }
48
+
49
+ return { data: payload };
50
+ },
51
+ },
52
+ };
@@ -0,0 +1,73 @@
1
+ /**
2
+ * flow/agent — AI Agent trigger node
3
+ *
4
+ * Pauses graph execution and invokes an AI agent with prompt + context.
5
+ * The agent bridge is injected via params.agentBridge or a global registry.
6
+ * Without a bridge, returns a placeholder indicating agent invocation is needed.
7
+ *
8
+ * @module symbiote-node/packs/flow/agent */
9
+
10
+ export default {
11
+ type: 'flow/agent',
12
+ category: 'flow',
13
+ icon: 'smart_toy',
14
+
15
+ driver: {
16
+ description: 'AI Agent trigger — invoke agent in pipeline',
17
+ inputs: [
18
+ { name: 'prompt', type: 'string' },
19
+ { name: 'context', type: 'any' },
20
+ ],
21
+ outputs: [
22
+ { name: 'result', type: 'any' },
23
+ { name: 'error', type: 'string' },
24
+ ],
25
+ params: {
26
+ timeout: { type: 'int', default: 30000, description: 'Agent timeout (ms)' },
27
+ allowedTools: { type: 'array', default: [], description: 'Tools the agent can use' },
28
+ model: { type: 'string', default: '', description: 'AI model override' },
29
+ },
30
+ },
31
+
32
+ lifecycle: {
33
+ validate: (inputs) => {
34
+ if (!inputs.prompt) return false;
35
+ return true;
36
+ },
37
+
38
+ cacheKey: (inputs) => `agent:${inputs.prompt}:${JSON.stringify(inputs.context)}`,
39
+
40
+ execute: async (inputs, params) => {
41
+ const { prompt, context } = inputs;
42
+ const { timeout, allowedTools, model } = params;
43
+
44
+ // Check if agentBridge is available (injected via params or global)
45
+ const bridge = params._agentBridge || globalThis.__symbioteNodeAgentBridge;
46
+ if (!bridge) {
47
+ // No bridge available — return pending marker
48
+ return {
49
+ result: {
50
+ _agentPending: true,
51
+ prompt,
52
+ context,
53
+ message: 'Agent bridge not connected. Connect via WebSocket (P23) to enable.',
54
+ },
55
+ error: null,
56
+ };
57
+ }
58
+
59
+ try {
60
+ const response = await Promise.race([
61
+ bridge.run({ prompt, context, tools: allowedTools, model }),
62
+ new Promise((_, reject) =>
63
+ setTimeout(() => reject(new Error('Agent timeout')), timeout)
64
+ ),
65
+ ]);
66
+
67
+ return { result: response.data, error: null };
68
+ } catch (err) {
69
+ return { result: null, error: err.message };
70
+ }
71
+ },
72
+ },
73
+ };
@@ -0,0 +1,107 @@
1
+ /**
2
+ * flow/if — Conditional branching node
3
+ *
4
+ * Routes data to 'true' or 'false' output based on condition.
5
+ * Condition can be a boolean input or a simple expression string.
6
+ *
7
+ * @module agi-graph/packs/flow/if
8
+ */
9
+
10
+ /**
11
+ * Evaluate a simple condition expression
12
+ * Supports: ==, !=, >, <, >=, <=, ===, !==
13
+ * @param {*} value - Value to test
14
+ * @param {string} expression - Expression string
15
+ * @returns {boolean}
16
+ */
17
+ function evaluateCondition(value, expression) {
18
+ if (typeof expression === 'boolean') return expression;
19
+ if (typeof expression === 'string') {
20
+ const trimmed = expression.trim();
21
+
22
+ // Direct boolean strings
23
+ if (trimmed === 'true') return true;
24
+ if (trimmed === 'false') return false;
25
+
26
+ // Null checks
27
+ if (trimmed === 'data != null' || trimmed === 'data !== null') return value != null;
28
+ if (trimmed === 'data == null' || trimmed === 'data === null') return value == null;
29
+
30
+ // Comparison operators
31
+ const match = trimmed.match(/^(.+?)\s*(===|!==|==|!=|>=|<=|>|<)\s*(.+)$/);
32
+ if (match) {
33
+ let [, left, op, right] = match;
34
+ left = left.trim();
35
+ right = right.trim();
36
+
37
+ // Resolve left side
38
+ const leftVal = left === 'data' || left === 'value' ? value : parseValueLiteral(left);
39
+ const rightVal = parseValueLiteral(right);
40
+
41
+ switch (op) {
42
+ case '===': return leftVal === rightVal;
43
+ case '!==': return leftVal !== rightVal;
44
+ case '==': return leftVal == rightVal;
45
+ case '!=': return leftVal != rightVal;
46
+ case '>': return leftVal > rightVal;
47
+ case '<': return leftVal < rightVal;
48
+ case '>=': return leftVal >= rightVal;
49
+ case '<=': return leftVal <= rightVal;
50
+ }
51
+ }
52
+ }
53
+
54
+ // Fallback: truthy check
55
+ return !!value;
56
+ }
57
+
58
+ /**
59
+ * Parse a literal value from condition string
60
+ * @param {string} str
61
+ * @returns {*}
62
+ */
63
+ function parseValueLiteral(str) {
64
+ if (str === 'null') return null;
65
+ if (str === 'undefined') return undefined;
66
+ if (str === 'true') return true;
67
+ if (str === 'false') return false;
68
+ if (str.startsWith("'") && str.endsWith("'")) return str.slice(1, -1);
69
+ if (str.startsWith('"') && str.endsWith('"')) return str.slice(1, -1);
70
+ const num = Number(str);
71
+ if (!isNaN(num)) return num;
72
+ return str;
73
+ }
74
+
75
+ export default {
76
+ type: 'flow/if',
77
+ category: 'flow',
78
+ icon: 'call_split',
79
+
80
+ driver: {
81
+ description: 'Conditional branch — routes data by condition',
82
+ inputs: [
83
+ { name: 'condition', type: 'any' },
84
+ { name: 'data', type: 'any' },
85
+ ],
86
+ outputs: [
87
+ { name: 'true', type: 'any' },
88
+ { name: 'false', type: 'any' },
89
+ ],
90
+ params: {
91
+ expression: { type: 'string', default: '', description: 'Condition expression (optional, overrides condition input)' },
92
+ },
93
+ },
94
+
95
+ lifecycle: {
96
+ validate: (inputs) => inputs.data !== undefined,
97
+ execute: (inputs, params) => {
98
+ const condValue = params.expression
99
+ ? evaluateCondition(inputs.data, params.expression)
100
+ : !!inputs.condition;
101
+
102
+ return condValue
103
+ ? { true: inputs.data, false: null }
104
+ : { true: null, false: inputs.data };
105
+ },
106
+ },
107
+ };
@@ -0,0 +1,58 @@
1
+ /**
2
+ * flow/loop — Iteration node
3
+ *
4
+ * Iterates over an array, executing a body function for each item.
5
+ * The bodyType param specifies which registered node type to execute per item.
6
+ *
7
+ * @module agi-graph/packs/flow/loop
8
+ */
9
+
10
+ import { getNodeType } from '../../Registry.js';
11
+
12
+ export default {
13
+ type: 'flow/loop',
14
+ category: 'flow',
15
+ icon: 'loop',
16
+
17
+ driver: {
18
+ description: 'Iterate over array — execute body per item',
19
+ inputs: [
20
+ { name: 'items', type: 'array' },
21
+ ],
22
+ outputs: [
23
+ { name: 'results', type: 'array' },
24
+ ],
25
+ params: {
26
+ bodyType: { type: 'string', default: '', description: 'Node type to execute per item' },
27
+ },
28
+ },
29
+
30
+ lifecycle: {
31
+ validate: (inputs) => Array.isArray(inputs.items),
32
+ execute: async (inputs, params) => {
33
+ const { items } = inputs;
34
+ const { bodyType } = params;
35
+ const results = [];
36
+
37
+ if (!bodyType) {
38
+ // No body type: return items as-is
39
+ return { results: items };
40
+ }
41
+
42
+ const typeDef = getNodeType(bodyType);
43
+ const executeFn = typeDef?.lifecycle?.execute || typeDef?.process;
44
+
45
+ if (!executeFn) {
46
+ return { results: items };
47
+ }
48
+
49
+ for (let i = 0; i < items.length; i++) {
50
+ const itemInput = { value: items[i], index: i, total: items.length };
51
+ const itemResult = await executeFn(itemInput, params);
52
+ results.push(itemResult);
53
+ }
54
+
55
+ return { results };
56
+ },
57
+ },
58
+ };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * flow/merge — Multi-input data merge node
3
+ *
4
+ * Combines data from multiple inputs (a, b) into a single output.
5
+ * Supports three modes:
6
+ * - 'first' (default): returns first non-null input (branch merge after IF)
7
+ * - 'combine': Object.assign all non-null inputs (deep merge)
8
+ * - 'append': collect all non-null inputs into an array
9
+ *
10
+ * @module symbiote-node/packs/flow/merge
11
+ */
12
+
13
+ export default {
14
+ type: 'flow/merge',
15
+ category: 'flow',
16
+ icon: 'merge',
17
+
18
+ driver: {
19
+ description: 'Merge branches — combine data from multiple inputs',
20
+ inputs: [
21
+ { name: 'a', type: 'any' },
22
+ { name: 'b', type: 'any' },
23
+ ],
24
+ outputs: [
25
+ { name: 'data', type: 'any' },
26
+ ],
27
+ params: {
28
+ mode: {
29
+ type: 'string',
30
+ default: 'first',
31
+ description: 'first = first non-null, combine = Object.assign, append = array',
32
+ },
33
+ },
34
+ },
35
+
36
+ lifecycle: {
37
+ execute: (inputs, params) => {
38
+ const mode = params?.mode || 'first';
39
+
40
+ if (mode === 'combine') {
41
+ const merged = {};
42
+ for (const value of Object.values(inputs)) {
43
+ if (value != null && typeof value === 'object') {
44
+ Object.assign(merged, value);
45
+ }
46
+ }
47
+ return { data: merged };
48
+ }
49
+
50
+ if (mode === 'append') {
51
+ const items = Object.values(inputs).filter(v => v != null);
52
+ return { data: items };
53
+ }
54
+
55
+ // Default: 'first' — first non-null input
56
+ const data = inputs.a != null ? inputs.a : inputs.b;
57
+ return { data };
58
+ },
59
+ },
60
+ };
@@ -0,0 +1,65 @@
1
+ /**
2
+ * flow/retry — Retry on error node
3
+ *
4
+ * If input has an error, re-invokes the action up to maxRetries times.
5
+ * Passes through successful results immediately.
6
+ *
7
+ * @module agi-graph/packs/flow/retry
8
+ */
9
+
10
+ export default {
11
+ type: 'flow/retry',
12
+ category: 'flow',
13
+ icon: 'refresh',
14
+
15
+ driver: {
16
+ description: 'Retry action on error — up to N attempts',
17
+ inputs: [
18
+ { name: 'action', type: 'any' },
19
+ { name: 'error', type: 'any' },
20
+ ],
21
+ outputs: [
22
+ { name: 'result', type: 'any' },
23
+ { name: 'error', type: 'string' },
24
+ ],
25
+ params: {
26
+ maxRetries: { type: 'int', default: 3, description: 'Maximum retry attempts' },
27
+ delay: { type: 'int', default: 1000, description: 'Delay between retries (ms)' },
28
+ },
29
+ },
30
+
31
+ lifecycle: {
32
+ execute: async (inputs, params) => {
33
+ // If no error, pass through the action result
34
+ if (inputs.error == null && inputs.action != null) {
35
+ return { result: inputs.action, error: null };
36
+ }
37
+
38
+ // If error but no actionFn to retry, propagate error
39
+ if (inputs.action?._retryFn) {
40
+ const { maxRetries, delay } = params;
41
+ let lastError = inputs.error;
42
+
43
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
44
+ if (delay > 0 && attempt > 1) {
45
+ await new Promise(r => setTimeout(r, delay));
46
+ }
47
+ try {
48
+ const result = await inputs.action._retryFn();
49
+ return { result, error: null };
50
+ } catch (err) {
51
+ lastError = err.message;
52
+ }
53
+ }
54
+
55
+ return { result: null, error: `Failed after ${maxRetries} retries: ${lastError}` };
56
+ }
57
+
58
+ // No retry function available, pass through with error
59
+ return {
60
+ result: inputs.action,
61
+ error: inputs.error ? String(inputs.error) : null,
62
+ };
63
+ },
64
+ },
65
+ };
@@ -0,0 +1,64 @@
1
+ /**
2
+ * flow/switch — Multi-branch routing node
3
+ *
4
+ * Routes data to one of N case outputs based on value match.
5
+ * Falls back to 'default' output if no case matches.
6
+ *
7
+ * @module agi-graph/packs/flow/switch
8
+ */
9
+
10
+ export default {
11
+ type: 'flow/switch',
12
+ category: 'flow',
13
+ icon: 'alt_route',
14
+
15
+ driver: {
16
+ description: 'Multi-branch routing by value match',
17
+ inputs: [
18
+ { name: 'value', type: 'any' },
19
+ { name: 'data', type: 'any' },
20
+ ],
21
+ outputs: [
22
+ { name: 'default', type: 'any' },
23
+ ],
24
+ params: {
25
+ cases: { type: 'object', default: {}, description: 'Map of value → output name' },
26
+ },
27
+ },
28
+
29
+ lifecycle: {
30
+ validate: (inputs) => inputs.data !== undefined,
31
+ execute: (inputs, params) => {
32
+ const { data } = inputs;
33
+ // Auto-extract value from data[field] when no explicit value input
34
+ const value = inputs.value !== undefined
35
+ ? inputs.value
36
+ : (params.field && data ? data[params.field] : undefined);
37
+ const cases = params.cases;
38
+ const hasCases = cases && Object.keys(cases).length > 0;
39
+ const result = { default: null };
40
+
41
+ if (hasCases) {
42
+ // Explicit cases mode: value → mapped output name
43
+ for (const outputName of Object.values(cases)) {
44
+ result[outputName] = null;
45
+ }
46
+ const stringValue = String(value);
47
+ const matchedOutput = cases[stringValue];
48
+ if (matchedOutput) {
49
+ result[matchedOutput] = data;
50
+ result.dynamicOutputs = Object.values(cases);
51
+ } else {
52
+ result.default = data;
53
+ }
54
+ } else {
55
+ // Direct routing: value IS the output name (e.g. 'created' → output 'created')
56
+ const outputName = String(value);
57
+ result[outputName] = data;
58
+ result.dynamicOutputs = [outputName];
59
+ }
60
+
61
+ return result;
62
+ },
63
+ },
64
+ };
@@ -0,0 +1,39 @@
1
+ /**
2
+ * flow/wait-all — Barrier node
3
+ *
4
+ * Waits for all non-null inputs and merges them into a single object.
5
+ * Acts as a synchronization point for parallel branches.
6
+ *
7
+ * @module agi-graph/packs/flow/wait-all
8
+ */
9
+
10
+ export default {
11
+ type: 'flow/wait-all',
12
+ category: 'flow',
13
+ icon: 'join',
14
+
15
+ driver: {
16
+ description: 'Barrier — merge all inputs into one object',
17
+ inputs: [
18
+ { name: 'a', type: 'any' },
19
+ { name: 'b', type: 'any' },
20
+ { name: 'c', type: 'any' },
21
+ ],
22
+ outputs: [
23
+ { name: 'output', type: 'object' },
24
+ ],
25
+ params: {},
26
+ },
27
+
28
+ lifecycle: {
29
+ execute: (inputs) => {
30
+ const output = {};
31
+ for (const [key, val] of Object.entries(inputs)) {
32
+ if (val != null) {
33
+ output[key] = val;
34
+ }
35
+ }
36
+ return { output };
37
+ },
38
+ },
39
+ };
@@ -0,0 +1,82 @@
1
+ /**
2
+ * io/http-request — Universal HTTP client node
3
+ *
4
+ * Performs HTTP requests using native fetch API.
5
+ * Supports GET, POST, PUT, DELETE with configurable headers and timeout.
6
+ *
7
+ * @module agi-graph/packs/io/http-request
8
+ */
9
+
10
+ export default {
11
+ type: 'io/http-request',
12
+ category: 'io',
13
+ icon: 'http',
14
+
15
+ driver: {
16
+ description: 'HTTP request (fetch) — GET, POST, PUT, DELETE',
17
+ inputs: [
18
+ { name: 'url', type: 'string' },
19
+ { name: 'body', type: 'any' },
20
+ ],
21
+ outputs: [
22
+ { name: 'response', type: 'any' },
23
+ { name: 'status', type: 'number' },
24
+ { name: 'error', type: 'string' },
25
+ ],
26
+ params: {
27
+ method: { type: 'string', default: 'GET', description: 'HTTP method' },
28
+ headers: { type: 'object', default: {}, description: 'Request headers' },
29
+ timeout: { type: 'int', default: 30000, description: 'Timeout (ms)' },
30
+ responseType: { type: 'string', default: 'auto', description: 'json | text | auto' },
31
+ },
32
+ },
33
+
34
+ lifecycle: {
35
+ validate: (inputs) => {
36
+ if (!inputs.url) return false;
37
+ return true;
38
+ },
39
+
40
+ cacheKey: (inputs, params) =>
41
+ `http:${params.method}:${inputs.url}:${JSON.stringify(inputs.body)}`,
42
+
43
+ execute: async (inputs, params) => {
44
+ const { url, body } = inputs;
45
+ const { method, headers, timeout, responseType } = params;
46
+
47
+ try {
48
+ const fetchOptions = {
49
+ method: method || 'GET',
50
+ headers: { ...headers },
51
+ signal: AbortSignal.timeout(timeout),
52
+ };
53
+
54
+ if (body && method !== 'GET' && method !== 'HEAD') {
55
+ if (typeof body === 'object') {
56
+ fetchOptions.body = JSON.stringify(body);
57
+ fetchOptions.headers['Content-Type'] =
58
+ fetchOptions.headers['Content-Type'] || 'application/json';
59
+ } else {
60
+ fetchOptions.body = String(body);
61
+ }
62
+ }
63
+
64
+ const res = await fetch(url, fetchOptions);
65
+
66
+ let response;
67
+ const contentType = res.headers.get('content-type') || '';
68
+
69
+ if (responseType === 'json' || (responseType === 'auto' && contentType.includes('json'))) {
70
+ response = await res.json();
71
+ } else {
72
+ response = await res.text();
73
+ }
74
+
75
+ return { response, status: res.status, error: null };
76
+
77
+ } catch (err) {
78
+ return { response: null, status: 0, error: err.message };
79
+ }
80
+ },
81
+ },
82
+ };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * io/read-file — Read file contents
3
+ *
4
+ * Reads a file from disk. Auto-parses JSON files.
5
+ *
6
+ * @module agi-graph/packs/io/read-file
7
+ */
8
+
9
+ import { promises as fs } from 'fs';
10
+
11
+ export default {
12
+ type: 'io/read-file',
13
+ category: 'io',
14
+ icon: 'file_open',
15
+
16
+ driver: {
17
+ description: 'Read file from disk (auto-parses JSON)',
18
+ inputs: [
19
+ { name: 'path', type: 'string' },
20
+ ],
21
+ outputs: [
22
+ { name: 'content', type: 'string' },
23
+ { name: 'parsed', type: 'any' },
24
+ { name: 'error', type: 'string' },
25
+ ],
26
+ params: {
27
+ encoding: { type: 'string', default: 'utf8', description: 'File encoding' },
28
+ },
29
+ },
30
+
31
+ lifecycle: {
32
+ validate: (inputs) => {
33
+ if (!inputs.path) return false;
34
+ return true;
35
+ },
36
+
37
+ // No caching — file content may change
38
+ cacheKey: null,
39
+
40
+ execute: async (inputs, params) => {
41
+ try {
42
+ const content = await fs.readFile(inputs.path, params.encoding || 'utf8');
43
+
44
+ let parsed = null;
45
+ if (inputs.path.endsWith('.json')) {
46
+ try {
47
+ parsed = JSON.parse(content);
48
+ } catch {
49
+ // Not valid JSON
50
+ }
51
+ }
52
+
53
+ return { content, parsed, error: null };
54
+
55
+ } catch (err) {
56
+ return { content: null, parsed: null, error: err.message };
57
+ }
58
+ },
59
+ },
60
+ };