@ringko-ai/rkh 0.2.0 → 0.2.1-rc
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/README.md +13 -15
- package/bin/{rkh.mjs → ringko.mjs} +419 -110
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
# RingKo CLI
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
npx @ringko-ai/rkh tui
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
The `rkh` executable requires Bun on your PATH. You can also use
|
|
10
|
-
`bunx @ringko-ai/rkh tui`, or run `npx @ringko-ai/rkh help` to list commands.
|
|
11
|
-
|
|
12
|
-
For a global installation:
|
|
3
|
+
`@ringko-ai/rkh` is the RingKo agent CLI, distributed as a globally installed npm
|
|
4
|
+
package. The `ringko` executable is a Bun bundle, so Node.js 24+ **and**
|
|
5
|
+
[Bun](https://bun.sh/) 1.2+ must be on `PATH` — Bun is not optional.
|
|
13
6
|
|
|
14
7
|
```sh
|
|
15
8
|
npm install -g @ringko-ai/rkh
|
|
16
|
-
|
|
9
|
+
ringko tui
|
|
17
10
|
```
|
|
18
11
|
|
|
19
|
-
|
|
12
|
+
`ringko help` lists every command. Without a global install, `npx @ringko-ai/rkh tui`
|
|
13
|
+
and `bunx @ringko-ai/rkh tui` run the same CLI.
|
|
14
|
+
|
|
15
|
+
Prerelease versions publish under the `next` dist-tag: `npm install -g @ringko-ai/rkh@next`.
|
|
20
16
|
|
|
21
17
|
This package bundles the CLI, built-in model providers and the WebUI assets.
|
|
22
18
|
The browser's interactive terminal uses Node.js and the `node-pty` dependency.
|
|
23
|
-
Custom provider modules configured by the host are loaded separately at runtime.
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
Custom provider modules configured by the host are loaded separately at runtime.
|
|
20
|
+
The package installs the `ringko` command; the standalone platform binaries
|
|
21
|
+
use the same name. For source development and standalone binaries, see the
|
|
22
|
+
[repository](https://github.com/RingKoAI/ringko-harness); the Chinese README is
|
|
23
|
+
[README.zh-CN.md](https://github.com/RingKoAI/ringko-harness/blob/main/README.zh-CN.md).
|
|
26
24
|
|
|
27
25
|
## Automatic npm releases
|
|
28
26
|
|
|
@@ -24830,6 +24830,314 @@ var init_write = __esm(() => {
|
|
|
24830
24830
|
init_workspace();
|
|
24831
24831
|
});
|
|
24832
24832
|
|
|
24833
|
+
// packages/tools/src/session-query.ts
|
|
24834
|
+
import { resolve as resolve5 } from "path";
|
|
24835
|
+
function asRecord3(value) {
|
|
24836
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
24837
|
+
throw new TypeError("Expected an object input.");
|
|
24838
|
+
}
|
|
24839
|
+
return value;
|
|
24840
|
+
}
|
|
24841
|
+
function integerField(record, key, min, max) {
|
|
24842
|
+
const value = record[key];
|
|
24843
|
+
if (value === undefined)
|
|
24844
|
+
return;
|
|
24845
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < min || value > max) {
|
|
24846
|
+
throw new TypeError(`Invalid '${key}'; expected an integer between ${min} and ${max}.`);
|
|
24847
|
+
}
|
|
24848
|
+
return value;
|
|
24849
|
+
}
|
|
24850
|
+
function stringField(record, key, max) {
|
|
24851
|
+
const value = record[key];
|
|
24852
|
+
if (value === undefined)
|
|
24853
|
+
return;
|
|
24854
|
+
if (typeof value !== "string" || value.trim().length === 0 || value.length > max) {
|
|
24855
|
+
throw new TypeError(`Invalid '${key}'; expected a non-empty string of at most ${max} characters.`);
|
|
24856
|
+
}
|
|
24857
|
+
return value;
|
|
24858
|
+
}
|
|
24859
|
+
function normalizePath(path) {
|
|
24860
|
+
const resolved = resolve5(path);
|
|
24861
|
+
return process.platform === "win32" ? resolved.toLowerCase() : resolved;
|
|
24862
|
+
}
|
|
24863
|
+
function inWorkspace(cwd, workspace) {
|
|
24864
|
+
return typeof cwd === "string" && cwd.length > 0 && normalizePath(cwd) === normalizePath(workspace);
|
|
24865
|
+
}
|
|
24866
|
+
function serialize2(value) {
|
|
24867
|
+
if (value === undefined)
|
|
24868
|
+
return "";
|
|
24869
|
+
try {
|
|
24870
|
+
return typeof value === "string" ? value : JSON.stringify(value) ?? "";
|
|
24871
|
+
} catch {
|
|
24872
|
+
return String(value);
|
|
24873
|
+
}
|
|
24874
|
+
}
|
|
24875
|
+
function collapse(text) {
|
|
24876
|
+
return text.replace(/\s+/g, " ").trim();
|
|
24877
|
+
}
|
|
24878
|
+
function snippetOf(text, needle, limit) {
|
|
24879
|
+
const folded = text.toLowerCase();
|
|
24880
|
+
const at = folded.indexOf(needle);
|
|
24881
|
+
if (at < 0)
|
|
24882
|
+
return collapse(text).slice(0, limit);
|
|
24883
|
+
const start = Math.max(0, at - Math.floor((limit - needle.length) / 2));
|
|
24884
|
+
const window2 = collapse(text.slice(start, start + limit * 2));
|
|
24885
|
+
return window2.length > limit ? `${window2.slice(0, limit)}\u2026` : window2;
|
|
24886
|
+
}
|
|
24887
|
+
function titleFor(handle) {
|
|
24888
|
+
try {
|
|
24889
|
+
return sessionTitle(handle.all());
|
|
24890
|
+
} catch {
|
|
24891
|
+
return;
|
|
24892
|
+
}
|
|
24893
|
+
}
|
|
24894
|
+
function openScoped(store, workspace, id, limits) {
|
|
24895
|
+
const meta = store.list().find((candidate) => candidate.id === id);
|
|
24896
|
+
if (!meta)
|
|
24897
|
+
throw new Error(`No session "${id}" in this workspace.`);
|
|
24898
|
+
if (meta.sizeBytes > limits.sessionBytes) {
|
|
24899
|
+
throw new Error(`Session "${id}" is too large to read (${meta.sizeBytes} bytes; limit ${limits.sessionBytes}).`);
|
|
24900
|
+
}
|
|
24901
|
+
const handle = store.open(meta.id, "read");
|
|
24902
|
+
try {
|
|
24903
|
+
if (!inWorkspace(handle.header.cwd, workspace)) {
|
|
24904
|
+
throw new Error(`Session "${id}" belongs to another workspace.`);
|
|
24905
|
+
}
|
|
24906
|
+
const title = titleFor(handle);
|
|
24907
|
+
return {
|
|
24908
|
+
summary: {
|
|
24909
|
+
id: handle.header.id,
|
|
24910
|
+
...title ? { title } : {},
|
|
24911
|
+
createdAt: handle.header.createdAt,
|
|
24912
|
+
sizeBytes: meta.sizeBytes,
|
|
24913
|
+
...handle.header.parentSession ? { parentSession: handle.header.parentSession } : {}
|
|
24914
|
+
},
|
|
24915
|
+
events: handle.all()
|
|
24916
|
+
};
|
|
24917
|
+
} finally {
|
|
24918
|
+
handle.close();
|
|
24919
|
+
}
|
|
24920
|
+
}
|
|
24921
|
+
function summaryFor(meta, store, limits) {
|
|
24922
|
+
const base = {
|
|
24923
|
+
id: meta.id,
|
|
24924
|
+
createdAt: meta.header.createdAt,
|
|
24925
|
+
sizeBytes: meta.sizeBytes,
|
|
24926
|
+
...meta.header.parentSession ? { parentSession: meta.header.parentSession } : {}
|
|
24927
|
+
};
|
|
24928
|
+
if (meta.sizeBytes > limits.titleBytes)
|
|
24929
|
+
return base;
|
|
24930
|
+
try {
|
|
24931
|
+
const handle = store.open(meta.id, "read");
|
|
24932
|
+
try {
|
|
24933
|
+
const title = titleFor(handle);
|
|
24934
|
+
return title ? { ...base, title } : base;
|
|
24935
|
+
} finally {
|
|
24936
|
+
handle.close();
|
|
24937
|
+
}
|
|
24938
|
+
} catch {
|
|
24939
|
+
return base;
|
|
24940
|
+
}
|
|
24941
|
+
}
|
|
24942
|
+
function createSessionListTool(store, workspace, limits = SESSION_QUERY_LIMITS) {
|
|
24943
|
+
return defineTool({
|
|
24944
|
+
name: "session_list",
|
|
24945
|
+
taskAccess: "read",
|
|
24946
|
+
description: "List the recorded sessions of the current workspace, newest first, with id, title, creation time and size. Use the id with session_read or session_search.",
|
|
24947
|
+
inputSchema: {
|
|
24948
|
+
type: "object",
|
|
24949
|
+
properties: { limit: { type: "integer", minimum: 1, maximum: limits.sessions } },
|
|
24950
|
+
additionalProperties: false
|
|
24951
|
+
},
|
|
24952
|
+
parseInput(value) {
|
|
24953
|
+
if (value === undefined || value === null)
|
|
24954
|
+
return {};
|
|
24955
|
+
const record = asRecord3(value);
|
|
24956
|
+
const limit = integerField(record, "limit", 1, limits.sessions);
|
|
24957
|
+
return limit === undefined ? {} : { limit };
|
|
24958
|
+
},
|
|
24959
|
+
assessRisk() {
|
|
24960
|
+
return { kind: "workspace_file", reason: "List recorded sessions for this workspace.", target: "session:list" };
|
|
24961
|
+
},
|
|
24962
|
+
execute({ limit }) {
|
|
24963
|
+
const all = store.list().filter((meta) => inWorkspace(meta.header.cwd, workspace));
|
|
24964
|
+
const selected = all.slice(0, limit ?? limits.sessions);
|
|
24965
|
+
return {
|
|
24966
|
+
workspace,
|
|
24967
|
+
sessions: selected.map((meta) => summaryFor(meta, store, limits)),
|
|
24968
|
+
truncated: all.length > selected.length
|
|
24969
|
+
};
|
|
24970
|
+
}
|
|
24971
|
+
});
|
|
24972
|
+
}
|
|
24973
|
+
function createSessionSearchTool(store, workspace, limits = SESSION_QUERY_LIMITS) {
|
|
24974
|
+
return defineTool({
|
|
24975
|
+
name: "session_search",
|
|
24976
|
+
taskAccess: "read",
|
|
24977
|
+
description: "Search recorded session events in this workspace for a case-insensitive substring. Returns the session id, sequence number, event type and a short snippet for each match; follow up with session_read.",
|
|
24978
|
+
inputSchema: {
|
|
24979
|
+
type: "object",
|
|
24980
|
+
properties: {
|
|
24981
|
+
query: { type: "string", minLength: 1, maxLength: limits.queryCharacters },
|
|
24982
|
+
session: { type: "string" }
|
|
24983
|
+
},
|
|
24984
|
+
required: ["query"],
|
|
24985
|
+
additionalProperties: false
|
|
24986
|
+
},
|
|
24987
|
+
parseInput(value) {
|
|
24988
|
+
const record = asRecord3(value);
|
|
24989
|
+
const query = stringField(record, "query", limits.queryCharacters);
|
|
24990
|
+
if (query === undefined)
|
|
24991
|
+
throw new TypeError("Expected a non-empty string 'query'.");
|
|
24992
|
+
const session = stringField(record, "session", 256);
|
|
24993
|
+
return session === undefined ? { query } : { query, session };
|
|
24994
|
+
},
|
|
24995
|
+
assessRisk(input) {
|
|
24996
|
+
const target = input.session ? `session:${input.session}` : "session:search";
|
|
24997
|
+
return { kind: "workspace_file", reason: "Search recorded session events for this workspace.", target };
|
|
24998
|
+
},
|
|
24999
|
+
execute({ query, session }) {
|
|
25000
|
+
const needle = query.toLowerCase();
|
|
25001
|
+
const all = store.list().filter((meta) => inWorkspace(meta.header.cwd, workspace));
|
|
25002
|
+
const targets = session ? all.filter((meta) => meta.id === session) : all.slice(0, limits.sessions);
|
|
25003
|
+
if (session !== undefined && targets.length === 0)
|
|
25004
|
+
throw new Error(`No session "${session}" in this workspace.`);
|
|
25005
|
+
const matches = [];
|
|
25006
|
+
const scanned = { sessions: 0, events: 0 };
|
|
25007
|
+
let characters = 0;
|
|
25008
|
+
let bytes = 0;
|
|
25009
|
+
let truncated = false;
|
|
25010
|
+
for (const meta of targets) {
|
|
25011
|
+
if (matches.length >= limits.events || characters >= limits.responseCharacters) {
|
|
25012
|
+
truncated = true;
|
|
25013
|
+
break;
|
|
25014
|
+
}
|
|
25015
|
+
if (bytes + meta.sizeBytes > limits.scanBytes) {
|
|
25016
|
+
truncated = true;
|
|
25017
|
+
break;
|
|
25018
|
+
}
|
|
25019
|
+
let scoped;
|
|
25020
|
+
try {
|
|
25021
|
+
scoped = openScoped(store, workspace, meta.id, limits);
|
|
25022
|
+
} catch {
|
|
25023
|
+
continue;
|
|
25024
|
+
}
|
|
25025
|
+
bytes += meta.sizeBytes;
|
|
25026
|
+
scanned.sessions += 1;
|
|
25027
|
+
for (const event of scoped.events.slice(0, limits.scanEventsPerSession)) {
|
|
25028
|
+
if (matches.length >= limits.events || characters >= limits.responseCharacters) {
|
|
25029
|
+
truncated = true;
|
|
25030
|
+
break;
|
|
25031
|
+
}
|
|
25032
|
+
scanned.events += 1;
|
|
25033
|
+
const haystack = `${event.type} ${serialize2(event.data)}`;
|
|
25034
|
+
if (!haystack.toLowerCase().includes(needle))
|
|
25035
|
+
continue;
|
|
25036
|
+
const snippet = snippetOf(haystack, needle, limits.snippetCharacters);
|
|
25037
|
+
matches.push({ session: meta.id, seq: event.seq, time: event.time, type: event.type, snippet });
|
|
25038
|
+
characters += snippet.length + 64;
|
|
25039
|
+
}
|
|
25040
|
+
}
|
|
25041
|
+
return { query, matches, scanned, truncated };
|
|
25042
|
+
}
|
|
25043
|
+
});
|
|
25044
|
+
}
|
|
25045
|
+
function createSessionReadTool(store, workspace, limits = SESSION_QUERY_LIMITS) {
|
|
25046
|
+
return defineTool({
|
|
25047
|
+
name: "session_read",
|
|
25048
|
+
taskAccess: "read",
|
|
25049
|
+
description: "Read recorded events from one session of this workspace by sequence cursor. Returns seq, time, type and data; oversized data is returned as bounded text.",
|
|
25050
|
+
inputSchema: {
|
|
25051
|
+
type: "object",
|
|
25052
|
+
properties: {
|
|
25053
|
+
session: { type: "string" },
|
|
25054
|
+
before: { type: "integer", minimum: 0 },
|
|
25055
|
+
after: { type: "integer", minimum: 0 },
|
|
25056
|
+
limit: { type: "integer", minimum: 1, maximum: limits.events }
|
|
25057
|
+
},
|
|
25058
|
+
required: ["session"],
|
|
25059
|
+
additionalProperties: false
|
|
25060
|
+
},
|
|
25061
|
+
parseInput(value) {
|
|
25062
|
+
const record = asRecord3(value);
|
|
25063
|
+
const session = stringField(record, "session", 256);
|
|
25064
|
+
if (session === undefined)
|
|
25065
|
+
throw new TypeError("Expected a non-empty string 'session'.");
|
|
25066
|
+
const before = integerField(record, "before", 0, Number.MAX_SAFE_INTEGER);
|
|
25067
|
+
const after = integerField(record, "after", 0, Number.MAX_SAFE_INTEGER);
|
|
25068
|
+
if (before !== undefined && after !== undefined)
|
|
25069
|
+
throw new TypeError("Pass either 'before' or 'after', not both.");
|
|
25070
|
+
const limit = integerField(record, "limit", 1, limits.events);
|
|
25071
|
+
return { session, ...before !== undefined ? { before } : {}, ...after !== undefined ? { after } : {}, ...limit !== undefined ? { limit } : {} };
|
|
25072
|
+
},
|
|
25073
|
+
assessRisk(input) {
|
|
25074
|
+
return { kind: "workspace_file", reason: "Read recorded events from a session of this workspace.", target: `session:${input.session}` };
|
|
25075
|
+
},
|
|
25076
|
+
execute({ session, before, after, limit }) {
|
|
25077
|
+
const scoped = openScoped(store, workspace, session, limits);
|
|
25078
|
+
const candidates = scoped.events.filter((event) => before !== undefined ? event.seq < before : after !== undefined ? event.seq > after : true);
|
|
25079
|
+
const selected = after !== undefined ? candidates.slice(0, limit ?? limits.events) : candidates.slice(-(limit ?? limits.events));
|
|
25080
|
+
const records = [];
|
|
25081
|
+
let characters = 0;
|
|
25082
|
+
let truncated = false;
|
|
25083
|
+
for (const event of selected) {
|
|
25084
|
+
const text = serialize2(event.data);
|
|
25085
|
+
const tooLarge = text.length > limits.eventCharacters;
|
|
25086
|
+
if (characters + Math.min(text.length, limits.eventCharacters) > limits.responseCharacters) {
|
|
25087
|
+
truncated = true;
|
|
25088
|
+
break;
|
|
25089
|
+
}
|
|
25090
|
+
characters += Math.min(text.length, limits.eventCharacters) + 64;
|
|
25091
|
+
records.push({
|
|
25092
|
+
seq: event.seq,
|
|
25093
|
+
time: event.time,
|
|
25094
|
+
type: event.type,
|
|
25095
|
+
...tooLarge ? { dataText: `${text.slice(0, limits.eventCharacters)}\u2026` } : event.data !== undefined ? { data: event.data } : {},
|
|
25096
|
+
dataTruncated: tooLarge
|
|
25097
|
+
});
|
|
25098
|
+
}
|
|
25099
|
+
const first = selected[0];
|
|
25100
|
+
const last = selected[selected.length - 1];
|
|
25101
|
+
return {
|
|
25102
|
+
session: scoped.summary,
|
|
25103
|
+
events: records,
|
|
25104
|
+
hasOlder: first !== undefined && candidates.some((event) => event.seq < first.seq),
|
|
25105
|
+
hasNewer: last !== undefined && candidates.some((event) => event.seq > last.seq),
|
|
25106
|
+
truncated: truncated || records.length < selected.length
|
|
25107
|
+
};
|
|
25108
|
+
}
|
|
25109
|
+
});
|
|
25110
|
+
}
|
|
25111
|
+
function registerSessionQueryTools(registry, options) {
|
|
25112
|
+
if (typeof options.workspace !== "string" || options.workspace.trim().length === 0) {
|
|
25113
|
+
throw new TypeError("Session query tools require a workspace.");
|
|
25114
|
+
}
|
|
25115
|
+
const limits = { ...SESSION_QUERY_LIMITS, ...options.limits };
|
|
25116
|
+
const store = options.store ?? new SessionStore({ cwd: options.workspace });
|
|
25117
|
+
registry.registerAll([
|
|
25118
|
+
createSessionListTool(store, options.workspace, limits),
|
|
25119
|
+
createSessionSearchTool(store, options.workspace, limits),
|
|
25120
|
+
createSessionReadTool(store, options.workspace, limits)
|
|
25121
|
+
]);
|
|
25122
|
+
}
|
|
25123
|
+
var SESSION_QUERY_LIMITS;
|
|
25124
|
+
var init_session_query = __esm(() => {
|
|
25125
|
+
init_src();
|
|
25126
|
+
init_src3();
|
|
25127
|
+
SESSION_QUERY_LIMITS = Object.freeze({
|
|
25128
|
+
sessions: 50,
|
|
25129
|
+
events: 100,
|
|
25130
|
+
sessionBytes: 4 * 1024 * 1024,
|
|
25131
|
+
titleBytes: 256 * 1024,
|
|
25132
|
+
scanBytes: 32 * 1024 * 1024,
|
|
25133
|
+
eventCharacters: 4096,
|
|
25134
|
+
snippetCharacters: 240,
|
|
25135
|
+
queryCharacters: 200,
|
|
25136
|
+
responseCharacters: 60000,
|
|
25137
|
+
scanEventsPerSession: 20000
|
|
25138
|
+
});
|
|
25139
|
+
});
|
|
25140
|
+
|
|
24833
25141
|
// packages/tools/src/index.ts
|
|
24834
25142
|
function registerWorkspaceTools(registry, options) {
|
|
24835
25143
|
const workspace = createWorkspace(options.workspace);
|
|
@@ -24871,6 +25179,7 @@ var init_src7 = __esm(() => {
|
|
|
24871
25179
|
init_write();
|
|
24872
25180
|
init_workspace();
|
|
24873
25181
|
init_ask();
|
|
25182
|
+
init_session_query();
|
|
24874
25183
|
});
|
|
24875
25184
|
|
|
24876
25185
|
// packages/workflow/src/index.ts
|
|
@@ -25016,7 +25325,7 @@ var init_skills2 = __esm(() => {
|
|
|
25016
25325
|
// packages/sdk/src/permissions.ts
|
|
25017
25326
|
import { createHash as createHash2, randomUUID as randomUUID6 } from "crypto";
|
|
25018
25327
|
import { closeSync as closeSync5, existsSync as existsSync3, fstatSync, mkdirSync as mkdirSync11, openSync as openSync5, readSync as readSync2, renameSync as renameSync4, unlinkSync as unlinkSync2, writeFileSync as writeFileSync9 } from "fs";
|
|
25019
|
-
import { join as join12, resolve as
|
|
25328
|
+
import { join as join12, resolve as resolve6 } from "path";
|
|
25020
25329
|
function validateRules(value) {
|
|
25021
25330
|
if (!Array.isArray(value) || value.length > MAX_RULES)
|
|
25022
25331
|
throw new TypeError("Invalid permission rules.");
|
|
@@ -25031,7 +25340,7 @@ class PermissionManager {
|
|
|
25031
25340
|
path;
|
|
25032
25341
|
sessions = new Map;
|
|
25033
25342
|
constructor(workspace) {
|
|
25034
|
-
const key = createHash2("sha256").update(
|
|
25343
|
+
const key = createHash2("sha256").update(resolve6(workspace)).digest("hex");
|
|
25035
25344
|
this.path = join12(ringkoRoot(), "permissions", `${key}.json`);
|
|
25036
25345
|
}
|
|
25037
25346
|
saved() {
|
|
@@ -25285,7 +25594,7 @@ var init_mcp_manager = __esm(() => {
|
|
|
25285
25594
|
});
|
|
25286
25595
|
|
|
25287
25596
|
// packages/sdk/src/runtime.ts
|
|
25288
|
-
import { resolve as
|
|
25597
|
+
import { resolve as resolve7 } from "path";
|
|
25289
25598
|
function applyToolPolicy(agent, workflow) {
|
|
25290
25599
|
for (const tool of agent.tools.list())
|
|
25291
25600
|
if (!workflowAllowsTool(workflow, tool.name))
|
|
@@ -25304,6 +25613,7 @@ function registerRuntimeTools(agent, config, workspace, host = {}, session) {
|
|
|
25304
25613
|
registerSessionTools(agent.tools, { todos, ask: host.ask ?? (async () => {
|
|
25305
25614
|
throw new Error("Questions require an interactive host.");
|
|
25306
25615
|
}) });
|
|
25616
|
+
registerSessionQueryTools(agent.tools, { workspace });
|
|
25307
25617
|
if (config.capabilities?.network)
|
|
25308
25618
|
registerNetworkTools(agent.tools, {
|
|
25309
25619
|
allowPrivateHosts: config.capabilities.privateNetwork === true,
|
|
@@ -25329,7 +25639,7 @@ class RuntimeManager {
|
|
|
25329
25639
|
constructor(workspace, log) {
|
|
25330
25640
|
if (typeof workspace !== "string" || !workspace.trim())
|
|
25331
25641
|
throw new TypeError("Runtime requires a workspace.");
|
|
25332
|
-
this.workspace =
|
|
25642
|
+
this.workspace = resolve7(workspace);
|
|
25333
25643
|
this.permissions = new PermissionManager(this.workspace);
|
|
25334
25644
|
this.mcp = new McpManager(this.workspace);
|
|
25335
25645
|
this.log = log ?? new EventLog;
|
|
@@ -35934,7 +36244,7 @@ function createProviderExecutedToolFactory({
|
|
|
35934
36244
|
supportsDeferredResults
|
|
35935
36245
|
});
|
|
35936
36246
|
}
|
|
35937
|
-
async function
|
|
36247
|
+
async function resolve10(value) {
|
|
35938
36248
|
if (typeof value === "function") {
|
|
35939
36249
|
value = value();
|
|
35940
36250
|
}
|
|
@@ -42080,7 +42390,7 @@ var anthropicErrorDataSchema, anthropicFailedResponseHandler, anthropicUploadFil
|
|
|
42080
42390
|
});
|
|
42081
42391
|
}
|
|
42082
42392
|
async getBatchHeaders(headers) {
|
|
42083
|
-
return combineHeaders(this.options.config.headers ? await
|
|
42393
|
+
return combineHeaders(this.options.config.headers ? await resolve10(this.options.config.headers) : undefined, headers);
|
|
42084
42394
|
}
|
|
42085
42395
|
}, bash_20241022InputSchema, bash_20241022_internal, bash_20250124InputSchema, bash_20250124_internal, computer_20241022InputSchema, computer_20241022, computer_20250124InputSchema, computer_20250124, computer_20251124InputSchema, computer_20251124, memory_20250818InputSchema, memory_20250818, textEditor_20241022InputSchema, textEditor_20241022, textEditor_20250124InputSchema, textEditor_20250124, textEditor_20250429InputSchema, textEditor_20250429, toolSearchBm25_20251119OutputSchema, toolSearchBm25_20251119InputSchema, factory13, toolSearchBm25_20251119 = (args = {}) => {
|
|
42086
42396
|
return factory13(args);
|
|
@@ -42093,7 +42403,7 @@ var anthropicErrorDataSchema, anthropicFailedResponseHandler, anthropicUploadFil
|
|
|
42093
42403
|
return this.config.provider;
|
|
42094
42404
|
}
|
|
42095
42405
|
async getHeaders() {
|
|
42096
|
-
return combineHeaders(await
|
|
42406
|
+
return combineHeaders(await resolve10(this.config.headers), {
|
|
42097
42407
|
"anthropic-beta": "skills-2025-10-02"
|
|
42098
42408
|
});
|
|
42099
42409
|
}
|
|
@@ -44258,10 +44568,10 @@ var init_dist5 = __esm(() => {
|
|
|
44258
44568
|
betas,
|
|
44259
44569
|
headers
|
|
44260
44570
|
}) {
|
|
44261
|
-
return combineHeaders(this.config.headers ? await
|
|
44571
|
+
return combineHeaders(this.config.headers ? await resolve10(this.config.headers) : undefined, headers, betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {});
|
|
44262
44572
|
}
|
|
44263
44573
|
async getBetasFromHeaders(requestHeaders) {
|
|
44264
|
-
const configHeaders = this.config.headers ? await
|
|
44574
|
+
const configHeaders = this.config.headers ? await resolve10(this.config.headers) : undefined;
|
|
44265
44575
|
const configBetaHeader = configHeaders?.["anthropic-beta"] ?? "";
|
|
44266
44576
|
const requestBetaHeader = requestHeaders?.["anthropic-beta"] ?? "";
|
|
44267
44577
|
return new Set([
|
|
@@ -50850,7 +51160,7 @@ var VERSION3 = "4.0.82", googleErrorDataSchema, googleFailedResponseHandler, goo
|
|
|
50850
51160
|
return { ...prepared, warnings: [...warnings, ...prepared.warnings] };
|
|
50851
51161
|
}
|
|
50852
51162
|
async getHeaders(headers) {
|
|
50853
|
-
return combineHeaders(this.batchConfig.headers ? await
|
|
51163
|
+
return combineHeaders(this.batchConfig.headers ? await resolve10(this.batchConfig.headers) : undefined, headers);
|
|
50854
51164
|
}
|
|
50855
51165
|
getBaseOrigin() {
|
|
50856
51166
|
return this.batchConfig.baseURL.replace(/\/v1beta$/, "");
|
|
@@ -51088,7 +51398,7 @@ var VERSION3 = "4.0.82", googleErrorDataSchema, googleFailedResponseHandler, goo
|
|
|
51088
51398
|
}
|
|
51089
51399
|
const videos = [];
|
|
51090
51400
|
const videoMetadata = [];
|
|
51091
|
-
const resolvedHeaders = await
|
|
51401
|
+
const resolvedHeaders = await resolve10(this.config.headers);
|
|
51092
51402
|
const apiKey = resolvedHeaders?.["x-goog-api-key"];
|
|
51093
51403
|
for (const generatedSample of response.generateVideoResponse.generatedSamples) {
|
|
51094
51404
|
if (generatedSample.video?.uri) {
|
|
@@ -51130,7 +51440,7 @@ var VERSION3 = "4.0.82", googleErrorDataSchema, googleFailedResponseHandler, goo
|
|
|
51130
51440
|
const { instances, parameters, warnings } = await this.buildRequest(options);
|
|
51131
51441
|
const { value: operation, responseHeaders } = await postJsonToApi({
|
|
51132
51442
|
url: `${this.config.baseURL}/models/${this.modelId}:predictLongRunning`,
|
|
51133
|
-
headers: combineHeaders(await
|
|
51443
|
+
headers: combineHeaders(await resolve10(this.config.headers), options.headers),
|
|
51134
51444
|
body: {
|
|
51135
51445
|
instances,
|
|
51136
51446
|
parameters
|
|
@@ -51163,7 +51473,7 @@ var VERSION3 = "4.0.82", googleErrorDataSchema, googleFailedResponseHandler, goo
|
|
|
51163
51473
|
const { value: statusOperation, responseHeaders } = await getFromApi({
|
|
51164
51474
|
url: `${this.config.baseURL}/${operationName}`,
|
|
51165
51475
|
validateUrl: false,
|
|
51166
|
-
headers: combineHeaders(await
|
|
51476
|
+
headers: combineHeaders(await resolve10(this.config.headers), options.headers),
|
|
51167
51477
|
successfulResponseHandler: createJsonResponseHandler(googleOperationSchema),
|
|
51168
51478
|
failedResponseHandler: googleFailedResponseHandler,
|
|
51169
51479
|
abortSignal: options.abortSignal,
|
|
@@ -51813,7 +52123,7 @@ var init_dist6 = __esm(() => {
|
|
|
51813
52123
|
values
|
|
51814
52124
|
});
|
|
51815
52125
|
}
|
|
51816
|
-
const mergedHeaders = combineHeaders(this.config.headers ? await
|
|
52126
|
+
const mergedHeaders = combineHeaders(this.config.headers ? await resolve10(this.config.headers) : undefined, headers);
|
|
51817
52127
|
const multimodalContent = googleOptions?.content;
|
|
51818
52128
|
validateMultimodalContentLength({ multimodalContent, values });
|
|
51819
52129
|
if (values.length === 1) {
|
|
@@ -52397,7 +52707,7 @@ var init_dist6 = __esm(() => {
|
|
|
52397
52707
|
extraHeaders,
|
|
52398
52708
|
toolNameMapping
|
|
52399
52709
|
} = await this.getArgs(options);
|
|
52400
|
-
const mergedHeaders = combineHeaders(this.config.headers ? await
|
|
52710
|
+
const mergedHeaders = combineHeaders(this.config.headers ? await resolve10(this.config.headers) : undefined, options.headers, extraHeaders);
|
|
52401
52711
|
const {
|
|
52402
52712
|
responseHeaders,
|
|
52403
52713
|
value: response,
|
|
@@ -52437,7 +52747,7 @@ var init_dist6 = __esm(() => {
|
|
|
52437
52747
|
toolNameMapping
|
|
52438
52748
|
} = await this.getArgs(options, { isStreaming: true });
|
|
52439
52749
|
const wrapProviderMetadata = (payload) => Object.fromEntries(providerOptionsNames.map((name) => [name, payload]));
|
|
52440
|
-
const headers = combineHeaders(this.config.headers ? await
|
|
52750
|
+
const headers = combineHeaders(this.config.headers ? await resolve10(this.config.headers) : undefined, options.headers, extraHeaders);
|
|
52441
52751
|
const { responseHeaders, value: response } = await postJsonToApi({
|
|
52442
52752
|
url: `${this.config.baseURL}/${getModelPath(this.modelId)}:streamGenerateContent?alt=sse`,
|
|
52443
52753
|
headers,
|
|
@@ -53439,7 +53749,7 @@ var init_dist6 = __esm(() => {
|
|
|
53439
53749
|
rawValue: rawResponse
|
|
53440
53750
|
} = await postJsonToApi({
|
|
53441
53751
|
url: `${this.config.baseURL}/models/${this.modelId}:generateContent`,
|
|
53442
|
-
headers: combineHeaders(this.config.headers ? await
|
|
53752
|
+
headers: combineHeaders(this.config.headers ? await resolve10(this.config.headers) : undefined, options.headers),
|
|
53443
53753
|
body: requestBody,
|
|
53444
53754
|
failedResponseHandler: googleFailedResponseHandler,
|
|
53445
53755
|
successfulResponseHandler: createJsonResponseHandler(googleSpeechResponseSchema),
|
|
@@ -54121,7 +54431,7 @@ var init_dist6 = __esm(() => {
|
|
|
54121
54431
|
async doGenerate(options) {
|
|
54122
54432
|
const { args, warnings, isAgent, pollingTimeoutMs } = await this.getArgs(options);
|
|
54123
54433
|
const url = `${this.config.baseURL}/interactions`;
|
|
54124
|
-
const mergedHeaders = combineHeaders(this.config.headers ? await
|
|
54434
|
+
const mergedHeaders = combineHeaders(this.config.headers ? await resolve10(this.config.headers) : undefined, options.headers);
|
|
54125
54435
|
const postResult = await postJsonToApi({
|
|
54126
54436
|
url,
|
|
54127
54437
|
headers: mergedHeaders,
|
|
@@ -54197,7 +54507,7 @@ var init_dist6 = __esm(() => {
|
|
|
54197
54507
|
async doStream(options) {
|
|
54198
54508
|
const { args, warnings, isBackground, pollingTimeoutMs } = await this.getArgs(options);
|
|
54199
54509
|
const url = `${this.config.baseURL}/interactions`;
|
|
54200
|
-
const mergedHeaders = combineHeaders(this.config.headers ? await
|
|
54510
|
+
const mergedHeaders = combineHeaders(this.config.headers ? await resolve10(this.config.headers) : undefined, options.headers);
|
|
54201
54511
|
if (isBackground) {
|
|
54202
54512
|
return this.doStreamBackground({
|
|
54203
54513
|
args,
|
|
@@ -54348,7 +54658,7 @@ var init_dist6 = __esm(() => {
|
|
|
54348
54658
|
rawValue: rawResponse
|
|
54349
54659
|
} = await postJsonToApi({
|
|
54350
54660
|
url: `${this.config.baseURL}/interactions`,
|
|
54351
|
-
headers: combineHeaders(this.config.headers ? await
|
|
54661
|
+
headers: combineHeaders(this.config.headers ? await resolve10(this.config.headers) : undefined, options.headers),
|
|
54352
54662
|
body: requestBody,
|
|
54353
54663
|
failedResponseHandler: googleFailedResponseHandler,
|
|
54354
54664
|
successfulResponseHandler: createJsonResponseHandler(googleInteractionsTranscriptionResponseSchema),
|
|
@@ -54404,7 +54714,7 @@ var init_dist6 = __esm(() => {
|
|
|
54404
54714
|
const warnings = [];
|
|
54405
54715
|
const googleOptions = await this.parseOptions(options.providerOptions);
|
|
54406
54716
|
validateLiveInputAudioFormat(options.inputAudioFormat);
|
|
54407
|
-
const headers = combineHeaders(this.config.headers ? await
|
|
54717
|
+
const headers = combineHeaders(this.config.headers ? await resolve10(this.config.headers) : undefined, options.headers);
|
|
54408
54718
|
let apiKey;
|
|
54409
54719
|
for (const [key, value] of Object.entries(headers)) {
|
|
54410
54720
|
if (key.toLowerCase() === "x-goog-api-key" && value != null) {
|
|
@@ -54732,21 +55042,21 @@ function createOpenAIStreamError({
|
|
|
54732
55042
|
});
|
|
54733
55043
|
}
|
|
54734
55044
|
function parseStreamError(frame) {
|
|
54735
|
-
const value =
|
|
55045
|
+
const value = asRecord4(frame);
|
|
54736
55046
|
if (value == null) {
|
|
54737
55047
|
return;
|
|
54738
55048
|
}
|
|
54739
55049
|
if (value.type === "response.failed") {
|
|
54740
|
-
const response =
|
|
54741
|
-
const responseError =
|
|
55050
|
+
const response = asRecord4(value.response);
|
|
55051
|
+
const responseError = asRecord4(response?.error);
|
|
54742
55052
|
return typeof responseError?.message === "string" ? {
|
|
54743
55053
|
message: responseError.message,
|
|
54744
55054
|
code: getStringOrNumber(responseError.code),
|
|
54745
55055
|
type: "response.failed"
|
|
54746
55056
|
} : undefined;
|
|
54747
55057
|
}
|
|
54748
|
-
const error =
|
|
54749
|
-
return typeof error.message === "string" && (
|
|
55058
|
+
const error = asRecord4(value.error) ?? value;
|
|
55059
|
+
return typeof error.message === "string" && (asRecord4(value.error) != null || typeof error.type === "string" || ("code" in error) || ("param" in error)) ? {
|
|
54750
55060
|
message: error.message,
|
|
54751
55061
|
code: getStringOrNumber(error.code),
|
|
54752
55062
|
type: typeof error.type === "string" ? error.type : undefined
|
|
@@ -54776,7 +55086,7 @@ function getStatusCode(error) {
|
|
|
54776
55086
|
return 504;
|
|
54777
55087
|
return 500;
|
|
54778
55088
|
}
|
|
54779
|
-
function
|
|
55089
|
+
function asRecord4(value) {
|
|
54780
55090
|
return typeof value === "object" && value != null ? value : undefined;
|
|
54781
55091
|
}
|
|
54782
55092
|
function getStringOrNumber(value) {
|
|
@@ -68216,7 +68526,7 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68216
68526
|
const { value } = await getFromApi({
|
|
68217
68527
|
url: `${this.config.baseURL}/config`,
|
|
68218
68528
|
validateUrl: false,
|
|
68219
|
-
headers: this.config.headers ? await
|
|
68529
|
+
headers: this.config.headers ? await resolve10(this.config.headers) : undefined,
|
|
68220
68530
|
successfulResponseHandler: createJsonResponseHandler(gatewayAvailableModelsResponseSchema),
|
|
68221
68531
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
68222
68532
|
errorSchema: z.any(),
|
|
@@ -68235,7 +68545,7 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68235
68545
|
const { value } = await getFromApi({
|
|
68236
68546
|
url: `${baseUrl.origin}/v1/credits`,
|
|
68237
68547
|
validateUrl: false,
|
|
68238
|
-
headers: this.config.headers ? await
|
|
68548
|
+
headers: this.config.headers ? await resolve10(this.config.headers) : undefined,
|
|
68239
68549
|
successfulResponseHandler: createJsonResponseHandler(gatewayCreditsResponseSchema),
|
|
68240
68550
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
68241
68551
|
errorSchema: z.any(),
|
|
@@ -68282,7 +68592,7 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68282
68592
|
const { value } = await getFromApi({
|
|
68283
68593
|
url: `${baseUrl.origin}/v1/report?${searchParams.toString()}`,
|
|
68284
68594
|
validateUrl: false,
|
|
68285
|
-
headers: this.config.headers ? await
|
|
68595
|
+
headers: this.config.headers ? await resolve10(this.config.headers) : undefined,
|
|
68286
68596
|
successfulResponseHandler: createJsonResponseHandler(gatewaySpendReportResponseSchema),
|
|
68287
68597
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
68288
68598
|
errorSchema: z.any(),
|
|
@@ -68305,7 +68615,7 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68305
68615
|
const { value } = await getFromApi({
|
|
68306
68616
|
url: `${baseUrl.origin}/v1/generation?id=${encodeURIComponent(params.id)}`,
|
|
68307
68617
|
validateUrl: false,
|
|
68308
|
-
headers: this.config.headers ? await
|
|
68618
|
+
headers: this.config.headers ? await resolve10(this.config.headers) : undefined,
|
|
68309
68619
|
successfulResponseHandler: createJsonResponseHandler(gatewayGenerationInfoResponseSchema),
|
|
68310
68620
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
68311
68621
|
errorSchema: z.any(),
|
|
@@ -68334,13 +68644,13 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68334
68644
|
}) {
|
|
68335
68645
|
assertTextBatchRequests3(requests);
|
|
68336
68646
|
const modelId = validateSingleModel2(requests);
|
|
68337
|
-
const resolvedHeaders = this.config.headers ? await
|
|
68647
|
+
const resolvedHeaders = this.config.headers ? await resolve10(this.config.headers) : undefined;
|
|
68338
68648
|
const idempotencyKey = getGatewayBatchIdempotencyKey(providerOptions);
|
|
68339
68649
|
const forwardedProviderOptions = omitGatewayIdempotencyKey(providerOptions);
|
|
68340
68650
|
try {
|
|
68341
68651
|
const { value: responseBody } = await postJsonToApi({
|
|
68342
68652
|
url: this.getBatchUrl("start"),
|
|
68343
|
-
headers: combineHeaders(resolvedHeaders, headers, { "ai-model-id": modelId }, await
|
|
68653
|
+
headers: combineHeaders(resolvedHeaders, headers, { "ai-model-id": modelId }, await resolve10(this.config.o11yHeaders), idempotencyKey != null ? { "idempotency-key": idempotencyKey } : undefined),
|
|
68344
68654
|
body: {
|
|
68345
68655
|
...webhookUrl != null && { callbackUrl: webhookUrl },
|
|
68346
68656
|
requests: requests.map((request) => ({
|
|
@@ -68378,11 +68688,11 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68378
68688
|
headers,
|
|
68379
68689
|
abortSignal
|
|
68380
68690
|
}) {
|
|
68381
|
-
const resolvedHeaders = this.config.headers ? await
|
|
68691
|
+
const resolvedHeaders = this.config.headers ? await resolve10(this.config.headers) : undefined;
|
|
68382
68692
|
try {
|
|
68383
68693
|
const { value: responseBody } = await postJsonToApi({
|
|
68384
68694
|
url: this.getBatchUrl("status"),
|
|
68385
|
-
headers: combineHeaders(resolvedHeaders, headers, await
|
|
68695
|
+
headers: combineHeaders(resolvedHeaders, headers, await resolve10(this.config.o11yHeaders)),
|
|
68386
68696
|
body: { batchId },
|
|
68387
68697
|
successfulResponseHandler: createJsonResponseHandler(gatewayBatchStatusResponseSchema),
|
|
68388
68698
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
@@ -68405,11 +68715,11 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68405
68715
|
headers,
|
|
68406
68716
|
abortSignal
|
|
68407
68717
|
}) {
|
|
68408
|
-
const resolvedHeaders = this.config.headers ? await
|
|
68718
|
+
const resolvedHeaders = this.config.headers ? await resolve10(this.config.headers) : undefined;
|
|
68409
68719
|
try {
|
|
68410
68720
|
const { value: lines } = await postJsonToApi({
|
|
68411
68721
|
url: this.getBatchUrl("results"),
|
|
68412
|
-
headers: combineHeaders(resolvedHeaders, headers, await
|
|
68722
|
+
headers: combineHeaders(resolvedHeaders, headers, await resolve10(this.config.o11yHeaders)),
|
|
68413
68723
|
body: { batchId },
|
|
68414
68724
|
successfulResponseHandler: createJsonLinesResponseHandler(gatewayBatchItemResultLineSchema),
|
|
68415
68725
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
@@ -68432,11 +68742,11 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68432
68742
|
headers,
|
|
68433
68743
|
abortSignal
|
|
68434
68744
|
}) {
|
|
68435
|
-
const resolvedHeaders = this.config.headers ? await
|
|
68745
|
+
const resolvedHeaders = this.config.headers ? await resolve10(this.config.headers) : undefined;
|
|
68436
68746
|
try {
|
|
68437
68747
|
const { value: responseBody } = await postJsonToApi({
|
|
68438
68748
|
url: this.getBatchUrl("cancel"),
|
|
68439
|
-
headers: combineHeaders(resolvedHeaders, headers, await
|
|
68749
|
+
headers: combineHeaders(resolvedHeaders, headers, await resolve10(this.config.o11yHeaders)),
|
|
68440
68750
|
body: { batchId },
|
|
68441
68751
|
successfulResponseHandler: createJsonResponseHandler(gatewayBatchStatusResponseSchema),
|
|
68442
68752
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
@@ -68473,11 +68783,11 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68473
68783
|
}
|
|
68474
68784
|
async doGenerate(options) {
|
|
68475
68785
|
const { headers, abortSignal } = options;
|
|
68476
|
-
const resolvedHeaders = this.config.headers ? await
|
|
68786
|
+
const resolvedHeaders = this.config.headers ? await resolve10(this.config.headers) : undefined;
|
|
68477
68787
|
try {
|
|
68478
68788
|
const { responseHeaders, value: responseBody } = await postJsonToApi({
|
|
68479
68789
|
url: this.getUrl(),
|
|
68480
|
-
headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await
|
|
68790
|
+
headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await resolve10(this.config.o11yHeaders), { accept: "text/event-stream" }),
|
|
68481
68791
|
body: this.buildRequestBody(options),
|
|
68482
68792
|
successfulResponseHandler: async ({
|
|
68483
68793
|
response,
|
|
@@ -68572,11 +68882,11 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68572
68882
|
}
|
|
68573
68883
|
async doStart(options) {
|
|
68574
68884
|
const { headers, abortSignal, webhookUrl } = options;
|
|
68575
|
-
const resolvedHeaders = this.config.headers ? await
|
|
68885
|
+
const resolvedHeaders = this.config.headers ? await resolve10(this.config.headers) : undefined;
|
|
68576
68886
|
try {
|
|
68577
68887
|
const { responseHeaders, value: responseBody } = await postJsonToApi({
|
|
68578
68888
|
url: this.getStartUrl(),
|
|
68579
|
-
headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await
|
|
68889
|
+
headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await resolve10(this.config.o11yHeaders)),
|
|
68580
68890
|
body: {
|
|
68581
68891
|
...this.buildRequestBody(options),
|
|
68582
68892
|
...webhookUrl && { callbackUrl: webhookUrl }
|
|
@@ -68608,11 +68918,11 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68608
68918
|
abortSignal,
|
|
68609
68919
|
headers
|
|
68610
68920
|
}) {
|
|
68611
|
-
const resolvedHeaders = this.config.headers ? await
|
|
68921
|
+
const resolvedHeaders = this.config.headers ? await resolve10(this.config.headers) : undefined;
|
|
68612
68922
|
try {
|
|
68613
68923
|
const { responseHeaders, value: responseBody } = await postJsonToApi({
|
|
68614
68924
|
url: this.getStatusUrl(),
|
|
68615
|
-
headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await
|
|
68925
|
+
headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await resolve10(this.config.o11yHeaders)),
|
|
68616
68926
|
body: { operation },
|
|
68617
68927
|
successfulResponseHandler: createJsonResponseHandler(gatewayVideoStatusResponseSchema),
|
|
68618
68928
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
@@ -68736,7 +69046,7 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68736
69046
|
schema: gatewayEvaluationProviderOptionsSchema
|
|
68737
69047
|
});
|
|
68738
69048
|
const validatedProviderOptions = gatewayOptions == null ? providerOptions : { ...providerOptions, gateway: gatewayOptions };
|
|
68739
|
-
const resolvedHeaders = this.config.headers ? await
|
|
69049
|
+
const resolvedHeaders = this.config.headers ? await resolve10(this.config.headers) : undefined;
|
|
68740
69050
|
try {
|
|
68741
69051
|
const {
|
|
68742
69052
|
responseHeaders,
|
|
@@ -68744,7 +69054,7 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68744
69054
|
rawValue
|
|
68745
69055
|
} = await postJsonToApi({
|
|
68746
69056
|
url: this.getUrl(),
|
|
68747
|
-
headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await
|
|
69057
|
+
headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await resolve10(this.config.o11yHeaders)),
|
|
68748
69058
|
body: {
|
|
68749
69059
|
state,
|
|
68750
69060
|
questions,
|
|
@@ -68800,7 +69110,7 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68800
69110
|
abortSignal,
|
|
68801
69111
|
providerOptions
|
|
68802
69112
|
}) {
|
|
68803
|
-
const resolvedHeaders = this.config.headers ? await
|
|
69113
|
+
const resolvedHeaders = this.config.headers ? await resolve10(this.config.headers) : undefined;
|
|
68804
69114
|
try {
|
|
68805
69115
|
const {
|
|
68806
69116
|
responseHeaders,
|
|
@@ -68808,7 +69118,7 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68808
69118
|
rawValue
|
|
68809
69119
|
} = await postJsonToApi({
|
|
68810
69120
|
url: this.getUrl(),
|
|
68811
|
-
headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await
|
|
69121
|
+
headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await resolve10(this.config.o11yHeaders)),
|
|
68812
69122
|
body: {
|
|
68813
69123
|
documents,
|
|
68814
69124
|
query,
|
|
@@ -68862,7 +69172,7 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68862
69172
|
headers,
|
|
68863
69173
|
abortSignal
|
|
68864
69174
|
}) {
|
|
68865
|
-
const resolvedHeaders = this.config.headers ? await
|
|
69175
|
+
const resolvedHeaders = this.config.headers ? await resolve10(this.config.headers) : undefined;
|
|
68866
69176
|
try {
|
|
68867
69177
|
const {
|
|
68868
69178
|
responseHeaders,
|
|
@@ -68870,7 +69180,7 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68870
69180
|
rawValue
|
|
68871
69181
|
} = await postJsonToApi({
|
|
68872
69182
|
url: this.getUrl(),
|
|
68873
|
-
headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await
|
|
69183
|
+
headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await resolve10(this.config.o11yHeaders)),
|
|
68874
69184
|
body: {
|
|
68875
69185
|
text,
|
|
68876
69186
|
...voice && { voice },
|
|
@@ -68928,7 +69238,7 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68928
69238
|
headers,
|
|
68929
69239
|
abortSignal
|
|
68930
69240
|
}) {
|
|
68931
|
-
const resolvedHeaders = this.config.headers ? await
|
|
69241
|
+
const resolvedHeaders = this.config.headers ? await resolve10(this.config.headers) : undefined;
|
|
68932
69242
|
try {
|
|
68933
69243
|
const {
|
|
68934
69244
|
responseHeaders,
|
|
@@ -68936,7 +69246,7 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68936
69246
|
rawValue
|
|
68937
69247
|
} = await postJsonToApi({
|
|
68938
69248
|
url: this.getUrl(),
|
|
68939
|
-
headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await
|
|
69249
|
+
headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await resolve10(this.config.o11yHeaders)),
|
|
68940
69250
|
body: {
|
|
68941
69251
|
audio: audio instanceof Uint8Array ? convertUint8ArrayToBase64(audio) : audio,
|
|
68942
69252
|
mediaType,
|
|
@@ -68970,7 +69280,7 @@ var import_oidc, import_oidc2, GATEWAY_REALTIME_SUBPROTOCOL = "ai-gateway-realti
|
|
|
68970
69280
|
}
|
|
68971
69281
|
async doStream(options) {
|
|
68972
69282
|
const currentDate = this.config._internal?.currentDate?.() ?? /* @__PURE__ */ new Date;
|
|
68973
|
-
const headers = combineHeaders(await
|
|
69283
|
+
const headers = combineHeaders(await resolve10(this.config.headers ?? {}), options.headers ?? {}, this.getModelConfigHeaders(), await resolve10(this.config.o11yHeaders));
|
|
68974
69284
|
const authMethod = await parseAuthMethod(headers);
|
|
68975
69285
|
const startFrame = {
|
|
68976
69286
|
type: TRANSCRIPTION_STREAM_START_FRAME_TYPE,
|
|
@@ -69575,7 +69885,7 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
69575
69885
|
async doGenerate(options) {
|
|
69576
69886
|
const { args, warnings } = await this.getArgs(options);
|
|
69577
69887
|
const { abortSignal } = options;
|
|
69578
|
-
const resolvedHeaders = this.config.headers ? await
|
|
69888
|
+
const resolvedHeaders = this.config.headers ? await resolve10(this.config.headers) : undefined;
|
|
69579
69889
|
try {
|
|
69580
69890
|
const {
|
|
69581
69891
|
responseHeaders,
|
|
@@ -69583,7 +69893,7 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
69583
69893
|
rawValue: rawResponse
|
|
69584
69894
|
} = await postJsonToApi({
|
|
69585
69895
|
url: this.getUrl(),
|
|
69586
|
-
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, false), await
|
|
69896
|
+
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, false), await resolve10(this.config.o11yHeaders)),
|
|
69587
69897
|
body: args,
|
|
69588
69898
|
successfulResponseHandler: createJsonResponseHandler(z.any()),
|
|
69589
69899
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
@@ -69606,11 +69916,11 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
69606
69916
|
async doStream(options) {
|
|
69607
69917
|
const { args, warnings } = await this.getArgs(options);
|
|
69608
69918
|
const { abortSignal } = options;
|
|
69609
|
-
const resolvedHeaders = this.config.headers ? await
|
|
69919
|
+
const resolvedHeaders = this.config.headers ? await resolve10(this.config.headers) : undefined;
|
|
69610
69920
|
try {
|
|
69611
69921
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
69612
69922
|
url: this.getUrl(),
|
|
69613
|
-
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, true), await
|
|
69923
|
+
headers: combineHeaders(resolvedHeaders, options.headers, this.getModelConfigHeaders(this.modelId, true), await resolve10(this.config.o11yHeaders)),
|
|
69614
69924
|
body: args,
|
|
69615
69925
|
successfulResponseHandler: createEventSourceResponseHandler(z.any()),
|
|
69616
69926
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
@@ -69705,7 +70015,7 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
69705
70015
|
abortSignal,
|
|
69706
70016
|
providerOptions
|
|
69707
70017
|
}) {
|
|
69708
|
-
const resolvedHeaders = this.config.headers ? await
|
|
70018
|
+
const resolvedHeaders = this.config.headers ? await resolve10(this.config.headers) : undefined;
|
|
69709
70019
|
try {
|
|
69710
70020
|
const {
|
|
69711
70021
|
responseHeaders,
|
|
@@ -69713,7 +70023,7 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
69713
70023
|
rawValue
|
|
69714
70024
|
} = await postJsonToApi({
|
|
69715
70025
|
url: this.getUrl(),
|
|
69716
|
-
headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await
|
|
70026
|
+
headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await resolve10(this.config.o11yHeaders)),
|
|
69717
70027
|
body: {
|
|
69718
70028
|
values,
|
|
69719
70029
|
...providerOptions ? { providerOptions } : {}
|
|
@@ -69805,11 +70115,11 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
69805
70115
|
headers,
|
|
69806
70116
|
abortSignal
|
|
69807
70117
|
}) {
|
|
69808
|
-
const resolvedHeaders = this.config.headers ? await
|
|
70118
|
+
const resolvedHeaders = this.config.headers ? await resolve10(this.config.headers) : undefined;
|
|
69809
70119
|
try {
|
|
69810
70120
|
const { responseHeaders, value: responseBody } = await postJsonToApi({
|
|
69811
70121
|
url: this.getUrl(),
|
|
69812
|
-
headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await
|
|
70122
|
+
headers: combineHeaders(resolvedHeaders, headers ?? {}, this.getModelConfigHeaders(), await resolve10(this.config.o11yHeaders)),
|
|
69813
70123
|
body: {
|
|
69814
70124
|
prompt,
|
|
69815
70125
|
n,
|
|
@@ -76995,12 +77305,12 @@ function normalizeStreamProviderError(error) {
|
|
|
76995
77305
|
if (isError(error) || AISDKError.isInstance(error) || StreamProviderError.isInstance(error)) {
|
|
76996
77306
|
return error;
|
|
76997
77307
|
}
|
|
76998
|
-
const outer =
|
|
77308
|
+
const outer = asRecord5(error);
|
|
76999
77309
|
if (outer == null) {
|
|
77000
77310
|
return error;
|
|
77001
77311
|
}
|
|
77002
77312
|
const providerStreamError = isProviderStreamError(error);
|
|
77003
|
-
const details = providerStreamError ? outer :
|
|
77313
|
+
const details = providerStreamError ? outer : asRecord5(asRecord5(outer.response)?.error) ?? asRecord5(outer.error) ?? outer;
|
|
77004
77314
|
if (typeof details.message !== "string") {
|
|
77005
77315
|
return error;
|
|
77006
77316
|
}
|
|
@@ -77036,7 +77346,7 @@ function inferExactMessageMetadata(message) {
|
|
|
77036
77346
|
function isRetryableStatusCode22(statusCode) {
|
|
77037
77347
|
return statusCode != null && (statusCode === 408 || statusCode === 409 || statusCode === 429 || statusCode >= 500);
|
|
77038
77348
|
}
|
|
77039
|
-
function
|
|
77349
|
+
function asRecord5(value) {
|
|
77040
77350
|
return typeof value === "object" && value != null ? value : undefined;
|
|
77041
77351
|
}
|
|
77042
77352
|
function isError(value) {
|
|
@@ -78044,7 +78354,7 @@ var __defProp2, __export2 = (target, all) => {
|
|
|
78044
78354
|
const schema = asSchema(inputSchema);
|
|
78045
78355
|
return {
|
|
78046
78356
|
name: "object",
|
|
78047
|
-
responseFormat:
|
|
78357
|
+
responseFormat: resolve10(schema.jsonSchema).then((jsonSchema3) => ({
|
|
78048
78358
|
type: "json",
|
|
78049
78359
|
schema: jsonSchema3,
|
|
78050
78360
|
...name25 != null && { name: name25 },
|
|
@@ -78116,7 +78426,7 @@ var __defProp2, __export2 = (target, all) => {
|
|
|
78116
78426
|
const elementSchema = asSchema(inputElementSchema);
|
|
78117
78427
|
return {
|
|
78118
78428
|
name: "array",
|
|
78119
|
-
responseFormat:
|
|
78429
|
+
responseFormat: resolve10(elementSchema.jsonSchema).then((jsonSchema3) => {
|
|
78120
78430
|
const {
|
|
78121
78431
|
$schema: _$schema,
|
|
78122
78432
|
definitions,
|
|
@@ -81594,7 +81904,7 @@ function tokenCount(value) {
|
|
|
81594
81904
|
}
|
|
81595
81905
|
return;
|
|
81596
81906
|
}
|
|
81597
|
-
function
|
|
81907
|
+
function asRecord6(value) {
|
|
81598
81908
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined;
|
|
81599
81909
|
}
|
|
81600
81910
|
function providerErrorFields(body) {
|
|
@@ -81605,8 +81915,8 @@ function providerErrorFields(body) {
|
|
|
81605
81915
|
} catch {
|
|
81606
81916
|
return fields;
|
|
81607
81917
|
}
|
|
81608
|
-
const outer =
|
|
81609
|
-
const error =
|
|
81918
|
+
const outer = asRecord6(parsed);
|
|
81919
|
+
const error = asRecord6(outer?.error) ?? outer;
|
|
81610
81920
|
if (!error)
|
|
81611
81921
|
return fields;
|
|
81612
81922
|
for (const key of ["code", "param", "type"]) {
|
|
@@ -81617,7 +81927,7 @@ function providerErrorFields(body) {
|
|
|
81617
81927
|
return fields;
|
|
81618
81928
|
}
|
|
81619
81929
|
function describeModelError(error) {
|
|
81620
|
-
const record =
|
|
81930
|
+
const record = asRecord6(error);
|
|
81621
81931
|
if (record) {
|
|
81622
81932
|
const parts = [];
|
|
81623
81933
|
if (typeof record.message === "string" && record.message.length > 0)
|
|
@@ -82068,13 +82378,13 @@ function codexModelsRequest(access, accountId) {
|
|
|
82068
82378
|
}
|
|
82069
82379
|
};
|
|
82070
82380
|
}
|
|
82071
|
-
function
|
|
82381
|
+
function asRecord7(value) {
|
|
82072
82382
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : undefined;
|
|
82073
82383
|
}
|
|
82074
82384
|
function toModel(value) {
|
|
82075
82385
|
if (typeof value === "string" && value.length > 0)
|
|
82076
82386
|
return { id: value };
|
|
82077
|
-
const record =
|
|
82387
|
+
const record = asRecord7(value);
|
|
82078
82388
|
if (!record)
|
|
82079
82389
|
return;
|
|
82080
82390
|
const id = record.id ?? record.slug ?? record.name ?? record.model;
|
|
@@ -82084,7 +82394,7 @@ function toModel(value) {
|
|
|
82084
82394
|
return { id, ...typeof name === "string" && name.length > 0 ? { name } : {} };
|
|
82085
82395
|
}
|
|
82086
82396
|
function normalizeModels(payload) {
|
|
82087
|
-
const record =
|
|
82397
|
+
const record = asRecord7(payload);
|
|
82088
82398
|
const candidates = Array.isArray(payload) ? payload : Array.isArray(record?.data) ? record.data : Array.isArray(record?.models) ? record.models : [];
|
|
82089
82399
|
const seen = new Set;
|
|
82090
82400
|
const models = [];
|
|
@@ -125360,7 +125670,7 @@ var init_model = __esm(() => {
|
|
|
125360
125670
|
import { execFile } from "child_process";
|
|
125361
125671
|
import { constants as constants2 } from "fs";
|
|
125362
125672
|
import { lstat as lstat2, open as open3, opendir as opendir2, realpath as realpath3 } from "fs/promises";
|
|
125363
|
-
import { isAbsolute as isAbsolute5, join as join14, relative as relative5, resolve as
|
|
125673
|
+
import { isAbsolute as isAbsolute5, join as join14, relative as relative5, resolve as resolve11, sep as sep3 } from "path";
|
|
125364
125674
|
import { promisify } from "util";
|
|
125365
125675
|
|
|
125366
125676
|
class WorkspaceReview {
|
|
@@ -125372,7 +125682,7 @@ class WorkspaceReview {
|
|
|
125372
125682
|
if (typeof path !== "string" || path.length > REVIEW_LIMITS.path || path.includes("\x00") || isAbsolute5(path) || path.split(/[\\/]/).some((part) => part === ".." || part.includes(":")))
|
|
125373
125683
|
throw new Error("Invalid workspace-relative path.");
|
|
125374
125684
|
const root = await realpath3(this.root);
|
|
125375
|
-
const candidate =
|
|
125685
|
+
const candidate = resolve11(root, path || ".");
|
|
125376
125686
|
const rel = relative5(root, candidate);
|
|
125377
125687
|
if (isAbsolute5(rel) || rel === ".." || rel.startsWith(`..${sep3}`))
|
|
125378
125688
|
throw new Error("Path is outside the workspace.");
|
|
@@ -125565,7 +125875,7 @@ import { randomUUID as randomUUID9 } from "crypto";
|
|
|
125565
125875
|
import { existsSync as existsSync5, mkdirSync as mkdirSync12, readdirSync as readdirSync3, statSync as statSync6 } from "fs";
|
|
125566
125876
|
import { readFile as readFile4 } from "fs/promises";
|
|
125567
125877
|
import { homedir as homedir3 } from "os";
|
|
125568
|
-
import { basename as basename3, dirname as dirname11, extname, join as join15, relative as relative6, resolve as
|
|
125878
|
+
import { basename as basename3, dirname as dirname11, extname, join as join15, relative as relative6, resolve as resolve12, sep as sep4 } from "path";
|
|
125569
125879
|
function json3(data, status = 200) {
|
|
125570
125880
|
return new Response(JSON.stringify(data), {
|
|
125571
125881
|
status,
|
|
@@ -125613,9 +125923,9 @@ function startServer(options = {}) {
|
|
|
125613
125923
|
throw new Error("Shared backends only support loopback hosts. Unset RINGKO_HOST or use 127.0.0.1.");
|
|
125614
125924
|
const configuredPort = Number(process.env.RINGKO_PORT);
|
|
125615
125925
|
const port = options.port ?? (Number.isInteger(configuredPort) && configuredPort > 0 ? configuredPort : DEFAULT_PORT);
|
|
125616
|
-
let workspace =
|
|
125617
|
-
const bundledWebuiDir =
|
|
125618
|
-
const webuiDir =
|
|
125926
|
+
let workspace = resolve12(options.workspace ?? process.cwd());
|
|
125927
|
+
const bundledWebuiDir = resolve12(import.meta.dir, "../webui");
|
|
125928
|
+
const webuiDir = resolve12(options.webuiDir ?? process.env.RINGKO_WEBUI_DIR ?? (existsSync5(join15(DEFAULT_WEBUI_DIR, "index.html")) ? DEFAULT_WEBUI_DIR : existsSync5(join15(bundledWebuiDir, "index.html")) ? bundledWebuiDir : join15(dirname11(process.execPath), "webui")));
|
|
125619
125929
|
let store = new SessionStore({ cwd: workspace });
|
|
125620
125930
|
const approvals = new Map;
|
|
125621
125931
|
const questions = new Map;
|
|
@@ -125657,7 +125967,7 @@ function startServer(options = {}) {
|
|
|
125657
125967
|
if (activeProject && !options.shared && !options.workspace) {
|
|
125658
125968
|
try {
|
|
125659
125969
|
if (statSync6(activeProject.path).isDirectory())
|
|
125660
|
-
workspace =
|
|
125970
|
+
workspace = resolve12(activeProject.path);
|
|
125661
125971
|
} catch {}
|
|
125662
125972
|
}
|
|
125663
125973
|
store = new SessionStore({ cwd: workspace });
|
|
@@ -125669,14 +125979,14 @@ function startServer(options = {}) {
|
|
|
125669
125979
|
projects = id ? { projects: projects.projects, current: id } : { projects: projects.projects };
|
|
125670
125980
|
saveProjects(projects);
|
|
125671
125981
|
const active = id ? projects.projects.find((entry) => entry.id === id) : undefined;
|
|
125672
|
-
workspace = active ?
|
|
125982
|
+
workspace = active ? resolve12(active.path) : baseWorkspace;
|
|
125673
125983
|
store = new SessionStore({ cwd: workspace });
|
|
125674
125984
|
resetMcp();
|
|
125675
125985
|
sync.publish("workspace");
|
|
125676
125986
|
}
|
|
125677
125987
|
const runtimes = new Map;
|
|
125678
125988
|
function runtimeFor(cwd) {
|
|
125679
|
-
const path =
|
|
125989
|
+
const path = resolve12(cwd);
|
|
125680
125990
|
let runtime = runtimes.get(path);
|
|
125681
125991
|
if (!runtime) {
|
|
125682
125992
|
runtime = new RuntimeManager(path, eventLog);
|
|
@@ -125758,14 +126068,14 @@ function startServer(options = {}) {
|
|
|
125758
126068
|
const raw = typeof body?.path === "string" ? body.path.trim() : "";
|
|
125759
126069
|
if (raw.length === 0)
|
|
125760
126070
|
return json3({ error: "path is required." }, 400);
|
|
125761
|
-
const target =
|
|
126071
|
+
const target = resolve12(raw);
|
|
125762
126072
|
try {
|
|
125763
126073
|
if (!statSync6(target).isDirectory())
|
|
125764
126074
|
return json3({ error: "path is not a directory." }, 400);
|
|
125765
126075
|
} catch {
|
|
125766
126076
|
return json3({ error: "path does not exist." }, 400);
|
|
125767
126077
|
}
|
|
125768
|
-
const existing = projects.projects.find((entry) =>
|
|
126078
|
+
const existing = projects.projects.find((entry) => resolve12(entry.path) === target);
|
|
125769
126079
|
if (!existing) {
|
|
125770
126080
|
const id = `proj-${randomUUID9().slice(0, 8)}`;
|
|
125771
126081
|
const name = typeof body?.name === "string" && body.name.trim().length > 0 ? body.name.trim() : basename3(target);
|
|
@@ -125781,7 +126091,7 @@ function startServer(options = {}) {
|
|
|
125781
126091
|
const LIST_LIMIT = 2000;
|
|
125782
126092
|
function crumbsFor(target) {
|
|
125783
126093
|
const crumbs = [];
|
|
125784
|
-
let current =
|
|
126094
|
+
let current = resolve12(target);
|
|
125785
126095
|
for (;; ) {
|
|
125786
126096
|
const parent = dirname11(current);
|
|
125787
126097
|
crumbs.unshift({ name: basename3(current) || current, path: current });
|
|
@@ -125794,7 +126104,7 @@ function startServer(options = {}) {
|
|
|
125794
126104
|
function handleListDirectory(url) {
|
|
125795
126105
|
const home = homedir3();
|
|
125796
126106
|
const requested = url.searchParams.get("path");
|
|
125797
|
-
const target = requested && requested.trim().length > 0 ?
|
|
126107
|
+
const target = requested && requested.trim().length > 0 ? resolve12(requested) : home;
|
|
125798
126108
|
let dirents;
|
|
125799
126109
|
try {
|
|
125800
126110
|
dirents = readdirSync3(target, { withFileTypes: true });
|
|
@@ -125821,7 +126131,7 @@ function startServer(options = {}) {
|
|
|
125821
126131
|
if (name.trim().length === 0 || name.includes("/") || name.includes("\\")) {
|
|
125822
126132
|
return json3({ error: "name must be a single folder name." }, 400);
|
|
125823
126133
|
}
|
|
125824
|
-
const target = join15(
|
|
126134
|
+
const target = join15(resolve12(parent), name);
|
|
125825
126135
|
try {
|
|
125826
126136
|
mkdirSync12(target, { recursive: false });
|
|
125827
126137
|
} catch (error) {
|
|
@@ -126675,7 +126985,7 @@ Attached files (read them if relevant): ${attachments.join(", ")}` : raw;
|
|
|
126675
126985
|
if (activeRuns.has(body.sessionId))
|
|
126676
126986
|
return json3({ error: "This session already has an active run. Queue the message until it finishes." }, 409);
|
|
126677
126987
|
const existing = runStore.open(body.sessionId, "read");
|
|
126678
|
-
if (existing.header.cwd &&
|
|
126988
|
+
if (existing.header.cwd && resolve12(existing.header.cwd) !== runWorkspace)
|
|
126679
126989
|
return json3({ error: "Session belongs to a different workspace." }, 409);
|
|
126680
126990
|
history = toChatMessages(existing.all());
|
|
126681
126991
|
session = runStore.open(body.sessionId, "write");
|
|
@@ -126915,7 +127225,7 @@ Attached files (read them if relevant): ${attachments.join(", ")}` : raw;
|
|
|
126915
127225
|
}
|
|
126916
127226
|
async function serveStatic(pathname) {
|
|
126917
127227
|
const rel = pathname === "/" ? "index.html" : pathname.replace(/^\/+/, "");
|
|
126918
|
-
const target =
|
|
127228
|
+
const target = resolve12(join15(webuiDir, rel));
|
|
126919
127229
|
const withinRoot = relative6(webuiDir, target);
|
|
126920
127230
|
if (withinRoot.startsWith("..") || withinRoot.includes(".."))
|
|
126921
127231
|
return json3({ error: "not found" }, 404);
|
|
@@ -127185,7 +127495,7 @@ Attached files (read them if relevant): ${attachments.join(", ")}` : raw;
|
|
|
127185
127495
|
const expectedWorkspace = request.headers.get("x-ringko-workspace");
|
|
127186
127496
|
if (expectedWorkspace) {
|
|
127187
127497
|
try {
|
|
127188
|
-
if (
|
|
127498
|
+
if (resolve12(decodeURIComponent(expectedWorkspace)) !== workspace)
|
|
127189
127499
|
return json3({ error: "Backend workspace changed. Reconnect to the correct workspace." }, 409);
|
|
127190
127500
|
} catch {
|
|
127191
127501
|
return json3({ error: "Invalid workspace header." }, 400);
|
|
@@ -127200,7 +127510,7 @@ Attached files (read them if relevant): ${attachments.join(", ")}` : raw;
|
|
|
127200
127510
|
}
|
|
127201
127511
|
}
|
|
127202
127512
|
if (url.pathname === "/api/backend" && request.method === "GET")
|
|
127203
|
-
return json3({ protocol: PROTOCOL_VERSION2, instance: sync.instance, workspace, configPath: options.configPath ?
|
|
127513
|
+
return json3({ protocol: PROTOCOL_VERSION2, instance: sync.instance, workspace, configPath: options.configPath ? resolve12(options.configPath) : null });
|
|
127204
127514
|
if (url.pathname === "/api/backend/stop" && request.method === "POST") {
|
|
127205
127515
|
if (activeRuns.size)
|
|
127206
127516
|
return json3({ error: "Stop active sessions before stopping the backend." }, 409);
|
|
@@ -127343,7 +127653,7 @@ Attached files (read them if relevant): ${attachments.join(", ")}` : raw;
|
|
|
127343
127653
|
if (options.shared) {
|
|
127344
127654
|
try {
|
|
127345
127655
|
const existing = store.open(id, "read");
|
|
127346
|
-
if (existing.header.cwd &&
|
|
127656
|
+
if (existing.header.cwd && resolve12(existing.header.cwd) !== workspace)
|
|
127347
127657
|
return json3({ error: "Session belongs to a different workspace." }, 409);
|
|
127348
127658
|
} catch {
|
|
127349
127659
|
return json3({ error: "Unknown session." }, 404);
|
|
@@ -127503,7 +127813,7 @@ var init_server = __esm(() => {
|
|
|
127503
127813
|
init_src9();
|
|
127504
127814
|
init_sync();
|
|
127505
127815
|
init_runs();
|
|
127506
|
-
DEFAULT_WEBUI_DIR =
|
|
127816
|
+
DEFAULT_WEBUI_DIR = resolve12(import.meta.dir, "../../webui/dist");
|
|
127507
127817
|
APPROVAL_TIMEOUT_MS = 5 * 60 * 1000;
|
|
127508
127818
|
TERMINAL_SESSION_TTL_MS = 30 * 60 * 1000;
|
|
127509
127819
|
MIME = {
|
|
@@ -127531,10 +127841,9 @@ var init_src15 = __esm(() => {
|
|
|
127531
127841
|
init_src5();
|
|
127532
127842
|
|
|
127533
127843
|
// packages/tui/src/cli-identity.ts
|
|
127534
|
-
var
|
|
127535
|
-
function cliCommand(
|
|
127536
|
-
|
|
127537
|
-
return name === NPM_CLI_COMMAND ? NPM_CLI_COMMAND : "ringko";
|
|
127844
|
+
var CLI_COMMAND = "ringko";
|
|
127845
|
+
function cliCommand(_entry = process.argv[1]) {
|
|
127846
|
+
return CLI_COMMAND;
|
|
127538
127847
|
}
|
|
127539
127848
|
|
|
127540
127849
|
// packages/tui/src/resume-hint.ts
|
|
@@ -127550,26 +127859,26 @@ ${source} tui --session ${quote(sessionId, windows)} --workspace ${quote(workspa
|
|
|
127550
127859
|
|
|
127551
127860
|
// packages/tui/src/cli.ts
|
|
127552
127861
|
init_runtime();
|
|
127553
|
-
import { resolve as
|
|
127862
|
+
import { resolve as resolve13 } from "path";
|
|
127554
127863
|
|
|
127555
127864
|
// packages/tui/src/backend.ts
|
|
127556
127865
|
init_src10();
|
|
127557
127866
|
import { spawn as spawn2 } from "child_process";
|
|
127558
|
-
import { resolve as
|
|
127867
|
+
import { resolve as resolve9 } from "path";
|
|
127559
127868
|
|
|
127560
127869
|
// packages/client/src/local.ts
|
|
127561
127870
|
import { createHash as createHash3 } from "crypto";
|
|
127562
127871
|
import { realpathSync as realpathSync2 } from "fs";
|
|
127563
|
-
import { resolve as
|
|
127872
|
+
import { resolve as resolve8 } from "path";
|
|
127564
127873
|
var SERVICE_PORT_BASE = 22000;
|
|
127565
127874
|
var SERVICE_PORT_RANGE = 20000;
|
|
127566
127875
|
function canonicalWorkspace(workspace) {
|
|
127567
|
-
return realpathSync2(
|
|
127876
|
+
return realpathSync2(resolve8(workspace));
|
|
127568
127877
|
}
|
|
127569
127878
|
function sharedPort(workspace, configPath) {
|
|
127570
127879
|
const path = canonicalWorkspace(workspace);
|
|
127571
127880
|
const normalized = process.platform === "win32" ? path.toLowerCase() : path;
|
|
127572
|
-
const config = configPath ?
|
|
127881
|
+
const config = configPath ? resolve8(configPath) : "";
|
|
127573
127882
|
const key = `${normalized}\x00${process.platform === "win32" ? config.toLowerCase() : config}`;
|
|
127574
127883
|
return SERVICE_PORT_BASE + createHash3("sha256").update(key).digest().readUInt32BE(0) % SERVICE_PORT_RANGE;
|
|
127575
127884
|
}
|
|
@@ -127580,7 +127889,7 @@ var PROBE_TIMEOUT_MS = 1000;
|
|
|
127580
127889
|
var RETRY_MS = 200;
|
|
127581
127890
|
async function connectBackend(options) {
|
|
127582
127891
|
const workspace = canonicalWorkspace(options.workspace);
|
|
127583
|
-
const configPath = options.configPath ?
|
|
127892
|
+
const configPath = options.configPath ? resolve9(options.configPath) : undefined;
|
|
127584
127893
|
const token = process.env.RINGKO_WEB_TOKEN?.trim();
|
|
127585
127894
|
const explicit = options.url ?? process.env.RINGKO_SERVER;
|
|
127586
127895
|
const port = sharedPort(workspace, configPath);
|
|
@@ -127600,7 +127909,7 @@ async function connectBackend(options) {
|
|
|
127600
127909
|
throw error;
|
|
127601
127910
|
return false;
|
|
127602
127911
|
}
|
|
127603
|
-
if (identity.protocol !== PROTOCOL_VERSION2 ||
|
|
127912
|
+
if (identity.protocol !== PROTOCOL_VERSION2 || resolve9(identity.workspace) !== workspace || (identity.configPath ?? undefined) !== configPath) {
|
|
127604
127913
|
throw new Error("This port belongs to a different backend/workspace/configuration. Use --server with the correct local backend address.");
|
|
127605
127914
|
}
|
|
127606
127915
|
return true;
|
|
@@ -127617,7 +127926,7 @@ async function connectBackend(options) {
|
|
|
127617
127926
|
const executable = process.execPath;
|
|
127618
127927
|
const script = process.argv[1];
|
|
127619
127928
|
const compiled = script?.includes("$bunfs") || script?.includes("~BUN") || script === executable;
|
|
127620
|
-
const args = [...!compiled && script ? [
|
|
127929
|
+
const args = [...!compiled && script ? [resolve9(script)] : [], "serve", "--shared", "--port", String(port), "--workspace", workspace, ...configPath ? ["--config", configPath] : []];
|
|
127621
127930
|
const child = spawn2(executable, args, { cwd: workspace, env: process.env, detached: true, stdio: "ignore", windowsHide: true });
|
|
127622
127931
|
const spawned = new Promise((ready, reject) => {
|
|
127623
127932
|
child.once("spawn", ready);
|
|
@@ -127643,7 +127952,7 @@ init_src3();
|
|
|
127643
127952
|
// packages/tui/src/provider.ts
|
|
127644
127953
|
init_loader();
|
|
127645
127954
|
// packages/tui/package.json
|
|
127646
|
-
var version2 = "0.2.
|
|
127955
|
+
var version2 = "0.2.1-rc";
|
|
127647
127956
|
|
|
127648
127957
|
// packages/tui/src/cli.ts
|
|
127649
127958
|
var VERSION8 = version2;
|
|
@@ -127693,7 +128002,7 @@ Options:
|
|
|
127693
128002
|
--completion-promise <text> (loop) Stop when a reply contains <promise>text</promise>
|
|
127694
128003
|
|
|
127695
128004
|
Providers are introduced through configuration; the config names a provider
|
|
127696
|
-
module that is imported at run time.
|
|
128005
|
+
module that is imported at run time.
|
|
127697
128006
|
`;
|
|
127698
128007
|
function denyApprovals(io) {
|
|
127699
128008
|
return async (request) => {
|
|
@@ -127952,7 +128261,7 @@ async function tuiCommand(parsed, io) {
|
|
|
127952
128261
|
...info.modelId ? { modelId: info.modelId } : {}
|
|
127953
128262
|
});
|
|
127954
128263
|
if (sessionId && (await backend.sessions()).some((session) => session.id === sessionId)) {
|
|
127955
|
-
io.out(resumeHint(sessionId,
|
|
128264
|
+
io.out(resumeHint(sessionId, resolve13(workspace), process.argv[1]));
|
|
127956
128265
|
}
|
|
127957
128266
|
return 0;
|
|
127958
128267
|
}
|
|
@@ -127960,7 +128269,7 @@ async function serveCommand(parsed, io) {
|
|
|
127960
128269
|
await Promise.resolve().then(() => init_src15());
|
|
127961
128270
|
let server;
|
|
127962
128271
|
try {
|
|
127963
|
-
server = startServer({ workspace:
|
|
128272
|
+
server = startServer({ workspace: resolve13(parsed.workspace ?? process.cwd()), port: parsed.port, configPath: parsed.config, shared: parsed.shared, authToken: process.env.RINGKO_WEB_TOKEN?.trim() });
|
|
127964
128273
|
} catch (error) {
|
|
127965
128274
|
io.err(error instanceof Error ? error.message : "Backend startup failed.");
|
|
127966
128275
|
return 1;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ringko-ai/rkh",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1-rc",
|
|
4
4
|
"description": "RingKo interactive agent CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"bin": {
|
|
8
|
-
"
|
|
8
|
+
"ringko": "bin/ringko.mjs"
|
|
9
9
|
},
|
|
10
10
|
"engines": {
|
|
11
11
|
"node": ">=24",
|