zam-core 0.10.11 → 0.11.1

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,178 @@ 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.selectedVscodeEvaluatorId === "string") {
6182
+ result.selectedVscodeEvaluatorId = raw.selectedVscodeEvaluatorId;
6183
+ }
6184
+ if (typeof raw.selectedAntigravityEvaluatorId === "string") {
6185
+ result.selectedAntigravityEvaluatorId = raw.selectedAntigravityEvaluatorId;
6186
+ }
6187
+ if (typeof raw.selectedVscodeModelId === "string") {
6188
+ result.selectedVscodeModelId = raw.selectedVscodeModelId;
6189
+ }
6190
+ if (typeof raw.selectedAntigravityModelId === "string") {
6191
+ result.selectedAntigravityModelId = raw.selectedAntigravityModelId;
6192
+ }
6193
+ if (raw.collapsed && typeof raw.collapsed === "object" && !Array.isArray(raw.collapsed)) {
6194
+ const collapsed = {};
6195
+ for (const [surface, value] of Object.entries(raw.collapsed)) {
6196
+ if (typeof value === "boolean") collapsed[surface] = value;
6197
+ }
6198
+ result.collapsed = collapsed;
6199
+ }
6200
+ return result;
6201
+ }
6202
+ function saveMachineCompanionConfig(companion, path = defaultConfigPath()) {
6203
+ const config = loadInstallConfig(path);
6204
+ config.companion = companion;
6205
+ saveInstallConfig(config, path);
6206
+ }
6207
+ function updateMachineCompanionConfig(update, path = defaultConfigPath()) {
6208
+ const companion = getMachineCompanionConfig(path);
6209
+ if ("selectedUserId" in update) {
6210
+ if (update.selectedUserId) {
6211
+ companion.selectedUserId = update.selectedUserId;
6212
+ } else {
6213
+ delete companion.selectedUserId;
6214
+ }
6215
+ }
6216
+ if ("selectedEvaluatorId" in update) {
6217
+ if (update.selectedEvaluatorId) {
6218
+ companion.selectedEvaluatorId = update.selectedEvaluatorId;
6219
+ } else {
6220
+ delete companion.selectedEvaluatorId;
6221
+ }
6222
+ }
6223
+ if ("selectedVscodeEvaluatorId" in update) {
6224
+ if (update.selectedVscodeEvaluatorId) {
6225
+ companion.selectedVscodeEvaluatorId = update.selectedVscodeEvaluatorId;
6226
+ } else {
6227
+ delete companion.selectedVscodeEvaluatorId;
6228
+ }
6229
+ }
6230
+ if ("selectedAntigravityEvaluatorId" in update) {
6231
+ if (update.selectedAntigravityEvaluatorId) {
6232
+ companion.selectedAntigravityEvaluatorId = update.selectedAntigravityEvaluatorId;
6233
+ } else {
6234
+ delete companion.selectedAntigravityEvaluatorId;
6235
+ }
6236
+ }
6237
+ if ("selectedVscodeModelId" in update) {
6238
+ if (update.selectedVscodeModelId) {
6239
+ companion.selectedVscodeModelId = update.selectedVscodeModelId;
6240
+ } else {
6241
+ delete companion.selectedVscodeModelId;
6242
+ }
6243
+ }
6244
+ if ("selectedAntigravityModelId" in update) {
6245
+ if (update.selectedAntigravityModelId) {
6246
+ companion.selectedAntigravityModelId = update.selectedAntigravityModelId;
6247
+ } else {
6248
+ delete companion.selectedAntigravityModelId;
6249
+ }
6250
+ }
6251
+ if (update.collapsed) {
6252
+ companion.collapsed = {
6253
+ ...companion.collapsed ?? {},
6254
+ [update.collapsed.surface]: update.collapsed.value
6255
+ };
6256
+ }
6257
+ saveMachineCompanionConfig(companion, path);
6258
+ return companion;
6259
+ }
6260
+ function getCompanionSelectedUserId(path = defaultConfigPath()) {
6261
+ return getMachineCompanionConfig(path).selectedUserId;
6262
+ }
6263
+ function setCompanionSelectedUserId(userId, path = defaultConfigPath()) {
6264
+ const companion = getMachineCompanionConfig(path);
6265
+ if (userId) {
6266
+ companion.selectedUserId = userId;
6267
+ } else {
6268
+ delete companion.selectedUserId;
6269
+ }
6270
+ saveMachineCompanionConfig(companion, path);
6271
+ }
6272
+ function getCompanionSelectedEvaluatorId(path = defaultConfigPath()) {
6273
+ return getMachineCompanionConfig(path).selectedEvaluatorId;
6274
+ }
6275
+ function setCompanionSelectedEvaluatorId(evaluatorId, path = defaultConfigPath()) {
6276
+ const companion = getMachineCompanionConfig(path);
6277
+ if (evaluatorId) {
6278
+ companion.selectedEvaluatorId = evaluatorId;
6279
+ } else {
6280
+ delete companion.selectedEvaluatorId;
6281
+ }
6282
+ saveMachineCompanionConfig(companion, path);
6283
+ }
6284
+ function getCompanionSelectedVscodeEvaluatorId(path = defaultConfigPath()) {
6285
+ return getMachineCompanionConfig(path).selectedVscodeEvaluatorId;
6286
+ }
6287
+ function setCompanionSelectedVscodeEvaluatorId(evaluatorId, path = defaultConfigPath()) {
6288
+ const companion = getMachineCompanionConfig(path);
6289
+ if (evaluatorId) {
6290
+ companion.selectedVscodeEvaluatorId = evaluatorId;
6291
+ } else {
6292
+ delete companion.selectedVscodeEvaluatorId;
6293
+ }
6294
+ saveMachineCompanionConfig(companion, path);
6295
+ }
6296
+ function getCompanionSelectedAntigravityEvaluatorId(path = defaultConfigPath()) {
6297
+ return getMachineCompanionConfig(path).selectedAntigravityEvaluatorId;
6298
+ }
6299
+ function setCompanionSelectedAntigravityEvaluatorId(evaluatorId, path = defaultConfigPath()) {
6300
+ const companion = getMachineCompanionConfig(path);
6301
+ if (evaluatorId) {
6302
+ companion.selectedAntigravityEvaluatorId = evaluatorId;
6303
+ } else {
6304
+ delete companion.selectedAntigravityEvaluatorId;
6305
+ }
6306
+ saveMachineCompanionConfig(companion, path);
6307
+ }
6308
+ function getCompanionSelectedVscodeModelId(path = defaultConfigPath()) {
6309
+ return getMachineCompanionConfig(path).selectedVscodeModelId;
6310
+ }
6311
+ function setCompanionSelectedVscodeModelId(modelId, path = defaultConfigPath()) {
6312
+ const companion = getMachineCompanionConfig(path);
6313
+ if (modelId) {
6314
+ companion.selectedVscodeModelId = modelId;
6315
+ } else {
6316
+ delete companion.selectedVscodeModelId;
6317
+ }
6318
+ saveMachineCompanionConfig(companion, path);
6319
+ }
6320
+ function getCompanionSelectedAntigravityModelId(path = defaultConfigPath()) {
6321
+ return getMachineCompanionConfig(path).selectedAntigravityModelId;
6322
+ }
6323
+ function setCompanionSelectedAntigravityModelId(modelId, path = defaultConfigPath()) {
6324
+ const companion = getMachineCompanionConfig(path);
6325
+ if (modelId) {
6326
+ companion.selectedAntigravityModelId = modelId;
6327
+ } else {
6328
+ delete companion.selectedAntigravityModelId;
6329
+ }
6330
+ saveMachineCompanionConfig(companion, path);
6331
+ }
6332
+ function getCompanionCollapsed(path = defaultConfigPath()) {
6333
+ return getMachineCompanionConfig(path).collapsed ?? {};
6334
+ }
6335
+ function setCompanionCollapsed(surface, collapsed, path = defaultConfigPath()) {
6336
+ const companion = getMachineCompanionConfig(path);
6337
+ companion.collapsed = {
6338
+ ...companion.collapsed ?? {},
6339
+ [surface]: collapsed
6340
+ };
6341
+ saveMachineCompanionConfig(companion, path);
6342
+ }
6146
6343
  function getLastRepairedVersion(path = defaultConfigPath()) {
6147
6344
  return loadInstallConfig(path).lastRepairedVersion;
6148
6345
  }
