@tai42/api-client 16.0.0 → 17.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +1 -1
- package/dist/agents.js.map +1 -1
- package/dist/client/agents-client.d.ts +26 -0
- package/dist/client/agents-client.d.ts.map +1 -0
- package/dist/client/agents-client.js +19 -0
- package/dist/client/agents-client.js.map +1 -0
- package/dist/client/auth-client.d.ts +247 -0
- package/dist/client/auth-client.d.ts.map +1 -0
- package/dist/client/auth-client.js +73 -0
- package/dist/client/auth-client.js.map +1 -0
- package/dist/client/backend-client.d.ts +39 -0
- package/dist/client/backend-client.d.ts.map +1 -0
- package/dist/client/backend-client.js +22 -0
- package/dist/client/backend-client.js.map +1 -0
- package/dist/client/backup-client.d.ts +56 -0
- package/dist/client/backup-client.d.ts.map +1 -0
- package/dist/client/backup-client.js +12 -0
- package/dist/client/backup-client.js.map +1 -0
- package/dist/client/capabilities-client.d.ts +40 -0
- package/dist/client/capabilities-client.d.ts.map +1 -0
- package/dist/client/capabilities-client.js +19 -0
- package/dist/client/capabilities-client.js.map +1 -0
- package/dist/client/channels-client.d.ts +7 -0
- package/dist/client/channels-client.d.ts.map +1 -0
- package/dist/client/channels-client.js +10 -0
- package/dist/client/channels-client.js.map +1 -0
- package/dist/client/config-client.d.ts +59 -0
- package/dist/client/config-client.d.ts.map +1 -0
- package/dist/client/config-client.js +18 -0
- package/dist/client/config-client.js.map +1 -0
- package/dist/client/connectors-client.d.ts +225 -0
- package/dist/client/connectors-client.d.ts.map +1 -0
- package/dist/client/connectors-client.js +31 -0
- package/dist/client/connectors-client.js.map +1 -0
- package/dist/client/conversations-client.d.ts +398 -0
- package/dist/client/conversations-client.d.ts.map +1 -0
- package/dist/client/conversations-client.js +120 -0
- package/dist/client/conversations-client.js.map +1 -0
- package/dist/client/hooks-client.d.ts +112 -0
- package/dist/client/hooks-client.d.ts.map +1 -0
- package/dist/client/hooks-client.js +25 -0
- package/dist/client/hooks-client.js.map +1 -0
- package/dist/{client.d.ts → client/index.d.ts} +2336 -2708
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +79 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/interactions-client.d.ts +52 -0
- package/dist/client/interactions-client.d.ts.map +1 -0
- package/dist/client/interactions-client.js +84 -0
- package/dist/client/interactions-client.js.map +1 -0
- package/dist/client/login-client.d.ts +69 -0
- package/dist/client/login-client.d.ts.map +1 -0
- package/dist/client/login-client.js +137 -0
- package/dist/client/login-client.js.map +1 -0
- package/dist/client/manifest-client.d.ts +354 -0
- package/dist/client/manifest-client.d.ts.map +1 -0
- package/dist/client/manifest-client.js +76 -0
- package/dist/client/manifest-client.js.map +1 -0
- package/dist/client/marketplace-client.d.ts +274 -0
- package/dist/client/marketplace-client.d.ts.map +1 -0
- package/dist/client/marketplace-client.js +46 -0
- package/dist/client/marketplace-client.js.map +1 -0
- package/dist/client/mcp-config-schema-client.d.ts +5 -0
- package/dist/client/mcp-config-schema-client.d.ts.map +1 -0
- package/dist/client/mcp-config-schema-client.js +9 -0
- package/dist/client/mcp-config-schema-client.js.map +1 -0
- package/dist/client/notifications-client.d.ts +27 -0
- package/dist/client/notifications-client.d.ts.map +1 -0
- package/dist/client/notifications-client.js +11 -0
- package/dist/client/notifications-client.js.map +1 -0
- package/dist/client/observability-client.d.ts +103 -0
- package/dist/client/observability-client.d.ts.map +1 -0
- package/dist/client/observability-client.js +43 -0
- package/dist/client/observability-client.js.map +1 -0
- package/dist/client/plugins-client.d.ts +17 -0
- package/dist/client/plugins-client.d.ts.map +1 -0
- package/dist/client/plugins-client.js +9 -0
- package/dist/client/plugins-client.js.map +1 -0
- package/dist/client/policy-client.d.ts +37 -0
- package/dist/client/policy-client.d.ts.map +1 -0
- package/dist/client/policy-client.js +26 -0
- package/dist/client/policy-client.js.map +1 -0
- package/dist/client/presets-client.d.ts +334 -0
- package/dist/client/presets-client.d.ts.map +1 -0
- package/dist/client/presets-client.js +38 -0
- package/dist/client/presets-client.js.map +1 -0
- package/dist/client/profiles-client.d.ts +101 -0
- package/dist/client/profiles-client.d.ts.map +1 -0
- package/dist/client/profiles-client.js +37 -0
- package/dist/client/profiles-client.js.map +1 -0
- package/dist/client/schedules-client.d.ts +27 -0
- package/dist/client/schedules-client.d.ts.map +1 -0
- package/dist/client/schedules-client.js +13 -0
- package/dist/client/schedules-client.js.map +1 -0
- package/dist/client/settings-schema-client.d.ts +23 -0
- package/dist/client/settings-schema-client.d.ts.map +1 -0
- package/dist/client/settings-schema-client.js +9 -0
- package/dist/client/settings-schema-client.js.map +1 -0
- package/dist/client/states-client.d.ts +470 -0
- package/dist/client/states-client.d.ts.map +1 -0
- package/dist/client/states-client.js +144 -0
- package/dist/client/states-client.js.map +1 -0
- package/dist/client/storage-client.d.ts +40 -0
- package/dist/client/storage-client.d.ts.map +1 -0
- package/dist/client/storage-client.js +43 -0
- package/dist/client/storage-client.js.map +1 -0
- package/dist/client/sub-mcp-client.d.ts +17 -0
- package/dist/client/sub-mcp-client.d.ts.map +1 -0
- package/dist/client/sub-mcp-client.js +14 -0
- package/dist/client/sub-mcp-client.js.map +1 -0
- package/dist/client/system-client.d.ts +11 -0
- package/dist/client/system-client.d.ts.map +1 -0
- package/dist/client/system-client.js +13 -0
- package/dist/client/system-client.js.map +1 -0
- package/dist/client/templates-client.d.ts +29 -0
- package/dist/client/templates-client.d.ts.map +1 -0
- package/dist/client/templates-client.js +21 -0
- package/dist/client/templates-client.js.map +1 -0
- package/dist/client/tool-extensions-client.d.ts +53 -0
- package/dist/client/tool-extensions-client.d.ts.map +1 -0
- package/dist/client/tool-extensions-client.js +21 -0
- package/dist/client/tool-extensions-client.js.map +1 -0
- package/dist/client/tool-meta-client.d.ts +69 -0
- package/dist/client/tool-meta-client.d.ts.map +1 -0
- package/dist/client/tool-meta-client.js +38 -0
- package/dist/client/tool-meta-client.js.map +1 -0
- package/dist/client/tools-client.d.ts +83 -0
- package/dist/client/tools-client.d.ts.map +1 -0
- package/dist/client/tools-client.js +38 -0
- package/dist/client/tools-client.js.map +1 -0
- package/dist/client/transport.d.ts +13 -0
- package/dist/client/transport.d.ts.map +1 -0
- package/dist/client/transport.js +10 -0
- package/dist/client/transport.js.map +1 -0
- package/dist/client/trigger-links-client.d.ts +44 -0
- package/dist/client/trigger-links-client.d.ts.map +1 -0
- package/dist/client/trigger-links-client.js +30 -0
- package/dist/client/trigger-links-client.js.map +1 -0
- package/dist/client/web-entry-gate-client.d.ts +34 -0
- package/dist/client/web-entry-gate-client.d.ts.map +1 -0
- package/dist/client/web-entry-gate-client.js +25 -0
- package/dist/client/web-entry-gate-client.js.map +1 -0
- package/dist/errors.d.ts +11 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +15 -0
- package/dist/errors.js.map +1 -1
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +33 -17
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +12 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -13
- package/dist/index.js.map +1 -1
- package/dist/schemas/api-keys.d.ts +43 -0
- package/dist/schemas/api-keys.d.ts.map +1 -0
- package/dist/schemas/api-keys.js +29 -0
- package/dist/schemas/api-keys.js.map +1 -0
- package/dist/schemas/auth-routes.d.ts +78 -0
- package/dist/schemas/auth-routes.d.ts.map +1 -0
- package/dist/schemas/auth-routes.js +42 -0
- package/dist/schemas/auth-routes.js.map +1 -0
- package/dist/schemas/backup.d.ts +78 -0
- package/dist/schemas/backup.d.ts.map +1 -0
- package/dist/schemas/backup.js +33 -0
- package/dist/schemas/backup.js.map +1 -0
- package/dist/schemas/capabilities.d.ts +109 -0
- package/dist/schemas/capabilities.d.ts.map +1 -0
- package/dist/schemas/capabilities.js +78 -0
- package/dist/schemas/capabilities.js.map +1 -0
- package/dist/schemas/channels.d.ts +7 -0
- package/dist/schemas/channels.d.ts.map +1 -0
- package/dist/schemas/channels.js +9 -0
- package/dist/schemas/channels.js.map +1 -0
- package/dist/schemas/config.d.ts +17 -0
- package/dist/schemas/config.d.ts.map +1 -0
- package/dist/schemas/config.js +17 -0
- package/dist/schemas/config.js.map +1 -0
- package/dist/schemas/connectors.d.ts +383 -0
- package/dist/schemas/connectors.d.ts.map +1 -0
- package/dist/schemas/connectors.js +122 -0
- package/dist/schemas/connectors.js.map +1 -0
- package/dist/schemas/conversations.d.ts +600 -0
- package/dist/schemas/conversations.d.ts.map +1 -0
- package/dist/schemas/conversations.js +208 -0
- package/dist/schemas/conversations.js.map +1 -0
- package/dist/schemas/extensions.d.ts +44 -0
- package/dist/schemas/extensions.d.ts.map +1 -0
- package/dist/schemas/extensions.js +29 -0
- package/dist/schemas/extensions.js.map +1 -0
- package/dist/schemas/fleet.d.ts +271 -0
- package/dist/schemas/fleet.d.ts.map +1 -0
- package/dist/schemas/fleet.js +132 -0
- package/dist/schemas/fleet.js.map +1 -0
- package/dist/schemas/hooks.d.ts +120 -0
- package/dist/schemas/hooks.d.ts.map +1 -0
- package/dist/schemas/hooks.js +44 -0
- package/dist/schemas/hooks.js.map +1 -0
- package/dist/schemas/index.d.ts +40 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +40 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/interactions.d.ts +156 -0
- package/dist/schemas/interactions.d.ts.map +1 -0
- package/dist/schemas/interactions.js +124 -0
- package/dist/schemas/interactions.js.map +1 -0
- package/dist/schemas/login.d.ts +93 -0
- package/dist/schemas/login.d.ts.map +1 -0
- package/dist/schemas/login.js +61 -0
- package/dist/schemas/login.js.map +1 -0
- package/dist/schemas/manifest-mcp.d.ts +125 -0
- package/dist/schemas/manifest-mcp.d.ts.map +1 -0
- package/dist/schemas/manifest-mcp.js +61 -0
- package/dist/schemas/manifest-mcp.js.map +1 -0
- package/dist/schemas/marketplace.d.ts +708 -0
- package/dist/schemas/marketplace.d.ts.map +1 -0
- package/dist/schemas/marketplace.js +387 -0
- package/dist/schemas/marketplace.js.map +1 -0
- package/dist/schemas/notifications.d.ts +61 -0
- package/dist/schemas/notifications.d.ts.map +1 -0
- package/dist/schemas/notifications.js +38 -0
- package/dist/schemas/notifications.js.map +1 -0
- package/dist/schemas/observability.d.ts +114 -0
- package/dist/schemas/observability.d.ts.map +1 -0
- package/dist/schemas/observability.js +74 -0
- package/dist/schemas/observability.js.map +1 -0
- package/dist/schemas/policy.d.ts +58 -0
- package/dist/schemas/policy.d.ts.map +1 -0
- package/dist/schemas/policy.js +32 -0
- package/dist/schemas/policy.js.map +1 -0
- package/dist/schemas/presets.d.ts +258 -0
- package/dist/schemas/presets.d.ts.map +1 -0
- package/dist/schemas/presets.js +95 -0
- package/dist/schemas/presets.js.map +1 -0
- package/dist/schemas/principals.d.ts +54 -0
- package/dist/schemas/principals.d.ts.map +1 -0
- package/dist/schemas/principals.js +34 -0
- package/dist/schemas/principals.js.map +1 -0
- package/dist/schemas/profiles.d.ts +180 -0
- package/dist/schemas/profiles.d.ts.map +1 -0
- package/dist/schemas/profiles.js +100 -0
- package/dist/schemas/profiles.js.map +1 -0
- package/dist/schemas/roles.d.ts +125 -0
- package/dist/schemas/roles.d.ts.map +1 -0
- package/dist/schemas/roles.js +46 -0
- package/dist/schemas/roles.js.map +1 -0
- package/dist/schemas/schedules.d.ts +25 -0
- package/dist/schemas/schedules.d.ts.map +1 -0
- package/dist/schemas/schedules.js +24 -0
- package/dist/schemas/schedules.js.map +1 -0
- package/dist/schemas/served.d.ts +626 -0
- package/dist/schemas/served.d.ts.map +1 -0
- package/dist/schemas/served.js +28 -0
- package/dist/schemas/served.js.map +1 -0
- package/dist/schemas/settings-schema.d.ts +23 -0
- package/dist/schemas/settings-schema.d.ts.map +1 -0
- package/dist/schemas/settings-schema.js +25 -0
- package/dist/schemas/settings-schema.js.map +1 -0
- package/dist/schemas/setup.d.ts +43 -0
- package/dist/schemas/setup.d.ts.map +1 -0
- package/dist/schemas/setup.js +19 -0
- package/dist/schemas/setup.js.map +1 -0
- package/dist/schemas/shared.d.ts +20 -0
- package/dist/schemas/shared.d.ts.map +1 -0
- package/dist/schemas/shared.js +20 -0
- package/dist/schemas/shared.js.map +1 -0
- package/dist/schemas/states.d.ts +499 -0
- package/dist/schemas/states.d.ts.map +1 -0
- package/dist/schemas/states.js +220 -0
- package/dist/schemas/states.js.map +1 -0
- package/dist/schemas/storage.d.ts +37 -0
- package/dist/schemas/storage.d.ts.map +1 -0
- package/dist/schemas/storage.js +24 -0
- package/dist/schemas/storage.js.map +1 -0
- package/dist/schemas/studio-plugins.d.ts +30 -0
- package/dist/schemas/studio-plugins.d.ts.map +1 -0
- package/dist/schemas/studio-plugins.js +20 -0
- package/dist/schemas/studio-plugins.js.map +1 -0
- package/dist/schemas/sub-mcp.d.ts +29 -0
- package/dist/schemas/sub-mcp.d.ts.map +1 -0
- package/dist/schemas/sub-mcp.js +22 -0
- package/dist/schemas/sub-mcp.js.map +1 -0
- package/dist/schemas/system-kinds.d.ts +122 -0
- package/dist/schemas/system-kinds.d.ts.map +1 -0
- package/dist/schemas/system-kinds.js +40 -0
- package/dist/schemas/system-kinds.js.map +1 -0
- package/dist/schemas/templates.d.ts +26 -0
- package/dist/schemas/templates.d.ts.map +1 -0
- package/dist/schemas/templates.js +11 -0
- package/dist/schemas/templates.js.map +1 -0
- package/dist/schemas/tool-meta.d.ts +64 -0
- package/dist/schemas/tool-meta.d.ts.map +1 -0
- package/dist/schemas/tool-meta.js +44 -0
- package/dist/schemas/tool-meta.js.map +1 -0
- package/dist/schemas/tools.d.ts +62 -0
- package/dist/schemas/tools.d.ts.map +1 -0
- package/dist/schemas/tools.js +53 -0
- package/dist/schemas/tools.js.map +1 -0
- package/dist/schemas/trigger-links.d.ts +71 -0
- package/dist/schemas/trigger-links.d.ts.map +1 -0
- package/dist/schemas/trigger-links.js +46 -0
- package/dist/schemas/trigger-links.js.map +1 -0
- package/dist/schemas/web-entry.d.ts +45 -0
- package/dist/schemas/web-entry.d.ts.map +1 -0
- package/dist/schemas/web-entry.js +36 -0
- package/dist/schemas/web-entry.js.map +1 -0
- package/dist/tool-runs.d.ts.map +1 -1
- package/dist/tool-runs.js.map +1 -1
- package/package.json +1 -1
- package/src/agents.ts +2 -2
- package/src/client/agents-client.ts +23 -0
- package/src/client/auth-client.ts +170 -0
- package/src/client/backend-client.ts +25 -0
- package/src/client/backup-client.ts +16 -0
- package/src/client/capabilities-client.ts +22 -0
- package/src/client/channels-client.ts +11 -0
- package/src/client/config-client.ts +21 -0
- package/src/client/connectors-client.ts +52 -0
- package/src/client/conversations-client.ts +240 -0
- package/src/client/hooks-client.ts +44 -0
- package/src/client/index.ts +122 -0
- package/src/client/interactions-client.ts +89 -0
- package/src/client/login-client.ts +150 -0
- package/src/client/manifest-client.ts +118 -0
- package/src/client/marketplace-client.ts +122 -0
- package/src/client/mcp-config-schema-client.ts +11 -0
- package/src/client/notifications-client.ts +13 -0
- package/src/client/observability-client.ts +82 -0
- package/src/client/plugins-client.ts +11 -0
- package/src/client/policy-client.ts +41 -0
- package/src/client/presets-client.ts +124 -0
- package/src/client/profiles-client.ts +51 -0
- package/src/client/schedules-client.ts +22 -0
- package/src/client/settings-schema-client.ts +11 -0
- package/src/client/states-client.ts +292 -0
- package/src/client/storage-client.ts +63 -0
- package/src/client/sub-mcp-client.ts +17 -0
- package/src/client/system-client.ts +16 -0
- package/src/client/templates-client.ts +28 -0
- package/src/client/tool-extensions-client.ts +24 -0
- package/src/client/tool-meta-client.ts +65 -0
- package/src/client/tools-client.ts +66 -0
- package/src/client/transport.ts +18 -0
- package/src/client/trigger-links-client.ts +51 -0
- package/src/client/web-entry-gate-client.ts +45 -0
- package/src/errors.ts +16 -0
- package/src/http.ts +48 -24
- package/src/index.ts +231 -226
- package/src/schemas/api-keys.ts +34 -0
- package/src/schemas/auth-routes.ts +48 -0
- package/src/schemas/backup.ts +43 -0
- package/src/schemas/capabilities.ts +92 -0
- package/src/schemas/channels.ts +11 -0
- package/src/schemas/config.ts +17 -0
- package/src/schemas/connectors.ts +139 -0
- package/src/schemas/conversations.ts +257 -0
- package/src/schemas/extensions.ts +34 -0
- package/src/schemas/fleet.ts +154 -0
- package/src/schemas/hooks.ts +57 -0
- package/src/schemas/index.ts +39 -0
- package/src/schemas/interactions.ts +147 -0
- package/src/schemas/login.ts +69 -0
- package/src/schemas/manifest-mcp.ts +70 -0
- package/src/schemas/marketplace.ts +447 -0
- package/src/schemas/notifications.ts +43 -0
- package/src/schemas/observability.ts +87 -0
- package/src/schemas/policy.ts +38 -0
- package/src/schemas/presets.ts +114 -0
- package/src/schemas/principals.ts +41 -0
- package/src/schemas/profiles.ts +120 -0
- package/src/schemas/roles.ts +58 -0
- package/src/schemas/schedules.ts +28 -0
- package/src/schemas/served.ts +50 -0
- package/src/schemas/settings-schema.ts +32 -0
- package/src/schemas/setup.ts +39 -0
- package/src/schemas/shared.ts +21 -0
- package/src/schemas/states.ts +273 -0
- package/src/schemas/storage.ts +31 -0
- package/src/schemas/studio-plugins.ts +21 -0
- package/src/schemas/sub-mcp.ts +24 -0
- package/src/schemas/system-kinds.ts +47 -0
- package/src/schemas/templates.ts +12 -0
- package/src/schemas/tool-meta.ts +51 -0
- package/src/schemas/tools.ts +62 -0
- package/src/schemas/trigger-links.ts +55 -0
- package/src/schemas/web-entry.ts +46 -0
- package/src/tool-runs.ts +1 -1
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -920
- package/dist/client.js.map +0 -1
- package/dist/schemas.d.ts +0 -5172
- package/dist/schemas.d.ts.map +0 -1
- package/dist/schemas.js +0 -2268
- package/dist/schemas.js.map +0 -1
- package/src/client.ts +0 -1771
- package/src/schemas.ts +0 -2760
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/** Auth scopes, routes, roles and API-key sub-client. */
|
|
2
|
+
import { encodeSegment } from '../http';
|
|
3
|
+
import * as s from '../schemas';
|
|
4
|
+
import type { Transport } from './transport';
|
|
5
|
+
|
|
6
|
+
/** Body for creating or editing an API key (POST/PUT `/api/auth/api-keys`). */
|
|
7
|
+
export interface ApiKeyBody {
|
|
8
|
+
readonly user_id: string;
|
|
9
|
+
readonly description: string;
|
|
10
|
+
readonly scopes: string[];
|
|
11
|
+
// The principal that OWNS the key. Admin-only: an admin may name a service
|
|
12
|
+
// principal; a non-admin omits it and the server forces self-ownership.
|
|
13
|
+
readonly owner_user_id?: string;
|
|
14
|
+
// `null` is an explicit clear on edit (PATCH-style PUT): absent preserves the
|
|
15
|
+
// stored policy data, `null` wipes it. Create never sends `null`.
|
|
16
|
+
readonly policy_data?: Record<string, unknown> | null;
|
|
17
|
+
// The access-control condition: an authored templated-text value (inline content
|
|
18
|
+
// or a stored template id), or `null` to explicitly clear it on edit.
|
|
19
|
+
readonly condition?: s.TemplatedText | null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Body for one-time claim-link creation (POST `/api/auth/claim-links`). The
|
|
24
|
+
* `api_key` is a raw key the caller holds (the just-minted key, client-side
|
|
25
|
+
* exactly once); `ttl_seconds` optionally overrides the default lifetime (the
|
|
26
|
+
* server caps it at its ceiling).
|
|
27
|
+
*/
|
|
28
|
+
export interface ClaimLinkBody {
|
|
29
|
+
readonly api_key: string;
|
|
30
|
+
readonly ttl_seconds?: number | null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Body for adding a URL to a scope (POST `/api/auth/scopes`). */
|
|
34
|
+
export interface AddUrlToScopeBody {
|
|
35
|
+
readonly scope_id: string;
|
|
36
|
+
readonly url: string;
|
|
37
|
+
readonly pattern?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Body for creating a role (POST `/api/auth/roles`). `base_tier` is the security
|
|
42
|
+
* tier the role inherits (`editor`/`viewer` — `admin` is reserved); its jq is
|
|
43
|
+
* resolved server-side, never authored here. `grants` is the editable per-tag
|
|
44
|
+
* access-level map (feature-group tag → `none`/`read`/`write`); it defaults to
|
|
45
|
+
* empty (every group `none`, fail-closed) when omitted.
|
|
46
|
+
*/
|
|
47
|
+
export interface RoleCreateBody {
|
|
48
|
+
readonly name: string;
|
|
49
|
+
readonly description?: string;
|
|
50
|
+
readonly base_tier: string;
|
|
51
|
+
readonly grants?: Record<string, s.GrantLevel>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Body for editing a role (PUT `/api/auth/roles/{name}`). Both fields are
|
|
56
|
+
* omit-means-KEEP: an absent `grants` preserves the stored map (never a silent
|
|
57
|
+
* wipe), an absent `description` preserves the stored description. The base-tier jq
|
|
58
|
+
* is seed-fixed and not editable here.
|
|
59
|
+
*/
|
|
60
|
+
export interface RoleUpdateBody {
|
|
61
|
+
readonly grants?: Record<string, s.GrantLevel>;
|
|
62
|
+
readonly description?: string;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Body for pinning a route public (POST `/api/auth/public-routes`). `pattern` is an
|
|
67
|
+
* optional regex the AC verifier full-matches request paths against, mapping every
|
|
68
|
+
* match to the `url` key (so a mount's whole subtree can be pinned in one call).
|
|
69
|
+
*/
|
|
70
|
+
export interface PinRoutePublicBody {
|
|
71
|
+
readonly url: string;
|
|
72
|
+
readonly pattern?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function authClient(t: Transport) {
|
|
76
|
+
const { req } = t;
|
|
77
|
+
return {
|
|
78
|
+
listScopes: (signal?: AbortSignal) => req('/api/auth/scopes', s.authScopes, { signal }),
|
|
79
|
+
addUrlToScope: (body: AddUrlToScopeBody) =>
|
|
80
|
+
req('/api/auth/scopes', s.addUrlToScopeResult, { method: 'POST', body }),
|
|
81
|
+
removeUrlFromScope: (body: { url: string }) =>
|
|
82
|
+
req('/api/auth/scopes/urls', s.removeUrlFromScopeResult, { method: 'DELETE', body }),
|
|
83
|
+
removeScope: (scopeId: string) =>
|
|
84
|
+
req(`/api/auth/scopes/${encodeSegment(scopeId)}`, s.removeScopeResult, {
|
|
85
|
+
method: 'DELETE',
|
|
86
|
+
}),
|
|
87
|
+
// The app's HTTP route catalog with each route's current mapping — the only
|
|
88
|
+
// source of the mapper's unassigned-routes bucket (`mapped: null` entries).
|
|
89
|
+
listAuthRoutes: (signal?: AbortSignal) => req('/api/auth/routes', s.authRoutes, { signal }),
|
|
90
|
+
// The urls pinned to the public marker; pinning/unpinning is the dedicated
|
|
91
|
+
// public-routes writer, never the scope machinery.
|
|
92
|
+
listPublicRoutes: (signal?: AbortSignal) =>
|
|
93
|
+
req('/api/auth/public-routes', s.publicRoutes, { signal }),
|
|
94
|
+
pinRoutePublic: (body: PinRoutePublicBody) =>
|
|
95
|
+
req('/api/auth/public-routes', s.pinPublicResult, { method: 'POST', body }),
|
|
96
|
+
// Unpin a public url. A url that is absent or scope-mapped is a loud 404.
|
|
97
|
+
unpinPublicRoute: (url: string) =>
|
|
98
|
+
req('/api/auth/public-routes', s.unpinPublicResult, { method: 'DELETE', body: { url } }),
|
|
99
|
+
|
|
100
|
+
// The seeded + operator-authored roles as full bodies (base-tier ceiling +
|
|
101
|
+
// editable per-tag grant map). ADMIN-ONLY — the route is `secret` (a listing
|
|
102
|
+
// exposes each role's raw base-tier jq); a non-admin projection never reaches it.
|
|
103
|
+
listRoles: (signal?: AbortSignal) => req('/api/auth/roles', s.roleList, { signal }),
|
|
104
|
+
// Create an operator-authored role. The server validates the grant map + base
|
|
105
|
+
// tier and 409s on a name collision; the reserved `admin` role cannot be created.
|
|
106
|
+
createRole: (body: RoleCreateBody) =>
|
|
107
|
+
req('/api/auth/roles', s.roleBody, { method: 'POST', body }),
|
|
108
|
+
// Edit a role's per-tag grant map + description (omit-means-keep). The reserved
|
|
109
|
+
// `admin` role and any `allow_all` role are block-downgrade guarded server-side.
|
|
110
|
+
updateRole: (name: string, body: RoleUpdateBody) =>
|
|
111
|
+
req(`/api/auth/roles/${encodeSegment(name)}`, s.roleBody, { method: 'PUT', body }),
|
|
112
|
+
// Delete a role. The reserved `admin` role is undeletable; a role still assigned
|
|
113
|
+
// to any principal is a loud 409.
|
|
114
|
+
deleteRole: (name: string) =>
|
|
115
|
+
req(`/api/auth/roles/${encodeSegment(name)}`, s.roleDeleted, { method: 'DELETE' }),
|
|
116
|
+
// A role's append-only version history + who/action/before→after audit trail.
|
|
117
|
+
// ADMIN-ONLY (`secret`).
|
|
118
|
+
listRoleVersions: (name: string, signal?: AbortSignal) =>
|
|
119
|
+
req(`/api/auth/roles/${encodeSegment(name)}/versions`, s.roleVersions, { signal }),
|
|
120
|
+
// Re-point a role's active version to a prior one (LIVE — holders follow on
|
|
121
|
+
// their next request); returns the re-pointed role body.
|
|
122
|
+
rollbackRole: (name: string, version: number) =>
|
|
123
|
+
req(`/api/auth/roles/${encodeSegment(name)}/rollback`, s.roleBody, {
|
|
124
|
+
method: 'POST',
|
|
125
|
+
body: { version },
|
|
126
|
+
}),
|
|
127
|
+
|
|
128
|
+
listTokensPayload: (signal?: AbortSignal) =>
|
|
129
|
+
req('/api/auth/tokens-payload', s.tokensPayload, { signal }),
|
|
130
|
+
createApiKey: (body: ApiKeyBody) =>
|
|
131
|
+
req('/api/auth/api-keys', s.createdApiKey, { method: 'POST', body }),
|
|
132
|
+
editApiKey: (userId: string, body: Omit<ApiKeyBody, 'user_id'>) =>
|
|
133
|
+
req(`/api/auth/api-keys/${encodeSegment(userId)}`, s.editApiKeyResult, {
|
|
134
|
+
method: 'PUT',
|
|
135
|
+
body,
|
|
136
|
+
}),
|
|
137
|
+
revokeApiKey: (userId: string) =>
|
|
138
|
+
req(`/api/auth/api-keys/${encodeSegment(userId)}`, s.revokeApiKeyResult, {
|
|
139
|
+
method: 'DELETE',
|
|
140
|
+
}),
|
|
141
|
+
// Mint a one-time claim link carrying a raw key to another device (the QR
|
|
142
|
+
// onboarding leg). The token rides the URL fragment; the server returns a
|
|
143
|
+
// relative `claim_path` and the raw token ONCE.
|
|
144
|
+
createClaimLink: (body: ClaimLinkBody) =>
|
|
145
|
+
req('/api/auth/claim-links', s.claimLinkCreated, { method: 'POST', body }),
|
|
146
|
+
|
|
147
|
+
// The deployment's principals (identities). ADMIN-ONLY (`secret`) — a
|
|
148
|
+
// non-admin projection never reaches the route.
|
|
149
|
+
listPrincipals: (signal?: AbortSignal) =>
|
|
150
|
+
req('/api/auth/principals', s.principalList, { signal }),
|
|
151
|
+
// Create a `human` or `service` principal and apply its role (admin only).
|
|
152
|
+
// A duplicate id is a loud 409; an unknown role a loud 400.
|
|
153
|
+
createPrincipal: (body: {
|
|
154
|
+
user_id?: string;
|
|
155
|
+
kind: 'human' | 'service';
|
|
156
|
+
display_name: string;
|
|
157
|
+
role: string;
|
|
158
|
+
}) => req('/api/auth/principals', s.principal, { method: 'POST', body }),
|
|
159
|
+
// Update a principal's display name and/or `disabled` flag (omit-means-keep;
|
|
160
|
+
// an all-absent body is a loud 400). Disabling turns off every credential the
|
|
161
|
+
// principal owns.
|
|
162
|
+
updatePrincipal: (userId: string, body: { display_name?: string; disabled?: boolean }) =>
|
|
163
|
+
req(`/api/auth/principals/${encodeSegment(userId)}`, s.principal, { method: 'PUT', body }),
|
|
164
|
+
// Delete a principal — revokes every key it owns and its policy row.
|
|
165
|
+
deletePrincipal: (userId: string) =>
|
|
166
|
+
req(`/api/auth/principals/${encodeSegment(userId)}`, s.principalDeleted, {
|
|
167
|
+
method: 'DELETE',
|
|
168
|
+
}),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Backend identity and worker-bus fleet sub-client. */
|
|
2
|
+
import * as s from '../schemas';
|
|
3
|
+
import type { Transport } from './transport';
|
|
4
|
+
|
|
5
|
+
export function backendClient(t: Transport) {
|
|
6
|
+
const { req } = t;
|
|
7
|
+
return {
|
|
8
|
+
// Backend IDENTITY (`getBackendInfo`, kept on `/api/backend`) is distinct from
|
|
9
|
+
// the FLEET doors, which ride the app's worker bus and need no backend at all.
|
|
10
|
+
// `getBackendInfo` reports `present: false` (a 200 empty state) when no backend
|
|
11
|
+
// plugin is registered. `listFleetWorkers` reads the live bus presence census
|
|
12
|
+
// (every subscribed worker, ASGI + backend-runtime) and never fabricates an empty
|
|
13
|
+
// fleet — a census read that fails surfaces as a loud 500.
|
|
14
|
+
getBackendInfo: (signal?: AbortSignal) => req('/api/backend', s.backendInfo, { signal }),
|
|
15
|
+
listFleetWorkers: (signal?: AbortSignal) =>
|
|
16
|
+
req('/api/fleet/workers', s.fleetWorkers, { signal }),
|
|
17
|
+
// Soft-restart the fleet: `targets` names the workers to reload, or `null` for
|
|
18
|
+
// the whole fleet. The serving worker applies locally then broadcasts; a 200
|
|
19
|
+
// response carries the per-worker fleet report, so workers that did not converge
|
|
20
|
+
// are named, not hidden. A failed local apply instead re-raises as a loud error
|
|
21
|
+
// (the transport throws with the failure message), not a returned report.
|
|
22
|
+
reloadFleetConfig: (targets: string[] | null) =>
|
|
23
|
+
req('/api/fleet/reload-config', s.fleetReloadResult, { method: 'POST', body: { targets } }),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Backup section listing, export and import sub-client. */
|
|
2
|
+
import { apiDownload } from '../http';
|
|
3
|
+
import * as s from '../schemas';
|
|
4
|
+
import type { Transport } from './transport';
|
|
5
|
+
|
|
6
|
+
export function backupClient(t: Transport) {
|
|
7
|
+
const { config, req } = t;
|
|
8
|
+
return {
|
|
9
|
+
listBackupSections: (signal?: AbortSignal) =>
|
|
10
|
+
req('/api/backup/sections', s.backupSections, { signal }),
|
|
11
|
+
exportBackup: (sections: string[], signal?: AbortSignal): Promise<Blob> =>
|
|
12
|
+
apiDownload(config, '/api/backup/export', { method: 'POST', body: { sections }, signal }),
|
|
13
|
+
importBackup: (body: { document: unknown; sections: string[] }) =>
|
|
14
|
+
req('/api/backup/import', s.backupImportReport, { method: 'POST', body }),
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Caller capability projection and auth-capabilities sub-clients. */
|
|
2
|
+
import * as s from '../schemas';
|
|
3
|
+
import type { Transport } from './transport';
|
|
4
|
+
|
|
5
|
+
export function capabilitiesGetMe(t: Transport) {
|
|
6
|
+
const { req } = t;
|
|
7
|
+
return {
|
|
8
|
+
// The derived (path, method) surface + tools/agents the caller can reach
|
|
9
|
+
// right now — the projection the Studio filters its nav and pages on.
|
|
10
|
+
getMe: (signal?: AbortSignal) => req('/api/auth/me', s.meProjection, { signal }),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function capabilitiesGetCaps(t: Transport) {
|
|
15
|
+
const { req } = t;
|
|
16
|
+
return {
|
|
17
|
+
// Whether this deployment can mint API keys locally (the settings key-create
|
|
18
|
+
// UI gates on `mintable`). AUTHED.
|
|
19
|
+
getAuthCapabilities: (signal?: AbortSignal) =>
|
|
20
|
+
req('/api/auth/capabilities', s.authCapabilities, { signal }),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Installed channel-plugin catalog sub-client. */
|
|
2
|
+
import * as s from '../schemas';
|
|
3
|
+
import type { Transport } from './transport';
|
|
4
|
+
|
|
5
|
+
export function channelsClient(t: Transport) {
|
|
6
|
+
const { req } = t;
|
|
7
|
+
return {
|
|
8
|
+
// The installed channel-plugin names (delivery media for ask_user questions).
|
|
9
|
+
listChannels: (signal?: AbortSignal) => req('/api/channels', s.channels, { signal }),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Environment-config and reload sub-client. */
|
|
2
|
+
import * as s from '../schemas';
|
|
3
|
+
import type { Transport } from './transport';
|
|
4
|
+
|
|
5
|
+
export function configClient(t: Transport) {
|
|
6
|
+
const { req } = t;
|
|
7
|
+
return {
|
|
8
|
+
getEnvConfig: (signal?: AbortSignal) => req('/api/config/env', s.envConfig, { signal }),
|
|
9
|
+
setEnvConfig: (env: Record<string, string>) =>
|
|
10
|
+
req('/api/config/env', s.reloadConfigResult, { method: 'POST', body: env }),
|
|
11
|
+
getConfigMode: (signal?: AbortSignal) => req('/api/config/mode', s.configMode, { signal }),
|
|
12
|
+
// The LOCAL soft-restart door (distinct from the System page's fleet door
|
|
13
|
+
// `/api/fleet/reload-config`): refresh env from the config manager, reset the
|
|
14
|
+
// settings caches, and re-initialize from the manifest — applied on the serving
|
|
15
|
+
// worker and broadcast to the fleet (all workers, or only `targets`; `null` = all).
|
|
16
|
+
// Admin-`fenced`; the 200 body is the bare per-worker fleet report so an
|
|
17
|
+
// unconverged sibling is visible, never hidden.
|
|
18
|
+
reloadConfig: (targets: string[] | null = null) =>
|
|
19
|
+
req('/api/config/reload', s.fleetReloadResult, { method: 'POST', body: { targets } }),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/** Connector provider and connection lifecycle sub-client. */
|
|
2
|
+
import { encodeSegment } from '../http';
|
|
3
|
+
import * as s from '../schemas';
|
|
4
|
+
import type { Transport } from './transport';
|
|
5
|
+
|
|
6
|
+
export interface StartConnectArgs {
|
|
7
|
+
readonly provider_id: string;
|
|
8
|
+
readonly alias: string;
|
|
9
|
+
readonly enabled_sub_services: string[];
|
|
10
|
+
readonly config_values?: Record<string, string>;
|
|
11
|
+
readonly return_url?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function connectorsClient(t: Transport) {
|
|
15
|
+
const { req } = t;
|
|
16
|
+
return {
|
|
17
|
+
listProviders: (signal?: AbortSignal) =>
|
|
18
|
+
req('/api/connectors/providers', s.providers, { signal }),
|
|
19
|
+
listConnections: (signal?: AbortSignal) =>
|
|
20
|
+
req('/api/connectors/connections', s.connectionsList, { signal }),
|
|
21
|
+
getConnection: (id: string, signal?: AbortSignal) =>
|
|
22
|
+
req(`/api/connectors/connections/${encodeSegment(id)}`, s.connectionView, { signal }),
|
|
23
|
+
startConnect: (args: StartConnectArgs) =>
|
|
24
|
+
req('/api/connectors/connections/start', s.startConnectResult, {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
body: args,
|
|
27
|
+
}),
|
|
28
|
+
disconnect: (id: string) =>
|
|
29
|
+
req(`/api/connectors/connections/${encodeSegment(id)}`, s.disconnectResult, {
|
|
30
|
+
method: 'DELETE',
|
|
31
|
+
}),
|
|
32
|
+
reconnect: (id: string, enabled_sub_services: string[], return_url?: string) =>
|
|
33
|
+
req(`/api/connectors/connections/${encodeSegment(id)}/reconnect`, s.reconnectResult, {
|
|
34
|
+
method: 'POST',
|
|
35
|
+
body: { enabled_sub_services, return_url },
|
|
36
|
+
}),
|
|
37
|
+
patchSubServices: (id: string, enabled_sub_services: string[], return_url?: string) =>
|
|
38
|
+
req(
|
|
39
|
+
`/api/connectors/connections/${encodeSegment(id)}/sub-services`,
|
|
40
|
+
s.patchSubServicesResult,
|
|
41
|
+
{
|
|
42
|
+
method: 'PATCH',
|
|
43
|
+
body: { enabled_sub_services, return_url },
|
|
44
|
+
},
|
|
45
|
+
),
|
|
46
|
+
completeOAuth: (state: string, code: string, error?: string) =>
|
|
47
|
+
req('/api/connectors/oauth/complete', s.oauthCompleteResult, {
|
|
48
|
+
method: 'POST',
|
|
49
|
+
body: { state, code, error },
|
|
50
|
+
}),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/** Conversation route, thread, transcript, config and admin sub-client. */
|
|
2
|
+
import { encodeSegment } from '../http';
|
|
3
|
+
import * as s from '../schemas';
|
|
4
|
+
import type { Transport } from './transport';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The thread-list filter set (GET `/api/conversations/{route}/threads` query
|
|
8
|
+
* params, alongside `page`/`pageSize`). `status` narrows to threads whose newest
|
|
9
|
+
* record sits in one delivery state; `address` is a SUBSTRING match over the
|
|
10
|
+
* client address. Both omitted when undefined — an unfiltered listing.
|
|
11
|
+
*/
|
|
12
|
+
export interface ConversationThreadFilters {
|
|
13
|
+
readonly status?: s.ConversationDeliveryStatus;
|
|
14
|
+
readonly address?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* One transcript read (GET `/api/conversations/{route}/transcript` query params).
|
|
19
|
+
* `order` is not a default the caller may skip: `asc` reads the thread from its
|
|
20
|
+
* beginning and `desc` from its newest end, and which one a screen wants is a
|
|
21
|
+
* decision that screen must make. `q` narrows the page to records whose text
|
|
22
|
+
* matches it (a SUBSTRING), omitted for an unfiltered read.
|
|
23
|
+
*/
|
|
24
|
+
export interface ConversationTranscriptQuery {
|
|
25
|
+
readonly routeName: string;
|
|
26
|
+
readonly threadId: string;
|
|
27
|
+
readonly page: number;
|
|
28
|
+
readonly pageSize: number;
|
|
29
|
+
readonly order: s.TranscriptOrder;
|
|
30
|
+
readonly q?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A route-scoped message search (GET
|
|
35
|
+
* `/api/conversations/{route}/messages/search` query params). `q` is the required
|
|
36
|
+
* needle — a substring over record text, across every thread on the route; `page`
|
|
37
|
+
* is supplied per-request by the infinite query.
|
|
38
|
+
*/
|
|
39
|
+
export interface ConversationMessageSearchQuery {
|
|
40
|
+
readonly routeName: string;
|
|
41
|
+
readonly q: string;
|
|
42
|
+
readonly page: number;
|
|
43
|
+
readonly pageSize: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Body for sending a message into a thread (POST
|
|
48
|
+
* `/api/conversations/{route}/thread/messages`). `thread_id` names the thread
|
|
49
|
+
* (an api-door address, passed as a value); `text` is the message. `address` is
|
|
50
|
+
* an optional override the server otherwise derives from the thread, omitted
|
|
51
|
+
* when undefined.
|
|
52
|
+
*/
|
|
53
|
+
export interface ConversationThreadMessageBody {
|
|
54
|
+
readonly thread_id: string;
|
|
55
|
+
readonly text: string;
|
|
56
|
+
readonly address?: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Route CRUD: the stored routing rows and their create/replace/delete doors. */
|
|
60
|
+
function conversationRouteMethods(t: Transport) {
|
|
61
|
+
const { req } = t;
|
|
62
|
+
return {
|
|
63
|
+
// The stored routing rows, each with its `callback_secret` withheld — the
|
|
64
|
+
// conversation monitor's route picker.
|
|
65
|
+
listConversationRoutes: (signal?: AbortSignal) =>
|
|
66
|
+
req('/api/conversations', s.conversationRoutes, { signal }),
|
|
67
|
+
// Create or REPLACE a route (an UPSERT: the same door is the create and the
|
|
68
|
+
// edit path). `route_name` rides the URL path AND the body; the door rejects a
|
|
69
|
+
// disagreeing pair, so both come from the one create object. The reply carries
|
|
70
|
+
// the freshly-minted `callback_secret` for an `api`-door row, returned ONCE.
|
|
71
|
+
createOrReplaceConversationRoute: (route: s.ConversationRouteCreate) =>
|
|
72
|
+
req(`/api/conversations/${encodeSegment(route.route_name)}`, s.conversationRouteWritten, {
|
|
73
|
+
method: 'POST',
|
|
74
|
+
body: route,
|
|
75
|
+
}),
|
|
76
|
+
// Delete a route by name (destructive + authority-changing server-side): it
|
|
77
|
+
// drops the routing row and reclaims the thread indexes it owned.
|
|
78
|
+
deleteConversationRoute: (routeName: string) =>
|
|
79
|
+
req(`/api/conversations/${encodeSegment(routeName)}`, s.conversationRouteDeleted, {
|
|
80
|
+
method: 'DELETE',
|
|
81
|
+
}),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Thread reads and writes: listings, transcript, message search, send, reply mode. */
|
|
86
|
+
function conversationThreadMethods(t: Transport) {
|
|
87
|
+
const { req } = t;
|
|
88
|
+
return {
|
|
89
|
+
// One route's threads, newest activity first. Admin-only server-side: a
|
|
90
|
+
// listing spans every caller on the route, so a scoped session gets a 403.
|
|
91
|
+
listConversationThreads: (
|
|
92
|
+
routeName: string,
|
|
93
|
+
page: number,
|
|
94
|
+
pageSize: number,
|
|
95
|
+
filters: ConversationThreadFilters = {},
|
|
96
|
+
signal?: AbortSignal,
|
|
97
|
+
) =>
|
|
98
|
+
req(`/api/conversations/${encodeSegment(routeName)}/threads`, s.conversationThreadsPage, {
|
|
99
|
+
signal,
|
|
100
|
+
query: { page, pageSize, status: filters.status, address: filters.address },
|
|
101
|
+
}),
|
|
102
|
+
// One thread's transcript, caller-scoped, read in the asked-for direction.
|
|
103
|
+
// The `thread_id` rides the QUERY STRING, never the path: it embeds the api
|
|
104
|
+
// door's `{principal}/{end user}` address with the principal already
|
|
105
|
+
// percent-encoded, which a path segment would have to encode a second time
|
|
106
|
+
// and the server would then decode once too few. A query value is decoded
|
|
107
|
+
// exactly once whatever it holds, so it is passed through verbatim.
|
|
108
|
+
readConversationTranscript: (query: ConversationTranscriptQuery, signal?: AbortSignal) =>
|
|
109
|
+
req(
|
|
110
|
+
`/api/conversations/${encodeSegment(query.routeName)}/transcript`,
|
|
111
|
+
s.conversationTranscriptPage,
|
|
112
|
+
{
|
|
113
|
+
signal,
|
|
114
|
+
query: {
|
|
115
|
+
thread_id: query.threadId,
|
|
116
|
+
page: query.page,
|
|
117
|
+
pageSize: query.pageSize,
|
|
118
|
+
order: query.order,
|
|
119
|
+
q: query.q,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
),
|
|
123
|
+
// Search every record on a route by text, across threads, newest first. The
|
|
124
|
+
// needle rides the QUERY (`q`); paging is the infinite query's own window. The
|
|
125
|
+
// page's `truncated` flag says the match set outran the door's scan cap.
|
|
126
|
+
searchConversationMessages: (query: ConversationMessageSearchQuery, signal?: AbortSignal) =>
|
|
127
|
+
req(
|
|
128
|
+
`/api/conversations/${encodeSegment(query.routeName)}/messages/search`,
|
|
129
|
+
s.conversationMessageSearchPage,
|
|
130
|
+
{ signal, query: { q: query.q, page: query.page, pageSize: query.pageSize } },
|
|
131
|
+
),
|
|
132
|
+
// Send a human message into a thread. The `thread_id` rides the BODY (a POST,
|
|
133
|
+
// never a path segment) — same encode-once reasoning as the transcript read.
|
|
134
|
+
sendConversationThreadMessage: (routeName: string, body: ConversationThreadMessageBody) =>
|
|
135
|
+
req(
|
|
136
|
+
`/api/conversations/${encodeSegment(routeName)}/thread/messages`,
|
|
137
|
+
s.conversationThreadMessageSent,
|
|
138
|
+
{ method: 'POST', body },
|
|
139
|
+
),
|
|
140
|
+
// Read a thread's reply mode (`agent`/`manual`) and where it comes from. The
|
|
141
|
+
// `thread_id` rides the QUERY value, encoded once, as the transcript read does.
|
|
142
|
+
getConversationThreadMode: (routeName: string, threadId: string, signal?: AbortSignal) =>
|
|
143
|
+
req(
|
|
144
|
+
`/api/conversations/${encodeSegment(routeName)}/thread/mode`,
|
|
145
|
+
s.conversationThreadModeState,
|
|
146
|
+
{ signal, query: { thread_id: threadId } },
|
|
147
|
+
),
|
|
148
|
+
// Flip a thread's reply mode. The `thread_id` rides the BODY (a PUT).
|
|
149
|
+
setConversationThreadMode: (
|
|
150
|
+
routeName: string,
|
|
151
|
+
threadId: string,
|
|
152
|
+
mode: s.ConversationThreadMode,
|
|
153
|
+
) =>
|
|
154
|
+
req(
|
|
155
|
+
`/api/conversations/${encodeSegment(routeName)}/thread/mode`,
|
|
156
|
+
s.conversationThreadModeState,
|
|
157
|
+
{ method: 'PUT', body: { thread_id: threadId, mode } },
|
|
158
|
+
),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Per-target presentation configs, keyed by `(target_kind, target_name)`. Admin surface. */
|
|
163
|
+
function conversationConfigMethods(t: Transport) {
|
|
164
|
+
const { req } = t;
|
|
165
|
+
return {
|
|
166
|
+
// The stored per-target presentation configs (each `(target_kind, target_name)`
|
|
167
|
+
// pair's multichannel flag + first-contact greeting). Admin config surface.
|
|
168
|
+
listConversationConfigs: (signal?: AbortSignal) =>
|
|
169
|
+
req('/api/conversation-configs', s.conversationConfigs, { signal }),
|
|
170
|
+
// One config by its `(target_kind, target_name)` key. 404 when unknown.
|
|
171
|
+
getConversationConfig: (
|
|
172
|
+
targetKind: s.ConversationTargetKind,
|
|
173
|
+
targetName: string,
|
|
174
|
+
signal?: AbortSignal,
|
|
175
|
+
) =>
|
|
176
|
+
req(
|
|
177
|
+
`/api/conversation-configs/${encodeSegment(targetKind)}/${encodeSegment(targetName)}`,
|
|
178
|
+
s.targetConversationConfig,
|
|
179
|
+
{ signal },
|
|
180
|
+
),
|
|
181
|
+
// Create or REPLACE a config (an UPSERT: the same door is the create and the
|
|
182
|
+
// edit path). The `(target_kind, target_name)` key rides the URL path; the door
|
|
183
|
+
// rejects a body whose key disagrees, so both come from the one config object.
|
|
184
|
+
setConversationConfig: (config: s.TargetConversationConfig) =>
|
|
185
|
+
req(
|
|
186
|
+
`/api/conversation-configs/${encodeSegment(config.target_kind)}/${encodeSegment(config.target_name)}`,
|
|
187
|
+
s.conversationConfigWritten,
|
|
188
|
+
{ method: 'PUT', body: config },
|
|
189
|
+
),
|
|
190
|
+
// Delete a config by its key. 404 when the key is unknown.
|
|
191
|
+
deleteConversationConfig: (targetKind: s.ConversationTargetKind, targetName: string) =>
|
|
192
|
+
req(
|
|
193
|
+
`/api/conversation-configs/${encodeSegment(targetKind)}/${encodeSegment(targetName)}`,
|
|
194
|
+
s.conversationConfigDeleted,
|
|
195
|
+
{ method: 'DELETE' },
|
|
196
|
+
),
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** Admin/GDPR doors: failed-message audit and destructive thread/person erasure. */
|
|
201
|
+
function conversationAdminMethods(t: Transport) {
|
|
202
|
+
const { req } = t;
|
|
203
|
+
return {
|
|
204
|
+
// Every answer record whose delivery ended `failed`, across every route and
|
|
205
|
+
// caller. Admin-only server-side; not a paged window (returns `{items, total}`).
|
|
206
|
+
listFailedConversationMessages: (signal?: AbortSignal) =>
|
|
207
|
+
req('/api/conversations/messages/failed', s.conversationFailedMessages, { signal }),
|
|
208
|
+
// Forget ONE thread on a route (destructive): its checkpoint, answer records and
|
|
209
|
+
// thread indexes. The `thread_id` rides the QUERY value, encoded once — it embeds
|
|
210
|
+
// the api door's percent-encoded `{principal}/{end user}` address, which a path
|
|
211
|
+
// segment would encode a second time. `removed` counts the records this call
|
|
212
|
+
// cleared; a valid id on its own route always succeeds, never a 404.
|
|
213
|
+
deleteConversationThread: (routeName: string, threadId: string) =>
|
|
214
|
+
req(`/api/conversations/${encodeSegment(routeName)}/thread`, s.conversationThreadDeleted, {
|
|
215
|
+
method: 'DELETE',
|
|
216
|
+
query: { thread_id: threadId },
|
|
217
|
+
}),
|
|
218
|
+
// Erase a LINKED person ENTIRELY (GDPR, wide blast radius): its aggregated thread
|
|
219
|
+
// and checkpoint, its person row, and every address→person index mapping, across
|
|
220
|
+
// EVERY route it wrote under. The `person_id` is a uuid4 with no percent-encoded
|
|
221
|
+
// principal, so it rides the PATH cleanly. `erased` says whether this call removed
|
|
222
|
+
// the person row (idempotent — a retry answers `false`, never a 404).
|
|
223
|
+
deleteConversationPerson: (personId: string) =>
|
|
224
|
+
req(`/api/conversations/persons/${encodeSegment(personId)}`, s.conversationPersonDeleted, {
|
|
225
|
+
method: 'DELETE',
|
|
226
|
+
}),
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export function conversationsClient(t: Transport) {
|
|
231
|
+
// Declaration emit prepends each spread group's members, so the groups are
|
|
232
|
+
// spread in reverse of their public order to keep the surface route → thread
|
|
233
|
+
// → config → admin.
|
|
234
|
+
return {
|
|
235
|
+
...conversationAdminMethods(t),
|
|
236
|
+
...conversationConfigMethods(t),
|
|
237
|
+
...conversationThreadMethods(t),
|
|
238
|
+
...conversationRouteMethods(t),
|
|
239
|
+
};
|
|
240
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Hook listing, registration and topic-verifier sub-client. */
|
|
2
|
+
import { encodeSegment } from '../http';
|
|
3
|
+
import * as s from '../schemas';
|
|
4
|
+
import type { Transport } from './transport';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Body for binding a webhook verifier to a topic
|
|
8
|
+
* (PUT `/api/hooks/topics/{topic}/verifier`). `verifier` is a registered verifier
|
|
9
|
+
* NAME, resolved against the live registry at bind time (an unknown name is a loud
|
|
10
|
+
* 400). `config` is that verifier's config object — it carries a `secret_env` name,
|
|
11
|
+
* never a secret value — and defaults to `{}` when omitted.
|
|
12
|
+
*/
|
|
13
|
+
export interface TopicVerifierBody {
|
|
14
|
+
readonly verifier: string;
|
|
15
|
+
readonly config?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function hooksClient(t: Transport) {
|
|
19
|
+
const { req } = t;
|
|
20
|
+
return {
|
|
21
|
+
listHooks: (topic?: string, signal?: AbortSignal) =>
|
|
22
|
+
req('/api/hooks', s.hookList, { signal, query: topic === undefined ? undefined : { topic } }),
|
|
23
|
+
registerHook: (params: s.HookRegister) =>
|
|
24
|
+
req('/api/hooks', s.hookRegistered, { method: 'POST', body: params }),
|
|
25
|
+
unregisterHook: (name: string) =>
|
|
26
|
+
req(`/api/hooks/${encodeSegment(name)}`, s.hookRemoved, { method: 'DELETE' }),
|
|
27
|
+
// The registered webhook-verifier catalog — the only source the bind picker
|
|
28
|
+
// reads (names only; an empty registry is a valid empty list).
|
|
29
|
+
listHookVerifiers: (signal?: AbortSignal) =>
|
|
30
|
+
req('/api/hooks/verifiers', s.hookVerifiers, { signal }),
|
|
31
|
+
// Bind a verifier to a topic (locks its otherwise-open public ingress). A PUT
|
|
32
|
+
// replaces any existing binding; an unknown verifier name is a loud 400.
|
|
33
|
+
setTopicVerifier: (topic: string, body: TopicVerifierBody) =>
|
|
34
|
+
req(`/api/hooks/topics/${encodeSegment(topic)}/verifier`, s.topicVerifierSet, {
|
|
35
|
+
method: 'PUT',
|
|
36
|
+
body,
|
|
37
|
+
}),
|
|
38
|
+
// Unbind a topic's verifier (re-opens its public ingress). 404 when no binding.
|
|
39
|
+
deleteTopicVerifier: (topic: string) =>
|
|
40
|
+
req(`/api/hooks/topics/${encodeSegment(topic)}/verifier`, s.topicVerifierRemoved, {
|
|
41
|
+
method: 'DELETE',
|
|
42
|
+
}),
|
|
43
|
+
};
|
|
44
|
+
}
|