@jini-ai/http-kit 0.2.1
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/LICENSE +201 -0
- package/README.md +107 -0
- package/dist/active-context.d.ts +99 -0
- package/dist/active-context.d.ts.map +1 -0
- package/dist/active-context.js +77 -0
- package/dist/active-context.js.map +1 -0
- package/dist/adapter.d.ts +36 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +92 -0
- package/dist/adapter.js.map +1 -0
- package/dist/agents.d.ts +55 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +23 -0
- package/dist/agents.js.map +1 -0
- package/dist/api-security-middleware.d.ts +146 -0
- package/dist/api-security-middleware.d.ts.map +1 -0
- package/dist/api-security-middleware.js +276 -0
- package/dist/api-security-middleware.js.map +1 -0
- package/dist/attachments.d.ts +317 -0
- package/dist/attachments.d.ts.map +1 -0
- package/dist/attachments.js +664 -0
- package/dist/attachments.js.map +1 -0
- package/dist/cancel-owned-runs.d.ts +44 -0
- package/dist/cancel-owned-runs.d.ts.map +1 -0
- package/dist/cancel-owned-runs.js +35 -0
- package/dist/cancel-owned-runs.js.map +1 -0
- package/dist/compat.d.ts +22 -0
- package/dist/compat.d.ts.map +1 -0
- package/dist/compat.js +17 -0
- package/dist/compat.js.map +1 -0
- package/dist/component-catalog.d.ts +74 -0
- package/dist/component-catalog.d.ts.map +1 -0
- package/dist/component-catalog.js +74 -0
- package/dist/component-catalog.js.map +1 -0
- package/dist/connectors.d.ts +165 -0
- package/dist/connectors.d.ts.map +1 -0
- package/dist/connectors.js +474 -0
- package/dist/connectors.js.map +1 -0
- package/dist/daemon-status.d.ts +72 -0
- package/dist/daemon-status.d.ts.map +1 -0
- package/dist/daemon-status.js +60 -0
- package/dist/daemon-status.js.map +1 -0
- package/dist/db-ops.d.ts +116 -0
- package/dist/db-ops.d.ts.map +1 -0
- package/dist/db-ops.js +191 -0
- package/dist/db-ops.js.map +1 -0
- package/dist/delegated-tools.d.ts +46 -0
- package/dist/delegated-tools.d.ts.map +1 -0
- package/dist/delegated-tools.js +155 -0
- package/dist/delegated-tools.js.map +1 -0
- package/dist/express/run-stream.d.ts +15 -0
- package/dist/express/run-stream.d.ts.map +1 -0
- package/dist/express/run-stream.js +11 -0
- package/dist/express/run-stream.js.map +1 -0
- package/dist/express-index.d.ts +32 -0
- package/dist/express-index.d.ts.map +1 -0
- package/dist/express-index.js +14 -0
- package/dist/express-index.js.map +1 -0
- package/dist/fastify/adapter.d.ts +31 -0
- package/dist/fastify/adapter.d.ts.map +1 -0
- package/dist/fastify/adapter.js +64 -0
- package/dist/fastify/adapter.js.map +1 -0
- package/dist/fastify/agents.d.ts +13 -0
- package/dist/fastify/agents.d.ts.map +1 -0
- package/dist/fastify/agents.js +7 -0
- package/dist/fastify/agents.js.map +1 -0
- package/dist/fastify/api-security-middleware.d.ts +64 -0
- package/dist/fastify/api-security-middleware.d.ts.map +1 -0
- package/dist/fastify/api-security-middleware.js +139 -0
- package/dist/fastify/api-security-middleware.js.map +1 -0
- package/dist/fastify/compat.d.ts +22 -0
- package/dist/fastify/compat.d.ts.map +1 -0
- package/dist/fastify/compat.js +16 -0
- package/dist/fastify/compat.js.map +1 -0
- package/dist/fastify/daemon-status.d.ts +22 -0
- package/dist/fastify/daemon-status.d.ts.map +1 -0
- package/dist/fastify/daemon-status.js +9 -0
- package/dist/fastify/daemon-status.js.map +1 -0
- package/dist/fastify/host-tools.d.ts +13 -0
- package/dist/fastify/host-tools.d.ts.map +1 -0
- package/dist/fastify/host-tools.js +8 -0
- package/dist/fastify/host-tools.js.map +1 -0
- package/dist/fastify/index.d.ts +36 -0
- package/dist/fastify/index.d.ts.map +1 -0
- package/dist/fastify/index.js +18 -0
- package/dist/fastify/index.js.map +1 -0
- package/dist/fastify/local-daemon-request.d.ts +43 -0
- package/dist/fastify/local-daemon-request.d.ts.map +1 -0
- package/dist/fastify/local-daemon-request.js +155 -0
- package/dist/fastify/local-daemon-request.js.map +1 -0
- package/dist/fastify/origin.d.ts +21 -0
- package/dist/fastify/origin.d.ts.map +1 -0
- package/dist/fastify/origin.js +14 -0
- package/dist/fastify/origin.js.map +1 -0
- package/dist/fastify/request.d.ts +20 -0
- package/dist/fastify/request.d.ts.map +1 -0
- package/dist/fastify/request.js +25 -0
- package/dist/fastify/request.js.map +1 -0
- package/dist/fastify/response.d.ts +20 -0
- package/dist/fastify/response.d.ts.map +1 -0
- package/dist/fastify/response.js +41 -0
- package/dist/fastify/response.js.map +1 -0
- package/dist/fastify/route-registration-guard.d.ts +70 -0
- package/dist/fastify/route-registration-guard.d.ts.map +1 -0
- package/dist/fastify/route-registration-guard.js +69 -0
- package/dist/fastify/route-registration-guard.js.map +1 -0
- package/dist/fastify/run-stream.d.ts +18 -0
- package/dist/fastify/run-stream.d.ts.map +1 -0
- package/dist/fastify/run-stream.js +10 -0
- package/dist/fastify/run-stream.js.map +1 -0
- package/dist/fastify/runs.d.ts +17 -0
- package/dist/fastify/runs.d.ts.map +1 -0
- package/dist/fastify/runs.js +33 -0
- package/dist/fastify/runs.js.map +1 -0
- package/dist/frontend-control.d.ts +131 -0
- package/dist/frontend-control.d.ts.map +1 -0
- package/dist/frontend-control.js +77 -0
- package/dist/frontend-control.js.map +1 -0
- package/dist/frontend-sessions.d.ts +100 -0
- package/dist/frontend-sessions.d.ts.map +1 -0
- package/dist/frontend-sessions.js +180 -0
- package/dist/frontend-sessions.js.map +1 -0
- package/dist/health.d.ts +91 -0
- package/dist/health.d.ts.map +1 -0
- package/dist/health.js +53 -0
- package/dist/health.js.map +1 -0
- package/dist/host-tools.d.ts +174 -0
- package/dist/host-tools.d.ts.map +1 -0
- package/dist/host-tools.js +338 -0
- package/dist/host-tools.js.map +1 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/local-daemon-request.d.ts +44 -0
- package/dist/local-daemon-request.d.ts.map +1 -0
- package/dist/local-daemon-request.js +145 -0
- package/dist/local-daemon-request.js.map +1 -0
- package/dist/media.d.ts +131 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +352 -0
- package/dist/media.js.map +1 -0
- package/dist/memory.d.ts +230 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +331 -0
- package/dist/memory.js.map +1 -0
- package/dist/model-proxy.d.ts +45 -0
- package/dist/model-proxy.d.ts.map +1 -0
- package/dist/model-proxy.js +619 -0
- package/dist/model-proxy.js.map +1 -0
- package/dist/origin-validation.d.ts +64 -0
- package/dist/origin-validation.d.ts.map +1 -0
- package/dist/origin-validation.js +226 -0
- package/dist/origin-validation.js.map +1 -0
- package/dist/origin.d.ts +32 -0
- package/dist/origin.d.ts.map +1 -0
- package/dist/origin.js +14 -0
- package/dist/origin.js.map +1 -0
- package/dist/pack-http.d.ts +30 -0
- package/dist/pack-http.d.ts.map +1 -0
- package/dist/pack-http.js +12 -0
- package/dist/pack-http.js.map +1 -0
- package/dist/raw-sse.d.ts +44 -0
- package/dist/raw-sse.d.ts.map +1 -0
- package/dist/raw-sse.js +93 -0
- package/dist/raw-sse.js.map +1 -0
- package/dist/remote-run-events.d.ts +66 -0
- package/dist/remote-run-events.d.ts.map +1 -0
- package/dist/remote-run-events.js +230 -0
- package/dist/remote-run-events.js.map +1 -0
- package/dist/request.d.ts +19 -0
- package/dist/request.d.ts.map +1 -0
- package/dist/request.js +25 -0
- package/dist/request.js.map +1 -0
- package/dist/research.d.ts +42 -0
- package/dist/research.d.ts.map +1 -0
- package/dist/research.js +316 -0
- package/dist/research.js.map +1 -0
- package/dist/response.d.ts +14 -0
- package/dist/response.d.ts.map +1 -0
- package/dist/response.js +45 -0
- package/dist/response.js.map +1 -0
- package/dist/route-manifest.d.ts +31 -0
- package/dist/route-manifest.d.ts.map +1 -0
- package/dist/route-manifest.js +103 -0
- package/dist/route-manifest.js.map +1 -0
- package/dist/route-registration-guard.d.ts +65 -0
- package/dist/route-registration-guard.d.ts.map +1 -0
- package/dist/route-registration-guard.js +71 -0
- package/dist/route-registration-guard.js.map +1 -0
- package/dist/routines.d.ts +114 -0
- package/dist/routines.d.ts.map +1 -0
- package/dist/routines.js +320 -0
- package/dist/routines.js.map +1 -0
- package/dist/run-stream.d.ts +60 -0
- package/dist/run-stream.d.ts.map +1 -0
- package/dist/run-stream.js +108 -0
- package/dist/run-stream.js.map +1 -0
- package/dist/runs.d.ts +79 -0
- package/dist/runs.d.ts.map +1 -0
- package/dist/runs.js +232 -0
- package/dist/runs.js.map +1 -0
- package/dist/sse.d.ts +139 -0
- package/dist/sse.d.ts.map +1 -0
- package/dist/sse.js +157 -0
- package/dist/sse.js.map +1 -0
- package/dist/terminals.d.ts +125 -0
- package/dist/terminals.d.ts.map +1 -0
- package/dist/terminals.js +349 -0
- package/dist/terminals.js.map +1 -0
- package/dist/tool-catalog.d.ts +68 -0
- package/dist/tool-catalog.d.ts.map +1 -0
- package/dist/tool-catalog.js +68 -0
- package/dist/tool-catalog.js.map +1 -0
- package/dist/types.d.ts +58 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/workspace-root.d.ts +69 -0
- package/dist/workspace-root.d.ts.map +1 -0
- package/dist/workspace-root.js +63 -0
- package/dist/workspace-root.js.map +1 -0
- package/dist/xai.d.ts +86 -0
- package/dist/xai.d.ts.map +1 -0
- package/dist/xai.js +668 -0
- package/dist/xai.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminals.js","sourceRoot":"","sources":["../src/terminals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AASzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,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AO;QACT,CAAC;QACD,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;YAC1B,YAAY,GAAG,IAAI,CAAC;QACtB,CAAC;QACD,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,WAAW,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC;AAED,4JAA4J;AAC5J,MAAM,UAAU,sBAAsB,CAAC,GAAY,EAAE,IAAuB,EAAE,OAAuB;IACnG,cAAc,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,cAAc,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACxD,cAAc,CAAC,GAAG,EAAE,kBAAkB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACvD,cAAc,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACxD,cAAc,CAAC,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,cAAc,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACxD,2BAA2B,CAAC,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module tool-catalog
|
|
3
|
+
*
|
|
4
|
+
* `GET /api/tools/search` / `GET /api/tools/:id` — the discovery half of
|
|
5
|
+
* `ai-control-plane.md` §29 / `PROP-tool-catalog-discovery-2026-07-26.md` §6.1's staged verbs
|
|
6
|
+
* (`search_tools`/`describe_tool`), v0 scope: no principal scoping, no versioning, no schema
|
|
7
|
+
* narrowing. `@jini-ai/mcp`'s `search_tools`/`describe_tool` tool defs proxy these two routes,
|
|
8
|
+
* exactly mirroring how `run-tools.ts`'s tools proxy `runs.ts`.
|
|
9
|
+
*
|
|
10
|
+
* This module does not depend on `@jini-ai/sqlite` or `better-sqlite3` — `ToolCatalogQuery` is a
|
|
11
|
+
* plain injected interface, structurally compatible with `@jini-ai/sqlite`'s
|
|
12
|
+
* `searchToolCatalog`/`getToolCatalogEntry` so a caller wires those in with zero adapter code,
|
|
13
|
+
* matching `db-ops.ts`'s established convention.
|
|
14
|
+
*
|
|
15
|
+
* **Deliberately not routed through `ToolExecutor`.** Unlike `db-ops.ts`'s three tools, nothing
|
|
16
|
+
* here executes a handler or has a side effect — it is a read over a snapshot table. `PROP` §6.3:
|
|
17
|
+
* "discovery is not permission... the catalog is never consulted for authorization." The actual
|
|
18
|
+
* gate is still `ToolExecutor`, reached only via `execute_delegated_tool`
|
|
19
|
+
* (`packages/daemon/src/delegated-tool-bridge.ts`) — finding a tool id here grants nothing.
|
|
20
|
+
*/
|
|
21
|
+
import type { Express } from 'express';
|
|
22
|
+
import { type AdapterContext } from './adapter.js';
|
|
23
|
+
export interface ToolCatalogSearchHit {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly description: string;
|
|
26
|
+
readonly source: string;
|
|
27
|
+
readonly score: number;
|
|
28
|
+
}
|
|
29
|
+
export interface ToolCatalogEntry {
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly description: string;
|
|
32
|
+
readonly inputSchema?: unknown;
|
|
33
|
+
readonly source: string;
|
|
34
|
+
}
|
|
35
|
+
/** Structurally identical to `@jini-ai/sqlite`'s `searchToolCatalog`/`getToolCatalogEntry` — defined locally so this package incurs no `better-sqlite3` dependency. */
|
|
36
|
+
export interface ToolCatalogQuery {
|
|
37
|
+
readonly search: (query: string, limit?: number) => readonly ToolCatalogSearchHit[];
|
|
38
|
+
readonly describe: (id: string) => ToolCatalogEntry | null;
|
|
39
|
+
}
|
|
40
|
+
export interface ToolCatalogHttpDeps {
|
|
41
|
+
readonly catalog: ToolCatalogQuery;
|
|
42
|
+
}
|
|
43
|
+
/** `GET /api/tools/search?q=...&limit=...` — ranked candidates only, never schemas (`PROP` §6.1). */
|
|
44
|
+
export declare const toolCatalogSearchRoute: import("./types.js").JsonRouteSpec<{
|
|
45
|
+
query: string;
|
|
46
|
+
limit: number;
|
|
47
|
+
}, {
|
|
48
|
+
hits: readonly ToolCatalogSearchHit[];
|
|
49
|
+
}, ToolCatalogHttpDeps>;
|
|
50
|
+
/**
|
|
51
|
+
* `GET /api/tools/:id` — full descriptor (schema included), paid for only once a candidate survives
|
|
52
|
+
* search.
|
|
53
|
+
*
|
|
54
|
+
* An unknown tool id is **404 `NOT_FOUND`**, not 400. A well-formed request naming a catalog entry
|
|
55
|
+
* that does not exist is a missing resource, not a malformed request — and the three sibling route
|
|
56
|
+
* families in this package that have the same "the referenced thing isn't there" case
|
|
57
|
+
* (`memory.ts`'s `memory not found`, `routines.ts`'s `routine not found`, `media.ts`'s
|
|
58
|
+
* `media task not found`) all already answer 404. This route answered 400 until 2026-07-29 purely
|
|
59
|
+
* because it reached for `validationError` — the same helper its `parse` step uses, where 400 *is*
|
|
60
|
+
* correct — so a caller could not distinguish "you sent a bad request" from "that tool is gone".
|
|
61
|
+
* `parse` failures here (a missing `:id` segment) are still 400.
|
|
62
|
+
*/
|
|
63
|
+
export declare const toolCatalogDescribeRoute: import("./types.js").JsonRouteSpec<{
|
|
64
|
+
id: string;
|
|
65
|
+
}, ToolCatalogEntry, ToolCatalogHttpDeps>;
|
|
66
|
+
/** Mounts both tool-catalog routes on `app`. A pack's `http(app, services)` calls this directly. */
|
|
67
|
+
export declare function registerToolCatalogRoutes(app: Express, deps: ToolCatalogHttpDeps, adapter: AdapterContext): void;
|
|
68
|
+
//# sourceMappingURL=tool-catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-catalog.d.ts","sourceRoot":"","sources":["../src/tool-catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAmC,KAAK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ationError } from './request.js';
|
|
4
|
+
import { err, ok } from './types.js';
|
|
5
|
+
const MAX_SEARCH_LIMIT = 25;
|
|
6
|
+
const DEFAULT_SEARCH_LIMIT = 10;
|
|
7
|
+
function parseSearchInput(input) {
|
|
8
|
+
const rawQuery = input.query.q;
|
|
9
|
+
if (typeof rawQuery !== 'string' || rawQuery.trim().length === 0) {
|
|
10
|
+
return err(validationError('q (search query) is required and must be a non-empty string'));
|
|
11
|
+
}
|
|
12
|
+
const rawLimit = input.query.limit;
|
|
13
|
+
if (rawLimit === undefined)
|
|
14
|
+
return ok({ query: rawQuery, limit: DEFAULT_SEARCH_LIMIT });
|
|
15
|
+
if (typeof rawLimit !== 'string' || !/^[0-9]+$/.test(rawLimit)) {
|
|
16
|
+
return err(validationError('limit must be a single positive-integer query-string value when provided'));
|
|
17
|
+
}
|
|
18
|
+
const parsed = Number(rawLimit);
|
|
19
|
+
if (parsed < 1)
|
|
20
|
+
return err(validationError('limit must be at least 1'));
|
|
21
|
+
return ok({ query: rawQuery, limit: Math.min(parsed, MAX_SEARCH_LIMIT) });
|
|
22
|
+
}
|
|
23
|
+
/** `GET /api/tools/search?q=...&limit=...` — ranked candidates only, never schemas (`PROP` §6.1). */
|
|
24
|
+
export const toolCatalogSearchRoute = defineJsonRoute({
|
|
25
|
+
method: 'get',
|
|
26
|
+
path: '/api/tools/search',
|
|
27
|
+
requireSameOrigin: true,
|
|
28
|
+
parse: parseSearchInput,
|
|
29
|
+
handle: (input, deps) => ok({ hits: deps.catalog.search(input.query, input.limit) }),
|
|
30
|
+
});
|
|
31
|
+
function parseDescribeInput(input) {
|
|
32
|
+
const id = input.params.id;
|
|
33
|
+
if (typeof id !== 'string' || id.length === 0) {
|
|
34
|
+
return err(validationError('id path segment is required'));
|
|
35
|
+
}
|
|
36
|
+
return ok({ id });
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* `GET /api/tools/:id` — full descriptor (schema included), paid for only once a candidate survives
|
|
40
|
+
* search.
|
|
41
|
+
*
|
|
42
|
+
* An unknown tool id is **404 `NOT_FOUND`**, not 400. A well-formed request naming a catalog entry
|
|
43
|
+
* that does not exist is a missing resource, not a malformed request — and the three sibling route
|
|
44
|
+
* families in this package that have the same "the referenced thing isn't there" case
|
|
45
|
+
* (`memory.ts`'s `memory not found`, `routines.ts`'s `routine not found`, `media.ts`'s
|
|
46
|
+
* `media task not found`) all already answer 404. This route answered 400 until 2026-07-29 purely
|
|
47
|
+
* because it reached for `validationError` — the same helper its `parse` step uses, where 400 *is*
|
|
48
|
+
* correct — so a caller could not distinguish "you sent a bad request" from "that tool is gone".
|
|
49
|
+
* `parse` failures here (a missing `:id` segment) are still 400.
|
|
50
|
+
*/
|
|
51
|
+
export const toolCatalogDescribeRoute = defineJsonRoute({
|
|
52
|
+
method: 'get',
|
|
53
|
+
path: '/api/tools/:id',
|
|
54
|
+
requireSameOrigin: true,
|
|
55
|
+
parse: parseDescribeInput,
|
|
56
|
+
handle: (input, deps) => {
|
|
57
|
+
const entry = deps.catalog.describe(input.id);
|
|
58
|
+
if (!entry)
|
|
59
|
+
return err(createApiError('NOT_FOUND', `no catalog entry for tool id "${input.id}"`));
|
|
60
|
+
return ok(entry);
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
/** Mounts both tool-catalog routes on `app`. A pack's `http(app, services)` calls this directly. */
|
|
64
|
+
export function registerToolCatalogRoutes(app, deps, adapter) {
|
|
65
|
+
mountJsonRoute(app, toolCatalogSearchRoute, deps, adapter);
|
|
66
|
+
mountJsonRoute(app, toolCatalogDescribeRoute, deps, adapter);
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=tool-catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-catalog.js","sourceRoot":"","sources":["../src/tool-catalog.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAuB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AE,sBAAsB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3D,cAAc,CAAC,GAAG,EAAE,wBAAwB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAC/D,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Foundational layer: the shared `Result` success/failure envelope and the route-spec shape
|
|
3
|
+
* (`JsonRouteSpec`, `InputParser`, `Handler`, `HttpMethod`, `RouteInputContext`) every other
|
|
4
|
+
* module in this package depends on.
|
|
5
|
+
*/
|
|
6
|
+
import type { ApiError } from '@jini-ai/protocol';
|
|
7
|
+
/**
|
|
8
|
+
* A discriminated success/failure envelope used throughout the module in place of throwing.
|
|
9
|
+
* Route parsing, handling, and origin checks all resolve to a `Result` so the Adapter can fold
|
|
10
|
+
* every failure mode into one error-handling pipeline.
|
|
11
|
+
*/
|
|
12
|
+
export type Result<T, E = ApiError> = {
|
|
13
|
+
ok: true;
|
|
14
|
+
value: T;
|
|
15
|
+
} | {
|
|
16
|
+
ok: false;
|
|
17
|
+
error: E;
|
|
18
|
+
};
|
|
19
|
+
/** Builds a successful `Result` carrying `value`. */
|
|
20
|
+
export declare const ok: <T, E = ApiError>(value: T) => Result<T, E>;
|
|
21
|
+
/** Builds a failed `Result` carrying `error`. */
|
|
22
|
+
export declare const err: <T = never, E = ApiError>(error: E) => Result<T, E>;
|
|
23
|
+
/**
|
|
24
|
+
* The normalized shape of a raw HTTP request handed to a route's `parse` function: body, query,
|
|
25
|
+
* and params, decoupled from any framework `Request` type so parsers are unit-testable without
|
|
26
|
+
* a real server.
|
|
27
|
+
*/
|
|
28
|
+
export interface RouteInputContext {
|
|
29
|
+
body: unknown;
|
|
30
|
+
query: Record<string, unknown>;
|
|
31
|
+
params: Record<string, string>;
|
|
32
|
+
}
|
|
33
|
+
/** Parses a `RouteInputContext` into a typed `Input`, or fails with an `ApiError`. */
|
|
34
|
+
export type InputParser<Input> = (raw: RouteInputContext) => Result<Input>;
|
|
35
|
+
/**
|
|
36
|
+
* Handles a parsed `Input` (plus injected `Deps`) and produces a `Result<Output>`.
|
|
37
|
+
*
|
|
38
|
+
* `signal` is optional and additive: it aborts if the underlying HTTP request's connection drops
|
|
39
|
+
* before the Adapter has written a response (see `mountJsonRoute` in `adapter.ts`) — a route with
|
|
40
|
+
* no long-running or delegated work has no reason to read it, and every existing 2-arg handler
|
|
41
|
+
* stays a valid `Handler` unchanged (TS accepts a callback that ignores trailing parameters).
|
|
42
|
+
*/
|
|
43
|
+
export type Handler<Input, Output, Deps> = (input: Input, deps: Deps, signal?: AbortSignal) => Promise<Result<Output>> | Result<Output>;
|
|
44
|
+
/** HTTP verbs the Adapter can mount a `JsonRouteSpec` under. */
|
|
45
|
+
export type HttpMethod = 'get' | 'post' | 'put' | 'delete' | 'patch';
|
|
46
|
+
/**
|
|
47
|
+
* Declarative description of one JSON route: how to parse input, how to handle it, and whether
|
|
48
|
+
* it requires a same-origin request. Consumed by `mountJsonRoute` in `adapter.ts`.
|
|
49
|
+
*/
|
|
50
|
+
export interface JsonRouteSpec<Input, Output, Deps> {
|
|
51
|
+
method: HttpMethod;
|
|
52
|
+
path: string;
|
|
53
|
+
requireSameOrigin?: boolean;
|
|
54
|
+
parse: InputParser<Input>;
|
|
55
|
+
handle: Handler<Input, Output, Deps>;
|
|
56
|
+
successStatus?: number;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;;GAIG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,QAAQ,IAAI;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAA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E,WAAW,CAAC,KAAK,CAAC,CAAC;IAC1B,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IACrC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAcA,qDAAqD;AACrD,MAAM,CAAC,MAAM,EAAE,GAAG,CAAkB,KAAQ,EAAgB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AACrF,iDAAiD;AACjD,MAAM,CAAC,MAAM,GAAG,GAAG,CAA0B,KAAQ,EAAgB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic, host-injectable "workspace root" resolution port.
|
|
3
|
+
*
|
|
4
|
+
* Several OD route packs need the same thing at the boundary: "given some
|
|
5
|
+
* opaque resource reference, what filesystem directory does a spawned
|
|
6
|
+
* process or launched editor run in?" OD answers that with
|
|
7
|
+
* `ctx.projectStore.getProject` + `ctx.projectFiles.resolveProjectDir` — a
|
|
8
|
+
* project-store lookup plus a metadata-driven directory resolver, both
|
|
9
|
+
* product-specific (see `packages/http/source-map.md`'s routes-classification
|
|
10
|
+
* table, rows `#11 terminal.ts` and `#23 host-tools.ts`, both of which name
|
|
11
|
+
* exactly this dependency as the reason `POST /api/projects/:id/open-in` and
|
|
12
|
+
* the interactive-terminal spawn route were not ported earlier). The kernel
|
|
13
|
+
* has no concept of "project," so it cannot hardcode that lookup — but it
|
|
14
|
+
* also must not silently invent a directory (guessing `process.cwd()` or an
|
|
15
|
+
* OS temp dir would let one request's resource reference leak into an
|
|
16
|
+
* unrelated working directory).
|
|
17
|
+
*
|
|
18
|
+
* Follows the same explicit-injection, conservative-default shape this repo
|
|
19
|
+
* already established for `@jini-ai/cli`'s `resolveDaemonUrl`
|
|
20
|
+
* (`packages/cli/src/daemon-url.ts`): a host supplies a resolver callback; the
|
|
21
|
+
* built-in default resolves nothing and the resolution function throws
|
|
22
|
+
* rather than guessing. It also mirrors `active-context.ts`'s
|
|
23
|
+
* `resolveResource` DI shape (a caller-supplied lookup replacing OD's
|
|
24
|
+
* `getProject`) and its `resourceRef`/`detail` field naming.
|
|
25
|
+
*/
|
|
26
|
+
/** What a route needs resolved: an opaque resource reference, plus an optional sub-locator within it (e.g. a specific file), matching `active-context.ts`'s `resourceRef`/`detail` naming. */
|
|
27
|
+
export interface WorkspaceRootRequest {
|
|
28
|
+
readonly resourceRef: string;
|
|
29
|
+
readonly detail?: string | null;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Host-supplied lookup: given a {@link WorkspaceRootRequest}, return the
|
|
33
|
+
* absolute filesystem path a process/editor should be rooted at, or a
|
|
34
|
+
* nullish value when this host has no directory for that resource (an
|
|
35
|
+
* unknown id, a resource with no on-disk representation, or a caller not
|
|
36
|
+
* permitted to resolve it — the resolver decides, the kernel does not).
|
|
37
|
+
*/
|
|
38
|
+
export type WorkspaceRootResolver = (request: WorkspaceRootRequest) => string | null | undefined | Promise<string | null | undefined>;
|
|
39
|
+
/** Thrown by {@link resolveWorkspaceRoot} when no root could be resolved — the caller has nothing safe to spawn a process or open an editor against. */
|
|
40
|
+
export declare class WorkspaceRootDeniedError extends Error {
|
|
41
|
+
readonly resourceRef: string;
|
|
42
|
+
constructor(resourceRef: string, reason?: string);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The built-in, zero-config default resolver: resolves nothing, for every
|
|
46
|
+
* request. A host that never wires its own resolver gets a hard denial from
|
|
47
|
+
* every call site that needs a workspace root — never a guessed path. This
|
|
48
|
+
* is the "conservative default that denies rather than guessing" half of
|
|
49
|
+
* the port, matching the task's explicit precedent
|
|
50
|
+
* (`ToolPolicy`/`resolveDaemonUrl`).
|
|
51
|
+
*/
|
|
52
|
+
export declare const denyAllWorkspaceRoots: WorkspaceRootResolver;
|
|
53
|
+
export interface ResolveWorkspaceRootOptions {
|
|
54
|
+
/** Defaults to {@link denyAllWorkspaceRoots} — a host must explicitly opt in to resolving real paths. */
|
|
55
|
+
readonly resolver?: WorkspaceRootResolver;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Resolves a workspace root for `request` via `options.resolver`.
|
|
59
|
+
*
|
|
60
|
+
* @throws {WorkspaceRootDeniedError} If the resolver is omitted, or returns
|
|
61
|
+
* `null`/`undefined`/an empty string. This function never falls back to a
|
|
62
|
+
* guessed path (`process.cwd()`, an OS temp dir, `resourceRef` itself
|
|
63
|
+
* treated as a path) — a route that cannot resolve a real root has nothing
|
|
64
|
+
* safe to act on.
|
|
65
|
+
* @complexity O(1) plus the injected resolver's own cost.
|
|
66
|
+
* @overallScore 100/100
|
|
67
|
+
*/
|
|
68
|
+
export declare function resolveWorkspaceRoot(request: WorkspaceRootRequest, options?: ResolveWorkspaceRootOptions): Promise<string>;
|
|
69
|
+
//# sourceMappingURL=workspace-root.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-root.d.ts","sourceRoot":"","sources":["../src/workspace-root.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,8LAA8L;AAC9L,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAClC,OAAO,EAAE,oBAAoB,KAC1B,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAEpE,wJAAwJ;AACxJ,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;gBAEjB,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAKjD;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,qBAAqB,EAAE,qBAAkC,CAAC;AAEvE,MAAM,WAAW,2BAA2B;IAC1C,yGAAyG;IACzG,QAAQ,CAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAC3C;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,oBAAoB,EAC7B,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,MAAM,CAAC,CAOjB"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic, host-injectable "workspace root" resolution port.
|
|
3
|
+
*
|
|
4
|
+
* Several OD route packs need the same thing at the boundary: "given some
|
|
5
|
+
* opaque resource reference, what filesystem directory does a spawned
|
|
6
|
+
* process or launched editor run in?" OD answers that with
|
|
7
|
+
* `ctx.projectStore.getProject` + `ctx.projectFiles.resolveProjectDir` — a
|
|
8
|
+
* project-store lookup plus a metadata-driven directory resolver, both
|
|
9
|
+
* product-specific (see `packages/http/source-map.md`'s routes-classification
|
|
10
|
+
* table, rows `#11 terminal.ts` and `#23 host-tools.ts`, both of which name
|
|
11
|
+
* exactly this dependency as the reason `POST /api/projects/:id/open-in` and
|
|
12
|
+
* the interactive-terminal spawn route were not ported earlier). The kernel
|
|
13
|
+
* has no concept of "project," so it cannot hardcode that lookup — but it
|
|
14
|
+
* also must not silently invent a directory (guessing `process.cwd()` or an
|
|
15
|
+
* OS temp dir would let one request's resource reference leak into an
|
|
16
|
+
* unrelated working directory).
|
|
17
|
+
*
|
|
18
|
+
* Follows the same explicit-injection, conservative-default shape this repo
|
|
19
|
+
* already established for `@jini-ai/cli`'s `resolveDaemonUrl`
|
|
20
|
+
* (`packages/cli/src/daemon-url.ts`): a host supplies a resolver callback; the
|
|
21
|
+
* built-in default resolves nothing and the resolution function throws
|
|
22
|
+
* rather than guessing. It also mirrors `active-context.ts`'s
|
|
23
|
+
* `resolveResource` DI shape (a caller-supplied lookup replacing OD's
|
|
24
|
+
* `getProject`) and its `resourceRef`/`detail` field naming.
|
|
25
|
+
*/
|
|
26
|
+
/** Thrown by {@link resolveWorkspaceRoot} when no root could be resolved — the caller has nothing safe to spawn a process or open an editor against. */
|
|
27
|
+
export class WorkspaceRootDeniedError extends Error {
|
|
28
|
+
resourceRef;
|
|
29
|
+
constructor(resourceRef, reason) {
|
|
30
|
+
super(reason ?? `no workspace root available for resource "${resourceRef}"`);
|
|
31
|
+
this.name = 'WorkspaceRootDeniedError';
|
|
32
|
+
this.resourceRef = resourceRef;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The built-in, zero-config default resolver: resolves nothing, for every
|
|
37
|
+
* request. A host that never wires its own resolver gets a hard denial from
|
|
38
|
+
* every call site that needs a workspace root — never a guessed path. This
|
|
39
|
+
* is the "conservative default that denies rather than guessing" half of
|
|
40
|
+
* the port, matching the task's explicit precedent
|
|
41
|
+
* (`ToolPolicy`/`resolveDaemonUrl`).
|
|
42
|
+
*/
|
|
43
|
+
export const denyAllWorkspaceRoots = () => null;
|
|
44
|
+
/**
|
|
45
|
+
* Resolves a workspace root for `request` via `options.resolver`.
|
|
46
|
+
*
|
|
47
|
+
* @throws {WorkspaceRootDeniedError} If the resolver is omitted, or returns
|
|
48
|
+
* `null`/`undefined`/an empty string. This function never falls back to a
|
|
49
|
+
* guessed path (`process.cwd()`, an OS temp dir, `resourceRef` itself
|
|
50
|
+
* treated as a path) — a route that cannot resolve a real root has nothing
|
|
51
|
+
* safe to act on.
|
|
52
|
+
* @complexity O(1) plus the injected resolver's own cost.
|
|
53
|
+
* @overallScore 100/100
|
|
54
|
+
*/
|
|
55
|
+
export async function resolveWorkspaceRoot(request, options = {}) {
|
|
56
|
+
const resolver = options.resolver ?? denyAllWorkspaceRoots;
|
|
57
|
+
const root = await resolver(request);
|
|
58
|
+
if (typeof root !== 'string' || root.length === 0) {
|
|
59
|
+
throw new WorkspaceRootDeniedError(request.resourceRef);
|
|
60
|
+
}
|
|
61
|
+
return root;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=workspace-root.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-root.js","sourceRoot":"","sources":["../src/workspace-root.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAmBH,wJAAwJ;AACxJ,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IACxC,WAAW,CAAS;IAE7B,YAAY,WAAmB,EAAE,MAAe;QAC9C,KAAK,CAAC,MAAM,IAAI,6CAA6C,WAAW,GAAG,CAAC,CAAC;QAC7E,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA0B,GAAG,EAAE,CAAC,IAAI,CAAC;AAOvE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,OAA6B,EAC7B,UAAuC,EAAE;IAEzC,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,qBAAqB,CAAC;IAC3D,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,CAAC;IACrC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,wBAAwB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/xai.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Express } from 'express';
|
|
2
|
+
import { PendingAuthCache, startOAuthCallbackListener, type OAuthCallbackListener, type OAuthPkceProviderConfig } from '@jini-ai/agent-runtime';
|
|
3
|
+
import { type AdapterContext } from './adapter.js';
|
|
4
|
+
export interface XaiInternalErrorContext {
|
|
5
|
+
readonly source: 'oauth-start' | 'oauth-complete' | 'oauth-disconnect' | 'auth-status' | 'search';
|
|
6
|
+
readonly correlationId: string;
|
|
7
|
+
readonly error: unknown;
|
|
8
|
+
}
|
|
9
|
+
export interface XaiHttpDeps {
|
|
10
|
+
/** Directory the xAI OAuth token is persisted under (`<dataDir>/<tokenFileName>`). Defaults to `process.cwd()` — a host with a real dataDir should override this (matching `create-local-node-daemon.ts`'s `memoryRoutesDeps.dataDir` pattern). */
|
|
11
|
+
readonly dataDir?: string;
|
|
12
|
+
/** On-disk file name for the stored token, scoped under `dataDir`. Defaults to `xai-oauth-token.json`. */
|
|
13
|
+
readonly tokenFileName?: string;
|
|
14
|
+
/** The OAuth+PKCE provider config to drive the dance against. Defaults to `@jini-ai/agent-runtime`'s real `XAI_OAUTH_PROVIDER_CONFIG` preset — override only to point at a different client_id/issuer (e.g. once a non-PoC xAI client_id is provisioned). */
|
|
15
|
+
readonly providerConfig?: OAuthPkceProviderConfig;
|
|
16
|
+
/** Loopback callback host `providerConfig.clientId` is registered against. Defaults to `XAI_OAUTH_REDIRECT_HOST` (`127.0.0.1`) — see module doc on why this is fixed for xAI's PoC client_id. */
|
|
17
|
+
readonly callbackHost?: string;
|
|
18
|
+
/** Loopback callback port `providerConfig.clientId` is registered against. Defaults to `XAI_OAUTH_REDIRECT_PORT` (`56121`). */
|
|
19
|
+
readonly callbackPort?: number;
|
|
20
|
+
/** Loopback callback path `providerConfig.clientId` is registered against. Defaults to `XAI_OAUTH_REDIRECT_PATH` (`/callback`). */
|
|
21
|
+
readonly callbackPath?: string;
|
|
22
|
+
/** In-memory pending-authorization cache backing the begin/complete dance. Defaults to a fresh 30-minute `PendingAuthCache`, shared across every request `registerXaiRoutes` mounts — see module doc on why this must be resolved once, not per-call. */
|
|
23
|
+
readonly pending?: PendingAuthCache;
|
|
24
|
+
/** Mutable slot holding the in-flight loopback listener, if any (only one OAuth dance can be in flight at a time — the port is a singleton). Shared the same way `pending` is. Defaults to `{ current: null }`. */
|
|
25
|
+
readonly listenerRef?: {
|
|
26
|
+
current: OAuthCallbackListener | null;
|
|
27
|
+
};
|
|
28
|
+
/** Opens the loopback callback listener. Defaults to `@jini-ai/agent-runtime`'s `startOAuthCallbackListener`. Overridable so tests never bind a real socket. */
|
|
29
|
+
readonly startCallbackListener?: typeof startOAuthCallbackListener;
|
|
30
|
+
/** Base URL for xAI's Responses API (`POST {searchBaseUrl}/responses`). Defaults to `https://api.x.ai/v1`. */
|
|
31
|
+
readonly searchBaseUrl?: string;
|
|
32
|
+
/** Model id sent to the Responses API when a search request doesn't supply its own. Defaults to xAI's real `grok-4.20-reasoning`. */
|
|
33
|
+
readonly searchDefaultModel?: string;
|
|
34
|
+
readonly fetchImpl?: typeof fetch;
|
|
35
|
+
/** Deadline for one search request *and* its response body, in milliseconds. Defaults to {@link DEFAULT_SEARCH_TIMEOUT_MS}. */
|
|
36
|
+
readonly searchTimeoutMs?: number;
|
|
37
|
+
/** Host-owned sink for the real exception behind a generic `INTERNAL_ERROR` response (SEC-005). Defaults to `console.error`. */
|
|
38
|
+
readonly onInternalError?: (context: XaiInternalErrorContext) => void;
|
|
39
|
+
}
|
|
40
|
+
export interface XaiOauthStartResponse {
|
|
41
|
+
readonly authorizeUrl: string;
|
|
42
|
+
readonly state: string;
|
|
43
|
+
readonly callback: {
|
|
44
|
+
readonly host: string;
|
|
45
|
+
readonly port: number;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export declare const xaiOauthStartRoute: import("./types.js").JsonRouteSpec<void, XaiOauthStartResponse, XaiHttpDeps>;
|
|
49
|
+
export interface XaiOkResponse {
|
|
50
|
+
readonly ok: true;
|
|
51
|
+
}
|
|
52
|
+
interface XaiOauthCompleteRequest {
|
|
53
|
+
readonly state: string;
|
|
54
|
+
readonly code: string;
|
|
55
|
+
}
|
|
56
|
+
export declare const xaiOauthCompleteRoute: import("./types.js").JsonRouteSpec<XaiOauthCompleteRequest, XaiOkResponse, XaiHttpDeps>;
|
|
57
|
+
export declare const xaiOauthCancelRoute: import("./types.js").JsonRouteSpec<void, XaiOkResponse, XaiHttpDeps>;
|
|
58
|
+
export interface XaiAuthStatusResponse {
|
|
59
|
+
readonly connected: boolean;
|
|
60
|
+
readonly expiresAt: number | null;
|
|
61
|
+
readonly scope: string | null;
|
|
62
|
+
readonly savedAt: number | null;
|
|
63
|
+
readonly listening: boolean;
|
|
64
|
+
}
|
|
65
|
+
export declare const xaiAuthStatusRoute: import("./types.js").JsonRouteSpec<void, XaiAuthStatusResponse, XaiHttpDeps>;
|
|
66
|
+
export declare const xaiOauthDisconnectRoute: import("./types.js").JsonRouteSpec<void, XaiOkResponse, XaiHttpDeps>;
|
|
67
|
+
interface XaiSearchRequest {
|
|
68
|
+
readonly query: string;
|
|
69
|
+
readonly allowedXHandles?: readonly string[];
|
|
70
|
+
readonly excludedXHandles?: readonly string[];
|
|
71
|
+
readonly fromDate?: string;
|
|
72
|
+
readonly toDate?: string;
|
|
73
|
+
readonly enableImageUnderstanding?: boolean;
|
|
74
|
+
readonly enableVideoUnderstanding?: boolean;
|
|
75
|
+
readonly model?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface XaiSearchResponse {
|
|
78
|
+
readonly answer: string;
|
|
79
|
+
readonly citations: readonly string[];
|
|
80
|
+
readonly model: string;
|
|
81
|
+
}
|
|
82
|
+
export declare const xaiSearchRoute: import("./types.js").JsonRouteSpec<XaiSearchRequest, XaiSearchResponse, XaiHttpDeps>;
|
|
83
|
+
/** Mounts every xAI route on `app`. A pack's `http(app, services)` calls this directly. */
|
|
84
|
+
export declare function registerXaiRoutes(app: Express, deps: XaiHttpDeps, adapter: AdapterContext): void;
|
|
85
|
+
export {};
|
|
86
|
+
//# sourceMappingURL=xai.d.ts.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