@nathapp/nax-ai 0.1.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.
Files changed (79) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +69 -0
  3. package/dist/auth/oauth-policy.d.ts +42 -0
  4. package/dist/auth/oauth-policy.d.ts.map +1 -0
  5. package/dist/auth/oauth-policy.js +61 -0
  6. package/dist/auth/oauth-policy.js.map +1 -0
  7. package/dist/auth/pi-auth.d.ts +12 -0
  8. package/dist/auth/pi-auth.d.ts.map +1 -0
  9. package/dist/auth/pi-auth.js +84 -0
  10. package/dist/auth/pi-auth.js.map +1 -0
  11. package/dist/auth/resolver.d.ts +30 -0
  12. package/dist/auth/resolver.d.ts.map +1 -0
  13. package/dist/auth/resolver.js +10 -0
  14. package/dist/auth/resolver.js.map +1 -0
  15. package/dist/client.d.ts +33 -0
  16. package/dist/client.d.ts.map +1 -0
  17. package/dist/client.js +68 -0
  18. package/dist/client.js.map +1 -0
  19. package/dist/index.d.ts +27 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +23 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/protocols/collect.d.ts +15 -0
  24. package/dist/protocols/collect.d.ts.map +1 -0
  25. package/dist/protocols/collect.js +65 -0
  26. package/dist/protocols/collect.js.map +1 -0
  27. package/dist/protocols/errors.d.ts +30 -0
  28. package/dist/protocols/errors.d.ts.map +1 -0
  29. package/dist/protocols/errors.js +59 -0
  30. package/dist/protocols/errors.js.map +1 -0
  31. package/dist/protocols/pi-client.d.ts +36 -0
  32. package/dist/protocols/pi-client.d.ts.map +1 -0
  33. package/dist/protocols/pi-client.js +348 -0
  34. package/dist/protocols/pi-client.js.map +1 -0
  35. package/dist/protocols/pi-protocols.d.ts +21 -0
  36. package/dist/protocols/pi-protocols.d.ts.map +1 -0
  37. package/dist/protocols/pi-protocols.js +29 -0
  38. package/dist/protocols/pi-protocols.js.map +1 -0
  39. package/dist/protocols/registry.d.ts +36 -0
  40. package/dist/protocols/registry.d.ts.map +1 -0
  41. package/dist/protocols/registry.js +85 -0
  42. package/dist/protocols/registry.js.map +1 -0
  43. package/dist/protocols/retry.d.ts +37 -0
  44. package/dist/protocols/retry.d.ts.map +1 -0
  45. package/dist/protocols/retry.js +96 -0
  46. package/dist/protocols/retry.js.map +1 -0
  47. package/dist/protocols/thinking.d.ts +11 -0
  48. package/dist/protocols/thinking.d.ts.map +1 -0
  49. package/dist/protocols/thinking.js +35 -0
  50. package/dist/protocols/thinking.js.map +1 -0
  51. package/dist/protocols/tool-args.d.ts +27 -0
  52. package/dist/protocols/tool-args.d.ts.map +1 -0
  53. package/dist/protocols/tool-args.js +38 -0
  54. package/dist/protocols/tool-args.js.map +1 -0
  55. package/dist/protocols/types.d.ts +142 -0
  56. package/dist/protocols/types.d.ts.map +1 -0
  57. package/dist/protocols/types.js +33 -0
  58. package/dist/protocols/types.js.map +1 -0
  59. package/dist/providers/catalog.d.ts +37 -0
  60. package/dist/providers/catalog.d.ts.map +1 -0
  61. package/dist/providers/catalog.js +72 -0
  62. package/dist/providers/catalog.js.map +1 -0
  63. package/dist/providers/pi-catalog.d.ts +14 -0
  64. package/dist/providers/pi-catalog.d.ts.map +1 -0
  65. package/dist/providers/pi-catalog.js +91 -0
  66. package/dist/providers/pi-catalog.js.map +1 -0
  67. package/dist/providers/types.d.ts +79 -0
  68. package/dist/providers/types.d.ts.map +1 -0
  69. package/dist/providers/types.js +10 -0
  70. package/dist/providers/types.js.map +1 -0
  71. package/dist/types.d.ts +94 -0
  72. package/dist/types.d.ts.map +1 -0
  73. package/dist/types.js +10 -0
  74. package/dist/types.js.map +1 -0
  75. package/dist/usage.d.ts +39 -0
  76. package/dist/usage.d.ts.map +1 -0
  77. package/dist/usage.js +40 -0
  78. package/dist/usage.js.map +1 -0
  79. package/package.json +68 -0
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Normalises a raw provider catalog into nax-ai types.
3
+ *
4
+ * STAYS pi-ai-BACKED. Hand-rolling the model catalog is explicitly out of
5
+ * scope: its pricing and model data are maintained upstream, and taking that
6
+ * maintenance back is the burden the dependency was chosen to avoid. Unlike
7
+ * `protocols/`, this layer is not a migration surface.
8
+ *
9
+ * This is also where the OAuth allowlist meets a real code path: a provider
10
+ * declaring a prohibited flow fails to resolve here.
11
+ */
12
+ import { assertOAuthFlowPermitted } from "../auth/oauth-policy.js";
13
+ export function normaliseCatalog(raw, overrides = []) {
14
+ const overrideFor = new Map(overrides.map((o) => [o.provider, o]));
15
+ const providers = new Map();
16
+ // Keep provider and model identifiers in separate map levels. Both are
17
+ // externally supplied opaque strings, so a delimiter-based composite key
18
+ // would make otherwise distinct pairs such as ("a", "b/c") and
19
+ // ("a/b", "c") collide.
20
+ const models = new Map();
21
+ const setModel = (provider, model) => {
22
+ let providerModels = models.get(provider);
23
+ if (providerModels === undefined) {
24
+ providerModels = new Map();
25
+ models.set(provider, providerModels);
26
+ }
27
+ providerModels.set(model.id, model);
28
+ };
29
+ for (const rawProvider of raw) {
30
+ // The gate, on the real path. A prohibited flow must stop resolution here,
31
+ // not merely fail a unit test of the policy module.
32
+ if (rawProvider.auth.kind === "oauth") {
33
+ assertOAuthFlowPermitted(rawProvider.auth.flow);
34
+ }
35
+ const override = overrideFor.get(rawProvider.id);
36
+ const headers = override?.headers ?? rawProvider.headers;
37
+ providers.set(rawProvider.id, {
38
+ id: rawProvider.id,
39
+ baseUrl: override?.baseUrl ?? rawProvider.baseUrl,
40
+ auth: rawProvider.auth,
41
+ ...(headers !== undefined ? { headers } : {}),
42
+ defaultProtocol: rawProvider.defaultProtocol,
43
+ });
44
+ for (const rawModel of rawProvider.models) {
45
+ setModel(rawProvider.id, {
46
+ id: rawModel.id,
47
+ provider: rawProvider.id,
48
+ protocol: rawModel.protocol ?? rawProvider.defaultProtocol,
49
+ pricing: rawModel.pricing,
50
+ contextWindow: rawModel.contextWindow,
51
+ supportsTools: rawModel.supportsTools,
52
+ thinkingLevels: rawModel.thinkingLevels,
53
+ });
54
+ }
55
+ }
56
+ // Override-supplied models are applied last so they can replace an entry.
57
+ for (const override of overrides) {
58
+ for (const model of override.models ?? []) {
59
+ setModel(override.provider, model);
60
+ }
61
+ }
62
+ return {
63
+ provider: (id) => providers.get(id),
64
+ model: (provider, model) => models.get(provider)?.get(model),
65
+ listModels: (provider) => {
66
+ if (provider !== undefined)
67
+ return [...(models.get(provider)?.values() ?? [])];
68
+ return [...models.values()].flatMap((providerModels) => [...providerModels.values()]);
69
+ },
70
+ };
71
+ }
72
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/providers/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AA6BnE,MAAM,UAAU,gBAAgB,CAAC,GAA2B,EAAE,SAAS,GAAgC,EAAE;IACvG,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACnE,MAAM,SAAS,GAAG,IAAI,GAAG,EAA4B,CAAC;IACtD,uEAAuE;IACvE,yEAAyE;IACzE,+DAA+D;IAC/D,wBAAwB;IACxB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAsC,CAAC;IAE7D,MAAM,QAAQ,GAAG,CAAC,QAAgB,EAAE,KAAoB,EAAQ,EAAE;QAChE,IAAI,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC1C,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;YACjC,cAAc,GAAG,IAAI,GAAG,EAAyB,CAAC;YAClD,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;QACvC,CAAC;QACD,cAAc,CAAC,GAAG,CAAC,K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E;IAC1E,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,KAAK,MAAM,KAAK,IAAI,QAAQ,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;YAC1C,QAAQ,CAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC;QACnC,KAAK,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC;QAC5D,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE;YACvB,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;YAC/E,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,GAAG,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACxF,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * pi-ai's bundled catalog, normalised into nax-ai types.
3
+ *
4
+ * pi-ai is the data source, never the runtime shape: no Model<Api> escapes
5
+ * this file. That is what lets a hand-written backend obtain baseUrl, headers
6
+ * and model metadata without importing pi-ai.
7
+ *
8
+ * The import is dynamic because the bundled catalog is roughly 1,290 models
9
+ * across 39 providers and costs about 50 ms to load. A consumer that does not
10
+ * call this pays nothing.
11
+ */
12
+ import type { RawProvider } from "./catalog.ts";
13
+ export declare function piProviders(ids?: readonly string[]): Promise<RawProvider[]>;
14
+ //# sourceMappingURL=pi-catalog.d.ts.map
@@ -0,0 +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,WAAW,CAAC,GAAG,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAsEjF"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * pi-ai's bundled catalog, normalised into nax-ai types.
3
+ *
4
+ * pi-ai is the data source, never the runtime shape: no Model<Api> escapes
5
+ * this file. That is what lets a hand-written backend obtain baseUrl, headers
6
+ * and model metadata without importing pi-ai.
7
+ *
8
+ * The import is dynamic because the bundled catalog is roughly 1,290 models
9
+ * across 39 providers and costs about 50 ms to load. A consumer that does not
10
+ * call this pays nothing.
11
+ */
12
+ /**
13
+ * Selects one of our two auth variants from pi-ai's, which may declare both.
14
+ *
15
+ * api-key wins when both are offered. This is not a tie-break for tidiness:
16
+ * anthropic offers both, and mapping it to oauth would make the allowlist in
17
+ * normaliseCatalog throw and render Anthropic unloadable. The prohibition is
18
+ * on Anthropic subscription OAuth, never on its API.
19
+ *
20
+ * `env` is left unset. pi-ai's variable-name table is module-private, and the
21
+ * two public routes to it either depend on the ambient environment or return
22
+ * the secret itself, so there is no honest value to put here.
23
+ */
24
+ function toProviderAuth(id, auth) {
25
+ if (auth.apiKey !== undefined)
26
+ return { kind: "api-key" };
27
+ if (auth.oauth !== undefined)
28
+ return { kind: "oauth", flow: id };
29
+ throw new Error(`Provider "${id}" declares neither api-key nor oauth auth.`);
30
+ }
31
+ export async function piProviders(ids) {
32
+ const { builtinProviders, getBuiltinModels, getBuiltinProviders } = await import("@earendil-works/pi-ai/providers/all");
33
+ const { getSupportedThinkingLevels } = await import("@earendil-works/pi-ai");
34
+ const available = new Set(getBuiltinProviders());
35
+ const wanted = ids ?? [...available];
36
+ const unknown = wanted.filter((id) => !available.has(id));
37
+ if (unknown.length > 0) {
38
+ throw new Error(`Unknown pi-ai provider(s): ${unknown.join(", ")}.`);
39
+ }
40
+ const providers = new Map(builtinProviders().map((provider) => [provider.id, provider]));
41
+ return wanted.map((id) => {
42
+ const provider = providers.get(id);
43
+ if (provider === undefined)
44
+ throw new Error(`Unknown pi-ai provider: ${id}.`);
45
+ const piModels = getBuiltinModels(id);
46
+ const models = piModels.map((model) => ({
47
+ id: model.id,
48
+ protocol: model.api,
49
+ pricing: {
50
+ input: model.cost.input,
51
+ output: model.cost.output,
52
+ cacheRead: model.cost.cacheRead,
53
+ cacheWrite: model.cost.cacheWrite,
54
+ ...(model.cost.tiers !== undefined
55
+ ? {
56
+ tiers: model.cost.tiers.map((tier) => ({
57
+ inputTokensAbove: tier.inputTokensAbove,
58
+ input: tier.input,
59
+ output: tier.output,
60
+ cacheRead: tier.cacheRead,
61
+ cacheWrite: tier.cacheWrite,
62
+ })),
63
+ }
64
+ : {}),
65
+ },
66
+ contextWindow: model.contextWindow,
67
+ // pi-ai's catalog does not carry a per-model tool flag; every model it
68
+ // serves through these four protocols accepts tool definitions, and a
69
+ // model that ignores them fails at request time, not at catalog time.
70
+ supportsTools: true,
71
+ thinkingLevels: getSupportedThinkingLevels(model),
72
+ }));
73
+ // A provider can span protocols, so the default is the one most of its
74
+ // models use; per-model `protocol` above is what actually selects.
75
+ const counts = new Map();
76
+ for (const model of models)
77
+ counts.set(model.protocol ?? "", (counts.get(model.protocol ?? "") ?? 0) + 1);
78
+ const defaultProtocol = [...counts.entries()].sort((a, b) => b[1] - a[1])[0]?.[0] ?? "openai-completions";
79
+ const baseUrl = provider.baseUrl ?? piModels[0]?.baseUrl ?? "";
80
+ const headers = piModels[0]?.headers;
81
+ return {
82
+ id,
83
+ baseUrl,
84
+ auth: toProviderAuth(id, provider.auth),
85
+ ...(headers !== undefined ? { headers } : {}),
86
+ defaultProtocol,
87
+ models,
88
+ };
89
+ });
90
+ }
91
+ //# sourceMappingURL=pi-catal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EAAsE;YACtE,aAAa,EAAE,IAAI;YACnB,cAAc,EAAE,0BAA0B,CAAC,KAAK,CAA6B;SAC9E,CAAC,CAAC,CAAC;QAEJ,uEAAuE;QACvE,mEAAmE;QACnE,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;QACzC,KAAK,MAAM,KAAK,IAAI,MAAM;YAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAC1G,MAAM,eAAe,GAAG,CAAC,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,oBAAoB,CAAC;QAE1G,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,EAAE,CAAC;QAC/D,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC;QAErC,OAAO;YACL,EAAE;YACF,OAAO;YACP,IAAI,EAAE,cAAc,CAAC,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC;YACvC,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7C,eAAe;YACf,MAAM;SACP,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Provider and model vocabulary.
3
+ *
4
+ * These are nax-ai's own types, deliberately not pi-ai's. A future hand-written
5
+ * protocol backend needs baseUrl, auth and headers, and must be able to obtain
6
+ * them without importing pi-ai — which is only true if the catalog is
7
+ * normalised into this shape at the boundary.
8
+ */
9
+ import type { ThinkingLevel } from "../protocols/types.ts";
10
+ /** Rates per 1M tokens. nax-ai supplies rates; the consumer computes cost. */
11
+ export interface PricingRates {
12
+ readonly input: number;
13
+ readonly output: number;
14
+ readonly cacheRead: number;
15
+ readonly cacheWrite: number;
16
+ }
17
+ /**
18
+ * A request-wide pricing tier. The highest matching threshold applies to the
19
+ * whole request.
20
+ *
21
+ * Extends the rates rather than `Pricing` so a tier cannot carry its own tiers.
22
+ */
23
+ export interface PricingTier extends PricingRates {
24
+ /** Applies when total input usage exceeds this token count. */
25
+ readonly inputTokensAbove: number;
26
+ }
27
+ export interface Pricing extends PricingRates {
28
+ /**
29
+ * Present for the 22 upstream models that price in tiers. A consumer that
30
+ * ignores this bills the base rates and will under-report a long-context
31
+ * request; one that honours it is correct. nax-ai still computes no cost.
32
+ */
33
+ readonly tiers?: readonly PricingTier[];
34
+ }
35
+ export type ProviderAuth =
36
+ /**
37
+ * `env` is descriptive only and is often absent: the upstream catalog does
38
+ * not expose variable names in a form that can be read without consulting
39
+ * the ambient environment. Auth resolution never reads this field.
40
+ */
41
+ {
42
+ readonly kind: "api-key";
43
+ readonly env?: string;
44
+ } | {
45
+ readonly kind: "oauth";
46
+ readonly flow: string;
47
+ };
48
+ export interface ResolvedProvider {
49
+ readonly id: string;
50
+ readonly baseUrl: string;
51
+ readonly auth: ProviderAuth;
52
+ readonly headers?: Readonly<Record<string, string>>;
53
+ readonly defaultProtocol: string;
54
+ }
55
+ export interface ResolvedModel {
56
+ readonly id: string;
57
+ readonly provider: string;
58
+ /** May differ from the provider default: one provider can span several. */
59
+ readonly protocol: string;
60
+ readonly pricing: Pricing;
61
+ readonly contextWindow: number;
62
+ readonly supportsTools: boolean;
63
+ /** Empty means the model has no thinking support. */
64
+ readonly thinkingLevels: readonly ThinkingLevel[];
65
+ }
66
+ /**
67
+ * Declaration-data overrides only.
68
+ *
69
+ * Behaviour changes are a wrapping protocol backend, not an override. Keeping
70
+ * that line sharp stops this growing into a second, weaker extension mechanism
71
+ * competing with the registry.
72
+ */
73
+ export interface ProviderOverride {
74
+ readonly provider: string;
75
+ readonly baseUrl?: string;
76
+ readonly headers?: Readonly<Record<string, string>>;
77
+ readonly models?: readonly ResolvedModel[];
78
+ }
79
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/providers/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,8EAA8E;AAC9E,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAY,SAAQ,YAAY;IAC/C,+DAA+D;IAC/D,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACnC;AAED,MAAM,WAAW,OAAQ,SAAQ,YAAY;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;CACzC;AAED,MAAM,MAAM,YAAY;AACtB;;;;GAIG;AACH;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1G,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,qDAAqD;IACrD,QAAQ,CAAC,cAAc,EAAE,SAAS,aAAa,EAAE,CAAC;CACnD;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACpD,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CAC5C"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Provider and model vocabulary.
3
+ *
4
+ * These are nax-ai's own types, deliberately not pi-ai's. A future hand-written
5
+ * protocol backend needs baseUrl, auth and headers, and must be able to obtain
6
+ * them without importing pi-ai — which is only true if the catalog is
7
+ * normalised into this shape at the boundary.
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/providers/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Public vocabulary for nax-ai.
3
+ *
4
+ * These types are deliberately generic. nax-ai knows nothing about stories,
5
+ * operations, sessions or permissions — a consumer maps these onto its own
6
+ * domain at its own boundary. Keeping nax concepts out of this file is what
7
+ * makes the package reusable; see ADR note in README.
8
+ */
9
+ /** Provider identifier as understood by the underlying client (e.g. "anthropic"). */
10
+ export type ProviderId = string;
11
+ /** A model selector: provider plus the provider's own model id. */
12
+ export interface ModelRef {
13
+ readonly provider: ProviderId;
14
+ readonly model: string;
15
+ }
16
+ /** Role of a message in a conversation. */
17
+ export type MessageRole = "system" | "user" | "assistant";
18
+ export interface Message {
19
+ readonly role: MessageRole;
20
+ readonly content: string;
21
+ }
22
+ /**
23
+ * Token accounting for a single call.
24
+ *
25
+ * Cache fields are separate rather than folded into `input` because providers
26
+ * price cache reads and cache writes differently, and a consumer computing
27
+ * cost needs them apart. Absent means the provider did not report it — which
28
+ * is different from zero.
29
+ */
30
+ export interface TokenUsage {
31
+ readonly inputTokens: number;
32
+ readonly outputTokens: number;
33
+ readonly cacheReadTokens?: number;
34
+ readonly cacheWriteTokens?: number;
35
+ }
36
+ /** Why the provider stopped generating. */
37
+ export type StopReason = "stop" | "length" | "tool_use" | "content_filter" | "error";
38
+ export interface CompleteOptions {
39
+ readonly model: ModelRef;
40
+ readonly messages: readonly Message[];
41
+ readonly maxTokens?: number;
42
+ readonly temperature?: number;
43
+ readonly signal?: AbortSignal;
44
+ }
45
+ export interface CompleteResult {
46
+ readonly text: string;
47
+ readonly usage: TokenUsage;
48
+ readonly stopReason: StopReason;
49
+ readonly toolCalls?: readonly import("./protocols/types.ts").ToolCall[];
50
+ /**
51
+ * Present only when the provider emitted extended thinking. A caller that
52
+ * wants to continue this turn (e.g. after running a tool call) must send
53
+ * these back on the next request's assistant message, in order — without
54
+ * this field there is no way to construct that follow-up turn.
55
+ */
56
+ readonly thinking?: readonly import("./protocols/types.ts").ThinkingBlock[];
57
+ }
58
+ /**
59
+ * Persistent credential storage, injected by the consumer.
60
+ *
61
+ * `modify` is a read-modify-write hook rather than a plain `write` so an
62
+ * implementation can hold a lock across the whole operation. That matters for
63
+ * OAuth refresh: concurrent processes sharing one credential file will
64
+ * otherwise race, and the in-process serialisation the default store provides
65
+ * does not span processes.
66
+ */
67
+ export interface CredentialStore {
68
+ read(providerId: ProviderId): Promise<StoredCredential | undefined>;
69
+ /**
70
+ * Returning `undefined` from `fn` removes the credential, and the pi adapter
71
+ * accordingly maps pi's leave-unchanged `undefined` (its no-op refresh) to
72
+ * the current credential.
73
+ */
74
+ modify(providerId: ProviderId, fn: (current: StoredCredential | undefined) => Promise<StoredCredential | undefined>): Promise<StoredCredential | undefined>;
75
+ delete(providerId: ProviderId): Promise<void>;
76
+ }
77
+ export type StoredCredential = {
78
+ readonly kind: "api-key";
79
+ /**
80
+ * Opaque. Some stores hold a literal, others a "$VAR" template or a
81
+ * "!command"; resolving those is the store's business, not nax-ai's.
82
+ * Never inspect, compare or log this value.
83
+ */
84
+ readonly key: string;
85
+ /** Provider-scoped values, including the substitution scope for `key`. */
86
+ readonly env?: Readonly<Record<string, string>>;
87
+ } | {
88
+ readonly kind: "oauth";
89
+ readonly access: string;
90
+ readonly refresh: string;
91
+ /** Epoch milliseconds. */
92
+ readonly expires: number;
93
+ };
94
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,qFAAqF;AACrF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC,mEAAmE;AACnE,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,2CAA2C;AAC3C,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;AAE1D,MAAM,WAAW,OAAO;I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AU,EAAE,UAAU,EACtB,EAAE,EAAE,CAAC,OAAO,EAAE,gBAAgB,GAAG,SAAS,KAAK,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,GACnF,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAAC;IACzC,MAAM,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C;AAED,MAAM,MAAM,gBAAgB,GACxB;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB;;;;OAIG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,0BAA0B;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Public vocabulary for nax-ai.
3
+ *
4
+ * These types are deliberately generic. nax-ai knows nothing about stories,
5
+ * operations, sessions or permissions — a consumer maps these onto its own
6
+ * domain at its own boundary. Keeping nax concepts out of this file is what
7
+ * makes the package reusable; see ADR note in README.
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Mapping from the underlying client's usage record to this package's.
3
+ *
4
+ * Kept as a standalone pure function, separate from any call path, because it
5
+ * is the piece most likely to be re-pointed at a different backend later: a
6
+ * hand-rolled protocol would produce the same `TokenUsage` from a different
7
+ * source shape, and nothing else would need to change.
8
+ *
9
+ * Two deliberate differences from the upstream shape:
10
+ *
11
+ * - `reasoning` is dropped. Upstream documents it as a *subset* of `output`,
12
+ * so surfacing it alongside would invite double-counting when a consumer
13
+ * sums fields to compute cost.
14
+ * - `cacheWrite1h` is folded into `cacheWriteTokens` rather than exposed.
15
+ * It is a subset of `cacheWrite` that only one provider reports, and the
16
+ * generic vocabulary here should not grow a provider-specific field.
17
+ *
18
+ * Zeroes are preserved rather than elided: upstream always populates the four
19
+ * base counters, so a zero means "the provider reported none", which is a
20
+ * different claim from a missing field.
21
+ */
22
+ import type { TokenUsage } from "./types.ts";
23
+ /** The subset of the upstream usage record this mapping reads. */
24
+ export interface UpstreamUsage {
25
+ readonly input: number;
26
+ readonly output: number;
27
+ readonly cacheRead: number;
28
+ readonly cacheWrite: number;
29
+ }
30
+ export declare function toTokenUsage(usage: UpstreamUsage): TokenUsage;
31
+ /**
32
+ * Total billable tokens for a call.
33
+ *
34
+ * Cache reads and writes are counted because providers bill them; they are
35
+ * priced differently from uncached input, which is why the caller needs the
36
+ * separated `TokenUsage` rather than a single number.
37
+ */
38
+ export declare function totalTokens(usage: TokenUsage): number;
39
+ //# sourceMappingURL=usage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,kEAAkE;AAClE,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,aAAa,GAAG,UAAU,CAO7D;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAErD"}
package/dist/usage.js ADDED
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Mapping from the underlying client's usage record to this package's.
3
+ *
4
+ * Kept as a standalone pure function, separate from any call path, because it
5
+ * is the piece most likely to be re-pointed at a different backend later: a
6
+ * hand-rolled protocol would produce the same `TokenUsage` from a different
7
+ * source shape, and nothing else would need to change.
8
+ *
9
+ * Two deliberate differences from the upstream shape:
10
+ *
11
+ * - `reasoning` is dropped. Upstream documents it as a *subset* of `output`,
12
+ * so surfacing it alongside would invite double-counting when a consumer
13
+ * sums fields to compute cost.
14
+ * - `cacheWrite1h` is folded into `cacheWriteTokens` rather than exposed.
15
+ * It is a subset of `cacheWrite` that only one provider reports, and the
16
+ * generic vocabulary here should not grow a provider-specific field.
17
+ *
18
+ * Zeroes are preserved rather than elided: upstream always populates the four
19
+ * base counters, so a zero means "the provider reported none", which is a
20
+ * different claim from a missing field.
21
+ */
22
+ export function toTokenUsage(usage) {
23
+ return {
24
+ inputTokens: usage.input,
25
+ outputTokens: usage.output,
26
+ cacheReadTokens: usage.cacheRead,
27
+ cacheWriteTokens: usage.cacheWrite,
28
+ };
29
+ }
30
+ /**
31
+ * Total billable tokens for a call.
32
+ *
33
+ * Cache reads and writes are counted because providers bill them; they are
34
+ * priced differently from uncached input, which is why the caller needs the
35
+ * separated `TokenUsage` rather than a single number.
36
+ */
37
+ export function totalTokens(usage) {
38
+ return usage.inputTokens + usage.outputTokens + (usage.cacheReadTokens ?? 0) + (usage.cacheWriteTokens ?? 0);
39
+ }
40
+ //# sourceMappingURL=usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.js","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAYH,MAAM,UAAU,YAAY,CAAC,KAAoB;IAC/C,OAAO;QACL,WAAW,EAAE,KAAK,CAAC,KAAK;QACxB,YAAY,EAAE,KAAK,CAAC,MAAM;QAC1B,eAAe,EAAE,KAAK,CAAC,SAAS;QAChC,gBAAgB,EAAE,KAAK,CAAC,UAAU;KACnC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,KAAiB;IAC3C,OAAO,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,YAAY,GAAG,CAAC,KAAK,CAAC,eAAe,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,gBAAgB,IAAI,CAAC,CAAC,CAAC;AAC/G,CAAC"}
package/package.json ADDED
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@nathapp/nax-ai",
3
+ "version": "0.1.0",
4
+ "description": "Provider-agnostic LLM client: completions, streaming, tool calls, usage and auth across API-key and OAuth providers.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist/",
16
+ "README.md",
17
+ "CHANGELOG.md"
18
+ ],
19
+ "engines": {
20
+ "node": ">=22.19.0"
21
+ },
22
+ "scripts": {
23
+ "build": "tsc -p tsconfig.build.json",
24
+ "release": "bun scripts/release.ts",
25
+ "typecheck": "tsc --noEmit",
26
+ "test": "vitest --run",
27
+ "test:live": "vitest --run --config vitest.live.config.ts",
28
+ "test:watch": "vitest",
29
+ "check:no-bun-apis": "bun run scripts/check-no-bun-apis.ts",
30
+ "check:pi-ai-imports": "bun run scripts/check-pi-ai-imports.ts",
31
+ "lint": "bun x biome check --error-on-warnings src/ test/ scripts/ && bun run check:no-bun-apis && bun run check:pi-ai-imports",
32
+ "lint:fix": "bun x biome check --write src/ test/ scripts/",
33
+ "prepublishOnly": "npm run build"
34
+ },
35
+ "dependencies": {
36
+ "@earendil-works/pi-ai": "0.84.4"
37
+ },
38
+ "devDependencies": {
39
+ "@biomejs/biome": "2.5.10",
40
+ "@types/node": "22.19.19",
41
+ "typescript": "7.0.2",
42
+ "vitest": "4.1.9"
43
+ },
44
+ "keywords": [
45
+ "llm",
46
+ "ai",
47
+ "anthropic",
48
+ "openai",
49
+ "provider",
50
+ "streaming"
51
+ ],
52
+ "license": "MIT",
53
+ "author": "William Khoo",
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "https://github.com/nathapp-io/nax-ai.git"
57
+ },
58
+ "homepage": "https://github.com/nathapp-io/nax-ai",
59
+ "bugs": {
60
+ "url": "https://github.com/nathapp-io/nax-ai/issues"
61
+ },
62
+ "publishConfig": {
63
+ "access": "public",
64
+ "registry": "https://registry.npmjs.org/",
65
+ "provenance": true,
66
+ "tag": "next"
67
+ }
68
+ }