opencode-devin 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.js +18 -7
- package/dist/index.js +2 -2
- package/dist/protocol/model.d.ts +2 -2
- package/dist/protocol/model.js +3 -3
- package/package.json +4 -3
- package/dist/auth/browser.d.ts +0 -7
- package/dist/auth/browser.js +0 -18
- package/dist/auth/exchange.d.ts +0 -15
- package/dist/auth/exchange.js +0 -43
- package/dist/auth/login.d.ts +0 -15
- package/dist/auth/login.js +0 -51
- package/dist/auth/loopback.d.ts +0 -15
- package/dist/auth/loopback.js +0 -93
- package/dist/auth/pkce.d.ts +0 -11
- package/dist/auth/pkce.js +0 -27
- package/dist/auth/url.d.ts +0 -12
- package/dist/auth/url.js +0 -17
- package/dist/protocol/auth.d.ts +0 -31
- package/dist/protocol/auth.js +0 -142
- package/dist/protocol/catalog.d.ts +0 -69
- package/dist/protocol/catalog.js +0 -230
- package/dist/protocol/chat.d.ts +0 -128
- package/dist/protocol/chat.js +0 -629
- package/dist/protocol/effort.d.ts +0 -36
- package/dist/protocol/effort.js +0 -71
- package/dist/protocol/metadata.d.ts +0 -17
- package/dist/protocol/metadata.js +0 -42
- package/dist/protocol/wire.d.ts +0 -30
- package/dist/protocol/wire.js +0 -114
package/dist/protocol/effort.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reasoning-effort handling, in one place.
|
|
3
|
-
*
|
|
4
|
-
* The catalog encodes effort as a suffix on the model UID, and both the
|
|
5
|
-
* catalog decoder and the request path have to read that suffix. They used to
|
|
6
|
-
* carry their own copy of the same alternation, which is exactly the kind of
|
|
7
|
-
* duplication that drifts when Cognition adds an effort level.
|
|
8
|
-
*/
|
|
9
|
-
/** Valid reasoning effort levels, weakest first. */
|
|
10
|
-
export const EFFORT_LEVELS = ["none", "minimal", "low", "medium", "high", "xhigh", "max"];
|
|
11
|
-
/** Narrow an arbitrary value to a known effort level, or `undefined`. */
|
|
12
|
-
export function toEffortLevel(value) {
|
|
13
|
-
if (typeof value !== "string")
|
|
14
|
-
return undefined;
|
|
15
|
-
const effort = value.toLowerCase();
|
|
16
|
-
return EFFORT_LEVELS.includes(effort) ? effort : undefined;
|
|
17
|
-
}
|
|
18
|
-
/** Effort named by a catalog capability value, e.g. "XHigh" or "No Thinking". */
|
|
19
|
-
export function effortFromLabel(label) {
|
|
20
|
-
if (!label)
|
|
21
|
-
return undefined;
|
|
22
|
-
return /^no thinking$/i.test(label.trim()) ? "none" : toEffortLevel(label.trim());
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Index of the effort segment in a UID split on "-".
|
|
26
|
-
*
|
|
27
|
-
* The effort is not always last: speed and context modifiers follow it, as in
|
|
28
|
-
* `claude-opus-5-5-high-fast`, `gpt-5-6-sol-none-priority` and
|
|
29
|
-
* `glm-5-2-max-1m`. The last effort word wins, and the first segment is never
|
|
30
|
-
* one, so a bare effort word is not a suffix.
|
|
31
|
-
*/
|
|
32
|
-
function effortIndex(segments) {
|
|
33
|
-
for (let i = segments.length - 1; i > 0; i--) {
|
|
34
|
-
if (toEffortLevel(segments[i]) === segments[i])
|
|
35
|
-
return i;
|
|
36
|
-
}
|
|
37
|
-
return -1;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Split a UID into its base UID and effort, e.g. `opus-4-8-high` into
|
|
41
|
-
* `opus-4-8` and `high`, or `opus-4-8-high-fast` into `opus-4-8-fast` and `high`.
|
|
42
|
-
*/
|
|
43
|
-
export function splitEffortSuffix(modelUid) {
|
|
44
|
-
const segments = modelUid.split("-");
|
|
45
|
-
const index = effortIndex(segments);
|
|
46
|
-
if (index === -1)
|
|
47
|
-
return { baseModelUid: modelUid };
|
|
48
|
-
return {
|
|
49
|
-
baseModelUid: [...segments.slice(0, index), ...segments.slice(index + 1)].join("-"),
|
|
50
|
-
effortLevel: segments[index],
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
/** Replace the effort in a UID that has one, or append it to one that does not. */
|
|
54
|
-
export function withEffortSuffix(modelUid, effort) {
|
|
55
|
-
const segments = modelUid.split("-");
|
|
56
|
-
const index = effortIndex(segments);
|
|
57
|
-
if (index === -1)
|
|
58
|
-
return `${modelUid}-${effort}`;
|
|
59
|
-
segments[index] = effort;
|
|
60
|
-
return segments.join("-");
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* The member to use when no effort is asked for: the UID that carries no
|
|
64
|
-
* effort if the family has one, otherwise medium, then high, then the first.
|
|
65
|
-
*/
|
|
66
|
-
export function defaultMember(family) {
|
|
67
|
-
return (family.find((member) => member.modelUid === (member.baseModelUid ?? member.modelUid)) ??
|
|
68
|
-
family.find((member) => member.effortLevel === "medium") ??
|
|
69
|
-
family.find((member) => member.effortLevel === "high") ??
|
|
70
|
-
family[0]);
|
|
71
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `Metadata` proto builder sent with every Codeium/Cognition RPC.
|
|
3
|
-
*
|
|
4
|
-
* Field layout reverse-engineered from the Windsurf language_server; originally
|
|
5
|
-
* ported from pi-devin-auth (MIT, Copyright (c) 2026 nmzpy).
|
|
6
|
-
*/
|
|
7
|
-
export interface MetadataInput {
|
|
8
|
-
apiKey: string;
|
|
9
|
-
sessionId: string;
|
|
10
|
-
requestId: bigint;
|
|
11
|
-
triggerId: string;
|
|
12
|
-
/** Short-lived JWT from GetUserJwt, required for catalog and chat RPCs. */
|
|
13
|
-
userJwt?: string;
|
|
14
|
-
osName?: string;
|
|
15
|
-
version?: string;
|
|
16
|
-
}
|
|
17
|
-
export declare function buildMetadata(input: MetadataInput): Buffer;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `Metadata` proto builder sent with every Codeium/Cognition RPC.
|
|
3
|
-
*
|
|
4
|
-
* Field layout reverse-engineered from the Windsurf language_server; originally
|
|
5
|
-
* ported from pi-devin-auth (MIT, Copyright (c) 2026 nmzpy).
|
|
6
|
-
*/
|
|
7
|
-
import { encodeMessage, encodeString, encodeTimestampBody, encodeVarintField } from "./wire.js";
|
|
8
|
-
const VERSION_STRING = "2.0.0";
|
|
9
|
-
function osName() {
|
|
10
|
-
switch (process.platform) {
|
|
11
|
-
case "darwin":
|
|
12
|
-
return "darwin";
|
|
13
|
-
case "linux":
|
|
14
|
-
return "linux";
|
|
15
|
-
case "win32":
|
|
16
|
-
return "windows";
|
|
17
|
-
default:
|
|
18
|
-
return process.platform;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
export function buildMetadata(input) {
|
|
22
|
-
const version = input.version ?? VERSION_STRING;
|
|
23
|
-
const os = input.osName ?? osName();
|
|
24
|
-
const parts = [
|
|
25
|
-
encodeString(1, "windsurf"),
|
|
26
|
-
encodeString(2, version),
|
|
27
|
-
encodeString(3, input.apiKey),
|
|
28
|
-
encodeString(4, "en"),
|
|
29
|
-
encodeString(5, os),
|
|
30
|
-
encodeString(7, version),
|
|
31
|
-
encodeVarintField(9, input.requestId),
|
|
32
|
-
encodeString(10, input.sessionId),
|
|
33
|
-
encodeString(12, "windsurf"),
|
|
34
|
-
encodeMessage(16, encodeTimestampBody()),
|
|
35
|
-
encodeString(25, input.triggerId),
|
|
36
|
-
encodeString(26, "Unset"),
|
|
37
|
-
encodeString(28, "windsurf"),
|
|
38
|
-
];
|
|
39
|
-
if (input.userJwt)
|
|
40
|
-
parts.push(encodeString(21, input.userJwt));
|
|
41
|
-
return Buffer.concat(parts);
|
|
42
|
-
}
|
package/dist/protocol/wire.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Protobuf wire-format encoding and Connect-RPC streaming envelope.
|
|
3
|
-
*
|
|
4
|
-
* Connect-RPC streaming frame layout (HTTPS POST body):
|
|
5
|
-
*
|
|
6
|
-
* flags 1 byte | length 4 bytes BE | payload
|
|
7
|
-
*
|
|
8
|
-
* - flags bit 0x01: payload is gzip-compressed
|
|
9
|
-
* - flags bit 0x02: end-of-stream trailer frame (JSON `{error}` or empty)
|
|
10
|
-
*
|
|
11
|
-
* Protocol reverse-engineered from the Windsurf language_server and the Devin
|
|
12
|
-
* CLI; originally ported from pi-devin-auth (MIT, Copyright (c) 2026 nmzpy).
|
|
13
|
-
*/
|
|
14
|
-
export type WireType = 0 | 1 | 2 | 5;
|
|
15
|
-
export interface ProtoField {
|
|
16
|
-
readonly num: number;
|
|
17
|
-
readonly wire: WireType;
|
|
18
|
-
readonly value: bigint | Buffer;
|
|
19
|
-
}
|
|
20
|
-
export declare function encodeVarint(value: bigint | number): Buffer;
|
|
21
|
-
export declare function encodeTag(fieldNum: number, wire: WireType): Buffer;
|
|
22
|
-
export declare function encodeString(fieldNum: number, value: string): Buffer;
|
|
23
|
-
export declare function encodeMessage(fieldNum: number, body: Buffer): Buffer;
|
|
24
|
-
export declare function encodeVarintField(fieldNum: number, value: bigint | number): Buffer;
|
|
25
|
-
export declare function encodeTimestampBody(): Buffer;
|
|
26
|
-
export declare function decodeVarint(buf: Buffer, offset: number): [bigint, number];
|
|
27
|
-
/** Iterate the protobuf fields of a message in wire order. */
|
|
28
|
-
export declare function iterFields(buf: Buffer): Generator<ProtoField>;
|
|
29
|
-
/** Wrap a protobuf message into a Connect-RPC streaming request frame. */
|
|
30
|
-
export declare function frameConnectStream(body: Buffer, compress?: boolean): Buffer;
|
package/dist/protocol/wire.js
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Protobuf wire-format encoding and Connect-RPC streaming envelope.
|
|
3
|
-
*
|
|
4
|
-
* Connect-RPC streaming frame layout (HTTPS POST body):
|
|
5
|
-
*
|
|
6
|
-
* flags 1 byte | length 4 bytes BE | payload
|
|
7
|
-
*
|
|
8
|
-
* - flags bit 0x01: payload is gzip-compressed
|
|
9
|
-
* - flags bit 0x02: end-of-stream trailer frame (JSON `{error}` or empty)
|
|
10
|
-
*
|
|
11
|
-
* Protocol reverse-engineered from the Windsurf language_server and the Devin
|
|
12
|
-
* CLI; originally ported from pi-devin-auth (MIT, Copyright (c) 2026 nmzpy).
|
|
13
|
-
*/
|
|
14
|
-
import * as zlib from "node:zlib";
|
|
15
|
-
export function encodeVarint(value) {
|
|
16
|
-
let v = BigInt(value);
|
|
17
|
-
if (v < 0n)
|
|
18
|
-
throw new RangeError(`encodeVarint: negative input not supported (got ${value})`);
|
|
19
|
-
const bytes = [];
|
|
20
|
-
while (v > 0x7fn) {
|
|
21
|
-
bytes.push(Number(v & 0x7fn) | 0x80);
|
|
22
|
-
v >>= 7n;
|
|
23
|
-
}
|
|
24
|
-
bytes.push(Number(v));
|
|
25
|
-
return Buffer.from(bytes);
|
|
26
|
-
}
|
|
27
|
-
export function encodeTag(fieldNum, wire) {
|
|
28
|
-
return encodeVarint((fieldNum << 3) | wire);
|
|
29
|
-
}
|
|
30
|
-
export function encodeString(fieldNum, value) {
|
|
31
|
-
const buf = Buffer.from(value, "utf8");
|
|
32
|
-
return Buffer.concat([encodeTag(fieldNum, 2), encodeVarint(buf.length), buf]);
|
|
33
|
-
}
|
|
34
|
-
export function encodeMessage(fieldNum, body) {
|
|
35
|
-
return Buffer.concat([encodeTag(fieldNum, 2), encodeVarint(body.length), body]);
|
|
36
|
-
}
|
|
37
|
-
export function encodeVarintField(fieldNum, value) {
|
|
38
|
-
return Buffer.concat([encodeTag(fieldNum, 0), encodeVarint(value)]);
|
|
39
|
-
}
|
|
40
|
-
export function encodeTimestampBody() {
|
|
41
|
-
const now = Date.now();
|
|
42
|
-
const seconds = Math.floor(now / 1000);
|
|
43
|
-
const nanos = (now % 1000) * 1_000_000;
|
|
44
|
-
return Buffer.concat([
|
|
45
|
-
encodeVarintField(1, seconds),
|
|
46
|
-
nanos > 0 ? encodeVarintField(2, nanos) : Buffer.alloc(0),
|
|
47
|
-
]);
|
|
48
|
-
}
|
|
49
|
-
export function decodeVarint(buf, offset) {
|
|
50
|
-
let result = 0n;
|
|
51
|
-
let shift = 0n;
|
|
52
|
-
let i = offset;
|
|
53
|
-
while (i < buf.length) {
|
|
54
|
-
const byte = buf[i++];
|
|
55
|
-
result |= BigInt(byte & 0x7f) << shift;
|
|
56
|
-
if (!(byte & 0x80))
|
|
57
|
-
return [result, i];
|
|
58
|
-
shift += 7n;
|
|
59
|
-
}
|
|
60
|
-
throw new Error("truncated varint");
|
|
61
|
-
}
|
|
62
|
-
/** Iterate the protobuf fields of a message in wire order. */
|
|
63
|
-
export function* iterFields(buf) {
|
|
64
|
-
let i = 0;
|
|
65
|
-
while (i < buf.length) {
|
|
66
|
-
const [tagBig, afterTag] = decodeVarint(buf, i);
|
|
67
|
-
i = afterTag;
|
|
68
|
-
const tag = Number(tagBig);
|
|
69
|
-
const num = tag >> 3;
|
|
70
|
-
const wire = (tag & 0x7);
|
|
71
|
-
if (wire === 0) {
|
|
72
|
-
const [value, afterValue] = decodeVarint(buf, i);
|
|
73
|
-
i = afterValue;
|
|
74
|
-
yield { num, wire, value };
|
|
75
|
-
}
|
|
76
|
-
else if (wire === 1) {
|
|
77
|
-
if (i + 8 > buf.length)
|
|
78
|
-
return;
|
|
79
|
-
yield { num, wire, value: buf.slice(i, i + 8) };
|
|
80
|
-
i += 8;
|
|
81
|
-
}
|
|
82
|
-
else if (wire === 2) {
|
|
83
|
-
const [lengthBig, afterLength] = decodeVarint(buf, i);
|
|
84
|
-
i = afterLength;
|
|
85
|
-
const length = Number(lengthBig);
|
|
86
|
-
if (length < 0 || i + length > buf.length)
|
|
87
|
-
return;
|
|
88
|
-
yield { num, wire, value: buf.slice(i, i + length) };
|
|
89
|
-
i += length;
|
|
90
|
-
}
|
|
91
|
-
else if (wire === 5) {
|
|
92
|
-
if (i + 4 > buf.length)
|
|
93
|
-
return;
|
|
94
|
-
yield { num, wire, value: buf.slice(i, i + 4) };
|
|
95
|
-
i += 4;
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
/** Wrap a protobuf message into a Connect-RPC streaming request frame. */
|
|
103
|
-
export function frameConnectStream(body, compress = true) {
|
|
104
|
-
let payload = body;
|
|
105
|
-
let flags = 0;
|
|
106
|
-
if (compress) {
|
|
107
|
-
payload = zlib.gzipSync(body);
|
|
108
|
-
flags |= 0x01;
|
|
109
|
-
}
|
|
110
|
-
const header = Buffer.alloc(5);
|
|
111
|
-
header[0] = flags;
|
|
112
|
-
header.writeUInt32BE(payload.length, 1);
|
|
113
|
-
return Buffer.concat([header, payload]);
|
|
114
|
-
}
|