zam-core 0.10.10 → 0.11.0

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/dist/cli/app.js CHANGED
@@ -810,6 +810,14 @@ import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as rea
810
810
  import { createRequire } from "module";
811
811
  import { homedir as homedir2 } from "os";
812
812
  import { dirname as dirname2, join as join2 } from "path";
813
+ function require2(id) {
814
+ if (!nodeRequire) {
815
+ nodeRequire = createRequire(
816
+ typeof __filename === "string" ? __filename : import.meta.url
817
+ );
818
+ }
819
+ return nodeRequire(id);
820
+ }
813
821
  function isRemoteDatabasePath(dbPath) {
814
822
  return /^(libsql|https?|wss?):\/\//i.test(dbPath);
815
823
  }
@@ -1133,7 +1141,7 @@ async function runMigrations(db) {
1133
1141
  );
1134
1142
  }
1135
1143
  }
1136
- var DEFAULT_DB_DIR, DEFAULT_DB_PATH, require2, TRANSIENT_REMOTE_ERROR_PATTERNS;
1144
+ var DEFAULT_DB_DIR, DEFAULT_DB_PATH, nodeRequire, TRANSIENT_REMOTE_ERROR_PATTERNS;
1137
1145
  var init_connection = __esm({
1138
1146
  "src/kernel/db/connection.ts"() {
1139
1147
  "use strict";
@@ -1143,7 +1151,6 @@ var init_connection = __esm({
1143
1151
  init_sync_adapter();
1144
1152
  DEFAULT_DB_DIR = join2(homedir2(), ".zam");
1145
1153
  DEFAULT_DB_PATH = join2(DEFAULT_DB_DIR, "zam.db");
1146
- require2 = createRequire(import.meta.url);
1147
1154
  TRANSIENT_REMOTE_ERROR_PATTERNS = [
1148
1155
  /status=5\d\d/i,
1149
1156
  /websocket/i,
@@ -5976,7 +5983,14 @@ var init_i18n = __esm({
5976
5983
  });
5977
5984
 
5978
5985
  // src/kernel/system/install-config.ts
5979
- import { existsSync as existsSync8, mkdirSync as mkdirSync7, readFileSync as readFileSync8, writeFileSync as writeFileSync5 } from "fs";
5986
+ import {
5987
+ existsSync as existsSync8,
5988
+ mkdirSync as mkdirSync7,
5989
+ readFileSync as readFileSync8,
5990
+ renameSync,
5991
+ unlinkSync,
5992
+ writeFileSync as writeFileSync5
5993
+ } from "fs";
5980
5994
  import { homedir as homedir6 } from "os";
5981
5995
  import { dirname as dirname4, join as join9 } from "path";
5982
5996
  import { ulid as ulid9 } from "ulid";
@@ -6004,8 +6018,19 @@ function loadInstallConfig(path = defaultConfigPath()) {
6004
6018
  function saveInstallConfig(config, path = defaultConfigPath()) {
6005
6019
  const dir = dirname4(path);
6006
6020
  if (!existsSync8(dir)) mkdirSync7(dir, { recursive: true });
6007
- writeFileSync5(path, `${JSON.stringify(config, null, 2)}
6021
+ const tempPath = join9(dir, `.config-${process.pid}-${Date.now()}.tmp`);
6022
+ writeFileSync5(tempPath, `${JSON.stringify(config, null, 2)}
6008
6023
  `, "utf-8");
6024
+ try {
6025
+ renameSync(tempPath, path);
6026
+ } catch (error) {
6027
+ try {
6028
+ unlinkSync(path);
6029
+ renameSync(tempPath, path);
6030
+ } catch {
6031
+ throw error;
6032
+ }
6033
+ }
6009
6034
  }
6010
6035
  function getInstallMode(path = defaultConfigPath()) {
6011
6036
  return loadInstallConfig(path).mode ?? "developer";
@@ -6143,6 +6168,105 @@ function setAgentConnectAutoDone(done, path = defaultConfigPath()) {
6143
6168
  }
6144
6169
  saveInstallConfig(config, path);
6145
6170
  }
6171
+ function getMachineCompanionConfig(path = defaultConfigPath()) {
6172
+ const raw = loadInstallConfig(path).companion;
6173
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
6174
+ const result = {};
6175
+ if (typeof raw.selectedUserId === "string") {
6176
+ result.selectedUserId = raw.selectedUserId;
6177
+ }
6178
+ if (typeof raw.selectedEvaluatorId === "string") {
6179
+ result.selectedEvaluatorId = raw.selectedEvaluatorId;
6180
+ }
6181
+ if (typeof raw.selectedVscodeModelId === "string") {
6182
+ result.selectedVscodeModelId = raw.selectedVscodeModelId;
6183
+ }
6184
+ if (raw.collapsed && typeof raw.collapsed === "object" && !Array.isArray(raw.collapsed)) {
6185
+ const collapsed = {};
6186
+ for (const [surface, value] of Object.entries(raw.collapsed)) {
6187
+ if (typeof value === "boolean") collapsed[surface] = value;
6188
+ }
6189
+ result.collapsed = collapsed;
6190
+ }
6191
+ return result;
6192
+ }
6193
+ function saveMachineCompanionConfig(companion, path = defaultConfigPath()) {
6194
+ const config = loadInstallConfig(path);
6195
+ config.companion = companion;
6196
+ saveInstallConfig(config, path);
6197
+ }
6198
+ function updateMachineCompanionConfig(update, path = defaultConfigPath()) {
6199
+ const companion = getMachineCompanionConfig(path);
6200
+ if ("selectedUserId" in update) {
6201
+ if (update.selectedUserId) {
6202
+ companion.selectedUserId = update.selectedUserId;
6203
+ } else {
6204
+ delete companion.selectedUserId;
6205
+ }
6206
+ }
6207
+ if ("selectedEvaluatorId" in update) {
6208
+ if (update.selectedEvaluatorId) {
6209
+ companion.selectedEvaluatorId = update.selectedEvaluatorId;
6210
+ } else {
6211
+ delete companion.selectedEvaluatorId;
6212
+ }
6213
+ }
6214
+ if (update.collapsed) {
6215
+ companion.collapsed = {
6216
+ ...companion.collapsed ?? {},
6217
+ [update.collapsed.surface]: update.collapsed.value
6218
+ };
6219
+ }
6220
+ saveMachineCompanionConfig(companion, path);
6221
+ return companion;
6222
+ }
6223
+ function getCompanionSelectedUserId(path = defaultConfigPath()) {
6224
+ return getMachineCompanionConfig(path).selectedUserId;
6225
+ }
6226
+ function setCompanionSelectedUserId(userId, path = defaultConfigPath()) {
6227
+ const companion = getMachineCompanionConfig(path);
6228
+ if (userId) {
6229
+ companion.selectedUserId = userId;
6230
+ } else {
6231
+ delete companion.selectedUserId;
6232
+ }
6233
+ saveMachineCompanionConfig(companion, path);
6234
+ }
6235
+ function getCompanionSelectedEvaluatorId(path = defaultConfigPath()) {
6236
+ return getMachineCompanionConfig(path).selectedEvaluatorId;
6237
+ }
6238
+ function setCompanionSelectedEvaluatorId(evaluatorId, path = defaultConfigPath()) {
6239
+ const companion = getMachineCompanionConfig(path);
6240
+ if (evaluatorId) {
6241
+ companion.selectedEvaluatorId = evaluatorId;
6242
+ } else {
6243
+ delete companion.selectedEvaluatorId;
6244
+ }
6245
+ saveMachineCompanionConfig(companion, path);
6246
+ }
6247
+ function getCompanionSelectedVscodeModelId(path = defaultConfigPath()) {
6248
+ return getMachineCompanionConfig(path).selectedVscodeModelId;
6249
+ }
6250
+ function setCompanionSelectedVscodeModelId(modelId, path = defaultConfigPath()) {
6251
+ const companion = getMachineCompanionConfig(path);
6252
+ if (modelId) {
6253
+ companion.selectedVscodeModelId = modelId;
6254
+ } else {
6255
+ delete companion.selectedVscodeModelId;
6256
+ }
6257
+ saveMachineCompanionConfig(companion, path);
6258
+ }
6259
+ function getCompanionCollapsed(path = defaultConfigPath()) {
6260
+ return getMachineCompanionConfig(path).collapsed ?? {};
6261
+ }
6262
+ function setCompanionCollapsed(surface, collapsed, path = defaultConfigPath()) {
6263
+ const companion = getMachineCompanionConfig(path);
6264
+ companion.collapsed = {
6265
+ ...companion.collapsed ?? {},
6266
+ [surface]: collapsed
6267
+ };
6268
+ saveMachineCompanionConfig(companion, path);
6269
+ }
6146
6270
  function getLastRepairedVersion(path = defaultConfigPath()) {
6147
6271
  return loadInstallConfig(path).lastRepairedVersion;
6148
6272
  }
@@ -6859,6 +6983,10 @@ __export(kernel_exports, {
6859
6983
  getCard: () => getCard,
6860
6984
  getCardById: () => getCardById,
6861
6985
  getCardDeletionImpact: () => getCardDeletionImpact,
6986
+ getCompanionCollapsed: () => getCompanionCollapsed,
6987
+ getCompanionSelectedEvaluatorId: () => getCompanionSelectedEvaluatorId,
6988
+ getCompanionSelectedUserId: () => getCompanionSelectedUserId,
6989
+ getCompanionSelectedVscodeModelId: () => getCompanionSelectedVscodeModelId,
6862
6990
  getConfiguredWorkspaces: () => getConfiguredWorkspaces,
6863
6991
  getDatabaseTargetInfo: () => getDatabaseTargetInfo,
6864
6992
  getDefaultDbPath: () => getDefaultDbPath,
@@ -6876,6 +7004,7 @@ __export(kernel_exports, {
6876
7004
  getLastRepairedVersion: () => getLastRepairedVersion,
6877
7005
  getMachineAiConfig: () => getMachineAiConfig,
6878
7006
  getMachineAiModels: () => getMachineAiModels,
7007
+ getMachineCompanionConfig: () => getMachineCompanionConfig,
6879
7008
  getMonitorDir: () => getMonitorDir,
6880
7009
  getMonitorLogStats: () => getMonitorLogStats,
6881
7010
  getMonitorPath: () => getMonitorPath,
@@ -6961,12 +7090,17 @@ __export(kernel_exports, {
6961
7090
  saveInstallConfig: () => saveInstallConfig,
6962
7091
  saveMachineAiConfig: () => saveMachineAiConfig,
6963
7092
  saveMachineAiModels: () => saveMachineAiModels,
7093
+ saveMachineCompanionConfig: () => saveMachineCompanionConfig,
6964
7094
  searchTokensHybrid: () => searchTokensHybrid,
6965
7095
  serializeGoal: () => serializeGoal,
6966
7096
  setADOCredentials: () => setADOCredentials,
6967
7097
  setActiveWorkspaceContext: () => setActiveWorkspaceContext,
6968
7098
  setActiveWorkspaceId: () => setActiveWorkspaceId,
6969
7099
  setAgentConnectAutoDone: () => setAgentConnectAutoDone,
7100
+ setCompanionCollapsed: () => setCompanionCollapsed,
7101
+ setCompanionSelectedEvaluatorId: () => setCompanionSelectedEvaluatorId,
7102
+ setCompanionSelectedUserId: () => setCompanionSelectedUserId,
7103
+ setCompanionSelectedVscodeModelId: () => setCompanionSelectedVscodeModelId,
6970
7104
  setInstallChannel: () => setInstallChannel,
6971
7105
  setInstallMode: () => setInstallMode,
6972
7106
  setLastRepairedVersion: () => setLastRepairedVersion,
@@ -6987,6 +7121,7 @@ __export(kernel_exports, {
6987
7121
  updateCard: () => updateCard,
6988
7122
  updateGoalStatus: () => updateGoalStatus,
6989
7123
  updateKnowledgeContext: () => updateKnowledgeContext,
7124
+ updateMachineCompanionConfig: () => updateMachineCompanionConfig,
6990
7125
  updateToken: () => updateToken,
6991
7126
  upsertConfiguredWorkspace: () => upsertConfiguredWorkspace,
6992
7127
  upsertTokenEmbedding: () => upsertTokenEmbedding,
@@ -7075,7 +7210,7 @@ import {
7075
7210
  accessSync,
7076
7211
  constants,
7077
7212
  existsSync as existsSync11,
7078
- unlinkSync,
7213
+ unlinkSync as unlinkSync2,
7079
7214
  writeFileSync as writeFileSync6
7080
7215
  } from "fs";
7081
7216
  import { tmpdir } from "os";
@@ -7222,7 +7357,7 @@ Run this manually in a new terminal:
7222
7357
  }
7223
7358
  } finally {
7224
7359
  try {
7225
- unlinkSync(tmpFile);
7360
+ unlinkSync2(tmpFile);
7226
7361
  } catch {
7227
7362
  }
7228
7363
  }
@@ -7920,6 +8055,24 @@ function planVscodeExtensionInstall(options) {
7920
8055
  launch: { command: options.zamPath, args: ["mcp"] }
7921
8056
  };
7922
8057
  }
8058
+ function compareVersions2(a, b) {
8059
+ const parse = (value) => value.split(".").map((part) => Number.parseInt(part, 10) || 0);
8060
+ const [aParts, bParts] = [parse(a), parse(b)];
8061
+ for (let i = 0; i < Math.max(aParts.length, bParts.length); i += 1) {
8062
+ const diff = (aParts[i] ?? 0) - (bParts[i] ?? 0);
8063
+ if (diff !== 0) return diff;
8064
+ }
8065
+ return 0;
8066
+ }
8067
+ function installedCompanionVersion(codePath, query) {
8068
+ try {
8069
+ const output = query(codePath, ["--list-extensions", "--show-versions"]);
8070
+ const match = output.match(/^zam-os\.zam-companion@(\S+)$/im);
8071
+ return match ? match[1] : null;
8072
+ } catch {
8073
+ return null;
8074
+ }
8075
+ }
7923
8076
  function installVscodeExtension(options) {
7924
8077
  const plan = planVscodeExtensionInstall(options);
7925
8078
  if (options.dryRun) return { ...plan, action: "planned" };
@@ -7943,6 +8096,18 @@ function installVscodeExtension(options) {
7943
8096
  shell: invocation.shell
7944
8097
  });
7945
8098
  });
8099
+ const query = options.query ?? ((command, args) => {
8100
+ const invocation = buildVscodeCliInvocation(command, args);
8101
+ return execFileSync3(invocation.command, invocation.args, {
8102
+ stdio: "pipe",
8103
+ shell: invocation.shell,
8104
+ encoding: "utf8"
8105
+ });
8106
+ });
8107
+ const installed = installedCompanionVersion(plan.codePath, query);
8108
+ if (installed && compareVersions2(plan.version, installed) < 0) {
8109
+ return { ...plan, action: "kept-newer" };
8110
+ }
7946
8111
  run(plan.codePath, ["--install-extension", plan.vsixPath, "--force"]);
7947
8112
  if (changed) {
7948
8113
  mkdirSync9(dirname6(plan.launchConfigPath), { recursive: true });
@@ -7998,7 +8163,7 @@ function resolveDeps(deps) {
7998
8163
  findZam: deps.findZam ?? (() => {
7999
8164
  const globalZam = findExecutable("zam");
8000
8165
  if (globalZam) return globalZam;
8001
- if (process.argv[1] && process.argv[1].endsWith("index.js")) {
8166
+ if (process.argv[1]?.endsWith("index.js")) {
8002
8167
  return process.argv[1];
8003
8168
  }
8004
8169
  return null;
@@ -8115,12 +8280,16 @@ function performAgentConnect(opts = {}, deps = {}) {
8115
8280
  skills
8116
8281
  };
8117
8282
  }
8283
+ var INSPECTED_HARNESSES = [
8284
+ ...USER_SCOPED_CONNECT_HARNESSES,
8285
+ "claude-code"
8286
+ ];
8118
8287
  function inspectConnectHarnesses(deps = {}) {
8119
8288
  const d = resolveDeps(deps);
8120
8289
  const foundZam = d.findZam();
8121
8290
  const zamPath = foundZam ?? "zam";
8122
8291
  const installed = new Set(d.detect());
8123
- const harnesses = USER_SCOPED_CONNECT_HARNESSES.map((harness) => {
8292
+ const harnesses = INSPECTED_HARNESSES.map((harness) => {
8124
8293
  const status = {
8125
8294
  harness,
8126
8295
  label: CONNECT_HARNESS_LABELS[harness],
@@ -10091,7 +10260,7 @@ async function readWebLink(url) {
10091
10260
  redirect: "manual",
10092
10261
  signal: controller.signal,
10093
10262
  headers: {
10094
- "User-Agent": "ZAM-Content-Studio/0.10.10"
10263
+ "User-Agent": "ZAM-Content-Studio/0.10.11"
10095
10264
  }
10096
10265
  });
10097
10266
  if (res.status >= 300 && res.status < 400) {
@@ -31206,6 +31375,7 @@ bridgeCommand.command("local-llm-hints").description("Detect installed local LLM
31206
31375
  var UI_WRITABLE_SETTINGS = /* @__PURE__ */ new Set([
31207
31376
  "llm.enabled",
31208
31377
  "llm.vision.enabled",
31378
+ "recall.quick_mode",
31209
31379
  "system.locale"
31210
31380
  ]);
31211
31381
  bridgeCommand.command("setting-set").description("Set a single allowlisted ZAM setting value (JSON)").requiredOption("--key <key>", "Setting key").requiredOption("--value <value>", "Setting value").action(async (opts) => {
@@ -31425,6 +31595,9 @@ bridgeCommand.command("get-settings").description("Get active ZAM settings (JSON
31425
31595
  enabled,
31426
31596
  url,
31427
31597
  model
31598
+ },
31599
+ recall: {
31600
+ quickMode: await getSetting(db, "recall.quick_mode") === "true"
31428
31601
  }
31429
31602
  });
31430
31603
  });
@@ -36771,7 +36944,11 @@ import { Command as Command17 } from "commander";
36771
36944
  var settingsCommand = new Command17("settings").description(
36772
36945
  "Manage user settings"
36773
36946
  );
36774
- var BOOLEAN_SETTING_KEYS = /* @__PURE__ */ new Set(["llm.enabled", "llm.vision.enabled"]);
36947
+ var BOOLEAN_SETTING_KEYS = /* @__PURE__ */ new Set([
36948
+ "llm.enabled",
36949
+ "llm.vision.enabled",
36950
+ "recall.quick_mode"
36951
+ ]);
36775
36952
  function normalizeSettingValue(key, value) {
36776
36953
  if (!BOOLEAN_SETTING_KEYS.has(key)) return value;
36777
36954
  const lower = value.toLowerCase();