@@ -6859,6 +7056,13 @@ __export(kernel_exports, {
6859
7056
  getCard: () => getCard,
6860
7057
  getCardById: () => getCardById,
6861
7058
  getCardDeletionImpact: () => getCardDeletionImpact,
7059
+ getCompanionCollapsed: () => getCompanionCollapsed,
7060
+ getCompanionSelectedAntigravityEvaluatorId: () => getCompanionSelectedAntigravityEvaluatorId,
7061
+ getCompanionSelectedAntigravityModelId: () => getCompanionSelectedAntigravityModelId,
7062
+ getCompanionSelectedEvaluatorId: () => getCompanionSelectedEvaluatorId,
7063
+ getCompanionSelectedUserId: () => getCompanionSelectedUserId,
7064
+ getCompanionSelectedVscodeEvaluatorId: () => getCompanionSelectedVscodeEvaluatorId,
7065
+ getCompanionSelectedVscodeModelId: () => getCompanionSelectedVscodeModelId,
6862
7066
  getConfiguredWorkspaces: () => getConfiguredWorkspaces,
6863
7067
  getDatabaseTargetInfo: () => getDatabaseTargetInfo,
6864
7068
  getDefaultDbPath: () => getDefaultDbPath,
@@ -6876,6 +7080,7 @@ __export(kernel_exports, {
6876
7080
  getLastRepairedVersion: () => getLastRepairedVersion,
6877
7081
  getMachineAiConfig: () => getMachineAiConfig,
6878
7082
  getMachineAiModels: () => getMachineAiModels,
7083
+ getMachineCompanionConfig: () => getMachineCompanionConfig,
6879
7084
  getMonitorDir: () => getMonitorDir,
6880
7085
  getMonitorLogStats: () => getMonitorLogStats,
6881
7086
  getMonitorPath: () => getMonitorPath,
@@ -6961,12 +7166,20 @@ __export(kernel_exports, {
6961
7166
  saveInstallConfig: () => saveInstallConfig,
6962
7167
  saveMachineAiConfig: () => saveMachineAiConfig,
6963
7168
  saveMachineAiModels: () => saveMachineAiModels,
7169
+ saveMachineCompanionConfig: () => saveMachineCompanionConfig,
6964
7170
  searchTokensHybrid: () => searchTokensHybrid,
6965
7171
  serializeGoal: () => serializeGoal,
6966
7172
  setADOCredentials: () => setADOCredentials,
6967
7173
  setActiveWorkspaceContext: () => setActiveWorkspaceContext,
6968
7174
  setActiveWorkspaceId: () => setActiveWorkspaceId,
6969
7175
  setAgentConnectAutoDone: () => setAgentConnectAutoDone,
7176
+ setCompanionCollapsed: () => setCompanionCollapsed,
7177
+ setCompanionSelectedAntigravityEvaluatorId: () => setCompanionSelectedAntigravityEvaluatorId,
7178
+ setCompanionSelectedAntigravityModelId: () => setCompanionSelectedAntigravityModelId,
7179
+ setCompanionSelectedEvaluatorId: () => setCompanionSelectedEvaluatorId,
7180
+ setCompanionSelectedUserId: () => setCompanionSelectedUserId,
7181
+ setCompanionSelectedVscodeEvaluatorId: () => setCompanionSelectedVscodeEvaluatorId,
7182
+ setCompanionSelectedVscodeModelId: () => setCompanionSelectedVscodeModelId,
6970
7183
  setInstallChannel: () => setInstallChannel,
6971
7184
  setInstallMode: () => setInstallMode,
6972
7185
  setLastRepairedVersion: () => setLastRepairedVersion,
@@ -6987,6 +7200,7 @@ __export(kernel_exports, {
6987
7200
  updateCard: () => updateCard,
6988
7201
  updateGoalStatus: () => updateGoalStatus,
6989
7202
  updateKnowledgeContext: () => updateKnowledgeContext,
7203
+ updateMachineCompanionConfig: () => updateMachineCompanionConfig,
6990
7204
  updateToken: () => updateToken,
6991
7205
  upsertConfiguredWorkspace: () => upsertConfiguredWorkspace,
6992
7206
  upsertTokenEmbedding: () => upsertTokenEmbedding,
@@ -7075,7 +7289,7 @@ import {
7075
7289
  accessSync,
7076
7290
  constants,
7077
7291
  existsSync as existsSync11,
7078
- unlinkSync,
7292
+ unlinkSync as unlinkSync2,
7079
7293
  writeFileSync as writeFileSync6
7080
7294
  } from "fs";
7081
7295
  import { tmpdir } from "os";
@@ -7222,7 +7436,7 @@ Run this manually in a new terminal:
7222
7436
  }
7223
7437
  } finally {
7224
7438
  try {
7225
- unlinkSync(tmpFile);
7439
+ unlinkSync2(tmpFile);
7226
7440
  } catch {
7227
7441
  }
7228
7442
  }
@@ -7920,6 +8134,24 @@ function planVscodeExtensionInstall(options) {
7920
8134
  launch: { command: options.zamPath, args: ["mcp"] }
7921
8135
  };
7922
8136
  }
8137
+ function compareVersions2(a, b) {
8138
+ const parse = (value) => value.split(".").map((part) => Number.parseInt(part, 10) || 0);
8139
+ const [aParts, bParts] = [parse(a), parse(b)];
8140
+ for (let i = 0; i < Math.max(aParts.length, bParts.length); i += 1) {
8141
+ const diff = (aParts[i] ?? 0) - (bParts[i] ?? 0);
8142
+ if (diff !== 0) return diff;
8143
+ }
8144
+ return 0;
8145
+ }
8146
+ function installedCompanionVersion(codePath, query) {
8147
+ try {
8148
+ const output = query(codePath, ["--list-extensions", "--show-versions"]);
8149
+ const match = output.match(/^zam-os\.zam-companion@(\S+)$/im);
8150
+ return match ? match[1] : null;
8151
+ } catch {
8152
+ return null;
8153
+ }
8154
+ }
7923
8155
  function installVscodeExtension(options) {
7924
8156
  const plan = planVscodeExtensionInstall(options);
7925
8157
  if (options.dryRun) return { ...plan, action: "planned" };
@@ -7943,6 +8175,18 @@ function installVscodeExtension(options) {
7943
8175
  shell: invocation.shell
7944
8176
  });
7945
8177
  });
8178
+ const query = options.query ?? ((command, args) => {
8179
+ const invocation = buildVscodeCliInvocation(command, args);
8180
+ return execFileSync3(invocation.command, invocation.args, {
8181
+ stdio: "pipe",
8182
+ shell: invocation.shell,
8183
+ encoding: "utf8"
8184
+ });
8185
+ });
8186
+ const installed = installedCompanionVersion(plan.codePath, query);
8187
+ if (installed && compareVersions2(plan.version, installed) < 0) {
8188
+ return { ...plan, action: "kept-newer" };
8189
+ }
7946
8190
  run(plan.codePath, ["--install-extension", plan.vsixPath, "--force"]);
7947
8191
  if (changed) {
7948
8192
  mkdirSync9(dirname6(plan.launchConfigPath), { recursive: true });
@@ -8115,12 +8359,16 @@ function performAgentConnect(opts = {}, deps = {}) {
8115
8359
  skills
8116
8360
  };
8117
8361
  }
8362
+ var INSPECTED_HARNESSES = [
8363
+ ...USER_SCOPED_CONNECT_HARNESSES,
8364
+ "claude-code"
8365
+ ];
8118
8366
  function inspectConnectHarnesses(deps = {}) {
8119
8367
  const d = resolveDeps(deps);
8120
8368
  const foundZam = d.findZam();
8121
8369
  const zamPath = foundZam ?? "zam";
8122
8370
  const installed = new Set(d.detect());
8123
- const harnesses = USER_SCOPED_CONNECT_HARNESSES.map((harness) => {
8371
+ const harnesses = INSPECTED_HARNESSES.map((harness) => {
8124
8372
  const status = {
8125
8373
  harness,
8126
8374
  label: CONNECT_HARNESS_LABELS[harness],
@@ -10091,7 +10339,7 @@ async function readWebLink(url) {
10091
10339
  redirect: "manual",
10092
10340
  signal: controller.signal,
10093
10341
  headers: {
10094
- "User-Agent": "ZAM-Content-Studio/0.10.11"
10342
+ "User-Agent": "ZAM-Content-Studio/0.11.1"
10095
10343
  }
10096
10344
  });
10097
10345
  if (res.status >= 300 && res.status < 400) {