@almadar/agent 3.5.5 → 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,7 @@
16
16
  */
17
17
  import { z } from 'zod';
18
18
  import type { OrbitalSchema } from '@almadar/core/types';
19
- export type GateClientProvider = 'deepseek' | 'qwen3.5' | 'gemma3-4b' | 'mistral-small';
19
+ export type GateClientProvider = 'deepseek' | 'qwen3.5' | 'gemma3-4b' | 'mistral-small' | 'mistral-medium';
20
20
  export declare function createDecomposeAppTool(gateProvider?: GateClientProvider): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
21
21
  prompt: z.ZodString;
22
22
  }, "strip", z.ZodTypeAny, {
@@ -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 { loadGoldenOrb as loadGoldenOrbByName };
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;
@@ -1,7 +1,7 @@
1
- import fs4 from 'fs';
2
- import path4 from 'path';
3
1
  import { extractJsonFromText, createOpenRouterClient, createDeepSeekClient } from '@almadar/llm';
4
- import { getAllBehaviors } from '@almadar/std';
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: () => loadGoldenOrb,
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 findExportsDir() {
46
- const monorepoPath = path4.resolve(
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 = loadGoldenOrb(matchName);
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 (!fs4.existsSync(ORBITAL_BINARY)) {
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 = path4.join(workDir, `_eval_validate_${Date.now()}.orb`);
106
+ const tempPath = path3.join(workDir, `_eval_validate_${Date.now()}.orb`);
138
107
  try {
139
- fs4.writeFileSync(tempPath, schemaStr);
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
- fs4.unlinkSync(tempPath);
134
+ fs3.unlinkSync(tempPath);
166
135
  } catch {
167
136
  }
168
137
  }
@@ -996,6 +965,9 @@ function createClientForProvider(config) {
996
965
  case "mistral-small":
997
966
  client = createOpenRouterClient({ model: "mistralai/mistral-small-3.1-24b-instruct", ...opts });
998
967
  break;
968
+ case "mistral-medium":
969
+ client = createOpenRouterClient({ model: "mistralai/mistral-medium-3.1", ...opts });
970
+ break;
999
971
  default: {
1000
972
  const _exhaustive = config.provider;
1001
973
  throw new Error(`Unknown provider: ${_exhaustive}`);
@@ -1058,7 +1030,7 @@ async function runGatePipeline(prompt, config, behaviorData, goldenOrb) {
1058
1030
  const orbFinal = await runGate4(client, orbAfterGate3, opts);
1059
1031
  const g4Ms = timeMs() - g4Start;
1060
1032
  console.log(`[Gate 4] Render-ui appended (${g4Ms.toFixed(0)}ms)`);
1061
- fs4.mkdirSync(config.workDir, { recursive: true });
1033
+ fs3.mkdirSync(config.workDir, { recursive: true });
1062
1034
  const validation = validateWithOrbitalCLI(orbFinal, config.workDir);
1063
1035
  console.log(`[Validate] valid=${validation.valid}, errors=${(validation.errors || []).length}`);
1064
1036
  let verify;
@@ -1091,12 +1063,12 @@ async function runGatePipeline(prompt, config, behaviorData, goldenOrb) {
1091
1063
  };
1092
1064
  }
1093
1065
  async function runVerify(orb, config) {
1094
- const tmpDir = path4.join(config.workDir, "gate-verify");
1095
- fs4.mkdirSync(tmpDir, { recursive: true });
1096
- const orbPath = path4.join(tmpDir, `${orb.name || "generated"}.orb`);
1097
- fs4.writeFileSync(orbPath, JSON.stringify(orb, null, 2));
1098
- const verifyApiPath = path4.resolve(
1099
- path4.dirname(new URL(import.meta.url).pathname),
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),
1100
1072
  "../../../../tools/orbital-verify-unified/src/api.js"
1101
1073
  );
1102
1074
  const { verifyApp } = await import(verifyApiPath);
@@ -1527,6 +1499,9 @@ function createGateClient(provider = "mistral-small") {
1527
1499
  case "mistral-small":
1528
1500
  client = createOpenRouterClient({ model: "mistralai/mistral-small-3.1-24b-instruct" });
1529
1501
  break;
1502
+ case "mistral-medium":
1503
+ client = createOpenRouterClient({ model: "mistralai/mistral-medium-3.1" });
1504
+ break;
1530
1505
  case "deepseek":
1531
1506
  default:
1532
1507
  client = createDeepSeekClient();
@@ -1601,8 +1576,8 @@ function createBuildOrbitalTool(workDir, gateProvider) {
1601
1576
  return tool(
1602
1577
  async (input) => {
1603
1578
  const client = createGateClient(gateProvider);
1604
- const orbitalsDir = path4.join(workDir, ".orbitals");
1605
- fs4.mkdirSync(orbitalsDir, { recursive: true });
1579
+ const orbitalsDir = path3.join(workDir, ".orbitals");
1580
+ fs3.mkdirSync(orbitalsDir, { recursive: true });
1606
1581
  let shellOrb;
1607
1582
  try {
1608
1583
  shellOrb = JSON.parse(input.shellOrb);
@@ -1611,8 +1586,8 @@ function createBuildOrbitalTool(workDir, gateProvider) {
1611
1586
  }
1612
1587
  let goldenOrb;
1613
1588
  if (input.goldenBehavior) {
1614
- const { loadGoldenOrbByName } = await Promise.resolve().then(() => (init_gate05_behavior_match(), gate05_behavior_match_exports));
1615
- goldenOrb = loadGoldenOrbByName(input.goldenBehavior) ?? void 0;
1589
+ const { loadGoldenOrbByName: loadGoldenOrbByName2 } = await Promise.resolve().then(() => (init_gate05_behavior_match(), gate05_behavior_match_exports));
1590
+ goldenOrb = loadGoldenOrbByName2(input.goldenBehavior) ?? void 0;
1616
1591
  }
1617
1592
  const opts = {
1618
1593
  goldenOrb
@@ -1629,11 +1604,11 @@ function createBuildOrbitalTool(workDir, gateProvider) {
1629
1604
  orb = await runGate4(client, orb, opts);
1630
1605
  for (const orbital of orb.orbitals) {
1631
1606
  const safeName = orbital.name.replace(/[^a-zA-Z0-9]/g, "_").toLowerCase();
1632
- const orbitalPath = path4.join(orbitalsDir, `${safeName}.json`);
1633
- fs4.writeFileSync(orbitalPath, JSON.stringify(orbital, null, 2));
1607
+ const orbitalPath = path3.join(orbitalsDir, `${safeName}.json`);
1608
+ fs3.writeFileSync(orbitalPath, JSON.stringify(orbital, null, 2));
1634
1609
  console.log(`[build_orbital] Written: ${orbitalPath}`);
1635
1610
  }
1636
- fs4.mkdirSync(workDir, { recursive: true });
1611
+ fs3.mkdirSync(workDir, { recursive: true });
1637
1612
  const validation = validateWithOrbitalCLI(orb, workDir);
1638
1613
  return {
1639
1614
  success: true,
@@ -1668,13 +1643,13 @@ function createBuildOrbitalTool(workDir, gateProvider) {
1668
1643
  function createVerifyAppTool(workDir) {
1669
1644
  return tool(
1670
1645
  async (input) => {
1671
- const orbPath = input.orbPath || path4.join(workDir, "schema.orb");
1672
- if (!fs4.existsSync(orbPath)) {
1646
+ const orbPath = input.orbPath || path3.join(workDir, "schema.orb");
1647
+ if (!fs3.existsSync(orbPath)) {
1673
1648
  return { success: false, error: `Schema file not found: ${orbPath}` };
1674
1649
  }
1675
1650
  try {
1676
- const verifyApiPath = path4.resolve(
1677
- path4.dirname(new URL(import.meta.url).pathname),
1651
+ const verifyApiPath = path3.resolve(
1652
+ path3.dirname(new URL(import.meta.url).pathname),
1678
1653
  "../../../../../tools/orbital-verify-unified/src/api.js"
1679
1654
  );
1680
1655
  const { verifyApp } = await import(verifyApiPath);
@@ -1824,8 +1799,8 @@ function createUseBehaviorTool(workDir) {
1824
1799
  finalOrbital = orbital;
1825
1800
  } else {
1826
1801
  console.log(`[use_behavior] Falling back to substitution for ${input.behaviorName}`);
1827
- const { getBehavior } = await import('@almadar/std');
1828
- const behavior = getBehavior(input.behaviorName);
1802
+ const { loadGoldenOrb } = await import('@almadar/std');
1803
+ const behavior = loadGoldenOrb(input.behaviorName);
1829
1804
  if (!behavior) {
1830
1805
  return { success: false, error: `Behavior "${input.behaviorName}" not found` };
1831
1806
  }
@@ -1876,13 +1851,13 @@ function createUseBehaviorTool(workDir) {
1876
1851
  substituteInRenderUi(finalOrbital, "button", "label", null, input.createButtonLabel, false);
1877
1852
  }
1878
1853
  }
1879
- const orbitalsDir = path4.join(workDir, ".orbitals");
1880
- fs4.mkdirSync(orbitalsDir, { recursive: true });
1854
+ const orbitalsDir = path3.join(workDir, ".orbitals");
1855
+ fs3.mkdirSync(orbitalsDir, { recursive: true });
1881
1856
  const safeName = newEntityName.replace(/[^a-zA-Z0-9]/g, "_").toLowerCase();
1882
- const orbitalPath = path4.join(orbitalsDir, `${safeName}.json`);
1883
- fs4.writeFileSync(orbitalPath, JSON.stringify(finalOrbital, null, 2));
1857
+ const orbitalPath = path3.join(orbitalsDir, `${safeName}.json`);
1858
+ fs3.writeFileSync(orbitalPath, JSON.stringify(finalOrbital, null, 2));
1884
1859
  const schema = { name: newEntityName + "App", version: "1.0.0", orbitals: [finalOrbital] };
1885
- fs4.mkdirSync(workDir, { recursive: true });
1860
+ fs3.mkdirSync(workDir, { recursive: true });
1886
1861
  const validation = validateWithOrbitalCLI(schema, workDir);
1887
1862
  return {
1888
1863
  success: true,
@@ -1957,12 +1932,12 @@ function walkAndSubstitute(node, patternType, propName, oldValue, newValue, firs
1957
1932
  function createConnectTool(workDir) {
1958
1933
  return tool(
1959
1934
  async (input) => {
1960
- const emitterPath = path4.join(workDir, ".orbitals", input.emitterFile);
1961
- const listenerPath = path4.join(workDir, ".orbitals", input.listenerFile);
1962
- if (!fs4.existsSync(emitterPath)) return { success: false, error: `Emitter not found: ${emitterPath}` };
1963
- if (!fs4.existsSync(listenerPath)) return { success: false, error: `Listener not found: ${listenerPath}` };
1964
- const emitter = JSON.parse(fs4.readFileSync(emitterPath, "utf-8"));
1965
- const listener = JSON.parse(fs4.readFileSync(listenerPath, "utf-8"));
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"));
1966
1941
  const emitterTraits = emitter.traits || [];
1967
1942
  const listenerTraits = listener.traits || [];
1968
1943
  if (emitterTraits.length === 0 || listenerTraits.length === 0) {
@@ -1984,8 +1959,8 @@ function createConnectTool(workDir) {
1984
1959
  scope: "external"
1985
1960
  });
1986
1961
  listenerTrait.listens = listens;
1987
- fs4.writeFileSync(emitterPath, JSON.stringify(emitter, null, 2));
1988
- fs4.writeFileSync(listenerPath, JSON.stringify(listener, null, 2));
1962
+ fs3.writeFileSync(emitterPath, JSON.stringify(emitter, null, 2));
1963
+ fs3.writeFileSync(listenerPath, JSON.stringify(listener, null, 2));
1989
1964
  return {
1990
1965
  success: true,
1991
1966
  event: input.eventName,
@@ -2009,13 +1984,13 @@ function createConnectTool(workDir) {
2009
1984
  function createComposeTool(workDir) {
2010
1985
  return tool(
2011
1986
  async (input) => {
2012
- const orbitalsDir = path4.join(workDir, ".orbitals");
1987
+ const orbitalsDir = path3.join(workDir, ".orbitals");
2013
1988
  const orbitals = [];
2014
- const orbitalFiles = input.orbitalFiles ? JSON.parse(input.orbitalFiles) : fs4.readdirSync(orbitalsDir).filter((f) => f.endsWith(".json"));
1989
+ const orbitalFiles = input.orbitalFiles ? JSON.parse(input.orbitalFiles) : fs3.readdirSync(orbitalsDir).filter((f) => f.endsWith(".json"));
2015
1990
  for (const file of orbitalFiles) {
2016
- const filePath = path4.join(orbitalsDir, file);
2017
- if (!fs4.existsSync(filePath)) continue;
2018
- orbitals.push(JSON.parse(fs4.readFileSync(filePath, "utf-8")));
1991
+ const filePath = path3.join(orbitalsDir, file);
1992
+ if (!fs3.existsSync(filePath)) continue;
1993
+ orbitals.push(JSON.parse(fs3.readFileSync(filePath, "utf-8")));
2019
1994
  }
2020
1995
  if (orbitals.length === 0) {
2021
1996
  return { success: false, error: "No orbitals found in .orbitals/" };
@@ -2049,8 +2024,8 @@ function createComposeTool(workDir) {
2049
2024
  version: "1.0.0",
2050
2025
  orbitals
2051
2026
  };
2052
- const schemaPath = path4.join(workDir, "schema.orb");
2053
- fs4.writeFileSync(schemaPath, JSON.stringify(schema, null, 2));
2027
+ const schemaPath = path3.join(workDir, "schema.orb");
2028
+ fs3.writeFileSync(schemaPath, JSON.stringify(schema, null, 2));
2054
2029
  const validation = validateWithOrbitalCLI(schema, workDir);
2055
2030
  return {
2056
2031
  success: true,