@opencode/client 2.1.3 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/service-timing-6mq2wh8y.js +33 -0
- package/dist/chunks/{service-probe-y2etg5bs.js → service-timing-7f0py9js.js} +2 -2
- package/dist/chunks/{service-probe-ezt8t3fk.js → service-timing-8we1dz3p.js} +6 -2
- package/dist/chunks/{service-probe-8ye1ye6f.js → service-timing-8ye1ye6f.js} +2 -2
- package/dist/chunks/{service-probe-6vp15eh6.js → service-timing-ab9bm97w.js} +1 -1
- package/dist/chunks/service-timing-b80wmp2t.js +30 -0
- package/dist/chunks/{service-probe-61wt4y9h.js → service-timing-cyxwqteg.js} +111 -75
- package/dist/chunks/{service-probe-8bbb028w.js → service-timing-gecjxyvt.js} +5 -1
- package/dist/chunks/{service-probe-xwk4fryp.js → service-timing-jpd9ebw3.js} +17 -17
- package/dist/chunks/{service-probe-nwcpakzx.js → service-timing-js54wxgp.js} +2 -2
- package/dist/chunks/{service-probe-v1n69e13.js → service-timing-knyqkv17.js} +8 -2
- package/dist/chunks/{service-probe-9j12j8xw.js → service-timing-myz4ngx9.js} +5 -5
- package/dist/chunks/{service-probe-5r97ebd4.js → service-timing-rxd7awy0.js} +59 -22
- package/dist/chunks/{service-probe-ryy6kscr.js → service-timing-ryy6kscr.js} +1 -1
- package/dist/chunks/{service-probe-g22sa7qz.js → service-timing-wcsbjfhx.js} +129 -36
- package/dist/contract.js +1 -1
- package/dist/effect/api/api.d.ts +104 -14
- package/dist/effect/api.d.ts +1 -0
- package/dist/effect/client.d.ts +901 -885
- package/dist/effect/client.js +12 -12
- package/dist/effect/generated/client-error.js +3 -3
- package/dist/effect/generated/client.d.ts +515 -503
- package/dist/effect/generated/client.js +5 -5
- package/dist/effect/generated/index.js +8 -8
- package/dist/effect/index.js +12 -12
- package/dist/effect/rpc.js +4 -4
- package/dist/effect/service.d.ts +1 -1
- package/dist/effect/service.js +11 -11
- package/dist/mcp.d.ts +44 -0
- package/dist/mcp.js +110 -0
- package/dist/promise/api.d.ts +1 -0
- package/dist/promise/client.d.ts +16 -5
- package/dist/promise/client.js +11 -11
- package/dist/promise/generated/client-error.js +3 -3
- package/dist/promise/generated/client.d.ts +17 -6
- package/dist/promise/generated/client.js +4 -4
- package/dist/promise/generated/index.js +17 -9
- package/dist/promise/generated/types.d.ts +1165 -3509
- package/dist/promise/generated/types.js +10 -2
- package/dist/promise/index.d.ts +1 -0
- package/dist/promise/index.js +21 -13
- package/dist/promise/rpc.js +2 -2
- package/dist/promise/service.d.ts +2 -2
- package/dist/promise/service.js +12 -11
- package/dist/pty-handoff.js +4 -1
- package/dist/rpc-runtime.js +1 -1
- package/dist/service-contender.js +1 -1
- package/dist/service-probe.js +3 -3
- package/dist/service-timing.js +1 -1
- package/dist/service-version.js +1 -1
- package/dist/service.js +1 -1
- package/dist/shared-events.d.ts +7 -2
- package/dist/shared-events.js +1 -1
- package/dist/solid/connection.js +1 -1
- package/dist/solid/data.d.ts +11 -1
- package/dist/solid/data.js +9 -9
- package/dist/solid/index.d.ts +1 -0
- package/dist/solid/index.js +16 -12
- package/dist/solid/pty.js +1 -1
- package/dist/solid/retention.d.ts +10 -0
- package/dist/solid/retention.js +6 -0
- package/dist/solid/usage.js +1 -1
- package/package.json +15 -8
- package/dist/chunks/service-probe-9p0yrv34.js +0 -30
- /package/dist/chunks/{service-probe-6mptkzbc.js → service-timing-6mptkzbc.js} +0 -0
- /package/dist/chunks/{service-probe-8s2anffy.js → service-timing-8s2anffy.js} +0 -0
- /package/dist/chunks/{service-probe-9rqn6x4v.js → service-timing-9rqn6x4v.js} +0 -0
- /package/dist/chunks/{service-probe-gne7h7mq.js → service-timing-gne7h7mq.js} +0 -0
- /package/dist/chunks/{service-probe-m2eywc8w.js → service-timing-m2eywc8w.js} +0 -0
- /package/dist/chunks/{service-probe-qav6mfdz.js → service-timing-qav6mfdz.js} +0 -0
- /package/dist/chunks/{service-probe-sxt88q69.js → service-timing-sxt88q69.js} +0 -0
- /package/dist/chunks/{service-probe-ve4aws36.js → service-timing-ve4aws36.js} +0 -0
- /package/dist/chunks/{service-probe-vmytr4q8.js → service-timing-vmytr4q8.js} +0 -0
- /package/dist/chunks/{service-probe-vyas3vgt.js → service-timing-vyas3vgt.js} +0 -0
- /package/dist/chunks/{service-probe-xgnj2w4v.js → service-timing-xgnj2w4v.js} +0 -0
- /package/dist/chunks/{service-probe-ydhz1zrh.js → service-timing-ydhz1zrh.js} +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// src/solid/retention.ts
|
|
2
|
+
import { createEffect, untrack } from "solid-js";
|
|
3
|
+
function createSessionRetention2(input) {
|
|
4
|
+
let previous;
|
|
5
|
+
let recent = [];
|
|
6
|
+
let evicted = new Map;
|
|
7
|
+
createEffect(() => {
|
|
8
|
+
const viewed = input.current();
|
|
9
|
+
const current = viewed === undefined ? undefined : input.session.root(viewed);
|
|
10
|
+
const keep = new Set(input.keep().map((id) => input.session.root(id)));
|
|
11
|
+
recent = [
|
|
12
|
+
...new Set([
|
|
13
|
+
...viewed !== previous && current !== undefined ? [current] : [],
|
|
14
|
+
...recent.map((id) => input.session.root(id))
|
|
15
|
+
])
|
|
16
|
+
];
|
|
17
|
+
previous = viewed;
|
|
18
|
+
const retained = new Set([...keep, ...recent.filter((id) => !keep.has(id)).slice(0, input.limit)]);
|
|
19
|
+
if (current !== undefined)
|
|
20
|
+
retained.add(current);
|
|
21
|
+
recent = recent.filter((id) => retained.has(id));
|
|
22
|
+
const count = (id) => untrack(() => input.session.message?.list(id).length ?? 0);
|
|
23
|
+
const excluded = new Map(input.session.list().flatMap((session) => {
|
|
24
|
+
const root = input.session.root(session.id);
|
|
25
|
+
return retained.has(root) ? [] : [[session.id, root]];
|
|
26
|
+
}));
|
|
27
|
+
const roots = new Set([...excluded].filter(([id, root]) => evicted.get(id) !== `${root}:${count(id)}`).map(([, root]) => root));
|
|
28
|
+
untrack(() => roots.forEach((root) => input.session.evict(root)));
|
|
29
|
+
evicted = new Map([...excluded].map(([id, root]) => [id, `${root}:${count(id)}`]));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { createSessionRetention2 };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// src/effect/generated/client-error.ts
|
|
2
2
|
import { Schema } from "effect";
|
|
3
3
|
|
|
4
|
-
class
|
|
4
|
+
class ClientError3 extends Schema.TaggedError()("ClientError", {
|
|
5
5
|
cause: Schema.Defect()
|
|
6
6
|
}) {
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export {
|
|
9
|
+
export { ClientError3 };
|
|
@@ -4,6 +4,7 @@ var isUnauthorizedError2 = (value) => typeof value === "object" && value !== nul
|
|
|
4
4
|
var isLocationNotFoundError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "LocationNotFoundError";
|
|
5
5
|
var isServiceUnavailableError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "ServiceUnavailableError";
|
|
6
6
|
var isAgentNotFoundError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "AgentNotFoundError";
|
|
7
|
+
var isPluginNotFoundError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "PluginNotFoundError";
|
|
7
8
|
var isInvalidCursorError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "InvalidCursorError";
|
|
8
9
|
var isSessionNotFoundError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "SessionNotFoundError";
|
|
9
10
|
var isConflictError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "ConflictError";
|
|
@@ -18,10 +19,14 @@ var isFormNotFoundError2 = (value) => typeof value === "object" && value !== nul
|
|
|
18
19
|
var isFormInvalidAnswerError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "FormInvalidAnswerError";
|
|
19
20
|
var isFormAlreadySettledError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "FormAlreadySettledError";
|
|
20
21
|
var isProviderNotFoundError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "ProviderNotFoundError";
|
|
22
|
+
var isModelNotFoundError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "ModelNotFoundError";
|
|
23
|
+
var isUnsupportedModelError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "UnsupportedModelError";
|
|
24
|
+
var isProviderRequestError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "ProviderRequestError";
|
|
21
25
|
var isIntegrationNotFoundError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "IntegrationNotFoundError";
|
|
22
26
|
var isIntegrationAttemptNotFoundError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "IntegrationAttemptNotFoundError";
|
|
23
27
|
var isIntegrationMethodNotFoundError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "IntegrationMethodNotFoundError";
|
|
24
28
|
var isMcpServerNotFoundError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "McpServerNotFoundError";
|
|
29
|
+
var isForbiddenError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "ForbiddenError";
|
|
25
30
|
var isProjectNotFoundError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "ProjectNotFoundError";
|
|
26
31
|
var isPermissionSavedNotFoundError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "PermissionSavedNotFoundError";
|
|
27
32
|
var isPermissionNotFoundError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "PermissionNotFoundError";
|
|
@@ -29,9 +34,8 @@ var isFileNotFoundError2 = (value) => typeof value === "object" && value !== nul
|
|
|
29
34
|
var isRpcError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "RpcError";
|
|
30
35
|
var isRpcInternalError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "RpcInternalError";
|
|
31
36
|
var isPtyNotFoundError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "PtyNotFoundError";
|
|
32
|
-
var isForbiddenError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "ForbiddenError";
|
|
33
37
|
var isShellNotFoundError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "ShellNotFoundError";
|
|
34
38
|
var isWorktreeError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "WorktreeError";
|
|
35
39
|
var isVcsInitNotSupportedError2 = (value) => typeof value === "object" && value !== null && ("_tag" in value) && value["_tag"] === "VcsInitNotSupportedError";
|
|
36
40
|
|
|
37
|
-
export { isInvalidRequestError2, isUnauthorizedError2, isLocationNotFoundError2, isServiceUnavailableError2, isAgentNotFoundError2, isInvalidCursorError2, isSessionNotFoundError2, isConflictError2, isUnknownError2, isMessageNotFoundError2, isCommandNotFoundError2, isCommandExecutionError2, isSkillNotFoundError2, isSessionBusyError2, isInstructionEntryValueTooLargeError2, isFormNotFoundError2, isFormInvalidAnswerError2, isFormAlreadySettledError2, isProviderNotFoundError2, isIntegrationNotFoundError2, isIntegrationAttemptNotFoundError2, isIntegrationMethodNotFoundError2, isMcpServerNotFoundError2, isProjectNotFoundError2, isPermissionSavedNotFoundError2, isPermissionNotFoundError2, isFileNotFoundError2, isRpcError2, isRpcInternalError2, isPtyNotFoundError2,
|
|
41
|
+
export { isInvalidRequestError2, isUnauthorizedError2, isLocationNotFoundError2, isServiceUnavailableError2, isAgentNotFoundError2, isPluginNotFoundError2, isInvalidCursorError2, isSessionNotFoundError2, isConflictError2, isUnknownError2, isMessageNotFoundError2, isCommandNotFoundError2, isCommandExecutionError2, isSkillNotFoundError2, isSessionBusyError2, isInstructionEntryValueTooLargeError2, isFormNotFoundError2, isFormInvalidAnswerError2, isFormAlreadySettledError2, isProviderNotFoundError2, isModelNotFoundError2, isUnsupportedModelError2, isProviderRequestError2, isIntegrationNotFoundError2, isIntegrationAttemptNotFoundError2, isIntegrationMethodNotFoundError2, isMcpServerNotFoundError2, isForbiddenError2, isProjectNotFoundError2, isPermissionSavedNotFoundError2, isPermissionNotFoundError2, isFileNotFoundError2, isRpcError2, isRpcInternalError2, isPtyNotFoundError2, isShellNotFoundError2, isWorktreeError2, isVcsInitNotSupportedError2 };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defaultEnsureTiming2
|
|
3
|
-
} from "./service-
|
|
3
|
+
} from "./service-timing-xgnj2w4v.js";
|
|
4
4
|
import {
|
|
5
5
|
matchesVersion2
|
|
6
|
-
} from "./service-
|
|
6
|
+
} from "./service-timing-sxt88q69.js";
|
|
7
7
|
|
|
8
8
|
// src/service-probe.ts
|
|
9
9
|
import { homedir } from "node:os";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {
|
|
2
|
+
make7
|
|
3
|
+
} from "./service-timing-gecjxyvt.js";
|
|
4
|
+
import {
|
|
5
|
+
make3
|
|
6
|
+
} from "./service-timing-wcsbjfhx.js";
|
|
7
|
+
import {
|
|
8
|
+
makeRpc2
|
|
9
|
+
} from "./service-timing-ab9bm97w.js";
|
|
10
|
+
import {
|
|
11
|
+
__export
|
|
12
|
+
} from "./service-timing-9rqn6x4v.js";
|
|
13
|
+
|
|
14
|
+
// src/promise/client.ts
|
|
15
|
+
var exports_client = {};
|
|
16
|
+
__export(exports_client, {
|
|
17
|
+
OpenCode: () => exports_client,
|
|
18
|
+
make: () => make2
|
|
19
|
+
});
|
|
20
|
+
function make2(options) {
|
|
21
|
+
const raw = make3(options);
|
|
22
|
+
const events = make7((signal, onActivity) => raw.event.subscribe(undefined, { signal, onActivity }));
|
|
23
|
+
return {
|
|
24
|
+
...raw,
|
|
25
|
+
rpc: Object.assign(makeRpc2(raw, events), raw.rpc),
|
|
26
|
+
event: events
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { make2, exports_client };
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
isFormNotFoundError2,
|
|
3
3
|
isFormAlreadySettledError2,
|
|
4
4
|
isPermissionNotFoundError2
|
|
5
|
-
} from "./service-
|
|
5
|
+
} from "./service-timing-8we1dz3p.js";
|
|
6
6
|
|
|
7
7
|
// src/solid/data.ts
|
|
8
8
|
import { Worktree } from "@opencode/schema/worktree";
|
|
@@ -10,7 +10,6 @@ import { SessionID } from "@opencode/schema/session-id";
|
|
|
10
10
|
import { SessionMessage } from "@opencode/schema/session-message";
|
|
11
11
|
import { createStore, produce, reconcile } from "solid-js/store";
|
|
12
12
|
import { batch, createEffect, createMemo, createSignal, onCleanup } from "solid-js";
|
|
13
|
-
var messageIDFromEvent = (eventID) => eventID.replace(/^evt_/, "msg_");
|
|
14
13
|
var messagePageLimit = 20;
|
|
15
14
|
var settleMs2 = 150;
|
|
16
15
|
function locationKey2(location) {
|
|
@@ -45,6 +44,18 @@ function optimisticFiles(files) {
|
|
|
45
44
|
});
|
|
46
45
|
return items?.length ? items : undefined;
|
|
47
46
|
}
|
|
47
|
+
function omitFileData(content) {
|
|
48
|
+
const omit = (item) => item.type === "file" && item.uri.startsWith("data:") ? { ...item, uri: `data:${item.mime};base64,` } : item;
|
|
49
|
+
return [omit(content[0]), ...content.slice(1).map(omit)];
|
|
50
|
+
}
|
|
51
|
+
function omitMessageFileData(message) {
|
|
52
|
+
if (message.type !== "assistant")
|
|
53
|
+
return message;
|
|
54
|
+
return {
|
|
55
|
+
...message,
|
|
56
|
+
content: message.content.map((part) => part.type === "tool" && ("content" in part.state) && part.state.content ? { ...part, state: { ...part.state, content: omitFileData(part.state.content) } } : part)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
48
59
|
function formRequestOptions(sessionID, ref) {
|
|
49
60
|
if (sessionID !== "global" || !ref)
|
|
50
61
|
return;
|
|
@@ -161,6 +172,7 @@ function createData2(config) {
|
|
|
161
172
|
const [defaultLocation, setDefaultLocation] = createSignal({ directory: config.directory });
|
|
162
173
|
const sessions = createMemo(() => Object.values(store.session.info).toSorted((a, b) => b.time.updated - a.time.updated));
|
|
163
174
|
const messageIndex = new Map;
|
|
175
|
+
const stored = (message) => config.omitToolFileData ? omitMessageFileData(message) : message;
|
|
164
176
|
const sync = createSync();
|
|
165
177
|
let activeUpdates;
|
|
166
178
|
const pendingUpdates = new Map;
|
|
@@ -295,6 +307,8 @@ function createData2(config) {
|
|
|
295
307
|
message.update(sessionID, (draft, index) => message.append(draft, index, item));
|
|
296
308
|
},
|
|
297
309
|
editAssistant(sessionID, messageID, fn) {
|
|
310
|
+
if (!messageIndex.get(sessionID)?.has(messageID))
|
|
311
|
+
return;
|
|
298
312
|
message.update(sessionID, (draft, index) => {
|
|
299
313
|
const position = index.get(messageID);
|
|
300
314
|
const item = position === undefined ? undefined : draft[position];
|
|
@@ -455,6 +469,10 @@ function createData2(config) {
|
|
|
455
469
|
});
|
|
456
470
|
activeUpdates = undefined;
|
|
457
471
|
setStore("session", "active", reconcile(Object.fromEntries(snapshot)));
|
|
472
|
+
snapshot.forEach((status, id) => {
|
|
473
|
+
if (status === "running" && !store.session.info[id])
|
|
474
|
+
refresh(() => result.session.sync(id));
|
|
475
|
+
});
|
|
458
476
|
}).catch(() => {
|
|
459
477
|
if (activeUpdates === updates)
|
|
460
478
|
activeUpdates = undefined;
|
|
@@ -492,7 +510,7 @@ function createData2(config) {
|
|
|
492
510
|
if (store.session.info[event.data.sessionID])
|
|
493
511
|
setStore("session", "info", event.data.sessionID, "agent", event.data.agent);
|
|
494
512
|
message.insert(event.data.sessionID, {
|
|
495
|
-
id:
|
|
513
|
+
id: SessionMessage.ID.fromEvent(event.id),
|
|
496
514
|
type: "agent-switched",
|
|
497
515
|
agent: event.data.agent,
|
|
498
516
|
previous,
|
|
@@ -507,13 +525,13 @@ function createData2(config) {
|
|
|
507
525
|
if (!store.session.message[event.data.sessionID])
|
|
508
526
|
return;
|
|
509
527
|
message.insert(event.data.sessionID, {
|
|
510
|
-
id:
|
|
528
|
+
id: SessionMessage.ID.fromEvent(event.id),
|
|
511
529
|
type: "model-switched",
|
|
512
530
|
model: event.data.model,
|
|
513
531
|
previous,
|
|
514
532
|
time: { created: event.created }
|
|
515
533
|
});
|
|
516
|
-
refresh(() => api().session.message.get({ sessionID: event.data.sessionID, messageID:
|
|
534
|
+
refresh(() => api().session.message.get({ sessionID: event.data.sessionID, messageID: SessionMessage.ID.fromEvent(event.id) }).then((item) => {
|
|
517
535
|
message.update(event.data.sessionID, (draft, index) => {
|
|
518
536
|
const position = index.get(item.id);
|
|
519
537
|
if (position === undefined)
|
|
@@ -554,11 +572,10 @@ function createData2(config) {
|
|
|
554
572
|
subpath: current.subpath
|
|
555
573
|
};
|
|
556
574
|
setStore("session", "info", event.data.sessionID, "location", event.data.location);
|
|
557
|
-
|
|
558
|
-
setStore("session", "info", event.data.sessionID, "projectID", event.data.projectID);
|
|
575
|
+
setStore("session", "info", event.data.sessionID, "projectID", event.data.projectID);
|
|
559
576
|
setStore("session", "info", event.data.sessionID, "subpath", event.data.subpath);
|
|
560
577
|
message.insert(event.data.sessionID, {
|
|
561
|
-
id:
|
|
578
|
+
id: SessionMessage.ID.fromEvent(event.id),
|
|
562
579
|
type: "location-switched",
|
|
563
580
|
location: event.data.location,
|
|
564
581
|
projectID: event.data.projectID,
|
|
@@ -638,7 +655,7 @@ function createData2(config) {
|
|
|
638
655
|
if (updateText === undefined)
|
|
639
656
|
return;
|
|
640
657
|
message.insert(event.data.sessionID, {
|
|
641
|
-
id:
|
|
658
|
+
id: SessionMessage.ID.fromEvent(event.id),
|
|
642
659
|
type: "system",
|
|
643
660
|
text: updateText,
|
|
644
661
|
description: `Instructions updated: ${Object.keys(event.data.delta).join(", ")}`,
|
|
@@ -648,7 +665,7 @@ function createData2(config) {
|
|
|
648
665
|
return;
|
|
649
666
|
case "session.synthetic":
|
|
650
667
|
message.insert(event.data.sessionID, {
|
|
651
|
-
id:
|
|
668
|
+
id: SessionMessage.ID.fromEvent(event.id),
|
|
652
669
|
type: "synthetic",
|
|
653
670
|
text: event.data.text,
|
|
654
671
|
description: event.data.description,
|
|
@@ -658,7 +675,7 @@ function createData2(config) {
|
|
|
658
675
|
return;
|
|
659
676
|
case "session.shell.started":
|
|
660
677
|
message.insert(event.data.sessionID, {
|
|
661
|
-
id:
|
|
678
|
+
id: SessionMessage.ID.fromEvent(event.id),
|
|
662
679
|
type: "shell",
|
|
663
680
|
shellID: event.data.shell.id,
|
|
664
681
|
command: event.data.shell.command,
|
|
@@ -669,6 +686,8 @@ function createData2(config) {
|
|
|
669
686
|
});
|
|
670
687
|
return;
|
|
671
688
|
case "session.shell.ended":
|
|
689
|
+
if (!store.session.message[event.data.sessionID])
|
|
690
|
+
return;
|
|
672
691
|
message.update(event.data.sessionID, (draft) => {
|
|
673
692
|
const match = message.shell(draft, event.data.shell.id);
|
|
674
693
|
if (!match)
|
|
@@ -734,6 +753,8 @@ function createData2(config) {
|
|
|
734
753
|
return;
|
|
735
754
|
}
|
|
736
755
|
case "session.step.failed":
|
|
756
|
+
if (event.location && (event.data.error.type === "provider.budget-limit" || event.data.error.type === "provider.model-budget-limit"))
|
|
757
|
+
refreshUsageLimits(event.location);
|
|
737
758
|
message.editAssistant(event.data.sessionID, event.data.assistantMessageID, (assistant) => {
|
|
738
759
|
assistant.time.completed = event.created;
|
|
739
760
|
assistant.finish = event.data.finish ?? "error";
|
|
@@ -807,7 +828,7 @@ function createData2(config) {
|
|
|
807
828
|
status: "completed",
|
|
808
829
|
input: tool.state.input,
|
|
809
830
|
metadata: event.data.metadata,
|
|
810
|
-
content: [...event.data.content]
|
|
831
|
+
content: config.omitToolFileData ? omitFileData(event.data.content) : [...event.data.content]
|
|
811
832
|
};
|
|
812
833
|
tool.executed = event.data.executed || tool.executed === true;
|
|
813
834
|
if (event.data.native)
|
|
@@ -824,7 +845,7 @@ function createData2(config) {
|
|
|
824
845
|
error: event.data.error,
|
|
825
846
|
input: typeof tool.state.input === "string" ? {} : tool.state.input,
|
|
826
847
|
metadata: event.data.metadata,
|
|
827
|
-
content: event.data.content
|
|
848
|
+
content: config.omitToolFileData && event.data.content ? omitFileData(event.data.content) : event.data.content
|
|
828
849
|
};
|
|
829
850
|
tool.executed = event.data.executed || tool.executed === true;
|
|
830
851
|
if (event.data.native)
|
|
@@ -867,7 +888,7 @@ function createData2(config) {
|
|
|
867
888
|
if (event.data.inputID)
|
|
868
889
|
removePending(event.data.sessionID, event.data.inputID);
|
|
869
890
|
message.insert(event.data.sessionID, {
|
|
870
|
-
id: event.data.inputID ??
|
|
891
|
+
id: event.data.inputID ?? SessionMessage.ID.fromEvent(event.id),
|
|
871
892
|
type: "compaction",
|
|
872
893
|
status: "running",
|
|
873
894
|
reason: event.data.reason,
|
|
@@ -889,7 +910,7 @@ function createData2(config) {
|
|
|
889
910
|
if (event.type === "session.execution.interrupted" && event.data.reason === "shutdown")
|
|
890
911
|
return;
|
|
891
912
|
message.insert(event.data.sessionID, {
|
|
892
|
-
id:
|
|
913
|
+
id: SessionMessage.ID.fromEvent(event.id),
|
|
893
914
|
type: "idle",
|
|
894
915
|
outcome: event.type === "session.execution.succeeded" ? "succeeded" : event.type === "session.execution.failed" ? "failed" : "interrupted",
|
|
895
916
|
...event.type === "session.execution.failed" ? { error: event.data.error } : {},
|
|
@@ -932,6 +953,8 @@ function createData2(config) {
|
|
|
932
953
|
});
|
|
933
954
|
return;
|
|
934
955
|
case "session.compaction.delta":
|
|
956
|
+
if (!store.session.message[event.data.sessionID])
|
|
957
|
+
return;
|
|
935
958
|
message.update(event.data.sessionID, (draft) => {
|
|
936
959
|
const current = message.compaction(draft);
|
|
937
960
|
if (current?.status === "running")
|
|
@@ -955,7 +978,7 @@ function createData2(config) {
|
|
|
955
978
|
return;
|
|
956
979
|
}
|
|
957
980
|
message.append(draft, index, {
|
|
958
|
-
id:
|
|
981
|
+
id: SessionMessage.ID.fromEvent(event.id),
|
|
959
982
|
type: "compaction",
|
|
960
983
|
status: "completed",
|
|
961
984
|
reason: event.data.reason,
|
|
@@ -975,14 +998,11 @@ function createData2(config) {
|
|
|
975
998
|
const position = draft.findLastIndex((item) => item.type === "compaction" && item.status === "running");
|
|
976
999
|
const current = draft[position];
|
|
977
1000
|
const failed = {
|
|
978
|
-
id: current?.id ?? event.data.inputID ??
|
|
1001
|
+
id: current?.id ?? event.data.inputID ?? SessionMessage.ID.fromEvent(event.id),
|
|
979
1002
|
type: "compaction",
|
|
980
1003
|
status: "failed",
|
|
981
|
-
reason: event.data.reason
|
|
982
|
-
error: event.data.error
|
|
983
|
-
type: "compaction.failed",
|
|
984
|
-
message: "Compaction failed before recording an error"
|
|
985
|
-
},
|
|
1004
|
+
reason: event.data.reason,
|
|
1005
|
+
error: event.data.error,
|
|
986
1006
|
metadata: current?.type === "compaction" ? current.metadata : event.metadata,
|
|
987
1007
|
cost: event.data.cost,
|
|
988
1008
|
tokens: event.data.tokens,
|
|
@@ -1017,27 +1037,30 @@ function createData2(config) {
|
|
|
1017
1037
|
Object.keys(store.location).forEach((key) => {
|
|
1018
1038
|
const ref = JSON.parse(key);
|
|
1019
1039
|
const location = { directory: ref[0], workspaceID: ref[1] ?? undefined };
|
|
1040
|
+
refreshUsageLimits(location);
|
|
1020
1041
|
if (event.type === "credential.updated") {
|
|
1021
|
-
result.location.integration
|
|
1022
|
-
refresh(() => result.location.integration.sync(location));
|
|
1042
|
+
refreshLocation("integration", result.location.integration, location);
|
|
1023
1043
|
return;
|
|
1024
1044
|
}
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1045
|
+
if (store.location[key]?.integration)
|
|
1046
|
+
setStore("location", key, (data) => ({
|
|
1047
|
+
integration: data?.integration?.map((integration) => {
|
|
1048
|
+
if (integration.id !== event.data.integrationID)
|
|
1049
|
+
return integration;
|
|
1050
|
+
const active = integration.connections.find((connection) => connection.type === "credential" && connection.id === event.data.credentialID);
|
|
1051
|
+
if (!active)
|
|
1052
|
+
return integration;
|
|
1053
|
+
return {
|
|
1054
|
+
...integration,
|
|
1055
|
+
connections: [active, ...integration.connections.filter((connection) => connection !== active)]
|
|
1056
|
+
};
|
|
1057
|
+
})
|
|
1058
|
+
}));
|
|
1059
|
+
const active = hasLocation("integration", location) || hasLocation("model", location) || hasLocation("provider", location);
|
|
1038
1060
|
result.location.model.invalidate(location);
|
|
1039
1061
|
result.location.provider.invalidate(location);
|
|
1040
|
-
|
|
1062
|
+
if (active)
|
|
1063
|
+
refresh(() => Promise.all([result.location.model.sync(location), result.location.provider.sync(location)]));
|
|
1041
1064
|
});
|
|
1042
1065
|
return;
|
|
1043
1066
|
}
|
|
@@ -1046,34 +1069,22 @@ function createData2(config) {
|
|
|
1046
1069
|
const location = event.location;
|
|
1047
1070
|
switch (event.type) {
|
|
1048
1071
|
case "provider.updated":
|
|
1049
|
-
result.location.provider
|
|
1050
|
-
refresh(() => result.location.provider.sync(location));
|
|
1072
|
+
refreshLocation("provider", result.location.provider, location);
|
|
1051
1073
|
break;
|
|
1052
1074
|
case "model.updated":
|
|
1053
|
-
result.location.model
|
|
1054
|
-
refresh(() => result.location.model.sync(location));
|
|
1075
|
+
refreshLocation("model", result.location.model, location);
|
|
1055
1076
|
break;
|
|
1056
1077
|
case "agent.updated":
|
|
1057
|
-
result.location.agent
|
|
1058
|
-
refresh(() => result.location.agent.sync(location));
|
|
1078
|
+
refreshLocation("agent", result.location.agent, location);
|
|
1059
1079
|
break;
|
|
1060
1080
|
case "command.updated":
|
|
1061
|
-
result.location.command
|
|
1062
|
-
refresh(() => result.location.command.sync(location));
|
|
1081
|
+
refreshLocation("command", result.location.command, location);
|
|
1063
1082
|
break;
|
|
1064
1083
|
case "skill.updated":
|
|
1065
|
-
result.location.skill
|
|
1066
|
-
refresh(() => result.location.skill.sync(location));
|
|
1084
|
+
refreshLocation("skill", result.location.skill, location);
|
|
1067
1085
|
break;
|
|
1068
1086
|
case "vcs.branch.updated":
|
|
1069
|
-
|
|
1070
|
-
vcs: {
|
|
1071
|
-
branch: {
|
|
1072
|
-
...data?.vcs?.branch,
|
|
1073
|
-
current: event.data.branch
|
|
1074
|
-
}
|
|
1075
|
-
}
|
|
1076
|
-
}));
|
|
1087
|
+
refreshLocation("vcs", result.location.vcs, location);
|
|
1077
1088
|
break;
|
|
1078
1089
|
case "form.created":
|
|
1079
1090
|
if (store.session.form[event.data.form.sessionID]?.some((form) => form.id === event.data.form.id))
|
|
@@ -1093,43 +1104,66 @@ function createData2(config) {
|
|
|
1093
1104
|
break;
|
|
1094
1105
|
case "shell.exited":
|
|
1095
1106
|
case "shell.deleted":
|
|
1107
|
+
if (!store.location[locationKey2(location)]?.shell?.[event.data.id])
|
|
1108
|
+
break;
|
|
1096
1109
|
setStore("location", locationKey2(location), (data) => ({
|
|
1097
1110
|
shell: Object.fromEntries(Object.entries(data?.shell ?? {}).filter(([id]) => id !== event.data.id))
|
|
1098
1111
|
}));
|
|
1099
1112
|
break;
|
|
1100
1113
|
case "reference.updated":
|
|
1101
|
-
result.location.reference
|
|
1102
|
-
refresh(() => result.location.reference.sync(location));
|
|
1114
|
+
refreshLocation("reference", result.location.reference, location);
|
|
1103
1115
|
break;
|
|
1104
|
-
case "integration.updated":
|
|
1116
|
+
case "integration.updated": {
|
|
1117
|
+
refreshUsageLimits(location);
|
|
1118
|
+
const active = hasLocation("integration", location) || hasLocation("model", location) || hasLocation("provider", location);
|
|
1105
1119
|
result.location.integration.invalidate(location);
|
|
1106
1120
|
result.location.model.invalidate(location);
|
|
1107
1121
|
result.location.provider.invalidate(location);
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1122
|
+
if (active)
|
|
1123
|
+
refresh(() => Promise.all([
|
|
1124
|
+
result.location.integration.sync(location),
|
|
1125
|
+
result.location.model.sync(location),
|
|
1126
|
+
result.location.provider.sync(location)
|
|
1127
|
+
]));
|
|
1113
1128
|
break;
|
|
1129
|
+
}
|
|
1114
1130
|
case "config.updated":
|
|
1115
|
-
result.location.config
|
|
1116
|
-
if (
|
|
1117
|
-
refresh(() => result.location.
|
|
1118
|
-
refresh(() => result.location.websearch.refresh(location));
|
|
1131
|
+
refreshLocation("config", result.location.config, location);
|
|
1132
|
+
if (hasLocation("websearch", location))
|
|
1133
|
+
refresh(() => result.location.websearch.refresh(location));
|
|
1119
1134
|
break;
|
|
1120
1135
|
case "websearch.updated":
|
|
1121
|
-
|
|
1136
|
+
if (hasLocation("websearch", location))
|
|
1137
|
+
refresh(() => result.location.websearch.refresh(location));
|
|
1122
1138
|
break;
|
|
1123
|
-
case "mcp.status.changed":
|
|
1139
|
+
case "mcp.status.changed": {
|
|
1140
|
+
const active = hasLocation("mcpServer", location);
|
|
1124
1141
|
result.location.mcp.server.invalidate(location);
|
|
1125
|
-
|
|
1142
|
+
if (active)
|
|
1143
|
+
settle(`mcp.status:${locationKey2(location)}`, () => result.location.mcp.server.sync(location));
|
|
1126
1144
|
break;
|
|
1145
|
+
}
|
|
1127
1146
|
case "mcp.resources.changed":
|
|
1128
|
-
result.location.mcp.resource
|
|
1129
|
-
refresh(() => result.location.mcp.resource.sync(location));
|
|
1147
|
+
refreshLocation("mcpResource", result.location.mcp.resource, location);
|
|
1130
1148
|
break;
|
|
1131
1149
|
}
|
|
1132
1150
|
}
|
|
1151
|
+
function hasLocation(field, ref) {
|
|
1152
|
+
const id = locationKey2(ref ?? defaultLocation());
|
|
1153
|
+
return store.location[id]?.[field] !== undefined || sync.has(`location.${field}:${id}`);
|
|
1154
|
+
}
|
|
1155
|
+
function refreshLocation(field, resource, location) {
|
|
1156
|
+
const active = hasLocation(field, location);
|
|
1157
|
+
resource.invalidate(location);
|
|
1158
|
+
if (active)
|
|
1159
|
+
refresh(() => resource.sync(location));
|
|
1160
|
+
}
|
|
1161
|
+
function refreshUsageLimits(location) {
|
|
1162
|
+
const loaded = store.location[locationKey2(location)]?.usageLimits !== undefined || sync.has(`location.usageLimits:${locationKey2(location)}`);
|
|
1163
|
+
usageLimits.invalidate(location);
|
|
1164
|
+
if (loaded)
|
|
1165
|
+
refresh(() => usageLimits.sync(location));
|
|
1166
|
+
}
|
|
1133
1167
|
function locationResource(field, load, options) {
|
|
1134
1168
|
const publish = (key, value) => setStore("location", key, { [field]: value });
|
|
1135
1169
|
return {
|
|
@@ -1149,6 +1183,7 @@ function createData2(config) {
|
|
|
1149
1183
|
};
|
|
1150
1184
|
}
|
|
1151
1185
|
const vcs = locationResource("vcs", (location) => api().vcs.get({ location }));
|
|
1186
|
+
const usageLimits = locationResource("usageLimits", (location) => api().usage.limits({ location }));
|
|
1152
1187
|
const shells = locationResource("shell", async (location) => {
|
|
1153
1188
|
const response = await api().shell.list({ location });
|
|
1154
1189
|
const ref = { directory: response.location.directory };
|
|
@@ -1416,7 +1451,7 @@ function createData2(config) {
|
|
|
1416
1451
|
limit: config.initialMessageLimit?.() ?? messagePageLimit,
|
|
1417
1452
|
order: "desc"
|
|
1418
1453
|
});
|
|
1419
|
-
const fetched = response.data.toReversed();
|
|
1454
|
+
const fetched = response.data.toReversed().map(stored);
|
|
1420
1455
|
const ids = new Set(fetched.map((item) => item.id));
|
|
1421
1456
|
const admitted = new Set((store.session.pending[sessionID] ?? []).flatMap((item) => item.type === "user" || item.type === "synthetic" ? [item.id] : []));
|
|
1422
1457
|
const local = (store.session.message[sessionID] ?? []).filter((item) => !ids.has(item.id) && (outbox.has(item.id) || admitted.has(item.id)));
|
|
@@ -1469,7 +1504,7 @@ function createData2(config) {
|
|
|
1469
1504
|
}, { signal });
|
|
1470
1505
|
if (signal?.aborted)
|
|
1471
1506
|
return;
|
|
1472
|
-
fetched.push(...response.data);
|
|
1507
|
+
fetched.push(...response.data.map(stored));
|
|
1473
1508
|
next = response.cursor.next ?? undefined;
|
|
1474
1509
|
if (!options?.all)
|
|
1475
1510
|
break;
|
|
@@ -1661,6 +1696,7 @@ function createData2(config) {
|
|
|
1661
1696
|
result.session.form.invalidate("global", location);
|
|
1662
1697
|
},
|
|
1663
1698
|
vcs: { info: vcs.list, sync: vcs.sync, invalidate: vcs.invalidate },
|
|
1699
|
+
usage: { limits: usageLimits.list, sync: usageLimits.sync, invalidate: usageLimits.invalidate },
|
|
1664
1700
|
agent: locationResource("agent", (location) => api().agent.list({ location })),
|
|
1665
1701
|
command: locationResource("command", (location) => api().command.list({ location })),
|
|
1666
1702
|
config: locationResource("config", async (location) => ({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export
|
|
3
|
-
} from "./service-
|
|
3
|
+
} from "./service-timing-9rqn6x4v.js";
|
|
4
4
|
|
|
5
5
|
// src/shared-events.ts
|
|
6
6
|
var exports_shared_events = {};
|
|
@@ -56,6 +56,8 @@ function make7(connect) {
|
|
|
56
56
|
let started = false;
|
|
57
57
|
let completion;
|
|
58
58
|
let connection;
|
|
59
|
+
const types = options?.types?.length ? new Set(options.types) : undefined;
|
|
60
|
+
const selected = (value) => !types || value.type === "server.connected" || types.has(value.type);
|
|
59
61
|
function finish(result, discard = true) {
|
|
60
62
|
completion = result;
|
|
61
63
|
if (discard)
|
|
@@ -81,6 +83,8 @@ function make7(connect) {
|
|
|
81
83
|
push(value) {
|
|
82
84
|
if (completion)
|
|
83
85
|
return;
|
|
86
|
+
if (!selected(value))
|
|
87
|
+
return;
|
|
84
88
|
const request = pending.shift();
|
|
85
89
|
if (request) {
|
|
86
90
|
request.resolve({ done: false, value });
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
2
|
make7
|
|
3
|
-
} from "./service-
|
|
3
|
+
} from "./service-timing-gecjxyvt.js";
|
|
4
4
|
import {
|
|
5
|
-
|
|
6
|
-
} from "./service-
|
|
5
|
+
ClientError3
|
|
6
|
+
} from "./service-timing-7f0py9js.js";
|
|
7
7
|
import {
|
|
8
|
-
|
|
9
|
-
} from "./service-
|
|
8
|
+
make5
|
|
9
|
+
} from "./service-timing-rxd7awy0.js";
|
|
10
10
|
import {
|
|
11
|
-
|
|
11
|
+
make6,
|
|
12
12
|
aborted2
|
|
13
|
-
} from "./service-
|
|
13
|
+
} from "./service-timing-myz4ngx9.js";
|
|
14
14
|
import {
|
|
15
15
|
__export
|
|
16
|
-
} from "./service-
|
|
16
|
+
} from "./service-timing-9rqn6x4v.js";
|
|
17
17
|
|
|
18
18
|
// src/effect/client.ts
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
OpenCode: () =>
|
|
22
|
-
make: () =>
|
|
19
|
+
var exports_client3 = {};
|
|
20
|
+
__export(exports_client3, {
|
|
21
|
+
OpenCode: () => exports_client3,
|
|
22
|
+
make: () => make4
|
|
23
23
|
});
|
|
24
24
|
import { Cause, Context, Effect, Stream } from "effect";
|
|
25
25
|
import { HttpClient, HttpClientRequest } from "effect/http";
|
|
@@ -28,9 +28,9 @@ var CurrentHeaders = Context.Reference("@opencode/client/effect/rpc/headers", {
|
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
|
-
var
|
|
31
|
+
var make4 = Effect.fn("OpenCode.make")(function* (options) {
|
|
32
32
|
const httpClient = yield* HttpClient.HttpClient;
|
|
33
|
-
const raw = yield*
|
|
33
|
+
const raw = yield* make5(options).pipe(Effect.provideService(HttpClient.HttpClient, HttpClient.mapRequestEffect(httpClient, (request) => Effect.map(CurrentHeaders, (headers) => headers ? HttpClientRequest.setHeaders(request, new Headers(headers)) : request))));
|
|
34
34
|
const context = yield* Effect.context();
|
|
35
35
|
const native = raw.event.subscribe();
|
|
36
36
|
|
|
@@ -41,12 +41,12 @@ var make2 = Effect.fn("OpenCode.make")(function* (options) {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
const shared = make7((signal) => Stream.toAsyncIterableWith(native.pipe(Stream.interruptWhen(aborted2(signal)), Stream.catchCause((cause) => Stream.fail(new EventFailure(cause)))), context));
|
|
44
|
-
const subscribe = () => Stream.fromAsyncIterable(shared.subscribe(), (error) => error).pipe(Stream.catch((error) => Stream.failCause(error instanceof EventFailure ? error.cause : Cause.fail(new
|
|
44
|
+
const subscribe = (input) => Stream.fromAsyncIterable(shared.subscribe({ types: input?.types }), (error) => error).pipe(Stream.catch((error) => Stream.failCause(error instanceof EventFailure ? error.cause : Cause.fail(new ClientError3({ cause: error })))));
|
|
45
45
|
return {
|
|
46
46
|
...raw,
|
|
47
47
|
event: { ...raw.event, subscribe },
|
|
48
|
-
rpc: Object.assign(
|
|
48
|
+
rpc: Object.assign(make6((input, options) => raw.rpc.call(input).pipe(Effect.provideService(CurrentHeaders, options?.headers)), subscribe), raw.rpc)
|
|
49
49
|
};
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
export {
|
|
52
|
+
export { make4, exports_client3 };
|