@cortexkit/opencode-magic-context 0.46.1 → 0.47.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/auto-search-worker.js +115 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/live-run-config.d.ts.map +1 -1
- package/dist/config/migrate-config-location.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +11 -3
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/{conflict-warning-hook-7fj2b9jw.js → conflict-warning-hook-z44ynfz7.js} +5 -4
- package/dist/{context-sh2m2vde.js → context-wq4ffwyb.js} +108 -23
- package/dist/{derive-budgets-7nj7r1rv.js → derive-budgets-ke12jnnh.js} +1 -1
- package/dist/embedding-worker.js +2 -2
- package/dist/features/magic-context/dreamer/task-gates.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts +2 -0
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -1
- package/dist/features/magic-context/project-embedding-registry.d.ts +7 -0
- package/dist/features/magic-context/project-embedding-registry.d.ts.map +1 -1
- package/dist/features/magic-context/search.d.ts +2 -0
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/session-project-storage.d.ts +8 -2
- package/dist/features/magic-context/session-project-storage.d.ts.map +1 -1
- package/dist/features/magic-context/storage-historian-runs.d.ts +2 -5
- package/dist/features/magic-context/storage-historian-runs.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +12 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-session.d.ts.map +1 -1
- package/dist/features/magic-context/storage-tags.d.ts +7 -2
- package/dist/features/magic-context/storage-tags.d.ts.map +1 -1
- package/dist/features/magic-context/storage.d.ts +1 -0
- package/dist/features/magic-context/storage.d.ts.map +1 -1
- package/dist/features/magic-context/transform-decision-log.d.ts +3 -1
- package/dist/features/magic-context/transform-decision-log.d.ts.map +1 -1
- package/dist/hooks/magic-context/active-anthropic-turn.d.ts +8 -0
- package/dist/hooks/magic-context/active-anthropic-turn.d.ts.map +1 -0
- package/dist/hooks/magic-context/apply-operations.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-blocking.fixture.d.ts +2 -0
- package/dist/hooks/magic-context/auto-search-blocking.fixture.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-deadline.d.ts +7 -0
- package/dist/hooks/magic-context/auto-search-deadline.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-host-review.fixture.d.ts +3 -0
- package/dist/hooks/magic-context/auto-search-host-review.fixture.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-lock-review.fixture.d.ts +2 -0
- package/dist/hooks/magic-context/auto-search-lock-review.fixture.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-long-lock-review.fixture.d.ts +2 -0
- package/dist/hooks/magic-context/auto-search-long-lock-review.fixture.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-omp-host-review.fixture.d.ts +4 -0
- package/dist/hooks/magic-context/auto-search-omp-host-review.fixture.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-omp-loader.fixture.d.ts +3 -0
- package/dist/hooks/magic-context/auto-search-omp-loader.fixture.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-runner.d.ts +1 -1
- package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-snapshot.fixture.d.ts +4 -0
- package/dist/hooks/magic-context/auto-search-snapshot.fixture.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts +69 -0
- package/dist/hooks/magic-context/auto-search-worker-client.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-worker.d.ts +2 -0
- package/dist/hooks/magic-context/auto-search-worker.d.ts.map +1 -0
- package/dist/hooks/magic-context/caveman-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +3 -5
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts +2 -1
- package/dist/hooks/magic-context/compartment-runner.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts +3 -1
- package/dist/hooks/magic-context/compartment-trigger.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -1
- package/dist/hooks/magic-context/execute-status.d.ts.map +1 -1
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts +2 -0
- package/dist/hooks/magic-context/final-wire-token-estimate.d.ts.map +1 -1
- package/dist/hooks/magic-context/heuristic-cleanup.d.ts.map +1 -1
- package/dist/hooks/magic-context/historian-drain-gate.d.ts +11 -0
- package/dist/hooks/magic-context/historian-drain-gate.d.ts.map +1 -0
- package/dist/hooks/magic-context/hook.d.ts +2 -1
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/latest-assistant-turn.d.ts +25 -0
- package/dist/hooks/magic-context/latest-assistant-turn.d.ts.map +1 -0
- package/dist/hooks/magic-context/latest-thinking-recovery.d.ts +61 -0
- package/dist/hooks/magic-context/latest-thinking-recovery.d.ts.map +1 -0
- package/dist/hooks/magic-context/module-wire.d.ts.map +1 -1
- package/dist/hooks/magic-context/opencode-proven-floor.d.ts +6 -0
- package/dist/hooks/magic-context/opencode-proven-floor.d.ts.map +1 -0
- package/dist/hooks/magic-context/pass-outcome.d.ts.map +1 -1
- package/dist/hooks/magic-context/protected-tail-boundary.d.ts.map +1 -1
- package/dist/hooks/magic-context/read-session-true-raw-tokens.d.ts.map +1 -1
- package/dist/hooks/magic-context/reasoning-budget-status.d.ts +15 -0
- package/dist/hooks/magic-context/reasoning-budget-status.d.ts.map +1 -0
- package/dist/hooks/magic-context/reasoning-budget.d.ts +40 -0
- package/dist/hooks/magic-context/reasoning-budget.d.ts.map +1 -0
- package/dist/hooks/magic-context/reasoning-removal.d.ts +6 -6
- package/dist/hooks/magic-context/reasoning-removal.d.ts.map +1 -1
- package/dist/hooks/magic-context/rust-mode-transform.d.ts.map +1 -1
- package/dist/hooks/magic-context/sentinel.d.ts +4 -0
- package/dist/hooks/magic-context/sentinel.d.ts.map +1 -1
- package/dist/hooks/magic-context/strip-content.d.ts +7 -3
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/tag-messages.d.ts +13 -0
- package/dist/hooks/magic-context/tag-messages.d.ts.map +1 -1
- package/dist/hooks/magic-context/tool-drop-target.d.ts +5 -0
- package/dist/hooks/magic-context/tool-drop-target.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +3 -28
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +28 -6
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +3 -1
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/{index-0d3g3461.js → index-0c82743p.js} +2 -1
- package/dist/{index-5p8jdswx.js → index-5a2r0p9f.js} +3 -3
- package/dist/{index-sjthx78w.js → index-6d9e1m08.js} +4647 -11000
- package/dist/{index-majxda46.js → index-6wkcswft.js} +1 -1
- package/dist/index-92bp57hg.js +2063 -0
- package/dist/{index-sfnj6h8h.js → index-9pk9exrb.js} +3 -3
- package/dist/{index-7qw742ev.js → index-adwfkpex.js} +5 -24
- package/dist/{index-3h0ybwah.js → index-bb36vgr3.js} +80 -12
- package/dist/{index-pkbcrdqs.js → index-cwf6s3ay.js} +1072 -2422
- package/dist/index-fnn5pjtt.js +6554 -0
- package/dist/{index-sgthv3f7.js → index-gg8j07zz.js} +1 -1
- package/dist/{index-8x2v7gg9.js → index-m5fe6jch.js} +7 -3
- package/dist/{v2/server-g0fjrkta.js → index-rrbbspwh.js} +42 -27
- package/dist/index-rrrsepyw.js +3464 -0
- package/dist/{index-hpecdzec.js → index-w2t4ah5j.js} +948 -501
- package/dist/{v2/server-fg34g6a5.js → index-wx8a6bw3.js} +48 -8
- package/dist/{index-r5hmbx3t.js → index-x3kwrmqk.js} +146 -3571
- package/dist/index-yr3zj7e7.js +23 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +624 -65
- package/dist/{message-time-backfill-68gj6t3e.js → message-time-backfill-r5epkzj3.js} +1 -1
- package/dist/migration-worker.js +7 -5
- package/dist/plugin/hooks/create-session-hooks.d.ts +2 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/host-stall-profiler-report.d.ts +67 -0
- package/dist/plugin/host-stall-profiler-report.d.ts.map +1 -0
- package/dist/plugin/host-stall-profiler.d.ts +96 -0
- package/dist/plugin/host-stall-profiler.d.ts.map +1 -0
- package/dist/plugin/messages-transform.d.ts +21 -6
- package/dist/plugin/messages-transform.d.ts.map +1 -1
- package/dist/{read-session-chunk-egz7r68d.js → read-session-chunk-4jey7hpt.js} +4 -4
- package/dist/{recomp-orchestrator-y15j0rb9.js → recomp-orchestrator-rervg6q4.js} +13 -10
- package/dist/{send-session-notification-dyw42dtr.js → send-session-notification-0m68ms3n.js} +4 -3
- package/dist/shared/auto-search-lifecycle.d.ts +7 -0
- package/dist/shared/auto-search-lifecycle.d.ts.map +1 -0
- package/dist/shared/historian-tool-expansions.d.ts +1 -1
- package/dist/shared/historian-tool-expansions.d.ts.map +1 -1
- package/dist/shared/historian-tool-template.d.ts +2 -2
- package/dist/shared/historian-tool-template.d.ts.map +1 -1
- package/dist/shared/sqlite.d.ts +16 -1
- package/dist/shared/sqlite.d.ts.map +1 -1
- package/dist/shared/status-view.d.ts.map +1 -1
- package/dist/shared/window-geometry.d.ts +4 -0
- package/dist/shared/window-geometry.d.ts.map +1 -1
- package/dist/tools/ctx-expand/render.d.ts.map +1 -1
- package/dist/{transform-postprocess-phase-bqhz6vdr.js → transform-postprocess-phase-z5hzpsxv.js} +13 -10
- package/dist/v2/auto-search-worker.js +115 -0
- package/dist/v2/{context-zecmzk5s.js → context-14v1hr8b.js} +3783 -4668
- package/dist/v2/{derive-budgets-kdgp4s3r.js → derive-budgets-nc9avxz8.js} +2 -2
- package/dist/v2/embedding-worker.js +3 -3
- package/dist/v2/hidden-completion.d.ts.map +1 -1
- package/dist/v2/hooks/context.d.ts.map +1 -1
- package/dist/v2/{message-time-backfill-r6qkem1x.js → message-time-backfill-1f9tzvcs.js} +1 -1
- package/dist/v2/migration-worker.js +7 -5
- package/dist/v2/{read-session-chunk-8vjp6581.js → read-session-chunk-gyyv7w2r.js} +4 -4
- package/dist/v2/{recomp-orchestrator-8ejxvrzz.js → recomp-orchestrator-42vjba7p.js} +17 -14
- package/dist/v2/{send-session-notification-qs0j78v6.js → send-session-notification-c0wtscea.js} +5 -4
- package/dist/v2/server-3trjk1hx.js +6360 -0
- package/dist/v2/{server-e29d7p7c.js → server-50hvkg3v.js} +7 -3
- package/dist/v2/{server-y8maxeft.js → server-cpepxy2q.js} +2 -1
- package/dist/v2/server-d0sraw7m.js +3403 -0
- package/dist/v2/server-e0c1b7a7.js +2063 -0
- package/dist/v2/{server-mcfawjgc.js → server-efhwzx05.js} +5 -24
- package/dist/v2/{server-3n4q9xme.js → server-fcdehk1s.js} +1 -1
- package/dist/{index-q4yp4b52.js → v2/server-fq7kq32k.js} +42 -27
- package/dist/v2/{server-jc7y02q0.js → server-nf82q6pt.js} +1117 -7290
- package/dist/v2/{server-frbm99q5.js → server-njt3np1k.js} +99 -3465
- package/dist/v2/{server-qp5hx1ad.js → server-nm9n3aqq.js} +107 -12
- package/dist/v2/{server-c5gz8wph.js → server-rz514f14.js} +7 -2
- package/dist/v2/{server-wvjvfhck.js → server-vd4e7174.js} +1 -1
- package/dist/{index-fg34g6a5.js → v2/server-wx8a6bw3.js} +48 -8
- package/dist/v2/{server-xa4xe3rv.js → server-y10vbq6y.js} +1 -1
- package/dist/v2/server-yr3zj7e7.js +23 -0
- package/dist/v2/server.js +5 -5
- package/dist/v2/{wrapup-orchestrator-0snhvwcv.js → wrapup-orchestrator-nbz854vc.js} +16 -13
- package/dist/wrapup-orchestrator-b2dztrar.js +29 -0
- package/package.json +3 -3
- package/src/config/index.ts +6 -0
- package/src/config/live-run-config.test.ts +37 -1
- package/src/config/live-run-config.ts +28 -0
- package/src/config/migrate-config-location.ts +10 -3
- package/src/config/schema/magic-context.test.ts +4 -3
- package/src/config/schema/magic-context.ts +18 -6
- package/src/shared/auto-search-lifecycle.ts +27 -0
- package/src/shared/historian-tool-defaults.json +6 -6
- package/src/shared/historian-tool-expansions.ts +65 -8
- package/src/shared/historian-tool-preview-defaults.json +13 -0
- package/src/shared/historian-tool-template.ts +48 -14
- package/src/shared/sqlite-640-review-r2.test.ts +136 -0
- package/src/shared/sqlite-640-review.test.ts +183 -0
- package/src/shared/sqlite-acquisition-routing.test.ts +18 -0
- package/src/shared/sqlite.ts +84 -14
- package/src/shared/status-view.test.ts +6 -1
- package/src/shared/status-view.ts +15 -1
- package/src/shared/tag-transcript.ts +6 -0
- package/src/shared/window-geometry.ts +10 -0
- package/dist/wrapup-orchestrator-39amhv9s.js +0 -26
- /package/dist/{index-en1k8h8m.js → index-5prbx026.js} +0 -0
- /package/dist/v2/{index-en1k8h8m.js → index-5prbx026.js} +0 -0
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
observeEmbeddingActivity
|
|
3
|
+
} from "./server-yr3zj7e7.js";
|
|
1
4
|
import {
|
|
2
5
|
importPluginModule,
|
|
3
6
|
sessionLog
|
|
@@ -7,33 +10,11 @@ import {
|
|
|
7
10
|
} from "./server-6r257mf5.js";
|
|
8
11
|
import {
|
|
9
12
|
shouldHoldIgnoredNotification
|
|
10
|
-
} from "./server-
|
|
13
|
+
} from "./server-vd4e7174.js";
|
|
11
14
|
import {
|
|
12
15
|
getErrorMessage
|
|
13
16
|
} from "./server-y8v6yerm.js";
|
|
14
17
|
|
|
15
|
-
// src/shared/embedding-activity.ts
|
|
16
|
-
var busySessions = new Set;
|
|
17
|
-
function setEmbeddingSessionBusy(sessionId, busy) {
|
|
18
|
-
if (busy)
|
|
19
|
-
busySessions.add(sessionId);
|
|
20
|
-
else
|
|
21
|
-
busySessions.delete(sessionId);
|
|
22
|
-
}
|
|
23
|
-
function observeEmbeddingActivity(event) {
|
|
24
|
-
const props = event.properties;
|
|
25
|
-
if (!props || typeof props.sessionID !== "string")
|
|
26
|
-
return;
|
|
27
|
-
if (event.type === "session.idle" || event.type === "session.deleted" || event.type === "session.status" && props.status?.type === "idle") {
|
|
28
|
-
setEmbeddingSessionBusy(props.sessionID, false);
|
|
29
|
-
} else if (event.type === "session.status" && props.status?.type) {
|
|
30
|
-
setEmbeddingSessionBusy(props.sessionID, true);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
function isEmbeddingHostBusy() {
|
|
34
|
-
return busySessions.size > 0;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
18
|
// src/hooks/magic-context/send-session-notification.ts
|
|
38
19
|
var MAX_QUEUED_IGNORED_NOTIFICATIONS2 = 16;
|
|
39
20
|
var queuedIgnoredNotifications = new Map;
|
|
@@ -420,4 +401,4 @@ async function sendStatusNotification2(_client, sessionId, text, params) {
|
|
|
420
401
|
}
|
|
421
402
|
}
|
|
422
403
|
|
|
423
|
-
export {
|
|
404
|
+
export { MAX_QUEUED_IGNORED_NOTIFICATIONS2, __ignoredNotificationTest2, setNotificationServerUrl2, sendCommandResult2, sendIgnoredMessage2, flushIgnoredMessages2, clearIgnoredMessages2, observeIgnoredNotificationEvent2, sendStatusNotification2 };
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
// src/shared/protected-tools-policy.ts
|
|
2
|
-
var DEFAULT_PROTECTED_TOOLS = {
|
|
3
|
-
todowrite: 1,
|
|
4
|
-
ctx_reduce: 3
|
|
5
|
-
};
|
|
6
|
-
function normalizeProtectedToolName(name) {
|
|
7
|
-
return (name ?? "").toLowerCase().replace(/^mcp_/, "");
|
|
8
|
-
}
|
|
9
|
-
function mergeProtectedTools(...maps) {
|
|
10
|
-
return Object.fromEntries([DEFAULT_PROTECTED_TOOLS, ...maps].flatMap((map) => Object.entries(map ?? {}).map(([name, count]) => [
|
|
11
|
-
normalizeProtectedToolName(name),
|
|
12
|
-
count
|
|
13
|
-
])));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
1
|
// src/shared/historian-tool-template.ts
|
|
17
2
|
class Parser {
|
|
18
3
|
source;
|
|
@@ -92,7 +77,7 @@ class Parser {
|
|
|
92
77
|
} else
|
|
93
78
|
break;
|
|
94
79
|
}
|
|
95
|
-
const expression = { steps
|
|
80
|
+
const expression = { steps };
|
|
96
81
|
if (this.take(".each(")) {
|
|
97
82
|
if (relative)
|
|
98
83
|
return this.error();
|
|
@@ -159,9 +144,23 @@ function compiled(source) {
|
|
|
159
144
|
function oneLine(value) {
|
|
160
145
|
return value.replace(/[\r\n\u2028\u2029]+/g, " ");
|
|
161
146
|
}
|
|
162
|
-
function truncate(value, cap) {
|
|
147
|
+
function truncate(value, cap, legacyPreview = false) {
|
|
163
148
|
const chars = Array.from(oneLine(value));
|
|
164
|
-
|
|
149
|
+
if (cap === undefined || chars.length <= cap)
|
|
150
|
+
return chars.join("");
|
|
151
|
+
if (legacyPreview)
|
|
152
|
+
return `${chars.slice(0, cap).join("")}…`;
|
|
153
|
+
let end = 0;
|
|
154
|
+
for (let i = 0;i < Math.min(cap, chars.length); i++) {
|
|
155
|
+
if (!".!?。!?".includes(chars[i]))
|
|
156
|
+
continue;
|
|
157
|
+
let next = i + 1;
|
|
158
|
+
while (next < chars.length && `"'”’)]`.includes(chars[next]))
|
|
159
|
+
next++;
|
|
160
|
+
if (next <= cap && ("。!?".includes(chars[i]) || next === chars.length || /[ \t]/.test(chars[next])))
|
|
161
|
+
end = next;
|
|
162
|
+
}
|
|
163
|
+
return `${end ? `${chars.slice(0, end).join("")} ` : ""}[… ${chars.length - end} more characters]`;
|
|
165
164
|
}
|
|
166
165
|
function scalar(value) {
|
|
167
166
|
if (value === undefined)
|
|
@@ -178,10 +177,11 @@ function compactJson(value) {
|
|
|
178
177
|
function field(value, key) {
|
|
179
178
|
return value !== null && typeof value === "object" && !Array.isArray(value) && Object.hasOwn(value, key) ? value[key] : undefined;
|
|
180
179
|
}
|
|
181
|
-
function render(nodes, root) {
|
|
180
|
+
function render(nodes, root, legacyPreview) {
|
|
182
181
|
return nodes.map((node) => {
|
|
183
182
|
if (typeof node === "string")
|
|
184
183
|
return node;
|
|
184
|
+
const cap = node.cap ?? (legacyPreview ? 300 : undefined);
|
|
185
185
|
let value = root;
|
|
186
186
|
let list = false;
|
|
187
187
|
for (const step of node.steps) {
|
|
@@ -195,19 +195,19 @@ function render(nodes, root) {
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
if (node.count)
|
|
198
|
-
return truncate(Array.isArray(value) ? String(value.length) : "",
|
|
198
|
+
return truncate(Array.isArray(value) ? String(value.length) : "", cap, legacyPreview);
|
|
199
199
|
if (node.each || list || node.join !== undefined) {
|
|
200
200
|
if (!Array.isArray(value))
|
|
201
201
|
return "";
|
|
202
|
-
const elements = value.slice(0, 10).map((item) => truncate(node.each ? render(node.each, item) : scalar(item), 300));
|
|
203
|
-
if (value.length > 10)
|
|
202
|
+
const elements = value.slice(0, legacyPreview ? 10 : undefined).map((item) => truncate(node.each ? render(node.each, item, legacyPreview) : scalar(item), legacyPreview ? 300 : undefined, legacyPreview));
|
|
203
|
+
if (legacyPreview && value.length > 10)
|
|
204
204
|
elements.push(`… +${value.length - 10} more`);
|
|
205
|
-
return truncate(elements.join(node.join ?? (node.each ? "; " : ", ")),
|
|
205
|
+
return truncate(elements.join(node.join ?? (node.each ? "; " : ", ")), cap, legacyPreview);
|
|
206
206
|
}
|
|
207
|
-
return truncate(scalar(value),
|
|
207
|
+
return truncate(scalar(value), cap, legacyPreview);
|
|
208
208
|
}).join("");
|
|
209
209
|
}
|
|
210
|
-
function renderToolTemplate(source, input, output) {
|
|
210
|
+
function renderToolTemplate(source, input, output, legacyPreview = false) {
|
|
211
211
|
const nodes = compiled(source);
|
|
212
212
|
if (!nodes)
|
|
213
213
|
return null;
|
|
@@ -222,8 +222,23 @@ function renderToolTemplate(source, input, output) {
|
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
const root = { input, output: structured };
|
|
225
|
-
const bareOutputNodes = nodes.map((node) => typeof node !== "string" && node.steps.length === 1 && ("field" in node.steps[0]) && node.steps[0].field === "output" && !node.each && !node.count && node.join === undefined ? truncate(text ?? "", node.cap) : node);
|
|
226
|
-
return truncate(render(bareOutputNodes, root), 1000);
|
|
225
|
+
const bareOutputNodes = nodes.map((node) => typeof node !== "string" && node.steps.length === 1 && ("field" in node.steps[0]) && node.steps[0].field === "output" && !node.each && !node.count && node.join === undefined ? truncate(text ?? "", node.cap ?? (legacyPreview ? 300 : undefined), legacyPreview) : node);
|
|
226
|
+
return truncate(render(bareOutputNodes, root, legacyPreview), legacyPreview ? 1000 : undefined, legacyPreview);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// src/shared/protected-tools-policy.ts
|
|
230
|
+
var DEFAULT_PROTECTED_TOOLS = {
|
|
231
|
+
todowrite: 1,
|
|
232
|
+
ctx_reduce: 3
|
|
233
|
+
};
|
|
234
|
+
function normalizeProtectedToolName(name) {
|
|
235
|
+
return (name ?? "").toLowerCase().replace(/^mcp_/, "");
|
|
236
|
+
}
|
|
237
|
+
function mergeProtectedTools(...maps) {
|
|
238
|
+
return Object.fromEntries([DEFAULT_PROTECTED_TOOLS, ...maps].flatMap((map) => Object.entries(map ?? {}).map(([name, count]) => [
|
|
239
|
+
normalizeProtectedToolName(name),
|
|
240
|
+
count
|
|
241
|
+
])));
|
|
227
242
|
}
|
|
228
243
|
|
|
229
244
|
export { toolTemplateError, renderToolTemplate, DEFAULT_PROTECTED_TOOLS, normalizeProtectedToolName, mergeProtectedTools };
|