@elizaos/app-core 2.0.0-alpha.335 → 2.0.0-alpha.337
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/apps/app-lifeops/src/routes/lifeops-routes.d.ts.map +1 -1
- package/apps/app-lifeops/src/routes/lifeops-routes.js +10 -1
- package/i18n/locales/en.json +5 -5
- package/package.json +5 -5
- package/packages/agent/src/runtime/eliza.d.ts.map +1 -1
- package/packages/agent/src/runtime/eliza.js +7 -2
- package/packages/app-core/src/api/automations-compat-routes.js +1 -1
- package/packages/app-core/src/api/client-n8n.d.ts +4 -1
- package/packages/app-core/src/api/client-n8n.d.ts.map +1 -1
- package/packages/app-core/src/api/client-n8n.js +18 -0
- package/packages/app-core/src/api/client-types-chat.d.ts +37 -0
- package/packages/app-core/src/api/client-types-chat.d.ts.map +1 -1
- package/packages/app-core/src/api/n8n-routes.d.ts +6 -0
- package/packages/app-core/src/api/n8n-routes.d.ts.map +1 -1
- package/packages/app-core/src/api/n8n-routes.js +334 -0
- package/packages/app-core/src/components/character/CharacterEditorPanels.d.ts.map +1 -1
- package/packages/app-core/src/components/character/CharacterEditorPanels.js +192 -85
- package/packages/app-core/src/components/character/CharacterExperienceWorkspace.d.ts.map +1 -1
- package/packages/app-core/src/components/character/CharacterExperienceWorkspace.js +182 -31
- package/packages/app-core/src/components/character/CharacterHubView.d.ts.map +1 -1
- package/packages/app-core/src/components/character/CharacterHubView.js +253 -23
- package/packages/app-core/src/components/character/CharacterOverviewSection.d.ts +14 -1
- package/packages/app-core/src/components/character/CharacterOverviewSection.d.ts.map +1 -1
- package/packages/app-core/src/components/character/CharacterOverviewSection.js +35 -8
- package/packages/app-core/src/components/character/character-hub-helpers.d.ts.map +1 -1
- package/packages/app-core/src/components/character/character-hub-helpers.js +3 -7
- package/packages/app-core/src/components/pages/AutomationsView.d.ts.map +1 -1
- package/packages/app-core/src/components/pages/AutomationsView.js +523 -274
- package/packages/app-core/src/components/pages/HeartbeatForm.d.ts.map +1 -1
- package/packages/app-core/src/components/pages/HeartbeatForm.js +11 -13
- package/packages/app-core/src/components/pages/KnowledgeView.d.ts.map +1 -1
- package/packages/app-core/src/components/pages/KnowledgeView.js +20 -6
- package/packages/app-core/src/components/pages/RelationshipsGraphPanel.d.ts +2 -1
- package/packages/app-core/src/components/pages/RelationshipsGraphPanel.d.ts.map +1 -1
- package/packages/app-core/src/components/pages/RelationshipsGraphPanel.js +3 -3
- package/packages/app-core/src/components/pages/WorkflowGraphViewer.d.ts +0 -9
- package/packages/app-core/src/components/pages/WorkflowGraphViewer.d.ts.map +1 -1
- package/packages/app-core/src/components/pages/WorkflowGraphViewer.js +52 -26
- package/packages/app-core/src/components/pages/knowledge-detail.d.ts.map +1 -1
- package/packages/app-core/src/components/pages/knowledge-detail.js +28 -2
- package/packages/app-core/src/components/pages/page-scoped-conversations.d.ts +1 -1
- package/packages/app-core/src/components/pages/page-scoped-conversations.js +4 -4
- package/packages/app-core/src/components/pages/relationships/RelationshipsPersonPanels.d.ts +2 -1
- package/packages/app-core/src/components/pages/relationships/RelationshipsPersonPanels.d.ts.map +1 -1
- package/packages/app-core/src/components/pages/relationships/RelationshipsPersonPanels.js +69 -32
- package/packages/app-core/src/components/pages/relationships/RelationshipsSidebar.d.ts +1 -6
- package/packages/app-core/src/components/pages/relationships/RelationshipsSidebar.d.ts.map +1 -1
- package/packages/app-core/src/components/pages/relationships/RelationshipsSidebar.js +4 -4
- package/packages/app-core/src/components/pages/relationships/RelationshipsWorkspaceView.d.ts +2 -1
- package/packages/app-core/src/components/pages/relationships/RelationshipsWorkspaceView.d.ts.map +1 -1
- package/packages/app-core/src/components/pages/relationships/RelationshipsWorkspaceView.js +25 -15
- package/packages/app-core/src/i18n/locales/en.json +5 -5
- package/packages/app-core/src/registry/generate-apps.js +2 -2
- package/packages/app-core/src/runtime/eliza.d.ts.map +1 -1
- package/packages/app-core/src/runtime/eliza.js +6 -1
- package/packages/app-core/src/services/n8n-dispatch.d.ts +10 -2
- package/packages/app-core/src/services/n8n-dispatch.d.ts.map +1 -1
- package/packages/app-core/src/services/n8n-dispatch.js +102 -8
- package/packages/shared/src/contracts/lifeops.d.ts +4 -0
- package/packages/shared/src/contracts/lifeops.d.ts.map +1 -1
- package/packages/typescript/src/features/advanced-capabilities/clipboard/services/clipboardService.d.ts.map +1 -1
- package/packages/typescript/src/features/advanced-capabilities/clipboard/services/clipboardService.js +6 -1
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* GET /api/n8n/status — mode + sidecar state
|
|
6
6
|
* POST /api/n8n/sidecar/start — fire-and-forget sidecar boot
|
|
7
7
|
* GET /api/n8n/workflows — list workflows
|
|
8
|
+
* POST /api/n8n/workflows — create workflow
|
|
9
|
+
* POST /api/n8n/workflows/generate — generate + create/update workflow
|
|
10
|
+
* PUT /api/n8n/workflows/{id} — update workflow
|
|
8
11
|
* POST /api/n8n/workflows/{id}/activate — activate workflow
|
|
9
12
|
* POST /api/n8n/workflows/{id}/deactivate — deactivate workflow
|
|
10
13
|
* DELETE /api/n8n/workflows/{id} — delete workflow
|
|
@@ -27,6 +30,7 @@
|
|
|
27
30
|
import { logger } from "@elizaos/core";
|
|
28
31
|
import { isNativeServerPlatform } from "../platform/is-native-server";
|
|
29
32
|
import { resolveN8nMode } from "../services/n8n-mode";
|
|
33
|
+
import { readCompatJsonBody } from "./compat-route-shared";
|
|
30
34
|
// ── Cloud health probe ──────────────────────────────────────────────────────
|
|
31
35
|
//
|
|
32
36
|
// Probes `${cloudBaseUrl}/api/v1/health` with a 2s timeout and caches the
|
|
@@ -110,6 +114,9 @@ function sanitizeNode(n) {
|
|
|
110
114
|
...(typeof obj.id === "string" ? { id: obj.id } : {}),
|
|
111
115
|
...(typeof obj.name === "string" ? { name: obj.name } : {}),
|
|
112
116
|
...(typeof obj.type === "string" ? { type: obj.type } : {}),
|
|
117
|
+
...(typeof obj.typeVersion === "number"
|
|
118
|
+
? { typeVersion: obj.typeVersion }
|
|
119
|
+
: {}),
|
|
113
120
|
};
|
|
114
121
|
}
|
|
115
122
|
/**
|
|
@@ -137,6 +144,10 @@ function sanitizeNodeFull(n) {
|
|
|
137
144
|
...base,
|
|
138
145
|
...(position !== undefined ? { position } : {}),
|
|
139
146
|
...(parameters !== undefined ? { parameters } : {}),
|
|
147
|
+
...(typeof obj.notes === "string" ? { notes: obj.notes } : {}),
|
|
148
|
+
...(typeof obj.notesInFlow === "boolean"
|
|
149
|
+
? { notesInFlow: obj.notesInFlow }
|
|
150
|
+
: {}),
|
|
140
151
|
};
|
|
141
152
|
}
|
|
142
153
|
/** Normalize an n8n workflow payload to our client-facing shape. */
|
|
@@ -341,6 +352,247 @@ function extractWorkflowSingle(body) {
|
|
|
341
352
|
return obj.workflow;
|
|
342
353
|
return body;
|
|
343
354
|
}
|
|
355
|
+
function asRecord(value) {
|
|
356
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
357
|
+
? value
|
|
358
|
+
: null;
|
|
359
|
+
}
|
|
360
|
+
function readOptionalString(obj, key) {
|
|
361
|
+
const value = obj[key];
|
|
362
|
+
return typeof value === "string" && value.trim().length > 0
|
|
363
|
+
? value.trim()
|
|
364
|
+
: undefined;
|
|
365
|
+
}
|
|
366
|
+
function readOptionalBoolean(obj, key) {
|
|
367
|
+
const value = obj[key];
|
|
368
|
+
return typeof value === "boolean" ? value : undefined;
|
|
369
|
+
}
|
|
370
|
+
function readOptionalNumber(obj, key) {
|
|
371
|
+
const value = obj[key];
|
|
372
|
+
return typeof value === "number" && Number.isFinite(value)
|
|
373
|
+
? value
|
|
374
|
+
: undefined;
|
|
375
|
+
}
|
|
376
|
+
function readPosition(value) {
|
|
377
|
+
return Array.isArray(value) &&
|
|
378
|
+
value.length >= 2 &&
|
|
379
|
+
typeof value[0] === "number" &&
|
|
380
|
+
typeof value[1] === "number"
|
|
381
|
+
? [value[0], value[1]]
|
|
382
|
+
: null;
|
|
383
|
+
}
|
|
384
|
+
function readCredentials(value) {
|
|
385
|
+
const raw = asRecord(value);
|
|
386
|
+
if (!raw)
|
|
387
|
+
return undefined;
|
|
388
|
+
const credentials = {};
|
|
389
|
+
for (const [key, credentialValue] of Object.entries(raw)) {
|
|
390
|
+
const credential = asRecord(credentialValue);
|
|
391
|
+
if (!credential)
|
|
392
|
+
continue;
|
|
393
|
+
const id = readOptionalString(credential, "id");
|
|
394
|
+
const name = readOptionalString(credential, "name");
|
|
395
|
+
if (!id || !name)
|
|
396
|
+
continue;
|
|
397
|
+
credentials[key] = { id, name };
|
|
398
|
+
}
|
|
399
|
+
return Object.keys(credentials).length > 0 ? credentials : undefined;
|
|
400
|
+
}
|
|
401
|
+
function normalizeWorkflowWriteNode(value, index) {
|
|
402
|
+
const obj = asRecord(value);
|
|
403
|
+
if (!obj)
|
|
404
|
+
return null;
|
|
405
|
+
const name = readOptionalString(obj, "name");
|
|
406
|
+
const type = readOptionalString(obj, "type");
|
|
407
|
+
if (!name || !type)
|
|
408
|
+
return null;
|
|
409
|
+
const position = readPosition(obj.position) ?? [index * 260, 0];
|
|
410
|
+
const parameters = asRecord(obj.parameters) ?? {};
|
|
411
|
+
const typeVersion = readOptionalNumber(obj, "typeVersion") ?? 1;
|
|
412
|
+
const credentials = readCredentials(obj.credentials);
|
|
413
|
+
return {
|
|
414
|
+
...(readOptionalString(obj, "id")
|
|
415
|
+
? { id: readOptionalString(obj, "id") }
|
|
416
|
+
: {}),
|
|
417
|
+
name,
|
|
418
|
+
type,
|
|
419
|
+
typeVersion,
|
|
420
|
+
position,
|
|
421
|
+
parameters,
|
|
422
|
+
...(credentials ? { credentials } : {}),
|
|
423
|
+
...(readOptionalBoolean(obj, "disabled") !== undefined
|
|
424
|
+
? { disabled: readOptionalBoolean(obj, "disabled") }
|
|
425
|
+
: {}),
|
|
426
|
+
...(readOptionalString(obj, "notes")
|
|
427
|
+
? { notes: readOptionalString(obj, "notes") }
|
|
428
|
+
: {}),
|
|
429
|
+
...(readOptionalBoolean(obj, "notesInFlow") !== undefined
|
|
430
|
+
? { notesInFlow: readOptionalBoolean(obj, "notesInFlow") }
|
|
431
|
+
: {}),
|
|
432
|
+
...(readOptionalString(obj, "color")
|
|
433
|
+
? { color: readOptionalString(obj, "color") }
|
|
434
|
+
: {}),
|
|
435
|
+
...(readOptionalBoolean(obj, "continueOnFail") !== undefined
|
|
436
|
+
? { continueOnFail: readOptionalBoolean(obj, "continueOnFail") }
|
|
437
|
+
: {}),
|
|
438
|
+
...(readOptionalBoolean(obj, "executeOnce") !== undefined
|
|
439
|
+
? { executeOnce: readOptionalBoolean(obj, "executeOnce") }
|
|
440
|
+
: {}),
|
|
441
|
+
...(readOptionalBoolean(obj, "alwaysOutputData") !== undefined
|
|
442
|
+
? { alwaysOutputData: readOptionalBoolean(obj, "alwaysOutputData") }
|
|
443
|
+
: {}),
|
|
444
|
+
...(readOptionalBoolean(obj, "retryOnFail") !== undefined
|
|
445
|
+
? { retryOnFail: readOptionalBoolean(obj, "retryOnFail") }
|
|
446
|
+
: {}),
|
|
447
|
+
...(readOptionalNumber(obj, "maxTries") !== undefined
|
|
448
|
+
? { maxTries: readOptionalNumber(obj, "maxTries") }
|
|
449
|
+
: {}),
|
|
450
|
+
...(readOptionalNumber(obj, "waitBetweenTries") !== undefined
|
|
451
|
+
? { waitBetweenTries: readOptionalNumber(obj, "waitBetweenTries") }
|
|
452
|
+
: {}),
|
|
453
|
+
...(obj.onError === "continueErrorOutput" ||
|
|
454
|
+
obj.onError === "continueRegularOutput" ||
|
|
455
|
+
obj.onError === "stopWorkflow"
|
|
456
|
+
? { onError: obj.onError }
|
|
457
|
+
: {}),
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
function normalizeWorkflowConnections(value) {
|
|
461
|
+
const raw = asRecord(value);
|
|
462
|
+
if (!raw)
|
|
463
|
+
return {};
|
|
464
|
+
const connections = {};
|
|
465
|
+
for (const [sourceName, outputValue] of Object.entries(raw)) {
|
|
466
|
+
const outputMap = asRecord(outputValue);
|
|
467
|
+
if (!outputMap)
|
|
468
|
+
continue;
|
|
469
|
+
const mainRaw = outputMap.main;
|
|
470
|
+
if (!Array.isArray(mainRaw))
|
|
471
|
+
continue;
|
|
472
|
+
const main = mainRaw.map((group) => Array.isArray(group)
|
|
473
|
+
? group
|
|
474
|
+
.map((connection) => {
|
|
475
|
+
const obj = asRecord(connection);
|
|
476
|
+
const node = obj ? readOptionalString(obj, "node") : undefined;
|
|
477
|
+
if (!obj || !node)
|
|
478
|
+
return null;
|
|
479
|
+
const index = readOptionalNumber(obj, "index") ?? 0;
|
|
480
|
+
return { node, type: "main", index };
|
|
481
|
+
})
|
|
482
|
+
.filter((connection) => connection !== null)
|
|
483
|
+
: []);
|
|
484
|
+
connections[sourceName] = { main };
|
|
485
|
+
}
|
|
486
|
+
return connections;
|
|
487
|
+
}
|
|
488
|
+
function normalizeWorkflowWritePayload(body) {
|
|
489
|
+
const name = readOptionalString(body, "name");
|
|
490
|
+
if (!name) {
|
|
491
|
+
return { error: "workflow name required" };
|
|
492
|
+
}
|
|
493
|
+
const nodesRaw = Array.isArray(body.nodes) ? body.nodes : [];
|
|
494
|
+
const nodes = nodesRaw
|
|
495
|
+
.map((node, index) => normalizeWorkflowWriteNode(node, index))
|
|
496
|
+
.filter((node) => node !== null);
|
|
497
|
+
if (nodes.length === 0) {
|
|
498
|
+
return { error: "workflow must include at least one valid node" };
|
|
499
|
+
}
|
|
500
|
+
return {
|
|
501
|
+
payload: {
|
|
502
|
+
name,
|
|
503
|
+
nodes,
|
|
504
|
+
connections: normalizeWorkflowConnections(body.connections),
|
|
505
|
+
settings: asRecord(body.settings) ?? {},
|
|
506
|
+
},
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
function inferWorkflowName(prompt, requestedName) {
|
|
510
|
+
if (requestedName?.trim()) {
|
|
511
|
+
return requestedName.trim().slice(0, 80);
|
|
512
|
+
}
|
|
513
|
+
const compact = prompt.replace(/\s+/g, " ").trim();
|
|
514
|
+
const withoutSchedule = compact.replace(/^(when|whenever|every|daily|weekly|hourly|on)\b[:,\s-]*/i, "");
|
|
515
|
+
const title = withoutSchedule.slice(0, 58).trim() || "Generated workflow";
|
|
516
|
+
return title[0] ? `${title[0].toUpperCase()}${title.slice(1)}` : title;
|
|
517
|
+
}
|
|
518
|
+
function labelFromStep(step, index) {
|
|
519
|
+
const cleaned = step
|
|
520
|
+
.replace(/\s+/g, " ")
|
|
521
|
+
.replace(/^(then|and|after that|next)\b[:,\s-]*/i, "")
|
|
522
|
+
.trim();
|
|
523
|
+
if (!cleaned)
|
|
524
|
+
return `Step ${index + 1}`;
|
|
525
|
+
const label = cleaned
|
|
526
|
+
.split(" ")
|
|
527
|
+
.slice(0, 6)
|
|
528
|
+
.join(" ")
|
|
529
|
+
.replace(/[.?!,;:]$/g, "");
|
|
530
|
+
return label[0]?.toUpperCase()
|
|
531
|
+
? `${label[0].toUpperCase()}${label.slice(1)}`
|
|
532
|
+
: label;
|
|
533
|
+
}
|
|
534
|
+
function promptToWorkflowSteps(prompt) {
|
|
535
|
+
const parts = prompt
|
|
536
|
+
.replace(/\s+/g, " ")
|
|
537
|
+
.split(/\b(?:then|after that|next)\b|[.;]\s*/i)
|
|
538
|
+
.map((part) => part.trim())
|
|
539
|
+
.filter(Boolean);
|
|
540
|
+
if (parts.length > 1)
|
|
541
|
+
return parts.slice(0, 6);
|
|
542
|
+
const byAnd = prompt
|
|
543
|
+
.replace(/\s+/g, " ")
|
|
544
|
+
.split(/\s+\band\b\s+/i)
|
|
545
|
+
.map((part) => part.trim())
|
|
546
|
+
.filter(Boolean);
|
|
547
|
+
return (byAnd.length > 1 ? byAnd : [prompt.trim()]).slice(0, 6);
|
|
548
|
+
}
|
|
549
|
+
function buildFallbackWorkflowFromPrompt(prompt, requestedName) {
|
|
550
|
+
const steps = promptToWorkflowSteps(prompt);
|
|
551
|
+
const nodes = [
|
|
552
|
+
{
|
|
553
|
+
name: "Start",
|
|
554
|
+
type: "n8n-nodes-base.manualTrigger",
|
|
555
|
+
typeVersion: 1,
|
|
556
|
+
position: [0, 0],
|
|
557
|
+
parameters: {},
|
|
558
|
+
},
|
|
559
|
+
...steps.map((step, index) => ({
|
|
560
|
+
name: labelFromStep(step, index),
|
|
561
|
+
type: "n8n-nodes-base.noOp",
|
|
562
|
+
typeVersion: 1,
|
|
563
|
+
position: [260 * (index + 1), 0],
|
|
564
|
+
parameters: {},
|
|
565
|
+
notes: step,
|
|
566
|
+
notesInFlow: true,
|
|
567
|
+
})),
|
|
568
|
+
];
|
|
569
|
+
const connections = {};
|
|
570
|
+
for (let index = 0; index < nodes.length - 1; index++) {
|
|
571
|
+
connections[nodes[index].name] = {
|
|
572
|
+
main: [[{ node: nodes[index + 1].name, type: "main", index: 0 }]],
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
return {
|
|
576
|
+
name: inferWorkflowName(prompt, requestedName),
|
|
577
|
+
nodes,
|
|
578
|
+
connections,
|
|
579
|
+
settings: {},
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
async function generateWorkflowPayload(ctx, prompt, name) {
|
|
583
|
+
const service = ctx.runtime?.getService?.("n8n_workflow");
|
|
584
|
+
if (typeof service?.generateWorkflowDraft === "function") {
|
|
585
|
+
const generated = await service.generateWorkflowDraft(prompt);
|
|
586
|
+
const normalized = normalizeWorkflowWritePayload({
|
|
587
|
+
...(asRecord(generated) ?? {}),
|
|
588
|
+
...(name?.trim() ? { name: name.trim() } : {}),
|
|
589
|
+
});
|
|
590
|
+
if (normalized.payload)
|
|
591
|
+
return normalized.payload;
|
|
592
|
+
logger.warn({ error: normalized.error }, "[n8n-routes] generated workflow payload was invalid; using fallback builder");
|
|
593
|
+
}
|
|
594
|
+
return buildFallbackWorkflowFromPrompt(prompt, name);
|
|
595
|
+
}
|
|
344
596
|
function propagateError(ctx, upstream) {
|
|
345
597
|
const status = upstream.status >= 400 && upstream.status < 600 ? upstream.status : 502;
|
|
346
598
|
let message = `upstream responded with ${upstream.status}`;
|
|
@@ -432,6 +684,15 @@ export async function handleN8nRoutes(ctx) {
|
|
|
432
684
|
const sidecar = await resolveSidecarForRequest(ctx, native);
|
|
433
685
|
return handleListWorkflows(ctx, sidecar, native);
|
|
434
686
|
}
|
|
687
|
+
// --- Workflow generation / creation --------------------------------------
|
|
688
|
+
if (method === "POST" && pathname === "/api/n8n/workflows/generate") {
|
|
689
|
+
const sidecar = await resolveSidecarForRequest(ctx, native);
|
|
690
|
+
return handleGenerateWorkflow(ctx, sidecar, native);
|
|
691
|
+
}
|
|
692
|
+
if (method === "POST" && pathname === "/api/n8n/workflows") {
|
|
693
|
+
const sidecar = await resolveSidecarForRequest(ctx, native);
|
|
694
|
+
return handleCreateWorkflow(ctx, sidecar, native);
|
|
695
|
+
}
|
|
435
696
|
// --- Workflow CRUD --------------------------------------------------------
|
|
436
697
|
const parsed = parseWorkflowPath(pathname);
|
|
437
698
|
if (parsed) {
|
|
@@ -447,6 +708,10 @@ export async function handleN8nRoutes(ctx) {
|
|
|
447
708
|
const sidecar = await resolveSidecarForRequest(ctx, native);
|
|
448
709
|
return handleGetWorkflow(ctx, parsed.id, sidecar, native);
|
|
449
710
|
}
|
|
711
|
+
if (method === "PUT" && parsed.action === "get") {
|
|
712
|
+
const sidecar = await resolveSidecarForRequest(ctx, native);
|
|
713
|
+
return handleUpdateWorkflow(ctx, parsed.id, sidecar, native);
|
|
714
|
+
}
|
|
450
715
|
if (method === "DELETE" && parsed.action === "get") {
|
|
451
716
|
const sidecar = await resolveSidecarForRequest(ctx, native);
|
|
452
717
|
return handleDeleteWorkflow(ctx, parsed.id, sidecar, native);
|
|
@@ -560,6 +825,75 @@ async function handleGetWorkflow(ctx, id, sidecar, native) {
|
|
|
560
825
|
sendJson(ctx, 200, normalized);
|
|
561
826
|
return true;
|
|
562
827
|
}
|
|
828
|
+
async function writeWorkflow(ctx, method, subpath, payload, sidecar, native) {
|
|
829
|
+
const resolved = resolveProxyTarget(ctx, subpath, sidecar, native);
|
|
830
|
+
if (!resolved.target) {
|
|
831
|
+
sendJson(ctx, 503, {
|
|
832
|
+
error: resolved.reason?.message ?? "n8n not ready",
|
|
833
|
+
status: resolved.reason?.status ?? "stopped",
|
|
834
|
+
});
|
|
835
|
+
return true;
|
|
836
|
+
}
|
|
837
|
+
const upstream = await fetchTargetAsJson(ctx, resolved.target, {
|
|
838
|
+
method,
|
|
839
|
+
body: JSON.stringify(payload),
|
|
840
|
+
});
|
|
841
|
+
if (!upstream.ok) {
|
|
842
|
+
propagateError(ctx, upstream);
|
|
843
|
+
return true;
|
|
844
|
+
}
|
|
845
|
+
const single = extractWorkflowSingle(upstream.body);
|
|
846
|
+
const normalized = normalizeWorkflowFull(single);
|
|
847
|
+
if (!normalized) {
|
|
848
|
+
sendJson(ctx, 502, { error: "unexpected upstream shape" });
|
|
849
|
+
return true;
|
|
850
|
+
}
|
|
851
|
+
sendJson(ctx, 200, normalized);
|
|
852
|
+
return true;
|
|
853
|
+
}
|
|
854
|
+
async function handleCreateWorkflow(ctx, sidecar, native) {
|
|
855
|
+
const body = await readCompatJsonBody(ctx.req, ctx.res);
|
|
856
|
+
if (!body)
|
|
857
|
+
return true;
|
|
858
|
+
const { payload, error } = normalizeWorkflowWritePayload(body);
|
|
859
|
+
if (!payload) {
|
|
860
|
+
sendJson(ctx, 400, { error: error ?? "invalid workflow payload" });
|
|
861
|
+
return true;
|
|
862
|
+
}
|
|
863
|
+
return writeWorkflow(ctx, "POST", "", payload, sidecar, native);
|
|
864
|
+
}
|
|
865
|
+
async function handleUpdateWorkflow(ctx, id, sidecar, native) {
|
|
866
|
+
if (!id) {
|
|
867
|
+
sendJson(ctx, 400, { error: "workflow id required" });
|
|
868
|
+
return true;
|
|
869
|
+
}
|
|
870
|
+
const body = await readCompatJsonBody(ctx.req, ctx.res);
|
|
871
|
+
if (!body)
|
|
872
|
+
return true;
|
|
873
|
+
const { payload, error } = normalizeWorkflowWritePayload(body);
|
|
874
|
+
if (!payload) {
|
|
875
|
+
sendJson(ctx, 400, { error: error ?? "invalid workflow payload" });
|
|
876
|
+
return true;
|
|
877
|
+
}
|
|
878
|
+
return writeWorkflow(ctx, "PUT", `/${encodeURIComponent(id)}`, payload, sidecar, native);
|
|
879
|
+
}
|
|
880
|
+
async function handleGenerateWorkflow(ctx, sidecar, native) {
|
|
881
|
+
const body = await readCompatJsonBody(ctx.req, ctx.res);
|
|
882
|
+
if (!body)
|
|
883
|
+
return true;
|
|
884
|
+
const prompt = readOptionalString(body, "prompt");
|
|
885
|
+
if (!prompt) {
|
|
886
|
+
sendJson(ctx, 400, { error: "prompt required" });
|
|
887
|
+
return true;
|
|
888
|
+
}
|
|
889
|
+
const name = readOptionalString(body, "name");
|
|
890
|
+
const workflowId = readOptionalString(body, "workflowId");
|
|
891
|
+
const payload = await generateWorkflowPayload(ctx, prompt, name);
|
|
892
|
+
if (workflowId) {
|
|
893
|
+
return writeWorkflow(ctx, "PUT", `/${encodeURIComponent(workflowId)}`, payload, sidecar, native);
|
|
894
|
+
}
|
|
895
|
+
return writeWorkflow(ctx, "POST", "", payload, sidecar, native);
|
|
896
|
+
}
|
|
563
897
|
async function handleToggleWorkflow(ctx, id, activate, sidecar, native) {
|
|
564
898
|
if (!id) {
|
|
565
899
|
sendJson(ctx, 400, { error: "workflow id required" });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CharacterEditorPanels.d.ts","sourceRoot":"","sources":["../../../../../../src/components/character/CharacterEditorPanels.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAQzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"CharacterEditorPanels.d.ts","sourceRoot":"","sources":["../../../../../../src/components/character/CharacterEditorPanels.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAQzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AA2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