@nathapp/nax-ai 0.1.2 → 0.1.4
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 +31 -0
- package/dist/auth/login-errors.d.ts +24 -0
- package/dist/auth/login-errors.d.ts.map +1 -0
- package/dist/auth/login-errors.js +40 -0
- package/dist/auth/login-errors.js.map +1 -0
- package/dist/auth/login-types.d.ts +90 -0
- package/dist/auth/login-types.d.ts.map +1 -0
- package/dist/auth/login-types.js +10 -0
- package/dist/auth/login-types.js.map +1 -0
- package/dist/auth/login.d.ts +15 -0
- package/dist/auth/login.d.ts.map +1 -0
- package/dist/auth/login.js +84 -0
- package/dist/auth/login.js.map +1 -0
- package/dist/auth/oauth-policy.d.ts.map +1 -1
- package/dist/auth/oauth-policy.js +2 -5
- package/dist/auth/oauth-policy.js.map +1 -1
- package/dist/auth/pi-auth.d.ts +66 -2
- package/dist/auth/pi-auth.d.ts.map +1 -1
- package/dist/auth/pi-auth.js +202 -0
- package/dist/auth/pi-auth.js.map +1 -1
- package/dist/client.d.ts +1 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/protocols/pi-protocols.d.ts +21 -3
- package/dist/protocols/pi-protocols.d.ts.map +1 -1
- package/dist/protocols/pi-protocols.js +17 -3
- package/dist/protocols/pi-protocols.js.map +1 -1
- package/dist/providers/pi-catalog.d.ts +12 -1
- package/dist/providers/pi-catalog.d.ts.map +1 -1
- package/dist/providers/pi-catalog.js +12 -1
- package/dist/providers/pi-catalog.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,6 +33,37 @@ While the API is unstable, `latest` and `next` both point at the current 0.x rel
|
|
|
33
33
|
|
|
34
34
|
A `ToolDefinition` can carry an optional `constrainedSampling: { type: "json_schema"; strict: "prefer" | "require" }` to ask the provider to constrain a tool's arguments to its schema. Support is per-model, not caller-controllable — some models simply cannot honour it. `"prefer"` degrades silently to an unconstrained tool when the model lacks support, so a well-formed response is not evidence the constraint was applied; `"require"` throws instead of degrading.
|
|
35
35
|
|
|
36
|
+
### Logging in
|
|
37
|
+
|
|
38
|
+
`login()` obtains a credential and writes it to the store you pass. It covers
|
|
39
|
+
both api-key entry and OAuth, choosing between them when a provider offers
|
|
40
|
+
both, and returns metadata rather than the credential — the store already has
|
|
41
|
+
it.
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { createFileCredentialStore, login } from "@nathapp/nax-ai";
|
|
45
|
+
|
|
46
|
+
const credentials = createFileCredentialStore({ path: `${homedir()}/.nax/credentials` });
|
|
47
|
+
|
|
48
|
+
const result = await login({
|
|
49
|
+
providerId: "openrouter",
|
|
50
|
+
credentials,
|
|
51
|
+
interaction: {
|
|
52
|
+
prompt: async (prompt) => ask(prompt.message), // your UI
|
|
53
|
+
notify: (event) => render(event),
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
// result: { providerId: "openrouter", method: "oauth", kind: "oauth" }
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Permitted OAuth flows are `openai-codex` and `openrouter`; see
|
|
60
|
+
`PERMITTED_OAUTH_FLOWS`. A provider outside that list keeps its api-key login.
|
|
61
|
+
|
|
62
|
+
There is no `logout`: removing a credential is `credentials.delete(providerId)`.
|
|
63
|
+
Note that nothing is revoked upstream — the provider-side token stays valid
|
|
64
|
+
until it expires, so a UI should say the credential was removed locally rather
|
|
65
|
+
than that the user was logged out.
|
|
66
|
+
|
|
36
67
|
## Scope
|
|
37
68
|
|
|
38
69
|
This package speaks a generic LLM vocabulary — models, messages, tool calls, usage, credentials. It knows nothing about any consumer's domain concepts, and that direction is one-way by design: consumers map onto their own types at their own boundary.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ProviderId } from "../types.ts";
|
|
2
|
+
import type { LoginMethod } from "./login-types.ts";
|
|
3
|
+
/**
|
|
4
|
+
* The provider offers no login method this package can run — either none at
|
|
5
|
+
* all, or not the one the caller named. Distinct from a policy refusal, which
|
|
6
|
+
* raises OAuthFlowProhibitedError: an absence and a prohibition send a reader
|
|
7
|
+
* to different problems.
|
|
8
|
+
*/
|
|
9
|
+
export declare class AuthMethodUnavailableError extends Error {
|
|
10
|
+
readonly providerId: ProviderId;
|
|
11
|
+
readonly requested: LoginMethod | undefined;
|
|
12
|
+
constructor(providerId: ProviderId, requested?: LoginMethod);
|
|
13
|
+
}
|
|
14
|
+
/** The user cancelled, or the caller aborted. Not a failure. */
|
|
15
|
+
export declare class LoginCancelledError extends Error {
|
|
16
|
+
readonly providerId: ProviderId;
|
|
17
|
+
constructor(providerId: ProviderId);
|
|
18
|
+
}
|
|
19
|
+
/** The flow ran and did not produce a usable credential. */
|
|
20
|
+
export declare class LoginFailedError extends Error {
|
|
21
|
+
readonly providerId: ProviderId;
|
|
22
|
+
constructor(providerId: ProviderId, reason: string);
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=login-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login-errors.d.ts","sourceRoot":"","sources":["../../src/auth/login-errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;GAKG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAIhC,QAAQ,CAAC,SAAS,EAAE,WAAW,GAAG,SAAS,CAAC;IAE5C,YAAY,UAAU,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,WAAW,EAS1D;CACF;AAED,gEAAgE;AAChE,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAEhC,YAAY,UAAU,EAAE,UAAU,EAIjC;CACF;AAED,4DAA4D;AAC5D,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAEhC,YAAY,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAIjD;CACF"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The provider offers no login method this package can run — either none at
|
|
3
|
+
* all, or not the one the caller named. Distinct from a policy refusal, which
|
|
4
|
+
* raises OAuthFlowProhibitedError: an absence and a prohibition send a reader
|
|
5
|
+
* to different problems.
|
|
6
|
+
*/
|
|
7
|
+
export class AuthMethodUnavailableError extends Error {
|
|
8
|
+
providerId;
|
|
9
|
+
// Declared as `| undefined` rather than optional: under
|
|
10
|
+
// exactOptionalPropertyTypes, assigning a possibly-undefined parameter to an
|
|
11
|
+
// optional field is a type error.
|
|
12
|
+
requested;
|
|
13
|
+
constructor(providerId, requested) {
|
|
14
|
+
super(requested === undefined
|
|
15
|
+
? `Provider "${providerId}" offers no login method this package can run.`
|
|
16
|
+
: `Provider "${providerId}" does not offer "${requested}" login.`);
|
|
17
|
+
this.name = "AuthMethodUnavailableError";
|
|
18
|
+
this.providerId = providerId;
|
|
19
|
+
this.requested = requested;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/** The user cancelled, or the caller aborted. Not a failure. */
|
|
23
|
+
export class LoginCancelledError extends Error {
|
|
24
|
+
providerId;
|
|
25
|
+
constructor(providerId) {
|
|
26
|
+
super(`Login to "${providerId}" was cancelled.`);
|
|
27
|
+
this.name = "LoginCancelledError";
|
|
28
|
+
this.providerId = providerId;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** The flow ran and did not produce a usable credential. */
|
|
32
|
+
export class LoginFailedError extends Error {
|
|
33
|
+
providerId;
|
|
34
|
+
constructor(providerId, reason) {
|
|
35
|
+
super(`Login to "${providerId}" failed: ${reason}`);
|
|
36
|
+
this.name = "LoginFailedError";
|
|
37
|
+
this.providerId = providerId;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=login-errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login-errors.js","sourceRoot":"","sources":["../../src/auth/login-errors.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAC1C,UAAU,CAAa;IAChC,wDAAwD;IACxD,6EAA6E;IAC7E,kCAAkC;IACzB,SAAS,CAA0B;IAE5C,YAAY,UAAsB,EAAE,SAAuB;QACzD,KAAK,CACH,SAAS,KAAK,SAAS;YACrB,CAAC,CAAC,aAAa,UAAU,gDAAgD;YACzE,CAAC,CAAC,aAAa,UAAU,qBAAqB,SAAS,UAAU,CACpE,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AAED,gEAAgE;AAChE,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,UAAU,CAAa;IAEhC,YAAY,UAAsB;QAChC,KAAK,CAAC,aAAa,UAAU,kBAAkB,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AAED,4DAA4D;AAC5D,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAChC,UAAU,CAAa;IAEhC,YAAY,UAAsB,EAAE,MAAc;QAChD,KAAK,CAAC,aAAa,UAAU,aAAa,MAAM,EAAE,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The vocabulary of a login, in nax-ai's own terms.
|
|
3
|
+
*
|
|
4
|
+
* pi-ai's equivalents are snake_case (`auth_url`, `device_code`, `manual_code`,
|
|
5
|
+
* `api_key`); these are kebab-case, matching `ProtocolError.kind`'s
|
|
6
|
+
* `rate-limit` and `bad-request`. That translation is the boundary: it is what
|
|
7
|
+
* keeps a rename upstream from becoming a breaking change here.
|
|
8
|
+
*/
|
|
9
|
+
import type { CredentialStore, ProviderId, StoredCredential } from "../types.ts";
|
|
10
|
+
export type LoginMethod = "api-key" | "oauth";
|
|
11
|
+
export interface LoginOption {
|
|
12
|
+
readonly id: string;
|
|
13
|
+
readonly label: string;
|
|
14
|
+
readonly description?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* `signal` cancels this one prompt — a flow uses it when an out-of-band event
|
|
18
|
+
* resolves the step, e.g. a manual-code prompt raced against a callback
|
|
19
|
+
* server. It is not the whole login's signal, which lives on `LoginOptions`.
|
|
20
|
+
*/
|
|
21
|
+
export type LoginPrompt = {
|
|
22
|
+
readonly signal?: AbortSignal;
|
|
23
|
+
} & ({
|
|
24
|
+
readonly type: "text";
|
|
25
|
+
readonly message: string;
|
|
26
|
+
readonly placeholder?: string;
|
|
27
|
+
} | {
|
|
28
|
+
readonly type: "secret";
|
|
29
|
+
readonly message: string;
|
|
30
|
+
readonly placeholder?: string;
|
|
31
|
+
} | {
|
|
32
|
+
readonly type: "select";
|
|
33
|
+
readonly message: string;
|
|
34
|
+
readonly options: readonly LoginOption[];
|
|
35
|
+
} | {
|
|
36
|
+
readonly type: "manual-code";
|
|
37
|
+
readonly message: string;
|
|
38
|
+
readonly placeholder?: string;
|
|
39
|
+
});
|
|
40
|
+
export interface LoginLink {
|
|
41
|
+
readonly url: string;
|
|
42
|
+
readonly label?: string;
|
|
43
|
+
}
|
|
44
|
+
export type LoginEvent = {
|
|
45
|
+
readonly type: "info";
|
|
46
|
+
readonly message: string;
|
|
47
|
+
readonly links?: readonly LoginLink[];
|
|
48
|
+
} | {
|
|
49
|
+
readonly type: "auth-url";
|
|
50
|
+
readonly url: string;
|
|
51
|
+
readonly instructions?: string;
|
|
52
|
+
} | {
|
|
53
|
+
readonly type: "device-code";
|
|
54
|
+
readonly userCode: string;
|
|
55
|
+
readonly verificationUri: string;
|
|
56
|
+
readonly intervalSeconds?: number;
|
|
57
|
+
readonly expiresInSeconds?: number;
|
|
58
|
+
} | {
|
|
59
|
+
readonly type: "progress";
|
|
60
|
+
readonly message: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Login interaction, serving both api-key and OAuth flows.
|
|
64
|
+
*
|
|
65
|
+
* `prompt()` returns the entered text or, for `select`, the chosen option id.
|
|
66
|
+
* Reject it to cancel.
|
|
67
|
+
*/
|
|
68
|
+
export interface LoginInteraction {
|
|
69
|
+
prompt(prompt: LoginPrompt): Promise<string>;
|
|
70
|
+
notify(event: LoginEvent): void;
|
|
71
|
+
}
|
|
72
|
+
export interface LoginOptions {
|
|
73
|
+
readonly providerId: ProviderId;
|
|
74
|
+
readonly credentials: CredentialStore;
|
|
75
|
+
readonly interaction: LoginInteraction;
|
|
76
|
+
/** Skips the method prompt. Throws if the named method is unavailable. */
|
|
77
|
+
readonly method?: LoginMethod;
|
|
78
|
+
readonly signal?: AbortSignal;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Metadata, deliberately not the credential: `login()` has already written it
|
|
82
|
+
* to the store, and returning the secret would create a second copy with no
|
|
83
|
+
* consumer. A caller that cannot obtain it cannot leak it.
|
|
84
|
+
*/
|
|
85
|
+
export interface LoginResult {
|
|
86
|
+
readonly providerId: ProviderId;
|
|
87
|
+
readonly method: LoginMethod;
|
|
88
|
+
readonly kind: StoredCredential["kind"];
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=login-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login-types.d.ts","sourceRoot":"","sources":["../../src/auth/login-types.ts"],"names":[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I,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;CACzC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The vocabulary of a login, in nax-ai's own terms.
|
|
3
|
+
*
|
|
4
|
+
* pi-ai's equivalents are snake_case (`auth_url`, `device_code`, `manual_code`,
|
|
5
|
+
* `api_key`); these are kebab-case, matching `ProtocolError.kind`'s
|
|
6
|
+
* `rate-limit` and `bad-request`. That translation is the boundary: it is what
|
|
7
|
+
* keeps a rename upstream from becoming a breaking change here.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=login-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login-types.js","sourceRoot":"","sources":["../../src/auth/login-types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Obtaining a credential, as opposed to holding or using one.
|
|
3
|
+
*
|
|
4
|
+
* This module never imports pi-ai: every provider-specific step is behind a
|
|
5
|
+
* LoginRunner that pi-auth.ts resolved. The credential is written to the
|
|
6
|
+
* caller's store before this returns, and never handed back.
|
|
7
|
+
*/
|
|
8
|
+
import type { LoginOptions, LoginResult } from "./login-types.ts";
|
|
9
|
+
import { resolveLoginTarget } from "./pi-auth.ts";
|
|
10
|
+
/** Test seam. */
|
|
11
|
+
export declare const _resolveTarget: {
|
|
12
|
+
resolve: typeof resolveLoginTarget;
|
|
13
|
+
};
|
|
14
|
+
export declare function login(options: LoginOptions): Promise<LoginResult>;
|
|
15
|
+
//# sourceMappingURL=login.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/auth/login.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAe,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/E,OAAO,EAAoB,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEpE,iBAAiB;AACjB,eAAO,MAAM,cAAc;IAAK,OAAO;CAAsB,CAAC;AA8C9D,wBAAsB,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAgCvE"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Obtaining a credential, as opposed to holding or using one.
|
|
3
|
+
*
|
|
4
|
+
* This module never imports pi-ai: every provider-specific step is behind a
|
|
5
|
+
* LoginRunner that pi-auth.ts resolved. The credential is written to the
|
|
6
|
+
* caller's store before this returns, and never handed back.
|
|
7
|
+
*/
|
|
8
|
+
import { AuthMethodUnavailableError, LoginCancelledError, LoginFailedError } from "./login-errors.js";
|
|
9
|
+
import { OAuthFlowProhibitedError } from "./oauth-policy.js";
|
|
10
|
+
import { resolveLoginTarget } from "./pi-auth.js";
|
|
11
|
+
/** Test seam. */
|
|
12
|
+
export const _resolveTarget = { resolve: resolveLoginTarget };
|
|
13
|
+
async function select(available, options, signal) {
|
|
14
|
+
const { providerId, method, interaction } = options;
|
|
15
|
+
if (method !== undefined) {
|
|
16
|
+
const named = available.find((choice) => choice.method === method);
|
|
17
|
+
if (named === undefined)
|
|
18
|
+
throw new AuthMethodUnavailableError(providerId, method);
|
|
19
|
+
return named;
|
|
20
|
+
}
|
|
21
|
+
const only = available.length === 1 ? available[0] : undefined;
|
|
22
|
+
if (only !== undefined)
|
|
23
|
+
return only;
|
|
24
|
+
const answer = await interaction.prompt({
|
|
25
|
+
type: "select",
|
|
26
|
+
message: `How do you want to sign in to "${providerId}"?`,
|
|
27
|
+
options: available.map((choice) => ({ id: choice.method, label: choice.runner.label })),
|
|
28
|
+
...(signal !== undefined ? { signal } : {}),
|
|
29
|
+
});
|
|
30
|
+
const picked = available.find((choice) => choice.method === answer);
|
|
31
|
+
// An unrecognised answer is not a reason to guess: falling back to the first
|
|
32
|
+
// method would bill against a credential path the user did not choose.
|
|
33
|
+
if (picked === undefined)
|
|
34
|
+
throw new AuthMethodUnavailableError(providerId);
|
|
35
|
+
return picked;
|
|
36
|
+
}
|
|
37
|
+
function isCancellation(error, signal) {
|
|
38
|
+
if (signal.aborted)
|
|
39
|
+
return true;
|
|
40
|
+
return error instanceof Error && error.name === "AbortError";
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A credential whose key is empty is not a credential. The store would accept
|
|
44
|
+
* it and every later call would fail with an auth error pointing nowhere near
|
|
45
|
+
* this login.
|
|
46
|
+
*/
|
|
47
|
+
function assertUsable(credential, providerId) {
|
|
48
|
+
if (credential.kind === "api-key" && credential.key.length === 0) {
|
|
49
|
+
throw new LoginFailedError(providerId, "the flow returned an empty API key");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export async function login(options) {
|
|
53
|
+
const { providerId, credentials, interaction, signal } = options;
|
|
54
|
+
const target = await _resolveTarget.resolve(providerId);
|
|
55
|
+
const available = [];
|
|
56
|
+
if (target.apiKey !== undefined)
|
|
57
|
+
available.push({ method: "api-key", runner: target.apiKey });
|
|
58
|
+
if (target.oauth !== undefined)
|
|
59
|
+
available.push({ method: "oauth", runner: target.oauth });
|
|
60
|
+
if (available.length === 0)
|
|
61
|
+
throw new AuthMethodUnavailableError(providerId);
|
|
62
|
+
const abort = signal ?? new AbortController().signal;
|
|
63
|
+
let chosen;
|
|
64
|
+
let credential;
|
|
65
|
+
try {
|
|
66
|
+
chosen = await select(available, options, abort);
|
|
67
|
+
credential = await chosen.runner.run(interaction, abort);
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
// A policy refusal keeps its own identity: its recorded reason is the
|
|
71
|
+
// point, and a generic failure would discard it.
|
|
72
|
+
if (error instanceof OAuthFlowProhibitedError)
|
|
73
|
+
throw error;
|
|
74
|
+
if (isCancellation(error, abort))
|
|
75
|
+
throw new LoginCancelledError(providerId);
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
assertUsable(credential, providerId);
|
|
79
|
+
// modify, never a bare write: it is what holds the store's lock across the
|
|
80
|
+
// whole read-modify-write.
|
|
81
|
+
await credentials.modify(providerId, async () => credential);
|
|
82
|
+
return { providerId, method: chosen.method, kind: credential.kind };
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/auth/login.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEtG,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAoB,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEpE,iBAAiB;AACjB,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAI9D,KAAK,UAAU,MAAM,CAAC,SAA4B,EAAE,OAAqB,EAAE,MAAmB;IAC5F,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAEpD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;QACnE,IAAI,KAAK,KAAK,SAAS;YAAE,MAAM,IAAI,0BAA0B,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QAClF,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/D,IAAI,IAAI,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAEpC,MAAM,MAAM,GAAG,MA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CAAC;IAE7D,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC;AACtE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-policy.d.ts","sourceRoot":"","sources":["../../src/auth/oauth-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,UAAU,
|
|
1
|
+
{"version":3,"file":"oauth-policy.d.ts","sourceRoot":"","sources":["../../src/auth/oauth-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,UAAU,EAAkD,CAAC;AAE1G;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAKtE,CAAC;AAEH,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAEhC,YAAY,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAIjD;CACF;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAEpE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,UAAU,GAAG,IAAI,CAQrE"}
|
|
@@ -20,17 +20,14 @@
|
|
|
20
20
|
* provider whose terms permit third-party OAuth use, or whose flow is a
|
|
21
21
|
* first-party developer credential rather than a consumer subscription.
|
|
22
22
|
*/
|
|
23
|
-
export const PERMITTED_OAUTH_FLOWS = Object.freeze([
|
|
24
|
-
"openai-codex",
|
|
25
|
-
"github-copilot",
|
|
26
|
-
"openrouter",
|
|
27
|
-
]);
|
|
23
|
+
export const PERMITTED_OAUTH_FLOWS = Object.freeze(["openai-codex", "openrouter"]);
|
|
28
24
|
/**
|
|
29
25
|
* OAuth flows that must never be registered, with the reason recorded so a
|
|
30
26
|
* future reader does not "fix" the omission.
|
|
31
27
|
*/
|
|
32
28
|
export const PROHIBITED_OAUTH_FLOWS = Object.freeze({
|
|
33
29
|
anthropic: "Anthropic subscription OAuth outside the official Claude CLI is server-blocked and a Consumer ToS violation. Route Claude subscription traffic through the official CLI instead.",
|
|
30
|
+
"github-copilot": "Not cleared: the upstream catalog marks this flow isSubscription: true, which fails this allowlist's 'first-party developer credential rather than a consumer subscription' clause, and its terms were never checked against the other one. This is an unresolved terms question, not an established violation like anthropic's — a review may reverse it on evidence. The provider's api-key login is unaffected.",
|
|
34
31
|
});
|
|
35
32
|
export class OAuthFlowProhibitedError extends Error {
|
|
36
33
|
providerId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-policy.js","sourceRoot":"","sources":["../../src/auth/oauth-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA0B,MAAM,CAAC,MAAM,CAAC
|
|
1
|
+
{"version":3,"file":"oauth-policy.js","sourceRoot":"","sources":["../../src/auth/oauth-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA0B,MAAM,CAAC,MAAM,CAAC,CAAC,cAAc,EAAE,YAAY,CAAC,CAAC,CAAC;AAE1G;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAyC,MAAM,CAAC,MAAM,CAAC;IACxF,SAAS,EACP,kLAAkL;IACpL,gBAAgB,EACd,oZAAoZ;CACvZ,CAAC,CAAC;AAEH,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACxC,UAAU,CAAa;IAEhC,YAAY,UAAsB,EAAE,MAAc;QAChD,KAAK,CAAC,mBAAmB,UAAU,oBAAoB,MAAM,EAAE,CAAC,CAAC;QACjE,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AAED,MAAM,UAAU,oBAAoB,CAAC,UAAsB;IACzD,OAAO,qBAAqB,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACpD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,UAAsB;IAC7D,MAAM,gBAAgB,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;IAC5D,IAAI,gBAAgB,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,IAAI,wBAAwB,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;IACnE,CAAC;IACD,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,uBAAuB,UAAU,uBAAuB,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC/G,CAAC;AACH,CAAC"}
|
package/dist/auth/pi-auth.d.ts
CHANGED
|
@@ -4,9 +4,73 @@
|
|
|
4
4
|
* On the ALLOWED list in scripts/check-pi-ai-imports.ts. Nothing here leaks a
|
|
5
5
|
* pi-ai type through an export a consumer sees.
|
|
6
6
|
*/
|
|
7
|
-
import type { MutableModels, CredentialStore as PiCredentialStore } from "@earendil-works/pi-ai";
|
|
8
|
-
import type { CredentialStore } from "../types.ts";
|
|
7
|
+
import type { MutableModels, CredentialStore as PiCredentialStore, Provider as PiProvider } from "@earendil-works/pi-ai";
|
|
8
|
+
import type { CredentialStore, ProviderId, StoredCredential } from "../types.ts";
|
|
9
|
+
import type { LoginInteraction } from "./login-types.ts";
|
|
9
10
|
import type { AuthResolver } from "./resolver.ts";
|
|
10
11
|
export declare function toPiCredentialStore(store: CredentialStore): PiCredentialStore;
|
|
11
12
|
export declare function createPiAuthResolver(models: MutableModels): AuthResolver;
|
|
13
|
+
export interface LoginRunner {
|
|
14
|
+
/** Shown in the method prompt when a provider offers both. */
|
|
15
|
+
readonly label: string;
|
|
16
|
+
run(interaction: LoginInteraction, signal: AbortSignal): Promise<StoredCredential>;
|
|
17
|
+
}
|
|
18
|
+
export interface LoginTarget {
|
|
19
|
+
readonly apiKey?: LoginRunner;
|
|
20
|
+
readonly oauth?: LoginRunner;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Test seam. The real read is a dynamic import because pi-ai's provider table
|
|
24
|
+
* is large and only login and the ambient-auth probe need it, matching
|
|
25
|
+
* pi-catalog.ts's own pattern.
|
|
26
|
+
*/
|
|
27
|
+
export declare const _loginDeps: {
|
|
28
|
+
providers: () => Promise<readonly PiProvider[]>;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Resolves which logins a provider can actually run.
|
|
32
|
+
*
|
|
33
|
+
* Reads pi's own two auth fields, NOT ResolvedProvider.auth: toProviderAuth
|
|
34
|
+
* resolves api-key over oauth when a provider declares both, which hides
|
|
35
|
+
* openrouter's OAuth flow (wrong) and anthropic's (right) indistinguishably.
|
|
36
|
+
*
|
|
37
|
+
* The allowlist is applied per method, not per provider, so a provider with a
|
|
38
|
+
* disallowed OAuth flow keeps its api-key login.
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveLoginTarget(providerId: ProviderId): Promise<LoginTarget>;
|
|
41
|
+
/**
|
|
42
|
+
* Registers pi-ai's OAuth flow modules so a bundled build of this package can
|
|
43
|
+
* still find them.
|
|
44
|
+
*
|
|
45
|
+
* The bug this exists to fix: pi-ai's default loader (`auth/oauth/load.js`)
|
|
46
|
+
* reaches each flow module through a *variable* import specifier, built from
|
|
47
|
+
* `import.meta.url` at run time. From source that resolves fine inside
|
|
48
|
+
* node_modules, but once this package is bundled `import.meta.url` points at
|
|
49
|
+
* the bundle file, the flow module is not beside it on disk, and login fails
|
|
50
|
+
* with "Cannot find module './openai-codex.js'". pi-ai ships a fix for this
|
|
51
|
+
* exact shape: `registerBundledOAuthFlowLoaders`, which lets a bundler-aware
|
|
52
|
+
* caller hand it the flow modules directly instead of letting it compute a
|
|
53
|
+
* path at run time.
|
|
54
|
+
*
|
|
55
|
+
* The import below MUST stay a dynamic import of a LITERAL specifier string:
|
|
56
|
+
* - Literal, so a bundler can statically follow and include it — that is
|
|
57
|
+
* the entire fix. Building the specifier from a variable (even
|
|
58
|
+
* `"@earendil-works/pi-ai" + "/bun-oauth"`) reintroduces the original bug
|
|
59
|
+
* in a new spot.
|
|
60
|
+
* - Dynamic, so this cost is paid only by a consumer that actually logs in.
|
|
61
|
+
* A static top-level import would drag all seven OAuth flow modules plus
|
|
62
|
+
* their `node:http`/`node:crypto` dependencies into every consumer's
|
|
63
|
+
* eager import graph, including ones that never call this function.
|
|
64
|
+
* A future "simplification" to a static import, or to a computed specifier,
|
|
65
|
+
* would silently undo the fix this function exists to provide.
|
|
66
|
+
*
|
|
67
|
+
* Named without "bun": pi-ai exposes this at the subpath `bun-oauth` because
|
|
68
|
+
* it was built for pi-ai's own standalone Bun binary, but nothing inside it
|
|
69
|
+
* is Bun-specific — it is seven plain imports and one function call, and it
|
|
70
|
+
* fixes the same bundler problem for any bundled build (Node included). This
|
|
71
|
+
* package ships to Node and Deno consumers too, so an API named after Bun
|
|
72
|
+
* here would misdescribe what it does.
|
|
73
|
+
*/
|
|
74
|
+
export declare function registerBundledOAuthFlows(): Promise<void>;
|
|
75
|
+
export declare function ambientAuthAvailable(providerId: ProviderId): Promise<boolean>;
|
|
12
76
|
//# sourceMappingURL=pi-auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-auth.d.ts","sourceRoot":"","sources":["../../src/auth/pi-auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,
|
|
1
|
+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,CAAC,OAAO,CAAC,CAiBnF"}
|
package/dist/auth/pi-auth.js
CHANGED
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* On the ALLOWED list in scripts/check-pi-ai-imports.ts. Nothing here leaks a
|
|
5
5
|
* pi-ai type through an export a consumer sees.
|
|
6
6
|
*/
|
|
7
|
+
import { defaultProviderAuthContext } from "@earendil-works/pi-ai";
|
|
8
|
+
import { AuthMethodUnavailableError, LoginFailedError } from "./login-errors.js";
|
|
9
|
+
import { assertOAuthFlowPermitted, isOAuthFlowPermitted } from "./oauth-policy.js";
|
|
7
10
|
function toPi(credential) {
|
|
8
11
|
if (credential === undefined)
|
|
9
12
|
return undefined;
|
|
@@ -81,4 +84,203 @@ export function createPiAuthResolver(models) {
|
|
|
81
84
|
},
|
|
82
85
|
};
|
|
83
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Test seam. The real read is a dynamic import because pi-ai's provider table
|
|
89
|
+
* is large and only login and the ambient-auth probe need it, matching
|
|
90
|
+
* pi-catalog.ts's own pattern.
|
|
91
|
+
*/
|
|
92
|
+
export const _loginDeps = {
|
|
93
|
+
providers: async () => {
|
|
94
|
+
const { builtinProviders } = await import("@earendil-works/pi-ai/providers/all");
|
|
95
|
+
return builtinProviders();
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
function required(credential, providerId) {
|
|
99
|
+
const stored = fromPi(credential);
|
|
100
|
+
if (stored === undefined)
|
|
101
|
+
throw new LoginFailedError(providerId, "the flow returned no credential");
|
|
102
|
+
return stored;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Resolves which logins a provider can actually run.
|
|
106
|
+
*
|
|
107
|
+
* Reads pi's own two auth fields, NOT ResolvedProvider.auth: toProviderAuth
|
|
108
|
+
* resolves api-key over oauth when a provider declares both, which hides
|
|
109
|
+
* openrouter's OAuth flow (wrong) and anthropic's (right) indistinguishably.
|
|
110
|
+
*
|
|
111
|
+
* The allowlist is applied per method, not per provider, so a provider with a
|
|
112
|
+
* disallowed OAuth flow keeps its api-key login.
|
|
113
|
+
*/
|
|
114
|
+
export async function resolveLoginTarget(providerId) {
|
|
115
|
+
const provider = (await _loginDeps.providers()).find((candidate) => candidate.id === providerId);
|
|
116
|
+
if (provider === undefined)
|
|
117
|
+
throw new AuthMethodUnavailableError(providerId);
|
|
118
|
+
const target = {};
|
|
119
|
+
const apiKeyAuth = provider.auth.apiKey;
|
|
120
|
+
if (apiKeyAuth?.login !== undefined) {
|
|
121
|
+
// bind rather than call detached: pi's flows are object methods and may
|
|
122
|
+
// read `this`.
|
|
123
|
+
const run = apiKeyAuth.login.bind(apiKeyAuth);
|
|
124
|
+
target.apiKey = {
|
|
125
|
+
label: apiKeyAuth.name,
|
|
126
|
+
run: async (interaction, signal) => required(await run({ ...toPiInteraction(interaction), signal }), providerId),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
const oauthAuth = provider.auth.oauth;
|
|
130
|
+
if (oauthAuth !== undefined && isOAuthFlowPermitted(providerId)) {
|
|
131
|
+
const run = oauthAuth.login.bind(oauthAuth);
|
|
132
|
+
target.oauth = {
|
|
133
|
+
label: oauthAuth.loginLabel ?? oauthAuth.name,
|
|
134
|
+
run: async (interaction, signal) => {
|
|
135
|
+
// Before the loader is touched, not after: pi bundles every flow behind
|
|
136
|
+
// one lazy loader, so the gate must sit in front of it.
|
|
137
|
+
assertOAuthFlowPermitted(providerId);
|
|
138
|
+
return required(await run({ ...toPiInteraction(interaction), signal }), providerId);
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
if (target.apiKey === undefined && provider.auth.oauth !== undefined) {
|
|
143
|
+
// The provider's only method is an OAuth flow this package refuses to run.
|
|
144
|
+
// A policy refusal must not read as an absence: throw the policy error
|
|
145
|
+
// rather than AuthMethodUnavailableError. assertOAuthFlowPermitted
|
|
146
|
+
// distinguishes prohibited (OAuthFlowProhibitedError) from unknown.
|
|
147
|
+
assertOAuthFlowPermitted(providerId);
|
|
148
|
+
}
|
|
149
|
+
return target;
|
|
150
|
+
}
|
|
151
|
+
function fromPiPrompt(prompt) {
|
|
152
|
+
const signal = prompt.signal !== undefined ? { signal: prompt.signal } : {};
|
|
153
|
+
switch (prompt.type) {
|
|
154
|
+
case "manual_code":
|
|
155
|
+
return {
|
|
156
|
+
...signal,
|
|
157
|
+
type: "manual-code",
|
|
158
|
+
message: prompt.message,
|
|
159
|
+
...(prompt.placeholder !== undefined ? { placeholder: prompt.placeholder } : {}),
|
|
160
|
+
};
|
|
161
|
+
case "select":
|
|
162
|
+
return { ...signal, type: "select", message: prompt.message, options: prompt.options };
|
|
163
|
+
default:
|
|
164
|
+
return {
|
|
165
|
+
...signal,
|
|
166
|
+
type: prompt.type,
|
|
167
|
+
message: prompt.message,
|
|
168
|
+
...(prompt.placeholder !== undefined ? { placeholder: prompt.placeholder } : {}),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function fromPiEvent(event) {
|
|
173
|
+
switch (event.type) {
|
|
174
|
+
case "auth_url":
|
|
175
|
+
return {
|
|
176
|
+
type: "auth-url",
|
|
177
|
+
url: event.url,
|
|
178
|
+
...(event.instructions !== undefined ? { instructions: event.instructions } : {}),
|
|
179
|
+
};
|
|
180
|
+
case "device_code":
|
|
181
|
+
return {
|
|
182
|
+
type: "device-code",
|
|
183
|
+
userCode: event.userCode,
|
|
184
|
+
verificationUri: event.verificationUri,
|
|
185
|
+
...(event.intervalSeconds !== undefined ? { intervalSeconds: event.intervalSeconds } : {}),
|
|
186
|
+
...(event.expiresInSeconds !== undefined ? { expiresInSeconds: event.expiresInSeconds } : {}),
|
|
187
|
+
};
|
|
188
|
+
case "info":
|
|
189
|
+
return { type: "info", message: event.message, ...(event.links !== undefined ? { links: event.links } : {}) };
|
|
190
|
+
default:
|
|
191
|
+
return { type: "progress", message: event.message };
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Presents a consumer's LoginInteraction to pi. pi calls us, so this maps
|
|
196
|
+
* inward: pi's snake_case names become nax-ai's kebab-case ones.
|
|
197
|
+
*/
|
|
198
|
+
function toPiInteraction(interaction) {
|
|
199
|
+
return {
|
|
200
|
+
prompt: async (prompt) => interaction.prompt(fromPiPrompt(prompt)),
|
|
201
|
+
notify: (event) => {
|
|
202
|
+
interaction.notify(fromPiEvent(event));
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Whether ambient auth alone would satisfy this provider.
|
|
208
|
+
*
|
|
209
|
+
* Enumerating env var names cannot answer this: ProviderAuth.env is
|
|
210
|
+
* descriptive only, often absent, and never read by auth resolution. pi's own
|
|
211
|
+
* resolve() returns undefined when a provider is not configured and already
|
|
212
|
+
* merges env vars, AWS profiles and ADC files, so asking it with no credential
|
|
213
|
+
* is the question exactly. check() is the side-effect-free variant, preferred
|
|
214
|
+
* because resolve() may execute commands.
|
|
215
|
+
*
|
|
216
|
+
* A probe that throws is reported as "not available" rather than propagated:
|
|
217
|
+
* this only ever decorates a diagnostic, and breaking the command it decorates
|
|
218
|
+
* would be worse than a missing warning.
|
|
219
|
+
*/
|
|
220
|
+
let bundledOAuthFlows;
|
|
221
|
+
/**
|
|
222
|
+
* Registers pi-ai's OAuth flow modules so a bundled build of this package can
|
|
223
|
+
* still find them.
|
|
224
|
+
*
|
|
225
|
+
* The bug this exists to fix: pi-ai's default loader (`auth/oauth/load.js`)
|
|
226
|
+
* reaches each flow module through a *variable* import specifier, built from
|
|
227
|
+
* `import.meta.url` at run time. From source that resolves fine inside
|
|
228
|
+
* node_modules, but once this package is bundled `import.meta.url` points at
|
|
229
|
+
* the bundle file, the flow module is not beside it on disk, and login fails
|
|
230
|
+
* with "Cannot find module './openai-codex.js'". pi-ai ships a fix for this
|
|
231
|
+
* exact shape: `registerBundledOAuthFlowLoaders`, which lets a bundler-aware
|
|
232
|
+
* caller hand it the flow modules directly instead of letting it compute a
|
|
233
|
+
* path at run time.
|
|
234
|
+
*
|
|
235
|
+
* The import below MUST stay a dynamic import of a LITERAL specifier string:
|
|
236
|
+
* - Literal, so a bundler can statically follow and include it — that is
|
|
237
|
+
* the entire fix. Building the specifier from a variable (even
|
|
238
|
+
* `"@earendil-works/pi-ai" + "/bun-oauth"`) reintroduces the original bug
|
|
239
|
+
* in a new spot.
|
|
240
|
+
* - Dynamic, so this cost is paid only by a consumer that actually logs in.
|
|
241
|
+
* A static top-level import would drag all seven OAuth flow modules plus
|
|
242
|
+
* their `node:http`/`node:crypto` dependencies into every consumer's
|
|
243
|
+
* eager import graph, including ones that never call this function.
|
|
244
|
+
* A future "simplification" to a static import, or to a computed specifier,
|
|
245
|
+
* would silently undo the fix this function exists to provide.
|
|
246
|
+
*
|
|
247
|
+
* Named without "bun": pi-ai exposes this at the subpath `bun-oauth` because
|
|
248
|
+
* it was built for pi-ai's own standalone Bun binary, but nothing inside it
|
|
249
|
+
* is Bun-specific — it is seven plain imports and one function call, and it
|
|
250
|
+
* fixes the same bundler problem for any bundled build (Node included). This
|
|
251
|
+
* package ships to Node and Deno consumers too, so an API named after Bun
|
|
252
|
+
* here would misdescribe what it does.
|
|
253
|
+
*/
|
|
254
|
+
export function registerBundledOAuthFlows() {
|
|
255
|
+
bundledOAuthFlows ??= (async () => {
|
|
256
|
+
const { registerBunOAuthFlows } = await import("@earendil-works/pi-ai/bun-oauth");
|
|
257
|
+
registerBunOAuthFlows();
|
|
258
|
+
})().catch((error) => {
|
|
259
|
+
// Memoise the success, never the failure. Caching a rejected promise
|
|
260
|
+
// would turn one transient import error into a permanent one: every
|
|
261
|
+
// later login in this process would fail with it, and nothing would
|
|
262
|
+
// clear it short of a restart.
|
|
263
|
+
bundledOAuthFlows = undefined;
|
|
264
|
+
throw error;
|
|
265
|
+
});
|
|
266
|
+
return bundledOAuthFlows;
|
|
267
|
+
}
|
|
268
|
+
export async function ambientAuthAvailable(providerId) {
|
|
269
|
+
const provider = (await _loginDeps.providers()).find((candidate) => candidate.id === providerId);
|
|
270
|
+
const apiKey = provider?.auth.apiKey;
|
|
271
|
+
if (apiKey === undefined)
|
|
272
|
+
return false;
|
|
273
|
+
const ctx = defaultProviderAuthContext();
|
|
274
|
+
const signal = new AbortController().signal;
|
|
275
|
+
try {
|
|
276
|
+
// Bind rather than call detached: pi's auth objects are methods that may read `this`.
|
|
277
|
+
if (apiKey.check !== undefined) {
|
|
278
|
+
return (await apiKey.check.bind(apiKey)({ ctx, signal })) !== undefined;
|
|
279
|
+
}
|
|
280
|
+
return (await apiKey.resolve.bind(apiKey)({ ctx, signal })) !== undefined;
|
|
281
|
+
}
|
|
282
|
+
catch {
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
84
286
|
//# sourceMappingURL=pi-auth.js.map
|
package/dist/auth/pi-auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-auth.js","sourceRoot":"","sources":["../../src/auth/pi-auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"pi-auth.js","sourceRoot":"","sources":["../../src/auth/pi-auth.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEjF,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAGnF,SAAS,IAAI,CAAC,UAAwC;IACpD,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC/C,IAAI,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAClC,OAAO;YACL,IAAI,EAAE,SAAS;YACf,GAAG,EAAE,UAAU,CAAC,GAAG;YACnB,GAAG,CAAC,UAAU,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,GAAG,U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IACd,CAAC,CAAC,CAAC;IACH,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,UAAsB;IAC/D,MAAM,QAAQ,GAAG,CAAC,MAAM,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,UAAU,CAAC,CAAC;IACjG,MAAM,MAAM,GAAG,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC;IACrC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAEvC,MAAM,GAAG,GAAG,0BAA0B,EAAE,CAAC;IACzC,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC,MAAM,CAAC;IAE5C,IAAI,CAAC;QACH,sFAAsF;QACtF,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC/B,OAAO,CAAC,MAAM,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC;QAC1E,CAAC;QACD,OAAO,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC;IAC5E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -9,12 +9,11 @@ import { type BackendSelection, type ProtocolEntries } from "./protocols/registr
|
|
|
9
9
|
import type { ProtocolEvent, ProtocolRequest } from "./protocols/types.ts";
|
|
10
10
|
import { type RawProvider } from "./providers/catalog.ts";
|
|
11
11
|
import type { Pricing, ProviderOverride, ResolvedModel } from "./providers/types.ts";
|
|
12
|
-
import type { CompleteResult
|
|
12
|
+
import type { CompleteResult } from "./types.ts";
|
|
13
13
|
export interface ClientOptions {
|
|
14
14
|
readonly providers: readonly RawProvider[];
|
|
15
15
|
readonly protocols: ProtocolEntries;
|
|
16
16
|
readonly backends?: BackendSelection;
|
|
17
|
-
readonly credentials?: CredentialStore;
|
|
18
17
|
readonly providerOverrides?: readonly ProviderOverride[];
|
|
19
18
|
/** Transport-fault retries before the first event. Default 2; 0 disables. */
|
|
20
19
|
readonly transportRetries?: number;
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,KAAK,gBAAgB,EAAkB,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAGtG,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,KAAK,EAAE,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,KAAK,gBAAgB,EAAkB,KAAK,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAGtG,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,SAAS,EAAE,SA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CAAC;QACvB,CAAC;QAED,MAAM,CAAC,KAAK,EAAE,GAAG;YACf,OAAO,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChC,CAAC;QAED,QAAQ,CAAC,KAAK,EAAE,GAAG;YACjB,OAAO,aAAa,CAAC,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;QAC/C,CAAC;QAED,QAAQ;YACN,QAAQ,CAAC,QAAQ,EAAE,CAAC;QACtB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,18 +11,22 @@
|
|
|
11
11
|
* this surface to be replaced — provider by provider — without consumers
|
|
12
12
|
* noticing.
|
|
13
13
|
*/
|
|
14
|
+
export { login } from "./auth/login.ts";
|
|
15
|
+
export { AuthMethodUnavailableError, LoginCancelledError, LoginFailedError, } from "./auth/login-errors.ts";
|
|
16
|
+
export type { LoginEvent, LoginInteraction, LoginLink, LoginMethod, LoginOption, LoginOptions, LoginPrompt, LoginResult, } from "./auth/login-types.ts";
|
|
14
17
|
export { assertOAuthFlowPermitted, isOAuthFlowPermitted, OAuthFlowProhibitedError, PERMITTED_OAUTH_FLOWS, PROHIBITED_OAUTH_FLOWS, } from "./auth/oauth-policy.ts";
|
|
18
|
+
export { ambientAuthAvailable, registerBundledOAuthFlows } from "./auth/pi-auth.ts";
|
|
15
19
|
export type { AuthResolver, ResolvedAuth } from "./auth/resolver.ts";
|
|
16
20
|
export { type Client, type ClientOptions, type ClientRequest, createClient } from "./client.ts";
|
|
17
21
|
export { createFileCredentialStore, type FileCredentialStoreOptions, } from "./credentials/file-store.ts";
|
|
18
22
|
export { createMemoryCredentialStore } from "./credentials/memory-store.ts";
|
|
19
23
|
export { collectStream, ProtocolStreamError } from "./protocols/collect.ts";
|
|
20
|
-
export { PI_PROTOCOL_NAMES, type PiProtocolName, type PiProtocolOptions, piProtocols, } from "./protocols/pi-protocols.ts";
|
|
24
|
+
export { DEFAULT_PROTOCOL_NAMES, defaultProtocols, PI_PROTOCOL_NAMES, type PiProtocolName, type PiProtocolOptions, type ProtocolName, type ProtocolOptions, piProtocols, } from "./protocols/pi-protocols.ts";
|
|
21
25
|
export { type BackendId, type BackendSelection, createRegistry, type ProtocolBackends, type ProtocolEntries, UnknownProtocolError, UnregisteredBackendError, } from "./protocols/registry.ts";
|
|
22
26
|
export { clampThinkingLevel } from "./protocols/thinking.ts";
|
|
23
27
|
export type { CacheRetention, ConstrainedSampling, ConversationMessage, JsonSchema, Protocol, ProtocolError, ProtocolEvent, ProtocolRequest, ThinkingBlock, ThinkingLevel, ToolCall, ToolDefinition, Transport, } from "./protocols/types.ts";
|
|
24
28
|
export { type Catalog, normaliseCatalog, type RawModel, type RawProvider } from "./providers/catalog.ts";
|
|
25
|
-
export { piProviders } from "./providers/pi-catalog.ts";
|
|
29
|
+
export { defaultProviders, piProviders } from "./providers/pi-catalog.ts";
|
|
26
30
|
export type { Pricing, PricingRates, PricingTier, ProviderAuth, ProviderOverride, ResolvedModel, ResolvedProvider, } from "./providers/types.ts";
|
|
27
31
|
export type { CompleteOptions, CompleteResult, CredentialStore, Message, MessageRole, ModelRef, ProviderId, StopReason, StoredCredential, TokenUsage, } from "./types.ts";
|
|
28
32
|
export { toTokenUsage, totalTokens, type UpstreamUsage } from "./usage.ts";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA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,2BAA2B,CAAC;AAC1E,YAAY,EACV,OAAO,EACP,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,eAAe,EACf,cAAc,EACd,eAAe,EACf,OAAO,EACP,WAAW,EACX,QAAQ,EACR,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,UAAU,GACX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -11,15 +11,18 @@
|
|
|
11
11
|
* this surface to be replaced — provider by provider — without consumers
|
|
12
12
|
* noticing.
|
|
13
13
|
*/
|
|
14
|
+
export { login } from "./auth/login.js";
|
|
15
|
+
export { AuthMethodUnavailableError, LoginCancelledError, LoginFailedError, } from "./auth/login-errors.js";
|
|
14
16
|
export { assertOAuthFlowPermitted, isOAuthFlowPermitted, OAuthFlowProhibitedError, PERMITTED_OAUTH_FLOWS, PROHIBITED_OAUTH_FLOWS, } from "./auth/oauth-policy.js";
|
|
17
|
+
export { ambientAuthAvailable, registerBundledOAuthFlows } from "./auth/pi-auth.js";
|
|
15
18
|
export { createClient } from "./client.js";
|
|
16
19
|
export { createFileCredentialStore, } from "./credentials/file-store.js";
|
|
17
20
|
export { createMemoryCredentialStore } from "./credentials/memory-store.js";
|
|
18
21
|
export { collectStream, ProtocolStreamError } from "./protocols/collect.js";
|
|
19
|
-
export { PI_PROTOCOL_NAMES, piProtocols, } from "./protocols/pi-protocols.js";
|
|
22
|
+
export { DEFAULT_PROTOCOL_NAMES, defaultProtocols, PI_PROTOCOL_NAMES, piProtocols, } from "./protocols/pi-protocols.js";
|
|
20
23
|
export { createRegistry, UnknownProtocolError, UnregisteredBackendError, } from "./protocols/registry.js";
|
|
21
24
|
export { clampThinkingLevel } from "./protocols/thinking.js";
|
|
22
25
|
export { normaliseCatalog } from "./providers/catalog.js";
|
|
23
|
-
export { piProviders } from "./providers/pi-catalog.js";
|
|
26
|
+
export { defaultProviders, piProviders } from "./providers/pi-catalog.js";
|
|
24
27
|
export { toTokenUsage, totalTokens } from "./usage.js";
|
|
25
28
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EACL,0BAA0B,EAC1B,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAWhC,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAEpF,OAAO,EAAuD,YAAY,EAAE,MAAM,aAAa,CAAC;AAChG,OAAO,EACL,yBAAyB,GAE1B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EAKjB,WAAW,GACZ,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAGL,cAAc,EAGd,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAgB7D,OAAO,EAAgB,gBAAgB,EAAmC,MAAM,wBAAwB,CAAC;AACzG,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAsB1E,OAAO,EAAE,YAAY,EAAE,WAAW,EAAsB,MAAM,YAAY,CAAC"}
|
|
@@ -12,9 +12,23 @@
|
|
|
12
12
|
import type { CredentialStore } from "../types.ts";
|
|
13
13
|
import type { ProtocolEntries } from "./registry.ts";
|
|
14
14
|
import type { Transport } from "./types.ts";
|
|
15
|
+
/**
|
|
16
|
+
* Neutral names for this module's public surface.
|
|
17
|
+
*
|
|
18
|
+
* This package exists to hide pi-ai behind its own vocabulary — that is its
|
|
19
|
+
* whole reason to exist. Naming the public API after "pi" defeats that: the
|
|
20
|
+
* name either starts lying the day the backend stops being pi-ai, or forces a
|
|
21
|
+
* breaking rename at exactly the moment the internals change. `DEFAULT_*` /
|
|
22
|
+
* `default*` name what these are (the client's default, pi-backed protocol
|
|
23
|
+
* set), not what implements them today.
|
|
24
|
+
*/
|
|
25
|
+
export declare const DEFAULT_PROTOCOL_NAMES: readonly ["anthropic-messages", "openai-completions", "openai-responses", "openai-codex-responses"];
|
|
26
|
+
/** @deprecated Use {@link DEFAULT_PROTOCOL_NAMES}. Kept as a non-breaking alias. */
|
|
15
27
|
export declare const PI_PROTOCOL_NAMES: readonly ["anthropic-messages", "openai-completions", "openai-responses", "openai-codex-responses"];
|
|
16
|
-
export type
|
|
17
|
-
|
|
28
|
+
export type ProtocolName = (typeof DEFAULT_PROTOCOL_NAMES)[number];
|
|
29
|
+
/** @deprecated Use {@link ProtocolName}. Kept as a non-breaking alias. */
|
|
30
|
+
export type PiProtocolName = ProtocolName;
|
|
31
|
+
export interface ProtocolOptions {
|
|
18
32
|
/** Where OAuth and api-key credentials live. Omitted means ambient only. */
|
|
19
33
|
readonly credentials?: CredentialStore;
|
|
20
34
|
/**
|
|
@@ -33,5 +47,9 @@ export interface PiProtocolOptions {
|
|
|
33
47
|
*/
|
|
34
48
|
readonly transport?: Transport;
|
|
35
49
|
}
|
|
36
|
-
|
|
50
|
+
/** @deprecated Use {@link ProtocolOptions}. Kept as a non-breaking alias. */
|
|
51
|
+
export type PiProtocolOptions = ProtocolOptions;
|
|
52
|
+
export declare function defaultProtocols(options?: ProtocolOptions): ProtocolEntries;
|
|
53
|
+
/** @deprecated Use {@link defaultProtocols}. Kept as a non-breaking alias. */
|
|
54
|
+
export declare const piProtocols: typeof defaultProtocols;
|
|
37
55
|
//# sourceMappingURL=pi-protocols.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-protocols.d.ts","sourceRoot":"","sources":["../../src/protocols/pi-protocols.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"pi-protocols.d.ts","sourceRoot":"","sources":["../../src/protocols/pi-protocols.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,YACjC,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,wBAAwB,CAChB,CAAC;AAEX,oFAAoF;AACpF,eAAO,MAAM,iBAAiB,qGAAyB,CAAC;AAExD,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnE,0EAA0E;AAC1E,MAAM,MAAM,cAAc,GAAG,YAAY,CAAC;AAE1C,MAAM,WAAW,eAAe;IAC9B,4EAA4E;IAC5E,QAAQ,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC;IACvC;;;;;;;;;;;;;OAaG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;CAChC;AAED,6EAA6E;AAC7E,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAEhD,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,eAAoB,GAAG,eAAe,CAY/E;AAED,8EAA8E;AAC9E,eAAO,MAAM,WAAW,yBAAmB,CAAC"}
|
|
@@ -9,14 +9,26 @@
|
|
|
9
9
|
* pi-ai is not imported here. The factory is lazy, so the import cost is paid
|
|
10
10
|
* on first resolve of a protocol and not before.
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Neutral names for this module's public surface.
|
|
14
|
+
*
|
|
15
|
+
* This package exists to hide pi-ai behind its own vocabulary — that is its
|
|
16
|
+
* whole reason to exist. Naming the public API after "pi" defeats that: the
|
|
17
|
+
* name either starts lying the day the backend stops being pi-ai, or forces a
|
|
18
|
+
* breaking rename at exactly the moment the internals change. `DEFAULT_*` /
|
|
19
|
+
* `default*` name what these are (the client's default, pi-backed protocol
|
|
20
|
+
* set), not what implements them today.
|
|
21
|
+
*/
|
|
22
|
+
export const DEFAULT_PROTOCOL_NAMES = [
|
|
13
23
|
"anthropic-messages",
|
|
14
24
|
"openai-completions",
|
|
15
25
|
"openai-responses",
|
|
16
26
|
"openai-codex-responses",
|
|
17
27
|
];
|
|
18
|
-
|
|
19
|
-
|
|
28
|
+
/** @deprecated Use {@link DEFAULT_PROTOCOL_NAMES}. Kept as a non-breaking alias. */
|
|
29
|
+
export const PI_PROTOCOL_NAMES = DEFAULT_PROTOCOL_NAMES;
|
|
30
|
+
export function defaultProtocols(options = {}) {
|
|
31
|
+
return Object.fromEntries(DEFAULT_PROTOCOL_NAMES.map((name) => [
|
|
20
32
|
name,
|
|
21
33
|
{
|
|
22
34
|
pi: async () => {
|
|
@@ -26,4 +38,6 @@ export function piProtocols(options = {}) {
|
|
|
26
38
|
},
|
|
27
39
|
]));
|
|
28
40
|
}
|
|
41
|
+
/** @deprecated Use {@link defaultProtocols}. Kept as a non-breaking alias. */
|
|
42
|
+
export const piProtocols = defaultProtocols;
|
|
29
43
|
//# sourceMappingURL=pi-protocols.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-protocols.js","sourceRoot":"","sources":["../../src/protocols/pi-protocols.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"pi-protocols.js","sourceRoot":"","sources":["../../src/protocols/pi-protocols.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,oBAAoB;IACpB,oBAAoB;IACpB,kBAAkB;IAClB,wBAAwB;CAChB,CAAC;AAEX,oFAAoF;AACpF,MAAM,CAAC,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AA8BxD,MAAM,UAAU,gBAAgB,CAAC,OAAO,GAAoB,EAAE;IAC5D,OAAO,MAAM,CAAC,WAAW,CACvB,sBAAsB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QACnC,IAAI;QACJ;YACE,EAAE,EAAE,KAAK,IAAI,EAAE;gBACb,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,CAAC;gBAC1E,OAAO,gBAAgB,CAAC,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC;YACvD,CAAC;SACF;KACF,CAAC,CACH,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAgB,CAAC"}
|
|
@@ -10,5 +10,16 @@
|
|
|
10
10
|
* call this pays nothing.
|
|
11
11
|
*/
|
|
12
12
|
import type { RawProvider } from "./catalog.ts";
|
|
13
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Neutral name for this module's public entry point.
|
|
15
|
+
*
|
|
16
|
+
* This package exists to hide pi-ai behind its own vocabulary, so a public
|
|
17
|
+
* name built from "pi" either lies once the backend stops being pi-ai, or
|
|
18
|
+
* forces a breaking rename exactly when that happens. `defaultProviders`
|
|
19
|
+
* names what this returns (the client's default provider catalog), not what
|
|
20
|
+
* produces it today. The old name stays as a deprecated, non-breaking alias.
|
|
21
|
+
*/
|
|
22
|
+
export declare function defaultProviders(ids?: readonly string[]): Promise<RawProvider[]>;
|
|
23
|
+
/** @deprecated Use {@link defaultProviders}. Kept as a non-breaking alias. */
|
|
24
|
+
export declare const piProviders: typeof defaultProviders;
|
|
14
25
|
//# sourceMappingURL=pi-catalog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-catalog.d.ts","sourceRoot":"","sources":["../../src/providers/pi-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,cAAc,CAAC;AAqB1D,wBAAsB,
|
|
1
|
+
{"version":3,"file":"pi-catalog.d.ts","sourceRoot":"","sources":["../../src/providers/pi-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAY,WAAW,EAAE,MAAM,cAAc,CAAC;AAqB1D;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CAAC,GAAG,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAsEtF;AAED,8EAA8E;AAC9E,eAAO,MAAM,WAAW,yBAAmB,CAAC"}
|
|
@@ -28,7 +28,16 @@ function toProviderAuth(id, auth) {
|
|
|
28
28
|
return { kind: "oauth", flow: id };
|
|
29
29
|
throw new Error(`Provider "${id}" declares neither api-key nor oauth auth.`);
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Neutral name for this module's public entry point.
|
|
33
|
+
*
|
|
34
|
+
* This package exists to hide pi-ai behind its own vocabulary, so a public
|
|
35
|
+
* name built from "pi" either lies once the backend stops being pi-ai, or
|
|
36
|
+
* forces a breaking rename exactly when that happens. `defaultProviders`
|
|
37
|
+
* names what this returns (the client's default provider catalog), not what
|
|
38
|
+
* produces it today. The old name stays as a deprecated, non-breaking alias.
|
|
39
|
+
*/
|
|
40
|
+
export async function defaultProviders(ids) {
|
|
32
41
|
const { builtinProviders, getBuiltinModels, getBuiltinProviders } = await import("@earendil-works/pi-ai/providers/all");
|
|
33
42
|
const { getSupportedThinkingLevels } = await import("@earendil-works/pi-ai");
|
|
34
43
|
const available = new Set(getBuiltinProviders());
|
|
@@ -88,4 +97,6 @@ export async function piProviders(ids) {
|
|
|
88
97
|
};
|
|
89
98
|
});
|
|
90
99
|
}
|
|
100
|
+
/** @deprecated Use {@link defaultProviders}. Kept as a non-breaking alias. */
|
|
101
|
+
export const piProviders = defaultProviders;
|
|
91
102
|
//# sourceMappingURL=pi-catalog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pi-catalog.js","sourceRoot":"","sources":["../../src/providers/pi-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH;;;;;;;;;;;GAWG;AACH,SAAS,cAAc,CAAC,EAAU,EAAE,IAA2C;IAC7E,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAC1D,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IACjE,MAAM,IAAI,KAAK,CAAC,aAAa,EAAE,4CAA4C,CAAC,C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