@vectorize-io/self-driving-agents 0.0.16 → 0.0.18

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.js CHANGED
@@ -125,6 +125,33 @@ function enableKnowledgeTools() {
125
125
  pc.enableKnowledgeTools = true;
126
126
  writeFileSync(OPENCLAW_CONFIG_PATH, JSON.stringify(config, null, 2) + "\n");
127
127
  }
128
+ // SDA agents are isolated per-agent only — no channel/user. The plugin's default
129
+ // (["agent","channel","user"]) produces banks like "marketing-seo::unknown::anonymous"
130
+ // for local sessions where channel/sender aren't populated.
131
+ async function ensureOpenClawAgentGranularity() {
132
+ const config = readOpenClawConfig();
133
+ if (!config)
134
+ return;
135
+ const pc = config.plugins?.entries?.["hindsight-openclaw"]?.config;
136
+ if (!pc)
137
+ return;
138
+ const current = pc.dynamicBankGranularity;
139
+ const desired = ["agent"];
140
+ const matches = Array.isArray(current) && current.length === 1 && current[0] === "agent";
141
+ if (matches)
142
+ return;
143
+ if (current && current.length > 0) {
144
+ const ok = await p.confirm({
145
+ message: `Plugin has dynamicBankGranularity=${color.yellow(JSON.stringify(current))}. SDA agents need ${color.cyan('["agent"]')}. Override?`,
146
+ initialValue: true,
147
+ });
148
+ if (p.isCancel(ok) || !ok)
149
+ return;
150
+ }
151
+ pc.dynamicBankGranularity = desired;
152
+ writeFileSync(OPENCLAW_CONFIG_PATH, JSON.stringify(config, null, 2) + "\n");
153
+ p.log.success("Set dynamicBankGranularity = [\"agent\"] for per-agent bank isolation");
154
+ }
128
155
  const MIN_PLUGIN_VERSION = "0.7.2";
