@tai42/api-client 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 (48) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +28 -0
  3. package/dist/agents.d.ts +265 -0
  4. package/dist/agents.d.ts.map +1 -0
  5. package/dist/agents.js +200 -0
  6. package/dist/agents.js.map +1 -0
  7. package/dist/client.d.ts +1316 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +468 -0
  10. package/dist/client.js.map +1 -0
  11. package/dist/errors.d.ts +43 -0
  12. package/dist/errors.d.ts.map +1 -0
  13. package/dist/errors.js +63 -0
  14. package/dist/errors.js.map +1 -0
  15. package/dist/fleet-report.d.ts +61 -0
  16. package/dist/fleet-report.d.ts.map +1 -0
  17. package/dist/fleet-report.js +42 -0
  18. package/dist/fleet-report.js.map +1 -0
  19. package/dist/http.d.ts +69 -0
  20. package/dist/http.d.ts.map +1 -0
  21. package/dist/http.js +152 -0
  22. package/dist/http.js.map +1 -0
  23. package/dist/index.d.ts +23 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +16 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/schemas.d.ts +5469 -0
  28. package/dist/schemas.d.ts.map +1 -0
  29. package/dist/schemas.js +1103 -0
  30. package/dist/schemas.js.map +1 -0
  31. package/dist/sse.d.ts +27 -0
  32. package/dist/sse.d.ts.map +1 -0
  33. package/dist/sse.js +84 -0
  34. package/dist/sse.js.map +1 -0
  35. package/dist/tool-runs.d.ts +112 -0
  36. package/dist/tool-runs.d.ts.map +1 -0
  37. package/dist/tool-runs.js +70 -0
  38. package/dist/tool-runs.js.map +1 -0
  39. package/package.json +51 -0
  40. package/src/agents.ts +248 -0
  41. package/src/client.ts +837 -0
  42. package/src/errors.ts +67 -0
  43. package/src/fleet-report.ts +94 -0
  44. package/src/http.ts +198 -0
  45. package/src/index.ts +142 -0
  46. package/src/schemas.ts +1341 -0
  47. package/src/sse.ts +90 -0
  48. package/src/tool-runs.ts +103 -0
