@tangle-network/agent-app 0.50.30 → 0.50.31

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 (40) hide show
  1. package/dist/agent-enrollment/application.d.ts +42 -0
  2. package/dist/agent-enrollment/index.d.ts +59 -0
  3. package/dist/agent-enrollment/index.js +208 -0
  4. package/dist/agent-enrollment/index.js.map +1 -0
  5. package/dist/assistant/index.js +6 -6
  6. package/dist/chat-routes/index.js +13 -13
  7. package/dist/chat-store/index.js +4 -4
  8. package/dist/{chunk-RACQDXJ7.js → chunk-4PZE7XAM.js} +6 -6
  9. package/dist/{chunk-QWYAR2CY.js → chunk-5KFRCVAO.js} +2 -2
  10. package/dist/{chunk-KTV5RQBQ.js → chunk-5TOV7EDF.js} +4 -4
  11. package/dist/chunk-6RWQ4VW5.js +124 -0
  12. package/dist/chunk-6RWQ4VW5.js.map +1 -0
  13. package/dist/{chunk-RFVTTZPG.js → chunk-CNI46COH.js} +2 -2
  14. package/dist/{chunk-RFVTTZPG.js.map → chunk-CNI46COH.js.map} +1 -1
  15. package/dist/{chunk-TJCTC5QI.js → chunk-LDCR7MRU.js} +2 -2
  16. package/dist/{chunk-QJRXKMHJ.js → chunk-UNXMIWPK.js} +6 -6
  17. package/dist/{chunk-XFCKMBOC.js → chunk-YFGG722I.js} +5 -5
  18. package/dist/{chunk-MX55JP7D.js → chunk-ZMMIQOFI.js} +5 -5
  19. package/dist/hosted-agent/application.js +5 -116
  20. package/dist/hosted-agent/application.js.map +1 -1
  21. package/dist/platform/hub-settings.d.ts +117 -0
  22. package/dist/platform/index.d.ts +1 -0
  23. package/dist/platform/index.js +225 -20
  24. package/dist/platform/index.js.map +1 -1
  25. package/dist/preset-cloudflare/index.js +2 -2
  26. package/dist/public-consultation/index.js +6 -6
  27. package/dist/sandbox/index.js +4 -4
  28. package/dist/stream/index.js +2 -2
  29. package/dist/teams-react/index.js +3 -3
  30. package/dist/tools/index.js +4 -4
  31. package/dist/web-react/index.js +8 -8
  32. package/dist/work-product/index.js +2 -2
  33. package/package.json +9 -4
  34. /package/dist/{chunk-RACQDXJ7.js.map → chunk-4PZE7XAM.js.map} +0 -0
  35. /package/dist/{chunk-QWYAR2CY.js.map → chunk-5KFRCVAO.js.map} +0 -0
  36. /package/dist/{chunk-KTV5RQBQ.js.map → chunk-5TOV7EDF.js.map} +0 -0
  37. /package/dist/{chunk-TJCTC5QI.js.map → chunk-LDCR7MRU.js.map} +0 -0
  38. /package/dist/{chunk-QJRXKMHJ.js.map → chunk-UNXMIWPK.js.map} +0 -0
  39. /package/dist/{chunk-XFCKMBOC.js.map → chunk-YFGG722I.js.map} +0 -0
  40. /package/dist/{chunk-MX55JP7D.js.map → chunk-ZMMIQOFI.js.map} +0 -0
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  OPENUI_NODE_JSON_SCHEMA,
6
6
  OPENUI_NODE_TYPES
7
- } from "./chunk-RFVTTZPG.js";
7
+ } from "./chunk-CNI46COH.js";
8
8
 
9
9
  // src/tools/openai.ts
10
10
  var APP_TOOL_NAMES = ["submit_proposal", "schedule_followup", "render_ui", "add_citation"];
@@ -112,4 +112,4 @@ export {
112
112
  customToolToOpenAI,
113
113
  findCustomTool
114
114
  };
