@cortexkit/opencode-magic-context 0.49.100 → 0.49.103
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/agents/dreamer.d.ts +3 -2
- package/dist/agents/dreamer.d.ts.map +1 -1
- package/dist/agents/permissions.d.ts +2 -0
- package/dist/agents/permissions.d.ts.map +1 -1
- package/dist/agents/smart-notes-dreamer-gate.fixture.d.ts +3 -1
- package/dist/agents/smart-notes-dreamer-gate.fixture.d.ts.map +1 -1
- package/dist/auto-search-worker.js +5 -5
- package/dist/chunk-embedding-write-worker.js +1 -1
- package/dist/{context-k2tdh146.js → context-jk7bgc3s.js} +227 -43
- package/dist/{embedding-backfill-79br4kk6.js → embedding-backfill-anty7zdf.js} +3 -3
- package/dist/{embedding-cache-zn4r1c31.js → embedding-cache-dveynq4m.js} +1 -1
- package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts +1 -0
- package/dist/features/magic-context/dreamer/curate-memory-safety.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-executor.d.ts.map +1 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts +7 -1
- package/dist/features/magic-context/dreamer/task-prompts.d.ts.map +1 -1
- package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts +2 -1
- package/dist/features/magic-context/memory/storage-memory-embeddings.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +5 -2
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-historian.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/host-served-rows.d.ts +7 -0
- package/dist/hooks/magic-context/host-served-rows.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-zyb7tndy.js → index-3nxhxeeg.js} +5 -5
- package/dist/{index-esym6cw4.js → index-42fg6tzz.js} +3 -3
- package/dist/{index-z1hc2g06.js → index-4536jdzj.js} +2 -2
- package/dist/{index-mfx7hzyc.js → index-4dywj733.js} +1 -1
- package/dist/{index-63kp05sy.js → index-4v50y0jr.js} +1 -1
- package/dist/{index-zg5r2syy.js → index-6gd9akdt.js} +1 -1
- package/dist/{index-0tqhr9zs.js → index-6t6v8prs.js} +5 -5
- package/dist/{index-0eyxarpb.js → index-7jvc0rhh.js} +100 -28
- package/dist/{index-kjhgxkdx.js → index-9jqaha1g.js} +1 -1
- package/dist/{index-634cww4x.js → index-9mxkvdtp.js} +9 -9
- package/dist/{index-3cgh0ght.js → index-f455a0g3.js} +1 -1
- package/dist/{index-6hjbeeth.js → index-jg5whyrd.js} +4 -4
- package/dist/{index-qjcye18f.js → index-jjxpmypb.js} +3 -3
- package/dist/{index-e6s2jpr8.js → index-jyj9jg9f.js} +2 -2
- package/dist/{index-ajmy0v5j.js → index-ke0mkz7g.js} +13 -0
- package/dist/{index-txthzqrm.js → index-mes48s7a.js} +152 -75
- package/dist/{index-jjy4shhy.js → index-p8nc9axh.js} +1 -1
- package/dist/{index-9emdjcb5.js → index-pw1f07vg.js} +1 -1
- package/dist/{v2/server-qjwpqvnf.js → index-qbydvfev.js} +4 -3
- package/dist/{index-rjxg7a7m.js → index-qzfz2tvk.js} +5 -1
- package/dist/{index-n3tebmah.js → index-t2h3484a.js} +8 -8
- package/dist/{index-mhdavdd4.js → index-vhx6yph7.js} +11 -8
- package/dist/{index-rakm1eay.js → index-zh683xh2.js} +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -42
- package/dist/{message-index-bounded-289186ah.js → message-index-bounded-8s8sx40x.js} +3 -3
- package/dist/migration-worker.js +1 -1
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/subagent-tool-policy.d.ts.map +1 -1
- package/dist/plugin/tool-registry.d.ts.map +1 -1
- package/dist/{project-embedding-registry-xy8dcdys.js → project-embedding-registry-4cv7n37m.js} +2 -2
- package/dist/raw-ordinal-warmup-worker.js +4 -4
- package/dist/{read-session-chunk-frnwxnjg.js → read-session-chunk-wwg20mte.js} +2 -2
- package/dist/{recomp-orchestrator-e7n124g0.js → recomp-orchestrator-vg4cxyp7.js} +13 -13
- package/dist/{render-argap54x.js → render-f32trg2t.js} +7 -7
- package/dist/{search-archive-ads5mh9s.js → search-archive-yh6xtvrx.js} +5 -5
- package/dist/{search-fxtb4844.js → search-ygtyb91s.js} +11 -11
- package/dist/{storage-memory-hhrvfw0x.js → storage-memory-p91f7b5h.js} +2 -2
- package/dist/{storage-tags-2d2ba8e9.js → storage-tags-5nke1bdt.js} +1 -1
- package/dist/{store-reader-01e8t5j0.js → store-reader-c5fwa9qx.js} +1 -1
- package/dist/{store-235fjtsn.js → store-wpx314rk.js} +2 -2
- package/dist/tools/ctx-memory/constants.d.ts +2 -0
- package/dist/tools/ctx-memory/constants.d.ts.map +1 -1
- package/dist/tools/ctx-memory/tools.d.ts +1 -0
- package/dist/tools/ctx-memory/tools.d.ts.map +1 -1
- package/dist/tools/ctx-reduce/constants.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-2y0st4gk.js → transform-postprocess-phase-958fmjs5.js} +14 -14
- package/dist/v2/auto-search-worker.js +5 -5
- package/dist/v2/chunk-embedding-write-worker.js +1 -1
- package/dist/v2/{context-v56v40cx.js → context-3g3jvxg8.js} +347 -88
- package/dist/v2/{embedding-backfill-nhgp8znm.js → embedding-backfill-ra9gbbs4.js} +3 -3
- package/dist/v2/{embedding-cache-zn4r1c31.js → embedding-cache-dveynq4m.js} +1 -1
- package/dist/v2/fold/instruction-supersession.d.ts +18 -1
- package/dist/v2/fold/instruction-supersession.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts +2 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/hooks/hidden-child.d.ts.map +1 -1
- package/dist/v2/hooks/revert-message-state.d.ts +6 -0
- package/dist/v2/hooks/revert-message-state.d.ts.map +1 -1
- package/dist/v2/hooks/tools.d.ts.map +1 -1
- package/dist/v2/{message-index-bounded-p69v4wpy.js → message-index-bounded-j1sxtefe.js} +3 -3
- package/dist/v2/migration-worker.js +1 -1
- package/dist/v2/{project-embedding-registry-qz9x79kn.js → project-embedding-registry-gdaqb7h0.js} +2 -2
- package/dist/v2/raw-ordinal-warmup-worker.js +4 -4
- package/dist/v2/{read-session-chunk-qzw3vedr.js → read-session-chunk-p6z3kmdj.js} +2 -2
- package/dist/v2/{recomp-orchestrator-5gkzamy2.js → recomp-orchestrator-29m3cc5b.js} +12 -12
- package/dist/v2/{render-atxj9eaf.js → render-jpj43axy.js} +7 -7
- package/dist/v2/{search-archive-vgwnvdx2.js → search-archive-wbhxp0p1.js} +5 -5
- package/dist/v2/{search-51qr14ed.js → search-ybyc7vmx.js} +10 -10
- package/dist/v2/{server-bhr92yb4.js → server-1qxdyz4p.js} +2 -2
- package/dist/v2/{server-8vby30m5.js → server-8f92sd2r.js} +2 -2
- package/dist/v2/{server-08jh9wew.js → server-8m5wk6aq.js} +5 -5
- package/dist/v2/{server-606mnrv4.js → server-9ms9b75c.js} +5 -1
- package/dist/v2/{server-s3m2y97h.js → server-b01a7dhj.js} +1 -1
- package/dist/v2/{server-rwdp3hw6.js → server-df5scn4q.js} +71 -11
- package/dist/v2/{server-7wpw3wc6.js → server-fagcnt6j.js} +11 -8
- package/dist/v2/{server-b25nvm9c.js → server-ga6y57vh.js} +1 -1
- package/dist/v2/{server-2ek9exbe.js → server-kx5egpt7.js} +3 -3
- package/dist/v2/{server-e14d7ebh.js → server-mc5t7k8v.js} +1 -1
- package/dist/v2/{server-9emdjcb5.js → server-pw1f07vg.js} +1 -1
- package/dist/{index-qjwpqvnf.js → v2/server-qbydvfev.js} +4 -3
- package/dist/v2/{server-c1vcbszm.js → server-qdpd8h27.js} +1 -1
- package/dist/v2/{server-ysg14rv1.js → server-qg8jyfxa.js} +13 -0
- package/dist/v2/{server-d2a639dg.js → server-r851hxn5.js} +8 -8
- package/dist/v2/{server-p2wxmjc3.js → server-t45hgcsg.js} +2 -2
- package/dist/v2/{server-awth2wsg.js → server-x22jtpna.js} +1 -1
- package/dist/v2/{server-wdmcqhv6.js → server-xpy46ddq.js} +3 -3
- package/dist/v2/server.js +2 -2
- package/dist/v2/{storage-memory-hhrvfw0x.js → storage-memory-p91f7b5h.js} +2 -2
- package/dist/v2/{storage-tags-4t9fb4ch.js → storage-tags-s7nvvyg8.js} +1 -1
- package/dist/v2/{store-0kjfynwp.js → store-mba47sxn.js} +2 -2
- package/dist/v2/{store-reader-w0srb18d.js → store-reader-w7w8vfsy.js} +1 -1
- package/dist/v2/store-reader.d.ts +7 -0
- package/dist/v2/store-reader.d.ts.map +1 -1
- package/dist/v2/{v2-archive-reader-1wc5wb1a.js → v2-archive-reader-5njmg3a3.js} +1 -1
- package/dist/v2/{wrapup-orchestrator-ksdn2emb.js → wrapup-orchestrator-ahkq8a61.js} +12 -12
- package/dist/{v2-archive-reader-4pk46nc1.js → v2-archive-reader-y38khjax.js} +1 -1
- package/dist/{wrapup-orchestrator-sc2fsfct.js → wrapup-orchestrator-gjqaac65.js} +14 -14
- package/package.json +1 -1
- package/src/agents/dreamer.ts +3 -2
- package/src/agents/hidden-agent-registrations.ts +2 -2
- package/src/agents/permissions.test.ts +89 -3
- package/src/agents/permissions.ts +32 -0
- package/src/agents/smart-notes-dreamer-gate.fixture.ts +27 -4
- package/src/agents/smart-notes-dreamer-gate.test.ts +5 -1
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
getCompartments,
|
|
12
12
|
getLastCompartmentEndMessage,
|
|
13
13
|
requestPendingMaterialization
|
|
14
|
-
} from "./server-
|
|
14
|
+
} from "./server-8f92sd2r.js";
|
|
15
15
|
import"./server-2amn2s73.js";
|
|
16
16
|
import"./server-d46xewmt.js";
|
|
17
17
|
import"./server-b5eg9ct6.js";
|
|
@@ -24,7 +24,7 @@ import"./server-1d042x6w.js";
|
|
|
24
24
|
import"./server-54nc921b.js";
|
|
25
25
|
import"./server-98xd6j4r.js";
|
|
26
26
|
import"./server-ghk96d57.js";
|
|
27
|
-
import"./server-
|
|
27
|
+
import"./server-qdpd8h27.js";
|
|
28
28
|
import {
|
|
29
29
|
getWrapupInProgressState,
|
|
30
30
|
acquireWrapupInProgress,
|
|
@@ -32,21 +32,21 @@ import {
|
|
|
32
32
|
releaseWrapupInProgress,
|
|
33
33
|
getHistorianFailureState,
|
|
34
34
|
clearEmergencyRecovery
|
|
35
|
-
} from "./server-
|
|
35
|
+
} from "./server-9ms9b75c.js";
|
|
36
36
|
import"./server-bzebqckc.js";
|
|
37
|
-
import"./server-
|
|
37
|
+
import"./server-ga6y57vh.js";
|
|
38
38
|
import"./server-1zx87sdm.js";
|
|
39
39
|
import"./server-arfzfxe8.js";
|
|
40
40
|
import"./server-2ra6pwf3.js";
|
|
41
41
|
import"./server-vgy98kcd.js";
|
|
42
42
|
import {
|
|
43
43
|
prepareRawSessionOrdinals2
|
|
44
|
-
} from "./server-
|
|
44
|
+
} from "./server-x22jtpna.js";
|
|
45
45
|
import"./server-fr0wbhdn.js";
|
|
46
46
|
import"./server-3mb205v9.js";
|
|
47
47
|
import"./server-3qeqa3b6.js";
|
|
48
48
|
import"./server-jrs4gny6.js";
|
|
49
|
-
import"./server-
|
|
49
|
+
import"./server-qg8jyfxa.js";
|
|
50
50
|
import"./server-fb3zxn06.js";
|
|
51
51
|
import"./server-5zx51pm4.js";
|
|
52
52
|
import"./server-j09jx1n9.js";
|
|
@@ -64,15 +64,15 @@ import {
|
|
|
64
64
|
registerActiveCompartmentRun,
|
|
65
65
|
setRecompStarting2,
|
|
66
66
|
setRecompTerminal2
|
|
67
|
-
} from "./server-
|
|
67
|
+
} from "./server-df5scn4q.js";
|
|
68
68
|
import"./server-qt1qqasc.js";
|
|
69
|
-
import"./server-
|
|
69
|
+
import"./server-fagcnt6j.js";
|
|
70
70
|
import"./server-7c5p0bh1.js";
|
|
71
|
-
import"./server-
|
|
71
|
+
import"./server-qbydvfev.js";
|
|
72
72
|
import"./server-pqgnjf38.js";
|
|
73
|
-
import"./server-
|
|
74
|
-
import"./server-
|
|
75
|
-
import"./server-
|
|
73
|
+
import"./server-kx5egpt7.js";
|
|
74
|
+
import"./server-1qxdyz4p.js";
|
|
75
|
+
import"./server-pw1f07vg.js";
|
|
76
76
|
import"./server-0b3ms151.js";
|
|
77
77
|
import"./server-d4h86y7v.js";
|
|
78
78
|
import"./server-n5wn7d9b.js";
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import {
|
|
2
2
|
runManagedWrapup2
|
|
3
|
-
} from "./index-
|
|
4
|
-
import"./index-
|
|
5
|
-
import"./index-
|
|
3
|
+
} from "./index-6t6v8prs.js";
|
|
4
|
+
import"./index-jg5whyrd.js";
|
|
5
|
+
import"./index-7jvc0rhh.js";
|
|
6
6
|
import"./index-qxzk5s30.js";
|
|
7
7
|
import"./index-sd3egckz.js";
|
|
8
|
-
import"./index-
|
|
9
|
-
import"./index-
|
|
10
|
-
import"./index-
|
|
11
|
-
import"./index-
|
|
12
|
-
import"./index-
|
|
13
|
-
import"./index-
|
|
8
|
+
import"./index-42fg6tzz.js";
|
|
9
|
+
import"./index-jyj9jg9f.js";
|
|
10
|
+
import"./index-pw1f07vg.js";
|
|
11
|
+
import"./index-vhx6yph7.js";
|
|
12
|
+
import"./index-qbydvfev.js";
|
|
13
|
+
import"./index-4536jdzj.js";
|
|
14
14
|
import"./index-ab86c21b.js";
|
|
15
|
-
import"./index-
|
|
15
|
+
import"./index-p8nc9axh.js";
|
|
16
16
|
import"./index-2amn2s73.js";
|
|
17
|
-
import"./index-
|
|
17
|
+
import"./index-ke0mkz7g.js";
|
|
18
18
|
import"./index-h1qh9n8b.js";
|
|
19
19
|
import"./index-fqth7850.js";
|
|
20
20
|
import"./index-61a853ky.js";
|
|
21
21
|
import"./index-qt1qqasc.js";
|
|
22
|
-
import"./index-
|
|
23
|
-
import"./index-
|
|
22
|
+
import"./index-9jqaha1g.js";
|
|
23
|
+
import"./index-qzfz2tvk.js";
|
|
24
24
|
import"./index-1zx87sdm.js";
|
|
25
25
|
import"./index-vdzd98ry.js";
|
|
26
26
|
import"./index-y14pawe1.js";
|
|
@@ -30,7 +30,7 @@ import"./index-r3f85n7y.js";
|
|
|
30
30
|
import"./index-fd3hkyk1.js";
|
|
31
31
|
import"./index-1vv1ka4a.js";
|
|
32
32
|
import"./index-gcf2x04k.js";
|
|
33
|
-
import"./index-
|
|
33
|
+
import"./index-f455a0g3.js";
|
|
34
34
|
import"./index-fb3zxn06.js";
|
|
35
35
|
import"./index-hyvxmz3e.js";
|
|
36
36
|
import"./index-fr0wbhdn.js";
|
package/package.json
CHANGED
package/src/agents/dreamer.ts
CHANGED
|
@@ -52,6 +52,7 @@ export const DREAMER_DOCS_ALLOWED_TOOLS = [
|
|
|
52
52
|
export const DREAMER_REVIEWER_AGENT = "dreamer-reviewer";
|
|
53
53
|
|
|
54
54
|
/** Curate receives its category snapshot from the host and edits memories via
|
|
55
|
-
*
|
|
55
|
+
* ctx_memory_curate. Plain ctx_memory is still accepted for older callers.
|
|
56
|
+
* It does not read code; the verify task checks memory accuracy.
|
|
56
57
|
* Keep the `dreamer` id because memory-tool authorization matches that id. */
|
|
57
|
-
export const DREAMER_CURATE_ALLOWED_TOOLS = ["ctx_memory"] as const;
|
|
58
|
+
export const DREAMER_CURATE_ALLOWED_TOOLS = ["ctx_memory", "ctx_memory_curate"] as const;
|
|
@@ -100,14 +100,14 @@ export function buildHiddenAgentRegistrations(args: {
|
|
|
100
100
|
description: HIDDEN_AGENT_DESCRIPTION,
|
|
101
101
|
prompt: args.dreamerPrompt,
|
|
102
102
|
// Curate receives its category snapshot in the first message and edits
|
|
103
|
-
// through
|
|
103
|
+
// through ctx_memory_curate; it never reads code because a separate verify task
|
|
104
104
|
// owns memory-vs-code correctness. No former bash/write/edit/read/aft/
|
|
105
105
|
// ctx_search/ctx_note surface remains. maintain-docs
|
|
106
106
|
// and review-user-memories moved to their own scoped agents below.
|
|
107
107
|
// (Inline literal — kept byte-identical to DREAMER_CURATE_ALLOWED_TOOLS
|
|
108
108
|
// by agent-registration-drift.test.ts; see the module header for why
|
|
109
109
|
// these are not const imports.)
|
|
110
|
-
allowedTools: ["ctx_memory"],
|
|
110
|
+
allowedTools: ["ctx_memory", "ctx_memory_curate"],
|
|
111
111
|
// Curate is a genuine multi-step whole-pool hygiene loop, so it keeps a
|
|
112
112
|
// high cap.
|
|
113
113
|
maxSteps: 150,
|
|
@@ -3,9 +3,94 @@ import { DREAMER_CURATE_ALLOWED_TOOLS, DREAMER_DOCS_ALLOWED_TOOLS } from "./drea
|
|
|
3
3
|
import {
|
|
4
4
|
applyDisallowedTools,
|
|
5
5
|
buildAllowOnlyPermission,
|
|
6
|
+
denyCurateToolToOtherAgents,
|
|
7
|
+
denyTaskRoutingToCallerAgents,
|
|
6
8
|
HISTORIAN_ALLOWED_TOOLS,
|
|
7
9
|
} from "./permissions";
|
|
8
10
|
|
|
11
|
+
describe("OpenCode 1 config hook Curate permissions", () => {
|
|
12
|
+
const configure = (agents: Parameters<typeof denyCurateToolToOtherAgents>[0]) =>
|
|
13
|
+
denyCurateToolToOtherAgents(denyTaskRoutingToCallerAgents(agents, ["dreamer"]));
|
|
14
|
+
|
|
15
|
+
it("places the deny after an agent's wildcard allow and preserves the list allow", () => {
|
|
16
|
+
const configured = configure({
|
|
17
|
+
custom: { permission: { read: "ask", "*": "allow", ctx_memory_list: "allow" } },
|
|
18
|
+
});
|
|
19
|
+
expect(Object.entries(configured.custom!.permission as object)).toEqual([
|
|
20
|
+
["read", "ask"],
|
|
21
|
+
["*", "allow"],
|
|
22
|
+
["ctx_memory_list", "allow"],
|
|
23
|
+
["ctx_memory_curate", "deny"],
|
|
24
|
+
]);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it("preserves a whole-agent string allow but puts the Curate deny last", () => {
|
|
28
|
+
expect(configure({ custom: { permission: "allow" } }).custom?.permission).toEqual({
|
|
29
|
+
"*": "allow",
|
|
30
|
+
ctx_memory_curate: "deny",
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("denies Curate even when a deprecated tools entry allows it", () => {
|
|
35
|
+
const tools = { ctx_memory_curate: true, ctx_memory_list: true };
|
|
36
|
+
// The host normalizes deprecated tools into permissions before the hook.
|
|
37
|
+
const configured = configure({
|
|
38
|
+
custom: { tools, permission: { ctx_memory_curate: "allow", ctx_memory_list: "allow" } },
|
|
39
|
+
});
|
|
40
|
+
expect(configured.custom).toEqual({
|
|
41
|
+
tools,
|
|
42
|
+
permission: { ctx_memory_list: "allow", ctx_memory_curate: "deny" },
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("replaces an explicit Curate allow, preserving user-key order across reloads", () => {
|
|
47
|
+
const configured = configure({
|
|
48
|
+
build: {
|
|
49
|
+
permission: { ctx_memory_curate: "allow", read: "ask", "ctx_memory_*": "allow" },
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
expect(Object.entries(configured.build!.permission as object)).toEqual([
|
|
53
|
+
["read", "ask"],
|
|
54
|
+
["ctx_memory_*", "allow"],
|
|
55
|
+
["task", { dreamer: "deny" }],
|
|
56
|
+
["ctx_memory_curate", "deny"],
|
|
57
|
+
]);
|
|
58
|
+
expect(JSON.stringify(configure(configured))).toBe(JSON.stringify(configured));
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("adds only a deny to a prompt-only agent and leaves the dreamer untouched", () => {
|
|
62
|
+
const dreamer = { permission: { "*": "deny", ctx_memory_curate: "allow" } };
|
|
63
|
+
const configured = configure({ custom: { prompt: "Keep the project style." }, dreamer });
|
|
64
|
+
expect(configured.custom).toEqual({
|
|
65
|
+
prompt: "Keep the project style.",
|
|
66
|
+
permission: { ctx_memory_curate: "deny" },
|
|
67
|
+
});
|
|
68
|
+
expect(configured.dreamer).toBe(dreamer);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("adds a final deny to built-ins without overriding their other defaults", () => {
|
|
72
|
+
const configured = configure({});
|
|
73
|
+
expect(Object.keys(configured).sort()).toEqual([
|
|
74
|
+
"build",
|
|
75
|
+
"compaction",
|
|
76
|
+
"explore",
|
|
77
|
+
"general",
|
|
78
|
+
"plan",
|
|
79
|
+
"summary",
|
|
80
|
+
"title",
|
|
81
|
+
]);
|
|
82
|
+
for (const id of ["general", "explore", "compaction", "title", "summary"]) {
|
|
83
|
+
expect(configured[id]).toEqual({ permission: { ctx_memory_curate: "deny" } });
|
|
84
|
+
}
|
|
85
|
+
for (const id of ["build", "plan"]) {
|
|
86
|
+
expect(Object.entries(configured[id]!.permission as object).at(-1)).toEqual([
|
|
87
|
+
"ctx_memory_curate",
|
|
88
|
+
"deny",
|
|
89
|
+
]);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
9
94
|
describe("buildAllowOnlyPermission", () => {
|
|
10
95
|
it("starts with wildcard deny so nothing is allowed by default", () => {
|
|
11
96
|
const perm = buildAllowOnlyPermission([]);
|
|
@@ -113,10 +198,10 @@ describe("applyDisallowedTools", () => {
|
|
|
113
198
|
});
|
|
114
199
|
|
|
115
200
|
describe("DREAMER_CURATE_ALLOWED_TOOLS (base dreamer = curate only)", () => {
|
|
116
|
-
it("allows only
|
|
201
|
+
it("allows only memory mutation tools — the category snapshot replaces enumeration", () => {
|
|
117
202
|
// A separate verify task owns memory-vs-code correctness; curate is
|
|
118
203
|
// pure pool hygiene, so it has no read/grep/bash/write/edit surface.
|
|
119
|
-
expect([...DREAMER_CURATE_ALLOWED_TOOLS]).toEqual(["ctx_memory"]);
|
|
204
|
+
expect([...DREAMER_CURATE_ALLOWED_TOOLS]).toEqual(["ctx_memory", "ctx_memory_curate"]);
|
|
120
205
|
});
|
|
121
206
|
|
|
122
207
|
it("does NOT include any codebase / shell / file-write tool", () => {
|
|
@@ -165,11 +250,12 @@ describe("integration: full hidden-agent permission shape", () => {
|
|
|
165
250
|
expect(perm).toEqual({ "*": "deny" });
|
|
166
251
|
});
|
|
167
252
|
|
|
168
|
-
it("base dreamer permission object denies all except
|
|
253
|
+
it("base dreamer permission object denies all except memory mutation tools", () => {
|
|
169
254
|
const perm = buildAllowOnlyPermission(DREAMER_CURATE_ALLOWED_TOOLS);
|
|
170
255
|
expect(perm).toEqual({
|
|
171
256
|
"*": "deny",
|
|
172
257
|
ctx_memory: "allow",
|
|
258
|
+
ctx_memory_curate: "allow",
|
|
173
259
|
});
|
|
174
260
|
});
|
|
175
261
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { log } from "../shared/logger";
|
|
2
|
+
import { CTX_MEMORY_CURATE_TOOL_NAME } from "../tools/ctx-memory/constants";
|
|
3
|
+
import { DREAMER_AGENT } from "./dreamer";
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* Permission rulesets for Magic Context's hidden subagents.
|
|
@@ -209,6 +211,36 @@ export function denyTaskRoutingToCallerAgents(
|
|
|
209
211
|
return result;
|
|
210
212
|
}
|
|
211
213
|
|
|
214
|
+
const OPENCODE1_BUILTIN_AGENT_IDS = [
|
|
215
|
+
...BUILTIN_TASK_CALLER_IDS,
|
|
216
|
+
"general",
|
|
217
|
+
"explore",
|
|
218
|
+
"compaction",
|
|
219
|
+
"title",
|
|
220
|
+
"summary",
|
|
221
|
+
] as const;
|
|
222
|
+
|
|
223
|
+
/** OpenCode 1 appends agent rules after global rules, and the last match wins. */
|
|
224
|
+
export function denyCurateToolToOtherAgents(
|
|
225
|
+
agentConfigs: Record<string, Record<string, unknown>>,
|
|
226
|
+
): Record<string, Record<string, unknown>> {
|
|
227
|
+
const result = { ...agentConfigs };
|
|
228
|
+
for (const id of new Set([...Object.keys(agentConfigs), ...OPENCODE1_BUILTIN_AGENT_IDS])) {
|
|
229
|
+
if (id === DREAMER_AGENT) continue;
|
|
230
|
+
const agent = agentConfigs[id] ?? {};
|
|
231
|
+
const permission = agent.permission;
|
|
232
|
+
const rules: Record<string, unknown> = isPermissionAction(permission)
|
|
233
|
+
? { "*": permission }
|
|
234
|
+
: isPermissionMap(permission)
|
|
235
|
+
? { ...permission }
|
|
236
|
+
: {};
|
|
237
|
+
// Reinsert the exact key at the end so a wildcard cannot shadow it.
|
|
238
|
+
delete rules[CTX_MEMORY_CURATE_TOOL_NAME];
|
|
239
|
+
result[id] = { ...agent, permission: { ...rules, [CTX_MEMORY_CURATE_TOOL_NAME]: "deny" } };
|
|
240
|
+
}
|
|
241
|
+
return result;
|
|
242
|
+
}
|
|
243
|
+
|
|
212
244
|
/** Historians summarize the supplied transcript; no file access or tools are needed. */
|
|
213
245
|
export const HISTORIAN_ALLOWED_TOOLS = [] as const;
|
|
214
246
|
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* setting the ctx_* tool list depends on. `renderToolSurfaces` renders the
|
|
6
6
|
* OpenCode 1 registry and the OpenCode 2 registration plus per-request rewrite
|
|
7
7
|
* for one parsed config and returns, per host, a short digest of ctx_note and
|
|
8
|
-
* one of every other
|
|
8
|
+
* one of every other legacy registration together. New dreamer-only tools
|
|
9
|
+
* have separate digests after checking that the primary request omits them.
|
|
9
10
|
*
|
|
10
11
|
* The committed golden (`smart-notes-dreamer-gate.golden.json`) holds these
|
|
11
12
|
* digests as produced by the code before the dreamer gate existed, so the test
|
|
@@ -20,7 +21,11 @@ import type { MagicContextPluginConfig } from "../config";
|
|
|
20
21
|
import { createToolRegistry } from "../plugin/tool-registry";
|
|
21
22
|
import { createPromptSurfaceRuntime } from "../shared/prompt-surface-runtime";
|
|
22
23
|
import type { Database } from "../shared/sqlite";
|
|
23
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
CTX_MEMORY_LIST_TOOL_NAME,
|
|
26
|
+
DREAMER_ONLY_MEMORY_TOOL_NAMES,
|
|
27
|
+
} from "../tools/ctx-memory/constants";
|
|
28
|
+
import { applyV2PromptSurfaceTools, removeDreamerOnlyTools } from "../v2/hooks/context";
|
|
24
29
|
import { registerTools } from "../v2/hooks/tools";
|
|
25
30
|
|
|
26
31
|
export const GATE_CASE_COUNT = 240;
|
|
@@ -79,7 +84,7 @@ export function gateCases(): Record<string, unknown>[] {
|
|
|
79
84
|
const shortDigest = (value: unknown) =>
|
|
80
85
|
createHash("sha256").update(JSON.stringify(value)).digest("hex").slice(0, 16);
|
|
81
86
|
|
|
82
|
-
/** `note` digests ctx_note's { description, schema }; `other` digests
|
|
87
|
+
/** `note` digests ctx_note's { description, schema }; `other` digests the other legacy registrations. */
|
|
83
88
|
export interface HostDigests {
|
|
84
89
|
note: string;
|
|
85
90
|
other: string;
|
|
@@ -90,6 +95,8 @@ export interface ToolSurfaceDigests {
|
|
|
90
95
|
oc1: HostDigests;
|
|
91
96
|
/** OpenCode 2 registration after the per-request description rewrite. */
|
|
92
97
|
oc2: HostDigests;
|
|
98
|
+
/** Dreamer-only tools added after the original OpenCode 2 registration capture. */
|
|
99
|
+
oc2DreamerOnly: Record<string, string>;
|
|
93
100
|
/** Full text per host, kept out of the golden; used for content checks. */
|
|
94
101
|
text: { oc1: string; oc2: string };
|
|
95
102
|
}
|
|
@@ -158,6 +165,21 @@ export async function renderToolSurfaces(args: {
|
|
|
158
165
|
.sort()
|
|
159
166
|
.map((name) => [name, draft.tools[name]]),
|
|
160
167
|
);
|
|
168
|
+
const primaryDraft = { ...draft, tools: { ...draft.tools } };
|
|
169
|
+
removeDreamerOnlyTools(primaryDraft as never);
|
|
170
|
+
const legacyOc2 = { ...oc2Surfaces };
|
|
171
|
+
const oc2DreamerOnly: Record<string, string> = {};
|
|
172
|
+
for (const name of DREAMER_ONLY_MEMORY_TOOL_NAMES) {
|
|
173
|
+
if (Object.hasOwn(primaryDraft.tools, name)) {
|
|
174
|
+
throw new Error(
|
|
175
|
+
`OpenCode 2 exposes the dreamer-only tool ${name} to the primary agent`,
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
// The original golden measured registrations and already included the list tool.
|
|
179
|
+
if (name === CTX_MEMORY_LIST_TOOL_NAME || !Object.hasOwn(oc2Surfaces, name)) continue;
|
|
180
|
+
oc2DreamerOnly[name] = shortDigest(oc2Surfaces[name]);
|
|
181
|
+
delete legacyOc2[name];
|
|
182
|
+
}
|
|
161
183
|
|
|
162
184
|
const digests = (surfaces: Record<string, unknown>): HostDigests => {
|
|
163
185
|
const { ctx_note: note, ...other } = surfaces;
|
|
@@ -165,7 +187,8 @@ export async function renderToolSurfaces(args: {
|
|
|
165
187
|
};
|
|
166
188
|
return {
|
|
167
189
|
oc1: digests(oc1Surfaces),
|
|
168
|
-
oc2: digests(
|
|
190
|
+
oc2: digests(legacyOc2),
|
|
191
|
+
oc2DreamerOnly,
|
|
169
192
|
text: { oc1: JSON.stringify(oc1Surfaces), oc2: JSON.stringify(oc2Surfaces) },
|
|
170
193
|
};
|
|
171
194
|
}
|
|
@@ -22,6 +22,7 @@ import golden from "./smart-notes-dreamer-gate.golden.json";
|
|
|
22
22
|
// gate; every config with a runnable dreamer must still render them exactly.
|
|
23
23
|
|
|
24
24
|
const SMART_NOTE_TEXT = /surface_condition|smart.note|outside checker/i;
|
|
25
|
+
const OC2_DREAMER_ONLY_DIGESTS = { ctx_memory_curate: "8d02fa49a68b4b20" };
|
|
25
26
|
const oldXdg = process.env.XDG_DATA_HOME;
|
|
26
27
|
let dir: string;
|
|
27
28
|
let db: Database;
|
|
@@ -51,7 +52,7 @@ const render = (raw: Record<string, unknown>): Promise<ToolSurfaceDigests> => {
|
|
|
51
52
|
|
|
52
53
|
test("ctx_* tool bytes match the pre-gate golden for every config with a runnable dreamer, and only ctx_note changes when the dreamer is off", async () => {
|
|
53
54
|
const cases = gateCases();
|
|
54
|
-
const expected = (golden as { cases: Array<
|
|
55
|
+
const expected = (golden as { cases: Array<Pick<ToolSurfaceDigests, "oc1" | "oc2">> }).cases;
|
|
55
56
|
expect(cases).toHaveLength(GATE_CASE_COUNT);
|
|
56
57
|
expect(expected).toHaveLength(GATE_CASE_COUNT);
|
|
57
58
|
|
|
@@ -64,6 +65,9 @@ test("ctx_* tool bytes match the pre-gate golden for every config with a runnabl
|
|
|
64
65
|
const before = expected[index];
|
|
65
66
|
if (!before) throw new Error(`golden has no case ${index}`);
|
|
66
67
|
const label = `case ${index} ${JSON.stringify(raw)}`;
|
|
68
|
+
expect(got.oc2DreamerOnly, label).toEqual(
|
|
69
|
+
config.memory.enabled ? OC2_DREAMER_ONLY_DIGESTS : {},
|
|
70
|
+
);
|
|
67
71
|
if (isDreamerRunnable(config)) {
|
|
68
72
|
runnable++;
|
|
69
73
|
expect({ label, oc1: got.oc1, oc2: got.oc2 }).toEqual({
|