package/dist/errors.js ADDED
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Loud error types. Every failure surfaces — a failed request or a schema
3
+ * mismatch throws, so the UI can render a visible error state, never a silent
4
+ * empty render.
5
+ */
6
+ /** The skeleton returned `{ "error": "<message>" }` (or a non-2xx status). */
7
+ export class ApiError extends Error {
8
+ status;
9
+ /** The optional machine-readable `code` from the `{ error, code }` envelope. */
10
+ code;
11
+ constructor(message, status, code) {
12
+ super(message);
13
+ this.name = 'ApiError';
14
+ this.status = status;
15
+ this.code = code;
16
+ }
17
+ }
18
+ /** A 401 from any data route. The shell routes this back to `/login`. */
19
+ export class ApiUnauthorizedError extends ApiError {
20
+ constructor(message = 'unauthorized') {
21
+ super(message, 401);
22
+ this.name = 'ApiUnauthorizedError';
23
+ }
24
+ }
25
+ /** A duplicate answer / alias collision etc. (HTTP 409). */
26
+ export class ApiConflictError extends ApiError {
27
+ constructor(message) {
28
+ super(message, 409);
29
+ this.name = 'ApiConflictError';
30
+ }
31
+ }
32
+ /**
33
+ * A login attempt was REJECTED (bad credentials, expired invite/SSO code,
34
+ * rate-limited). Deliberately NOT an ApiUnauthorizedError: that type means "your
35
+ * stored session credential is dead" and routes to /login globally (the
36
+ * create-studio wiring); this one means "the credentials you just typed on the
37
+ * login page were refused" and renders inline, on the page the user is already
38
+ * on.
39
+ */
40
+ export class ApiLoginFailedError extends Error {
41
+ status;
42
+ constructor(message, status) {
43
+ super(message);
44
+ this.name = 'ApiLoginFailedError';
45
+ this.status = status;
46
+ }
47
+ }
48
+ /**
49
+ * The response body did not match its declared zod schema. This is a contract
50
+ * drift between the Studio and the skeleton — a loud, visible error, never a
51
+ * silently-coerced value.
52
+ */
53
+ export class ApiSchemaError extends Error {
54
+ endpoint;
55
+ issues;
56
+ constructor(endpoint, issues) {
57
+ super(`response from ${endpoint} did not match its expected schema`);
58
+ this.name = 'ApiSchemaError';
59
+ this.endpoint = endpoint;
60
+ this.issues = issues;
61
+ }
62
+ }
63
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,8EAA8E;AAC9E,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,MAAM,CAAS;IACxB,gFAAgF;IACvE,IAAI,CAAqB;IAClC,YAAY,OAAe,EAAE,MAAc,EAAE,IAAa;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,yEAAyE;AACzE,MAAM,OAAO,oBAAqB,SAAQ,QAAQ;IAChD,YAAY,OAAO,GAAG,cAAc;QAClC,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED,4DAA4D;AAC5D,MAAM,OAAO,gBAAiB,SAAQ,QAAQ;IAC5C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACnC,MAAM,CAAS;IACxB,YAAY,OAAe,EAAE,MAAc;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC9B,QAAQ,CAAS;IACjB,MAAM,CAAU;IACzB,YAAY,QAAgB,EAAE,MAAe;QAC3C,KAAK,CAAC,iBAAiB,QAAQ,oCAAoC,CAAC,CAAC;QACrE,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * The shared fleet-report handler — the single interpreter of a config mutation's
3
+ * fleet broadcast. Every mutation surface (connector, backup, mcp-config, env,
4
+ * extensions, single-MCP reload, fleet reload) routes its broadcast report through
5
+ * this one function so a FAILED propagation is never invisible: an unconfirmed
6
+ * sibling (`failed`/`missing`/`departed`/`timed_out`) or an unreachable bus becomes
7
+ * an explicit summary the UI renders as a loud, user-visible state — never a faked
8
+ * success on a departed/timed_out/failed origin.
9
+ *
10
+ * A mutation embeds its broadcast in one of two shapes: the mode-wrapped
11
+ * {@link FleetReportFanout} (`fanout` field) or the bare {@link FleetResult} (the
12
+ * fleet-reload and single-MCP-reload bodies). Both normalize to a
13
+ * {@link FleetReportSummary} through the functions here; the SDK's `FleetReport`
14
+ * component renders the summary.
15
+ */
16
+ import type { FleetOutcome, FleetReportFanout, FleetResult } from './schemas';
17
+ /** A per-origin propagation FAILURE: an origin that did not confirm `applied`. */
18
+ export type FleetFailureOutcome = Exclude<FleetOutcome, 'applied'>;
19
+ /** One origin that failed to converge, with the report's message for it. */
20
+ export interface FleetOriginFailure {
21
+ readonly origin: string;
22
+ readonly outcome: FleetFailureOutcome;
23
+ /** The failed apply's `error`, or the publisher's computed-outcome `detail`. */
24
+ readonly message: string | null;
25
+ }
26
+ /**
27
+ * The interpreted state of one broadcast.
28
+ * - `converged` — the bus was reached and every origin applied (or the change was
29
+ * local-only on a lone worker). The caller renders its own success; the report
30
+ * needs no loud state.
31
+ * - `degraded` — the bus was reached but one or more origins did not confirm; the
32
+ * named `failures` are stale/unreached siblings the operator must see.
33
+ * - `unreachable` — the bus itself could not be reached, so no sibling was told;
34
+ * `error` carries the transport failure.
35
+ */
36
+ export type FleetReportStatus = 'converged' | 'degraded' | 'unreachable';
37
+ export interface FleetReportSummary {
38
+ readonly status: FleetReportStatus;
39
+ /** The single-worker `local-only` note, when the broadcast reached no sibling. */
40
+ readonly note: string | null;
41
+ /** The origins that did not apply — empty unless `status` is `degraded`. */
42
+ readonly failures: readonly FleetOriginFailure[];
43
+ /** The bus-unreachable transport error — non-null only when `unreachable`. */
44
+ readonly error: string | null;
45
+ }
46
+ /** True when a summary describes a propagation the operator must be shown. */
47
+ export declare function isFleetReportFailure(summary: FleetReportSummary | null): boolean;
48
+ /**
49
+ * Interpret a bare {@link FleetResult} (the fleet-reload / single-MCP-reload body).
50
+ * An unreachable bus is `unreachable`; a reachable report with any non-`applied`
51
+ * origin is `degraded` (those origins named); otherwise `converged`.
52
+ */
53
+ export declare function summarizeFleetResult(result: FleetResult): FleetReportSummary;
54
+ /**
55
+ * Interpret a mutation's mode-wrapped {@link FleetReportFanout}. `null`/`undefined`
56
+ * (the response path mutated no manifest) yields `null` — there is nothing to report.
57
+ * A `local-only` fan-out is `converged` with its note; `fleet`/`unreachable` carry a
58
+ * bare {@link FleetResult} and defer to {@link summarizeFleetResult}.
59
+ */
60
+ export declare function summarizeFleetFanout(fanout: FleetReportFanout | null | undefined): FleetReportSummary | null;
61
+ //# sourceMappingURL=fleet-report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fleet-report.d.ts","sourceRoot":"","sources":["../src/fleet-report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE9E,kFAAkF;AAClF,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAEnE,4EAA4E;AAC5E,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;IACtC,gFAAgF;IAChF,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,UAAU,GAAG,aAAa,CAAC;AAEzE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,kFAAkF;IAClF,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,4EAA4E;IAC5E,QAAQ,CAAC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACjD,8EAA8E;IAC9E,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,8EAA8E;AAC9E,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,GAAG,OAAO,CAEhF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,kBAAkB,CAiB5E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,GAC3C,kBAAkB,GAAG,IAAI,CAM3B"}
@@ -0,0 +1,42 @@
1
+ /** True when a summary describes a propagation the operator must be shown. */
2
+ export function isFleetReportFailure(summary) {
3
+ return summary !== null && summary.status !== 'converged';
4
+ }
5
+ /**
6
+ * Interpret a bare {@link FleetResult} (the fleet-reload / single-MCP-reload body).
7
+ * An unreachable bus is `unreachable`; a reachable report with any non-`applied`
8
+ * origin is `degraded` (those origins named); otherwise `converged`.
9
+ */
10
+ export function summarizeFleetResult(result) {
11
+ if (!result.reachable) {
12
+ return { status: 'unreachable', note: null, failures: [], error: result.error };
13
+ }
14
+ const failures = result.results
15
+ .filter((entry) => entry.outcome !== 'applied')
16
+ .map((entry) => ({
17
+ origin: entry.origin,
18
+ outcome: entry.outcome,
19
+ message: entry.error ?? entry.detail ?? null,
20
+ }));
21
+ return {
22
+ status: failures.length > 0 ? 'degraded' : 'converged',
23
+ note: null,
24
+ failures,
25
+ error: null,
26
+ };
27
+ }
28
+ /**
29
+ * Interpret a mutation's mode-wrapped {@link FleetReportFanout}. `null`/`undefined`
30
+ * (the response path mutated no manifest) yields `null` — there is nothing to report.
31
+ * A `local-only` fan-out is `converged` with its note; `fleet`/`unreachable` carry a
32
+ * bare {@link FleetResult} and defer to {@link summarizeFleetResult}.
33
+ */
34
+ export function summarizeFleetFanout(fanout) {
35
+ if (fanout === null || fanout === undefined)
36
+ return null;
37
+ if (fanout.mode === 'local-only') {
38
+ return { status: 'converged', note: fanout.note, failures: [], error: null };
39
+ }
40
+ return summarizeFleetResult(fanout);
41
+ }
42
+ //# sourceMappingURL=fleet-report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fleet-report.js","sourceRoot":"","sources":["../src/fleet-report.ts"],"names":[],"mappings":"AAkDA,8EAA8E;AAC9E,MAAM,UAAU,oBAAoB,CAAC,OAAkC;IACrE,OAAO,OAAO,KAAK,IAAI,IAAI,OAAO,CAAC,MAAM,KAAK,WAAW,CAAC;AAC5D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAmB;IACtD,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;QACtB,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;IAClF,CAAC;IACD,MAAM,QAAQ,GAAyB,MAAM,CAAC,OAAO;SAClD,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC;SAC9C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACf,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,OAAO,EAAE,KAAK,CAAC,OAA8B;QAC7C,OAAO,EAAE,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,IAAI,IAAI;KAC7C,CAAC,CAAC,CAAC;IACN,OAAO;QACL,MAAM,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW;QACtD,IAAI,EAAE,IAAI;QACV,QAAQ;QACR,KAAK,EAAE,IAAI;KACZ,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAA4C;IAE5C,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACzD,IAAI,MAAM,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QACjC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAC/E,CAAC;IACD,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC"}
package/dist/http.d.ts ADDED
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The HTTP core: a fetch wrapper that attaches the auth header, unwraps the
3
+ * skeleton's `{ "data" }` / `{ "error" }` envelope, and validates the payload
4
+ * against a per-endpoint zod schema. Every failure throws.
5
+ *
6
+ * Same-origin by default: the skeleton serves the built SPA, so requests use
7
+ * relative `/api/...` URLs. `VITE_API_BASE_URL` can override for cross-origin
8
+ * deployments (documented as requiring CORS on the skeleton).
9
+ */
10
+ import type { z } from 'zod';
11
+ /** Supplies the current API key (in-memory or sessionStorage-backed) + base URL. */
12
+ export interface ApiConfig {
13
+ /** Absolute base (e.g. `https://host`) or '' for same-origin relative `/api`. */
14
+ readonly baseUrl?: string;
15
+ /** Returns the pre-provisioned API key, or null when unauthenticated. */
16
+ getToken: () => string | null;
17
+ /** Optional fetch impl (tests inject one; defaults to global fetch). */
18
+ fetch?: typeof fetch;
19
+ }
20
+ export interface RequestOptions {
21
+ readonly method?: string;
22
+ readonly body?: unknown;
23
+ readonly query?: Record<string, string | number | string[] | undefined>;
24
+ readonly signal?: AbortSignal;
25
+ }
26
+ /**
27
+ * Whether a value can never be faithfully transmitted as a single URL path
28
+ * segment. The browser's WHATWG URL parser removes dot-segments (`.`, `..`) from a
29
+ * relative request path before it is sent — even percent-encoded — and reads an
30
+ * empty or absolute (`/`-prefixed) value as a path boundary, so any of these would
31
+ * silently retarget the request at an unrelated same-origin route. The path
32
+ * encoders reject such a segment loudly at the client boundary instead of letting
33
+ * it leave; the server enforces the same relative-path rule.
34
+ */
35
+ export declare function isUnsafePathSegment(segment: string): boolean;
36
+ /**
37
+ * Encode a single id (string or number) as ONE URL path segment.
38
+ * `encodeURIComponent` already percent-encodes any interior `/`, so the value is
39
+ * guaranteed to stay a single segment (spaces, `#`, `?`, … all escape). An empty,
40
+ * `.`, `..`, or absolute id is REJECTED loudly rather than encoded (see
41
+ * `isUnsafePathSegment`): the browser would collapse it and retarget the request
42
+ * at a different route. A number stringifies to digits and is always safe.
43
+ */
44
+ export declare function encodeSegment(value: string | number): string;
45
+ /**
46
+ * Send a request and validate the unwrapped `data` against `schema`. The auth
47
+ * header is `X-Api-Key` (the skeleton's access-control middleware also accepts
48
+ * `Authorization: Bearer`; we use the dedicated key header).
49
+ */
50
+ export declare function apiRequest<S extends z.ZodTypeAny>(config: ApiConfig, path: string, schema: S, options?: RequestOptions): Promise<z.infer<S>>;
51
+ /**
52
+ * Fetch a plain-text endpoint (the skeleton's `/health` → `"OK"` and `/metrics`
53
+ * → Prometheus text). No `{ data }` envelope, no zod — the body is returned
54
+ * verbatim. Non-2xx still throws loudly.
55
+ */
56
+ export declare function apiText(config: ApiConfig, path: string, options?: RequestOptions): Promise<string>;
57
+ /**
58
+ * Fetch a raw file download (the skeleton's backup export and observability
59
+ * exports stream a document, NOT a `{ data }` envelope). Attaches the auth
60
+ * header, serializes a JSON body when one is given (POST exports), and returns
61
+ * the response as a `Blob`. Non-2xx throws loudly — no silent empty download.
62
+ */
63
+ export declare function apiDownload(config: ApiConfig, path: string, options?: RequestOptions): Promise<Blob>;
64
+ /** Pull the `error` message and optional machine `code` from the failure envelope. */
65
+ export declare function extractError(value: unknown): {
66
+ message: string | null;
67
+ code: string | undefined;
68
+ };
69
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAI7B,oFAAoF;AACpF,MAAM,WAAW,SAAS;IACxB,iFAAiF;IACjF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,yEAAyE;IACzE,QAAQ,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAC9B,wEAAwE;IACxE,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAGxB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;IACxE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAID;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE5D;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAQ5D;AAkBD;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,EACrD,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,CAAC,EACT,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAqCrB;AAED;;;;GAIG;AACH,wBAAsB,OAAO,CAC3B,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,MAAM,CAAC,CAejB;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAiBf;AAMD,sFAAsF;AACtF,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAOjG"}
package/dist/http.js ADDED
@@ -0,0 +1,152 @@
1
+ import { ApiConflictError, ApiError, ApiSchemaError, ApiUnauthorizedError } from './errors';
2
+ const JSON_HEADERS = { 'content-type': 'application/json' };
3
+ /**
4
+ * Whether a value can never be faithfully transmitted as a single URL path
5
+ * segment. The browser's WHATWG URL parser removes dot-segments (`.`, `..`) from a
6
+ * relative request path before it is sent — even percent-encoded — and reads an
7
+ * empty or absolute (`/`-prefixed) value as a path boundary, so any of these would
8
+ * silently retarget the request at an unrelated same-origin route. The path
9
+ * encoders reject such a segment loudly at the client boundary instead of letting
10
+ * it leave; the server enforces the same relative-path rule.
11
+ */
12
+ export function isUnsafePathSegment(segment) {
13
+ return segment === '' || segment === '.' || segment === '..' || segment.startsWith('/');
14
+ }
15
+ /**
16
+ * Encode a single id (string or number) as ONE URL path segment.
17
+ * `encodeURIComponent` already percent-encodes any interior `/`, so the value is
18
+ * guaranteed to stay a single segment (spaces, `#`, `?`, … all escape). An empty,
19
+ * `.`, `..`, or absolute id is REJECTED loudly rather than encoded (see
20
+ * `isUnsafePathSegment`): the browser would collapse it and retarget the request
21
+ * at a different route. A number stringifies to digits and is always safe.
22
+ */
23
+ export function encodeSegment(value) {
24
+ const segment = String(value);
25
+ if (isUnsafePathSegment(segment)) {
26
+ throw new Error(`URL path segment must not be empty, '.', '..', or absolute; received ${JSON.stringify(segment)}`);
27
+ }
28
+ return encodeURIComponent(segment);
29
+ }
30
+ function buildUrl(base, path, query) {
31
+ const url = `${base}${path}`;
32
+ if (!query)
33
+ return url;
34
+ const params = new URLSearchParams();
35
+ for (const [key, value] of Object.entries(query)) {
36
+ if (value === undefined)
37
+ continue;
38
+ if (Array.isArray(value)) {
39
+ for (const element of value)
40
+ params.append(key, element);
41
+ }
42
+ else {
43
+ params.set(key, String(value));
44
+ }
45
+ }
46
+ const qs = params.toString();
47
+ return qs ? `${url}?${qs}` : url;
48
+ }
49
+ /**
50
+ * Send a request and validate the unwrapped `data` against `schema`. The auth
51
+ * header is `X-Api-Key` (the skeleton's access-control middleware also accepts
52
+ * `Authorization: Bearer`; we use the dedicated key header).
53
+ */
54
+ export async function apiRequest(config, path, schema, options = {}) {
55
+ const doFetch = config.fetch ?? globalThis.fetch;
56
+ const token = config.getToken();
57
+ const headers = { ...JSON_HEADERS };
58
+ if (token)
59
+ headers['x-api-key'] = token;
60
+ const response = await doFetch(buildUrl(config.baseUrl ?? '', path, options.query), {
61
+ method: options.method ?? 'GET',
62
+ headers,
63
+ body: options.body === undefined ? undefined : JSON.stringify(options.body),
64
+ signal: options.signal,
65
+ });
66
+ if (response.status === 401)
67
+ throw new ApiUnauthorizedError();
68
+ let payload;
69
+ try {
70
+ payload = await response.json();
71
+ }
72
+ catch {
73
+ if (response.ok)
74
+ throw new ApiSchemaError(path, 'response was not valid JSON');
75
+ throw new ApiError(response.statusText || 'request failed', response.status);
76
+ }
77
+ if (!response.ok) {
78
+ const { message, code } = extractError(payload);
79
+ const text = message ?? (response.statusText || 'request failed');
80
+ if (response.status === 409)
81
+ throw new ApiConflictError(text);
82
+ throw new ApiError(text, response.status, code);
83
+ }
84
+ if (!isDataEnvelope(payload)) {
85
+ throw new ApiSchemaError(path, 'response was not a { data } envelope');
86
+ }
87
+ const parsed = schema.safeParse(payload.data);
88
+ if (!parsed.success)
89
+ throw new ApiSchemaError(path, parsed.error.issues);
90
+ return parsed.data;
91
+ }
92
+ /**
93
+ * Fetch a plain-text endpoint (the skeleton's `/health` → `"OK"` and `/metrics`
94
+ * → Prometheus text). No `{ data }` envelope, no zod — the body is returned
95
+ * verbatim. Non-2xx still throws loudly.
96
+ */
97
+ export async function apiText(config, path, options = {}) {
98
+ const doFetch = config.fetch ?? globalThis.fetch;
99
+ const token = config.getToken();
100
+ const headers = {};
101
+ if (token)
102
+ headers['x-api-key'] = token;
103
+ const response = await doFetch(buildUrl(config.baseUrl ?? '', path, options.query), {
104
+ method: options.method ?? 'GET',
105
+ headers,
106
+ signal: options.signal,
107
+ });
108
+ if (response.status === 401)
109
+ throw new ApiUnauthorizedError();
110
+ if (!response.ok)
111
+ throw new ApiError(response.statusText || 'request failed', response.status);
112
+ return response.text();
113
+ }
114
+ /**
115
+ * Fetch a raw file download (the skeleton's backup export and observability
116
+ * exports stream a document, NOT a `{ data }` envelope). Attaches the auth
117
+ * header, serializes a JSON body when one is given (POST exports), and returns
118
+ * the response as a `Blob`. Non-2xx throws loudly — no silent empty download.
119
+ */
120
+ export async function apiDownload(config, path, options = {}) {
121
+ const doFetch = config.fetch ?? globalThis.fetch;
122
+ const token = config.getToken();
123
+ const headers = {};
124
+ if (options.body !== undefined)
125
+ Object.assign(headers, JSON_HEADERS);
126
+ if (token)
127
+ headers['x-api-key'] = token;
128
+ const response = await doFetch(buildUrl(config.baseUrl ?? '', path, options.query), {
129
+ method: options.method ?? 'GET',
130
+ headers,
131
+ body: options.body === undefined ? undefined : JSON.stringify(options.body),
132
+ signal: options.signal,
133
+ });
134
+ if (response.status === 401)
135
+ throw new ApiUnauthorizedError();
136
+ if (!response.ok)
137
+ throw new ApiError(response.statusText || 'download failed', response.status);
138
+ return response.blob();
139
+ }
140
+ function isDataEnvelope(value) {
141
+ return typeof value === 'object' && value !== null && 'data' in value;
142
+ }
143
+ /** Pull the `error` message and optional machine `code` from the failure envelope. */
144
+ export function extractError(value) {
145
+ if (typeof value === 'object' && value !== null) {
146
+ const message = 'error' in value && typeof value.error === 'string' ? value.error : null;
147
+ const code = 'code' in value && typeof value.code === 'string' ? value.code : undefined;
148
+ return { message, code };
149
+ }
150
+ return { message: null, code: undefined };
151
+ }
152
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAqB5F,MAAM,YAAY,GAAG,EAAE,cAAc,EAAE,kBAAkB,EAAW,CAAC;AAErE;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,OAAO,OAAO,KAAK,EAAE,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAC1F,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,KAAsB;IAClD,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CACb,wEAAwE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAClG,CAAC;IACJ,CAAC;IACD,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY,EAAE,IAAY,EAAE,KAA+B;IAC3E,MAAM,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC;IAC7B,IAAI,CAAC,KA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C,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QACzF,MAAM,IAAI,GAAG,MAAM,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;QACxF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC3B,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @tai42/api-client — the typed transport for the tai-skeleton HTTP API.
3
+ *
4
+ * One zod schema per consumed endpoint; every response is
5
+ * validated and every failure throws. No caching of its own — server state
6
+ * lives in TanStack Query in the feature packages.
7
+ */
8
+ export { createApiClient, isSafeApiPath } from './client';
9
+ export type { ApiClient, RunToolArgs, StartConnectArgs, ApiKeyBody, ClaimLinkBody, ValidateConditionBody, TopicVerifierBody, AddUrlToScopeBody, PinRoutePublicBody, CreatePresetBody, SavePresetVersionBody, ValidatePresetBody, StorageUploadBody, MetricsQuery, RunsQuery, MarketplaceSearchQuery, MarketplaceInstallBody, MarketplaceUninstallBody, } from './client';
10
+ export type { ApiConfig, RequestOptions } from './http';
11
+ export { apiRequest, apiText, apiDownload } from './http';
12
+ export { ApiError, ApiUnauthorizedError, ApiConflictError, ApiLoginFailedError, ApiSchemaError, } from './errors';
13
+ export { SseFrameParser, readSseFrames } from './sse';
14
+ export type { SseFrame } from './sse';
15
+ export { parseAgentFrame, parseAgentTranscript, agentEventSchema } from './agents';
16
+ export type { AgentSummary, AgentEvent, UnknownAgentEvent, ParsedAgentEvent } from './agents';
17
+ export { toolRunStatus, toolRunSubmitResult, toolRunRecord, toolRunListItem, toolRunList, isTerminalRunStatus, } from './tool-runs';
18
+ export type { ToolRunStatus, ToolRunSubmitResult, ToolRunRecord, ToolRunListItem, SubmitToolRunArgs, } from './tool-runs';
19
+ export { summarizeFleetResult, summarizeFleetFanout, isFleetReportFailure } from './fleet-report';
20
+ export type { FleetReportSummary, FleetReportStatus, FleetOriginFailure, FleetFailureOutcome, } from './fleet-report';
21
+ export * as schemas from './schemas';
22
+ export type { ToolSchema, ToolMediaResult, ToolTagEntry, AuthRoute, PresetRecord, PresetDetail, PresetBody, PresetVersion, PresetRenamed, PresetReferees, PresetValidation, PresetVersionTags, PresetExtensionElement, PolicyBody, PolicyVersion, ValidateConditionResult, Extension, ToolExtensions, ToolExtensionsApplyResult, ProviderView, ConnectionView, OAuthCompleteResult, StudioPluginManifest, Interaction, InteractionAnswered, InteractionMediaItem, MediaKind, AnswerFormat, Channels, Notification, Notifications, HookParams, SettingsSchema, TokensPayload, LoginFormField, LoginMethod, LoginMethods, LoginResult, MeProjection, RouteEntry, PatternEntry, SubMcpEntry, ClaimLinkCreated, LogoutResult, AuthCapabilities, BackupDocument, BackupImportReport, ScheduleItem, StorageInfo, StorageResourceStat, BackendInfo, OriginKind, FleetOrigin, FleetWorkers, FleetOutcome, FleetOriginResult, FleetResult, FleetReloadResult, FleetReportFanout, ReloadConfigResult, McpReloadResult, KindStatus, DashboardMetrics, Run, RunSpan, RunTrace, MarketplaceItem, MarketplaceSearchRow, MarketplaceSearchPage, MarketplaceVersion, MarketplaceLatestVersion, MarketplaceAdvisory, MarketplacePluginDetail, MarketplaceInstalledPlugin, MarketplaceInstallResult, MarketplaceUninstallResult, } from './schemas';
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC1D,YAAY,EACV,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,gBAA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BAAsB,EACtB,UAAU,EACV,aAAa,EACb,uBAAuB,EACvB,SAAS,EACT,cAAc,EACd,yBAAyB,EACzB,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,SAAS,EACT,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,UAAU,EACV,cAAc,EACd,aAAa,EACb,cAAc,EACd,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,UAAU,EACV,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,GAAG,EACH,OAAO,EACP,QAAQ,EACR,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,EACxB,mBAAmB,EACnB,uBAAuB,EACvB,0BAA0B,EAC1B,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,WAAW,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @tai42/api-client — the typed transport for the tai-skeleton HTTP API.
3
+ *
4
+ * One zod schema per consumed endpoint; every response is
5
+ * validated and every failure throws. No caching of its own — server state
6
+ * lives in TanStack Query in the feature packages.
7
+ */
8
+ export { createApiClient, isSafeApiPath } from './client';
9
+ export { apiRequest, apiText, apiDownload } from './http';
10
+ export { ApiError, ApiUnauthorizedError, ApiConflictError, ApiLoginFailedError, ApiSchemaError, } from './errors';
11
+ export { SseFrameParser, readSseFrames } from './sse';
12
+ export { parseAgentFrame, parseAgentTranscript, agentEventSchema } from './agents';
13
+ export { toolRunStatus, toolRunSubmitResult, toolRunRecord, toolRunListItem, toolRunList, isTerminalRunStatus, } from './tool-runs';
14
+ export { summarizeFleetResult, summarizeFleetFanout, isFleetReportFailure } from './fleet-report';
15
+ export * as schemas from './schemas';
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAsB1D,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAC1D,OAAO,EACL,QAAQ,EACR,oBAAoB,EACpB,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,GACf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAEnF,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,WAAW,EACX,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAQrB,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAOlG,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC"}