返回 CodeWhale
creator.mjs
根目录 / crates / engine / extension-host / dist / builtin / creator.mjs
1 // codewhale built-in host module creator — generated by crates/engine/extension-host/build.mjs; do not edit.
2 var __defProp = Object.defineProperty;
3 var __export = (target, all) => {
4 for (var name3 in all)
5 __defProp(target, name3, { get: all[name3], enumerable: true });
6 };
7
8 // node_modules/@deepseek-ai/dsh-util-values/lib/index.js
9 var SIMPLE_ESCAPES = {
10 '"': '"',
11 "\\": "\\",
12 "/": "/",
13 b: "\b",
14 f: "\f",
15 n: "\n",
16 r: "\r",
17 t: " "
18 };
19 var CONTENT_ESCAPE = /[\\\u0000-\u001f]/u;
20 function isWhitespace(c) {
21 return c === " " || c === "\n" || c === "\r" || c === " ";
22 }
23 function isHex(c) {
24 return c >= "0" && c <= "9" || c >= "a" && c <= "f" || c >= "A" && c <= "F";
25 }
26 var PartialArguments = class PartialArguments2 {
27 /** The view of a call with no arguments available. */
28 static EMPTY = PartialArguments2.fromObject({});
29 /**
30 * View finished argument text without scanning it until a reader asks.
31 * @param text - the complete argument JSON text.
32 * @returns a sealed view.
33 */
34 static fromText(text) {
35 const view = new PartialArguments2();
36 view.append(text);
37 view.sealed = true;
38 return view;
39 }
40 /**
41 * View an already parsed argument payload, such as a PTC dispatch object.
42 * @param value - the parsed argument value.
43 * @returns a sealed view; a non-object payload has no fields.
44 */
45 static fromObject(value) {
46 const view = new PartialArguments2();
47 view.object = typeof value === "object" && value !== null && !Array.isArray(value) ? value : {};
48 view.sealed = true;
49 return view;
50 }
51 /**
52 * The source: text so far or a parsed object, plus whether it can still grow.
53 * These are the only enumerable fields, so two views over the same source
54 * compare equal structurally however far each has been read.
55 */
56 chunks = [];
57 object;
58 sealed = false;
59 #ends = [];
60 #size = 0;
61 #consumed = 0;
62 #mode = "root";
63 #escape = false;
64 #keyStart = 0;
65 #keyEscaped = false;
66 #key = "";
67 #current = null;
68 #nestedEnds = [];
69 #nestedInString = false;
70 #invalidAt;
71 #invalidValue = false;
72 #entries = /* @__PURE__ */ new Map();
73 #order = [];
74 #reads = /* @__PURE__ */ new Map();
75 /** Whether this view rejects further appends; does not scan text or register reads. */
76 get isSealed() {
77 return this.sealed;
78 }
79 /** Whether indexing or a content read found invalid JSON; unread value contents are not validated. */
80 get invalid() {
81 this.scan();
82 return this.#mode === "invalid" || this.#invalidValue;
83 }
84 /**
85 * Retain streamed argument text without scanning or comparing observed answers.
86 * @param fragment - the text following every fragment appended before.
87 */
88 append(fragment) {
89 if (this.sealed) throw new Error("PartialArguments: cannot append to a sealed view");
90 if (fragment.length === 0) return;
91 this.chunks.push(fragment);
92 this.#size += fragment.length;
93 this.#ends.push(this.#size);
94 }
95 /**
96 * Reconcile a streamed prefix with authoritative complete text without joining the fragments.
97 * @param text - the final argument text, which replaces missing or conflicting deltas.
98 * @returns this view sealed with its caches retained when every character matches; otherwise a new sealed view.
99 */
100 settle(text) {
101 if (this.object !== void 0 || text.length !== this.#size) return PartialArguments2.fromText(text);
102 let offset = 0;
103 for (const chunk of this.chunks) {
104 if (!text.startsWith(chunk, offset)) return PartialArguments2.fromText(text);
105 offset += chunk.length;
106 }
107 this.chunks = text.length === 0 ? [] : [text];
108 this.#ends = text.length === 0 ? [] : [text.length];
109 this.sealed = true;
110 return this;
111 }
112 /**
113 * Compare observed answers and advance their publication baseline. Unread views remain unscanned.
114 * @returns whether any observed answer changed since its first read or the preceding refresh.
115 */
116 refresh() {
117 if (this.#reads.size === 0) return false;
118 this.scan();
119 let changed = false;
120 let completions = false;
121 for (const read of this.#reads.values()) {
122 if (read.completion) {
123 completions = true;
124 continue;
125 }
126 changed = this.refreshRead(read) || changed;
127 }
128 if (completions) {
129 for (const read of this.#reads.values()) if (read.completion) changed = this.refreshRead(read) || changed;
130 }
131 if (this.sealed) this.#reads.clear();
132 return changed;
133 }
134 refreshRead(read) {
135 const now = read.answer();
136 if (Object.is(now, read.last)) return false;
137 read.last = now;
138 return true;
139 }
140 /**
141 * Check whether no further fields can arrive.
142 * @returns whether the outer object closed, indexing failed, or the view is sealed; unread values are not validated.
143 */
144 closed() {
145 return this.remember("closed", "", () => this.closedNow());
146 }
147 /**
148 * List discovered fields in first-appearance order.
149 * @returns top-level keys seen so far, in first-appearance order.
150 */
151 keys() {
152 return this.remember("keys", "", () => this.keysNow(), (keys) => keys.length);
153 }
154 /**
155 * Check whether a top-level field has appeared.
156 * @param key - argument name.
157 * @returns whether the field has appeared (a string opened or another value began).
158 */
159 has(key) {
160 return this.remember("has", key, () => this.hasNow(key));
161 }
162 /**
163 * Check whether a field's closing delimiter has arrived, without validating its contents.
164 * @param key - argument name.
165 * @returns whether its delimiter arrived and no content reader has reported an error for this value.
166 */
167 complete(key) {
168 return this.remember("complete", key, () => this.completeNow(key));
169 }
170 /**
171 * Read string length without materializing its text.
172 * @param key - argument name.
173 * @param options - change granularity for a streaming string.
174 * @returns decoded UTF-16 length of the string field so far; undefined when absent or not a string.
175 */
176 stringLength(key, options) {
177 const step = Math.max(1, Math.floor(options?.step ?? 1));
178 const offset = options?.offset ?? 0;
179 return this.remember(`length:${step}:${offset}`, key, () => this.lengthNow(key), (length) => length === void 0 ? void 0 : Math.ceil((length + offset) / step));
180 }
181 /**
182 * Check a string against a decoded UTF-16 length limit without materializing it.
183 * @param key - argument name.
184 * @param maxLength - decoded UTF-16 limit, floored to at least zero.
185 * @returns whether the string is longer than the limit; false when absent or not a string.
186 */
187 stringExceeds(key, maxLength) {
188 const limit = Math.max(0, Math.floor(maxLength));
189 return this.remember(`exceeds:${limit}`, key, () => (this.lengthNow(key, limit + 1) ?? 0) > limit);
190 }
191 /**
192 * Read a decoded string, including a streaming prefix.
193 * @param key - argument name.
194 * @returns the string field's decoded text so far; undefined when absent or not a string.
195 */
196 text(key) {
197 return this.remember("text", key, () => this.textNow(key));
198 }
199 /**
200 * Read at most the first decoded UTF-16 units of a string.
201 * @param key - argument name.
202 * @param maxLength - maximum decoded UTF-16 length, floored to at least one.
203 * @returns the bounded string prefix; undefined when absent or not a string.
204 */
205 textPrefix(key, maxLength) {
206 const limit = Math.max(1, Math.floor(maxLength));
207 return this.remember(`prefix:${limit}`, key, () => this.textPrefixNow(key, limit));
208 }
209 /**
210 * Read a completed non-string argument.
211 * @param key - argument name.
212 * @returns the parsed non-string value once it closed; undefined while open, absent, or a string.
213 */
214 value(key) {
215 return this.remember("value", key, () => this.valueNow(key));
216 }
217 /** Answer a question and, on a streaming view, remember it for change detection. */
218 remember(kind, key, read, comparison) {
219 this.scan();
220 const result = read();
221 if (!this.sealed) {
222 const id = `${kind}/${key}`;
223 if (!this.#reads.has(id)) this.#reads.set(id, {
224 completion: kind === "complete",
225 answer: comparison === void 0 ? read : () => comparison(read()),
226 last: comparison === void 0 ? result : comparison(result)
227 });
228 }
229 return result;
230 }
231 closedNow() {
232 return this.sealed || this.#mode === "closed" || this.#mode === "invalid";
233 }
234 keysNow() {
235 return this.object === void 0 ? this.#order : Object.keys(this.object);
236 }
237 hasNow(key) {
238 return this.object === void 0 ? this.#entries.has(key) : Object.hasOwn(this.object, key);
239 }
240 completeNow(key) {
241 if (this.object !== void 0) return Object.hasOwn(this.object, key);
242 const entry = this.#entries.get(key);
243 return entry !== void 0 && entry.end >= 0 && (entry.kind === "string" ? entry.invalidAt === void 0 : !entry.invalid);
244 }
245 lengthNow(key, limit = Number.POSITIVE_INFINITY) {
246 if (this.object !== void 0) {
247 const field = Object.hasOwn(this.object, key) ? this.object[key] : void 0;
248 return typeof field === "string" ? field.length : void 0;
249 }
250 const entry = this.#entries.get(key);
251 if (entry?.kind !== "string") return void 0;
252 if (entry.text !== void 0 && entry.text.at === entry.end) return entry.text.length;
253 const read = entry.length ??= {
254 at: entry.start,
255 length: 0,
256 text: ""
257 };
258 this.readString(entry, read, limit, false);
259 return read.length;
260 }
261 textNow(key) {
262 if (this.object !== void 0) {
263 const field = Object.hasOwn(this.object, key) ? this.object[key] : void 0;
264 return typeof field === "string" ? field : void 0;
265 }
266 const entry = this.#entries.get(key);
267 if (entry?.kind !== "string") return void 0;
268 if (entry.text === void 0 && entry.end >= 0 && entry.needsDecoding && entry.invalidAt === void 0) {
269 let text;
270 try {
271 text = JSON.parse(`"${this.slice(entry.start, entry.end)}"`);
272 } catch (_error) {
273 }
274 if (text !== void 0) entry.text = {
275 at: entry.end,
276 length: text.length,
277 text
278 };
279 }
280 const read = entry.text ??= {
281 at: entry.start,
282 length: 0,
283 text: ""
284 };
285 this.readString(entry, read, Number.POSITIVE_INFINITY, true);
286 return read.text;
287 }
288 textPrefixNow(key, maxLength) {
289 if (this.object !== void 0) {
290 const field = Object.hasOwn(this.object, key) ? this.object[key] : void 0;
291 return typeof field === "string" ? field.slice(0, maxLength) : void 0;
292 }
293 const entry = this.#entries.get(key);
294 if (entry?.kind !== "string") return void 0;
295 const prefixes = entry.prefixes ??= /* @__PURE__ */ new Map();
296 let read = prefixes.get(maxLength);
297 if (read === void 0) {
298 read = {
299 at: entry.start,
300 length: 0,
301 text: ""
302 };
303 prefixes.set(maxLength, read);
304 }
305 this.readString(entry, read, maxLength, true);
306 return read.text;
307 }
308 valueNow(key) {
309 if (this.object !== void 0) {
310 if (!Object.hasOwn(this.object, key)) return void 0;
311 const field = this.object[key];
312 return typeof field === "string" ? void 0 : field;
313 }
314 const entry = this.#entries.get(key);
315 if (entry?.kind !== "value" || entry.end < 0 || entry.invalid) return void 0;
316 if (entry.parsed === void 0) try {
317 entry.parsed = JSON.parse(this.slice(entry.start, entry.end));
318 } catch (_error) {
319 entry.invalid = true;
320 this.#invalidValue = true;
321 }
322 return entry.parsed;
323 }
324 chunkAt(at) {
325 let low = 0;
326 let high = this.#ends.length;
327 while (low < high) {
328 const mid = low + high >>> 1;
329 if (this.#ends[mid] <= at) low = mid + 1;
330 else high = mid;
331 }
332 return low;
333 }
334 /** Materialize only a requested range, never the cumulative source. */
335 slice(start, end) {
336 if (start >= end) return "";
337 const first = this.chunkAt(start);
338 const last = this.chunkAt(end - 1);
339 const base = first === 0 ? 0 : this.#ends[first - 1];
340 if (first === last) return this.chunks[first].slice(start - base, end - base);
341 const parts = [this.chunks[first].slice(start - base)];
342 for (let i = first + 1; i < last; i++) parts.push(this.chunks[i]);
343 parts.push(this.chunks[last].slice(0, end - this.#ends[last - 1]));
344 return parts.join("");
345 }
346 readString(entry, read, limit, materialize) {
347 const end = Math.min(entry.end < 0 ? this.#consumed : entry.end, entry.invalidAt ?? Number.POSITIVE_INFINITY, this.#invalidAt ?? Number.POSITIVE_INFINITY);
348 if (!entry.needsDecoding) {
349 const length = Math.min(end - read.at, limit - read.length);
350 if (length <= 0) return;
351 if (materialize) read.text += this.slice(read.at, read.at + length);
352 read.at += length;
353 read.length += length;
354 return;
355 }
356 let chunkIndex = this.chunkAt(read.at);
357 while (read.at < end && read.length < limit) {
358 const base = chunkIndex === 0 ? 0 : this.#ends[chunkIndex - 1];
359 const chunk = this.chunks[chunkIndex];
360 const remaining = chunk.slice(read.at - base, Math.min(chunk.length, end - base));
361 const boundary = remaining.search(CONTENT_ESCAPE);
362 const length = Math.min(boundary < 0 ? remaining.length : boundary, limit - read.length);
363 if (length > 0) {
364 if (materialize) read.text += remaining.slice(0, length);
365 read.at += length;
366 read.length += length;
367 if (read.at === base + chunk.length) chunkIndex++;
368 continue;
369 }
370 const type = remaining.length > 1 ? remaining[1] : read.at + 1 < end ? this.chunks[chunkIndex + 1][0] : void 0;
371 let decoded;
372 let width = 2;
373 if (remaining[0] === "\\" && type === void 0 && entry.end < 0) return;
374 if (remaining[0] === "\\" && type === "u") {
375 const hex = this.slice(read.at + 2, Math.min(end, read.at + 6));
376 let valid = true;
377 for (let i = 0; i < hex.length; i++) if (!isHex(hex[i])) valid = false;
378 if (valid) {
379 if (hex.length < 4 && entry.end < 0) return;
380 if (hex.length === 4) decoded = String.fromCharCode(Number.parseInt(hex, 16));
381 }
382 width = 6;
383 } else if (remaining[0] === "\\" && type !== void 0) decoded = SIMPLE_ESCAPES[type];
384 if (decoded === void 0) {
385 entry.invalidAt = read.at;
386 this.#invalidValue = true;
387 return;
388 }
389 if (materialize) read.text += decoded;
390 read.length++;
391 read.at += width;
392 while (chunkIndex < this.chunks.length && read.at >= this.#ends[chunkIndex]) chunkIndex++;
393 }
394 }
395 /** Locate new field ranges without decoding or parsing their contents. */
396 scan() {
397 if (this.object !== void 0 || this.#consumed === this.#size) return;
398 for (let i = this.chunkAt(this.#consumed); i < this.chunks.length && this.#invalidAt === void 0; i++) {
399 const pending = this.chunks[i];
400 const base = i === 0 ? 0 : this.#ends[i - 1];
401 for (let index = this.#consumed - base; index < pending.length && this.#mode !== "invalid"; index++) {
402 if (this.#mode === "string" || this.#mode === "nested" && this.#nestedInString) {
403 const end = this.stringBoundary(pending, index);
404 this.#consumed += end - index;
405 index = end;
406 if (index === pending.length) break;
407 }
408 this.step(pending[index], this.#consumed);
409 this.#consumed++;
410 }
411 }
412 }
413 /** Only raw quotes and their preceding backslash runs can terminate a string. */
414 stringBoundary(fragment, start) {
415 let at = start;
416 while (true) {
417 const quote = fragment.indexOf('"', at);
418 const end = quote < 0 ? fragment.length : quote;
419 if (this.#mode === "string") {
420 const entry = this.#current;
421 if (!entry.needsDecoding && CONTENT_ESCAPE.test(fragment.slice(at, end))) entry.needsDecoding = true;
422 }
423 let slashStart = end;
424 while (slashStart > at && fragment[slashStart - 1] === "\\") slashStart--;
425 const escaped = (end - slashStart) % 2 === 1 !== (slashStart === at && this.#escape);
426 this.#escape = quote < 0 && escaped;
427 if (quote < 0 || !escaped) return end;
428 at = quote + 1;
429 }
430 }
431 step(c, at) {
432 switch (this.#mode) {
433 case "root":
434 if (isWhitespace(c)) return;
435 if (c === "{") {
436 this.#mode = "key-or-end";
437 return;
438 }
439 this.fail();
440 return;
441 case "key-or-end":
442 if (isWhitespace(c)) return;
443 if (c === "}") {
444 this.#mode = "closed";
445 return;
446 }
447 if (c === '"') {
448 this.beginKey(at);
449 return;
450 }
451 this.fail();
452 return;
453 case "key-only":
454 if (isWhitespace(c)) return;
455 if (c === '"') {
456 this.beginKey(at);
457 return;
458 }
459 this.fail();
460 return;
461 case "key":
462 this.stepKey(c, at);
463 return;
464 case "colon":
465 if (isWhitespace(c)) return;
466 if (c === ":") {
467 this.#mode = "value";
468 return;
469 }
470 this.fail();
471 return;
472 case "value":
473 this.beginValue(c, at);
474 return;
475 case "string": {
476 const entry = this.#current;
477 entry.end = at;
478 this.#current = null;
479 this.#mode = "comma-or-end";
480 return;
481 }
482 case "scalar":
483 this.stepScalar(c, at);
484 return;
485 case "nested":
486 this.stepNested(c, at);
487 return;
488 case "comma-or-end":
489 if (isWhitespace(c)) return;
490 if (c === ",") {
491 this.#mode = "key-only";
492 return;
493 }
494 if (c === "}") {
495 this.#mode = "closed";
496 return;
497 }
498 this.fail();
499 return;
500 case "closed":
501 if (isWhitespace(c)) return;
502 this.fail();
503 return;
504 /* v8 ignore next 2 -- scan() stops stepping once the view is invalid. */
505 case "invalid":
506 return;
507 /* v8 ignore next 2 -- Every scanner mode has a handler above. */
508 default:
509 assertNever(this.#mode);
510 }
511 }
512 fail() {
513 this.#invalidAt = this.#consumed;
514 this.#mode = "invalid";
515 this.#current = null;
516 }
517 beginKey(at) {
518 this.#mode = "key";
519 this.#keyStart = at + 1;
520 this.#keyEscaped = false;
521 this.#escape = false;
522 }
523 stepKey(c, at) {
524 if (c < " ") {
525 this.fail();
526 return;
527 }
528 if (this.#escape) {
529 this.#escape = false;
530 return;
531 }
532 if (c === "\\") {
533 this.#escape = true;
534 this.#keyEscaped = true;
535 return;
536 }
537 if (c !== '"') return;
538 const raw = this.slice(this.#keyStart, at);
539 if (this.#keyEscaped) try {
540 this.#key = JSON.parse(`"${raw}"`);
541 } catch (_error) {
542 this.fail();
543 return;
544 }
545 else this.#key = raw;
546 this.#mode = "colon";
547 }
548 open(entry) {
549 if (!this.#entries.has(this.#key)) this.#order.push(this.#key);
550 this.#entries.set(this.#key, entry);
551 this.#current = entry;
552 }
553 beginValue(c, at) {
554 if (isWhitespace(c)) return;
555 if (c === '"') {
556 this.open({
557 kind: "string",
558 start: at + 1,
559 end: -1,
560 needsDecoding: false,
561 invalidAt: void 0,
562 length: void 0,
563 text: void 0,
564 prefixes: void 0
565 });
566 this.#escape = false;
567 this.#mode = "string";
568 return;
569 }
570 if (c === "}" || c === "," || c === ":" || c === "]") {
571 this.fail();
572 return;
573 }
574 this.open({
575 kind: "value",
576 start: at,
577 end: -1,
578 parsed: void 0,
579 invalid: false
580 });
581 if (c === "{" || c === "[") {
582 this.#mode = "nested";
583 this.#nestedEnds = [c === "{" ? "}" : "]"];
584 this.#nestedInString = false;
585 this.#escape = false;
586 return;
587 }
588 this.#mode = "scalar";
589 }
590 stepScalar(c, at) {
591 if (c !== "," && c !== "}" && !isWhitespace(c)) return;
592 this.closeValue(at);
593 this.#mode = c === "," ? "key-only" : c === "}" ? "closed" : "comma-or-end";
594 }
595 stepNested(c, at) {
596 if (this.#nestedInString) {
597 this.#nestedInString = false;
598 return;
599 }
600 if (c === '"') {
601 this.#nestedInString = true;
602 return;
603 }
604 if (c === "{" || c === "[") {
605 this.#nestedEnds.push(c === "{" ? "}" : "]");
606 return;
607 }
608 if (c === "}" || c === "]") {
609 if (this.#nestedEnds.pop() !== c) {
610 this.fail();
611 return;
612 }
613 if (this.#nestedEnds.length === 0) {
614 this.closeValue(at + 1);
615 this.#mode = "comma-or-end";
616 }
617 }
618 }
619 closeValue(end) {
620 const entry = this.#current;
621 entry.end = end;
622 this.#current = null;
623 }
624 };
625 function assertNever(value, context) {
626 const rendered = JSON.stringify(value) ?? String(value);
627 throw new Error(`unreachable variant${context ? ` in ${context}` : ""}: ${rendered}`);
628 }
629 function hasIntrinsicConstructor(prototype, name3) {
630 const constructor = Object.getOwnPropertyDescriptor(prototype, "constructor")?.value;
631 if (typeof constructor !== "function") return false;
632 try {
633 return constructor.name === name3 && constructor.prototype === prototype && Function.prototype.toString.call(constructor) === Function.prototype.toString.call(name3 === "Array" ? Array : Object);
634 } catch {
635 return false;
636 }
637 }
638 function isIntrinsicObjectPrototype(value) {
639 return Object.getPrototypeOf(value) === null && hasIntrinsicConstructor(value, "Object");
640 }
641 function hasPlainArrayPrototype(value) {
642 const prototype = Object.getPrototypeOf(value);
643 if (!Array.isArray(prototype) || !hasIntrinsicConstructor(prototype, "Array")) return false;
644 const objectPrototype = Object.getPrototypeOf(prototype);
645 return typeof objectPrototype === "object" && objectPrototype !== null && isIntrinsicObjectPrototype(objectPrototype);
646 }
647 function hasPlainObjectPrototype(value) {
648 const prototype = Object.getPrototypeOf(value);
649 return prototype === null || typeof prototype === "object" && isIntrinsicObjectPrototype(prototype);
650 }
651 function enumerableStringKeys(value) {
652 const keys = Reflect.ownKeys(value);
653 if (keys.some((key) => typeof key !== "string" || !Object.prototype.propertyIsEnumerable.call(value, key))) return void 0;
654 return keys;
655 }
656 function walkJsonValue(value, detach) {
657 const ancestors = /* @__PURE__ */ new Set();
658 let root;
659 let parent;
660 const assign = (item) => {
661 if (parent === void 0) {
662 if (detach) root = item;
663 } else if (parent.kind === "array") {
664 if (parent.target !== void 0) parent.target[parent.key] = item;
665 } else if (parent.target !== void 0) Object.defineProperty(parent.target, parent.key, {
666 value: item,
667 enumerable: true,
668 configurable: true,
669 writable: true
670 });
671 };
672 const frames = [];
673 let current = value;
674 for (; ; ) {
675 if (current === null) assign(null);
676 else if (typeof current === "boolean" || typeof current === "string") assign(current);
677 else if (typeof current === "number") {
678 if (!Number.isFinite(current) || Object.is(current, -0)) return void 0;
679 assign(current);
680 } else {
681 if (typeof current !== "object") return void 0;
682 if (ancestors.has(current)) return void 0;
683 if (Array.isArray(current)) {
684 if (!hasPlainArrayPrototype(current)) return void 0;
685 const length = current.length;
686 if (Reflect.ownKeys(current).length !== length + 1) return void 0;
687 const target = detach ? [] : void 0;
688 if (target !== void 0) assign(target);
689 let indices;
690 if (!Number.isInteger(length)) {
691 indices = [];
692 for (let index = length - 1; index >= 0; index--) indices.push(index);
693 }
694 frames.push({
695 kind: "array",
696 source: current,
697 length: indices?.length ?? length,
698 index: 0,
699 key: 0,
700 indices,
701 target
702 });
703 } else {
704 if (!hasPlainObjectPrototype(current)) return void 0;
705 const keys = enumerableStringKeys(current);
706 if (keys === void 0) return void 0;
707 const target = detach ? {} : void 0;
708 if (target !== void 0) assign(target);
709 frames.push({
710 kind: "object",
711 source: current,
712 keys,
713 index: 0,
714 key: "",
715 target
716 });
717 }
718 ancestors.add(current);
719 }
720 for (; ; ) {
721 const frame = frames.at(-1);
722 if (frame === void 0) return detach ? root : true;
723 const length = frame.kind === "array" ? frame.length : frame.keys.length;
724 if (frame.index >= length) {
725 ancestors.delete(frame.source);
726 frames.pop();
727 continue;
728 }
729 const index = frame.index++;
730 parent = frame;
731 if (frame.kind === "array") {
732 const key = frame.indices === void 0 ? index : frame.indices[frame.indices.length - index - 1];
733 if (key === void 0) return void 0;
734 if (!Object.prototype.hasOwnProperty.call(frame.source, key)) return void 0;
735 frame.key = key;
736 current = frame.source[key];
737 } else {
738 const key = frame.keys[index];
739 if (key === void 0) return void 0;
740 frame.key = key;
741 current = frame.source[key];
742 }
743 break;
744 }
745 }
746 }
747 function isJsonValue(value) {
748 return walkJsonValue(value, false) === true;
749 }
750
751 // src/dsh/upstream/creator/sandbox/escalation.js
752 var en = { escalation: (mode, justification) => `Allow this operation with ${mode} permissions: ${justification}` };
753 var zh = { escalation: (mode, justification) => `允许本次操作使用 ${mode} 权限:${justification}` };
754 var ja = { escalation: (mode, justification) => `${mode} 権限でこの操作を許可します:${justification}` };
755 var es = { escalation: (mode, justification) => `Permitir esta operación con permisos ${mode}: ${justification}` };
756 var fr = { escalation: (mode, justification) => `Autoriser cette opération avec les permissions ${mode} : ${justification}` };
757 var de = { escalation: (mode, justification) => `Diesen Vorgang mit ${mode}-Berechtigungen zulassen: ${justification}` };
758 var ru = { escalation: (mode, justification) => `Разрешить эту операцию с правами ${mode}: ${justification}` };
759 var pt = { escalation: (mode, justification) => `Permitir esta operação com permissões ${mode}: ${justification}` };
760 function escalationDisplayReason(mode, justification) {
761 return {
762 en: en.escalation(mode, justification),
763 zh: zh.escalation(mode, justification),
764 ja: ja.escalation(mode, justification),
765 es: es.escalation(mode, justification),
766 fr: fr.escalation(mode, justification),
767 de: de.escalation(mode, justification),
768 ru: ru.escalation(mode, justification),
769 pt: pt.escalation(mode, justification)
770 };
771 }
772 var WIDER_MODES = {
773 "read-only": ["workspace-write", "danger-full-access"],
774 "workspace-write": ["danger-full-access"]
775 };
776 async function approveEscalation(request, approval) {
777 const { requestedMode: mode, effectiveMode, justification, subject } = request;
778 if (mode === effectiveMode) return effectiveMode;
779 if (!(WIDER_MODES[effectiveMode] ?? []).includes(mode)) throw new Error(`sandbox escalation to "${mode}" is not strictly wider than this call's current "${effectiveMode}" mode`);
780 if (approval.approver === void 0) throw new Error(`sandbox escalation to "${mode}" requires approval, but no approval service is composed`);
781 if (approval.agent === void 0) throw new Error(`sandbox escalation to "${mode}" requires approval, but the call has no agent to route it through`);
782 const outcome = await approval.approver.request({
783 agent: approval.agent,
784 toolName: approval.toolName,
785 callId: approval.callId,
786 reason: `escalate sandbox to ${mode}: ${justification}`,
787 displayReason: escalationDisplayReason(mode, justification),
788 ...approval.signal ? { signal: approval.signal } : {}
789 });
790 switch (outcome) {
791 case "allowed-once":
792 return mode;
793 case "rejected":
794 throw new Error(`the user rejected escalating this ${subject} to "${mode}"; it stays denied, so stop and explain instead of working around it`);
795 case "cancelled":
796 throw new Error(`approval for escalating to "${mode}" was cancelled`);
797 case "unavailable":
798 throw new Error(`sandbox escalation to "${mode}" requires approval, but no approval channel is available`);
799 default:
800 return assertNever(outcome, "EscalationOutcome");
801 }
802 }
803
804 // src/dsh/dsh-message-compat.js
805 var HarnessError = class extends Error {
806 code;
807 constructor(message, code, options) {
808 super(message, options);
809 this.code = code;
810 this.name = new.target.name;
811 }
812 };
813 var LlmError = class extends HarnessError {
814 constructor(message, code, options) {
815 super(message, code, options);
816 this.name = "LlmError";
817 }
818 };
819 var UserQuestionError = class extends HarnessError {
820 constructor(message, code, options) {
821 super(message, code, options);
822 this.name = "UserQuestionError";
823 }
824 };
825 Object.defineProperty(HarnessError, "name", { value: "HarnessError" });
826 Object.defineProperty(LlmError, "name", { value: "LlmError" });
827 Object.defineProperty(UserQuestionError, "name", { value: "UserQuestionError" });
828
829 // src/dsh/dsh-tools-compat.js
830 var JsonSchemaError = class extends HarnessError {
831 /** Individual schema violations in walk order. */
832 violations;
833 constructor(violations) {
834 super(`unsupported JSON schema: ${violations.join("; ")}`, "UNSUPPORTED_SCHEMA");
835 this.name = "JsonSchemaError";
836 this.violations = violations;
837 }
838 };
839 var CONSTRAINT_KEYWORDS = /* @__PURE__ */ new Set([
840 "type",
841 "oneOf",
842 "properties",
843 "required",
844 "additionalProperties",
845 "items",
846 "enum",
847 "const"
848 ]);
849 var ANNOTATION_KEYWORDS = /* @__PURE__ */ new Set([
850 "description",
851 "title",
852 "default",
853 "examples"
854 ]);
855 var SCHEMA_TYPES = [
856 "object",
857 "array",
858 "string",
859 "number",
860 "integer",
861 "boolean",
862 "null"
863 ];
864 function hasIntrinsicConstructor2(prototype, name3) {
865 const constructor = Object.getOwnPropertyDescriptor(prototype, "constructor")?.value;
866 if (typeof constructor !== "function") return false;
867 try {
868 return constructor.name === name3 && constructor.prototype === prototype && Function.prototype.toString.call(constructor) === `function ${name3}() { [native code] }`;
869 } catch {
870 return false;
871 }
872 }
873 function isIntrinsicObjectPrototype2(value) {
874 return Object.getPrototypeOf(value) === null && hasIntrinsicConstructor2(value, "Object");
875 }
876 function isPlainJsonRecord(value) {
877 if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
878 try {
879 const prototype = Object.getPrototypeOf(value);
880 return prototype === null || typeof prototype === "object" && isIntrinsicObjectPrototype2(prototype);
881 } catch {
882 return false;
883 }
884 }
885 function hasPlainArrayPrototype2(value) {
886 const prototype = Object.getPrototypeOf(value);
887 if (!Array.isArray(prototype) || !hasIntrinsicConstructor2(prototype, "Array")) return false;
888 const objectPrototype = Object.getPrototypeOf(prototype);
889 return typeof objectPrototype === "object" && objectPrototype !== null && isIntrinsicObjectPrototype2(objectPrototype);
890 }
891 function hasOnlyEnumerableStringKeys(value) {
892 try {
893 return Reflect.ownKeys(value).every((key) => typeof key === "string" && Object.prototype.propertyIsEnumerable.call(value, key));
894 } catch {
895 return false;
896 }
897 }
898 function isJsonSchemaRecord(value) {
899 return isPlainJsonRecord(value) && hasOnlyEnumerableStringKeys(value);
900 }
901 function isPlainJsonArray(value) {
902 if (!Array.isArray(value)) return false;
903 try {
904 if (!hasPlainArrayPrototype2(value) || Reflect.ownKeys(value).length !== value.length + 1) return false;
905 for (let index = 0; index < value.length; index++) if (!Object.hasOwn(value, index)) return false;
906 return true;
907 } catch {
908 return false;
909 }
910 }
911 function isJsonNumber(value) {
912 return typeof value === "number" && Number.isFinite(value) && !Object.is(value, -0);
913 }
914 function scalarMatches(type, value) {
915 switch (type) {
916 case "string":
917 return typeof value === "string";
918 case "number":
919 return isJsonNumber(value);
920 case "integer":
921 return isJsonNumber(value) && Number.isInteger(value);
922 case "boolean":
923 return typeof value === "boolean";
924 case "null":
925 return value === null;
926 /* v8 ignore next -- JsonSchemaScalarType is closed; this retains compile-time exhaustiveness. */
927 default:
928 return assertNever(type, "JsonSchemaType");
929 }
930 }
931 var ONE_OF_SIBLING_KEYWORDS = [
932 "properties",
933 "required",
934 "additionalProperties",
935 "items",
936 "enum",
937 "const"
938 ];
939 function checkObjectSchemaTail(node, path, properties, violations) {
940 const hasRequired = Object.hasOwn(node, "required");
941 const required = hasRequired ? node.required : void 0;
942 if (hasRequired) if (!isPlainJsonArray(required) || required.some((entry) => typeof entry !== "string")) violations.push(`${path}.required must be an array of strings`);
943 else {
944 const declared = isJsonSchemaRecord(properties) ? properties : {};
945 for (const key of required) if (!Object.hasOwn(declared, key)) violations.push(`${path}.required names "${key}" which is not in properties`);
946 }
947 if (Object.hasOwn(node, "additionalProperties") && typeof node.additionalProperties !== "boolean") violations.push(`${path}.additionalProperties must be a boolean`);
948 }
949 function checkSchemaNode(root, rootPath, violations, seen) {
950 const tasks = [{
951 kind: "enter",
952 node: root,
953 path: rootPath
954 }];
955 for (let task = tasks.pop(); task !== void 0; task = tasks.pop()) {
956 if (task.kind === "leave") {
957 seen.delete(task.node);
958 continue;
959 }
960 if (task.kind === "one-of-tail") {
961 for (const key of ONE_OF_SIBLING_KEYWORDS) if (Object.hasOwn(task.node, key)) violations.push(`${task.path}.${key} is not supported beside oneOf`);
962 continue;
963 }
964 if (task.kind === "object-tail") {
965 checkObjectSchemaTail(task.node, task.path, task.properties, violations);
966 continue;
967 }
968 const { node, path } = task;
969 if (!isJsonSchemaRecord(node)) {
970 violations.push(`${path} must be a schema object`);
971 continue;
972 }
973 if (seen.has(node)) {
974 violations.push(`${path} is circular`);
975 continue;
976 }
977 seen.add(node);
978 tasks.push({
979 kind: "leave",
980 node
981 });
982 for (const key of Object.keys(node)) {
983 if (CONSTRAINT_KEYWORDS.has(key)) continue;
984 if (ANNOTATION_KEYWORDS.has(key)) {
985 try {
986 if (!isJsonValue(node[key])) violations.push(`${path}.${key} annotation must be lossless JSON data`);
987 } catch {
988 violations.push(`${path}.${key} annotation must be lossless JSON data`);
989 }
990 continue;
991 }
992 violations.push(`${path}.${key} is not a supported keyword (subset: type/oneOf/properties/required/additionalProperties/items/enum/const + annotations)`);
993 }
994 if (Object.hasOwn(node, "description") && typeof node.description !== "string") violations.push(`${path}.description must be a string`);
995 if (Object.hasOwn(node, "title") && typeof node.title !== "string") violations.push(`${path}.title must be a string`);
996 const hasType = Object.hasOwn(node, "type");
997 const hasOneOf = Object.hasOwn(node, "oneOf");
998 if (hasType && hasOneOf) {
999 violations.push(`${path} cannot declare both type and oneOf`);
1000 continue;
1001 }
1002 if (!hasType && !hasOneOf) {
1003 for (const key of ONE_OF_SIBLING_KEYWORDS) if (Object.hasOwn(node, key)) violations.push(`${path}.${key} requires type or oneOf`);
1004 continue;
1005 }
1006 if (hasOneOf) {
1007 const oneOf = node.oneOf;
1008 tasks.push({
1009 kind: "one-of-tail",
1010 node,
1011 path
1012 });
1013 if (!isPlainJsonArray(oneOf) || oneOf.length < 2) violations.push(`${path}.oneOf must be an array of at least two schemas`);
1014 else for (let index = oneOf.length - 1; index >= 0; index--) tasks.push({
1015 kind: "enter",
1016 node: oneOf[index],
1017 path: `${path}.oneOf[${index}]`
1018 });
1019 continue;
1020 }
1021 const type = node.type;
1022 if (typeof type !== "string" || !SCHEMA_TYPES.includes(type)) {
1023 violations.push(Array.isArray(type) ? `${path}.type must be a single type string (type arrays are not supported)` : `${path}.type must be one of ${SCHEMA_TYPES.join("/")}`);
1024 continue;
1025 }
1026 const schemaType = type;
1027 for (const [key, types] of Object.entries({
1028 properties: ["object"],
1029 required: ["object"],
1030 additionalProperties: ["object"],
1031 items: ["array"],
1032 enum: [
1033 "string",
1034 "number",
1035 "integer",
1036 "boolean",
1037 "null"
1038 ],
1039 const: [
1040 "string",
1041 "number",
1042 "integer",
1043 "boolean",
1044 "null"
1045 ]
1046 })) if (Object.hasOwn(node, key) && !types.includes(schemaType)) violations.push(`${path}.${key} is not supported on type "${schemaType}"`);
1047 switch (schemaType) {
1048 case "object": {
1049 const properties = Object.hasOwn(node, "properties") ? node.properties : void 0;
1050 tasks.push({
1051 kind: "object-tail",
1052 node,
1053 path,
1054 properties
1055 });
1056 if (Object.hasOwn(node, "properties")) if (!isJsonSchemaRecord(properties)) violations.push(`${path}.properties must be an object of schemas`);
1057 else {
1058 const entries = Object.entries(properties);
1059 for (let index = entries.length - 1; index >= 0; index--) {
1060 const entry = entries[index];
1061 if (entry === void 0) continue;
1062 tasks.push({
1063 kind: "enter",
1064 node: entry[1],
1065 path: `${path}.properties.${entry[0]}`
1066 });
1067 }
1068 }
1069 break;
1070 }
1071 case "array":
1072 if (Object.hasOwn(node, "items")) tasks.push({
1073 kind: "enter",
1074 node: node.items,
1075 path: `${path}.items`
1076 });
1077 break;
1078 case "string":
1079 case "number":
1080 case "integer":
1081 case "boolean":
1082 case "null": {
1083 const hasEnum = Object.hasOwn(node, "enum");
1084 const allowed = hasEnum ? node.enum : void 0;
1085 const enumValid = isPlainJsonArray(allowed) && allowed.length > 0 && allowed.every((entry) => scalarMatches(schemaType, entry));
1086 if (hasEnum && !enumValid) violations.push(`${path}.enum must be a non-empty array of ${schemaType} values`);
1087 const hasConst = Object.hasOwn(node, "const");
1088 const declaredConst = hasConst ? node.const : void 0;
1089 const constValid = scalarMatches(schemaType, declaredConst);
1090 if (hasConst) {
1091 if (!constValid) violations.push(`${path}.const must be a ${schemaType} value`);
1092 else if (enumValid && !allowed.includes(declaredConst)) violations.push(`${path}.const must be one of ${path}.enum when both are declared`);
1093 }
1094 break;
1095 }
1096 /* v8 ignore next -- schemaType was narrowed from the closed SCHEMA_TYPES table above. */
1097 default:
1098 assertNever(schemaType, "JsonSchemaType");
1099 }
1100 }
1101 }
1102 function assertSupportedJsonSchema(schema) {
1103 const violations = [];
1104 checkSchemaNode(schema, "schema", violations, /* @__PURE__ */ new Set());
1105 if (violations.length > 0) throw new JsonSchemaError(violations);
1106 }
1107 function safelyIsJsonValue(value) {
1108 try {
1109 return isJsonValue(value);
1110 } catch {
1111 return false;
1112 }
1113 }
1114 function diagnosticPath(path) {
1115 return path === "" ? "arguments" : path;
1116 }
1117 function propertyPath(path, key) {
1118 return path === "" ? key : `${path}.${key}`;
1119 }
1120 function losslessValueViolation(path) {
1121 return [`"${diagnosticPath(path)}" must be a lossless JSON value`];
1122 }
1123 function appendViolations(target, source) {
1124 for (const violation of source) target.push(violation);
1125 }
1126 function valueFrame(node, value, path) {
1127 return {
1128 node,
1129 value,
1130 path,
1131 catches: false,
1132 phase: "start",
1133 children: [],
1134 childIndex: 0,
1135 violations: [],
1136 tailViolations: [],
1137 matches: 0
1138 };
1139 }
1140 function checkScalarValue(node, value, path) {
1141 const allowed = Object.hasOwn(node, "enum") ? node.enum : void 0;
1142 if (allowed !== void 0 && !allowed.includes(value)) return [`"${diagnosticPath(path)}" must be one of ${JSON.stringify(allowed)}`];
1143 if (Object.hasOwn(node, "const") && value !== node.const) return [`"${diagnosticPath(path)}" must be ${JSON.stringify(node.const)}`];
1144 return [];
1145 }
1146 function checkValue(schema, value, path) {
1147 const frames = [valueFrame(schema, value, path)];
1148 let rootResult;
1149 const receive = (result) => {
1150 const parent = frames.at(-1);
1151 if (parent === void 0) {
1152 rootResult = result;
1153 return;
1154 }
1155 if (parent.kind === "oneOf") {
1156 if (result.length === 0) parent.matches++;
1157 } else appendViolations(parent.violations, result);
1158 };
1159 const finish = (result) => {
1160 frames.pop();
1161 receive(result);
1162 };
1163 while (frames.length > 0) {
1164 const frame = frames.at(-1);
1165 if (frame === void 0) break;
1166 try {
1167 if (frame.phase === "children") {
1168 if (frame.childIndex < frame.children.length) {
1169 const child = frame.children[frame.childIndex];
1170 if (child === void 0) throw new Error("missing schema-value child frame");
1171 frame.childIndex++;
1172 frames.push(valueFrame(child.node, child.value, child.path));
1173 continue;
1174 }
1175 if (frame.kind === "oneOf") {
1176 finish(frame.matches === 1 ? [] : [`"${diagnosticPath(frame.path)}" must match exactly one oneOf branch (matched ${frame.matches})`]);
1177 continue;
1178 }
1179 appendViolations(frame.violations, frame.tailViolations);
1180 if (frame.violations.length > 0) finish(frame.violations);
1181 else if (frame.kind === "object") finish(safelyIsJsonValue(frame.value) ? [] : [`"${diagnosticPath(frame.path)}" must be a lossless JSON object`]);
1182 else finish(safelyIsJsonValue(frame.value) ? [] : [`"${diagnosticPath(frame.path)}" must be a dense lossless JSON array`]);
1183 continue;
1184 }
1185 const nodeType = Object.hasOwn(frame.node, "type") ? frame.node.type : void 0;
1186 frame.catches = !(nodeType !== void 0 && !SCHEMA_TYPES.includes(nodeType));
1187 const oneOf = Object.hasOwn(frame.node, "oneOf") ? frame.node.oneOf : void 0;
1188 if (oneOf !== void 0) {
1189 frame.kind = "oneOf";
1190 frame.children = Array.from(oneOf, (branch) => ({
1191 node: branch,
1192 value: frame.value,
1193 path: frame.path
1194 }));
1195 frame.childIndex = 0;
1196 frame.matches = 0;
1197 frame.phase = "children";
1198 continue;
1199 }
1200 if (nodeType === void 0) {
1201 finish(safelyIsJsonValue(frame.value) ? [] : losslessValueViolation(frame.path));
1202 continue;
1203 }
1204 switch (nodeType) {
1205 case "object": {
1206 if (!isPlainJsonRecord(frame.value)) {
1207 finish([`"${diagnosticPath(frame.path)}" must be an object`]);
1208 break;
1209 }
1210 const properties = Object.hasOwn(frame.node, "properties") ? frame.node.properties ?? {} : {};
1211 const violations = [];
1212 const required = Object.hasOwn(frame.node, "required") ? frame.node.required ?? [] : [];
1213 for (const key of required) if (!Object.hasOwn(frame.value, key) || frame.value[key] === void 0) violations.push(`missing required property "${propertyPath(frame.path, key)}"`);
1214 const children = [];
1215 for (const [key, child] of Object.entries(properties)) {
1216 if (!Object.hasOwn(frame.value, key) || frame.value[key] === void 0) continue;
1217 children.push({
1218 node: child,
1219 value: frame.value[key],
1220 path: propertyPath(frame.path, key)
1221 });
1222 }
1223 const tailViolations = [];
1224 if (Object.hasOwn(frame.node, "additionalProperties") && frame.node.additionalProperties === false) {
1225 for (const key of Object.keys(frame.value)) if (!Object.hasOwn(properties, key)) tailViolations.push(`"${propertyPath(frame.path, key)}" is not a declared property (additionalProperties: false)`);
1226 }
1227 frame.kind = "object";
1228 frame.children = children;
1229 frame.childIndex = 0;
1230 frame.violations = violations;
1231 frame.tailViolations = tailViolations;
1232 frame.phase = "children";
1233 break;
1234 }
1235 case "array": {
1236 if (!Array.isArray(frame.value)) {
1237 finish([`"${diagnosticPath(frame.path)}" must be an array`]);
1238 break;
1239 }
1240 const items = Object.hasOwn(frame.node, "items") ? frame.node.items : void 0;
1241 const children = items === void 0 ? [] : frame.value.flatMap((entry, index) => [{
1242 node: items,
1243 value: entry,
1244 path: `${frame.path}[${index}]`
1245 }]);
1246 frame.kind = "array";
1247 frame.children = children;
1248 frame.childIndex = 0;
1249 frame.violations = [];
1250 frame.phase = "children";
1251 break;
1252 }
1253 case "string":
1254 finish(typeof frame.value === "string" ? checkScalarValue(frame.node, frame.value, frame.path) : [`"${diagnosticPath(frame.path)}" must be a string`]);
1255 break;
1256 case "number":
1257 finish(typeof frame.value !== "number" ? [`"${diagnosticPath(frame.path)}" must be a number`] : !isJsonNumber(frame.value) ? [`"${diagnosticPath(frame.path)}" must be a finite JSON number`] : checkScalarValue(frame.node, frame.value, frame.path));
1258 break;
1259 case "integer":
1260 finish(!isJsonNumber(frame.value) || !Number.isInteger(frame.value) ? [`"${diagnosticPath(frame.path)}" must be an integer`] : checkScalarValue(frame.node, frame.value, frame.path));
1261 break;
1262 case "boolean":
1263 finish(typeof frame.value === "boolean" ? checkScalarValue(frame.node, frame.value, frame.path) : [`"${diagnosticPath(frame.path)}" must be a boolean`]);
1264 break;
1265 case "null":
1266 finish(frame.value === null ? checkScalarValue(frame.node, frame.value, frame.path) : [`"${diagnosticPath(frame.path)}" must be null`]);
1267 break;
1268 default:
1269 finish(assertNever(nodeType, "JsonSchemaType"));
1270 }
1271 } catch (error) {
1272 let failed = frames.pop();
1273 while (failed !== void 0 && !failed.catches) failed = frames.pop();
1274 if (failed === void 0) throw error;
1275 receive(losslessValueViolation(failed.path));
1276 }
1277 }
1278 return rootResult ?? losslessValueViolation(path);
1279 }
1280 function validateJsonSchemaValue(schema, value, path = "value") {
1281 return checkValue(schema, value, path);
1282 }
1283 var ANNOTATION_KEYS = [
1284 "description",
1285 "title",
1286 "default",
1287 "examples"
1288 ];
1289 function authorError(message) {
1290 throw new JsonSchemaError([message]);
1291 }
1292 function copyAnnotations(source, target) {
1293 if (Object.hasOwn(source, "description")) target.description = source.description;
1294 if (Object.hasOwn(source, "title")) target.title = source.title;
1295 if (Object.hasOwn(source, "default")) target.default = source.default;
1296 if (Object.hasOwn(source, "examples")) target.examples = source.examples;
1297 }
1298 function assertAuthorKeys(source, path, allowed) {
1299 for (const key of Object.keys(source)) if (!allowed.includes(key)) authorError(`${path}.${key} is not supported by the value schema DSL`);
1300 }
1301 function assignCompiledNode(destination, node) {
1302 switch (destination.kind) {
1303 case "root":
1304 destination.holder.value = node;
1305 break;
1306 case "property":
1307 Object.defineProperty(destination.target, destination.key, {
1308 value: node,
1309 enumerable: true,
1310 configurable: true,
1311 writable: true
1312 });
1313 break;
1314 case "item":
1315 destination.target.items = node;
1316 break;
1317 case "one-of":
1318 destination.target[destination.index] = node;
1319 break;
1320 }
1321 }
1322 function assignCompiledPropertyMap(destination, compiled) {
1323 if (destination.kind === "root") destination.holder.value = compiled;
1324 else destination.target.properties = compiled.properties;
1325 }
1326 function runSchemaCompiler(initial) {
1327 const seen = /* @__PURE__ */ new Set();
1328 const tasks = [initial];
1329 for (let task = tasks.pop(); task !== void 0; task = tasks.pop()) {
1330 if (task.kind === "leave") {
1331 seen.delete(task.input);
1332 continue;
1333 }
1334 if (task.kind === "property-map-tail") {
1335 if (task.required.length > 0) {
1336 task.compiled.required = task.required;
1337 if (task.destination.kind === "object") task.destination.target.required = task.required;
1338 }
1339 continue;
1340 }
1341 if (task.kind === "property") {
1342 if (!isJsonSchemaRecord(task.property)) authorError(`${task.path} must be a value schema object`);
1343 if (Object.hasOwn(task.property, "required") && task.property.required !== true) authorError(`${task.path}.required must be true when present`);
1344 if (Object.hasOwn(task.property, "required") && task.property.required === true) task.required.push(task.key);
1345 tasks.push({
1346 kind: "value",
1347 input: task.property,
1348 path: task.path,
1349 allowRequired: true,
1350 destination: {
1351 kind: "property",
1352 target: task.properties,
1353 key: task.key
1354 }
1355 });
1356 continue;
1357 }
1358 if (task.kind === "property-map") {
1359 if (!isJsonSchemaRecord(task.input)) authorError(`${task.path} must be an object of value schemas`);
1360 if (seen.has(task.input)) authorError(`${task.path} is circular`);
1361 seen.add(task.input);
1362 const compiled = { properties: {} };
1363 const required = [];
1364 assignCompiledPropertyMap(task.destination, compiled);
1365 tasks.push({
1366 kind: "leave",
1367 input: task.input
1368 });
1369 tasks.push({
1370 kind: "property-map-tail",
1371 compiled,
1372 required,
1373 destination: task.destination
1374 });
1375 const entries = Object.entries(task.input);
1376 for (let index = entries.length - 1; index >= 0; index--) {
1377 const entry = entries[index];
1378 if (entry === void 0) continue;
1379 tasks.push({
1380 kind: "property",
1381 property: entry[1],
1382 path: `${task.path}.${entry[0]}`,
1383 key: entry[0],
1384 properties: compiled.properties,
1385 required
1386 });
1387 }
1388 continue;
1389 }
1390 const { input, path } = task;
1391 if (!isJsonSchemaRecord(input)) authorError(`${path} must be a value schema object`);
1392 if (seen.has(input)) authorError(`${path} is circular`);
1393 seen.add(input);
1394 const authorKeys = [...ANNOTATION_KEYS, ...task.allowRequired ? ["required"] : []];
1395 const node = {};
1396 assignCompiledNode(task.destination, node);
1397 tasks.push({
1398 kind: "leave",
1399 input
1400 });
1401 if (Object.hasOwn(input, "oneOf")) {
1402 assertAuthorKeys(input, path, [
1403 ...authorKeys,
1404 "oneOf",
1405 "type"
1406 ]);
1407 if (Object.hasOwn(input, "type")) authorError(`${path} cannot declare both type and oneOf`);
1408 if (!isPlainJsonArray(input.oneOf)) authorError(`${path}.oneOf must be an array of at least two value schemas`);
1409 const branches = [];
1410 node.oneOf = branches;
1411 copyAnnotations(input, node);
1412 for (let index = input.oneOf.length - 1; index >= 0; index--) tasks.push({
1413 kind: "value",
1414 input: input.oneOf[index],
1415 path: `${path}.oneOf[${index}]`,
1416 allowRequired: false,
1417 destination: {
1418 kind: "one-of",
1419 target: branches,
1420 index
1421 }
1422 });
1423 continue;
1424 }
1425 const inputType = Object.hasOwn(input, "type") ? input.type : void 0;
1426 switch (inputType) {
1427 case "json":
1428 assertAuthorKeys(input, path, [...authorKeys, "type"]);
1429 copyAnnotations(input, node);
1430 break;
1431 case "object":
1432 assertAuthorKeys(input, path, [
1433 ...authorKeys,
1434 "type",
1435 "properties",
1436 "additionalProperties"
1437 ]);
1438 if (!Object.hasOwn(input, "additionalProperties") || typeof input.additionalProperties !== "boolean") authorError(`${path}.additionalProperties must be explicitly true or false`);
1439 node.type = "object";
1440 copyAnnotations(input, node);
1441 node.additionalProperties = input.additionalProperties;
1442 if (Object.hasOwn(input, "properties")) tasks.push({
1443 kind: "property-map",
1444 input: input.properties,
1445 path: `${path}.properties`,
1446 destination: {
1447 kind: "object",
1448 target: node
1449 }
1450 });
1451 break;
1452 case "array":
1453 assertAuthorKeys(input, path, [
1454 ...authorKeys,
1455 "type",
1456 "items"
1457 ]);
1458 node.type = "array";
1459 copyAnnotations(input, node);
1460 if (Object.hasOwn(input, "items")) tasks.push({
1461 kind: "value",
1462 input: input.items,
1463 path: `${path}.items`,
1464 allowRequired: false,
1465 destination: {
1466 kind: "item",
1467 target: node
1468 }
1469 });
1470 break;
1471 case "string":
1472 case "number":
1473 case "integer":
1474 case "boolean":
1475 case "null":
1476 assertAuthorKeys(input, path, [
1477 ...authorKeys,
1478 "type",
1479 "enum",
1480 "const"
1481 ]);
1482 node.type = inputType;
1483 copyAnnotations(input, node);
1484 if (Object.hasOwn(input, "enum")) {
1485 if (!isPlainJsonArray(input.enum)) authorError(`${path}.enum must be a non-empty array of scalar values`);
1486 node.enum = Array.from(input.enum, (entry) => entry);
1487 }
1488 if (Object.hasOwn(input, "const")) node.const = input.const;
1489 break;
1490 default:
1491 authorError(`${path}.type must be string/number/integer/boolean/null/array/object/json, or use oneOf`);
1492 }
1493 }
1494 }
1495 function compilePropertyMap(input, path) {
1496 const holder = {};
1497 runSchemaCompiler({
1498 kind: "property-map",
1499 input,
1500 path,
1501 destination: {
1502 kind: "root",
1503 holder
1504 }
1505 });
1506 return holder.value ?? authorError(`${path} did not compile`);
1507 }
1508 function compileValueSchema(input, path) {
1509 const holder = {};
1510 runSchemaCompiler({
1511 kind: "value",
1512 input,
1513 path,
1514 allowRequired: false,
1515 destination: {
1516 kind: "root",
1517 holder
1518 }
1519 });
1520 return holder.value ?? authorError(`${path} did not compile`);
1521 }
1522 function valueSchemaSpecToJsonSchema(spec) {
1523 const schema = compileValueSchema(spec, "schema");
1524 assertSupportedJsonSchema(schema);
1525 return schema;
1526 }
1527 function parameterSchemaSpecToJsonSchema(spec) {
1528 const compiled = compilePropertyMap(spec, "parameters");
1529 const schema = {
1530 type: "object",
1531 properties: compiled.properties,
1532 ...compiled.required === void 0 ? {} : { required: compiled.required }
1533 };
1534 assertSupportedJsonSchema(schema);
1535 return schema;
1536 }
1537 var ToolArgsError = class extends HarnessError {
1538 /** Individual violations in schema-walk order. */
1539 violations;
1540 constructor(violations) {
1541 super(`invalid arguments: ${violations.join("; ")}`, "INVALID_ARGS");
1542 this.name = "ToolArgsError";
1543 this.violations = violations;
1544 }
1545 };
1546 function defineTool(options) {
1547 const userExecute = options.execute;
1548 const userFinalizeContent = options.finalizeContent;
1549 const userProjectContent = options.projectContent;
1550 const userRender = options.output.render;
1551 const userPresentationMeta = options.output.presentationMeta;
1552 const userPresentCall = options.presentCall;
1553 const userPresentResult = options.presentResult;
1554 const userIsConcurrencySafe = options.isConcurrencySafe;
1555 if (options.timeoutMs !== void 0 && (!Number.isFinite(options.timeoutMs) || options.timeoutMs <= 0)) throw new Error(`defineTool(${options.name}): timeoutMs must be a positive finite number`);
1556 const parameters = parameterSchemaSpecToJsonSchema(options.parameters);
1557 const outputSchema = valueSchemaSpecToJsonSchema(options.output.schema);
1558 const validate = (args) => validateJsonSchemaValue(parameters, args, "");
1559 const tool = {
1560 name: options.name,
1561 description: options.description,
1562 parameters,
1563 output: {
1564 schema: outputSchema,
1565 render(args, value) {
1566 return userRender(args, value);
1567 },
1568 ...userPresentationMeta !== void 0 ? { presentationMeta(args, value) {
1569 return userPresentationMeta(args, value);
1570 } } : {}
1571 },
1572 ...options.deferLoading === true ? { deferLoading: options.deferLoading } : {},
1573 ...options.timeoutMs !== void 0 ? { timeoutMs: options.timeoutMs } : {},
1574 async execute(args, exec) {
1575 const violations = validate(args);
1576 if (violations.length > 0) throw new ToolArgsError(violations);
1577 return userExecute(args, exec);
1578 }
1579 };
1580 if (userProjectContent) tool.projectContent = (exec, result) => userProjectContent(exec, result);
1581 if (userFinalizeContent) tool.finalizeContent = (exec, result) => userFinalizeContent(exec, result);
1582 if (userPresentCall) tool.presentCall = (args) => {
1583 if (validate(args).length > 0) return void 0;
1584 return userPresentCall(args);
1585 };
1586 if (userPresentResult) tool.presentResult = (args, result) => {
1587 if (validate(args).length > 0) return void 0;
1588 return userPresentResult(args, result);
1589 };
1590 if (userIsConcurrencySafe) tool.isConcurrencySafe = (args) => {
1591 if (validate(args).length > 0) return false;
1592 return userIsConcurrencySafe(args);
1593 };
1594 return tool;
1595 }
1596
1597 // src/dsh/compatibility.json
1598 var compatibility_default = {
1599 version: 3,
1600 target_dsh_version: "0.2.2-rc.1",
1601 provided_services: {
1602 dsh: [
1603 "tools",
1604 "commands",
1605 "storage",
1606 "skills",
1607 "sessions",
1608 "userQuestions",
1609 "subagents",
1610 "agents",
1611 "systemPrompt",
1612 "llm",
1613 "credentials",
1614 "settings",
1615 "pluginManager",
1616 "deepseekAccount",
1617 "terminal",
1618 "attachments",
1619 "agentPresets",
1620 "agentDefaultModel",
1621 "sessionProjections",
1622 "workspaceRegistry",
1623 "typertGateway",
1624 "web",
1625 "webServer",
1626 "connection",
1627 "sessionTitle",
1628 "profileContext",
1629 "sessionPersistence",
1630 "storageDomain",
1631 "invariants",
1632 "permissionPresets"
1633 ],
1634 cordis: [
1635 "logger",
1636 "events",
1637 "reflect",
1638 "registry"
1639 ],
1640 codewhale: [
1641 "prompt",
1642 "avatars",
1643 "mcp",
1644 "shellHooks",
1645 "remote",
1646 "workspace"
1647 ]
1648 },
1649 refused_services: [
1650 "shellHooks",
1651 "loader",
1652 "approval",
1653 "agents",
1654 "subagents",
1655 "sessions",
1656 "llm",
1657 "sandboxPolicy",
1658 "credentials",
1659 "fs",
1660 "subprocess",
1661 "systemPrompt",
1662 "runtimeLoop",
1663 "tools",
1664 "commands",
1665 "prompt",
1666 "storage",
1667 "skills",
1668 "avatars",
1669 "mcp",
1670 "logger",
1671 "userQuestions",
1672 "remote",
1673 "workspace",
1674 "settings",
1675 "pluginManager",
1676 "deepseekAccount",
1677 "terminal",
1678 "attachments",
1679 "agentPresets",
1680 "agentDefaultModel",
1681 "sessionProjections",
1682 "workspaceRegistry",
1683 "typertGateway",
1684 "web",
1685 "webServer",
1686 "connection",
1687 "sessionTitle",
1688 "profileContext",
1689 "sessionPersistence",
1690 "storageDomain",
1691 "invariants",
1692 "permissionPresets"
1693 ],
1694 row_bridges: {
1695 "@deepseek-ai/dsh-mcp-client": "mcp",
1696 "@deepseek-ai/dsh-skill-filesystem": "skills",
1697 "@deepseek-ai/dsh-hooks-claude-code": "hooks-claude-code",
1698 "@deepseek-ai/dsh-hooks-codex": "hooks-codex",
1699 "@deepseek-ai/dsh-persona": "persona",
1700 "@deepseek-ai/dsh-storage": "host-spine",
1701 "@deepseek-ai/dsh-storage-json": "host-spine",
1702 "@deepseek-ai/dsh-storage-domain": "host-spine",
1703 "@deepseek-ai/dsh-workspace": "host-spine",
1704 "@deepseek-ai/dsh-code-runtime-worker-thread": "host-spine",
1705 "@deepseek-ai/dsh-tool-subagent/model-selection-settings": "host-spine",
1706 "@deepseek-ai/dsh-agent-preset-registry": "host-spine",
1707 "@deepseek-ai/dsh-cordis-host-runner": "host-spine",
1708 "@deepseek-ai/dsh-host-webserver": "host-spine"
1709 },
1710 module_singletons: {
1711 "@codewhale/dsh-composition": "dsh-composition",
1712 "@deepseek-ai/cordis-plugin-loader": "dsh-loader",
1713 "@deepseek-ai/cordis-plugin-include": "dsh-include",
1714 "@deepseek-ai/cordis-plugin-group": "dsh-group",
1715 "@deepseek-ai/cordis": "cordis",
1716 "@deepseek-ai/schemastery": "schemastery",
1717 "@deepseek-ai/cosmokit": "cosmokit",
1718 cosmokit: "cosmokit",
1719 "@deepseek-ai/dsh-tools": "dsh-tools",
1720 "@deepseek-ai/dsh-error": "dsh-error",
1721 "@deepseek-ai/dsh-util-values": "dsh-util-values",
1722 "@deepseek-ai/dsh-commands/brand": "dsh-commands-brand",
1723 "@deepseek-ai/dsh-llm": "dsh-llm-values",
1724 "@deepseek-ai/dsh-session": "dsh-session-values",
1725 "@deepseek-ai/dsh-session/surface": "dsh-session-surface",
1726 "@deepseek-ai/dsh-system-prompt": "dsh-system-prompt-values",
1727 "@deepseek-ai/dsh-user-questions": "dsh-user-questions-values",
1728 "@deepseek-ai/dsh-credentials": "dsh-credentials",
1729 "@deepseek-ai/dsh-settings": "dsh-settings",
1730 "@deepseek-ai/dsh-home-paths": "dsh-home-paths",
1731 "@deepseek-ai/dsh-atomic-write": "dsh-atomic-write",
1732 "@deepseek-ai/dsh-skill": "dsh-skill",
1733 "@deepseek-ai/dsh-typert-protocol": "dsh-typert-protocol",
1734 "@deepseek-ai/dsh-workspace": "dsh-workspace",
1735 "@deepseek-ai/dsh-subagent": "dsh-subagent",
1736 "@deepseek-ai/dsh-agent": "dsh-agent",
1737 "@deepseek-ai/dsh-app-boot": "dsh-app-boot"
1738 },
1739 definition_api: {
1740 package: "@deepseek-ai/dsh-tools",
1741 version: "0.2.2-rc.1",
1742 license: "MIT",
1743 tarball: "https://registry.npmjs.org/@deepseek-ai/dsh-tools/-/dsh-tools-0.2.2-rc.1.tgz",
1744 integrity: "sha512-svB49dLPCHkKHgGwik3dTvEH0sL1vKwIzlQgqjE4qzEqFbSEROW8fByk3g2y2lxDv8TqgEUa0Vp2qFrVbm2lfw==",
1745 license_sha256: "ebb4f09972aee8608be255debaf78451a68e95c290f55c240dec2ecfa16ea6be",
1746 tarball_sha256: "bb94ee037bd7d3efe2d0654c6a1fa7084b268b895fa0ca6ceeb7e65d4fd6da72",
1747 sources: [
1748 {
1749 file: "lib/shared-DTdn5dXO.js",
1750 sha256: "d02f0d8f36878313b0dae3a1bba5b77f7db4cffc77a0b72772048a36bacf2cf0",
1751 lines: [
1752 [
1753 22,
1754 548
1755 ]
1756 ]
1757 },
1758 {
1759 file: "lib/index.js",
1760 sha256: "1889cbf718d64518dd83245d4dba1e1f080b2c5326259c3ed5b1be7a7666a2bd",
1761 lines: [
1762 [
1763 7,
1764 377
1765 ]
1766 ]
1767 },
1768 {
1769 file: "lib/shared-DTdn5dXO.js",
1770 sha256: "d02f0d8f36878313b0dae3a1bba5b77f7db4cffc77a0b72772048a36bacf2cf0",
1771 lines: [
1772 [
1773 566,
1774 596
1775 ]
1776 ]
1777 }
1778 ]
1779 },
1780 command_followup: "one-text-message-submit-on-success",
1781 pure_api: {
1782 file: "src/dsh/dsh-message-compat.js",
1783 source_sha256: "018236676c31a588543e69d09821c53bc1138d14f4520b92ceba0e122cc8de78",
1784 exports: {
1785 "@deepseek-ai/dsh-llm": [
1786 "createUserMessage",
1787 "createAssistantMessage",
1788 "createSystemMessage",
1789 "createToolResultMessage",
1790 "freezeMessage",
1791 "contentHasImage",
1792 "ReasoningEffortId",
1793 "MessageId",
1794 "ToolCallId",
1795 "isAgentLoopRequest",
1796 "resolveRetryPolicy",
1797 "boundContextSummary",
1798 "BlockAssembler",
1799 "LlmAdapter",
1800 "LlmError",
1801 "HarnessError"
1802 ],
1803 "@deepseek-ai/dsh-session": [
1804 "SessionId",
1805 "SESSION_FORMAT_VERSION",
1806 "KNOWN_SESSION_EVENT_TYPES",
1807 "deriveEventMessage"
1808 ],
1809 "@deepseek-ai/dsh-system-prompt": [
1810 "PERSONA_PREFIX_SECTION"
1811 ],
1812 "@deepseek-ai/dsh-user-questions": [
1813 "UserQuestionError"
1814 ]
1815 },
1816 packages: [
1817 {
1818 package: "@deepseek-ai/dsh-brand",
1819 version: "0.2.2-rc.1",
1820 license: "MIT",
1821 tarball: "https://registry.npmjs.org/@deepseek-ai/dsh-brand/-/dsh-brand-0.2.2-rc.1.tgz",
1822 integrity: "sha512-ShGNEmNuEQA+bfkspWC2kGrdbrM4dFNhqlrNHIWsHO+PgVH1KoTKTLSraT1pt0A8YYk/moKE0gL2gY9dNBU+rw==",
1823 tarball_sha256: "d953cb5e8dcd69be0b0347ce9a3b36421eefa751820cbe909f4a185348ad5530",
1824 source_file: "lib/index.js",
1825 source_sha256: "14feb59256b891982b2017d73ed03ee65e2a7365f48e4902a856acb0e52d5eb0",
1826 excerpts: [
1827 {
1828 name: "brandString",
1829 lines: [
1830 20,
1831 22
1832 ],
1833 sha256: "2f0b62ba6507db54836a99e24d1d219e598b6140e575d2cf5c63d86a18e5e8ac"
1834 }
1835 ],
1836 license_sha256: "ebb4f09972aee8608be255debaf78451a68e95c290f55c240dec2ecfa16ea6be",
1837 license_text_sha256: "fe195482bb2bddf34ebced7531d6afb11c33fa42f248472736ad9fa9b9eb503b",
1838 excerpted: true
1839 },
1840 {
1841 package: "@deepseek-ai/dsh-util-crypto",
1842 version: "0.2.2-rc.1",
1843 license: "MIT",
1844 tarball: "https://registry.npmjs.org/@deepseek-ai/dsh-util-crypto/-/dsh-util-crypto-0.2.2-rc.1.tgz",
1845 integrity: "sha512-I9Nhh3/64HPzjdR/mUt0J534FYHgodMUe0coXtA91+kxGcJQcSHOYouewv4hf0NWw0BuLh5zihTdtldZtobOWA==",
1846 tarball_sha256: "c9ef0dfed280c83202f1d7bd5d32b1139a92a2fc375da62962ef709c3d1e4a6a",
1847 source_file: "lib/index.js",
1848 source_sha256: "640b26c8e5a1156c6c8e8749a22f805c9c0e34444778eb4ee9529be3e88ec862",
1849 excerpts: [
1850 {
1851 name: "randomUUID",
1852 lines: [
1853 27,
1854 33
1855 ],
1856 sha256: "e6c3b47d5cf366a149204c36d1697e658f61c48bfd96e66ec1c96deec3a8f4e2"
1857 }
1858 ],
1859 license_sha256: "ebb4f09972aee8608be255debaf78451a68e95c290f55c240dec2ecfa16ea6be",
1860 license_text_sha256: "fe195482bb2bddf34ebced7531d6afb11c33fa42f248472736ad9fa9b9eb503b",
1861 excerpted: true
1862 },
1863 {
1864 package: "@deepseek-ai/dsh-llm",
1865 version: "0.2.2-rc.1",
1866 license: "MIT",
1867 tarball: "https://registry.npmjs.org/@deepseek-ai/dsh-llm/-/dsh-llm-0.2.2-rc.1.tgz",
1868 integrity: "sha512-XeEvH+6bpkjx0E2P1B5ZE+WWa+VHp4DimQaJDKNUZEFouqHMuN1B61TIz6IzUquRxa/6X4yJy+qXQ9WwAeMw5w==",
1869 tarball_sha256: "cbf45039d3ef63e26987de514928a847a8c2d0b049df8fb24c11684e203b05d4",
1870 source_file: "lib/index.js",
1871 source_sha256: "8e541fc98a11897706a122fde1db42f8b2a41b3b354ba3fcb932e9a16929ac6a",
1872 excerpts: [
1873 {
1874 name: "createMessage",
1875 lines: [
1876 37,
1877 42
1878 ],
1879 sha256: "74baa44c9dea1821d97bd4fe592b21baf31f60eaf06962a269fcf2ec88e352ae"
1880 },
1881 {
1882 name: "createUserMessage",
1883 lines: [
1884 59,
1885 64
1886 ],
1887 sha256: "2c4929c2c18e511aa0fefe216eb50e703191057bb15ba1412ddcfdcc8bfc020f"
1888 },
1889 {
1890 name: "HarnessError declaration",
1891 lines: [
1892 126,
1893 126
1894 ],
1895 sha256: "d260a23e0a20850d3b623cbeed54626b47d43fa74e000c5d529dc0a341ab63ee"
1896 },
1897 {
1898 name: "HarnessError body",
1899 lines: [
1900 128,
1901 134
1902 ],
1903 sha256: "30ee24ef29e412b1ab2f0ca89ab600bb0260022d1479d43ca2ad21173b774ccf"
1904 }
1905 ],
1906 license_sha256: "ebb4f09972aee8608be255debaf78451a68e95c290f55c240dec2ecfa16ea6be",
1907 license_text_sha256: "fe195482bb2bddf34ebced7531d6afb11c33fa42f248472736ad9fa9b9eb503b",
1908 excerpted: true
1909 },
1910 {
1911 package: "@deepseek-ai/dsh-session",
1912 version: "0.2.2-rc.1",
1913 license: "MIT",
1914 tarball: "https://registry.npmjs.org/@deepseek-ai/dsh-session/-/dsh-session-0.2.2-rc.1.tgz",
1915 integrity: "sha512-e0zx9HFNn8EyqrymGQS85SjKOyr61//ChTgIVDlCBSZvBB723fuXyi9LiHIIuPTlkgmWJl3gm5J51ebEXew7PQ==",
1916 tarball_sha256: "b8b1b4a7b9c8efbdbe4c134ed3b18cddf11842b62ad7675c21c05b3afef1cfb5",
1917 source_file: "lib/index.js",
1918 source_sha256: "6fad466aa1f7aa64bfa038681ead5721f66c88e9891e25d357d2b8edbccd5494",
1919 excerpts: [
1920 {
1921 name: "SessionId",
1922 lines: [
1923 13,
1924 15
1925 ],
1926 sha256: "68a5778f0586d4e1c219ce6ae3cec3120a57446bbb91f371b4ba208533f48996"
1927 }
1928 ],
1929 license_sha256: "ebb4f09972aee8608be255debaf78451a68e95c290f55c240dec2ecfa16ea6be",
1930 license_text_sha256: "fe195482bb2bddf34ebced7531d6afb11c33fa42f248472736ad9fa9b9eb503b",
1931 excerpted: true
1932 },
1933 {
1934 package: "@deepseek-ai/dsh-system-prompt",
1935 version: "0.2.2-rc.1",
1936 license: "MIT",
1937 tarball: "https://registry.npmjs.org/@deepseek-ai/dsh-system-prompt/-/dsh-system-prompt-0.2.2-rc.1.tgz",
1938 integrity: "sha512-1p9imdrenPnJTkLb6Coq+ELBDjngblM/YGP1Pa/xf1oisjLHcCoK2n9kkOUTIfgvoFtqWfxZJNZeKef71ZmlrA==",
1939 tarball_sha256: "5ecb3f2ff2f0c037287c22c1ef917f1ce5cdd4c8055d51da6646ed5a39fe02a9",
1940 source_file: "lib/index.js",
1941 source_sha256: "18b692b03bbb717589085f63b126cbcf22963763c5a0565bb3a7a5d254e8e4a7",
1942 excerpts: [
1943 {
1944 name: "PERSONA_PREFIX_SECTION",
1945 lines: [
1946 61,
1947 61
1948 ],
1949 sha256: "11338254c278626eea6887b9cb5dc94d16f2ab4dae4bd7e555ea608c4b15648f"
1950 }
1951 ],
1952 license_sha256: "ebb4f09972aee8608be255debaf78451a68e95c290f55c240dec2ecfa16ea6be",
1953 license_text_sha256: "fe195482bb2bddf34ebced7531d6afb11c33fa42f248472736ad9fa9b9eb503b",
1954 excerpted: true
1955 },
1956 {
1957 package: "@deepseek-ai/dsh-util-values",
1958 version: "0.2.2-rc.1",
1959 license: "MIT",
1960 tarball: "https://registry.npmjs.org/@deepseek-ai/dsh-util-values/-/dsh-util-values-0.2.2-rc.1.tgz",
1961 integrity: "sha512-UN4B/Fa9zAunYN3UuXDQ3QknxF/lMKNwTu2WxXKKEC+Ejz745po7I/JmsVFVa7+socfuwwTmVrfSsddRVU+lew==",
1962 tarball_sha256: "e5de9a3c2600c70d72dba702cd0dfc8097264b7b6a7f393f4cfa799c81ecf759",
1963 source_file: "lib/index.js",
1964 source_sha256: "8b4ffdf40126d48bd22017b4671f7e90612d01833fc865f7a0b60d3de4183e8b",
1965 excerpts: [
1966 {
1967 name: "deepFreeze",
1968 lines: [
1969 809,
1970 845
1971 ],
1972 sha256: "66ee7f28877afa912496ba944a581ac74e7b87390e6a47c4c640d8f477bdc6e2"
1973 }
1974 ],
1975 license_sha256: "ebb4f09972aee8608be255debaf78451a68e95c290f55c240dec2ecfa16ea6be",
1976 license_text_sha256: "fe195482bb2bddf34ebced7531d6afb11c33fa42f248472736ad9fa9b9eb503b",
1977 excerpted: false
1978 },
1979 {
1980 package: "@deepseek-ai/dsh-user-questions",
1981 version: "0.2.2-rc.1",
1982 license: "MIT",
1983 tarball: "https://registry.npmjs.org/@deepseek-ai/dsh-user-questions/-/dsh-user-questions-0.2.2-rc.1.tgz",
1984 integrity: "sha512-COY40boWZ7XEszSvMGZ4CY5ze5ujCdA+Trtqx5C6ioqWzH9e8YbkY7AxyCOadxVO++5zAsqvsAfq65cZUPIMGA==",
1985 tarball_sha256: "e7c1c38234fea9c0634ec95272bd1005c48ce890d2b935c8442b4ae7fee1b51e",
1986 source_file: "lib/index.js",
1987 source_sha256: "69fee77aa57cc43de583d53a4877394c4cf3b5d58b8d7579fd8095c0a015bfbd",
1988 excerpts: [
1989 {
1990 name: "UserQuestionError",
1991 lines: [
1992 430,
1993 435
1994 ],
1995 sha256: "5d49a4ecdf40039b26824f3575a79820b48ed011f90641870f44fe5a41bf5ced"
1996 }
1997 ],
1998 license_sha256: "ebb4f09972aee8608be255debaf78451a68e95c290f55c240dec2ecfa16ea6be",
1999 license_text_sha256: "fe195482bb2bddf34ebced7531d6afb11c33fa42f248472736ad9fa9b9eb503b",
2000 excerpted: true
2001 }
2002 ],
2003 reuse: {
2004 package: "@deepseek-ai/dsh-util-values",
2005 version: "0.2.2-rc.1",
2006 file: "lib/index.js",
2007 symbol: "deepFreeze",
2008 lines: [
2009 809,
2010 845
2011 ],
2012 sha256: "66ee7f28877afa912496ba944a581ac74e7b87390e6a47c4c640d8f477bdc6e2"
2013 },
2014 constructor_names: [
2015 "HarnessError",
2016 "UserQuestionError"
2017 ]
2018 },
2019 tool_caller_projection: "readonly-id-session-header-cwd",
2020 session_methods: {
2021 flush: "invocation-bound-acknowledged-checkpoint-with-host-redaction-policy"
2022 },
2023 user_question_methods: {
2024 ask: "invocation-bound-root-agent-typed-answers-no-wait"
2025 },
2026 subagent_methods: {
2027 getProvider: "spawn-only-independent-context",
2028 startActivation: "invocation-bound-caller-or-parent-delivery-text-prompt-model-persona-deny",
2029 result: "text-output-typed-stop-reason",
2030 dispose: "exact-activation"
2031 },
2032 agents_methods: {},
2033 system_prompt_methods: {
2034 section: "child-persona-slot-in-agent-created-only"
2035 },
2036 tool_definition_fields: {
2037 deferLoading: "boolean-presentation-noop-engine-controls-loading"
2038 }
2039 };
2040
2041 // src/dsh/dsh-app-boot-compat.js
2042 function getDshRuntimeVersion() {
2043 return compatibility_default.target_dsh_version;
2044 }
2045
2046 // src/dsh/upstream/creator/plugin-manager/tools.js
2047 var ERROR_STEPS = {
2048 "management-required": "This entry belongs to plugin management itself and cannot be changed.",
2049 "unaddressable": "This entry has no unique profile patch target; tell the user to edit the profile patch file directly.",
2050 "unknown-plugin": "Call list_plugins and retry with an exact entryId.",
2051 "invalid-spec": "Retry with an npm package name, a git URL, a tarball URL, or an absolute local directory.",
2052 "already-installed": "The package is already installed; to install another version, call remove_bundle first, then install_bundle again.",
2053 "ambiguous-install": "The dependency change named no single package; call list_bundles to see what was installed.",
2054 "not-bundle": "The package declares no dsh.bundle and cannot be managed as a plugin; install a DSH plugin bundle instead.",
2055 "not-removable": "Call list_bundles; only bundles marked removable can be removed.",
2056 "stop-profile": "This profile runs without HMR; tell the user to stop DSH and run `dsh plugin --profile <profile> remove <bundle>`.",
2057 "bundle-in-use": "Call list_plugins, disable the entries from other layers that still use this bundle, then retry.",
2058 "stale-approval": "Call install_bundle again without approvedBuilds to read the current pendingBuilds.",
2059 "incompatible-version": "Install a version compatible with the running DSH. A version exemption needs the user's explicit acceptance of crash and data-loss risk.",
2060 "unsupported-platform": "This bundle cannot run on the current Host platform; ask the user to use a supported Host.",
2061 "operation-error": "Report the diagnostic to the user; retry only after its cause is addressed."
2062 };
2063 var FAILURE_STEPS = {
2064 "pnpm-missing": "pnpm is not available to DSH; tell the user to install pnpm.",
2065 "timeout": "Retry, or retry with another registry.",
2066 "not-found": "Check the package name and version with the user, then retry.",
2067 "no-matching-version": "Retry with a published version.",
2068 "network": "Retry later or pass another registry.",
2069 "disk-full": "Tell the user to free disk space, then retry.",
2070 "permission": "Tell the user DSH cannot write the profile directory; retry after they fix its permissions.",
2071 "build-blocked": "Ask the user whether to allow the install scripts of the packages in pendingBuilds; if they approve, retry with approvedBuilds."
2072 };
2073 var RESTART_STEPS = {
2074 "no-hmr": "this profile applies changes only at startup",
2075 "package-moved": "an installed package now resolves to another directory, or the change replaces a package the DSH installation provides; remove a package before installing it from another location",
2076 "host-module": "the change reaches modules DSH itself loaded",
2077 "unmanaged-plugin": "the change reaches a plugin running outside the plugin list",
2078 "module-comparison": "DSH could not compare loaded plugins with their files"
2079 };
2080 function withNextStep(result) {
2081 switch (result.application) {
2082 case "applied":
2083 return result;
2084 case "cancelled":
2085 return { ...result, nextStep: "The installation was cancelled and its files restored; nothing changed." };
2086 case "overridden":
2087 return { ...result, nextStep: "Saved, but a higher-priority layer such as the agent preset overrides it; tell the user it is not in effect." };
2088 case "restart-required": {
2089 const reason = result.restartReason === void 0 ? "" : `: ${RESTART_STEPS[result.restartReason]}`;
2090 return { ...result, nextStep: `Tell the user to restart DSH to apply this change${reason}.` };
2091 }
2092 case "failed": {
2093 const code = result.error?.code ?? "operation-error";
2094 const kind = code === "operation-error" ? result.packageResult?.kind : void 0;
2095 return { ...result, nextStep: (kind === void 0 ? void 0 : FAILURE_STEPS[kind]) ?? ERROR_STEPS[code] };
2096 }
2097 /* v8 ignore next -- ChangeResult.application is a closed union */
2098 default:
2099 return assertNever(result.application);
2100 }
2101 }
2102 function apply(ctx) {
2103 ctx.tools.register(defineTool({
2104 name: "plugin_manager",
2105 description: "List plugins or bundles in the current profile, enable or disable them, install a bundle, or remove an installed bundle. Every action requires danger-full-access permission or approval for this call. Approval does not change the session permission mode. Changes affect every session in this profile. List first to obtain exact identifiers. Package installation can execute allowed build scripts. Live profiles apply changes immediately, including upgrades of installed packages; a change result that is not applied carries nextStep, which says what to do or tell the user. Unmet DSH version requirements (engines.dsh, else DSH peer dependencies) block installation and activation. Version exemptions risk crashes and data loss: warn the user and obtain explicit permission for the exact plugin and runtime versions before granting one.",
2106 parameters: {
2107 action: { type: "string", required: true, enum: ["list_plugins", "list_bundles", "set_plugin", "set_bundle", "install_bundle", "remove_bundle", "list_version_exemptions", "set_version_exemption"], description: "Management operation." },
2108 target: { type: "string", description: "Plugin entry id, bundle package name, or installation spec, according to action. For an Official catalog entry, pass list_bundles installTarget.spec to install_bundle." },
2109 enabled: { type: "boolean", description: "Required for set operations; defaults to true for installation. For set_version_exemption, true grants and false revokes." },
2110 runtimeVersion: { type: "string", description: "For set_version_exemption: exact DSH version from list_version_exemptions. Target must be the manifest package-name@version, not an alias or version range." },
2111 acceptRisk: { type: "boolean", description: "For granting an exemption: true only after warning the user about possible crashes and data loss and receiving explicit permission for this exact plugin/runtime pair. General installation permission is not enough." },
2112 approvedBuilds: { type: "array", items: { type: "string" }, description: "For install_bundle: pass names from pendingBuilds only after the user explicitly approves running their install scripts in the conversation. This grants persistent permission for this profile." },
2113 registry: { type: "string", description: "For install_bundle: the npm registry URL asked first, when the user names one; otherwise the configured registry is asked, and its configured fallbacks while a registry is unreachable." },
2114 offset: { type: "number", description: "Zero-based list offset; defaults to 0." },
2115 limit: { type: "number", description: "List page size, from 1 to 100; defaults to 25." }
2116 },
2117 output: {
2118 schema: { type: "string" },
2119 render: (_args, value) => [{ type: "text", text: value }]
2120 },
2121 async execute(args, exec) {
2122 const policy = ctx.sandboxPolicy.resolve(exec.agent === void 0 ? {} : { session: exec.agent.session });
2123 await approveEscalation({
2124 requestedMode: "danger-full-access",
2125 effectiveMode: policy.mode,
2126 subject: "plugin management operation",
2127 justification: `plugin_manager ${JSON.stringify(args)}. Profile changes persist across sessions; installed Host code runs outside the workspace sandbox.`
2128 }, {
2129 approver: ctx.get("approval"),
2130 agent: exec.agent,
2131 callId: exec.callId,
2132 toolName: "plugin_manager",
2133 signal: exec.signal
2134 });
2135 exec.signal.throwIfAborted();
2136 const manager = ctx.pluginManager;
2137 switch (args.action) {
2138 case "list_version_exemptions":
2139 return JSON.stringify({ runtimeVersion: getDshRuntimeVersion(), ...manager.listVersionExemptions() });
2140 case "set_version_exemption":
2141 if (args.target === void 0 || args.runtimeVersion === void 0 || args.enabled === void 0) {
2142 throw new Error("target package-name@version, runtimeVersion, and enabled are required");
2143 }
2144 return JSON.stringify(withNextStep(await manager.setVersionExemption(args.target, args.runtimeVersion, args.enabled, args.acceptRisk)));
2145 case "list_plugins":
2146 case "list_bundles": {
2147 const offset = args.offset ?? 0;
2148 const limit = args.limit ?? 25;
2149 if (!Number.isInteger(offset) || offset < 0 || !Number.isInteger(limit) || limit < 1 || limit > 100) {
2150 throw new Error("offset must be a non-negative integer and limit must be an integer from 1 to 100");
2151 }
2152 const rows = args.action === "list_plugins" ? await manager.listPlugins() : await manager.listBundles();
2153 const entries = rows.slice(offset, offset + limit).map(({ meta: _meta, ...row }) => "rows" in row ? (({ updatable: _updatable, listedByDefault: _listedByDefault, ...bundle }) => ({
2154 ...bundle,
2155 rows: bundle.rows.map(({ meta: _rowMeta, ...declared }) => declared)
2156 }))(row) : row);
2157 return JSON.stringify({
2158 entries,
2159 total: rows.length,
2160 nextOffset: offset + entries.length < rows.length ? offset + entries.length : null
2161 });
2162 }
2163 case "set_plugin":
2164 case "set_bundle": {
2165 if (args.target === void 0 || args.enabled === void 0)
2166 throw new Error("target and enabled are required");
2167 return JSON.stringify(withNextStep(await (args.action === "set_plugin" ? manager.setPluginEnabled(args.target, args.enabled) : manager.setBundleEnabled(args.target, args.enabled))));
2168 }
2169 case "install_bundle":
2170 if (args.target === void 0)
2171 throw new Error("target package spec is required");
2172 return JSON.stringify(withNextStep(await manager.installBundle(args.target, {
2173 ...args.enabled === void 0 ? {} : { enabled: args.enabled },
2174 ...args.approvedBuilds === void 0 ? {} : { approvedBuilds: args.approvedBuilds },
2175 ...args.registry === void 0 ? {} : { registry: args.registry }
2176 })));
2177 case "remove_bundle":
2178 if (args.target === void 0)
2179 throw new Error("target bundle name is required");
2180 return JSON.stringify(withNextStep(await manager.removeBundle(args.target)));
2181 /* v8 ignore next -- tool JSON validation rejects actions outside the declared enum */
2182 default:
2183 return assertNever(args.action);
2184 }
2185 },
2186 presentCall: (args) => ({ card: "generic", title: "Manage profile plugins", kind: args.action.startsWith("list_") ? "read" : "other", rawInput: args })
2187 }));
2188 }
2189
2190 // src/dsh/upstream/creator/tool-cordis/index.js
2191 var tool_cordis_exports = {};
2192 __export(tool_cordis_exports, {
2193 apply: () => apply2,
2194 inject: () => inject,
2195 name: () => name
2196 });
2197 function presentInspectListCall() {
2198 return {
2199 card: "generic",
2200 kind: "read",
2201 title: "List Cordis Inspect Providers"
2202 };
2203 }
2204 function presentInspectQueryCall(args) {
2205 return {
2206 card: "generic",
2207 kind: "read",
2208 title: `Query Cordis ${args.platform} ${args.provider}.${args.method}`
2209 };
2210 }
2211 var name = "tool-cordis";
2212 var inject = ["tools", "cordisInspect"];
2213 function requireAgent(exec) {
2214 if (exec.agent === void 0) throw new Error("Cordis inspection requires an Agent-backed session");
2215 return exec.agent;
2216 }
2217 function apply2(ctx) {
2218 ctx.tools.register(defineTool({
2219 name: "cordis_inspect_list",
2220 description: "List every Cordis Inspect Provider currently known to the Host, including local Host Providers and the latest manifests synchronized from the Client. Each entry includes its platform, purpose, read-only methods, and input/output schemas. Call this Tool before writing or configuring a plugin, then select the provider and method for cordis_inspect_query from its result. Do not guess names or treat an Inspect method as a business Service that Plugin code can call.",
2221 parameters: {},
2222 output: {
2223 schema: { type: "json" },
2224 render: (_args, value) => [{
2225 type: "text",
2226 text: JSON.stringify(value, null, 2)
2227 }]
2228 },
2229 execute(_args, _exec) {
2230 return Promise.resolve({ providers: ctx.cordisInspect.list() });
2231 },
2232 presentCall: presentInspectListCall
2233 }));
2234 ctx.tools.register(defineTool({
2235 name: "cordis_inspect_query",
2236 description: "Run a read-only query declared by an Inspect Provider. platform, provider, and method must come from cordis_inspect_list, and input must satisfy that method's schema. Use this Tool before writing plugin code to read exact Service methods, Event modes, plugin Config schemas, Tool schemas, theme tokens, or live Slot trees and props. Host queries run locally. A Client query waits for the first valid page response within the configured timeout; otherwise it reports a Client failure or asks you to reconnect and retry. This Tool cannot invoke business Service methods or modify the runtime.",
2237 parameters: {
2238 platform: {
2239 type: "string",
2240 required: true,
2241 enum: ["host", "client"],
2242 description: "Runtime platform that owns the Provider."
2243 },
2244 provider: {
2245 type: "string",
2246 required: true,
2247 description: "Exact Provider ID returned by cordis_inspect_list."
2248 },
2249 method: {
2250 type: "string",
2251 required: true,
2252 description: "Exact method name declared by the Provider manifest."
2253 },
2254 input: {
2255 type: "json",
2256 description: "Optional query input; it must satisfy the method input schema."
2257 }
2258 },
2259 output: {
2260 schema: { type: "json" },
2261 render: (_args, value) => [{
2262 type: "text",
2263 text: JSON.stringify(value, null, 2)
2264 }]
2265 },
2266 async execute(args, exec) {
2267 const data = await ctx.cordisInspect.query(args.platform, args.provider, args.method, args.input, requireAgent(exec), exec.signal);
2268 return {
2269 platform: args.platform,
2270 provider: args.provider,
2271 method: args.method,
2272 data
2273 };
2274 },
2275 presentCall: presentInspectQueryCall
2276 }));
2277 }
2278
2279 // src/json.ts
2280 function isJson(value, depth = 0) {
2281 if (depth > 64) return false;
2282 if (value === null) return true;
2283 switch (typeof value) {
2284 case "boolean":
2285 case "string":
2286 return true;
2287 case "number":
2288 return Number.isFinite(value);
2289 case "object": {
2290 const array = Array.isArray(value);
2291 if (!array && Object.getPrototypeOf(value) !== Object.prototype && Object.getPrototypeOf(value) !== null) return false;
2292 const keys = Reflect.ownKeys(value);
2293 if (array && keys.length !== value.length + 1) return false;
2294 for (const key of keys) {
2295 if (array && key === "length") continue;
2296 if (typeof key !== "string") return false;
2297 if (array && (!/^(0|[1-9]\d*)$/u.test(key) || Number(key) >= value.length)) return false;
2298 const descriptor = Object.getOwnPropertyDescriptor(value, key);
2299 if (!descriptor.enumerable || !("value" in descriptor) || !isJson(descriptor.value, depth + 1)) return false;
2300 }
2301 return true;
2302 }
2303 default:
2304 return false;
2305 }
2306 }
2307
2308 // src/dsh/inspect-catalog.json
2309 var inspect_catalog_default = {
2310 version: 1,
2311 targetDshVersion: "0.2.2-rc.1",
2312 host: {
2313 services: [
2314 {
2315 key: "tools",
2316 group: "dsh",
2317 summary: "The tool registry: a plugin adds model-callable tools. The Engine owns calling, approval and results.",
2318 availability: "always",
2319 availabilityText: "Available to every plugin that injects it.",
2320 methods: [
2321 {
2322 name: "register",
2323 signature: "register(definition: ToolDefinition): () => void",
2324 summary: "Register one tool built with defineTool from @deepseek-ai/dsh-tools. The definition must stay inside the supported JSON Schema subset (type, oneOf, properties, required, additionalProperties, items, enum, const). A second argument is refused. Returns an idempotent disposer."
2325 },
2326 {
2327 name: "get",
2328 signature: "get(name: string, agent: Agent): { name: string } | undefined",
2329 summary: "Whether the calling agent has a tool by this name. Answers only inside a live tool call, for that call's own agent."
2330 },
2331 {
2332 name: "guard",
2333 signature: "guard(fn: (exec: ToolExec) => string | { kind?: 'deny', reason: string } | undefined): () => void",
2334 summary: "Register a deny-only tool guard through the tools/pre-execute admission path. Can deny or abstain, never auto-approve."
2335 }
2336 ]
2337 },
2338 {
2339 key: "commands",
2340 group: "dsh",
2341 summary: "Slash commands a person types. A handler runs only when the person types the command.",
2342 availability: "always",
2343 availabilityText: "Available to every plugin that injects it.",
2344 methods: [
2345 {
2346 name: "register",
2347 signature: "register(definition: { name: string, description: string, argumentHint?: string, handler(call: { args: string, signal: AbortSignal }): CommandResult }): () => void",
2348 summary: "Register one slash command. Names start with a lower case letter, then lower case letters, digits, _ and -, at most 64 characters; at most 64 commands per plugin. A name that clashes with a built-in command gets the alias plugin-<plugin-slug>-<command>, and is refused if that alias is invalid or also taken. A name another plugin already registered is refused, so pick a plugin-specific name. Returns an idempotent disposer."
2349 }
2350 ]
2351 },
2352 {
2353 key: "storage",
2354 group: "dsh",
2355 summary: "Owner-local JSON persistence under the data folder the Engine assigned. It holds no session history and no secrets.",
2356 availability: "always",
2357 availabilityText: "Available to every plugin that injects it.",
2358 methods: [
2359 {
2360 name: "get",
2361 signature: "get(key: string): Promise<Json | undefined>",
2362 summary: "Read one stored value."
2363 },
2364 {
2365 name: "set",
2366 signature: "set(key: string, value: Json): Promise<void>",
2367 summary: "Store one JSON value, within the bounded key, value and owner limits."
2368 },
2369 {
2370 name: "delete",
2371 signature: "delete(key: string): Promise<void>",
2372 summary: "Remove one stored value."
2373 }
2374 ]
2375 },
2376 {
2377 key: "skills",
2378 group: "dsh",
2379 summary: "Skill roots: reviewed folders of skills added to the Engine's skill catalog.",
2380 availability: "always",
2381 availabilityText: "Available to every plugin that injects it.",
2382 methods: [
2383 {
2384 name: "registerRoot",
2385 signature: "registerRoot(definition: { path: string }): () => void",
2386 summary: "Add a bundle-relative folder of SKILL.md packages. At most 8 roots per plugin. Absolute paths, links, empty components, . and .. are refused."
2387 }
2388 ]
2389 },
2390 {
2391 key: "sessions",
2392 group: "dsh",
2393 summary: "The session of the calling tool invocation.",
2394 availability: "tool-invocation",
2395 availabilityText: "Answers only inside a live tool call of the plugin.",
2396 methods: [
2397 {
2398 name: "flush",
2399 signature: "flush(session: Session): Promise<boolean>",
2400 summary: "Ask the Engine to persist the committed prefix of the exact session of this tool call. Nothing else on sessions is available."
2401 }
2402 ]
2403 },
2404 {
2405 key: "userQuestions",
2406 group: "dsh",
2407 summary: "Questions put to the person through the Engine's own question card.",
2408 availability: "tool-invocation",
2409 availabilityText: "Answers only inside a live tool call of the plugin.",
2410 methods: [
2411 {
2412 name: "ask",
2413 signature: "ask(request: { agent: Agent, questions: Question[], signal?: AbortSignal }): Promise<Answers>",
2414 summary: "Ask the person typed questions during a live root tool call. Timed or continued questions (wait) are not supported."
2415 }
2416 ]
2417 },
2418 {
2419 key: "subagents",
2420 group: "dsh",
2421 summary: "One independent child agent a root tool call may start.",
2422 availability: "tool-invocation",
2423 availabilityText: "Answers only inside a live tool call of the plugin.",
2424 methods: [
2425 {
2426 name: "getProvider",
2427 signature: "getProvider(id: 'spawn'): Provider",
2428 summary: "Describe the one provider: a fresh child with no inherited conversation."
2429 },
2430 {
2431 name: "startActivation",
2432 signature: "startActivation(options: { provider: 'spawn', childId: string, request: { parent: Agent, prompt: TextBlock[], agentOptions?: { model?: string } }, signal?: AbortSignal, delivery?: 'caller' | 'parent' }): Promise<{ childId: string, messageId: string, result: Promise<ChildResult>, dispose(): Promise<void> }>",
2433 summary: "Start the child through the Engine's approval gate. Resolves to the activation handle { childId, messageId, result, dispose }. Prompts are text only; only the model option is accepted. Needs the live calling agent as parent and is not available inside a child."
2434 },
2435 {
2436 name: "result",
2437 signature: "activation.result: Promise<{ stopReason: string, output: { type: 'text', text: string }[], diagnostic?: string }>",
2438 summary: "A getter, not a method: read the property, do not call it. Resolves when the child finishes, with its stop reason and its text output blocks; diagnostic notes dropped non-text blocks."
2439 },
2440 {
2441 name: "dispose",
2442 signature: "activation.dispose(): Promise<void>",
2443 summary: "Stop that exact child and its own descendants."
2444 }
2445 ]
2446 },
2447 {
2448 key: "agents",
2449 group: "dsh",
2450 summary: "Reserved. The host offers no methods on agents.",
2451 availability: "none",
2452 availabilityText: "No methods.",
2453 methods: []
2454 },
2455 {
2456 key: "systemPrompt",
2457 group: "dsh",
2458 summary: "The child agent's persona slot, reachable only inside an agent/created listener.",
2459 availability: "child-agent-hook",
2460 availabilityText: "Answers only inside an agent/created listener, on the child agent.",
2461 methods: [
2462 {
2463 name: "section",
2464 signature: "agent.ctx.systemPrompt.section({ name: 'deployment:persona-prefix', order: agent.ctx.systemPrompt.getSectionOrder('DEPLOYMENT_PERSONA_PREFIX'), text: string }): () => void",
2465 summary: "Set the child's persona text, at most 32 KiB, once. name must be the string deployment:persona-prefix (the PERSONA_PREFIX_SECTION value) and order must be what getSectionOrder('DEPLOYMENT_PERSONA_PREFIX') returns, which is 0. Anything else is refused. Called anywhere else it fails. The Engine's own system prompt cannot be replaced."
2466 }
2467 ]
2468 },
2469 {
2470 key: "llm",
2471 group: "dsh",
2472 summary: "Host-mediated model catalog lookup, completions, and streaming.",
2473 availability: "review-grant",
2474 availabilityText: "Served by the Engine only when the plugin's review granted it.",
2475 methods: [
2476 {
2477 name: "catalog",
2478 signature: "catalog(options?: { provider?: string }): Promise<ModelCatalog>",
2479 summary: "List available providers and models."
2480 },
2481 {
2482 name: "complete",
2483 signature: "complete(request: LlmRequest): Promise<LlmResponse>",
2484 summary: "Run a single non-streaming completion through Core."
2485 },
2486 {
2487 name: "listModels",
2488 signature: "listModels(provider?: string): Promise<ModelSummary[]>",
2489 summary: "List model entries with context and modality metadata."
2490 },
2491 {
2492 name: "resolveModelInfo",
2493 signature: "resolveModelInfo(modelId: string): Promise<ModelSummary | null>",
2494 summary: "Look up metadata for one model identifier."
2495 },
2496 {
2497 name: "stream",
2498 signature: "stream(request: LlmRequest): AsyncIterable<LlmChunk>",
2499 summary: "Stream completion chunks through Core."
2500 }
2501 ]
2502 },
2503 {
2504 key: "credentials",
2505 group: "dsh",
2506 summary: "Reviewed credential resolution and host-guarded HTTP fetch.",
2507 availability: "review-grant",
2508 availabilityText: "Served by the Engine only when the plugin's review granted it.",
2509 methods: [
2510 {
2511 name: "resolve",
2512 signature: "resolve(key: string, options?: Record<string, unknown>): Promise<CredentialValue>",
2513 summary: "Resolve an approved credential key."
2514 },
2515 {
2516 name: "describe",
2517 signature: "describe(key: string): Promise<CredentialMeta>",
2518 summary: "Inspect metadata for a credential key."
2519 },
2520 {
2521 name: "set",
2522 signature: "set(key: string, secret: string, options?: Record<string, unknown>): Promise<void>",
2523 summary: "Store a secret in Codewhale credential storage."
2524 },
2525 {
2526 name: "fetch",
2527 signature: "fetch(input: string, init?: FetchInit): Promise<FetchResponse>",
2528 summary: "Perform a policy-checked outbound HTTP request."
2529 }
2530 ]
2531 },
2532 {
2533 key: "settings",
2534 group: "dsh",
2535 summary: "Reviewed read/write access to declared Codewhale plugin settings.",
2536 availability: "review-grant",
2537 availabilityText: "Served by the Engine only when the plugin's review granted it.",
2538 methods: [
2539 {
2540 name: "describe",
2541 signature: "describe(keys?: string[]): Promise<Record<string, unknown>>",
2542 summary: "Read reviewed setting values and schemas."
2543 },
2544 {
2545 name: "update",
2546 signature: "update(patch: Record<string, unknown>, options?: Record<string, unknown>): Promise<void>",
2547 summary: "Merge partial updates into allowed settings."
2548 },
2549 {
2550 name: "replace",
2551 signature: "replace(patch: Record<string, unknown>, options?: Record<string, unknown>): Promise<void>",
2552 summary: "Replace reviewed setting keys atomically."
2553 },
2554 {
2555 name: "mutate",
2556 signature: "mutate(fn: (current: Record<string, unknown>) => Record<string, unknown>): Promise<void>",
2557 summary: "Apply a synchronous transform to reviewed settings."
2558 }
2559 ]
2560 },
2561 {
2562 key: "pluginManager",
2563 group: "dsh",
2564 summary: "Reviewed plugin installation and removal requests through Core.",
2565 availability: "review-grant",
2566 availabilityText: "Served by the Engine only when the plugin's review granted it.",
2567 methods: [
2568 {
2569 name: "installBundle",
2570 signature: "installBundle(packageName: string, options?: Record<string, unknown>): Promise<unknown>",
2571 summary: "Request Core to preview or install a plugin bundle."
2572 },
2573 {
2574 name: "removeBundle",
2575 signature: "removeBundle(packageName: string): Promise<void>",
2576 summary: "Request Core to remove an installed plugin bundle."
2577 },
2578 {
2579 name: "cancelInstall",
2580 signature: "cancelInstall(): Promise<void>",
2581 summary: "Cancel an active plugin installation request."
2582 }
2583 ]
2584 },
2585 {
2586 key: "deepseekAccount",
2587 group: "dsh",
2588 summary: "DeepSeek account balance queries through the authenticated provider.",
2589 availability: "review-grant",
2590 availabilityText: "Served by the Engine only when the plugin's review granted it.",
2591 methods: [
2592 {
2593 name: "getBalance",
2594 signature: "getBalance(options?: Record<string, unknown>): Promise<AccountBalance>",
2595 summary: "Fetch the active DeepSeek account balance."
2596 }
2597 ]
2598 },
2599 {
2600 key: "terminal",
2601 group: "dsh",
2602 summary: "Reviewed interactive terminal sessions inside the workspace.",
2603 availability: "review-grant",
2604 availabilityText: "Served by the Engine only when the plugin's review granted it.",
2605 methods: [
2606 {
2607 name: "list",
2608 signature: "list(): Promise<TerminalSession[]>",
2609 summary: "List active terminal sessions for this owner."
2610 },
2611 {
2612 name: "run",
2613 signature: "run(options?: { argv?: string[], cwd?: string }): Promise<TerminalSession>",
2614 summary: "Start a terminal session in the workspace."
2615 },
2616 {
2617 name: "send",
2618 signature: "send(id: string, data: string): Promise<void>",
2619 summary: "Write input to a running terminal session."
2620 },
2621 {
2622 name: "wait",
2623 signature: "wait(id: string, options?: { timeoutMs?: number }): Promise<TerminalExit>",
2624 summary: "Wait for output or completion from a terminal session."
2625 },
2626 {
2627 name: "cancel",
2628 signature: "cancel(id: string): Promise<void>",
2629 summary: "Terminate a running terminal session."
2630 },
2631 {
2632 name: "reset",
2633 signature: "reset(id: string): Promise<void>",
2634 summary: "Reset a terminal session buffer."
2635 }
2636 ]
2637 },
2638 {
2639 key: "attachments",
2640 group: "dsh",
2641 summary: "Conversation image validation, storage, and bounded read/resize through the Engine.",
2642 availability: "review-grant",
2643 availabilityText: "Served by the Engine only when the plugin's review granted it.",
2644 methods: [
2645 {
2646 name: "validateImage",
2647 signature: "validateImage(input: ImageBytesInput, signal?: AbortSignal): Promise<ValidateImageResult>",
2648 summary: "Validate an image payload against Codewhale image limits."
2649 },
2650 {
2651 name: "saveImage",
2652 signature: "saveImage(input: ImageBytesInput, signal?: AbortSignal): Promise<StoredImageAttachmentRef>",
2653 summary: "Store a validated conversation image attachment for the active tool result."
2654 },
2655 {
2656 name: "readImage",
2657 signature: "readImage(ref: ImageAttachmentRef, signal?: AbortSignal): Promise<ReadImageResult>",
2658 summary: "Read a stored conversation image by attachment reference."
2659 },
2660 {
2661 name: "readImageRequest",
2662 signature: "readImageRequest(ref: ImageAttachmentRef, target?: ReadImageRequestTarget, signal?: AbortSignal): Promise<ReadImageRequestResult>",
2663 summary: "Read a resized/fitted variant of a stored conversation image."
2664 }
2665 ]
2666 },
2667 {
2668 key: "agentPresets",
2669 group: "dsh",
2670 summary: "Reviewed read-only agent preset catalog scoped to the owning plugin.",
2671 availability: "always",
2672 availabilityText: "Available to every plugin that injects it.",
2673 methods: [
2674 {
2675 name: "list",
2676 signature: "list(): Promise<AgentPreset[]>",
2677 summary: "List reviewed presets visible to this owner."
2678 },
2679 {
2680 name: "get",
2681 signature: "get(id: string): Promise<AgentPreset | undefined>",
2682 summary: "Look up one reviewed preset by id."
2683 },
2684 {
2685 name: "register",
2686 signature: "register(preset: AgentPreset): () => void",
2687 summary: "Register an owner-scoped preset metadata entry."
2688 }
2689 ]
2690 },
2691 {
2692 key: "agentDefaultModel",
2693 group: "dsh",
2694 summary: "Read-only view of the active invocation default model selection.",
2695 availability: "tool-invocation",
2696 availabilityText: "Answers only inside a live tool call of the plugin.",
2697 methods: [
2698 {
2699 name: "currentSelection",
2700 signature: "currentSelection(): { provider: string, model: string } | undefined",
2701 summary: "Return the read-only default provider/model for the live invocation."
2702 }
2703 ]
2704 },
2705 {
2706 key: "sessionProjections",
2707 group: "dsh",
2708 summary: "Read-only projection of active session messages and events.",
2709 availability: "tool-invocation",
2710 availabilityText: "Answers only inside a live tool call of the plugin.",
2711 methods: [
2712 {
2713 name: "get",
2714 signature: "get(sessionId?: string): SessionProjection | undefined",
2715 summary: "Return the read-only projection for the active session."
2716 },
2717 {
2718 name: "list",
2719 signature: "list(): SessionProjection[]",
2720 summary: "List read-only session projections visible to the live invocation."
2721 }
2722 ]
2723 },
2724 {
2725 key: "workspaceRegistry",
2726 group: "dsh",
2727 summary: "Read-only workspace metadata for the active invocation.",
2728 availability: "tool-invocation",
2729 availabilityText: "Answers only inside a live tool call of the plugin.",
2730 methods: [
2731 {
2732 name: "list",
2733 signature: "list(): WorkspaceMeta[]",
2734 summary: "List read-only workspace metadata visible to the live invocation."
2735 },
2736 {
2737 name: "get",
2738 signature: "get(id: string): WorkspaceMeta | undefined",
2739 summary: "Look up read-only workspace metadata by id or path."
2740 },
2741 {
2742 name: "resolveByPath",
2743 signature: "resolveByPath(path: string): WorkspaceMeta | undefined",
2744 summary: "Resolve read-only workspace metadata by filesystem path."
2745 }
2746 ]
2747 },
2748 {
2749 key: "typertGateway",
2750 group: "dsh",
2751 summary: "Owner-scoped Typert service descriptor registry.",
2752 availability: "always",
2753 availabilityText: "Available to every plugin that injects it.",
2754 methods: [
2755 {
2756 name: "register",
2757 signature: "register(name: string, service: unknown, descriptors?: unknown[]): () => void",
2758 summary: "Register an owner-scoped Typert service and its descriptors."
2759 },
2760 {
2761 name: "list",
2762 signature: "list(): string[]",
2763 summary: "List Typert service names registered by this owner."
2764 },
2765 {
2766 name: "get",
2767 signature: "get(name: string): { service: unknown, descriptors: unknown[] } | undefined",
2768 summary: "Look up a registered Typert service by name."
2769 }
2770 ]
2771 },
2772 {
2773 key: "web",
2774 group: "dsh",
2775 summary: "Network-policy-guarded web fetch and owner-scoped search provider registration.",
2776 availability: "review-grant",
2777 availabilityText: "Served by the Engine only when the plugin's review granted it.",
2778 methods: [
2779 {
2780 name: "fetch",
2781 signature: "fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>",
2782 summary: "Perform a policy-checked outbound HTTP request through the Engine network broker."
2783 },
2784 {
2785 name: "registerSearchProvider",
2786 signature: "registerSearchProvider(provider: SearchProvider): () => void",
2787 summary: "Register an owner-scoped web search provider."
2788 }
2789 ]
2790 },
2791 {
2792 key: "webServer",
2793 group: "dsh",
2794 summary: "Sandboxed Engine-brokered in-memory HTTP route registry (no raw sockets).",
2795 availability: "always",
2796 availabilityText: "Available to every plugin that injects it.",
2797 methods: [
2798 {
2799 name: "register",
2800 signature: "register(route: { kind?: 'exact' | 'prefix', path: string, method?: string, methods?: string[], handler: (req, res) => void | Promise<void> }): () => void",
2801 summary: "Register an owner-scoped HTTP route dispatched through Engine plugin_route/dispatch."
2802 },
2803 {
2804 name: "getOrigin",
2805 signature: "getOrigin(): string",
2806 summary: "Return the loopback origin advertised to the plugin."
2807 }
2808 ]
2809 },
2810 {
2811 key: "connection",
2812 group: "dsh",
2813 summary: "Scoped loopback connection status, trust fence, Fetch route registry, and RPC channel registry.",
2814 availability: "always",
2815 availabilityText: "Available to every plugin that injects it.",
2816 methods: [
2817 {
2818 name: "requestRejection",
2819 signature: "requestRejection(req?: { headers?: Record<string, string | string[] | undefined> }): { status: number, message: string } | null",
2820 summary: "Verify loopback Host and non-cross-site Fetch metadata."
2821 },
2822 {
2823 name: "fetch.register",
2824 signature: "fetch.register(route: { path: string, methods?: string[], fetch: (req: Request) => Response | Promise<Response> }): () => void",
2825 summary: "Register an owner-scoped Fetch-style route handler."
2826 },
2827 {
2828 name: "rpc.handle",
2829 signature: "rpc.handle(channel: string, handler: (endpoint: string, payload: unknown) => unknown | Promise<unknown>): () => void",
2830 summary: "Register an owner-scoped JSON RPC channel handler."
2831 }
2832 ]
2833 },
2834 {
2835 key: "sessionTitle",
2836 group: "dsh",
2837 summary: "Owner-scoped in-memory session title store and rename observer.",
2838 availability: "always",
2839 availabilityText: "Available to every plugin that injects it.",
2840 methods: [
2841 {
2842 name: "get",
2843 signature: "get(session: unknown): string | undefined",
2844 summary: "Read a session title stored by this owner."
2845 },
2846 {
2847 name: "rename",
2848 signature: "rename(session: unknown, title: string): string",
2849 summary: "Store a bounded single-line title for a session under this owner."
2850 },
2851 {
2852 name: "register",
2853 signature: "register(listener: (sessionId: string, title: string) => void): () => void",
2854 summary: "Observe session title updates within this owner."
2855 }
2856 ]
2857 },
2858 {
2859 key: "profileContext",
2860 group: "dsh",
2861 summary: "Read-only owner-scoped profile directory metadata.",
2862 availability: "always",
2863 availabilityText: "Available to every plugin that injects it.",
2864 methods: [
2865 {
2866 name: "dir",
2867 signature: "get dir(): string",
2868 summary: "Return the owner's scoped data directory (fails closed when absent)."
2869 },
2870 {
2871 name: "installAnchor",
2872 signature: "get installAnchor(): string",
2873 summary: "Return the owner's scoped install anchor directory."
2874 }
2875 ]
2876 },
2877 {
2878 key: "sessionPersistence",
2879 group: "dsh",
2880 summary: "Read-only session log lookup surface; Core owns durable session logs and refuses plugin mutations.",
2881 availability: "always",
2882 availabilityText: "Available to every plugin that injects it.",
2883 methods: [
2884 {
2885 name: "findLog",
2886 signature: "findLog(id?: unknown): Promise<undefined>",
2887 summary: "Resolve undefined; host session logs are not exposed on disk to plugins."
2888 },
2889 {
2890 name: "listLogs",
2891 signature: "listLogs(): Promise<readonly unknown[]>",
2892 summary: "Return an empty frozen list."
2893 },
2894 {
2895 name: "readLog",
2896 signature: "readLog(id?: unknown): Promise<undefined>",
2897 summary: "Resolve undefined; host session logs are private to Core."
2898 },
2899 {
2900 name: "artifactDirectory",
2901 signature: "artifactDirectory(headerOrId?: unknown): undefined",
2902 summary: "Return undefined; host session directories are private to Core."
2903 }
2904 ]
2905 },
2906 {
2907 key: "storageDomain",
2908 group: "dsh",
2909 summary: "Owner-scoped, bounded in-memory structured storage domains isolated per plugin.",
2910 availability: "always",
2911 availabilityText: "Available to every plugin that injects it.",
2912 methods: [
2913 {
2914 name: "open",
2915 signature: "open(spec: { name: string } | string): Promise<ScopedStorageDomainHandle>",
2916 summary: "Open an owner-scoped in-memory storage domain with bounded tables and entries."
2917 },
2918 {
2919 name: "get",
2920 signature: "get(name: string): ScopedStorageDomainHandle | undefined",
2921 summary: "Look up an already-opened domain for this owner."
2922 },
2923 {
2924 name: "list",
2925 signature: "list(): readonly string[]",
2926 summary: "List domains currently opened by this owner."
2927 }
2928 ]
2929 },
2930 {
2931 key: "invariants",
2932 group: "dsh",
2933 summary: "Owner-scoped invariant registration table cleaned up on plugin disposal.",
2934 availability: "always",
2935 availabilityText: "Available to every plugin that injects it.",
2936 methods: [
2937 {
2938 name: "register",
2939 signature: "register(name: string, install?: unknown): () => void",
2940 summary: "Register a named invariant under this owner and return a disposer."
2941 },
2942 {
2943 name: "list",
2944 signature: "list(): readonly string[]",
2945 summary: "List invariant names registered by this owner."
2946 }
2947 ]
2948 },
2949 {
2950 key: "permissionPresets",
2951 group: "dsh",
2952 summary: "Read-only catalog of Codewhale permission posture names; Core owns approval authority.",
2953 availability: "always",
2954 availabilityText: "Available to every plugin that injects it.",
2955 methods: [
2956 {
2957 name: "availability",
2958 signature: "get availability(): 'readonly'",
2959 summary: "Report that permission presets are read-only."
2960 },
2961 {
2962 name: "defaultPreset",
2963 signature: "get defaultPreset(): string",
2964 summary: "Return the default posture name ('ask')."
2965 },
2966 {
2967 name: "names",
2968 signature: "get names(): readonly string[]",
2969 summary: "List Codewhale permission posture names."
2970 },
2971 {
2972 name: "list",
2973 signature: "list(): readonly { name: string, readonly: boolean }[]",
2974 summary: "List read-only permission preset descriptors."
2975 },
2976 {
2977 name: "get",
2978 signature: "get(name: string): { name: string, readonly: boolean } | undefined",
2979 summary: "Look up one permission preset descriptor by name."
2980 }
2981 ]
2982 },
2983 {
2984 key: "logger",
2985 group: "cordis",
2986 summary: "Cordis logging. Every line becomes a host log notification attributed to the plugin.",
2987 availability: "always",
2988 availabilityText: "Available to every plugin that injects it.",
2989 methods: [
2990 {
2991 name: "logger",
2992 signature: "ctx.logger(name?: string): Logger",
2993 summary: "A named logger with debug, info, warn and error. The host reports error and warn as such and everything else as info."
2994 }
2995 ]
2996 },
2997 {
2998 key: "events",
2999 group: "cordis",
3000 summary: "Cordis event dispatch. Query the host Event provider for the events this host fires.",
3001 availability: "always",
3002 availabilityText: "Available to every plugin that injects it.",
3003 methods: [
3004 {
3005 name: "on",
3006 signature: "ctx.on(name: string, listener: Function, options?: boolean | { prepend?: boolean, global?: boolean }): () => boolean",
3007 summary: "Listen to an event. The host refuses five lifecycle events and limits the options of two (see the Event provider)."
3008 },
3009 {
3010 name: "once",
3011 signature: "ctx.once(name: string, listener: Function, options?: boolean | { prepend?: boolean, global?: boolean }): () => boolean",
3012 summary: "Listen to an event once."
3013 },
3014 {
3015 name: "emit",
3016 signature: "ctx.emit(name: string, ...args: any[]): void",
3017 summary: "Dispatch an event to its listeners."
3018 }
3019 ]
3020 },
3021 {
3022 key: "reflect",
3023 group: "cordis",
3024 summary: "Cordis service reflection. A plugin may provide its own services but not the Engine's.",
3025 availability: "always",
3026 availabilityText: "Available to every plugin that injects it.",
3027 methods: [
3028 {
3029 name: "provide",
3030 signature: "ctx.reflect.provide(name: string, value?: any): () => void",
3031 summary: "Provide a service under a name. Names in refusedServices are refused: the Engine owns them."
3032 },
3033 {
3034 name: "get",
3035 signature: "ctx.reflect.get(name: string, strict?: boolean): any",
3036 summary: "Read a provided service."
3037 }
3038 ]
3039 },
3040 {
3041 key: "registry",
3042 group: "cordis",
3043 summary: "Cordis plugin registry.",
3044 availability: "always",
3045 availabilityText: "Available to every plugin that injects it.",
3046 methods: [
3047 {
3048 name: "get",
3049 signature: "ctx.registry.get(plugin: Plugin): Runtime | undefined",
3050 summary: "Look up the runtime record of a plugin."
3051 },
3052 {
3053 name: "resolve",
3054 signature: "ctx.registry.resolve(plugin: Plugin): Function | undefined",
3055 summary: "Resolve a plugin shape to its callback."
3056 }
3057 ]
3058 },
3059 {
3060 key: "prompt",
3061 group: "codewhale",
3062 summary: "Attributed sections of the Engine's runtime prompt. A plugin cannot replace the system prompt.",
3063 availability: "always",
3064 availabilityText: "Available to every plugin that injects it.",
3065 methods: [
3066 {
3067 name: "registerSection",
3068 signature: "registerSection(definition: { id: string, text: string, interpolate?: 'model-cwd' }): () => void",
3069 summary: "Contribute a plain-text section of at most 4 KiB; at most 128 sections per plugin. The id is lower case letters, digits, _ and -, starts with a letter, at most 64 characters. With interpolate set, only {{model}} and {{cwd}} are expanded."
3070 }
3071 ]
3072 },
3073 {
3074 key: "avatars",
3075 group: "codewhale",
3076 summary: "Avatar packs for the terminal.",
3077 availability: "always",
3078 availabilityText: "Available to every plugin that injects it.",
3079 methods: [
3080 {
3081 name: "registerPack",
3082 signature: "registerPack(definition: { path: string }): () => void",
3083 summary: "Register a reviewed bundle-relative avatar pack: a path ending in .json, at most 4 packs per plugin."
3084 }
3085 ]
3086 },
3087 {
3088 key: "mcp",
3089 group: "codewhale",
3090 summary: "Proposals of MCP servers. The Engine owns connection, credentials and tool calls.",
3091 availability: "native-review",
3092 availabilityText: "Available to a reviewed native plugin.",
3093 methods: [
3094 {
3095 name: "registerServer",
3096 signature: "registerServer(definition: { serverName: string, server: Record<string, unknown> }): () => void",
3097 summary: "Propose one server. serverName is a letter or digit followed by up to 31 letters, digits, _ or -. headers and env must stay empty and the url may carry no credentials, query or fragment. At most 64 servers per plugin; at most 64 KiB per definition."
3098 }
3099 ]
3100 },
3101 {
3102 key: "shellHooks",
3103 group: "codewhale",
3104 summary: "Claude Code and Codex style command hooks, run by the Engine.",
3105 availability: "native-review",
3106 availabilityText: "Available to a reviewed native plugin.",
3107 methods: [
3108 {
3109 name: "register",
3110 signature: "register(definition: { dialect: 'claude-code' | 'codex', point: string, matcher?: string, hook: { event: string, command: string, timeout_secs: number, background: false, continue_on_error: false, name: string } }): () => void",
3111 summary: "Register one command hook for a reviewed native plugin. Forced continuation, observer steering, non-command and asynchronous hooks are not supported."
3112 }
3113 ]
3114 },
3115 {
3116 key: "remote",
3117 group: "codewhale",
3118 summary: "Remote pairing, served by the Engine.",
3119 availability: "review-grant",
3120 availabilityText: "Served by the Engine only when the plugin's review granted it.",
3121 methods: [
3122 {
3123 name: "status",
3124 signature: "status(): Promise<Status>",
3125 summary: "Whether remote access is on."
3126 },
3127 {
3128 name: "pair",
3129 signature: "pair(options?: { label?: string }): Promise<Pairing>",
3130 summary: "Start a pairing."
3131 },
3132 {
3133 name: "clients",
3134 signature: "clients(): Promise<Client[]>",
3135 summary: "List paired clients."
3136 },
3137 {
3138 name: "revoke",
3139 signature: "revoke(id: string): Promise<void>",
3140 summary: "Revoke one grant by the id pair returned."
3141 }
3142 ]
3143 },
3144 {
3145 key: "workspace",
3146 group: "codewhale",
3147 summary: "Bounded workspace file reads, writes, directory listings, and approved command execution.",
3148 availability: "review-grant",
3149 availabilityText: "Served by the Engine only when the plugin's review granted it.",
3150 methods: [
3151 {
3152 name: "read",
3153 signature: "read(path: string, options?: { startLine?: number, maxLines?: number }): Promise<string>",
3154 summary: "Read a file inside the reviewed workspace root."
3155 },
3156 {
3157 name: "list",
3158 signature: "list(path?: string): Promise<WorkspaceEntry[]>",
3159 summary: "List entries under a workspace directory."
3160 },
3161 {
3162 name: "write",
3163 signature: "write(path: string, content: string): Promise<void>",
3164 summary: "Write a file inside the reviewed workspace root."
3165 },
3166 {
3167 name: "exec",
3168 signature: "exec(argv: string[], options?: { cwd?: string, timeoutMs?: number }): Promise<ExecResult>",
3169 summary: "Run a reviewed command inside the workspace."
3170 }
3171 ]
3172 }
3173 ],
3174 refusedServices: [
3175 "shellHooks",
3176 "loader",
3177 "approval",
3178 "agents",
3179 "subagents",
3180 "sessions",
3181 "llm",
3182 "sandboxPolicy",
3183 "credentials",
3184 "fs",
3185 "subprocess",
3186 "systemPrompt",
3187 "runtimeLoop",
3188 "tools",
3189 "commands",
3190 "prompt",
3191 "storage",
3192 "skills",
3193 "avatars",
3194 "mcp",
3195 "logger",
3196 "userQuestions",
3197 "remote",
3198 "workspace",
3199 "settings",
3200 "pluginManager",
3201 "deepseekAccount",
3202 "terminal",
3203 "attachments",
3204 "agentPresets",
3205 "agentDefaultModel",
3206 "sessionProjections",
3207 "workspaceRegistry",
3208 "typertGateway",
3209 "web",
3210 "webServer",
3211 "connection",
3212 "sessionTitle",
3213 "profileContext",
3214 "sessionPersistence",
3215 "storageDomain",
3216 "invariants",
3217 "permissionPresets"
3218 ],
3219 events: [
3220 {
3221 name: "tools/pre-execute",
3222 status: "supported",
3223 mode: "ordered listeners, native hooks first, then plugin listeners in registration order",
3224 signature: "ctx.on('tools/pre-execute', async (exec: { name: string, callId: string, arguments: object, signal: AbortSignal, workspace: string, mode: string, model: string }, next: () => Promise<Abstention>) => Verdict | undefined)",
3225 summary: "Programmable tool admission for a reviewed native plugin. The frozen call view has no session, agent, tool or approval handle. Return { kind: 'deny', reason }, { kind: 'ask', reason? }, { kind: 'revise', input }, { kind: 'annotate', text } or { kind: 'abstain' }; undefined abstains. A malformed answer, error or timeout fails the call closed. The listener batch has a five second deadline.",
3226 options: "prepend and global are refused."
3227 },
3228 {
3229 name: "tools/post-execute",
3230 status: "supported",
3231 mode: "read-only observers in registration order, after the tool finishes",
3232 signature: "ctx.on('tools/post-execute', async (exec: { name: string, callId: string, arguments: { is_error: boolean, duration_ms: number }, signal: AbortSignal, workspace: string, mode: string, model: string }, next: () => Promise<Abstention>) => void)",
3233 summary: "Observes a finished tool call for a reviewed native plugin. The view carries only whether the call failed and how long it took, never its output, session or agent. The return value is ignored and an error is logged, so an observer cannot change or fail the call. The listener batch has a five second deadline.",
3234 options: "prepend and global are refused."
3235 },
3236 {
3237 name: "tools/result",
3238 status: "supported",
3239 mode: "read-only observers in registration order, after the tool finishes",
3240 signature: "ctx.on('tools/result', async (exec: { name: string, callId: string, arguments: { is_error: boolean, duration_ms: number }, signal: AbortSignal, workspace: string, mode: string, model: string }, next: () => Promise<Abstention>) => void)",
3241 summary: "Alias for read-only tool outcome observation backed by tools/post-execute. Cannot mutate or veto execution.",
3242 options: "prepend and global are refused."
3243 },
3244 {
3245 name: "agent/created",
3246 status: "supported",
3247 mode: "listeners of the owning plugin only",
3248 signature: "ctx.on('agent/created', async ({ agent }: { agent: { id: string, ctx: { systemPrompt: { getSectionOrder(name), section(section) }, tools: { restrict(filter: { deny: string[] }) } } } }) => void)",
3249 summary: "Fires for a child agent that this plugin's own subagents.startActivation creates, before the child starts. The listener may set the child's persona and deny tools to it; the window closes when the listeners return.",
3250 options: "global is refused."
3251 },
3252 {
3253 name: "agent/pre-step",
3254 status: "refused",
3255 summary: "Not projected by this host: no core projection exists, so a listener would never fire."
3256 },
3257 {
3258 name: "agent/turn-stopping",
3259 status: "refused",
3260 summary: "Not projected by this host: no core projection exists, so a listener would never fire."
3261 },
3262 {
3263 name: "subagent/start",
3264 status: "refused",
3265 summary: "Not projected by this host: no core projection exists, so a listener would never fire."
3266 },
3267 {
3268 name: "subagent/end",
3269 status: "refused",
3270 summary: "Not projected by this host: no core projection exists, so a listener would never fire."
3271 },
3272 {
3273 name: "approval/request",
3274 status: "refused",
3275 summary: "Not projected by this host: no core projection exists, so a listener would never fire."
3276 }
3277 ],
3278 cordisInternalEvents: "Cordis fires its own internal/* lifecycle events. They are not part of this host's supported contract and are not listed.",
3279 config: [
3280 {
3281 id: "row:@deepseek-ai/dsh-mcp-client",
3282 name: "@deepseek-ai/dsh-mcp-client",
3283 bridge: "mcp",
3284 summary: "An MCP server row. The Engine proposes the server and owns the connection.",
3285 limits: [
3286 "stdio rows name a command; streamable-http and sse rows name a url.",
3287 "Reconnect and instruction bounds belong to the Engine and are not configurable here."
3288 ],
3289 example: {
3290 transport: "stdio",
3291 serverName: "docs",
3292 command: "node",
3293 args: [
3294 "server.js"
3295 ],
3296 cwd: "."
3297 },
3298 schema: {
3299 $schema: "https://json-schema.org/draft/2020-12/schema",
3300 title: "@deepseek-ai/dsh-mcp-client",
3301 type: "object",
3302 additionalProperties: false,
3303 required: [
3304 "transport",
3305 "serverName"
3306 ],
3307 properties: {
3308 transport: {
3309 type: "string",
3310 enum: [
3311 "stdio",
3312 "streamable-http",
3313 "sse"
3314 ]
3315 },
3316 serverName: {
3317 type: "string",
3318 pattern: "^[A-Za-z0-9][A-Za-z0-9_-]{0,31}$"
3319 },
3320 command: {
3321 type: "string",
3322 description: "stdio only: the program to run."
3323 },
3324 args: {
3325 type: "array",
3326 items: {
3327 type: "string"
3328 },
3329 description: "stdio only."
3330 },
3331 env: {
3332 type: "object",
3333 maxProperties: 0,
3334 description: "Must be empty or absent: credentials stay with the Engine."
3335 },
3336 cwd: {
3337 type: "string",
3338 description: "stdio only: a bundle-relative directory, no .. components."
3339 },
3340 url: {
3341 type: "string",
3342 description: "streamable-http and sse: the endpoint, with no credentials, query or fragment."
3343 },
3344 headers: {
3345 type: "object",
3346 maxProperties: 0,
3347 description: "Must be empty or absent: credentials stay with the Engine."
3348 },
3349 toolCallTimeoutMs: {
3350 type: "integer",
3351 minimum: 1e3,
3352 maximum: 864e5,
3353 multipleOf: 1e3
3354 },
3355 failOnStartupError: {
3356 type: "boolean",
3357 description: "When true, install and enable connect the server first and report failure if it cannot start; when false or absent, the Engine connects lazily and reports failures through /mcp."
3358 }
3359 }
3360 }
3361 },
3362 {
3363 id: "row:@deepseek-ai/dsh-skill-filesystem",
3364 name: "@deepseek-ai/dsh-skill-filesystem",
3365 bridge: "skills",
3366 summary: "A skill folder row, limited to reviewed roots inside the bundle.",
3367 limits: [
3368 "Both includeDefaultRoots and watch must be written out as false."
3369 ],
3370 example: {
3371 includeDefaultRoots: false,
3372 watch: false,
3373 customSkillDirs: [
3374 "skills"
3375 ]
3376 },
3377 schema: {
3378 $schema: "https://json-schema.org/draft/2020-12/schema",
3379 title: "@deepseek-ai/dsh-skill-filesystem",
3380 type: "object",
3381 additionalProperties: false,
3382 required: [
3383 "includeDefaultRoots",
3384 "watch",
3385 "customSkillDirs"
3386 ],
3387 properties: {
3388 providerName: {
3389 type: "string",
3390 maxLength: 64
3391 },
3392 includeDefaultRoots: {
3393 type: "boolean",
3394 const: false,
3395 description: "Must be false: ambient roots are not read."
3396 },
3397 watch: {
3398 type: "boolean",
3399 const: false,
3400 description: "Must be false: there is no file watcher."
3401 },
3402 customSkillDirs: {
3403 type: "array",
3404 minItems: 1,
3405 maxItems: 8,
3406 items: {
3407 type: "string"
3408 },
3409 description: "Bundle-relative skill roots, no duplicates."
3410 }
3411 }
3412 }
3413 },
3414 {
3415 id: "row:@deepseek-ai/dsh-hooks-claude-code",
3416 name: "@deepseek-ai/dsh-hooks-claude-code",
3417 bridge: "hooks-claude-code",
3418 summary: "Claude Code style command hooks read from a reviewed file in the bundle.",
3419 limits: [
3420 "projectDir is refused: each process uses the current workspace.",
3421 "Only command hooks run; non-command and asynchronous hooks fail the row.",
3422 "At most 128 commands per row."
3423 ],
3424 example: {
3425 configPath: "hooks/hooks.json"
3426 },
3427 hookEvents: [
3428 {
3429 event: "SessionStart",
3430 point: "session_start"
3431 },
3432 {
3433 event: "UserPromptSubmit",
3434 point: "message_submit"
3435 },
3436 {
3437 event: "PreToolUse",
3438 point: "tool_call_before"
3439 },
3440 {
3441 event: "PostToolUse",
3442 point: "tool_call_after"
3443 },
3444 {
3445 event: "Stop",
3446 point: "turn_end"
3447 },
3448 {
3449 event: "SubagentStart",
3450 point: "subagent_spawn"
3451 },
3452 {
3453 event: "SubagentStop",
3454 point: "subagent_complete"
3455 }
3456 ],
3457 schema: {
3458 $schema: "https://json-schema.org/draft/2020-12/schema",
3459 title: "@deepseek-ai/dsh-hooks-claude-code",
3460 type: "object",
3461 additionalProperties: true,
3462 required: [
3463 "configPath"
3464 ],
3465 properties: {
3466 configPath: {
3467 type: "string",
3468 description: "A regular file inside the bundle, at most 1 MiB, unchanged since review."
3469 },
3470 pluginRoot: {
3471 type: "string",
3472 description: 'Absent, ".", or this reviewed bundle root.'
3473 },
3474 defaultTimeoutMs: {
3475 type: "integer",
3476 minimum: 1e3,
3477 maximum: 864e5,
3478 multipleOf: 1e3,
3479 description: "Whole seconds, used when a hook sets none; default 600000."
3480 }
3481 }
3482 }
3483 },
3484 {
3485 id: "row:@deepseek-ai/dsh-hooks-codex",
3486 name: "@deepseek-ai/dsh-hooks-codex",
3487 bridge: "hooks-codex",
3488 summary: "Codex style command hooks read from a reviewed file in the bundle.",
3489 limits: [
3490 "projectDir is refused: each process uses the current workspace.",
3491 "Only command hooks run; non-command and asynchronous hooks fail the row.",
3492 "At most 128 commands per row."
3493 ],
3494 example: {
3495 configPath: "hooks/hooks.json"
3496 },
3497 hookEvents: [
3498 {
3499 event: "SessionStart",
3500 point: "session_start"
3501 },
3502 {
3503 event: "UserPromptSubmit",
3504 point: "message_submit"
3505 },
3506 {
3507 event: "PreToolUse",
3508 point: "tool_call_before"
3509 },
3510 {
3511 event: "PostToolUse",
3512 point: "tool_call_after"
3513 },
3514 {
3515 event: "Stop",
3516 point: "turn_end"
3517 },
3518 {
3519 event: "SubagentStart",
3520 point: "subagent_spawn"
3521 },
3522 {
3523 event: "SubagentStop",
3524 point: "subagent_complete"
3525 }
3526 ],
3527 schema: {
3528 $schema: "https://json-schema.org/draft/2020-12/schema",
3529 title: "@deepseek-ai/dsh-hooks-codex",
3530 type: "object",
3531 additionalProperties: true,
3532 required: [
3533 "configPath"
3534 ],
3535 properties: {
3536 configPath: {
3537 type: "string",
3538 description: "A regular file inside the bundle, at most 1 MiB, unchanged since review."
3539 },
3540 pluginRoot: {
3541 type: "string",
3542 description: 'Absent, ".", or this reviewed bundle root.'
3543 },
3544 defaultTimeoutMs: {
3545 type: "integer",
3546 minimum: 1e3,
3547 maximum: 864e5,
3548 multipleOf: 1e3,
3549 description: "Whole seconds, used when a hook sets none; default 600000."
3550 }
3551 }
3552 }
3553 },
3554 {
3555 id: "row:@deepseek-ai/dsh-persona",
3556 name: "@deepseek-ai/dsh-persona",
3557 bridge: "persona",
3558 summary: "Text added before and after the Engine's own prompt for this plugin's entry.",
3559 limits: [
3560 "Needs an exact Engine-selected entry scope."
3561 ],
3562 example: {
3563 prefix: "Answer in short sentences."
3564 },
3565 schema: {
3566 $schema: "https://json-schema.org/draft/2020-12/schema",
3567 title: "@deepseek-ai/dsh-persona",
3568 type: "object",
3569 additionalProperties: false,
3570 required: [
3571 "prefix"
3572 ],
3573 properties: {
3574 prefix: {
3575 type: "string",
3576 description: "At most 4096 UTF-8 bytes, no control characters. Only {{model}} and {{cwd}} are expanded."
3577 },
3578 suffix: {
3579 type: "string",
3580 description: "Same limits as prefix."
3581 },
3582 complete: {
3583 type: "boolean",
3584 const: false,
3585 description: "Replacing the whole prompt belongs to the Engine."
3586 },
3587 includeRuntimeContext: {
3588 type: "boolean",
3589 const: true,
3590 description: "Suppressing the runtime context belongs to the Engine."
3591 }
3592 }
3593 }
3594 },
3595 {
3596 id: "row:@deepseek-ai/dsh-storage",
3597 name: "@deepseek-ai/dsh-storage",
3598 bridge: "host-spine",
3599 summary: "Storage row bridge satisfied natively by the Engine spine.",
3600 limits: [
3601 "Served natively by the Codewhale Engine spine; row configuration is inert."
3602 ],
3603 example: {},
3604 schema: {
3605 $schema: "https://json-schema.org/draft/2020-12/schema",
3606 title: "@deepseek-ai/dsh-storage",
3607 type: "object",
3608 additionalProperties: true
3609 }
3610 },
3611 {
3612 id: "row:@deepseek-ai/dsh-storage-json",
3613 name: "@deepseek-ai/dsh-storage-json",
3614 bridge: "host-spine",
3615 summary: "JSON storage row bridge satisfied natively by the Engine spine.",
3616 limits: [
3617 "Served natively by the Codewhale Engine spine; row configuration is inert."
3618 ],
3619 example: {},
3620 schema: {
3621 $schema: "https://json-schema.org/draft/2020-12/schema",
3622 title: "@deepseek-ai/dsh-storage-json",
3623 type: "object",
3624 additionalProperties: true
3625 }
3626 },
3627 {
3628 id: "row:@deepseek-ai/dsh-storage-domain",
3629 name: "@deepseek-ai/dsh-storage-domain",
3630 bridge: "host-spine",
3631 summary: "Domain storage row bridge satisfied natively by the Engine spine.",
3632 limits: [
3633 "Served natively by the Codewhale Engine spine; row configuration is inert."
3634 ],
3635 example: {},
3636 schema: {
3637 $schema: "https://json-schema.org/draft/2020-12/schema",
3638 title: "@deepseek-ai/dsh-storage-domain",
3639 type: "object",
3640 additionalProperties: true
3641 }
3642 },
3643 {
3644 id: "row:@deepseek-ai/dsh-workspace",
3645 name: "@deepseek-ai/dsh-workspace",
3646 bridge: "host-spine",
3647 summary: "Workspace row bridge satisfied natively by the Engine spine.",
3648 limits: [
3649 "Served natively by the Codewhale Engine spine; row configuration is inert."
3650 ],
3651 example: {},
3652 schema: {
3653 $schema: "https://json-schema.org/draft/2020-12/schema",
3654 title: "@deepseek-ai/dsh-workspace",
3655 type: "object",
3656 additionalProperties: true
3657 }
3658 },
3659 {
3660 id: "row:@deepseek-ai/dsh-code-runtime-worker-thread",
3661 name: "@deepseek-ai/dsh-code-runtime-worker-thread",
3662 bridge: "host-spine",
3663 summary: "Worker-thread runtime row bridge satisfied natively by the Engine spine.",
3664 limits: [
3665 "Served natively by the Codewhale Engine spine; row configuration is inert."
3666 ],
3667 example: {},
3668 schema: {
3669 $schema: "https://json-schema.org/draft/2020-12/schema",
3670 title: "@deepseek-ai/dsh-code-runtime-worker-thread",
3671 type: "object",
3672 additionalProperties: true
3673 }
3674 },
3675 {
3676 id: "row:@deepseek-ai/dsh-tool-subagent/model-selection-settings",
3677 name: "@deepseek-ai/dsh-tool-subagent/model-selection-settings",
3678 bridge: "host-spine",
3679 summary: "Subagent model-selection settings row bridge satisfied natively by the Engine spine.",
3680 limits: [
3681 "Served natively by the Codewhale Engine spine; row configuration is inert."
3682 ],
3683 example: {},
3684 schema: {
3685 $schema: "https://json-schema.org/draft/2020-12/schema",
3686 title: "@deepseek-ai/dsh-tool-subagent/model-selection-settings",
3687 type: "object",
3688 additionalProperties: true
3689 }
3690 },
3691 {
3692 id: "row:@deepseek-ai/dsh-agent-preset-registry",
3693 name: "@deepseek-ai/dsh-agent-preset-registry",
3694 bridge: "host-spine",
3695 summary: "Agent-preset registry row bridge satisfied natively by the Engine spine.",
3696 limits: [
3697 "Served natively by the Codewhale Engine spine; row configuration is inert."
3698 ],
3699 example: {},
3700 schema: {
3701 $schema: "https://json-schema.org/draft/2020-12/schema",
3702 title: "@deepseek-ai/dsh-agent-preset-registry",
3703 type: "object",
3704 additionalProperties: true
3705 }
3706 },
3707 {
3708 id: "row:@deepseek-ai/dsh-cordis-host-runner",
3709 name: "@deepseek-ai/dsh-cordis-host-runner",
3710 bridge: "host-spine",
3711 summary: "Host-runner row bridge satisfied natively by the Engine spine.",
3712 limits: [
3713 "Served natively by the Codewhale Engine spine; row configuration is inert."
3714 ],
3715 example: {},
3716 schema: {
3717 $schema: "https://json-schema.org/draft/2020-12/schema",
3718 title: "@deepseek-ai/dsh-cordis-host-runner",
3719 type: "object",
3720 additionalProperties: true
3721 }
3722 },
3723 {
3724 id: "row:@deepseek-ai/dsh-host-webserver",
3725 name: "@deepseek-ai/dsh-host-webserver",
3726 bridge: "host-spine",
3727 summary: "Host webserver row bridge satisfied natively by the Engine spine.",
3728 limits: [
3729 "Served natively by the Codewhale Engine spine; row configuration is inert."
3730 ],
3731 example: {},
3732 schema: {
3733 $schema: "https://json-schema.org/draft/2020-12/schema",
3734 title: "@deepseek-ai/dsh-host-webserver",
3735 type: "object",
3736 additionalProperties: true
3737 }
3738 }
3739 ]
3740 },
3741 client: {
3742 seats: [
3743 {
3744 seat: "customize.plugins.detail",
3745 drawn: true,
3746 where: "The plugin's own page under Customize, Plugins."
3747 },
3748 {
3749 seat: "conversation.composer.dock",
3750 drawn: false,
3751 where: "Under the composer. The desktop app does not place it yet."
3752 },
3753 {
3754 seat: "conversation.chat.node",
3755 drawn: false,
3756 where: "Inside the conversation. The desktop app does not place it yet."
3757 },
3758 {
3759 seat: "workpane.panel",
3760 drawn: false,
3761 where: "The work pane. The desktop app does not place it yet."
3762 },
3763 {
3764 seat: "sidebar.section",
3765 drawn: false,
3766 where: "The sidebar. The desktop app does not place it yet."
3767 },
3768 {
3769 seat: "command.row",
3770 drawn: false,
3771 where: "The command list. The desktop app does not place it yet."
3772 }
3773 ],
3774 slots: [
3775 {
3776 slot: "plugins.bundle.config",
3777 seat: "customize.plugins.detail",
3778 supported: true
3779 },
3780 {
3781 slot: "plugins.row.config",
3782 seat: "customize.plugins.detail",
3783 supported: true
3784 },
3785 {
3786 slot: "plugins.tab",
3787 seat: "customize.plugins.detail",
3788 supported: true
3789 },
3790 {
3791 slot: "plugins.detail.section",
3792 seat: "customize.plugins.detail",
3793 supported: true
3794 },
3795 {
3796 slot: "plugins.item",
3797 seat: "customize.plugins.detail",
3798 supported: true
3799 },
3800 {
3801 slot: "plugins.detail.actions",
3802 seat: "customize.plugins.detail",
3803 supported: true
3804 },
3805 {
3806 slot: "plugins.detail.badge",
3807 seat: "customize.plugins.detail",
3808 supported: true
3809 },
3810 {
3811 slot: "settings.section",
3812 seat: "customize.plugins.detail",
3813 supported: true
3814 },
3815 {
3816 slot: "settings.section.icon",
3817 seat: "customize.plugins.detail",
3818 supported: true
3819 },
3820 {
3821 slot: "settings.plugin.item",
3822 seat: "customize.plugins.detail",
3823 supported: true
3824 },
3825 {
3826 slot: "settings.general.item",
3827 seat: "customize.plugins.detail",
3828 supported: true
3829 },
3830 {
3831 slot: "settings.plugins.tab",
3832 seat: "customize.plugins.detail",
3833 supported: true
3834 },
3835 {
3836 slot: "web-ui.plugin.item",
3837 seat: "customize.plugins.detail",
3838 supported: true
3839 },
3840 {
3841 slot: "conversation.chat.node",
3842 seat: "conversation.chat.node",
3843 supported: true
3844 },
3845 {
3846 slot: "conversation.chat.turnTail",
3847 seat: "conversation.chat.node",
3848 supported: true
3849 },
3850 {
3851 slot: "conversation.chat.assistant-actions",
3852 seat: "conversation.chat.node",
3853 supported: true
3854 },
3855 {
3856 slot: "conversation.chat.commandview",
3857 seat: "conversation.chat.node",
3858 supported: true
3859 },
3860 {
3861 slot: "conversation.chat.text-interaction",
3862 seat: "conversation.chat.node",
3863 supported: true
3864 },
3865 {
3866 slot: "conversation.user.text.node",
3867 seat: "conversation.chat.node",
3868 supported: true
3869 },
3870 {
3871 slot: "tool.call.toolview",
3872 seat: "conversation.chat.node",
3873 supported: true
3874 },
3875 {
3876 slot: "conversation.view",
3877 seat: "conversation.chat.node",
3878 supported: true
3879 },
3880 {
3881 slot: "conversation.input.dock",
3882 seat: "conversation.composer.dock",
3883 supported: true
3884 },
3885 {
3886 slot: "conversation.input.overlay",
3887 seat: "conversation.composer.dock",
3888 supported: true
3889 },
3890 {
3891 slot: "conversation.input.right",
3892 seat: "conversation.composer.dock",
3893 supported: true
3894 },
3895 {
3896 slot: "conversation.composer.dock",
3897 seat: "conversation.composer.dock",
3898 supported: true
3899 },
3900 {
3901 slot: "sidebar.right.pane.tab",
3902 seat: "workpane.panel",
3903 supported: true
3904 },
3905 {
3906 slot: "sidebar.right.pane.tab.title",
3907 seat: "workpane.panel",
3908 supported: true
3909 },
3910 {
3911 slot: "shell.overlay",
3912 seat: "workpane.panel",
3913 supported: true
3914 },
3915 {
3916 slot: "main",
3917 seat: "workpane.panel",
3918 supported: true
3919 },
3920 {
3921 slot: "main.conversation",
3922 seat: "workpane.panel",
3923 supported: true
3924 },
3925 {
3926 slot: "main.page-menu",
3927 seat: "workpane.panel",
3928 supported: true
3929 },
3930 {
3931 slot: "sidebar.panellist",
3932 seat: "sidebar.section",
3933 supported: true
3934 },
3935 {
3936 slot: "sidebar.channels",
3937 seat: "sidebar.section",
3938 supported: true
3939 },
3940 {
3941 slot: "sidebar.workspaces",
3942 seat: "sidebar.section",
3943 supported: true
3944 },
3945 {
3946 slot: "sidebar.footer.action",
3947 seat: "sidebar.section",
3948 supported: true
3949 },
3950 {
3951 slot: "sidebar.session.row.leading",
3952 seat: "sidebar.section",
3953 supported: true
3954 },
3955 {
3956 slot: "sidebar.workspaces.session.row.action",
3957 seat: "sidebar.section",
3958 supported: true
3959 },
3960 {
3961 slot: "conversation.session.header.actions",
3962 seat: "command.row",
3963 supported: true
3964 },
3965 {
3966 slot: "conversation.session.header.lineage",
3967 seat: "command.row",
3968 supported: true
3969 },
3970 {
3971 slot: "conversation.session.header.utilities",
3972 seat: "command.row",
3973 supported: true
3974 },
3975 {
3976 slot: "contextMenu.icon",
3977 seat: null,
3978 supported: false,
3979 reason: "no ADE seat yet"
3980 }
3981 ],
3982 theme: {
3983 tokens: [],
3984 colorSchemes: [
3985 "light",
3986 "dark"
3987 ],
3988 scheme: "The frame sets data-theme and color-scheme on its document to the app's current scheme and follows changes.",
3989 api: [
3990 {
3991 name: "ctx.theme.getTheme",
3992 signature: "getTheme(): { active: { colorScheme: 'light' | 'dark' } }",
3993 summary: "The scheme in use now."
3994 },
3995 {
3996 name: "ctx.theme.overrideTokens",
3997 signature: "overrideTokens(source: string, tokens: Record<string, { light: string, dark: string }>): () => void",
3998 summary: "Set custom properties on the frame's document for each scheme. source is at most 256 characters; each name starts with -- and is at most 128 characters; each value is at most 512 characters. Returns a disposer."
3999 }
4000 ],
4001 notes: [
4002 "The frame defines no named design tokens of its own. There are no --dsw-* tokens to read: a plugin that wants tokens defines them with overrideTokens and uses them in its own styles.",
4003 "The frame's background is transparent and its margin is zero, so the plugin sits on the app's own surface."
4004 ]
4005 }
4006 }
4007 };
4008
4009 // src/dsh/inspect.ts
4010 var catalog = inspect_catalog_default;
4011 var EMPTY_INPUT = { type: "object", properties: {}, additionalProperties: false };
4012 var ANY_OUTPUT = { description: "JSON data owned by this inspect provider." };
4013 var NO_CLIENT = "No client is connected. Plugin screens are drawn by the desktop app; in a terminal nothing is drawn, so every slot reports drawn: false.";
4014 var exactInput = (field, description) => ({
4015 type: "object",
4016 properties: { [field]: { type: "string", description } },
4017 additionalProperties: false
4018 });
4019 var method = (name3, description, inputSchema = EMPTY_INPUT, outputSchema = ANY_OUTPUT) => ({ name: name3, description, inputSchema, outputSchema });
4020 var copy = (value) => JSON.parse(JSON.stringify(value));
4021 function serviceView(service) {
4022 return {
4023 key: service.key,
4024 group: service.group,
4025 summary: service.summary,
4026 availability: service.availability,
4027 availabilityText: service.availabilityText,
4028 methods: service.methods
4029 };
4030 }
4031 function serviceProvider() {
4032 return {
4033 platform: "host",
4034 id: "Service",
4035 description: "The services this host gives plugins, with their methods, and the services a plugin may not provide. A name that is not listed does not exist here.",
4036 methods: [method(
4037 "listService",
4038 "Without input: the directory of services with one-line summaries and method signatures. With service: that service's exact contract, with availability. These are services a plugin injects, not DSH's full catalogue.",
4039 exactInput("service", "Exact service key. Omit it for the directory.")
4040 )],
4041 run(_name, input) {
4042 const key = input.service;
4043 if (key === void 0) {
4044 return {
4045 services: catalog.host.services.map((s) => ({ key: s.key, group: s.group, summary: s.summary, availability: s.availability, signatures: s.methods.map((m) => m.signature) })),
4046 refusedServices: catalog.host.refusedServices,
4047 note: "refusedServices are names a plugin may not provide: the Engine owns them. Service methods named by the host Event and Config providers are separate.",
4048 targetDshVersion: catalog.targetDshVersion
4049 };
4050 }
4051 const found = catalog.host.services.find((s) => s.key === key);
4052 if (!found) throw new Error(`Host service "${String(key)}" is not provided by this host. Call without service for the directory.`);
4053 return { service: serviceView(found), targetDshVersion: catalog.targetDshVersion };
4054 }
4055 };
4056 }
4057 function eventProvider() {
4058 return {
4059 platform: "host",
4060 id: "Event",
4061 description: "The events a plugin may listen to in this host, and the ones the host refuses.",
4062 methods: [method(
4063 "listEvents",
4064 "Without input: the directory of events with status supported or refused. With event: its exact contract.",
4065 exactInput("event", "Exact event name. Omit it for the directory.")
4066 )],
4067 run(_name, input) {
4068 const key = input.event;
4069 if (key === void 0) {
4070 return {
4071 events: catalog.host.events.map((e) => ({ name: e.name, status: e.status, summary: e.summary })),
4072 note: catalog.host.cordisInternalEvents
4073 };
4074 }
4075 const found = catalog.host.events.find((e) => e.name === key);
4076 if (!found) throw new Error(`Host event "${String(key)}" is not known to this host. Call without event for the directory.`);
4077 return { event: found };
4078 }
4079 };
4080 }
4081 var CONFIG_INPUT = {
4082 type: "object",
4083 properties: {
4084 entry: { type: "string", description: "Exact entry id from the directory; returns that entry's Config schema." },
4085 name: { type: "string", description: "Exact package or plugin name; limits the directory to it." },
4086 offset: { type: "integer", description: "Zero-based directory offset; defaults to 0." },
4087 limit: { type: "integer", description: "Directory page size, from 1 to 100; defaults to 25." }
4088 },
4089 additionalProperties: false
4090 };
4091 function configProvider(sources) {
4092 return {
4093 platform: "host",
4094 id: "Config",
4095 description: "Config a composition row may carry: the packages a row may name, each with the config it accepts, and the plugins installed on this host with their state.",
4096 methods: [method("listConfigs", "Without entry: a page of the directory (row packages first, then installed plugins) with total and nextOffset. With entry: one row package's exact JSON Schema, limits and a valid example. Installed plugins are listed with their state; their own config is not described here.", CONFIG_INPUT)],
4097 async run(_name, input, _agent, signal) {
4098 const rows = catalog.host.config.map((r) => ({ id: r.id, name: r.name, kind: "row-package", status: "schema", bridge: r.bridge, summary: r.summary }));
4099 const installed = sources.installed ? await sources.installed(signal) : [];
4100 for (const row of installed) rows.push({ id: `plugin:${row.id}`, name: row.name, kind: "installed-plugin", status: row.state });
4101 if (input.entry !== void 0) {
4102 const pkg = catalog.host.config.find((r) => r.id === input.entry);
4103 if (pkg) return { entry: pkg.id, name: pkg.name, kind: "row-package", bridge: pkg.bridge, summary: pkg.summary, limits: pkg.limits, example: pkg.example, ...pkg.hookEvents ? { hookEvents: pkg.hookEvents } : {}, schema: pkg.schema };
4104 const live = rows.find((r) => r.id === input.entry);
4105 if (live) return { entry: live.id, name: live.name, kind: live.kind, status: live.status, schema: null, note: "An installed plugin's own Config is not described by this host." };
4106 throw new Error(`Host Config entry "${String(input.entry)}" is not listed. Call without entry for the directory.`);
4107 }
4108 const filtered = input.name === void 0 ? rows : rows.filter((r) => r.name === input.name);
4109 const offset = typeof input.offset === "number" ? input.offset : 0;
4110 const limit = typeof input.limit === "number" ? input.limit : 25;
4111 if (offset < 0 || limit < 1 || limit > 100) throw new Error("Host Config directory needs offset >= 0 and 1 <= limit <= 100");
4112 const page = filtered.slice(offset, offset + limit);
4113 const next = offset + page.length;
4114 return { entries: page, total: filtered.length, ...next < filtered.length ? { nextOffset: next } : {} };
4115 }
4116 };
4117 }
4118 function toolProvider(sources) {
4119 const source = sources.tools;
4120 if (!source) return void 0;
4121 return {
4122 platform: "host",
4123 id: "Tool",
4124 description: "Tools visible to the requesting agent.",
4125 methods: [method("listTools", "Return the name of every tool currently callable by this agent.")],
4126 async run(_name, _input, agent, signal) {
4127 return { tools: [...await source(agent, signal)] };
4128 }
4129 };
4130 }
4131 var SUBTREE_INPUT = exactInput("root", "Exact slot name to select. Omit it for every slot.");
4132 function slotsProvider(sources) {
4133 return {
4134 platform: "client",
4135 id: "Slots",
4136 description: "The DSH slot names this host accepts, the seat each maps to, and whether the connected client draws that seat.",
4137 methods: [method("listSubTree", "Return every slot with its seat and drawn state; with root, also that slot selected. Slots are static names here, not a live tree, and their props are not described by this host: a plugin registers on a slot, the Engine serves it on the mapped seat, and the client draws only the seats it places.", SUBTREE_INPUT)],
4138 run(_name, input) {
4139 const state = sources.client?.() ?? { connected: false };
4140 const drawn = new Set(state.connected ? state.drawnSeats ?? catalog.client.seats.filter((s) => s.drawn).map((s) => s.seat) : []);
4141 const slots = catalog.client.slots.map((s) => ({
4142 type: "slot",
4143 name: s.slot,
4144 seat: s.seat,
4145 supported: s.supported,
4146 drawn: s.supported && drawn.has(s.seat),
4147 ...s.reason ? { reason: s.reason } : {}
4148 }));
4149 const seats = catalog.client.seats.map((s) => ({ seat: s.seat, drawn: drawn.has(s.seat), where: s.where }));
4150 const out = {
4151 client: state.connected ? { connected: true } : { connected: false, message: NO_CLIENT },
4152 seats,
4153 trees: slots,
4154 referencedTypes: []
4155 };
4156 if (input.root !== void 0) {
4157 const selected = slots.find((s) => s.name === input.root);
4158 out.requestedRoot = { name: input.root, available: selected !== void 0 };
4159 if (selected) out.selected = selected;
4160 }
4161 return out;
4162 }
4163 };
4164 }
4165 function themeProvider() {
4166 return {
4167 platform: "client",
4168 id: "Theme",
4169 description: "What the plugin frame provides for theming.",
4170 methods: [method("listTokens", "Return the named tokens the frame provides (none), the colour schemes, and the theme calls a plugin has.")],
4171 run() {
4172 return { tokens: catalog.client.theme.tokens, colorSchemes: catalog.client.theme.colorSchemes, scheme: catalog.client.theme.scheme, api: catalog.client.theme.api, notes: catalog.client.theme.notes, referencedTypes: [] };
4173 }
4174 };
4175 }
4176 function createCordisInspect(sources = {}) {
4177 const providers = [serviceProvider(), eventProvider(), configProvider(sources), toolProvider(sources), slotsProvider(sources), themeProvider()].filter((p) => p !== void 0);
4178 for (const provider of providers) {
4179 if (provider.id.trim() === "" || provider.description.trim() === "") throw new Error("Cordis inspect provider needs an id and a description");
4180 for (const m of provider.methods) {
4181 assertSupportedJsonSchema(m.inputSchema);
4182 assertSupportedJsonSchema(m.outputSchema);
4183 }
4184 }
4185 const label = (platform) => platform === "host" ? "Host" : "Client";
4186 return {
4187 list() {
4188 return providers.map((p) => ({ platform: p.platform, id: p.id, description: p.description, methods: copy(p.methods) }));
4189 },
4190 async query(platform, providerId, methodName, input, agent, signal = new AbortController().signal) {
4191 if (platform !== "host" && platform !== "client") throw new Error(`Cordis inspect platform must be "host" or "client", not "${String(platform)}"`);
4192 const provider = providers.find((p) => p.platform === platform && p.id === providerId);
4193 if (!provider) throw new Error(`${label(platform)} Cordis inspect provider "${providerId}" is not registered`);
4194 const found = provider.methods.find((m) => m.name === methodName);
4195 if (!found) throw new Error(`Cordis inspect provider "${provider.id}" has no method "${methodName}"`);
4196 const violations = validateJsonSchemaValue(found.inputSchema, input ?? {}, "input");
4197 if (violations.length > 0) throw new Error(`${label(platform)} Cordis inspect ${provider.id}.${found.name} rejected input: ${violations.join("; ")}`);
4198 signal.throwIfAborted();
4199 const data = await provider.run(methodName, input ?? {}, agent, signal);
4200 signal.throwIfAborted();
4201 if (!isJson(data)) throw new Error(`${label(platform)} Cordis inspect ${provider.id}.${found.name} returned a non-JSON value`);
4202 return copy(data);
4203 }
4204 };
4205 }
4206
4207 // src/builtin/creator.ts
4208 var name2 = "creator";
4209 var inject2 = ["tools", "pluginManager", "sandboxPolicy"];
4210 function apply3(ctx) {
4211 apply(ctx);
4212 const cordisInspect = createCordisInspect({
4213 installed: async (signal) => {
4214 const rows = await ctx.pluginManager.listPlugins(signal);
4215 return rows.map((r) => ({
4216 id: String(r.entryId),
4217 name: String(r.moduleName),
4218 state: !r.enabled ? "disabled" : String(r.fiberPhase ?? "active")
4219 }));
4220 },
4221 tools: async (_agent, signal) => {
4222 const names = await ctx.pluginManager.listTools(signal);
4223 return names.map((name3) => ({ name: String(name3) }));
4224 }
4225 });
4226 ctx.provide("cordisInspect", cordisInspect);
4227 ctx.plugin(tool_cordis_exports);
4228 }
4229 export {
4230 apply3 as apply,
4231 inject2 as inject,
4232 name2 as name
4233 };
4234
4234 lines Plain Text