@almadar/agent 3.5.4 → 3.5.6
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.
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { z } from 'zod';
|
|
18
18
|
import type { OrbitalSchema } from '@almadar/core/types';
|
|
19
|
-
export
|
|
19
|
+
export type GateClientProvider = 'deepseek' | 'qwen3.5' | 'gemma3-4b' | 'mistral-small' | 'mistral-medium';
|
|
20
|
+
export declare function createDecomposeAppTool(gateProvider?: GateClientProvider): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
20
21
|
prompt: z.ZodString;
|
|
21
22
|
}, "strip", z.ZodTypeAny, {
|
|
22
23
|
prompt: string;
|
|
@@ -36,7 +37,7 @@ export declare function createDecomposeAppTool(): import("@langchain/core/tools"
|
|
|
36
37
|
}[];
|
|
37
38
|
shellOrb: OrbitalSchema;
|
|
38
39
|
}, unknown, "decompose_app">;
|
|
39
|
-
export declare function createMatchBehaviorTool(): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
40
|
+
export declare function createMatchBehaviorTool(gateProvider?: GateClientProvider): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
40
41
|
description: z.ZodString;
|
|
41
42
|
orbitalName: z.ZodString;
|
|
42
43
|
entityName: z.ZodString;
|
|
@@ -61,7 +62,7 @@ export declare function createMatchBehaviorTool(): import("@langchain/core/tools
|
|
|
61
62
|
behaviorName: string | null;
|
|
62
63
|
hasGoldenOrb: boolean;
|
|
63
64
|
}, unknown, "match_behavior">;
|
|
64
|
-
export declare function createBuildOrbitalTool(workDir: string): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
65
|
+
export declare function createBuildOrbitalTool(workDir: string, gateProvider?: GateClientProvider): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
65
66
|
orbitalName: z.ZodString;
|
|
66
67
|
shellOrb: z.ZodString;
|
|
67
68
|
goldenBehavior: z.ZodOptional<z.ZodString>;
|
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
import type { LLMClient } from '@almadar/llm';
|
|
14
14
|
import type { OrbitalSchema } from '@almadar/core/types';
|
|
15
15
|
import type { GateOpts } from './types.js';
|
|
16
|
-
export
|
|
17
|
-
declare function loadGoldenOrb(behaviorName: string): OrbitalSchema | null;
|
|
16
|
+
export declare function loadGoldenOrbByName(behaviorName: string): OrbitalSchema | null;
|
|
18
17
|
export interface BehaviorMatchResult {
|
|
19
18
|
matchedName: string | null;
|
|
20
19
|
goldenOrb: OrbitalSchema | null;
|
package/dist/gates/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { extractJsonFromText, createOpenRouterClient, createDeepSeekClient } from '@almadar/llm';
|
|
2
|
+
import { loadGoldenOrb, getAllBehaviors } from '@almadar/std';
|
|
3
|
+
import fs3 from 'fs';
|
|
4
|
+
import path3 from 'path';
|
|
5
5
|
import { execSync } from 'child_process';
|
|
6
6
|
import { getDecompositionCompact, getBindingsCompact, getBindingContextRules, getOrbRenderUIGuide } from '@almadar/skills';
|
|
7
7
|
import { tool } from '@langchain/core/tools';
|
|
@@ -9,12 +9,6 @@ import { z } from 'zod';
|
|
|
9
9
|
|
|
10
10
|
var __defProp = Object.defineProperty;
|
|
11
11
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
13
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
14
|
-
}) : x)(function(x) {
|
|
15
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
16
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
17
|
-
});
|
|
18
12
|
var __esm = (fn, res) => function __init() {
|
|
19
13
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
20
14
|
};
|
|
@@ -26,7 +20,7 @@ var __export = (target, all) => {
|
|
|
26
20
|
// src/gates/gate05-behavior-match.ts
|
|
27
21
|
var gate05_behavior_match_exports = {};
|
|
28
22
|
__export(gate05_behavior_match_exports, {
|
|
29
|
-
loadGoldenOrbByName: () =>
|
|
23
|
+
loadGoldenOrbByName: () => loadGoldenOrbByName,
|
|
30
24
|
runGate05: () => runGate05
|
|
31
25
|
});
|
|
32
26
|
function getBehaviorCatalog() {
|
|
@@ -42,33 +36,8 @@ function getBehaviorCatalog() {
|
|
|
42
36
|
cachedCatalog = lines.join("\n");
|
|
43
37
|
return cachedCatalog;
|
|
44
38
|
}
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
path4.dirname(new URL(import.meta.url).pathname),
|
|
48
|
-
"../../../almadar-std/behaviors/exports"
|
|
49
|
-
);
|
|
50
|
-
if (fs4.existsSync(monorepoPath)) return monorepoPath;
|
|
51
|
-
try {
|
|
52
|
-
const stdPkg = path4.dirname(__require.resolve("@almadar/std/package.json"));
|
|
53
|
-
const nmPath = path4.join(stdPkg, "behaviors", "exports");
|
|
54
|
-
if (fs4.existsSync(nmPath)) return nmPath;
|
|
55
|
-
} catch {
|
|
56
|
-
}
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
function loadGoldenOrb(behaviorName) {
|
|
60
|
-
const exportsDir = findExportsDir();
|
|
61
|
-
if (!exportsDir) {
|
|
62
|
-
console.warn("[Gate 0.5] Cannot find behaviors/exports/ directory");
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
const orbPath = path4.join(exportsDir, `${behaviorName}.orb`);
|
|
66
|
-
if (!fs4.existsSync(orbPath)) {
|
|
67
|
-
console.warn(`[Gate 0.5] .orb file not found: ${orbPath}`);
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
const content = fs4.readFileSync(orbPath, "utf-8");
|
|
71
|
-
return JSON.parse(content);
|
|
39
|
+
function loadGoldenOrbByName(behaviorName) {
|
|
40
|
+
return loadGoldenOrb(behaviorName);
|
|
72
41
|
}
|
|
73
42
|
function buildMatchSystemPrompt() {
|
|
74
43
|
return `You are a behavior matching assistant. Given an application description and its orbital structure, select the most relevant golden behavior from the catalog below.
|
|
@@ -111,7 +80,7 @@ async function runGate05(client, prompt, orb, opts = {}) {
|
|
|
111
80
|
console.log("[Gate 0.5] No behavior match found, using pure mode");
|
|
112
81
|
return { matchedName: null, goldenOrb: null };
|
|
113
82
|
}
|
|
114
|
-
const goldenOrb =
|
|
83
|
+
const goldenOrb = loadGoldenOrbByName(matchName);
|
|
115
84
|
if (!goldenOrb) {
|
|
116
85
|
console.warn(`[Gate 0.5] Matched "${matchName}" but could not load .orb file`);
|
|
117
86
|
return { matchedName: matchName, goldenOrb: null };
|
|
@@ -127,16 +96,16 @@ var init_gate05_behavior_match = __esm({
|
|
|
127
96
|
});
|
|
128
97
|
var ORBITAL_BINARY = "/home/osamah/bin/orbital";
|
|
129
98
|
function validateWithOrbitalCLI(schema, workDir) {
|
|
130
|
-
if (!
|
|
99
|
+
if (!fs3.existsSync(ORBITAL_BINARY)) {
|
|
131
100
|
return {
|
|
132
101
|
valid: false,
|
|
133
102
|
errors: [{ code: "CLI_NOT_FOUND", path: "", message: `orbital binary not found at ${ORBITAL_BINARY}` }]
|
|
134
103
|
};
|
|
135
104
|
}
|
|
136
105
|
const schemaStr = typeof schema === "string" ? schema : JSON.stringify(schema, null, 2);
|
|
137
|
-
const tempPath =
|
|
106
|
+
const tempPath = path3.join(workDir, `_eval_validate_${Date.now()}.orb`);
|
|
138
107
|
try {
|
|
139
|
-
|
|
108
|
+
fs3.writeFileSync(tempPath, schemaStr);
|
|
140
109
|
const output = execSync(`${ORBITAL_BINARY} validate --json "${tempPath}"`, {
|
|
141
110
|
encoding: "utf-8",
|
|
142
111
|
timeout: 3e4,
|
|
@@ -162,7 +131,7 @@ function validateWithOrbitalCLI(schema, workDir) {
|
|
|
162
131
|
};
|
|
163
132
|
} finally {
|
|
164
133
|
try {
|
|
165
|
-
|
|
134
|
+
fs3.unlinkSync(tempPath);
|
|
166
135
|
} catch {
|
|
167
136
|
}
|
|
168
137
|
}
|
|
@@ -979,16 +948,40 @@ function createClientForProvider(config) {
|
|
|
979
948
|
...config.model ? { model: config.model } : {},
|
|
980
949
|
...config.temperature !== void 0 ? { temperature: config.temperature } : {}
|
|
981
950
|
};
|
|
951
|
+
let client;
|
|
982
952
|
switch (config.provider) {
|
|
983
953
|
case "deepseek":
|
|
984
|
-
|
|
954
|
+
client = createDeepSeekClient(opts);
|
|
955
|
+
break;
|
|
985
956
|
case "zhipu":
|
|
986
|
-
|
|
957
|
+
client = createOpenRouterClient({ model: "z-ai/glm-4.7", ...opts });
|
|
958
|
+
break;
|
|
959
|
+
case "qwen3.5":
|
|
960
|
+
client = createOpenRouterClient({ model: "qwen/qwen3.5-9b", ...opts });
|
|
961
|
+
break;
|
|
962
|
+
case "gemma3-4b":
|
|
963
|
+
client = createOpenRouterClient({ model: "google/gemma-3-4b-it", ...opts });
|
|
964
|
+
break;
|
|
965
|
+
case "mistral-small":
|
|
966
|
+
client = createOpenRouterClient({ model: "mistralai/mistral-small-3.1-24b-instruct", ...opts });
|
|
967
|
+
break;
|
|
968
|
+
case "mistral-medium":
|
|
969
|
+
client = createOpenRouterClient({ model: "mistralai/mistral-medium-3.1", ...opts });
|
|
970
|
+
break;
|
|
987
971
|
default: {
|
|
988
972
|
const _exhaustive = config.provider;
|
|
989
973
|
throw new Error(`Unknown provider: ${_exhaustive}`);
|
|
990
974
|
}
|
|
991
975
|
}
|
|
976
|
+
if (config.provider === "qwen3.5") {
|
|
977
|
+
const originalCallRaw = client.callRaw.bind(client);
|
|
978
|
+
const originalCallRawWithMetadata = client.callRawWithMetadata.bind(client);
|
|
979
|
+
client.callRaw = (opts2) => originalCallRaw({ ...opts2, userPrompt: `/no_think
|
|
980
|
+
${opts2.userPrompt}` });
|
|
981
|
+
client.callRawWithMetadata = (opts2) => originalCallRawWithMetadata({ ...opts2, userPrompt: `/no_think
|
|
982
|
+
${opts2.userPrompt}` });
|
|
983
|
+
}
|
|
984
|
+
return client;
|
|
992
985
|
}
|
|
993
986
|
function timeMs() {
|
|
994
987
|
return performance.now();
|
|
@@ -1037,7 +1030,7 @@ async function runGatePipeline(prompt, config, behaviorData, goldenOrb) {
|
|
|
1037
1030
|
const orbFinal = await runGate4(client, orbAfterGate3, opts);
|
|
1038
1031
|
const g4Ms = timeMs() - g4Start;
|
|
1039
1032
|
console.log(`[Gate 4] Render-ui appended (${g4Ms.toFixed(0)}ms)`);
|
|
1040
|
-
|
|
1033
|
+
fs3.mkdirSync(config.workDir, { recursive: true });
|
|
1041
1034
|
const validation = validateWithOrbitalCLI(orbFinal, config.workDir);
|
|
1042
1035
|
console.log(`[Validate] valid=${validation.valid}, errors=${(validation.errors || []).length}`);
|
|
1043
1036
|
let verify;
|
|
@@ -1070,12 +1063,12 @@ async function runGatePipeline(prompt, config, behaviorData, goldenOrb) {
|
|
|
1070
1063
|
};
|
|
1071
1064
|
}
|
|
1072
1065
|
async function runVerify(orb, config) {
|
|
1073
|
-
const tmpDir =
|
|
1074
|
-
|
|
1075
|
-
const orbPath =
|
|
1076
|
-
|
|
1077
|
-
const verifyApiPath =
|
|
1078
|
-
|
|
1066
|
+
const tmpDir = path3.join(config.workDir, "gate-verify");
|
|
1067
|
+
fs3.mkdirSync(tmpDir, { recursive: true });
|
|
1068
|
+
const orbPath = path3.join(tmpDir, `${orb.name || "generated"}.orb`);
|
|
1069
|
+
fs3.writeFileSync(orbPath, JSON.stringify(orb, null, 2));
|
|
1070
|
+
const verifyApiPath = path3.resolve(
|
|
1071
|
+
path3.dirname(new URL(import.meta.url).pathname),
|
|
1079
1072
|
"../../../../tools/orbital-verify-unified/src/api.js"
|
|
1080
1073
|
);
|
|
1081
1074
|
const { verifyApp } = await import(verifyApiPath);
|
|
@@ -1494,10 +1487,40 @@ function countNodes(tree) {
|
|
|
1494
1487
|
return count;
|
|
1495
1488
|
}
|
|
1496
1489
|
init_gate05_behavior_match();
|
|
1497
|
-
function
|
|
1490
|
+
function createGateClient(provider = "mistral-small") {
|
|
1491
|
+
let client;
|
|
1492
|
+
switch (provider) {
|
|
1493
|
+
case "qwen3.5":
|
|
1494
|
+
client = createOpenRouterClient({ model: "qwen/qwen3.5-9b" });
|
|
1495
|
+
break;
|
|
1496
|
+
case "gemma3-4b":
|
|
1497
|
+
client = createOpenRouterClient({ model: "google/gemma-3-4b-it" });
|
|
1498
|
+
break;
|
|
1499
|
+
case "mistral-small":
|
|
1500
|
+
client = createOpenRouterClient({ model: "mistralai/mistral-small-3.1-24b-instruct" });
|
|
1501
|
+
break;
|
|
1502
|
+
case "mistral-medium":
|
|
1503
|
+
client = createOpenRouterClient({ model: "mistralai/mistral-medium-3.1" });
|
|
1504
|
+
break;
|
|
1505
|
+
case "deepseek":
|
|
1506
|
+
default:
|
|
1507
|
+
client = createDeepSeekClient();
|
|
1508
|
+
break;
|
|
1509
|
+
}
|
|
1510
|
+
if (provider === "qwen3.5") {
|
|
1511
|
+
const originalCallRaw = client.callRaw.bind(client);
|
|
1512
|
+
const originalCallRawWithMetadata = client.callRawWithMetadata.bind(client);
|
|
1513
|
+
client.callRaw = (opts) => originalCallRaw({ ...opts, userPrompt: `/no_think
|
|
1514
|
+
${opts.userPrompt}` });
|
|
1515
|
+
client.callRawWithMetadata = (opts) => originalCallRawWithMetadata({ ...opts, userPrompt: `/no_think
|
|
1516
|
+
${opts.userPrompt}` });
|
|
1517
|
+
}
|
|
1518
|
+
return client;
|
|
1519
|
+
}
|
|
1520
|
+
function createDecomposeAppTool(gateProvider) {
|
|
1498
1521
|
return tool(
|
|
1499
1522
|
async (input) => {
|
|
1500
|
-
const client =
|
|
1523
|
+
const client = createGateClient(gateProvider);
|
|
1501
1524
|
const orb = await runGate0(client, input.prompt);
|
|
1502
1525
|
return {
|
|
1503
1526
|
appName: orb.name,
|
|
@@ -1519,10 +1542,10 @@ function createDecomposeAppTool() {
|
|
|
1519
1542
|
}
|
|
1520
1543
|
);
|
|
1521
1544
|
}
|
|
1522
|
-
function createMatchBehaviorTool() {
|
|
1545
|
+
function createMatchBehaviorTool(gateProvider) {
|
|
1523
1546
|
return tool(
|
|
1524
1547
|
async (input) => {
|
|
1525
|
-
const client =
|
|
1548
|
+
const client = createGateClient(gateProvider);
|
|
1526
1549
|
const shellOrb = {
|
|
1527
1550
|
orbitals: [{
|
|
1528
1551
|
name: input.orbitalName,
|
|
@@ -1549,12 +1572,12 @@ function createMatchBehaviorTool() {
|
|
|
1549
1572
|
}
|
|
1550
1573
|
);
|
|
1551
1574
|
}
|
|
1552
|
-
function createBuildOrbitalTool(workDir) {
|
|
1575
|
+
function createBuildOrbitalTool(workDir, gateProvider) {
|
|
1553
1576
|
return tool(
|
|
1554
1577
|
async (input) => {
|
|
1555
|
-
const client =
|
|
1556
|
-
const orbitalsDir =
|
|
1557
|
-
|
|
1578
|
+
const client = createGateClient(gateProvider);
|
|
1579
|
+
const orbitalsDir = path3.join(workDir, ".orbitals");
|
|
1580
|
+
fs3.mkdirSync(orbitalsDir, { recursive: true });
|
|
1558
1581
|
let shellOrb;
|
|
1559
1582
|
try {
|
|
1560
1583
|
shellOrb = JSON.parse(input.shellOrb);
|
|
@@ -1563,8 +1586,8 @@ function createBuildOrbitalTool(workDir) {
|
|
|
1563
1586
|
}
|
|
1564
1587
|
let goldenOrb;
|
|
1565
1588
|
if (input.goldenBehavior) {
|
|
1566
|
-
const { loadGoldenOrbByName } = await Promise.resolve().then(() => (init_gate05_behavior_match(), gate05_behavior_match_exports));
|
|
1567
|
-
goldenOrb =
|
|
1589
|
+
const { loadGoldenOrbByName: loadGoldenOrbByName2 } = await Promise.resolve().then(() => (init_gate05_behavior_match(), gate05_behavior_match_exports));
|
|
1590
|
+
goldenOrb = loadGoldenOrbByName2(input.goldenBehavior) ?? void 0;
|
|
1568
1591
|
}
|
|
1569
1592
|
const opts = {
|
|
1570
1593
|
goldenOrb
|
|
@@ -1581,11 +1604,11 @@ function createBuildOrbitalTool(workDir) {
|
|
|
1581
1604
|
orb = await runGate4(client, orb, opts);
|
|
1582
1605
|
for (const orbital of orb.orbitals) {
|
|
1583
1606
|
const safeName = orbital.name.replace(/[^a-zA-Z0-9]/g, "_").toLowerCase();
|
|
1584
|
-
const orbitalPath =
|
|
1585
|
-
|
|
1607
|
+
const orbitalPath = path3.join(orbitalsDir, `${safeName}.json`);
|
|
1608
|
+
fs3.writeFileSync(orbitalPath, JSON.stringify(orbital, null, 2));
|
|
1586
1609
|
console.log(`[build_orbital] Written: ${orbitalPath}`);
|
|
1587
1610
|
}
|
|
1588
|
-
|
|
1611
|
+
fs3.mkdirSync(workDir, { recursive: true });
|
|
1589
1612
|
const validation = validateWithOrbitalCLI(orb, workDir);
|
|
1590
1613
|
return {
|
|
1591
1614
|
success: true,
|
|
@@ -1620,13 +1643,13 @@ function createBuildOrbitalTool(workDir) {
|
|
|
1620
1643
|
function createVerifyAppTool(workDir) {
|
|
1621
1644
|
return tool(
|
|
1622
1645
|
async (input) => {
|
|
1623
|
-
const orbPath = input.orbPath ||
|
|
1624
|
-
if (!
|
|
1646
|
+
const orbPath = input.orbPath || path3.join(workDir, "schema.orb");
|
|
1647
|
+
if (!fs3.existsSync(orbPath)) {
|
|
1625
1648
|
return { success: false, error: `Schema file not found: ${orbPath}` };
|
|
1626
1649
|
}
|
|
1627
1650
|
try {
|
|
1628
|
-
const verifyApiPath =
|
|
1629
|
-
|
|
1651
|
+
const verifyApiPath = path3.resolve(
|
|
1652
|
+
path3.dirname(new URL(import.meta.url).pathname),
|
|
1630
1653
|
"../../../../../tools/orbital-verify-unified/src/api.js"
|
|
1631
1654
|
);
|
|
1632
1655
|
const { verifyApp } = await import(verifyApiPath);
|
|
@@ -1776,8 +1799,8 @@ function createUseBehaviorTool(workDir) {
|
|
|
1776
1799
|
finalOrbital = orbital;
|
|
1777
1800
|
} else {
|
|
1778
1801
|
console.log(`[use_behavior] Falling back to substitution for ${input.behaviorName}`);
|
|
1779
|
-
const {
|
|
1780
|
-
const behavior =
|
|
1802
|
+
const { loadGoldenOrb } = await import('@almadar/std');
|
|
1803
|
+
const behavior = loadGoldenOrb(input.behaviorName);
|
|
1781
1804
|
if (!behavior) {
|
|
1782
1805
|
return { success: false, error: `Behavior "${input.behaviorName}" not found` };
|
|
1783
1806
|
}
|
|
@@ -1828,13 +1851,13 @@ function createUseBehaviorTool(workDir) {
|
|
|
1828
1851
|
substituteInRenderUi(finalOrbital, "button", "label", null, input.createButtonLabel, false);
|
|
1829
1852
|
}
|
|
1830
1853
|
}
|
|
1831
|
-
const orbitalsDir =
|
|
1832
|
-
|
|
1854
|
+
const orbitalsDir = path3.join(workDir, ".orbitals");
|
|
1855
|
+
fs3.mkdirSync(orbitalsDir, { recursive: true });
|
|
1833
1856
|
const safeName = newEntityName.replace(/[^a-zA-Z0-9]/g, "_").toLowerCase();
|
|
1834
|
-
const orbitalPath =
|
|
1835
|
-
|
|
1857
|
+
const orbitalPath = path3.join(orbitalsDir, `${safeName}.json`);
|
|
1858
|
+
fs3.writeFileSync(orbitalPath, JSON.stringify(finalOrbital, null, 2));
|
|
1836
1859
|
const schema = { name: newEntityName + "App", version: "1.0.0", orbitals: [finalOrbital] };
|
|
1837
|
-
|
|
1860
|
+
fs3.mkdirSync(workDir, { recursive: true });
|
|
1838
1861
|
const validation = validateWithOrbitalCLI(schema, workDir);
|
|
1839
1862
|
return {
|
|
1840
1863
|
success: true,
|
|
@@ -1909,12 +1932,12 @@ function walkAndSubstitute(node, patternType, propName, oldValue, newValue, firs
|
|
|
1909
1932
|
function createConnectTool(workDir) {
|
|
1910
1933
|
return tool(
|
|
1911
1934
|
async (input) => {
|
|
1912
|
-
const emitterPath =
|
|
1913
|
-
const listenerPath =
|
|
1914
|
-
if (!
|
|
1915
|
-
if (!
|
|
1916
|
-
const emitter = JSON.parse(
|
|
1917
|
-
const listener = JSON.parse(
|
|
1935
|
+
const emitterPath = path3.join(workDir, ".orbitals", input.emitterFile);
|
|
1936
|
+
const listenerPath = path3.join(workDir, ".orbitals", input.listenerFile);
|
|
1937
|
+
if (!fs3.existsSync(emitterPath)) return { success: false, error: `Emitter not found: ${emitterPath}` };
|
|
1938
|
+
if (!fs3.existsSync(listenerPath)) return { success: false, error: `Listener not found: ${listenerPath}` };
|
|
1939
|
+
const emitter = JSON.parse(fs3.readFileSync(emitterPath, "utf-8"));
|
|
1940
|
+
const listener = JSON.parse(fs3.readFileSync(listenerPath, "utf-8"));
|
|
1918
1941
|
const emitterTraits = emitter.traits || [];
|
|
1919
1942
|
const listenerTraits = listener.traits || [];
|
|
1920
1943
|
if (emitterTraits.length === 0 || listenerTraits.length === 0) {
|
|
@@ -1936,8 +1959,8 @@ function createConnectTool(workDir) {
|
|
|
1936
1959
|
scope: "external"
|
|
1937
1960
|
});
|
|
1938
1961
|
listenerTrait.listens = listens;
|
|
1939
|
-
|
|
1940
|
-
|
|
1962
|
+
fs3.writeFileSync(emitterPath, JSON.stringify(emitter, null, 2));
|
|
1963
|
+
fs3.writeFileSync(listenerPath, JSON.stringify(listener, null, 2));
|
|
1941
1964
|
return {
|
|
1942
1965
|
success: true,
|
|
1943
1966
|
event: input.eventName,
|
|
@@ -1961,13 +1984,13 @@ function createConnectTool(workDir) {
|
|
|
1961
1984
|
function createComposeTool(workDir) {
|
|
1962
1985
|
return tool(
|
|
1963
1986
|
async (input) => {
|
|
1964
|
-
const orbitalsDir =
|
|
1987
|
+
const orbitalsDir = path3.join(workDir, ".orbitals");
|
|
1965
1988
|
const orbitals = [];
|
|
1966
|
-
const orbitalFiles = input.orbitalFiles ? JSON.parse(input.orbitalFiles) :
|
|
1989
|
+
const orbitalFiles = input.orbitalFiles ? JSON.parse(input.orbitalFiles) : fs3.readdirSync(orbitalsDir).filter((f) => f.endsWith(".json"));
|
|
1967
1990
|
for (const file of orbitalFiles) {
|
|
1968
|
-
const filePath =
|
|
1969
|
-
if (!
|
|
1970
|
-
orbitals.push(JSON.parse(
|
|
1991
|
+
const filePath = path3.join(orbitalsDir, file);
|
|
1992
|
+
if (!fs3.existsSync(filePath)) continue;
|
|
1993
|
+
orbitals.push(JSON.parse(fs3.readFileSync(filePath, "utf-8")));
|
|
1971
1994
|
}
|
|
1972
1995
|
if (orbitals.length === 0) {
|
|
1973
1996
|
return { success: false, error: "No orbitals found in .orbitals/" };
|
|
@@ -2001,8 +2024,8 @@ function createComposeTool(workDir) {
|
|
|
2001
2024
|
version: "1.0.0",
|
|
2002
2025
|
orbitals
|
|
2003
2026
|
};
|
|
2004
|
-
const schemaPath =
|
|
2005
|
-
|
|
2027
|
+
const schemaPath = path3.join(workDir, "schema.orb");
|
|
2028
|
+
fs3.writeFileSync(schemaPath, JSON.stringify(schema, null, 2));
|
|
2006
2029
|
const validation = validateWithOrbitalCLI(schema, workDir);
|
|
2007
2030
|
return {
|
|
2008
2031
|
success: true,
|