@cotal-ai/connector-opencode 0.177.0 → 0.179.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/agui-map.d.ts +9 -2
- package/dist/agui-map.d.ts.map +1 -1
- package/dist/agui-map2.d.ts +29 -7
- package/dist/agui-map2.d.ts.map +1 -1
- package/dist/agui-source.d.ts +13 -2
- package/dist/agui-source.d.ts.map +1 -1
- package/dist/agui-source2.d.ts +18 -3
- package/dist/agui-source2.d.ts.map +1 -1
- package/dist/catalog2.d.ts +5 -0
- package/dist/catalog2.d.ts.map +1 -0
- package/dist/command-catalog.d.ts.map +1 -1
- package/dist/command-catalog1.d.ts +10 -0
- package/dist/command-catalog1.d.ts.map +1 -0
- package/dist/command-routes.d.ts +2 -2
- package/dist/commands1.d.ts +39 -0
- package/dist/commands1.d.ts.map +1 -0
- package/dist/commands2.d.ts +28 -0
- package/dist/commands2.d.ts.map +1 -0
- package/dist/extension.d.ts +2 -1
- package/dist/extension.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/launch.d.ts.map +1 -1
- package/dist/launch.js +2 -2
- package/dist/naming2.d.ts +19 -0
- package/dist/naming2.d.ts.map +1 -0
- package/dist/opencode2-http.d.ts +14 -0
- package/dist/opencode2-http.d.ts.map +1 -0
- package/dist/opencode2-types.d.ts +2 -0
- package/dist/opencode2-types.d.ts.map +1 -1
- package/dist/plugin/docs-bundle.bin +0 -0
- package/dist/plugin/docs-index.bin +0 -0
- package/dist/plugin/index.js +53 -44
- package/dist/plugin-io.d.ts +1 -0
- package/dist/plugin-io.d.ts.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin2.d.ts.map +1 -1
- package/dist/private-serve.d.ts +18 -0
- package/dist/private-serve.d.ts.map +1 -0
- package/dist/prompt-asks.d.ts +48 -0
- package/dist/prompt-asks.d.ts.map +1 -0
- package/dist/prompts.d.ts +93 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/reconnect-command.d.ts +2 -2
- package/dist/serve.js +2 -2
- package/dist/settled-models.d.ts +10 -0
- package/dist/settled-models.d.ts.map +1 -0
- package/dist/stream1.d.ts +50 -0
- package/dist/stream1.d.ts.map +1 -0
- package/dist/stream2.d.ts +70 -0
- package/dist/stream2.d.ts.map +1 -0
- package/package.json +4 -4
package/dist/agui-map.d.ts
CHANGED
|
@@ -18,9 +18,11 @@
|
|
|
18
18
|
* a reverted session is: publish only on finality, drop the per-part state for the vanished ids, log
|
|
19
19
|
* the divergence once, keep going. Because the source hands over only settled parts, this mapper
|
|
20
20
|
* holds no per-part state to drop: a part arrives once, complete, and is mapped in one shot. So the
|
|
21
|
-
* divergence log is the source's, and there is nothing here for a revert to invalidate.
|
|
21
|
+
* divergence log is the source's, and there is nothing here for a revert to invalidate. A part
|
|
22
|
+
* that streamed through the delta journal (stream1.ts) is the one exception: its stream stays open
|
|
23
|
+
* until its saved record or the turn's end closes it.
|
|
22
24
|
*/
|
|
23
|
-
import { type RecordMapper } from "@cotal-ai/connector-core";
|
|
25
|
+
import { type Merged, type RecordMapper, type StreamSeed } from "@cotal-ai/connector-core";
|
|
24
26
|
import type { OpenCodeRecord } from "./agui-source.js";
|
|
25
27
|
interface OpenCodeMapperOptions {
|
|
26
28
|
/** The native session id. It is the `threadId` on every event and nothing else may claim it. */
|
|
@@ -32,11 +34,16 @@ interface OpenCodeMapperOptions {
|
|
|
32
34
|
resumeRunId?: string;
|
|
33
35
|
/** Emit `REASONING_*` for reasoning parts. Off by default (§7 Q1). */
|
|
34
36
|
reasoning?: boolean;
|
|
37
|
+
/** The stream state {@link streamSeed} rebuilt for a restarted emitter. */
|
|
38
|
+
seed?: StreamSeed;
|
|
35
39
|
/** Arrival clock, for the records carrying no usable source stamp. Injectable for determinism. */
|
|
36
40
|
now?: () => number;
|
|
37
41
|
}
|
|
38
42
|
export interface OpenCodeMapper {
|
|
39
43
|
map: RecordMapper<OpenCodeRecord>;
|
|
44
|
+
/** {@link map} over the session's records with its delta journal read in among them: a journal
|
|
45
|
+
* line streams the parts it carries, and a part's saved record closes its stream. */
|
|
46
|
+
mapMerged: RecordMapper<Merged<OpenCodeRecord>>;
|
|
40
47
|
/**
|
|
41
48
|
* Forget a run the emitter closed out of band. KEYED ON THE ID: the report can arrive after this
|
|
42
49
|
* mapper has already opened a newer run, and clearing unconditionally would orphan that one, whose
|
package/dist/agui-map.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agui-map.d.ts","sourceRoot":"","sources":["../src/agui-map.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"agui-map.d.ts","sourceRoot":"","sources":["../src/agui-map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,YAAY,EAEjB,KAAK,UAAU,EAchB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGvD,UAAU,qBAAqB;IAC7B,gGAAgG;IAChG,QAAQ,EAAE,MAAM,CAAC;IACjB,oGAAoG;IACpG,SAAS,EAAE,MAAM,MAAM,CAAC;IACxB;2FACuF;IACvF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,2EAA2E;IAC3E,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,kGAAkG;IAClG,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,YAAY,CAAC,cAAc,CAAC,CAAC;IAClC;0FACsF;IACtF,SAAS,EAAE,YAAY,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC;IAChD;;;;OAIG;IACH,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAkFD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,qBAAqB,GAAG,cAAc,CAiHhF"}
|
package/dist/agui-map2.d.ts
CHANGED
|
@@ -5,20 +5,31 @@
|
|
|
5
5
|
*
|
|
6
6
|
* - `text` -> `TEXT_MESSAGE_*`, assistant only
|
|
7
7
|
* - `reasoning` -> `REASONING_*`, off by default
|
|
8
|
-
* - `tool` -> `TOOL_CALL_START` / `ARGS` / `END`
|
|
8
|
+
* - `tool` -> `TOOL_CALL_START` / `ARGS` / `END` at its call record, which the source hands over
|
|
9
|
+
* once the tool runs, and `TOOL_CALL_RESULT` then the `cotal.toolResult` marker with the element's
|
|
10
|
+
* own error status at its result record. `toolCallId` is the native call id.
|
|
9
11
|
* - `user` -> nothing of its own: it closes the open run, because a new turn began. Its text is
|
|
10
12
|
* never published, for the 1.x reason: a peer batch is prepended into the person's own prompt, so
|
|
11
13
|
* the record has no boundary between the two authors to filter on.
|
|
12
14
|
* - `idle` -> closes the open run with the outcome the server recorded: `failed` is `RUN_ERROR`,
|
|
13
15
|
* and `succeeded` and `interrupted` are `RUN_FINISHED` with no outcome, which says the run ended
|
|
14
|
-
* without claiming it succeeded. A stop someone pressed is not a failure.
|
|
16
|
+
* without claiming it succeeded. A stop someone pressed is not a failure. An execution that a
|
|
17
|
+
* rejected permission or a dismissed question interrupted records no `idle` (measured on 2.0.24),
|
|
18
|
+
* so `plugin2.ts` closes that run out of band and this mapper forgets it.
|
|
15
19
|
* - every other message kind -> nothing, and it closes nothing.
|
|
16
20
|
*
|
|
17
|
-
* A turn that ends before its first element
|
|
18
|
-
*
|
|
19
|
-
*
|
|
21
|
+
* A turn that ends before its first element, such as one the provider refused, has no run open at
|
|
22
|
+
* its `idle`, so that `idle` publishes a run of its own: its start at the turn's `user` record and
|
|
23
|
+
* the `idle`'s terminal. A reader waiting on the turn then sees it end. An `idle` that ends no turn
|
|
24
|
+
* of its own, such as one recorded after an out-of-band close, maps to nothing. Tool arguments and
|
|
25
|
+
* results are mapped here and dropped by the emitter's egress policy before anything is written,
|
|
26
|
+
* the one place that decides what leaves.
|
|
27
|
+
*
|
|
28
|
+
* A text or reasoning element that streamed through the delta journal (stream2.ts) publishes as it
|
|
29
|
+
* streams, under its stream key, and its saved record ends that message. A run that closes with a
|
|
30
|
+
* stream still open ends the stream first.
|
|
20
31
|
*/
|
|
21
|
-
import { type RecordMapper } from "@cotal-ai/connector-core";
|
|
32
|
+
import { type Merged, type RecordMapper, type StreamSeed } from "@cotal-ai/connector-core";
|
|
22
33
|
import type { OpenCode2Record } from "./agui-source2.js";
|
|
23
34
|
export interface OpenCode2MapperOptions {
|
|
24
35
|
/** The native session id: the `threadId` on every event. */
|
|
@@ -30,6 +41,17 @@ export interface OpenCode2MapperOptions {
|
|
|
30
41
|
resumeRunId?: string;
|
|
31
42
|
/** Emit `REASONING_*` for reasoning elements. Off by default. */
|
|
32
43
|
reasoning?: boolean;
|
|
44
|
+
/** The stream state {@link streamSeed} rebuilt for a restarted emitter. */
|
|
45
|
+
seed?: StreamSeed;
|
|
46
|
+
}
|
|
47
|
+
export interface OpenCode2Mapper {
|
|
48
|
+
map: RecordMapper<OpenCode2Record>;
|
|
49
|
+
/** {@link map} over the session's records with its delta journal read in among them: a journal
|
|
50
|
+
* line streams the elements it carries, and an element's saved record closes its stream. */
|
|
51
|
+
mapMerged: RecordMapper<Merged<OpenCode2Record>>;
|
|
52
|
+
/** Forget a run the emitter closed out of band. Keyed on the id, as 1.x's `forgetOpenRun` is, so a
|
|
53
|
+
* newer run opened before the report arrives stays open. */
|
|
54
|
+
forgetOpenRun: (runId: string) => void;
|
|
33
55
|
}
|
|
34
|
-
export declare function createOpenCode2Mapper(opts: OpenCode2MapperOptions):
|
|
56
|
+
export declare function createOpenCode2Mapper(opts: OpenCode2MapperOptions): OpenCode2Mapper;
|
|
35
57
|
//# sourceMappingURL=agui-map2.d.ts.map
|
package/dist/agui-map2.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agui-map2.d.ts","sourceRoot":"","sources":["../src/agui-map2.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"agui-map2.d.ts","sourceRoot":"","sources":["../src/agui-map2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,YAAY,EAEjB,KAAK,UAAU,EAehB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAoB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAG3E,MAAM,WAAW,sBAAsB;IACrC,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,oGAAoG;IACpG,SAAS,EAAE,MAAM,MAAM,CAAC;IACxB;6CACyC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,2EAA2E;IAC3E,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAcD,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,YAAY,CAAC,eAAe,CAAC,CAAC;IACnC;iGAC6F;IAC7F,SAAS,EAAE,YAAY,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC;IACjD;iEAC6D;IAC7D,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAiBD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,sBAAsB,GAAG,eAAe,CA4FnF"}
|
package/dist/agui-source.d.ts
CHANGED
|
@@ -17,12 +17,16 @@
|
|
|
17
17
|
* `part.id` cursor would be sound only for as long as an unrelated safety ruling keeps user parts
|
|
18
18
|
* out, which is a dependency nobody would remember. The pair is sound either way and costs nothing.
|
|
19
19
|
*
|
|
20
|
+
* **A tool part is two records.** Its call settles once the tool runs and its result once the tool
|
|
21
|
+
* has completed or failed, so a call shows while it runs. The call's cursor is the pair with `:call`
|
|
22
|
+
* after it, and it orders before the part's own.
|
|
23
|
+
*
|
|
20
24
|
* **Removal is tolerated by construction.** The cursor is compared as an ORDER, never looked up as
|
|
21
25
|
* an identity, so a session whose parts were reverted away resumes from the same position without
|
|
22
26
|
* the record it names having to still exist. That is what makes the ruling implementable: publish
|
|
23
27
|
* on finality, and treat a later removal as a logged divergence rather than a halt.
|
|
24
28
|
*/
|
|
25
|
-
import type {
|
|
29
|
+
import type { OrderedSource, SourceRead } from "@cotal-ai/connector-core";
|
|
26
30
|
/** The message fields the mapper needs. Deliberately not the whole `Message`: the source hands on
|
|
27
31
|
* identity, authorship and the turn-level completion mark, and nothing it does not read. */
|
|
28
32
|
export interface OpenCodeMessageInfo {
|
|
@@ -32,12 +36,15 @@ export interface OpenCodeMessageInfo {
|
|
|
32
36
|
created?: number;
|
|
33
37
|
completed?: number;
|
|
34
38
|
};
|
|
39
|
+
error?: unknown;
|
|
35
40
|
}
|
|
36
41
|
/** One record: a part, plus the message that owns it. The mapper needs both, because authorship and
|
|
37
42
|
* the turn-level finality backstop live on the message, not on the part. */
|
|
38
43
|
export interface OpenCodeRecord {
|
|
39
44
|
part: OpenCodePart;
|
|
40
45
|
message: OpenCodeMessageInfo;
|
|
46
|
+
/** The record of a tool part's call, which comes before the part's own record, its result. */
|
|
47
|
+
call?: true;
|
|
41
48
|
}
|
|
42
49
|
/**
|
|
43
50
|
* The part shape this source reads. It is a STRUCTURAL subset of the SDK's `Part` union, declared
|
|
@@ -96,6 +103,9 @@ type ReadSessionMessages = () => Promise<OpenCodeMessageWithParts[]>;
|
|
|
96
103
|
export declare function isSettled(record: OpenCodeRecord): boolean;
|
|
97
104
|
/** Serialise the ordering key. Ids carry no `:`, so the first one separates the halves. */
|
|
98
105
|
export declare function cursorOf(record: OpenCodeRecord): string;
|
|
106
|
+
/** Negative when position `a` is before `b`, zero at the same position, positive after. The empty
|
|
107
|
+
* cursor of an empty session is before every record. */
|
|
108
|
+
export declare function compareCursors(a: string, b: string): number;
|
|
99
109
|
interface OpenCodeSessionSourceOptions {
|
|
100
110
|
/** Reads the session. */
|
|
101
111
|
read: ReadSessionMessages;
|
|
@@ -117,7 +127,7 @@ interface OpenCodeSessionSourceOptions {
|
|
|
117
127
|
*/
|
|
118
128
|
endedAt?: () => string | undefined;
|
|
119
129
|
}
|
|
120
|
-
export declare class OpenCodeSessionSource implements
|
|
130
|
+
export declare class OpenCodeSessionSource implements OrderedSource<OpenCodeRecord> {
|
|
121
131
|
readonly kind = "opencode-session";
|
|
122
132
|
private readonly read0;
|
|
123
133
|
private readonly onVanished?;
|
|
@@ -132,6 +142,7 @@ export declare class OpenCodeSessionSource implements DurableSource<OpenCodeReco
|
|
|
132
142
|
/** The session's records in session order: messages by id (measured monotonic with creation
|
|
133
143
|
* time, 0 disagreements over the corpus), parts by id within a message. */
|
|
134
144
|
private ordered;
|
|
145
|
+
compare(a: string, b: string): number;
|
|
135
146
|
/** The position of the end: the last record's cursor, or the empty cursor of an empty session,
|
|
136
147
|
* which the next read with it treats as `undefined` does. */
|
|
137
148
|
end(): Promise<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agui-source.d.ts","sourceRoot":"","sources":["../src/agui-source.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"agui-source.d.ts","sourceRoot":"","sources":["../src/agui-source.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE1E;6FAC6F;AAC7F,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;6EAC6E;AAC7E,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE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,GAAG,MAAM,CAEvD;AA2BD;yDACyD;AACzD,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAK3D;AAOD,UAAU,4BAA4B;IACpC,yBAAyB;IACzB,IAAI,EAAE,mBAAmB,CAAC;IAC1B;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;CACpC;AAED,qBAAa,qBAAsB,YAAW,aAAa,CAAC,cAAc,CAAC;IACzE,QAAQ,CAAC,IAAI,sBAAsB;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsB;IAC5C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAA2B;IACvD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAA2B;IACpD;;6DAEyD;IACzD,OAAO,CAAC,gBAAgB,CAAC,CAAS;gBAEtB,IAAI,EAAE,4BAA4B;IAM9C,2EAA2E;IAC3E,OAAO,CAAC,OAAO;IAMf;gFAC4E;YAC9D,OAAO;IAkBrB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IAIrC;kEAC8D;IACxD,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;IAKtB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;IAyB3E;;;;;;;;;OASG;IACH,OAAO,CAAC,aAAa;CAQtB"}
|
package/dist/agui-source2.d.ts
CHANGED
|
@@ -16,9 +16,12 @@
|
|
|
16
16
|
* So a record is one element, keyed by its message id and its position, and the cursor is that pair
|
|
17
17
|
* compared as an order. Message ids sort by creation (measured on every captured session). A message
|
|
18
18
|
* with no element is one record of its own: a user prompt, a turn end, and a step that has not
|
|
19
|
-
* written anything yet, which must hold the read like any unsettled element does.
|
|
19
|
+
* written anything yet, which must hold the read like any unsettled element does. A tool is two
|
|
20
|
+
* records at its position: its call, settled once its input is final (`running`), and then its
|
|
21
|
+
* result, so a call shows while it runs, as OpenCode's own ACP agent shows it. The call's cursor is
|
|
22
|
+
* the position with `:call` after it.
|
|
20
23
|
*/
|
|
21
|
-
import type {
|
|
24
|
+
import type { OrderedSource, SourceRead } from "@cotal-ai/connector-core";
|
|
22
25
|
/** The fields of a 2.x message this source and its mapper read. */
|
|
23
26
|
export interface OpenCode2Message {
|
|
24
27
|
id: string;
|
|
@@ -86,24 +89,36 @@ export interface OpenCode2Record {
|
|
|
86
89
|
message: OpenCode2Message;
|
|
87
90
|
index: number;
|
|
88
91
|
element?: OpenCode2Element;
|
|
92
|
+
/** The record of a tool's call, which comes before the tool's own record, its result. */
|
|
93
|
+
call?: true;
|
|
89
94
|
}
|
|
95
|
+
/** Negative when position `a` is before `b`, zero at the same position, positive after. The empty
|
|
96
|
+
* cursor is before every record. */
|
|
97
|
+
export declare function compareCursors2(a: string, b: string): number;
|
|
90
98
|
interface OpenCode2SessionSourceOptions {
|
|
91
99
|
page: FetchMessagePage;
|
|
92
100
|
/** Called once per cursor whose record is no longer in the session, which is what a revert does.
|
|
93
101
|
* The read stays correct without it, because the cursor is compared as an order. */
|
|
94
102
|
onVanished?: (cursor: string) => void;
|
|
95
103
|
}
|
|
96
|
-
export declare class OpenCode2SessionSource implements
|
|
104
|
+
export declare class OpenCode2SessionSource implements OrderedSource<OpenCode2Record> {
|
|
97
105
|
readonly kind = "opencode2-session";
|
|
98
106
|
private readonly page;
|
|
99
107
|
private readonly onVanished?;
|
|
100
108
|
private reportedVanished?;
|
|
109
|
+
private furthest;
|
|
101
110
|
constructor(opts: OpenCode2SessionSourceOptions);
|
|
102
111
|
/** Every message at or after `from`, or the whole session when `from` is absent. Pages run newest
|
|
103
112
|
* first, so the read stops at the first page that reaches back to `from`. */
|
|
104
113
|
private messages;
|
|
105
114
|
/** The records in session order, each with whether a later `idle` has ended its turn. */
|
|
106
115
|
private ordered;
|
|
116
|
+
compare(a: string, b: string): number;
|
|
117
|
+
/** The furthest position a read has reached: every record up to it was settled when it was read. */
|
|
118
|
+
get reached(): string;
|
|
119
|
+
/** The position of the session's last record before message `messageId`, which a read reaches
|
|
120
|
+
* once everything older than the message is settled. */
|
|
121
|
+
before(messageId: string): Promise<string>;
|
|
107
122
|
end(): Promise<string>;
|
|
108
123
|
read(cursor: string | undefined): Promise<SourceRead<OpenCode2Record>>;
|
|
109
124
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agui-source2.d.ts","sourceRoot":"","sources":["../src/agui-source2.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"agui-source2.d.ts","sourceRoot":"","sources":["../src/agui-source2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE1E,mEAAmE;AACnE,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX;uCACmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACjE,kEAAkE;IAClE,OAAO,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAC7B,mDAAmD;IACnD,OAAO,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,aAAa,CAAC;IACjD,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C;AAED,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;C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,EAAE,IAAI,CAAC;CACb;AA4BD;qCACqC;AACrC,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAK5D;AAoBD,UAAU,6BAA6B;IACrC,IAAI,EAAE,gBAAgB,CAAC;IACvB;yFACqF;IACrF,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC;AAED,qBAAa,sBAAuB,YAAW,aAAa,CAAC,eAAe,CAAC;IAC3E,QAAQ,CAAC,IAAI,uBAAuB;IACpC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAmB;IACxC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAA2B;IACvD,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAM;gBAEV,IAAI,EAAE,6BAA6B;IAK/C;kFAC8E;YAChE,QAAQ;IAYtB,yFAAyF;YAC3E,OAAO;IAgBrB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IAIrC,oGAAoG;IACpG,IAAI,OAAO,IAAI,MAAM,CAEpB;IAED;6DACyD;IACnD,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAO1C,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;IAOtB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;CAsB7E"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ModelCatalog } from "@cotal-ai/core";
|
|
2
|
+
/** Every 2.x install serves this list, so a read that does not produce one fails: the manager then
|
|
3
|
+
* reports the catalog unreadable, never as an install without a catalog. */
|
|
4
|
+
export declare function listOpenCode2Models(bin: string, env: NodeJS.ProcessEnv): Promise<ModelCatalog>;
|
|
5
|
+
//# sourceMappingURL=catalog2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog2.d.ts","sourceRoot":"","sources":["../src/catalog2.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAa,MAAM,gBAAgB,CAAC;AA+C9D;6EAC6E;AAC7E,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAa9F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-catalog.d.ts","sourceRoot":"","sources":["../src/command-catalog.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command-catalog.d.ts","sourceRoot":"","sources":["../src/command-catalog.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AA6CtE,sGAAsG;AACtG,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAMxH"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The commands and skills an OpenCode 1.x seat started in a directory would run, read before any seat
|
|
3
|
+
* exists. A 1.x server lists both at `GET /command` on the first request (measured on 1.19.6), so this
|
|
4
|
+
* reads that list once from a private server (private-serve.ts) and names each entry as the seat's
|
|
5
|
+
* dispatcher does (commands1.ts).
|
|
6
|
+
*/
|
|
7
|
+
import type { CommandCatalog } from "@cotal-ai/core";
|
|
8
|
+
import { type PrivateServe } from "./private-serve.js";
|
|
9
|
+
export declare function openCode1CommandCatalog(o: Omit<PrivateServe, "port">): Promise<CommandCatalog>;
|
|
10
|
+
//# sourceMappingURL=command-catalog1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-catalog1.d.ts","sourceRoot":"","sources":["../src/command-catalog1.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EAA8B,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEnF,wBAAsB,uBAAuB,CAAC,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAQpG"}
|
package/dist/command-routes.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* How OpenCode 2.x lists and runs commands and skills at its server: what a seat's
|
|
3
|
-
* lists and runs, and what the connector lists before launch (command-catalog.ts).
|
|
2
|
+
* How OpenCode 2.x lists and runs commands and skills at its server: what a seat's dispatcher
|
|
3
|
+
* (commands2.ts) lists and runs, and what the connector lists before launch (command-catalog.ts).
|
|
4
4
|
*/
|
|
5
5
|
import type { CommandEntry, CommandTarget } from "@cotal-ai/core";
|
|
6
6
|
/** How OpenCode lists and runs each command target, measured on 2.2.5. The field `key` of a listed
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The OpenCode 1.x dispatcher on the `agent` endpoint (SPEC 13.22), as measured on 1.19.6.
|
|
3
|
+
* `GET /command` lists commands and skills, a skill with `source: "skill"`, and
|
|
4
|
+
* `POST /session/:id/command` runs either by name. That route answers only once the turn it started
|
|
5
|
+
* has ended, so a dispatch resolves once that turn starts: OpenCode calls the
|
|
6
|
+
* `command.execute.before` hook, stores the command's prompt, and reports the session busy. An
|
|
7
|
+
* owner's turn goes out as a prompt, each image as a file part with a data URL, and `usage` reads
|
|
8
|
+
* the session's messages the way T3 Code's OpenCode provider does.
|
|
9
|
+
*/
|
|
10
|
+
import { type CommandDispatcher } from "@cotal-ai/connector-core";
|
|
11
|
+
import type { CommandEntry } from "@cotal-ai/core";
|
|
12
|
+
export interface Commands1Deps {
|
|
13
|
+
/** The plugin's OpenCode HTTP client. An answer that is not 2xx throws an Error with its `status`. */
|
|
14
|
+
api<T>(path: string, init?: RequestInit, timeoutMs?: number): Promise<T>;
|
|
15
|
+
/** The owned session, created first when there is none yet. */
|
|
16
|
+
ensureSession(): Promise<string | undefined>;
|
|
17
|
+
/** The session a turn runs in now, the connector's or its user's, or undefined while none runs. */
|
|
18
|
+
running(): string | undefined;
|
|
19
|
+
/** Record that the next end of the turn in `session` is a stop someone asked for. */
|
|
20
|
+
markInterrupt(session: string): void;
|
|
21
|
+
/** The `system` field of the first turn the plugin submits, or undefined once one went out. */
|
|
22
|
+
firstTurnSystem(): string | undefined;
|
|
23
|
+
/** A turn carrying the first-turn `system` field went out. */
|
|
24
|
+
primed(): void;
|
|
25
|
+
warn(message: string): void;
|
|
26
|
+
}
|
|
27
|
+
export interface Commands1 {
|
|
28
|
+
readonly dispatcher: CommandDispatcher;
|
|
29
|
+
/** The `command.execute.before` hook: OpenCode is about to store a command's prompt. */
|
|
30
|
+
starting(sessionID: string, command: string): void;
|
|
31
|
+
/** OpenCode reported `session` busy: a turn started in it. */
|
|
32
|
+
turnStarted(sessionID: string): void;
|
|
33
|
+
/** Teardown began: stop waiting on a command's answer. */
|
|
34
|
+
close(): void;
|
|
35
|
+
}
|
|
36
|
+
/** The entries of a `GET /command` answer, as a seat lists them and runs them by name. */
|
|
37
|
+
export declare function opencode1CommandEntries(data: unknown): CommandEntry[];
|
|
38
|
+
export declare function opencode1Commands(deps: Commands1Deps): Commands1;
|
|
39
|
+
//# sourceMappingURL=commands1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands1.d.ts","sourceRoot":"","sources":["../src/commands1.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAmD,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACnH,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,gBAAgB,CAAC;AAGlE,MAAM,WAAW,aAAa;IAC5B,sGAAsG;IACtG,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IACzE,+DAA+D;IAC/D,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7C,mGAAmG;IACnG,OAAO,IAAI,MAAM,GAAG,SAAS,CAAC;IAC9B,qFAAqF;IACrF,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,+FAA+F;IAC/F,eAAe,IAAI,MAAM,GAAG,SAAS,CAAC;IACtC,8DAA8D;IAC9D,MAAM,IAAI,IAAI,CAAC;IACf,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IACvC,wFAAwF;IACxF,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACnD,8DAA8D;IAC9D,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,0DAA0D;IAC1D,KAAK,IAAI,IAAI,CAAC;CACf;AAwCD,0FAA0F;AAC1F,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,OAAO,GAAG,YAAY,EAAE,CAIrE;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,CAoIhE"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The OpenCode 2.x dispatcher on the `agent` endpoint (SPEC 13.22): its commands and skills,
|
|
3
|
+
* interrupt, the owner's turns with images, and usage. A turn goes out as a prompt, each image a file
|
|
4
|
+
* attached by its data URL, and `usage` reads the session and its last model step the way T3 Code's
|
|
5
|
+
* OpenCode 2 provider does, as measured on 2.0.24.
|
|
6
|
+
*/
|
|
7
|
+
import { type CommandDispatcher } from "@cotal-ai/connector-core";
|
|
8
|
+
import { type OpenCodeApi } from "./opencode2-http.js";
|
|
9
|
+
export interface Commands2Deps {
|
|
10
|
+
api: OpenCodeApi;
|
|
11
|
+
/** The owned session, created first when there is none yet. */
|
|
12
|
+
ensureSession(): Promise<string | undefined>;
|
|
13
|
+
/** The owned session, or undefined before there is one. */
|
|
14
|
+
session(): string | undefined;
|
|
15
|
+
/** The `system` field of the first turn the plugin submits, or undefined once one went out. */
|
|
16
|
+
firstTurnSystem(): string | undefined;
|
|
17
|
+
/** A turn carrying the first-turn `system` field went out. */
|
|
18
|
+
primed(): void;
|
|
19
|
+
/** Aborted when teardown begins. */
|
|
20
|
+
signal: AbortSignal;
|
|
21
|
+
}
|
|
22
|
+
export interface Commands2 {
|
|
23
|
+
readonly dispatcher: CommandDispatcher;
|
|
24
|
+
/** Each event the plugin's event loop reads: a list's `loaded` event ends the first list's wait. */
|
|
25
|
+
event(type: string): void;
|
|
26
|
+
}
|
|
27
|
+
export declare function opencode2Commands(deps: Commands2Deps): Commands2;
|
|
28
|
+
//# sourceMappingURL=commands2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands2.d.ts","sourceRoot":"","sources":["../src/commands2.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAmD,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAInH,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAiB1E,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,WAAW,CAAC;IACjB,+DAA+D;IAC/D,aAAa,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7C,2DAA2D;IAC3D,OAAO,IAAI,MAAM,GAAG,SAAS,CAAC;IAC9B,+FAA+F;IAC/F,eAAe,IAAI,MAAM,GAAG,SAAS,CAAC;IACtC,8DAA8D;IAC9D,MAAM,IAAI,IAAI,CAAC;IACf,oCAAoC;IACpC,MAAM,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IACvC,oGAAoG;IACpG,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,CAuHhE"}
|
package/dist/extension.d.ts
CHANGED
|
@@ -11,7 +11,8 @@ import { type Connector } from "@cotal-ai/core";
|
|
|
11
11
|
* Config rides in `OPENCODE_CONFIG_CONTENT` (inline JSON, the highest merge layer), so the
|
|
12
12
|
* operator's `~/.config/opencode` is never written.
|
|
13
13
|
* `permission:"allow"` keeps a supervised agent from stalling on a tool approval the human may not
|
|
14
|
-
* be at the keyboard to grant
|
|
14
|
+
* be at the keyboard to grant, unless the launch asks first (`askPermissions`). Self-registers on
|
|
15
|
+
* import; the manager resolves it by type "opencode".
|
|
15
16
|
*/
|
|
16
17
|
export declare const opencodeConnector: Connector;
|
|
17
18
|
//# sourceMappingURL=extension.d.ts.map
|
package/dist/extension.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAGA,OAAO,EAAY,KAAK,SAAS,EAA8F,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":"AAGA,OAAO,EAAY,KAAK,SAAS,EAA8F,MAAM,gBAAgB,CAAC;AAyItJ;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAiM/B,CAAC"}
|