115
- //# sourceMappingURL=chunk-TJCTC5QI.js.map
115
+ //# sourceMappingURL=chunk-LDCR7MRU.js.map
@@ -33,11 +33,7 @@ import {
33
33
  } from "./chunk-Q3ZHNN5X.js";
34
34
  import {
35
35
  attachmentPartsFromMessageParts
36
- } from "./chunk-RACQDXJ7.js";
37
- import {
38
- parsePlanSubmittedEvent,
39
- persistedPartToPlan
40
- } from "./chunk-YJMCRXQQ.js";
36
+ } from "./chunk-4PZE7XAM.js";
41
37
  import {
42
38
  cancelStatusFor,
43
39
  fieldAcceptsFreeText,
@@ -48,6 +44,10 @@ import {
48
44
  persistedPartToInteraction,
49
45
  questionInteractionContentSignature
50
46
  } from "./chunk-M3K2HVQD.js";
47
+ import {
48
+ parsePlanSubmittedEvent,
49
+ persistedPartToPlan
50
+ } from "./chunk-YJMCRXQQ.js";
51
51
 
52
52
  // src/web-react/index.tsx
53
53
  import { useEffect as useEffect13, useMemo as useMemo7, useRef as useRef12, useState as useState17, memo } from "react";
@@ -7138,4 +7138,4 @@ export {
7138
7138
  useThinkingSeconds,
7139
7139
  ChatMessages
7140
7140
  };
7141
- //# sourceMappingURL=chunk-QJRXKMHJ.js.map
7141
+ //# sourceMappingURL=chunk-UNXMIWPK.js.map
@@ -1,13 +1,13 @@
1
- import {
2
- parseJsonObjectBody
3
- } from "./chunk-3NCPXNBZ.js";
4
1
  import {
5
2
  createInteractionAnswerRoute
6
3
  } from "./chunk-WWFE5EXY.js";
4
+ import {
5
+ parseJsonObjectBody
6
+ } from "./chunk-3NCPXNBZ.js";
7
7
  import {
8
8
  mentionInputToPart,
9
9
  toChatMessageParts
10
- } from "./chunk-RACQDXJ7.js";
10
+ } from "./chunk-4PZE7XAM.js";
11
11
  import {
12
12
  ChatTurnInputError,
13
13
  assertPromptPartsWithinCap,
@@ -1078,4 +1078,4 @@ export {
1078
1078
  createChatTurnRoutes,
1079
1079
  streamChatRouteAsSandboxEvents
1080
1080
  };
1081
- //# sourceMappingURL=chunk-XFCKMBOC.js.map
1081
+ //# sourceMappingURL=chunk-YFGG722I.js.map
@@ -1,13 +1,13 @@
1
+ import {
2
+ canTransitionInteractionStatus,
3
+ persistedPartToInteraction
4
+ } from "./chunk-M3K2HVQD.js";
1
5
  import {
2
6
  canTransitionPlanStatus,
3
7
  persistedPartToPlan,
4
8
  planPartKey,
5
9
  planToPersistedPart
6
10
  } from "./chunk-YJMCRXQQ.js";
7
- import {
8
- canTransitionInteractionStatus,
9
- persistedPartToInteraction
10
- } from "./chunk-M3K2HVQD.js";
11
11
 
12
12
  // src/stream/stream-normalizer.ts
13
13
  function asRecord(value) {
@@ -406,4 +406,4 @@ export {
406
406
  terminalizeDanglingAssistantToolUpdates,
407
407
  encodeEvent
408
408
  };
409
- //# sourceMappingURL=chunk-MX55JP7D.js.map
409
+ //# sourceMappingURL=chunk-ZMMIQOFI.js.map
@@ -1,121 +1,10 @@
1
1
  import {
2
- parseJsonObjectBody
3
- } from "../chunk-3NCPXNBZ.js";
2
+ attachWorkspaceLine,
3
+ createApplicationLineHandler,
4
+ publicApplicationSenderVerification
5
+ } from "../chunk-6RWQ4VW5.js";
6
+ import "../chunk-3NCPXNBZ.js";
4
7
  import "../chunk-TXD5HXLE.js";
5
-
6
- // src/hosted-agent/application.ts
7
- import {
8
- LINE_APPLICATION_REQUEST_MAX_BYTES,
9
- parseLineApplicationRequest,
10
- parseLineApplicationResult
11
- } from "@tangle-network/sandbox/core";
12
-
13
- // src/hosted-agent/workspace-line.ts
14
- async function attachWorkspaceLine(input) {
15
- if (!/^lsv_[A-Za-z0-9_-]+$/.test(input.senderVerificationId)) {
16
- throw new TypeError("A valid sender verification id is required");
17
- }
18
- const verification = await input.ownerLines.getSenderVerification(input.lineId, input.senderVerificationId);
19
- const expiresAt = new Date(verification.expiresAt).getTime();
20
- if (verification.lineId !== input.lineId || verification.testId !== input.senderVerificationId || verification.state !== "verified" || !verification.proof.signedInboundTestAt || !verification.proof.providerReplyAcknowledgedAt || !verification.proof.signedInboundConfirmAt || !Number.isFinite(expiresAt) || expiresAt <= Date.now()) {
21
- throw new TypeError("The selected line has no current verified sender proof");
22
- }
23
- const address = verification.approvedSender?.trim() ?? "";
24
- const turnsPerDay = input.turnsPerDay ?? 20;
25
- if (!/^\+[1-9]\d{6,14}$/.test(address)) {
26
- throw new TypeError("The verified sender must be an E.164 phone number");
27
- }
28
- if (!Number.isSafeInteger(turnsPerDay) || turnsPerDay < 1 || turnsPerDay > 1e4) {
29
- throw new TypeError("A daily turn limit between 1 and 10000 is required");
30
- }
31
- const url = new URL(input.application.url);
32
- if (url.protocol !== "https:" || url.username || url.password || url.hash) {
33
- throw new TypeError("The application callback must use HTTPS without URL credentials or a fragment");
34
- }
35
- if (!/^[\x21-\x7e]{1,1024}$/.test(input.application.binding) || !/^[\x21-\x7e]{16,512}$/.test(input.application.secret)) {
36
- throw new TypeError("A binding and a header-safe callback credential are required");
37
- }
38
- const attachment = {
39
- number: input.lineId,
40
- senderVerificationId: input.senderVerificationId,
41
- mode: "personal",
42
- members: [{ address, role: "owner" }],
43
- unknownSenders: "reject",
44
- roles: { owner: { context: "own", tools: "act" } },
45
- respond: { kind: "agent", application: { ...input.application } },
46
- limits: { turnsPerMemberPerDay: turnsPerDay }
47
- };
48
- return input.box.lines.attach(attachment);
49
- }
50
-
51
- // src/hosted-agent/application-verification.ts
52
- function publicApplicationSenderVerification(result) {
53
- return {
54
- lineId: result.lineId,
55
- testId: result.testId,
56
- state: result.state,
57
- expiresAt: result.expiresAt,
58
- proof: {
59
- signedInboundTestAt: result.proof.signedInboundTestAt,
60
- providerReplyAcknowledgedAt: result.proof.providerReplyAcknowledgedAt,
61
- signedInboundConfirmAt: result.proof.signedInboundConfirmAt
62
- }
63
- };
64
- }
65
-
66
- // src/hosted-agent/application.ts
67
- function createApplicationLineHandler(options) {
68
- return async (request) => {
69
- if (request.method !== "POST") return failure(405, "method_not_allowed");
70
- let authenticated;
71
- try {
72
- authenticated = await options.authenticate(request);
73
- } catch (error) {
74
- return error instanceof Response ? error : failure(503, "line_authentication_unavailable");
75
- }
76
- let input;
77
- try {
78
- if (request.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase() !== "application/json")
79
- return failure(415, "json_required");
80
- const [body, error] = await parseJsonObjectBody(request, { maxBytes: LINE_APPLICATION_REQUEST_MAX_BYTES });
81
- if (error) return error;
82
- input = parseLineApplicationRequest(body);
83
- if (input.binding !== authenticated.binding) return failure(403, "line_binding_mismatch");
84
- if (request.headers.get("idempotency-key") !== `line-application:${input.messageId}`)
85
- return failure(400, "idempotency_key_mismatch");
86
- } catch {
87
- return failure(400, "line_request_invalid");
88
- }
89
- const immutable = Object.freeze({ ...input, sender: Object.freeze({ ...input.sender }) });
90
- try {
91
- const { target } = authenticated;
92
- await options.authorize(target, immutable);
93
- let observed = await options.read(target, immutable);
94
- if (observed.state === "missing") {
95
- if (immutable.acceptedExecutionId !== void 0)
96
- return failure(503, "accepted_execution_unavailable");
97
- await options.authorize(target, immutable);
98
- await options.admit(target, immutable);
99
- observed = await options.read(target, immutable);
100
- if (observed.state === "missing") observed = { state: "pending", admitted: false };
101
- }
102
- await options.authorize(target, immutable);
103
- const result = parseLineApplicationResult({
104
- ...observed,
105
- version: 1,
106
- binding: input.binding,
107
- messageId: input.messageId,
108
- attachmentId: input.attachmentId
109
- }, input);
110
- return Response.json(result, { headers: { "cache-control": "no-store" } });
111
- } catch (error) {
112
- return error instanceof Response ? error : failure(503, "line_application_unavailable");
113
- }
114
- };
115
- }
116
- function failure(status, code) {
117
- return Response.json({ error: { code } }, { status, headers: { "cache-control": "no-store" } });
118
- }
119
8
  export {
120
9
  attachWorkspaceLine,
121
10
  createApplicationLineHandler,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hosted-agent/application.ts","../../src/hosted-agent/workspace-line.ts","../../src/hosted-agent/application-verification.ts"],"sourcesContent":["import { parseJsonObjectBody } from '../web/core'\nimport {\n LINE_APPLICATION_REQUEST_MAX_BYTES,\n parseLineApplicationRequest,\n parseLineApplicationResult,\n type LineApplicationRequest,\n type LineApplicationResult,\n type LineApplicationState,\n} from '@tangle-network/sandbox/core'\n\nexport { attachWorkspaceLine } from './workspace-line'\nexport { publicApplicationSenderVerification } from './application-verification'\nexport type { ApplicationOwnerLines } from './workspace-line'\nexport type { ApplicationSenderVerification, ApplicationSenderVerificationStart, OwnerApplicationSenderVerification } from './application-verification'\n\n/** Missing is an affirmative storage observation, never an error fallback. */\nexport type ApplicationLineObservation = LineApplicationState | { state: 'missing' }\n\nexport interface ApplicationLineOptions<T> {\n /** Authenticate before consuming the body. It must not trust model-supplied identity. */\n authenticate(request: Request): Promise<{ binding: string; target: T }>\n /** Recheck live binding, membership, owner authority and exact retained message. */\n authorize(target: T, input: Readonly<LineApplicationRequest>): Promise<void>\n /** Observe the application's existing durable turn, transcript and outputs. */\n read(target: T, input: Readonly<LineApplicationRequest>): Promise<ApplicationLineObservation>\n /**\n * Enter the normal persisted chat route using input.messageId as its stable\n * client turn identity. That route owns admission, locks and completion.\n * This callback MUST deduplicate that identity across concurrent requests.\n */\n admit(target: T, input: Readonly<LineApplicationRequest>): Promise<void>\n}\n\n/** One bounded pass from the native Lines worker into the application's existing execution path. */\nexport function createApplicationLineHandler<T>(options: ApplicationLineOptions<T>) {\n return async (request: Request): Promise<Response> => {\n if (request.method !== 'POST') return failure(405, 'method_not_allowed')\n let authenticated: { binding: string; target: T }\n try {\n authenticated = await options.authenticate(request)\n } catch (error) {\n return error instanceof Response ? error : failure(503, 'line_authentication_unavailable')\n }\n let input: LineApplicationRequest\n try {\n if (request.headers.get('content-type')?.split(';')[0]?.trim().toLowerCase() !== 'application/json')\n return failure(415, 'json_required')\n const [body, error] = await parseJsonObjectBody(request, { maxBytes: LINE_APPLICATION_REQUEST_MAX_BYTES })\n if (error) return error\n input = parseLineApplicationRequest(body)\n if (input.binding !== authenticated.binding) return failure(403, 'line_binding_mismatch')\n if (request.headers.get('idempotency-key') !== `line-application:${input.messageId}`)\n return failure(400, 'idempotency_key_mismatch')\n } catch {\n return failure(400, 'line_request_invalid')\n }\n // A viewer's AbortSignal must not cancel the accepted application task.\n const immutable = Object.freeze({ ...input, sender: Object.freeze({ ...input.sender }) })\n try {\n const { target } = authenticated\n await options.authorize(target, immutable)\n let observed = await options.read(target, immutable)\n if (observed.state === 'missing') {\n if (immutable.acceptedExecutionId !== undefined)\n return failure(503, 'accepted_execution_unavailable')\n // The read may yield to revocation; check again before admitting work.\n await options.authorize(target, immutable)\n await options.admit(target, immutable)\n observed = await options.read(target, immutable)\n if (observed.state === 'missing') observed = { state: 'pending', admitted: false }\n }\n // Reading or admitting work may yield to a disconnect or member revocation.\n await options.authorize(target, immutable)\n const result: LineApplicationResult = parseLineApplicationResult({\n ...observed, version: 1, binding: input.binding,\n messageId: input.messageId, attachmentId: input.attachmentId,\n }, input)\n return Response.json(result, { headers: { 'cache-control': 'no-store' } })\n } catch (error) {\n // Unavailable authoritative state is not permission to start a new task.\n return error instanceof Response ? error : failure(503, 'line_application_unavailable')\n }\n }\n}\n\nfunction failure(status: number, code: string): Response {\n return Response.json({ error: { code } }, { status, headers: { 'cache-control': 'no-store' } })\n}\n","import type { LineApplication, LineAttachment, SandboxInstance } from '@tangle-network/sandbox/core'\nimport type { OwnerApplicationSenderVerification } from './application-verification'\n\nexport interface ApplicationOwnerLines {\n /** Read with the same owner API key that started TEST and will attach. */\n getSenderVerification(lineId: string, testId: string): Promise<OwnerApplicationSenderVerification>\n}\n\n/** Attach a proved handset to the application's normal chat path. Platform\n * atomically consumes the one-use proof and checks this owner key again. */\nexport async function attachWorkspaceLine(input: {\n box: Pick<SandboxInstance, 'lines'>\n ownerLines: ApplicationOwnerLines\n lineId: string\n senderVerificationId: string\n application: LineApplication\n turnsPerDay?: number\n}): Promise<LineAttachment> {\n if (!/^lsv_[A-Za-z0-9_-]+$/.test(input.senderVerificationId)) {\n throw new TypeError('A valid sender verification id is required')\n }\n const verification = await input.ownerLines.getSenderVerification(input.lineId, input.senderVerificationId)\n const expiresAt = new Date(verification.expiresAt).getTime()\n if (verification.lineId !== input.lineId || verification.testId !== input.senderVerificationId\n || verification.state !== 'verified' || !verification.proof.signedInboundTestAt\n || !verification.proof.providerReplyAcknowledgedAt || !verification.proof.signedInboundConfirmAt\n || !Number.isFinite(expiresAt) || expiresAt <= Date.now()) {\n throw new TypeError('The selected line has no current verified sender proof')\n }\n const address = verification.approvedSender?.trim() ?? ''\n const turnsPerDay = input.turnsPerDay ?? 20\n if (!/^\\+[1-9]\\d{6,14}$/.test(address)) {\n throw new TypeError('The verified sender must be an E.164 phone number')\n }\n if (!Number.isSafeInteger(turnsPerDay) || turnsPerDay < 1 || turnsPerDay > 10_000) {\n throw new TypeError('A daily turn limit between 1 and 10000 is required')\n }\n const url = new URL(input.application.url)\n if (url.protocol !== 'https:' || url.username || url.password || url.hash) {\n throw new TypeError('The application callback must use HTTPS without URL credentials or a fragment')\n }\n if (!/^[\\x21-\\x7e]{1,1024}$/.test(input.application.binding)\n || !/^[\\x21-\\x7e]{16,512}$/.test(input.application.secret)) {\n throw new TypeError('A binding and a header-safe callback credential are required')\n }\n const attachment = {\n number: input.lineId,\n senderVerificationId: input.senderVerificationId,\n mode: 'personal',\n members: [{ address, role: 'owner' }],\n unknownSenders: 'reject',\n roles: { owner: { context: 'own', tools: 'act' } },\n respond: { kind: 'agent', application: { ...input.application } },\n limits: { turnsPerMemberPerDay: turnsPerDay },\n } satisfies Parameters<SandboxInstance['lines']['attach']>[0] & { senderVerificationId: string }\n return input.box.lines.attach(attachment)\n}\n","/** Public TEST data. The private CONFIRM reply is never returned to a browser. */\nexport interface ApplicationSenderVerificationStart {\n lineId: string\n testId: string\n state: 'awaiting_test'\n testText: string\n expiresAt: string\n}\n\n/** Browser-safe status from the owner server. No sender address is present. */\nexport interface ApplicationSenderVerification {\n lineId: string\n testId: string\n state: 'awaiting_test' | 'sending' | 'challenge_sent' | 'verified'\n | 'consumed' | 'cancelled' | 'superseded' | 'failed' | 'expired'\n expiresAt: string\n proof: {\n signedInboundTestAt: string | null\n providerReplyAcknowledgedAt: string | null\n signedInboundConfirmAt: string | null\n }\n}\n\n/** The owner-key SDK read includes the confirmed sender for the attach helper. */\nexport interface OwnerApplicationSenderVerification extends ApplicationSenderVerification {\n approvedSender?: string\n}\n\n/** Use at the host response boundary so approvedSender cannot enter page state. */\nexport function publicApplicationSenderVerification(\n result: OwnerApplicationSenderVerification,\n): ApplicationSenderVerification {\n return {\n lineId: result.lineId,\n testId: result.testId,\n state: result.state,\n expiresAt: result.expiresAt,\n proof: {\n signedInboundTestAt: result.proof.signedInboundTestAt,\n providerReplyAcknowledgedAt: result.proof.providerReplyAcknowledgedAt,\n signedInboundConfirmAt: result.proof.signedInboundConfirmAt,\n },\n }\n}\n"],"m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
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,117 @@
1
+ /** Non-secret API-key setup shapes supported by the Hub SDK. */
2
+ export type HubSettingsApiKeyMetadata = {
3
+ propertyId: string;
4
+ currency?: string;
5
+ } | {
6
+ listings: Array<{
7
+ id: string;
8
+ pms: string;
9
+ }>;
10
+ };
11
+ /** Browser OAuth setup, excluding CLI mode and identity/credential overrides. */
12
+ export interface HubSettingsOAuthInput {
13
+ returnUrl: string;
14
+ connectionParameters?: Record<string, string>;
15
+ }
16
+ type PolicyDecision = 'allow' | 'ask' | 'deny';
17
+ /**
18
+ * Structural subset of the existing SDK, with no execution methods. Keeping
19
+ * this structural avoids imposing a Hub SDK peer on existing platform imports.
20
+ */
21
+ export interface HubSettingsClient {
22
+ connections: {
23
+ providers(): Promise<unknown>;
24
+ list(): Promise<unknown>;
25
+ start(provider: string, input: HubSettingsOAuthInput): Promise<unknown>;
26
+ connectApiKey(provider: string, apiKey: string, metadata?: HubSettingsApiKeyMetadata): Promise<unknown>;
27
+ revoke(connectionId: string): Promise<unknown>;
28
+ health(connectionId: string): Promise<unknown>;
29
+ };
30
+ tools: {
31
+ search(query: string, options: {
32
+ provider: string;
33
+ limit: number;
34
+ }): Promise<unknown>;
35
+ };
36
+ permissions: {
37
+ list(connectionId: string): Promise<unknown>;
38
+ set(input: {
39
+ connectionId: string;
40
+ actionPath: string;
41
+ decision: PolicyDecision;
42
+ }): Promise<unknown>;
43
+ delete(input: {
44
+ connectionId: string;
45
+ actionPath: string;
46
+ }): Promise<unknown>;
47
+ };
48
+ }
49
+ /** Validated, exact intent. The provider API key is deliberately not copied here. */
50
+ export type HubSettingsOperation = {
51
+ readonly operation: 'providers.list' | 'connections.list';
52
+ readonly target: 'caller-account';
53
+ } | {
54
+ readonly operation: 'oauth.start';
55
+ readonly provider: string;
56
+ readonly input: Readonly<HubSettingsOAuthInput>;
57
+ } | {
58
+ readonly operation: 'api-key.connect';
59
+ readonly provider: string;
60
+ readonly metadata?: HubSettingsApiKeyMetadata;
61
+ } | {
62
+ readonly operation: 'connection.revoke' | 'connection.health' | 'policies.list';
63
+ readonly connectionId: string;
64
+ } | {
65
+ readonly operation: 'provider.actions';
66
+ readonly provider: string;
67
+ readonly query: string;
68
+ readonly limit: number;
69
+ } | {
70
+ readonly operation: 'policy.set';
71
+ readonly connectionId: string;
72
+ readonly actionPath: string;
73
+ readonly decision: PolicyDecision;
74
+ } | {
75
+ readonly operation: 'policy.reset';
76
+ readonly connectionId: string;
77
+ readonly actionPath: string;
78
+ };
79
+ /** Server-derived application identity, not fields read from browser input. */
80
+ export interface HubSettingsPrincipal {
81
+ readonly userId: string;
82
+ readonly sessionId: string;
83
+ readonly workspaceId: string;
84
+ }
85
+ export interface HubSettingsGrant {
86
+ readonly authorized: true;
87
+ readonly principal: HubSettingsPrincipal;
88
+ }
89
+ export interface HubSettingsClientBinding {
90
+ readonly client: HubSettingsClient;
91
+ /** Reassert the identity against which the credential was actually resolved. */
92
+ readonly principal: HubSettingsPrincipal;
93
+ /** Never env/admin credentials, another owner's key, or a brokered execution token. */
94
+ readonly credentialSource: 'caller-account';
95
+ }
96
+ export interface HubSettingsContext {
97
+ /** Application-owned mount path, without a trailing slash. Default /api/hub/settings. */
98
+ basePath?: string;
99
+ /**
100
+ * Required on EVERY valid operation, including reads. Validate the current
101
+ * session, CSRF protection, workspace role and exact target/decision here.
102
+ * Return a denial Response or throw the app's auth Response to reject.
103
+ * The body has been consumed; use the validated intent, not request.json().
104
+ * OAuth success, connection ownership/policy, app consent and workspace
105
+ * binding are separate facts. An execution grant is not a settings grant.
106
+ */
107
+ authorize(request: Request, operation: HubSettingsOperation): Promise<HubSettingsGrant | Response>;
108
+ /** Called only after authorization. Resolve the caller's linked account SDK client server-side. */
109
+ resolveClient(principal: HubSettingsPrincipal): Promise<HubSettingsClientBinding>;
110
+ }
111
+ export interface HubSettingsRoutes {
112
+ /** Exact method/path allowlist under basePath; never forwards request headers or arbitrary paths. */
113
+ handle(request: Request): Promise<Response>;
114
+ }
115
+ /** Build a finite Hub settings server boundary; existing Hub proxy routes are unaffected. */
116
+ export declare function createHubSettingsRoutes(ctx: HubSettingsContext): HubSettingsRoutes;
117
+ export {};
@@ -5,6 +5,7 @@
5
5
  */
6
6
  export * from './sso';
7
7
  export * from './hub';
8
+ export * from './hub-settings';
8
9
  export * from './billing';
9
10
  export * from './guards';
10
11
  export * from './api-key-auth';