@botiverse/oar 0.99.0 → 0.100.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/README.md +15 -15
- package/dist/contracts/login.d.ts +7 -1
- package/dist/contracts/login.d.ts.map +1 -1
- package/dist/contracts/provider-auth.d.ts +8 -4
- package/dist/contracts/provider-auth.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/runtimes/antigravity/logout.d.ts.map +1 -1
- package/dist/runtimes/antigravity/logout.js +3 -2
- package/dist/runtimes/antigravity/logout.js.map +1 -1
- package/dist/runtimes/claude/logout.d.ts.map +1 -1
- package/dist/runtimes/claude/logout.js +3 -2
- package/dist/runtimes/claude/logout.js.map +1 -1
- package/dist/runtimes/codebuddy/index.d.ts +1 -0
- package/dist/runtimes/codebuddy/index.d.ts.map +1 -1
- package/dist/runtimes/codebuddy/index.js +1 -0
- package/dist/runtimes/codebuddy/index.js.map +1 -1
- package/dist/runtimes/codebuddy/logout.d.ts +5 -0
- package/dist/runtimes/codebuddy/logout.d.ts.map +1 -0
- package/dist/runtimes/codebuddy/logout.js +57 -0
- package/dist/runtimes/codebuddy/logout.js.map +1 -0
- package/dist/runtimes/codex/installation.d.ts +15 -4
- package/dist/runtimes/codex/installation.d.ts.map +1 -1
- package/dist/runtimes/codex/installation.js +42 -9
- package/dist/runtimes/codex/installation.js.map +1 -1
- package/dist/runtimes/codex/logout.d.ts.map +1 -1
- package/dist/runtimes/codex/logout.js +3 -2
- package/dist/runtimes/codex/logout.js.map +1 -1
- package/dist/runtimes/grok/auth.d.ts.map +1 -1
- package/dist/runtimes/grok/auth.js +3 -2
- package/dist/runtimes/grok/auth.js.map +1 -1
- package/dist/runtimes/kimi/logout.d.ts.map +1 -1
- package/dist/runtimes/kimi/logout.js +3 -2
- package/dist/runtimes/kimi/logout.js.map +1 -1
- package/dist/runtimes/opencode/index.d.ts +2 -0
- package/dist/runtimes/opencode/index.d.ts.map +1 -1
- package/dist/runtimes/opencode/index.js +1 -0
- package/dist/runtimes/opencode/index.js.map +1 -1
- package/dist/runtimes/opencode/provider-auth-error.d.ts +25 -0
- package/dist/runtimes/opencode/provider-auth-error.d.ts.map +1 -0
- package/dist/runtimes/opencode/provider-auth-error.js +13 -0
- package/dist/runtimes/opencode/provider-auth-error.js.map +1 -0
- package/dist/runtimes/opencode/provider-auth-facade.d.ts +28 -0
- package/dist/runtimes/opencode/provider-auth-facade.d.ts.map +1 -0
- package/dist/runtimes/opencode/provider-auth-facade.js +178 -0
- package/dist/runtimes/opencode/provider-auth-facade.js.map +1 -0
- package/dist/runtimes/opencode/provider-auth-oauth.d.ts +24 -0
- package/dist/runtimes/opencode/provider-auth-oauth.d.ts.map +1 -0
- package/dist/runtimes/opencode/provider-auth-oauth.js +189 -0
- package/dist/runtimes/opencode/provider-auth-oauth.js.map +1 -0
- package/dist/runtimes/opencode/provider-auth-prompts.d.ts +16 -0
- package/dist/runtimes/opencode/provider-auth-prompts.d.ts.map +1 -0
- package/dist/runtimes/opencode/provider-auth-prompts.js +91 -0
- package/dist/runtimes/opencode/provider-auth-prompts.js.map +1 -0
- package/dist/runtimes/opencode/provider-auth-registry.d.ts +79 -0
- package/dist/runtimes/opencode/provider-auth-registry.d.ts.map +1 -0
- package/dist/runtimes/opencode/provider-auth-registry.js +146 -0
- package/dist/runtimes/opencode/provider-auth-registry.js.map +1 -0
- package/dist/runtimes/opencode/provider-auth-server.d.ts +38 -0
- package/dist/runtimes/opencode/provider-auth-server.d.ts.map +1 -0
- package/dist/runtimes/opencode/provider-auth-server.js +221 -0
- package/dist/runtimes/opencode/provider-auth-server.js.map +1 -0
- package/dist/runtimes/opencode/provider-auth.d.ts +49 -0
- package/dist/runtimes/opencode/provider-auth.d.ts.map +1 -0
- package/dist/runtimes/opencode/provider-auth.js +39 -0
- package/dist/runtimes/opencode/provider-auth.js.map +1 -0
- package/dist/shared/acp/session.js +4 -1
- package/dist/shared/acp/session.js.map +1 -1
- package/dist/shared/acp/turn-terminals.d.ts +2 -1
- package/dist/shared/acp/turn-terminals.d.ts.map +1 -1
- package/dist/shared/acp/turn-terminals.js +47 -23
- package/dist/shared/acp/turn-terminals.js.map +1 -1
- package/dist/shared/executable/host-watchdog.d.ts +22 -0
- package/dist/shared/executable/host-watchdog.d.ts.map +1 -0
- package/dist/shared/executable/host-watchdog.js +79 -0
- package/dist/shared/executable/host-watchdog.js.map +1 -0
- package/dist/shared/executable/node-eval.d.ts +10 -0
- package/dist/shared/executable/node-eval.d.ts.map +1 -0
- package/dist/shared/executable/node-eval.js +17 -0
- package/dist/shared/executable/node-eval.js.map +1 -0
- package/dist/shared/login.d.ts +9 -4
- package/dist/shared/login.d.ts.map +1 -1
- package/dist/shared/login.js +15 -7
- package/dist/shared/login.js.map +1 -1
- package/dist/shared/logout.d.ts +8 -0
- package/dist/shared/logout.d.ts.map +1 -1
- package/dist/shared/logout.js +13 -0
- package/dist/shared/logout.js.map +1 -1
- package/dist/shared/shell-environment.d.ts.map +1 -1
- package/dist/shared/shell-environment.js +6 -13
- package/dist/shared/shell-environment.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ProviderLoginInteraction, ProviderLoginPrompt } from "../../contracts/provider-auth.js";
|
|
2
|
+
import { type OpencodeFormField } from "./provider-auth-registry.js";
|
|
3
|
+
/** A `Form.Value` OpenCode accepts in an `answer`. */
|
|
4
|
+
export type FormValue = string | number | boolean | readonly string[];
|
|
5
|
+
/** Both signals as one, either may be absent. */
|
|
6
|
+
export declare function eitherSignal(first: AbortSignal | undefined, second: AbortSignal | undefined): AbortSignal | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* Ask the host, rejecting with the signal's reason once it aborts even if the
|
|
9
|
+
* host leaves its prompt pending (Pi's facade does the same).
|
|
10
|
+
*/
|
|
11
|
+
export declare function ask(interaction: ProviderLoginInteraction, prompt: ProviderLoginPrompt): Promise<string>;
|
|
12
|
+
/** True when the form would ask the person something a bare key cannot answer. */
|
|
13
|
+
export declare function formAsks(fields: readonly OpencodeFormField[]): boolean;
|
|
14
|
+
/** Ask each applicable required field in OpenCode's order; the answer object holds only what the person gave. */
|
|
15
|
+
export declare function askForm(interaction: ProviderLoginInteraction, fields: readonly OpencodeFormField[], signal: AbortSignal | undefined): Promise<Record<string, FormValue>>;
|
|
16
|
+
//# sourceMappingURL=provider-auth-prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-auth-prompts.d.ts","sources":["../../../src/runtimes/opencode/provider-auth-prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACtG,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEnF,sDAAsD;AACtD,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,MAAM,EAAE,CAAC;AAEtE,iDAAiD;AACjD,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,CAKrH;AAED;;;GAGG;AACH,wBAAsB,GAAG,CAAC,WAAW,EAAE,wBAAwB,EAAE,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAc7G;AAgBD,kFAAkF;AAClF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,GAAG,OAAO,CAGtE;AAkCD,iHAAiH;AACjH,wBAAsB,OAAO,CAC3B,WAAW,EAAE,wBAAwB,EACrC,MAAM,EAAE,SAAS,iBAAiB,EAAE,EACpC,MAAM,EAAE,WAAW,GAAG,SAAS,GAC9B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAapC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { fieldApplies } from "./provider-auth-registry.js";
|
|
2
|
+
/** Both signals as one, either may be absent. */
|
|
3
|
+
export function eitherSignal(first, second) {
|
|
4
|
+
if (first === undefined) {
|
|
5
|
+
return second;
|
|
6
|
+
}
|
|
7
|
+
return second === undefined ? first : AbortSignal.any([first, second]);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Ask the host, rejecting with the signal's reason once it aborts even if the
|
|
11
|
+
* host leaves its prompt pending (Pi's facade does the same).
|
|
12
|
+
*/
|
|
13
|
+
export async function ask(interaction, prompt) {
|
|
14
|
+
const { signal } = prompt;
|
|
15
|
+
signal?.throwIfAborted();
|
|
16
|
+
if (signal === undefined) {
|
|
17
|
+
return interaction.prompt(prompt);
|
|
18
|
+
}
|
|
19
|
+
const aborted = Promise.withResolvers();
|
|
20
|
+
const abort = () => { aborted.reject(signal.reason); };
|
|
21
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
22
|
+
try {
|
|
23
|
+
return await Promise.race([interaction.prompt(prompt), aborted.promise]);
|
|
24
|
+
}
|
|
25
|
+
finally {
|
|
26
|
+
signal.removeEventListener("abort", abort);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The fields OAR asks: required, visible and applicable given the answers so
|
|
31
|
+
* far. Hidden and optional ones are left to OpenCode, which applies their
|
|
32
|
+
* defaults itself (observed on 2.2.7 for GitLab's instance URL and the
|
|
33
|
+
* OpenCode console's hidden server); `external` fields cannot be answered here.
|
|
34
|
+
*/
|
|
35
|
+
function asked(entry, answers) {
|
|
36
|
+
return entry.required && !entry.hidden && entry.type !== "external" && fieldApplies(entry, answers);
|
|
37
|
+
}
|
|
38
|
+
function defaults(fields) {
|
|
39
|
+
return Object.fromEntries(fields.flatMap((entry) => (entry.default === undefined ? [] : [[entry.key, entry.default]])));
|
|
40
|
+
}
|
|
41
|
+
/** True when the form would ask the person something a bare key cannot answer. */
|
|
42
|
+
export function formAsks(fields) {
|
|
43
|
+
const known = defaults(fields);
|
|
44
|
+
return fields.some((entry) => asked(entry, known) && entry.default === undefined);
|
|
45
|
+
}
|
|
46
|
+
function promptFor(entry, signal) {
|
|
47
|
+
const message = entry.title ?? entry.key;
|
|
48
|
+
const cancellation = signal === undefined ? {} : { signal };
|
|
49
|
+
if (entry.type === "boolean") {
|
|
50
|
+
return { ...cancellation, kind: "select", message, options: [{ id: "true", label: "Yes" }, { id: "false", label: "No" }] };
|
|
51
|
+
}
|
|
52
|
+
if (entry.options.length > 0 && !entry.custom && entry.type !== "multiselect") {
|
|
53
|
+
return { ...cancellation, kind: "select", message, options: entry.options.map((option) => ({ id: option.value, label: option.label })) };
|
|
54
|
+
}
|
|
55
|
+
const fallback = typeof entry.default === "string" ? entry.default : undefined;
|
|
56
|
+
const placeholder = entry.placeholder ?? fallback;
|
|
57
|
+
return { ...cancellation, kind: "text", message, ...(placeholder === undefined ? {} : { placeholder }) };
|
|
58
|
+
}
|
|
59
|
+
function valueOf(entry, answer) {
|
|
60
|
+
const trimmed = answer.trim();
|
|
61
|
+
if (trimmed === "") {
|
|
62
|
+
return typeof entry.default === "string" || typeof entry.default === "number" || typeof entry.default === "boolean" ? entry.default : undefined;
|
|
63
|
+
}
|
|
64
|
+
switch (entry.type) {
|
|
65
|
+
case "boolean":
|
|
66
|
+
return trimmed === "true";
|
|
67
|
+
case "number":
|
|
68
|
+
case "integer":
|
|
69
|
+
return Number(trimmed);
|
|
70
|
+
case "multiselect":
|
|
71
|
+
return trimmed.split(",").map((part) => part.trim()).filter((part) => part !== "");
|
|
72
|
+
default:
|
|
73
|
+
return trimmed;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** Ask each applicable required field in OpenCode's order; the answer object holds only what the person gave. */
|
|
77
|
+
export async function askForm(interaction, fields, signal) {
|
|
78
|
+
const answers = {};
|
|
79
|
+
const known = defaults(fields);
|
|
80
|
+
for (const entry of fields) {
|
|
81
|
+
if (!asked(entry, { ...known, ...answers })) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const value = valueOf(entry, await ask(interaction, promptFor(entry, signal)));
|
|
85
|
+
if (value !== undefined) {
|
|
86
|
+
answers[entry.key] = value;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return answers;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=provider-auth-prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-auth-prompts.js","sources":["../../../src/runtimes/opencode/provider-auth-prompts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAA0B,MAAM,6BAA6B,CAAC;AAKnF,iDAAiD;AACjD,MAAM,UAAU,YAAY,CAAC,KAA8B,EAAE,MAA+B;IAC1F,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AACzE,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,WAAqC,EAAE,MAA2B;IAC1F,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAC1B,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,EAAS,CAAC;IAC/C,MAAM,KAAK,GAAG,GAAS,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,EA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QAC/E,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC7B,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { LoginProvider, ProviderAuthStatus } from "../../contracts/provider-auth.js";
|
|
2
|
+
export interface OpencodeFormOption {
|
|
3
|
+
readonly value: string;
|
|
4
|
+
readonly label: string;
|
|
5
|
+
}
|
|
6
|
+
/** One `Form.Field`, reduced to what a prompt needs. */
|
|
7
|
+
export interface OpencodeFormField {
|
|
8
|
+
readonly key: string;
|
|
9
|
+
readonly type: string;
|
|
10
|
+
readonly title?: string;
|
|
11
|
+
readonly required: boolean;
|
|
12
|
+
readonly hidden: boolean;
|
|
13
|
+
readonly custom: boolean;
|
|
14
|
+
readonly placeholder?: string;
|
|
15
|
+
readonly default?: unknown;
|
|
16
|
+
readonly options: readonly OpencodeFormOption[];
|
|
17
|
+
readonly when: readonly {
|
|
18
|
+
readonly key: string;
|
|
19
|
+
readonly op: string;
|
|
20
|
+
readonly value: unknown;
|
|
21
|
+
}[];
|
|
22
|
+
}
|
|
23
|
+
export type OpencodeMethod = {
|
|
24
|
+
readonly type: "oauth";
|
|
25
|
+
readonly id: string;
|
|
26
|
+
readonly label?: string;
|
|
27
|
+
readonly form: readonly OpencodeFormField[];
|
|
28
|
+
} | {
|
|
29
|
+
readonly type: "key";
|
|
30
|
+
readonly label?: string;
|
|
31
|
+
readonly form: readonly OpencodeFormField[];
|
|
32
|
+
} | {
|
|
33
|
+
readonly type: "env";
|
|
34
|
+
readonly names: readonly string[];
|
|
35
|
+
}
|
|
36
|
+
/** `external` and `command`: OpenCode reads a credential another tool keeps; OAR offers no flow for them. */
|
|
37
|
+
| {
|
|
38
|
+
readonly type: "other";
|
|
39
|
+
readonly native: string;
|
|
40
|
+
};
|
|
41
|
+
/** A stored credential (`Connection.CredentialInfo`) or an environment variable OpenCode found (`Connection.EnvInfo`). No secret is in either. */
|
|
42
|
+
export type OpencodeConnection = {
|
|
43
|
+
readonly type: "credential";
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly label?: string;
|
|
46
|
+
readonly method?: string;
|
|
47
|
+
} | {
|
|
48
|
+
readonly type: "env";
|
|
49
|
+
readonly name: string;
|
|
50
|
+
};
|
|
51
|
+
export interface OpencodeIntegration {
|
|
52
|
+
readonly id: string;
|
|
53
|
+
readonly name: string;
|
|
54
|
+
readonly methods: readonly OpencodeMethod[];
|
|
55
|
+
readonly connections: readonly OpencodeConnection[];
|
|
56
|
+
}
|
|
57
|
+
/** One `Integration.Info`; undefined when it lacks an id. */
|
|
58
|
+
export declare function parseIntegration(value: unknown): OpencodeIntegration | undefined;
|
|
59
|
+
/** `integration.list`'s `data`, in OpenCode's order. */
|
|
60
|
+
export declare function parseIntegrations(body: unknown): OpencodeIntegration[];
|
|
61
|
+
/**
|
|
62
|
+
* The ways OpenCode offers to sign in to one integration: each `oauth`
|
|
63
|
+
* method under its own label, with no `subscription` (OpenCode does not
|
|
64
|
+
* say whether a sign-in is one), then its `key` prompt, then its `env`
|
|
65
|
+
* variables as an ambient key. `external` and `command` methods read a
|
|
66
|
+
* credential another tool keeps and are omitted.
|
|
67
|
+
*/
|
|
68
|
+
export declare function loginProviderOf(integration: OpencodeIntegration): LoginProvider | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Status from OpenCode's connections, never a secret: a stored credential
|
|
71
|
+
* first (OpenCode lists the newest first), else an environment variable it
|
|
72
|
+
* found. An `external` credential is configured with no contract method.
|
|
73
|
+
*/
|
|
74
|
+
export declare function statusOf(providerId: string, connections: readonly OpencodeConnection[]): ProviderAuthStatus;
|
|
75
|
+
/** The user code in an attempt's instructions: `Enter code: X` (GitHub Copilot, OpenAI) or `... and enter code: X` (xAI). */
|
|
76
|
+
export declare function deviceCodeOf(instructions: string): string | undefined;
|
|
77
|
+
/** A field applies when every `when` condition holds against the answers so far. */
|
|
78
|
+
export declare function fieldApplies(entry: OpencodeFormField, answers: Readonly<Record<string, unknown>>): boolean;
|
|
79
|
+
//# sourceMappingURL=provider-auth-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-auth-registry.d.ts","sources":["../../../src/runtimes/opencode/provider-auth-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAuB,kBAAkB,EAAuB,MAAM,kCAAkC,CAAC;AASpI,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,wDAAwD;AACxD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAChD,QAAQ,CAAC,IAAI,EAAE,SAAS;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CAClG;AAED,MAAM,MAAM,cAAc,GACtB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,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G,mBAAmB,EAAE,CAGtE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,mBAAmB,GAAG,aAAa,GAAG,SAAS,CAc3F;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,kBAAkB,EAAE,GAAG,kBAAkB,CAgB3G;AAED,6HAA6H;AAC7H,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAErE;AAED,oFAAoF;AACpF,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAK1G"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { asRecord, asRecordList } from "../../shared/json.js";
|
|
2
|
+
function text(value) {
|
|
3
|
+
return typeof value === "string" && value !== "" ? value : undefined;
|
|
4
|
+
}
|
|
5
|
+
function field(record) {
|
|
6
|
+
const key = text(record.key);
|
|
7
|
+
const type = text(record.type);
|
|
8
|
+
if (key === undefined || type === undefined) {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
const title = text(record.title);
|
|
12
|
+
const placeholder = text(record.placeholder);
|
|
13
|
+
const options = asRecordList(record.options).flatMap((option) => {
|
|
14
|
+
const value = text(option.value);
|
|
15
|
+
return value === undefined ? [] : [{ value, label: text(option.label) ?? value }];
|
|
16
|
+
});
|
|
17
|
+
const when = asRecordList(record.when).flatMap((condition) => {
|
|
18
|
+
const whenKey = text(condition.key);
|
|
19
|
+
return whenKey === undefined ? [] : [{ key: whenKey, op: text(condition.op) ?? "eq", value: condition.value }];
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
key,
|
|
23
|
+
type,
|
|
24
|
+
required: record.required === true,
|
|
25
|
+
hidden: record.hidden === true,
|
|
26
|
+
custom: record.custom === true,
|
|
27
|
+
options,
|
|
28
|
+
when,
|
|
29
|
+
...(title === undefined ? {} : { title }),
|
|
30
|
+
...(placeholder === undefined ? {} : { placeholder }),
|
|
31
|
+
...(record.default === undefined ? {} : { default: record.default }),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function form(value) {
|
|
35
|
+
return asRecordList(value).flatMap((entry) => field(entry) ?? []);
|
|
36
|
+
}
|
|
37
|
+
function method(record) {
|
|
38
|
+
const label = text(record.label);
|
|
39
|
+
const labelled = label === undefined ? {} : { label };
|
|
40
|
+
switch (record.type) {
|
|
41
|
+
case "oauth": {
|
|
42
|
+
const id = text(record.id);
|
|
43
|
+
return id === undefined ? undefined : { type: "oauth", id, ...labelled, form: form(record.form) };
|
|
44
|
+
}
|
|
45
|
+
case "key":
|
|
46
|
+
return { type: "key", ...labelled, form: form(record.form) };
|
|
47
|
+
case "env": {
|
|
48
|
+
const names = Array.isArray(record.names) ? record.names.filter((name) => typeof name === "string") : [];
|
|
49
|
+
return names.length === 0 ? undefined : { type: "env", names };
|
|
50
|
+
}
|
|
51
|
+
default:
|
|
52
|
+
return typeof record.type === "string" ? { type: "other", native: record.type } : undefined;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function connection(record) {
|
|
56
|
+
if (record.type === "credential") {
|
|
57
|
+
const id = text(record.id);
|
|
58
|
+
const label = text(record.label);
|
|
59
|
+
const native = text(record.method);
|
|
60
|
+
return id === undefined ? undefined : {
|
|
61
|
+
type: "credential",
|
|
62
|
+
id,
|
|
63
|
+
...(label === undefined ? {} : { label }),
|
|
64
|
+
...(native === undefined ? {} : { method: native }),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const name = text(record.name);
|
|
68
|
+
return record.type === "env" && name !== undefined ? { type: "env", name } : undefined;
|
|
69
|
+
}
|
|
70
|
+
/** One `Integration.Info`; undefined when it lacks an id. */
|
|
71
|
+
export function parseIntegration(value) {
|
|
72
|
+
const record = asRecord(value);
|
|
73
|
+
const id = text(record?.id);
|
|
74
|
+
if (record === null || id === undefined) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
id,
|
|
79
|
+
name: text(record.name) ?? id,
|
|
80
|
+
methods: asRecordList(record.methods).flatMap((entry) => method(entry) ?? []),
|
|
81
|
+
connections: asRecordList(record.connections).flatMap((entry) => connection(entry) ?? []),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/** `integration.list`'s `data`, in OpenCode's order. */
|
|
85
|
+
export function parseIntegrations(body) {
|
|
86
|
+
const data = asRecord(body)?.data;
|
|
87
|
+
return Array.isArray(data) ? data.flatMap((entry) => parseIntegration(entry) ?? []) : [];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The ways OpenCode offers to sign in to one integration: each `oauth`
|
|
91
|
+
* method under its own label, with no `subscription` (OpenCode does not
|
|
92
|
+
* say whether a sign-in is one), then its `key` prompt, then its `env`
|
|
93
|
+
* variables as an ambient key. `external` and `command` methods read a
|
|
94
|
+
* credential another tool keeps and are omitted.
|
|
95
|
+
*/
|
|
96
|
+
export function loginProviderOf(integration) {
|
|
97
|
+
const oauth = [];
|
|
98
|
+
const keys = [];
|
|
99
|
+
for (const entry of integration.methods) {
|
|
100
|
+
if (entry.type === "oauth") {
|
|
101
|
+
oauth.push({ method: "oauth", name: entry.label ?? entry.id });
|
|
102
|
+
}
|
|
103
|
+
else if (entry.type === "key") {
|
|
104
|
+
keys.push({ method: "api_key", name: entry.label ?? `${integration.name} API key` });
|
|
105
|
+
}
|
|
106
|
+
else if (entry.type === "env") {
|
|
107
|
+
keys.push({ method: "api_key", name: entry.names.join(", "), ambient: true });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const methods = [...oauth, ...keys];
|
|
111
|
+
return methods.length === 0 ? undefined : { providerId: integration.id, name: integration.name, methods };
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Status from OpenCode's connections, never a secret: a stored credential
|
|
115
|
+
* first (OpenCode lists the newest first), else an environment variable it
|
|
116
|
+
* found. An `external` credential is configured with no contract method.
|
|
117
|
+
*/
|
|
118
|
+
export function statusOf(providerId, connections) {
|
|
119
|
+
const chosen = connections.find((entry) => entry.type === "credential") ?? connections[0];
|
|
120
|
+
if (chosen === undefined) {
|
|
121
|
+
return { providerId, configured: false };
|
|
122
|
+
}
|
|
123
|
+
if (chosen.type === "env") {
|
|
124
|
+
return { providerId, configured: true, method: "api_key", label: chosen.name };
|
|
125
|
+
}
|
|
126
|
+
const methods = { oauth: "oauth", key: "api_key" };
|
|
127
|
+
const kind = chosen.method === undefined ? undefined : methods[chosen.method];
|
|
128
|
+
return {
|
|
129
|
+
providerId,
|
|
130
|
+
configured: true,
|
|
131
|
+
...(kind === undefined ? {} : { method: kind }),
|
|
132
|
+
...(chosen.label === undefined ? {} : { label: chosen.label }),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/** The user code in an attempt's instructions: `Enter code: X` (GitHub Copilot, OpenAI) or `... and enter code: X` (xAI). */
|
|
136
|
+
export function deviceCodeOf(instructions) {
|
|
137
|
+
return /\benter code:\s*(\S+)\s*$/iu.exec(instructions)?.[1];
|
|
138
|
+
}
|
|
139
|
+
/** A field applies when every `when` condition holds against the answers so far. */
|
|
140
|
+
export function fieldApplies(entry, answers) {
|
|
141
|
+
return entry.when.every((condition) => {
|
|
142
|
+
const equal = answers[condition.key] === condition.value;
|
|
143
|
+
return condition.op === "neq" ? !equal : equal;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=provider-auth-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-auth-registry.js","sources":["../../../src/runtimes/opencode/provider-auth-registry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAmB,MAAM,sBAAsB,CAAC;AA8C/E,SAAS,IAAI,CAAC,KAAc;IAC1B,OAAO,OAAO,KAAK,KAAK,QA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AAoB;IAC/C,OAAO,6BAA6B,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,YAAY,CAAC,KAAwB,EAAE,OAA0C;IAC/F,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,EAAE;QACpC,MAAM,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,KAAK,CAAC;QACzD,OAAO,SAAS,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LoginSecrets } from "../../shared/login.js";
|
|
2
|
+
export type HttpMethod = "GET" | "POST" | "DELETE";
|
|
3
|
+
export interface ApiResponse {
|
|
4
|
+
readonly status: number;
|
|
5
|
+
/** Parsed JSON; undefined for an empty or non-JSON body. */
|
|
6
|
+
readonly body: unknown;
|
|
7
|
+
}
|
|
8
|
+
export type ApiCall = (method: HttpMethod, path: string, body?: unknown) => Promise<ApiResponse>;
|
|
9
|
+
export interface OpencodeServerOptions {
|
|
10
|
+
readonly command: string;
|
|
11
|
+
readonly env: NodeJS.ProcessEnv;
|
|
12
|
+
readonly cwd: string;
|
|
13
|
+
/** One budget for startup and readiness together, and the bound for each request. */
|
|
14
|
+
readonly timeoutMs: number;
|
|
15
|
+
readonly idleMs: number;
|
|
16
|
+
/** Readiness poll interval while the registry loads. */
|
|
17
|
+
readonly pollMs: number;
|
|
18
|
+
}
|
|
19
|
+
/** OpenCode's own error JSON (`{_tag, message}`) as one redacted line. */
|
|
20
|
+
export declare function nativeDetail(response: ApiResponse, secrets: LoginSecrets): string;
|
|
21
|
+
/**
|
|
22
|
+
* The serve child's environment: the caller's, with OAR's password, no
|
|
23
|
+
* inherited OpenCode 1 username (2.2.7 has a fixed user), and no update
|
|
24
|
+
* check or model-catalog fetch (OPENCODE_DISABLE_AUTOUPDATE and
|
|
25
|
+
* OPENCODE_DISABLE_MODELS_FETCH, both read by 2.2.7). On POSIX, BROWSER is a
|
|
26
|
+
* command that does nothing, so OpenCode can never open a browser on the
|
|
27
|
+
* machine it runs on; Windows has no such command and keeps the caller's.
|
|
28
|
+
*/
|
|
29
|
+
export declare function serveEnvironment(env: NodeJS.ProcessEnv, password: string, platform?: NodeJS.Platform): NodeJS.ProcessEnv;
|
|
30
|
+
export declare class OpencodeServer {
|
|
31
|
+
#private;
|
|
32
|
+
constructor(options: OpencodeServerOptions);
|
|
33
|
+
/** Run `work` against a ready server, starting one when none runs. */
|
|
34
|
+
run<T>(work: (call: ApiCall) => Promise<T>): Promise<T>;
|
|
35
|
+
/** Stop the server and everything it started; the next operation starts a new one. */
|
|
36
|
+
close(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=provider-auth-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-auth-server.d.ts","sources":["../../../src/runtimes/opencode/provider-auth-server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAwC,MAAM,uBAAuB,CAAC;AAa3F,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AAEjG,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IAChC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,qFAAqF;IACrF,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,wDAAwD;IACxD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAcD,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,CAKjF;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAAG,MAAM,CAAC,UAAU,CAY1I;AAOD,qBAAa,cAAc;;IAOzB,YAAY,OAAO,EAAE,qBAAqB,EAEzC;IAED,sEAAsE;IAChE,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAiB5D;IAED,sFAAsF;IAChF,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAW3B;CAuIF"}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { randomBytes } from "node:crypto";
|
|
2
|
+
import { asRecord, parseJson } from "../../shared/json.js";
|
|
3
|
+
import { LoginSecrets, spawnLoginProcess } from "../../shared/login.js";
|
|
4
|
+
import { OpencodeProviderAuthError } from "./provider-auth-error.js";
|
|
5
|
+
const LISTENING = /^server listening on (https?:\/\/\S+)/u;
|
|
6
|
+
// OpenCode's error tag, e.g. `InvalidRequestError`.
|
|
7
|
+
const TAG = "_tag";
|
|
8
|
+
/** OpenCode's own error JSON (`{_tag, message}`) as one redacted line. */
|
|
9
|
+
export function nativeDetail(response, secrets) {
|
|
10
|
+
const record = asRecord(response.body);
|
|
11
|
+
const tag = record?.[TAG];
|
|
12
|
+
const message = typeof record?.message === "string" ? secrets.line(record.message) : undefined;
|
|
13
|
+
return [`HTTP ${String(response.status)}`, typeof tag === "string" ? tag : undefined, message].filter((part) => part !== undefined && part !== "").join(": ");
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The serve child's environment: the caller's, with OAR's password, no
|
|
17
|
+
* inherited OpenCode 1 username (2.2.7 has a fixed user), and no update
|
|
18
|
+
* check or model-catalog fetch (OPENCODE_DISABLE_AUTOUPDATE and
|
|
19
|
+
* OPENCODE_DISABLE_MODELS_FETCH, both read by 2.2.7). On POSIX, BROWSER is a
|
|
20
|
+
* command that does nothing, so OpenCode can never open a browser on the
|
|
21
|
+
* machine it runs on; Windows has no such command and keeps the caller's.
|
|
22
|
+
*/
|
|
23
|
+
export function serveEnvironment(env, password, platform = process.platform) {
|
|
24
|
+
const inherited = { ...env };
|
|
25
|
+
delete inherited.OPENCODE_SERVER_USERNAME;
|
|
26
|
+
return {
|
|
27
|
+
...inherited,
|
|
28
|
+
// OpenCode reads OPENCODE_PASSWORD first, then OPENCODE_SERVER_PASSWORD.
|
|
29
|
+
OPENCODE_PASSWORD: password,
|
|
30
|
+
OPENCODE_SERVER_PASSWORD: password,
|
|
31
|
+
OPENCODE_DISABLE_AUTOUPDATE: "1",
|
|
32
|
+
OPENCODE_DISABLE_MODELS_FETCH: "1",
|
|
33
|
+
...(platform === "win32" ? {} : { BROWSER: "true" }),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function listed(response) {
|
|
37
|
+
const data = asRecord(response.body)?.data;
|
|
38
|
+
return response.status === 200 && Array.isArray(data) && data.length > 0;
|
|
39
|
+
}
|
|
40
|
+
export class OpencodeServer {
|
|
41
|
+
#options;
|
|
42
|
+
#running;
|
|
43
|
+
#users = 0;
|
|
44
|
+
#idle;
|
|
45
|
+
#stopping = new Set();
|
|
46
|
+
constructor(options) {
|
|
47
|
+
this.#options = options;
|
|
48
|
+
}
|
|
49
|
+
/** Run `work` against a ready server, starting one when none runs. */
|
|
50
|
+
async run(work) {
|
|
51
|
+
clearTimeout(this.#idle);
|
|
52
|
+
this.#users += 1;
|
|
53
|
+
try {
|
|
54
|
+
const running = await this.#ensure();
|
|
55
|
+
return await work(async (method, path, body) => {
|
|
56
|
+
const response = await this.#request(running, method, path, body);
|
|
57
|
+
return response;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
this.#users -= 1;
|
|
62
|
+
if (this.#users === 0) {
|
|
63
|
+
this.#idle = setTimeout(() => { void this.close(); }, this.#options.idleMs);
|
|
64
|
+
// Waiting to stop an idle server must not keep the host process alive.
|
|
65
|
+
this.#idle.unref();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/** Stop the server and everything it started; the next operation starts a new one. */
|
|
70
|
+
async close() {
|
|
71
|
+
clearTimeout(this.#idle);
|
|
72
|
+
const running = this.#running;
|
|
73
|
+
this.#running = undefined;
|
|
74
|
+
if (running !== undefined) {
|
|
75
|
+
const stopping = OpencodeServer.#stop(running);
|
|
76
|
+
this.#stopping.add(stopping);
|
|
77
|
+
void (async () => { await stopping; this.#stopping.delete(stopping); })();
|
|
78
|
+
}
|
|
79
|
+
// Also a stop already under way (the idle period's): close() settles once no server it started runs.
|
|
80
|
+
await Promise.all(this.#stopping);
|
|
81
|
+
}
|
|
82
|
+
static async #stop(running) {
|
|
83
|
+
try {
|
|
84
|
+
const settled = await running;
|
|
85
|
+
settled.process.stop();
|
|
86
|
+
await settled.process.exited;
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
// A failed start already stopped its process.
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async #ensure() {
|
|
93
|
+
// Another caller may replace an exited server while this one waits.
|
|
94
|
+
for (let current = this.#running; current !== undefined; current = this.#running) {
|
|
95
|
+
const running = await current;
|
|
96
|
+
if (!running.exited) {
|
|
97
|
+
return running;
|
|
98
|
+
}
|
|
99
|
+
if (this.#running === current) {
|
|
100
|
+
this.#running = undefined;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const started = this.#start();
|
|
104
|
+
this.#running = started;
|
|
105
|
+
try {
|
|
106
|
+
return await started;
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
// A failed start leaves nothing to reuse.
|
|
110
|
+
if (this.#running === started) {
|
|
111
|
+
this.#running = undefined;
|
|
112
|
+
}
|
|
113
|
+
throw error;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async #start() {
|
|
117
|
+
const { command, env, cwd, timeoutMs, pollMs } = this.#options;
|
|
118
|
+
const password = randomBytes(24).toString("base64url");
|
|
119
|
+
const secrets = new LoginSecrets();
|
|
120
|
+
secrets.add(password);
|
|
121
|
+
const listening = Promise.withResolvers();
|
|
122
|
+
const said = { first: "" };
|
|
123
|
+
const child = spawnLoginProcess(command, ["serve", "--hostname", "127.0.0.1", "--port", "0"], serveEnvironment(env, password), {
|
|
124
|
+
onLine: (line) => {
|
|
125
|
+
const url = LISTENING.exec(line)?.[1];
|
|
126
|
+
if (url !== undefined) {
|
|
127
|
+
listening.resolve(url);
|
|
128
|
+
}
|
|
129
|
+
if (said.first === "") {
|
|
130
|
+
said.first = line;
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
}, { cwd, stopWithHost: true });
|
|
134
|
+
const deadline = Date.now() + timeoutMs;
|
|
135
|
+
const timer = setTimeout(() => { listening.reject(new OpencodeProviderAuthError("timed_out", `opencode serve did not start within ${String(timeoutMs)} ms`)); }, timeoutMs);
|
|
136
|
+
void (async () => {
|
|
137
|
+
const exit = await child.exited;
|
|
138
|
+
const words = said.first === "" ? "" : `: ${secrets.line(said.first)}`;
|
|
139
|
+
listening.reject(new OpencodeProviderAuthError("startup_failed", `opencode serve exited (${exit.error ?? `code ${String(exit.exitCode)}`})${words}`));
|
|
140
|
+
})();
|
|
141
|
+
try {
|
|
142
|
+
const url = await listening.promise;
|
|
143
|
+
const running = { process: child, url, authorization: `Basic ${Buffer.from(`opencode:${password}`).toString("base64")}`, exited: false };
|
|
144
|
+
void (async () => {
|
|
145
|
+
await child.exited;
|
|
146
|
+
running.exited = true;
|
|
147
|
+
})();
|
|
148
|
+
await this.#ready(running, deadline, timeoutMs, pollMs);
|
|
149
|
+
return running;
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
// Gone before the caller hears of the failure: Windows cannot remove a directory a live process runs in.
|
|
153
|
+
child.stop();
|
|
154
|
+
await child.exited;
|
|
155
|
+
throw error;
|
|
156
|
+
}
|
|
157
|
+
finally {
|
|
158
|
+
clearTimeout(timer);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* The registry fills in stages after listening; 2.2.7 lists its plugins
|
|
163
|
+
* only once it is complete. Startup and readiness share one budget: each
|
|
164
|
+
* read gets only what is left of it.
|
|
165
|
+
*/
|
|
166
|
+
async #ready(running, deadline, timeoutMs, pollMs) {
|
|
167
|
+
const late = () => new OpencodeProviderAuthError("timed_out", `opencode serve did not load its integrations within ${String(timeoutMs)} ms`);
|
|
168
|
+
const read = async (path) => {
|
|
169
|
+
const left = deadline - Date.now();
|
|
170
|
+
if (left <= 0) {
|
|
171
|
+
throw late();
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
return await this.#request(running, "GET", path, undefined, left);
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
throw error instanceof OpencodeProviderAuthError && error.kind === "timed_out" ? late() : error;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
for (;;) {
|
|
181
|
+
const plugins = await read("/api/plugin");
|
|
182
|
+
const integrations = await read("/api/integration");
|
|
183
|
+
if (listed(plugins) && listed(integrations)) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
if (running.exited) {
|
|
187
|
+
throw new OpencodeProviderAuthError("startup_failed", "opencode serve exited before its integrations loaded");
|
|
188
|
+
}
|
|
189
|
+
if (Date.now() + pollMs > deadline) {
|
|
190
|
+
throw late();
|
|
191
|
+
}
|
|
192
|
+
await new Promise((resolve) => { setTimeout(resolve, pollMs); });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async #request(running, method, path, body, timeoutMs = this.#options.timeoutMs) {
|
|
196
|
+
const parsed = await this.#fetch(running, method, path, body, timeoutMs);
|
|
197
|
+
if (parsed.status === 401) {
|
|
198
|
+
// 2.2.7: `{"_tag":"UnauthorizedError","message":"Authentication required"}` for a wrong or missing password.
|
|
199
|
+
throw new OpencodeProviderAuthError("authentication_failed", `OpenCode's server refused OAR's password (${nativeDetail(parsed, new LoginSecrets())})`, 401);
|
|
200
|
+
}
|
|
201
|
+
return parsed;
|
|
202
|
+
}
|
|
203
|
+
async #fetch(running, method, path, body, timeoutMs) {
|
|
204
|
+
try {
|
|
205
|
+
const response = await fetch(`${running.url}${path}`, {
|
|
206
|
+
method,
|
|
207
|
+
headers: { authorization: running.authorization, ...(body === undefined ? {} : { "content-type": "application/json" }) },
|
|
208
|
+
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
|
209
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
210
|
+
});
|
|
211
|
+
const textBody = await response.text();
|
|
212
|
+
return { status: response.status, body: textBody === "" ? undefined : parseJson(textBody) };
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
const timedOut = error instanceof Error && error.name === "TimeoutError";
|
|
216
|
+
// Never the request body: it may carry a key.
|
|
217
|
+
throw new OpencodeProviderAuthError(timedOut ? "timed_out" : "server_failed", `${method} ${path} ${timedOut ? `timed out after ${String(timeoutMs)} ms` : "failed: OpenCode's server did not answer"}`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=provider-auth-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-auth-server.js","sources":["../../../src/run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