@cydm/happy-elves 0.1.0-beta.254 → 0.1.0-beta.258

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cydm/happy-elves-cli",
3
- "version": "0.1.0-beta.254",
3
+ "version": "0.1.0-beta.258",
4
4
  "private": true,
5
5
  "type": "module"
6
6
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cydm/happy-elves-daemon",
3
- "version": "0.1.0-beta.254",
3
+ "version": "0.1.0-beta.258",
4
4
  "private": true,
5
5
  "type": "module"
6
6
  }
@@ -21,17 +21,47 @@ function primitiveSupport(value) {
21
21
  function historyModel(value) {
22
22
  return value === "append-only" || value === "authoritative-linear" ? value : undefined;
23
23
  }
24
+ function stringField(value) {
25
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
26
+ }
27
+ function agentModelOptions(value) {
28
+ if (!Array.isArray(value))
29
+ return undefined;
30
+ const seen = new Set();
31
+ const models = value.flatMap((item) => {
32
+ if (!isRecord(item))
33
+ return [];
34
+ const id = stringField(item.id);
35
+ if (!id || seen.has(id))
36
+ return [];
37
+ seen.add(id);
38
+ const label = stringField(item.label);
39
+ const reason = stringField(item.reason);
40
+ return [{
41
+ id,
42
+ ...(label ? { label } : {}),
43
+ ...(item.unavailable === true ? { unavailable: true } : {}),
44
+ ...(reason ? { reason } : {}),
45
+ }];
46
+ });
47
+ return models.length > 0 ? models : undefined;
48
+ }
24
49
  export function normalizeMachineCapabilities(value) {
25
50
  const record = isRecord(value) ? value : {};
26
51
  const agents = Array.isArray(record.agents)
27
52
  ? record.agents.flatMap((agent) => {
28
53
  if (!isRecord(agent) || typeof agent.id !== "string" || typeof agent.label !== "string")
29
54
  return [];
55
+ const agentHistoryModel = historyModel(agent.historyModel);
56
+ const defaultModel = stringField(agent.defaultModel);
57
+ const models = agentModelOptions(agent.models);
30
58
  return [{
31
59
  id: agent.id,
32
60
  label: agent.label,
33
61
  ...(typeof agent.command === "string" ? { command: agent.command } : {}),
34
- ...(historyModel(agent.historyModel) ? { historyModel: historyModel(agent.historyModel) } : {}),
62
+ ...(agentHistoryModel ? { historyModel: agentHistoryModel } : {}),
63
+ ...(defaultModel ? { defaultModel } : {}),
64
+ ...(models ? { models } : {}),
35
65
  ...(isRecord(agent.sessionPrimitives)
36
66
  ? {
37
67
  sessionPrimitives: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cydm/happy-elves",
3
- "version": "0.1.0-beta.254",
3
+ "version": "0.1.0-beta.258",
4
4
  "description": "Remote controller for local coding agents with hosted or self-hosted relay support.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -360,8 +360,8 @@ function modelOptionsFromEnv(value) {
360
360
  });
361
361
  }
362
362
  function modelOptionsFromCodexCache(codexHome) {
363
- const cachePath = path.join(codexHome?.trim() || path.join(os.homedir(), ".codex"), "models_cache.json");
364
- if (!existsSync(cachePath))
363
+ const cachePath = codexModelCachePaths(codexHome).find((candidate) => existsSync(candidate));
364
+ if (!cachePath)
365
365
  return [];
366
366
  try {
367
367
  const parsed = JSON.parse(readFileSync(cachePath, "utf8"));
@@ -388,6 +388,26 @@ function modelOptionsFromCodexCache(codexHome) {
388
388
  return [];
389
389
  }
390
390
  }
391
+ function codexModelCachePaths(codexHome) {
392
+ const candidates = [
393
+ process.env.HAPPY_ELVES_CODEX_MODELS_CACHE,
394
+ codexHome?.trim() ? path.join(codexHome.trim(), "models_cache.json") : undefined,
395
+ process.env.APPDATA ? path.join(process.env.APPDATA, "Codex", "models_cache.json") : undefined,
396
+ process.env.APPDATA ? path.join(process.env.APPDATA, "codex", "models_cache.json") : undefined,
397
+ process.env.LOCALAPPDATA ? path.join(process.env.LOCALAPPDATA, "Codex", "models_cache.json") : undefined,
398
+ process.env.LOCALAPPDATA ? path.join(process.env.LOCALAPPDATA, "codex", "models_cache.json") : undefined,
399
+ path.join(os.homedir(), ".codex", "models_cache.json"),
400
+ process.env.USERPROFILE ? path.join(process.env.USERPROFILE, ".codex", "models_cache.json") : undefined,
401
+ ];
402
+ const seen = new Set();
403
+ return candidates.flatMap((candidate) => {
404
+ const normalized = candidate?.trim();
405
+ if (!normalized || seen.has(normalized))
406
+ return [];
407
+ seen.add(normalized);
408
+ return [normalized];
409
+ });
410
+ }
391
411
  function isRecord(value) {
392
412
  return typeof value === "object" && value !== null && !Array.isArray(value);
393
413
  }