@eclipse-docks/extension-ai-system 0.8.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +1 -1
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +87 -2
- package/dist/api.js.map +1 -0
- package/dist/{cognitive-extension-7_ZMUCGD.js → cognitive-extension-CvP05Bw_.js} +241 -36
- package/dist/cognitive-extension-CvP05Bw_.js.map +1 -0
- package/dist/cognitive-extension.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/runtime/cognitive-runtime.d.ts +5 -0
- package/dist/runtime/cognitive-runtime.d.ts.map +1 -1
- package/dist/runtime/context/usage.d.ts +3 -0
- package/dist/runtime/context/usage.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/models/openai-compatible.d.ts.map +1 -1
- package/dist/runtime/models/types.d.ts +6 -1
- package/dist/runtime/models/types.d.ts.map +1 -1
- package/dist/runtime/skills-commands.d.ts +3 -0
- package/dist/runtime/skills-commands.d.ts.map +1 -0
- package/dist/runtime/skills-parse.d.ts +14 -0
- package/dist/runtime/skills-parse.d.ts.map +1 -0
- package/dist/runtime/skills-resolve.d.ts +9 -0
- package/dist/runtime/skills-resolve.d.ts.map +1 -0
- package/dist/runtime/skills-select.d.ts +9 -0
- package/dist/runtime/skills-select.d.ts.map +1 -0
- package/dist/runtime/skills-types.d.ts +47 -0
- package/dist/runtime/skills-types.d.ts.map +1 -0
- package/dist/runtime/skills.d.ts +13 -0
- package/dist/runtime/skills.d.ts.map +1 -0
- package/dist/runtime/specialists/index.d.ts.map +1 -1
- package/dist/runtime/specialists/loop.d.ts.map +1 -1
- package/dist/runtime/tools/fetch-adapter.d.ts +4 -0
- package/dist/runtime/tools/fetch-adapter.d.ts.map +1 -0
- package/dist/runtime/tools/index.d.ts +1 -0
- package/dist/runtime/tools/index.d.ts.map +1 -1
- package/dist/runtime/types.d.ts +7 -0
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/{runtime-By5PP2BC.js → runtime-DVzLyx8h.js} +345 -16
- package/dist/runtime-DVzLyx8h.js.map +1 -0
- package/dist/view/cognitive-view.d.ts +5 -0
- package/dist/view/cognitive-view.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/cognitive-extension-7_ZMUCGD.js.map +0 -1
- package/dist/runtime-By5PP2BC.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-adapter.d.ts","sourceRoot":"","sources":["../../../src/runtime/tools/fetch-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAwC3C,0FAA0F;AAC1F,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAgG3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/tools/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/tools/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC"}
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -98,6 +98,11 @@ export interface SessionAttachment {
|
|
|
98
98
|
createdAt: number;
|
|
99
99
|
messageId?: string;
|
|
100
100
|
}
|
|
101
|
+
/** Provider-reported token counts for a model turn (may span multiple tool-loop calls). */
|
|
102
|
+
export interface TokenUsage {
|
|
103
|
+
inputTokens: number;
|
|
104
|
+
outputTokens: number;
|
|
105
|
+
}
|
|
101
106
|
export interface ChatMessage {
|
|
102
107
|
id: string;
|
|
103
108
|
role: 'user' | 'assistant' | 'system';
|
|
@@ -105,6 +110,8 @@ export interface ChatMessage {
|
|
|
105
110
|
createdAt: number;
|
|
106
111
|
routedModel?: string;
|
|
107
112
|
effort?: EffortLevel;
|
|
113
|
+
/** Cumulative provider usage for this assistant turn, when reported. */
|
|
114
|
+
usage?: TokenUsage;
|
|
108
115
|
}
|
|
109
116
|
export interface Checkpoint {
|
|
110
117
|
id: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GACvB,KAAK,GACL,OAAO,GACP,MAAM,GACN,UAAU,GACV,SAAS,GACT,SAAS,GACT,OAAO,GACP,cAAc,CAAC;AAEnB,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;AAE7D,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;AAEjF,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,KAAK,GAAG,IAAI,CAAC;IACnB,SAAS,EAAE,KAAK,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,KAAK,GAAG,IAAI,CAAC;IACvB,OAAO,EAAE,KAAK,GAAG,IAAI,CAAC;IACtB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,WAAW,GAAG,SAAS,CAAC;AAE1D,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,WAAW,CAAC;IACnB,SAAS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,EAAE,WAAW,EAAE,CAAC;IACvB,8DAA8D;IAC9D,WAAW,EAAE,iBAAiB,EAAE,CAAC;IACjC,OAAO,EAAE,SAAS,CAAC;IACnB,cAAc,EAAE,cAAc,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,WAAW,CAAA;CAAE,GACzF;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,WAAW,CAAC;IAAC,SAAS,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAExE,MAAM,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Directory, File, IN_MEMORY_ROOT_NAME, commandRegistry, filebrowserDialog, getInMemoryRoot, persistenceService, setInMemoryMountProjection, workspaceService } from "@eclipse-docks/core";
|
|
1
|
+
import { Directory, File, IN_MEMORY_ROOT_NAME, commandRegistry, contributionRegistry, filebrowserDialog, getInMemoryRoot, persistenceService, registerAll, setInMemoryMountProjection, workspaceService } from "@eclipse-docks/core";
|
|
2
2
|
import { Models } from "@opencode-ai/models";
|
|
3
3
|
//#region src/runtime/events.ts
|
|
4
4
|
/** Tiny in-process bus so runtime stays UI-agnostic. */
|
|
@@ -624,11 +624,16 @@ async function fetchOpenAICompatibleModels(baseUrl, apiKey, signal) {
|
|
|
624
624
|
function buildChatCompletionBody(params) {
|
|
625
625
|
const model = params.model.includes("/") ? params.model.split("/").slice(1).join("/") : params.model;
|
|
626
626
|
const { reasoning_effort: _a, reasoningEffort: _b, reasoning: _c, ...safeOptions } = params.providerOptions ?? {};
|
|
627
|
+
const { stream_options: userStreamOptions, ...restSafeOptions } = safeOptions;
|
|
627
628
|
const body = {
|
|
628
629
|
model,
|
|
629
630
|
messages: toOpenAIMessages(params.messages),
|
|
630
631
|
stream: true,
|
|
631
|
-
...
|
|
632
|
+
...restSafeOptions,
|
|
633
|
+
stream_options: {
|
|
634
|
+
...userStreamOptions && typeof userStreamOptions === "object" ? userStreamOptions : {},
|
|
635
|
+
include_usage: true
|
|
636
|
+
}
|
|
632
637
|
};
|
|
633
638
|
const requestedEffort = params.providerOptions?.reasoning_effort ?? params.providerOptions?.reasoningEffort;
|
|
634
639
|
const reasoningModel = detectEffortCapability(params.model).supported || requestedEffort != null;
|
|
@@ -726,15 +731,22 @@ var OpenAICompatibleProvider = class {
|
|
|
726
731
|
return;
|
|
727
732
|
}
|
|
728
733
|
try {
|
|
729
|
-
const
|
|
734
|
+
const json = JSON.parse(data);
|
|
735
|
+
const usage = parseStreamUsage(json.usage);
|
|
736
|
+
if (usage) yield {
|
|
737
|
+
type: "usage",
|
|
738
|
+
usage
|
|
739
|
+
};
|
|
740
|
+
const delta = json.choices?.[0]?.delta;
|
|
730
741
|
if (!delta) continue;
|
|
731
|
-
if (delta.content) yield {
|
|
742
|
+
if (typeof delta.content === "string" && delta.content) yield {
|
|
732
743
|
type: "text",
|
|
733
744
|
text: delta.content
|
|
734
745
|
};
|
|
735
|
-
|
|
746
|
+
const reasoning = delta.reasoning_content ?? delta.reasoning;
|
|
747
|
+
if (reasoning) yield {
|
|
736
748
|
type: "reasoning",
|
|
737
|
-
text: String(
|
|
749
|
+
text: String(reasoning)
|
|
738
750
|
};
|
|
739
751
|
if (Array.isArray(delta.tool_calls)) for (const tc of delta.tool_calls) {
|
|
740
752
|
const idx = tc.index ?? 0;
|
|
@@ -758,6 +770,17 @@ var OpenAICompatibleProvider = class {
|
|
|
758
770
|
yield { type: "done" };
|
|
759
771
|
}
|
|
760
772
|
};
|
|
773
|
+
function parseStreamUsage(usage) {
|
|
774
|
+
if (!usage) return null;
|
|
775
|
+
const inputTokens = Number(usage.prompt_tokens ?? usage.input_tokens ?? 0);
|
|
776
|
+
const outputTokens = Number(usage.completion_tokens ?? usage.output_tokens ?? 0);
|
|
777
|
+
if (!Number.isFinite(inputTokens) && !Number.isFinite(outputTokens)) return null;
|
|
778
|
+
if (inputTokens <= 0 && outputTokens <= 0) return null;
|
|
779
|
+
return {
|
|
780
|
+
inputTokens: Math.max(0, Math.round(inputTokens) || 0),
|
|
781
|
+
outputTokens: Math.max(0, Math.round(outputTokens) || 0)
|
|
782
|
+
};
|
|
783
|
+
}
|
|
761
784
|
//#endregion
|
|
762
785
|
//#region src/runtime/models/router.ts
|
|
763
786
|
var EFFORT_ORDER = [
|
|
@@ -1485,7 +1508,7 @@ async function qualifyWorkspaceToolPath(rawPath, mode = "write") {
|
|
|
1485
1508
|
}
|
|
1486
1509
|
//#endregion
|
|
1487
1510
|
//#region src/runtime/tools/workspace-adapter.ts
|
|
1488
|
-
function asRecord(value) {
|
|
1511
|
+
function asRecord$1(value) {
|
|
1489
1512
|
return value && typeof value === "object" ? value : {};
|
|
1490
1513
|
}
|
|
1491
1514
|
/** Some File backends (e.g. in-memory) expose mime; the abstract File does not. */
|
|
@@ -1708,7 +1731,7 @@ function registerWorkspaceTools(broker) {
|
|
|
1708
1731
|
}
|
|
1709
1732
|
}, async (call) => {
|
|
1710
1733
|
try {
|
|
1711
|
-
const args = asRecord(call.arguments);
|
|
1734
|
+
const args = asRecord$1(call.arguments);
|
|
1712
1735
|
const qualified = await qualifyWorkspaceToolPath(String(args.path ?? ""), "write");
|
|
1713
1736
|
if (!qualified.ok) return {
|
|
1714
1737
|
id: call.id,
|
|
@@ -1753,6 +1776,131 @@ function registerWorkspaceTools(broker) {
|
|
|
1753
1776
|
});
|
|
1754
1777
|
}
|
|
1755
1778
|
//#endregion
|
|
1779
|
+
//#region src/runtime/tools/fetch-adapter.ts
|
|
1780
|
+
var DEFAULT_MAX_BYTES = 512e3;
|
|
1781
|
+
var DEFAULT_MAX_CHARS = 12e4;
|
|
1782
|
+
var DEFAULT_TIMEOUT_MS = 2e4;
|
|
1783
|
+
function asRecord(value) {
|
|
1784
|
+
return value && typeof value === "object" ? value : {};
|
|
1785
|
+
}
|
|
1786
|
+
function parseUrl(raw) {
|
|
1787
|
+
const trimmed = raw.trim();
|
|
1788
|
+
if (!trimmed) return { error: "Missing url" };
|
|
1789
|
+
let parsed;
|
|
1790
|
+
try {
|
|
1791
|
+
parsed = new URL(trimmed);
|
|
1792
|
+
} catch {
|
|
1793
|
+
return { error: `Invalid url: ${trimmed}` };
|
|
1794
|
+
}
|
|
1795
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") return { error: `Only http(s) URLs are allowed (got ${parsed.protocol})` };
|
|
1796
|
+
return parsed;
|
|
1797
|
+
}
|
|
1798
|
+
function isTextualContentType(contentType) {
|
|
1799
|
+
const type = contentType.split(";")[0]?.trim().toLowerCase() ?? "";
|
|
1800
|
+
if (!type) return true;
|
|
1801
|
+
if (type.startsWith("text/")) return true;
|
|
1802
|
+
return type.includes("json") || type.includes("xml") || type.includes("javascript") || type.includes("svg") || type.includes("markdown") || type.includes("yaml") || type.includes("csv");
|
|
1803
|
+
}
|
|
1804
|
+
/** Registers a read-only HTTP(S) fetch tool for remote documentation and text content. */
|
|
1805
|
+
function registerFetchTools(broker) {
|
|
1806
|
+
broker.register({
|
|
1807
|
+
name: "fetch",
|
|
1808
|
+
description: "Fetch a remote http(s) URL and return text content (HTML, Markdown, JSON, etc.). Use for docs and references (e.g. Web Awesome agent skills on jsDelivr). Binary responses return metadata only.",
|
|
1809
|
+
parameters: {
|
|
1810
|
+
type: "object",
|
|
1811
|
+
properties: {
|
|
1812
|
+
url: {
|
|
1813
|
+
type: "string",
|
|
1814
|
+
description: "Absolute http(s) URL to fetch"
|
|
1815
|
+
},
|
|
1816
|
+
max_chars: {
|
|
1817
|
+
type: "number",
|
|
1818
|
+
description: `Max characters of body text to return (default ${DEFAULT_MAX_CHARS})`
|
|
1819
|
+
}
|
|
1820
|
+
},
|
|
1821
|
+
required: ["url"]
|
|
1822
|
+
}
|
|
1823
|
+
}, async (call) => {
|
|
1824
|
+
const args = asRecord(call.arguments);
|
|
1825
|
+
const parsed = parseUrl(String(args.url ?? ""));
|
|
1826
|
+
if ("error" in parsed) return {
|
|
1827
|
+
id: call.id,
|
|
1828
|
+
name: call.name,
|
|
1829
|
+
ok: false,
|
|
1830
|
+
output: null,
|
|
1831
|
+
error: parsed.error
|
|
1832
|
+
};
|
|
1833
|
+
const maxCharsRaw = Number(args.max_chars);
|
|
1834
|
+
const maxChars = Number.isFinite(maxCharsRaw) && maxCharsRaw > 0 ? Math.min(Math.floor(maxCharsRaw), DEFAULT_MAX_CHARS * 2) : DEFAULT_MAX_CHARS;
|
|
1835
|
+
const controller = new AbortController();
|
|
1836
|
+
const timer = setTimeout(() => controller.abort(), DEFAULT_TIMEOUT_MS);
|
|
1837
|
+
try {
|
|
1838
|
+
const response = await fetch(parsed.href, {
|
|
1839
|
+
method: "GET",
|
|
1840
|
+
redirect: "follow",
|
|
1841
|
+
signal: controller.signal,
|
|
1842
|
+
headers: { Accept: "text/*, application/json, application/xml, */*;q=0.1" }
|
|
1843
|
+
});
|
|
1844
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
1845
|
+
const buffer = new Uint8Array(await response.arrayBuffer());
|
|
1846
|
+
const truncatedBytes = buffer.byteLength > DEFAULT_MAX_BYTES;
|
|
1847
|
+
const slice = truncatedBytes ? buffer.subarray(0, DEFAULT_MAX_BYTES) : buffer;
|
|
1848
|
+
if (!isTextualContentType(contentType) && !looksLikeUtf8Text(slice)) return {
|
|
1849
|
+
id: call.id,
|
|
1850
|
+
name: call.name,
|
|
1851
|
+
ok: response.ok,
|
|
1852
|
+
output: {
|
|
1853
|
+
url: response.url || parsed.href,
|
|
1854
|
+
status: response.status,
|
|
1855
|
+
contentType,
|
|
1856
|
+
byteLength: buffer.byteLength,
|
|
1857
|
+
binary: true,
|
|
1858
|
+
note: "Response is not text; body omitted. Prefer documentation or raw text URLs."
|
|
1859
|
+
},
|
|
1860
|
+
error: response.ok ? void 0 : `HTTP ${response.status}`
|
|
1861
|
+
};
|
|
1862
|
+
const decoded = new TextDecoder("utf-8", { fatal: false }).decode(slice);
|
|
1863
|
+
const truncatedChars = decoded.length > maxChars;
|
|
1864
|
+
const body = truncatedChars ? decoded.slice(0, maxChars) : decoded;
|
|
1865
|
+
return {
|
|
1866
|
+
id: call.id,
|
|
1867
|
+
name: call.name,
|
|
1868
|
+
ok: response.ok,
|
|
1869
|
+
output: {
|
|
1870
|
+
url: response.url || parsed.href,
|
|
1871
|
+
status: response.status,
|
|
1872
|
+
contentType,
|
|
1873
|
+
byteLength: buffer.byteLength,
|
|
1874
|
+
truncated: truncatedBytes || truncatedChars,
|
|
1875
|
+
body
|
|
1876
|
+
},
|
|
1877
|
+
error: response.ok ? void 0 : `HTTP ${response.status}`
|
|
1878
|
+
};
|
|
1879
|
+
} catch (err) {
|
|
1880
|
+
const message = err instanceof Error && err.name === "AbortError" ? `Timed out after ${DEFAULT_TIMEOUT_MS}ms` : err instanceof Error ? err.message : String(err);
|
|
1881
|
+
return {
|
|
1882
|
+
id: call.id,
|
|
1883
|
+
name: call.name,
|
|
1884
|
+
ok: false,
|
|
1885
|
+
output: null,
|
|
1886
|
+
error: message
|
|
1887
|
+
};
|
|
1888
|
+
} finally {
|
|
1889
|
+
clearTimeout(timer);
|
|
1890
|
+
}
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1893
|
+
function looksLikeUtf8Text(bytes) {
|
|
1894
|
+
if (!bytes.length) return true;
|
|
1895
|
+
const sample = bytes.subarray(0, Math.min(bytes.length, 512));
|
|
1896
|
+
let odd = 0;
|
|
1897
|
+
for (const b of sample) {
|
|
1898
|
+
if (b === 0) return false;
|
|
1899
|
+
if (b < 7 || b > 13 && b < 32) odd += 1;
|
|
1900
|
+
}
|
|
1901
|
+
return odd / sample.length < .1;
|
|
1902
|
+
}
|
|
1903
|
+
//#endregion
|
|
1756
1904
|
//#region src/runtime/tools/command-adapter.ts
|
|
1757
1905
|
/** Commands that must never be exposed as LLM tools (pickers, storage boots, settings). */
|
|
1758
1906
|
var SKIP = /* @__PURE__ */ new Set([
|
|
@@ -1778,7 +1926,8 @@ var SKIP_PREFIXES = [
|
|
|
1778
1926
|
var KEEP_TOOLS = /* @__PURE__ */ new Set([
|
|
1779
1927
|
"workspace_list",
|
|
1780
1928
|
"workspace_read",
|
|
1781
|
-
"workspace_write"
|
|
1929
|
+
"workspace_write",
|
|
1930
|
+
"fetch"
|
|
1782
1931
|
]);
|
|
1783
1932
|
function sanitizeName(id) {
|
|
1784
1933
|
return id.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64);
|
|
@@ -2154,7 +2303,7 @@ var SessionRuntime = class {
|
|
|
2154
2303
|
//#region src/runtime/specialists/classify-risk.ts
|
|
2155
2304
|
var CLASSIFY_SYSTEM = `You classify tool calls for user approval.
|
|
2156
2305
|
Mark risk "critical" if the call can change state: write/edit/delete files, connect or load a workspace, run shell/commands with side effects, install, deploy, publish, push, or otherwise mutate the environment.
|
|
2157
|
-
Mark risk "safe" only for read-only inspection (list, read, search, describe).
|
|
2306
|
+
Mark risk "safe" only for read-only inspection (list, read, search, describe, fetch).
|
|
2158
2307
|
When unsure, choose "critical".
|
|
2159
2308
|
Reply with ONLY a JSON array: [{"id":"<tool call id>","risk":"safe"|"critical"}]`;
|
|
2160
2309
|
/** Ask the model whether pending tool calls are safe or critical. Unknown → critical. */
|
|
@@ -2292,6 +2441,10 @@ async function runSpecialistLoop(input) {
|
|
|
2292
2441
|
const messages = historyToProviderMessages(input.systemPrompt, input.history, input.compactionSummary);
|
|
2293
2442
|
let success = true;
|
|
2294
2443
|
let cancelled = false;
|
|
2444
|
+
const usage = {
|
|
2445
|
+
inputTokens: 0,
|
|
2446
|
+
outputTokens: 0
|
|
2447
|
+
};
|
|
2295
2448
|
const markCancelled = () => {
|
|
2296
2449
|
if (cancelled) return;
|
|
2297
2450
|
cancelled = true;
|
|
@@ -2326,6 +2479,10 @@ async function runSpecialistLoop(input) {
|
|
|
2326
2479
|
success = false;
|
|
2327
2480
|
break;
|
|
2328
2481
|
}
|
|
2482
|
+
if (chunk.type === "usage" && chunk.usage) {
|
|
2483
|
+
usage.inputTokens += chunk.usage.inputTokens;
|
|
2484
|
+
usage.outputTokens += chunk.usage.outputTokens;
|
|
2485
|
+
}
|
|
2329
2486
|
if (chunk.type === "reasoning" && chunk.text) emit({
|
|
2330
2487
|
type: "reasoning",
|
|
2331
2488
|
text: chunk.text,
|
|
@@ -2451,7 +2608,8 @@ async function runSpecialistLoop(input) {
|
|
|
2451
2608
|
parts: coalesceParts(parts),
|
|
2452
2609
|
createdAt: Date.now(),
|
|
2453
2610
|
routedModel: input.resolved.model,
|
|
2454
|
-
effort: input.resolved.effort
|
|
2611
|
+
effort: input.resolved.effort,
|
|
2612
|
+
...usage.inputTokens > 0 || usage.outputTokens > 0 ? { usage } : {}
|
|
2455
2613
|
},
|
|
2456
2614
|
success
|
|
2457
2615
|
};
|
|
@@ -2485,10 +2643,10 @@ function systemPromptFor(role, goal, opts = {}) {
|
|
|
2485
2643
|
"This turn publishes session attachments under the shared in-memory root (in-memory/<sessionId>/… or in-memory://<sessionId>/…).",
|
|
2486
2644
|
"Read them with workspace_read / workspace_list — in-memory paths work without mounting that root into the workspace tree.",
|
|
2487
2645
|
"Do not call load_workspace / connect_opfs / connect_indexeddb to find attachments.",
|
|
2488
|
-
"Canvas from a screenshot: workspace_read the attachment path →
|
|
2646
|
+
"Canvas from a screenshot: skills.load eclipse-docks-canvas → workspace_read the attachment path → workspace_write a new .canvas.js (into a durable workspace folder) → canvas.open. Change a canvas with canvas.apply_source. An open editor is marked dirty and recompiled and is not saved; a canvas that is not open in an editor is written to its file. Do not workspace_write a canvas that is already open.",
|
|
2489
2647
|
"Qualify durable writes as <root>/<file> using a root from workspace_list (e.g. tests/demo.canvas.js); bare filenames are auto-rooted when a single durable folder is connected, otherwise a folder picker appears.",
|
|
2490
2648
|
"If no durable workspace folder is connected for writing canvases, say so and stop."
|
|
2491
|
-
].join(" ") : "Session attachments live under the shared in-memory root and are readable via workspace_read / workspace_list."} Workspace paths use a connected root prefix from workspace_list (never write bare names at the composite root unless a single durable folder can auto-qualify them).`;
|
|
2649
|
+
].join(" ") : "Session attachments live under the shared in-memory root and are readable via workspace_read / workspace_list."} Workspace paths use a connected root prefix from workspace_list (never write bare names at the composite root unless a single durable folder can auto-qualify them). For specialized workflows (e.g. canvas.js), call skills.list to discover registered skills, then skills.load with the matching name before following those instructions.`;
|
|
2492
2650
|
switch (role) {
|
|
2493
2651
|
case "plan": return `${preamble}\nMode: PLAN (read-only). Analyze and propose a plan for: ${goal}`;
|
|
2494
2652
|
case "explore": return `${preamble}\nMode: EXPLORE (read-only). Search and report findings for: ${goal}`;
|
|
@@ -2580,6 +2738,13 @@ function estimateSessionContextUsage(session, modelRef) {
|
|
|
2580
2738
|
}
|
|
2581
2739
|
const used = buckets.reduce((sum, b) => sum + b.tokens, 0);
|
|
2582
2740
|
const percent = limit > 0 ? Math.min(100, used / limit * 100) : 0;
|
|
2741
|
+
let inputTokens = 0;
|
|
2742
|
+
let outputTokens = 0;
|
|
2743
|
+
for (const message of session?.history ?? []) {
|
|
2744
|
+
if (!message.usage) continue;
|
|
2745
|
+
inputTokens += message.usage.inputTokens;
|
|
2746
|
+
outputTokens += message.usage.outputTokens;
|
|
2747
|
+
}
|
|
2583
2748
|
return {
|
|
2584
2749
|
used,
|
|
2585
2750
|
limit,
|
|
@@ -2587,7 +2752,9 @@ function estimateSessionContextUsage(session, modelRef) {
|
|
|
2587
2752
|
remaining: Math.max(0, limit - used),
|
|
2588
2753
|
level: contextUsageLevel(percent),
|
|
2589
2754
|
buckets: buckets.filter((b) => b.tokens > 0),
|
|
2590
|
-
modelRef
|
|
2755
|
+
modelRef,
|
|
2756
|
+
inputTokens,
|
|
2757
|
+
outputTokens
|
|
2591
2758
|
};
|
|
2592
2759
|
}
|
|
2593
2760
|
function formatTokenCount(n) {
|
|
@@ -2692,6 +2859,108 @@ function projectInMemoryMountToFolder(folderName) {
|
|
|
2692
2859
|
});
|
|
2693
2860
|
}
|
|
2694
2861
|
//#endregion
|
|
2862
|
+
//#region src/runtime/skills-parse.ts
|
|
2863
|
+
/**
|
|
2864
|
+
* Parse a SKILL.md document (YAML frontmatter + markdown body).
|
|
2865
|
+
* Compatible with Cursor Agent Skills layout.
|
|
2866
|
+
*/
|
|
2867
|
+
function parseSkillMarkdown(raw) {
|
|
2868
|
+
const text = raw.replace(/^\uFEFF/, "");
|
|
2869
|
+
const match = text.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
|
|
2870
|
+
if (!match) return {
|
|
2871
|
+
name: "",
|
|
2872
|
+
description: "",
|
|
2873
|
+
body: text.trim()
|
|
2874
|
+
};
|
|
2875
|
+
const front = match[1] ?? "";
|
|
2876
|
+
const body = (match[2] ?? "").trim();
|
|
2877
|
+
return {
|
|
2878
|
+
name: readFrontmatterString(front, "name"),
|
|
2879
|
+
description: readFrontmatterString(front, "description"),
|
|
2880
|
+
body
|
|
2881
|
+
};
|
|
2882
|
+
}
|
|
2883
|
+
/** Short ambient prompt block (uses skill description). */
|
|
2884
|
+
function formatSkillForPrompt(skill) {
|
|
2885
|
+
const description = skill.description.trim();
|
|
2886
|
+
if (!description) return skill.body.trim();
|
|
2887
|
+
return description;
|
|
2888
|
+
}
|
|
2889
|
+
function readFrontmatterString(front, key) {
|
|
2890
|
+
const folded = front.match(new RegExp(`^${key}:\\s*>-\\s*\\r?\\n((?:[ \\t]+.*\\r?\\n?)*)`, "m"));
|
|
2891
|
+
if (folded?.[1]) return folded[1].split(/\r?\n/).map((line) => line.replace(/^[ \t]+/, "").trimEnd()).filter((line, index, all) => line.length > 0 || index < all.length - 1).join(" ").replace(/\s+/g, " ").trim();
|
|
2892
|
+
const quoted = front.match(new RegExp(`^${key}:\\s*[\"']([\\s\\S]*?)[\"']\\s*$`, "m"));
|
|
2893
|
+
if (quoted?.[1]) return quoted[1].replace(/\s+/g, " ").trim();
|
|
2894
|
+
return front.match(new RegExp(`^${key}:\\s*(.+)$`, "m"))?.[1]?.trim() ?? "";
|
|
2895
|
+
}
|
|
2896
|
+
//#endregion
|
|
2897
|
+
//#region src/runtime/skills-types.ts
|
|
2898
|
+
function isSkillContribution(value) {
|
|
2899
|
+
if (!value || typeof value !== "object") return false;
|
|
2900
|
+
const skill = value;
|
|
2901
|
+
const hasBody = typeof skill.body === "string";
|
|
2902
|
+
const hasLoad = typeof skill.load === "function";
|
|
2903
|
+
return typeof skill.name === "string" && skill.name.length > 0 && typeof skill.label === "string" && (hasBody || hasLoad);
|
|
2904
|
+
}
|
|
2905
|
+
//#endregion
|
|
2906
|
+
//#region src/runtime/skills-resolve.ts
|
|
2907
|
+
function rawFromLoadResult(result) {
|
|
2908
|
+
if (typeof result === "string") return result;
|
|
2909
|
+
return typeof result?.default === "string" ? result.default : "";
|
|
2910
|
+
}
|
|
2911
|
+
async function readSkillRaw(skill) {
|
|
2912
|
+
if (typeof skill.body === "string" && skill.body.trim()) return skill.body.replace(/^\uFEFF/, "");
|
|
2913
|
+
if (!skill.load) return "";
|
|
2914
|
+
return rawFromLoadResult(await skill.load()).replace(/^\uFEFF/, "");
|
|
2915
|
+
}
|
|
2916
|
+
/**
|
|
2917
|
+
* Resolve SKILL.md (eager `body` or lazy `load`) into name/description/body.
|
|
2918
|
+
* Frontmatter wins for description unless the contribution sets an explicit override.
|
|
2919
|
+
*/
|
|
2920
|
+
async function resolveSkill(skill) {
|
|
2921
|
+
const raw = (await readSkillRaw(skill)).trim();
|
|
2922
|
+
const parsed = raw ? parseSkillMarkdown(raw) : {
|
|
2923
|
+
name: "",
|
|
2924
|
+
description: "",
|
|
2925
|
+
body: ""
|
|
2926
|
+
};
|
|
2927
|
+
return {
|
|
2928
|
+
name: skill.name || parsed.name,
|
|
2929
|
+
label: skill.label || parsed.name || skill.name,
|
|
2930
|
+
description: (skill.description ?? parsed.description).trim(),
|
|
2931
|
+
body: parsed.body.trim() || (raw && !parsed.description && !parsed.name ? raw : "")
|
|
2932
|
+
};
|
|
2933
|
+
}
|
|
2934
|
+
/** @deprecated Prefer {@link resolveSkill}; kept for callers that only need the body. */
|
|
2935
|
+
async function resolveSkillBody(skill) {
|
|
2936
|
+
return (await resolveSkill(skill)).body;
|
|
2937
|
+
}
|
|
2938
|
+
//#endregion
|
|
2939
|
+
//#region src/runtime/skills.ts
|
|
2940
|
+
/** Contribution slot for AI agent skills (Cursor-compatible SKILL.md content). */
|
|
2941
|
+
var SYSTEM_SKILLS = "system.skills";
|
|
2942
|
+
function listSkillContributions() {
|
|
2943
|
+
return contributionRegistry.getContributions(SYSTEM_SKILLS).filter(isSkillContribution);
|
|
2944
|
+
}
|
|
2945
|
+
/** Register a SKILL.md document on {@link SYSTEM_SKILLS}. Returns an unregister function. */
|
|
2946
|
+
function registerSkillMarkdown(raw, opts) {
|
|
2947
|
+
const parsed = parseSkillMarkdown(raw);
|
|
2948
|
+
const name = (opts?.name || parsed.name || `skill-${Date.now()}`).trim();
|
|
2949
|
+
const contribution = {
|
|
2950
|
+
name,
|
|
2951
|
+
label: opts?.label || parsed.name || name,
|
|
2952
|
+
body: (opts?.body || raw).trim(),
|
|
2953
|
+
ranking: opts?.ranking,
|
|
2954
|
+
icon: opts?.icon,
|
|
2955
|
+
relevant: opts?.relevant,
|
|
2956
|
+
load: opts?.load,
|
|
2957
|
+
description: opts?.description
|
|
2958
|
+
};
|
|
2959
|
+
if (!contribution.body && !contribution.load) return () => void 0;
|
|
2960
|
+
contributionRegistry.registerContribution(SYSTEM_SKILLS, contribution);
|
|
2961
|
+
return () => contributionRegistry.unregisterContribution(SYSTEM_SKILLS, name);
|
|
2962
|
+
}
|
|
2963
|
+
//#endregion
|
|
2695
2964
|
//#region src/runtime/cognitive-runtime.ts
|
|
2696
2965
|
var PERSIST_KEY = "cognitive/v1/state";
|
|
2697
2966
|
/** Auto-compact after a turn when live history exceeds this many messages. */
|
|
@@ -2726,6 +2995,7 @@ var CognitiveRuntime = class {
|
|
|
2726
2995
|
emit: false
|
|
2727
2996
|
});
|
|
2728
2997
|
registerWorkspaceTools(this.tools);
|
|
2998
|
+
registerFetchTools(this.tools);
|
|
2729
2999
|
this.tools.setApprovalMode(this.approvalMode);
|
|
2730
3000
|
this.tools.setPermissionHandler(async (req) => this.requestPermission(req));
|
|
2731
3001
|
this.ready = this.hydrateAll();
|
|
@@ -2781,6 +3051,13 @@ var CognitiveRuntime = class {
|
|
|
2781
3051
|
this.promptEnhancers = this.promptEnhancers.filter((e) => e !== enhancer);
|
|
2782
3052
|
};
|
|
2783
3053
|
}
|
|
3054
|
+
/**
|
|
3055
|
+
* Register a Cursor-compatible SKILL.md document on {@link SYSTEM_SKILLS}.
|
|
3056
|
+
* Relevant skills are selected into the specialist prompt each turn.
|
|
3057
|
+
*/
|
|
3058
|
+
addSkillMarkdown(raw) {
|
|
3059
|
+
return registerSkillMarkdown(raw);
|
|
3060
|
+
}
|
|
2784
3061
|
/** First catalog model for the default provider — used by Manual routing. */
|
|
2785
3062
|
defaultModelId() {
|
|
2786
3063
|
const catalog = catalogFromSettings(this.providersSettings);
|
|
@@ -3003,6 +3280,7 @@ var CognitiveRuntime = class {
|
|
|
3003
3280
|
buffers: tick.buffers,
|
|
3004
3281
|
status: "running"
|
|
3005
3282
|
});
|
|
3283
|
+
this.emitSessions();
|
|
3006
3284
|
this.events.publish(TOPIC.coreTick, {
|
|
3007
3285
|
valenceDelta: tick.valenceDelta,
|
|
3008
3286
|
intent: tick.intent,
|
|
@@ -3259,6 +3537,57 @@ function summarizePrompt(text, attachments) {
|
|
|
3259
3537
|
return `Attached ${attachments.map((a) => a.name).join(", ")}`;
|
|
3260
3538
|
}
|
|
3261
3539
|
//#endregion
|
|
3262
|
-
|
|
3540
|
+
//#region src/runtime/skills-commands.ts
|
|
3541
|
+
/** Register skills.list / skills.load as Docks commands (also exposed as LLM tools). */
|
|
3542
|
+
function registerSkillCommands() {
|
|
3543
|
+
registerAll({
|
|
3544
|
+
command: {
|
|
3545
|
+
id: "skills.list",
|
|
3546
|
+
name: "List skills",
|
|
3547
|
+
description: "List registered agent skills (name + description from SKILL.md). Call skills.load with a skill name to read the full instructions.",
|
|
3548
|
+
parameters: []
|
|
3549
|
+
},
|
|
3550
|
+
handler: { execute: async () => Promise.all(listSkillContributions().map(async (skill) => {
|
|
3551
|
+
const resolved = await resolveSkill(skill);
|
|
3552
|
+
return {
|
|
3553
|
+
name: resolved.name,
|
|
3554
|
+
label: resolved.label,
|
|
3555
|
+
description: resolved.description
|
|
3556
|
+
};
|
|
3557
|
+
})) }
|
|
3558
|
+
});
|
|
3559
|
+
registerAll({
|
|
3560
|
+
command: {
|
|
3561
|
+
id: "skills.load",
|
|
3562
|
+
name: "Load skill",
|
|
3563
|
+
description: "Load the full body of a registered agent skill by name. Prefer skills returned by skills.list.",
|
|
3564
|
+
parameters: [{
|
|
3565
|
+
name: "name",
|
|
3566
|
+
description: "Skill name (e.g. eclipse-docks-canvas)",
|
|
3567
|
+
required: true
|
|
3568
|
+
}]
|
|
3569
|
+
},
|
|
3570
|
+
handler: { execute: async (context) => {
|
|
3571
|
+
const name = String(context.params?.name ?? "").trim();
|
|
3572
|
+
if (!name) return {
|
|
3573
|
+
error: "Missing skill name",
|
|
3574
|
+
available: listSkillContributions().map((skill) => skill.name)
|
|
3575
|
+
};
|
|
3576
|
+
const skill = listSkillContributions().find((entry) => entry.name === name);
|
|
3577
|
+
if (!skill) return {
|
|
3578
|
+
error: `Unknown skill: ${name}`,
|
|
3579
|
+
available: listSkillContributions().map((entry) => entry.name)
|
|
3580
|
+
};
|
|
3581
|
+
const resolved = await resolveSkill(skill);
|
|
3582
|
+
if (!resolved.body) return {
|
|
3583
|
+
error: `Skill ${name} has no body`,
|
|
3584
|
+
name: resolved.name
|
|
3585
|
+
};
|
|
3586
|
+
return resolved;
|
|
3587
|
+
} }
|
|
3588
|
+
});
|
|
3589
|
+
}
|
|
3590
|
+
//#endregion
|
|
3591
|
+
export { detectEffortCapability as C, AI_VIEW_NAME as D, AI_SETTINGS_KEY as E, OPEN_AI_SETTINGS_COMMAND as O, parseModelIds as S, AI_SETTINGS_EDITOR_ID as T, readPromptAttachmentFromFile as _, listSkillContributions as a, defaultProvidersSettings as b, resolveSkillBody as c, parseSkillMarkdown as d, estimateSessionContextUsage as f, ATTACHMENT_FILE_ACCEPT as g, formatTokenCount as h, SYSTEM_SKILLS as i, TOPIC as k, isSkillContribution as l, formatContextPercent as m, CognitiveRuntime as n, registerSkillMarkdown as o, formatBucketDetail as p, cognitiveRuntime as r, resolveSkill as s, registerSkillCommands as t, formatSkillForPrompt as u, OpenAICompatibleProvider as v, loadModelsCatalog as w, listConfiguredModelIds as x, fetchOpenAICompatibleModels as y };
|
|
3263
3592
|
|
|
3264
|
-
//# sourceMappingURL=runtime-
|
|
3593
|
+
//# sourceMappingURL=runtime-DVzLyx8h.js.map
|