129
156
  function getInstalledPluginVersion() {
130
157
  try {
@@ -178,7 +205,7 @@ function resolveFromPlugin(agentId) {
178
205
  bankId = pc.bankId;
179
206
  }
180
207
  else {
181
- const granularity = pc.dynamicBankGranularity || ["agent", "channel", "user"];
208
+ const granularity = pc.dynamicBankGranularity || ["agent"];
182
209
  const fieldMap = {
183
210
  agent: agentId,
184
211
  channel: "unknown",
@@ -724,10 +751,12 @@ async function main() {
724
751
  if (harness === "openclaw") {
725
752
  await ensurePlugin();
726
753
  enableKnowledgeTools();
754
+ await ensureOpenClawAgentGranularity();
727
755
  ({ apiUrl, bankId, apiToken } = resolveFromPlugin(agentId));
728
756
  }
729
757
  else if (harness === "nemoclaw") {
730
758
  await ensureNemoClawPlugin(sandbox, agentId);
759
+ await ensureOpenClawAgentGranularity();
731
760
  ({ apiUrl, bankId, apiToken } = resolveFromPlugin(agentId));
732
761
  }
733
762
  else if (harness === "hermes") {
@@ -948,22 +977,24 @@ async function main() {
948
977
  /* ignore */
949
978
  }
950
979
  }
951
- const allowedTools = userSettings.allowedTools || [];
980
+ const permissions = (userSettings.permissions ||= {});
981
+ const allow = permissions.allow || [];
952
982
  const toolsToAllow = [
953
- "mcp__hindsight__*",
983
+ "mcp__plugin_hindsight-memory_hindsight__*",
954
984
  "Skill(hindsight-memory:create-agent)",
955
985
  `Bash(ls ~/.self-driving-agents/*)`,
956
986
  `Bash(cat ~/.self-driving-agents/*)`,
957
987
  ];
958
988
  let updated = false;
959
989
  for (const tool of toolsToAllow) {
960
- if (!allowedTools.includes(tool)) {
961
- allowedTools.push(tool);
990
+ if (!allow.includes(tool)) {
991
+ allow.push(tool);
962
992
  updated = true;
963
993
  }
964
994
  }
965
995
  if (updated) {
966
- userSettings.allowedTools = allowedTools;
996
+ permissions.allow = allow;
997
+ userSettings.permissions = permissions;
967
998
  writeFileSync(userSettingsPath, JSON.stringify(userSettings, null, 2) + "\n");
968
999
  p.log.success("Auto-approved hindsight tools in Claude Code");
969
1000
  }
@@ -580,7 +580,7 @@ describe("claude-code marketplace detection", () => {
580
580
  });
581
581
  });
582
582
  describe("claude-code allowed-tools merge", () => {
583
- // Mirrors the auto-approve logic that merges entries into ~/.claude/settings.json's allowedTools.
583
+ // Mirrors the auto-approve logic that merges entries into ~/.claude/settings.json's permissions.allow.
584
584
  function mergeAllowed(existing, toAdd) {
585
585
  const merged = [...existing];
586
586
  let updated = false;
@@ -593,7 +593,7 @@ describe("claude-code allowed-tools merge", () => {
593
593
  return { merged, updated };
594
594
  }
595
595
  const HINDSIGHT_TOOLS = [
596
- "mcp__hindsight__*",
596
+ "mcp__plugin_hindsight-memory_hindsight__*",
597
597
  "Skill(hindsight-memory:create-agent)",
598
598
  "Bash(ls ~/.self-driving-agents/*)",
599
599
  "Bash(cat ~/.self-driving-agents/*)",
@@ -607,7 +607,7 @@ describe("claude-code allowed-tools merge", () => {
607
607
  const { merged } = mergeAllowed(["Bash(npm *)", "Read"], HINDSIGHT_TOOLS);
608
608
  expect(merged).toContain("Bash(npm *)");
609
609
  expect(merged).toContain("Read");
610
- expect(merged).toContain("mcp__hindsight__*");
610
+ expect(merged).toContain("mcp__plugin_hindsight-memory_hindsight__*");
611
611
  });
612
612
  it("does not duplicate when already present", () => {
613
613
  const existing = [...HINDSIGHT_TOOLS];
@@ -616,12 +616,36 @@ describe("claude-code allowed-tools merge", () => {
616
616
  expect(merged).toHaveLength(HINDSIGHT_TOOLS.length);
617
617
  });
618
618
  it("only adds missing entries", () => {
619
- const existing = ["mcp__hindsight__*"];
619
+ const existing = ["mcp__plugin_hindsight-memory_hindsight__*"];
620
620
  const { merged, updated } = mergeAllowed(existing, HINDSIGHT_TOOLS);
621
621
  expect(updated).toBe(true);
622
622
  expect(merged).toHaveLength(HINDSIGHT_TOOLS.length);
623
623
  });
624
624
  });
625
+ describe("openclaw dynamicBankGranularity enforcement", () => {
626
+ function decide(current) {
627
+ if (Array.isArray(current) && current.length === 1 && current[0] === "agent") {
628
+ return "noop";
629
+ }
630
+ if (Array.isArray(current) && current.length > 0) {
631
+ return "ask-confirm";
632
+ }
633
+ return "set-fresh";
634
+ }
635
+ it("sets [agent] when not configured (fresh install)", () => {
636
+ expect(decide(undefined)).toBe("set-fresh");
637
+ expect(decide(null)).toBe("set-fresh");
638
+ expect(decide([])).toBe("set-fresh");
639
+ });
640
+ it("noop when already [agent]", () => {
641
+ expect(decide(["agent"])).toBe("noop");
642
+ });
643
+ it("asks confirmation when set to a different value", () => {
644
+ expect(decide(["agent", "channel", "user"])).toBe("ask-confirm");
645
+ expect(decide(["channel"])).toBe("ask-confirm");
646
+ expect(decide(["agent", "project"])).toBe("ask-confirm");
647
+ });
648
+ });
625
649
  describe("claude-code Hindsight config persistence", () => {
626
650
  // Mirrors the config-write logic: if existing config has a connection
627
651
  // (hindsightApiUrl or llmProvider), don't prompt; otherwise prompt.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectorize-io/self-driving-agents",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "Install self-driving agents with portable memory on any harness",
5
5
  "type": "module",
6
6
  "main": "dist/cli.js",