@tangle-network/agent-app 0.53.16 → 0.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/assistant/index.js +3 -3
  2. package/dist/design-canvas-react/index.js +4 -4
  3. package/dist/teams-react/index.d.ts +1 -2
  4. package/dist/teams-react/index.js +618 -10
  5. package/dist/teams-react/index.js.map +1 -1
  6. package/dist/theme/tailwind-preset.js +4 -1
  7. package/dist/theme/tailwind-preset.js.map +1 -1
  8. package/dist/web-react/index.js +6 -6
  9. package/package.json +1 -31
  10. package/dist/InvitationsPanel-OFCYVSAE.js +0 -9
  11. package/dist/InvitationsPanel-OFCYVSAE.js.map +0 -1
  12. package/dist/InviteAcceptPage-BDOO4JSE.js +0 -7
  13. package/dist/InviteAcceptPage-BDOO4JSE.js.map +0 -1
  14. package/dist/MembersPanel-3ZK2GCMC.js +0 -9
  15. package/dist/MembersPanel-3ZK2GCMC.js.map +0 -1
  16. package/dist/chunk-5MI2SKQH.js +0 -211
  17. package/dist/chunk-5MI2SKQH.js.map +0 -1
  18. package/dist/chunk-AULM4X7U.js +0 -77
  19. package/dist/chunk-AULM4X7U.js.map +0 -1
  20. package/dist/chunk-GRDLGQ6A.js +0 -164
  21. package/dist/chunk-GRDLGQ6A.js.map +0 -1
  22. package/dist/chunk-W7P5KV6O.js +0 -192
  23. package/dist/chunk-W7P5KV6O.js.map +0 -1
  24. package/dist/run/index.d.ts +0 -63
  25. package/dist/run/index.js +0 -30
  26. package/dist/run/index.js.map +0 -1
  27. package/dist/tangle/index.d.ts +0 -94
  28. package/dist/tangle/index.js +0 -33
  29. package/dist/tangle/index.js.map +0 -1
  30. package/dist/teams/resend.d.ts +0 -27
  31. package/dist/teams/resend.js +0 -38
  32. package/dist/teams/resend.js.map +0 -1
  33. package/dist/teams-react/lazy.d.ts +0 -14
  34. package/dist/teams-react/lazy.js +0 -17
  35. package/dist/teams-react/lazy.js.map +0 -1
  36. package/dist/web-react/inert.d.ts +0 -39
  37. package/dist/web-react/session-gateway.d.ts +0 -140
  38. package/dist/web-react/session-gateway.js +0 -187
  39. package/dist/web-react/session-gateway.js.map +0 -1
@@ -1,94 +0,0 @@
1
- /**
2
- * Tangle login + the developer self-service app-registration → broker-token
3
- * flow, for apps built on agent-app.
4
- *
5
- * The platform (agent-dev-container integration hub) lets a developer register
6
- * their client app and obtain a `sk-tan-broker-` bearer to call `/v1/hub/exec`
7
- * on a user's connected integrations — WITHOUT being a hard-coded "trusted app".
8
- * The wire client (`TangleAppsClient` — registerApp / exchangeAuthCode /
9
- * mintBrokerToken) lives in `@tangle-network/agent-integrations`; this module is
10
- * the app-shell layer on top, and is intentionally **structural**: it depends on
11
- * the minter CONTRACT, not the concrete client, so it installs without the
12
- * agent-integrations publish and is trivially testable. A consumer constructs
13
- * the real client and passes it in.
14
- *
15
- * 1. {@link buildConsentUrl} — send the user through the ONE-TIME consent
16
- * (their Tangle session authorizes the app for a connection + scopes).
17
- * 2. On the callback, the consumer's client `exchangeAuthCode`s the `agc_`
18
- * code into the first broker token + a durable grant.
19
- * 3. {@link createBrokerTokenProvider} — the runtime path: each request mints
20
- * a fresh single-use broker token from the durable grant using only app
21
- * credentials (no user session). Neither tokens nor in-flight mint
22
- * promises may be shared between execution attempts.
23
- */
24
- /** A single-use hub bearer minted from a durable grant — mirrors
25
- * `@tangle-network/agent-integrations`'s `BrokerToken`. */
26
- export interface BrokerToken {
27
- /** The `sk-tan-broker-…` bearer for a single `/v1/hub/exec` call. */
28
- accessToken: string;
29
- /** Seconds until expiry. */
30
- expiresIn: number;
31
- scope: string;
32
- connectionId?: string;
33
- }
34
- /** The one method the provider needs — `TangleAppsClient` satisfies it
35
- * structurally, so `createBrokerTokenProvider({ client: tangleAppsClient, … })`
36
- * type-checks without importing the concrete class. */
37
- export interface BrokerTokenMinter {
38
- mintBrokerToken(input: {
39
- clientId: string;
40
- clientSecret: string;
41
- grantId: string;
42
- ttlSeconds?: number;
43
- }): Promise<BrokerToken>;
44
- }
45
- /** Define input parameters required to generate a consent URL for OAuth authorization */
46
- export interface ConsentUrlInput {
47
- /** Platform base URL (e.g. https://id.tangle.tools). */
48
- endpoint: string;
49
- clientId: string;
50
- /** Must match one of the app's registered redirect URIs. */
51
- redirectUri: string;
52
- /** Scopes the app is requesting for this connection (e.g. ['gmail.read']). */
53
- scopes: string[];
54
- /** Opaque CSRF/state value the callback echoes back — verify it on return. */
55
- state: string;
56
- /** Optionally pre-select a specific connection to authorize. */
57
- connectionId?: string;
58
- }
59
- /**
60
- * Build the URL to send the user to for the one-time app-consent. The user's
61
- * Tangle session (not the app's credentials) authorizes it; on approval the
62
- * platform redirects to `redirectUri?code=agc_…&state=…`.
63
- */
64
- export declare function buildConsentUrl(input: ConsentUrlInput): string;
65
- /** Define options for configuring a broker token provider including client credentials and token management settings */
66
- export interface BrokerTokenProviderOptions {
67
- client: BrokerTokenMinter;
68
- clientId: string;
69
- clientSecret: string;
70
- /** The durable grant id from the consent exchange. */
71
- grantId: string;
72
- /** Requested token TTL (seconds). */
73
- ttlSeconds?: number;
74
- /** @deprecated Retained for source compatibility. Single-use tokens are
75
- * never cached, so refresh skew is ignored. */
76
- refreshSkewMs?: number;
77
- /** @deprecated Retained for source compatibility; no local expiry cache. */
78
- now?: () => number;
79
- }
80
- /** Mint a separate single-use bearer for each execution attempt. */
81
- export interface BrokerTokenProvider {
82
- /** Mint a fresh bearer for exactly one Hub execution; never cache or share it. */
83
- getToken(): Promise<string>;
84
- /** Compatibility no-op: no bearer is cached. Does not revoke Hub grants or
85
- * already-issued tokens; revocation belongs to the authoritative Hub. */
86
- invalidate(): void;
87
- }
88
- /**
89
- * Mint a fresh broker token for every call, including concurrent calls.
90
- * A broker bearer is consumed by one Hub execution even when its TTL has not
91
- * expired. Cache the durable grant, never the bearer or an in-flight mint.
92
- * Mint failures propagate; this helper never retries an external action.
93
- */
94
- export declare function createBrokerTokenProvider(opts: BrokerTokenProviderOptions): BrokerTokenProvider;
@@ -1,33 +0,0 @@
1
- // src/tangle/index.ts
2
- function buildConsentUrl(input) {
3
- const base = input.endpoint.replace(/\/+$/, "");
4
- const params = new URLSearchParams({
5
- client_id: input.clientId,
6
- redirect_uri: input.redirectUri,
7
- scope: input.scopes.join(" "),
8
- state: input.state,
9
- response_type: "code"
10
- });
11
- if (input.connectionId) params.set("connection_id", input.connectionId);
12
- return `${base}/cross-site/app-consent?${params.toString()}`;
13
- }
14
- function createBrokerTokenProvider(opts) {
15
- return {
16
- async getToken() {
17
- const token = await opts.client.mintBrokerToken({
18
- clientId: opts.clientId,
19
- clientSecret: opts.clientSecret,
20
- grantId: opts.grantId,
21
- ttlSeconds: opts.ttlSeconds
22
- });
23
- return token.accessToken;
24
- },
25
- invalidate() {
26
- }
27
- };
28
- }
29
- export {
30
- buildConsentUrl,
31
- createBrokerTokenProvider
32
- };
33
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/tangle/index.ts"],"sourcesContent":["/**\n * Tangle login + the developer self-service app-registration → broker-token\n * flow, for apps built on agent-app.\n *\n * The platform (agent-dev-container integration hub) lets a developer register\n * their client app and obtain a `sk-tan-broker-` bearer to call `/v1/hub/exec`\n * on a user's connected integrations — WITHOUT being a hard-coded \"trusted app\".\n * The wire client (`TangleAppsClient` — registerApp / exchangeAuthCode /\n * mintBrokerToken) lives in `@tangle-network/agent-integrations`; this module is\n * the app-shell layer on top, and is intentionally **structural**: it depends on\n * the minter CONTRACT, not the concrete client, so it installs without the\n * agent-integrations publish and is trivially testable. A consumer constructs\n * the real client and passes it in.\n *\n * 1. {@link buildConsentUrl} — send the user through the ONE-TIME consent\n * (their Tangle session authorizes the app for a connection + scopes).\n * 2. On the callback, the consumer's client `exchangeAuthCode`s the `agc_`\n * code into the first broker token + a durable grant.\n * 3. {@link createBrokerTokenProvider} — the runtime path: each request mints\n * a fresh single-use broker token from the durable grant using only app\n * credentials (no user session). Neither tokens nor in-flight mint\n * promises may be shared between execution attempts.\n */\n\n/** A single-use hub bearer minted from a durable grant — mirrors\n * `@tangle-network/agent-integrations`'s `BrokerToken`. */\nexport interface BrokerToken {\n /** The `sk-tan-broker-…` bearer for a single `/v1/hub/exec` call. */\n accessToken: string\n /** Seconds until expiry. */\n expiresIn: number\n scope: string\n connectionId?: string\n}\n\n/** The one method the provider needs — `TangleAppsClient` satisfies it\n * structurally, so `createBrokerTokenProvider({ client: tangleAppsClient, … })`\n * type-checks without importing the concrete class. */\nexport interface BrokerTokenMinter {\n mintBrokerToken(input: { clientId: string; clientSecret: string; grantId: string; ttlSeconds?: number }): Promise<BrokerToken>\n}\n\n/** Define input parameters required to generate a consent URL for OAuth authorization */\nexport interface ConsentUrlInput {\n /** Platform base URL (e.g. https://id.tangle.tools). */\n endpoint: string\n clientId: string\n /** Must match one of the app's registered redirect URIs. */\n redirectUri: string\n /** Scopes the app is requesting for this connection (e.g. ['gmail.read']). */\n scopes: string[]\n /** Opaque CSRF/state value the callback echoes back — verify it on return. */\n state: string\n /** Optionally pre-select a specific connection to authorize. */\n connectionId?: string\n}\n\n/**\n * Build the URL to send the user to for the one-time app-consent. The user's\n * Tangle session (not the app's credentials) authorizes it; on approval the\n * platform redirects to `redirectUri?code=agc_…&state=…`.\n */\nexport function buildConsentUrl(input: ConsentUrlInput): string {\n const base = input.endpoint.replace(/\\/+$/, '')\n const params = new URLSearchParams({\n client_id: input.clientId,\n redirect_uri: input.redirectUri,\n scope: input.scopes.join(' '),\n state: input.state,\n response_type: 'code',\n })\n if (input.connectionId) params.set('connection_id', input.connectionId)\n return `${base}/cross-site/app-consent?${params.toString()}`\n}\n\n/** Define options for configuring a broker token provider including client credentials and token management settings */\nexport interface BrokerTokenProviderOptions {\n client: BrokerTokenMinter\n clientId: string\n clientSecret: string\n /** The durable grant id from the consent exchange. */\n grantId: string\n /** Requested token TTL (seconds). */\n ttlSeconds?: number\n /** @deprecated Retained for source compatibility. Single-use tokens are\n * never cached, so refresh skew is ignored. */\n refreshSkewMs?: number\n /** @deprecated Retained for source compatibility; no local expiry cache. */\n now?: () => number\n}\n\n/** Mint a separate single-use bearer for each execution attempt. */\nexport interface BrokerTokenProvider {\n /** Mint a fresh bearer for exactly one Hub execution; never cache or share it. */\n getToken(): Promise<string>\n /** Compatibility no-op: no bearer is cached. Does not revoke Hub grants or\n * already-issued tokens; revocation belongs to the authoritative Hub. */\n invalidate(): void\n}\n\n/**\n * Mint a fresh broker token for every call, including concurrent calls.\n * A broker bearer is consumed by one Hub execution even when its TTL has not\n * expired. Cache the durable grant, never the bearer or an in-flight mint.\n * Mint failures propagate; this helper never retries an external action.\n */\nexport function createBrokerTokenProvider(opts: BrokerTokenProviderOptions): BrokerTokenProvider {\n return {\n async getToken() {\n const token = await opts.client.mintBrokerToken({\n clientId: opts.clientId,\n clientSecret: opts.clientSecret,\n grantId: opts.grantId,\n ttlSeconds: opts.ttlSeconds,\n })\n return token.accessToken\n },\n invalidate() {\n // No cached bearer to clear. Keep this method for existing callers.\n },\n }\n}\n"],"mappings":";AA8DO,SAAS,gBAAgB,OAAgC;AAC9D,QAAM,OAAO,MAAM,SAAS,QAAQ,QAAQ,EAAE;AAC9C,QAAM,SAAS,IAAI,gBAAgB;AAAA,IACjC,WAAW,MAAM;AAAA,IACjB,cAAc,MAAM;AAAA,IACpB,OAAO,MAAM,OAAO,KAAK,GAAG;AAAA,IAC5B,OAAO,MAAM;AAAA,IACb,eAAe;AAAA,EACjB,CAAC;AACD,MAAI,MAAM,aAAc,QAAO,IAAI,iBAAiB,MAAM,YAAY;AACtE,SAAO,GAAG,IAAI,2BAA2B,OAAO,SAAS,CAAC;AAC5D;AAiCO,SAAS,0BAA0B,MAAuD;AAC/F,SAAO;AAAA,IACL,MAAM,WAAW;AACf,YAAM,QAAQ,MAAM,KAAK,OAAO,gBAAgB;AAAA,QAC9C,UAAU,KAAK;AAAA,QACf,cAAc,KAAK;AAAA,QACnB,SAAS,KAAK;AAAA,QACd,YAAY,KAAK;AAAA,MACnB,CAAC;AACD,aAAO,MAAM;AAAA,IACf;AAAA,IACA,aAAa;AAAA,IAEb;AAAA,EACF;AACF;","names":[]}
@@ -1,27 +0,0 @@
1
- /**
2
- * Opt-in Resend transport for the teams invitations `sendInvitationEmail` seam.
3
- * Most adopters back the seam with Resend and hand-roll the same wrapper — and
4
- * the same mistake: `resend.emails.send()` returns `{ data, error }` and does NOT
5
- * throw on an API-level failure (unverified domain, rate limit, bad recipient),
6
- * so a `try/catch` alone records a failed send as a success. This helper sends
7
- * through the shared `renderInvitationEmail` template and returns a typed failure
8
- * on BOTH a thrown error AND a non-null `result.error`.
9
- *
10
- * `resend` is an OPTIONAL peer, imported only here: apps not on Resend keep
11
- * passing a raw seam, and the package core never pulls a mail dependency.
12
- */
13
- import type { SendInvitationEmailSeam } from './invitations-api';
14
- /** Define options for sending a resend invitation including sender address and optional API key */
15
- export interface ResendInvitationSenderOptions {
16
- /** RFC-5322 From header, e.g. `GTM Agent <noreply@gtm.tangle.tools>`. */
17
- from: string;
18
- /** Resend API key. Defaults to `process.env.RESEND_API_KEY`. */
19
- apiKey?: string;
20
- }
21
- /**
22
- * Build a `sendInvitationEmail` seam backed by Resend. Wire it into
23
- * `createInvitationsApi({ sendInvitationEmail: createResendInvitationSender({ from }) })`.
24
- * The client is built lazily on first send; with no key the seam fails typed
25
- * (the invitation is still created — emailStatus becomes 'failed').
26
- */
27
- export declare function createResendInvitationSender(opts: ResendInvitationSenderOptions): SendInvitationEmailSeam;
@@ -1,38 +0,0 @@
1
- import {
2
- renderInvitationEmail
3
- } from "../chunk-2DRYTJHI.js";
4
-
5
- // src/teams/resend.ts
6
- import { Resend } from "resend";
7
- function createResendInvitationSender(opts) {
8
- let client = null;
9
- function getClient() {
10
- if (client) return client;
11
- const key = opts.apiKey ?? (typeof process !== "undefined" ? process.env.RESEND_API_KEY : void 0);
12
- if (!key) return null;
13
- client = new Resend(key);
14
- return client;
15
- }
16
- return async (input) => {
17
- const resend = getClient();
18
- if (!resend) return { succeeded: false, error: "RESEND_API_KEY is not configured" };
19
- const msg = renderInvitationEmail(input, { fromAddress: opts.from });
20
- try {
21
- const result = await resend.emails.send({
22
- from: msg.from,
23
- to: input.to,
24
- subject: msg.subject,
25
- html: msg.html,
26
- text: msg.text
27
- });
28
- if (result.error) return { succeeded: false, error: result.error.message };
29
- return { succeeded: true };
30
- } catch (err) {
31
- return { succeeded: false, error: err instanceof Error ? err.message : "Invitation email failed to send" };
32
- }
33
- };
34
- }
35
- export {
36
- createResendInvitationSender
37
- };
38
- //# sourceMappingURL=resend.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/teams/resend.ts"],"sourcesContent":["/**\n * Opt-in Resend transport for the teams invitations `sendInvitationEmail` seam.\n * Most adopters back the seam with Resend and hand-roll the same wrapper — and\n * the same mistake: `resend.emails.send()` returns `{ data, error }` and does NOT\n * throw on an API-level failure (unverified domain, rate limit, bad recipient),\n * so a `try/catch` alone records a failed send as a success. This helper sends\n * through the shared `renderInvitationEmail` template and returns a typed failure\n * on BOTH a thrown error AND a non-null `result.error`.\n *\n * `resend` is an OPTIONAL peer, imported only here: apps not on Resend keep\n * passing a raw seam, and the package core never pulls a mail dependency.\n */\n\nimport { Resend } from 'resend'\nimport { renderInvitationEmail } from './invitations'\nimport type { SendInvitationEmailSeam } from './invitations-api'\n\n/** Define options for sending a resend invitation including sender address and optional API key */\nexport interface ResendInvitationSenderOptions {\n /** RFC-5322 From header, e.g. `GTM Agent <noreply@gtm.tangle.tools>`. */\n from: string\n /** Resend API key. Defaults to `process.env.RESEND_API_KEY`. */\n apiKey?: string\n}\n\n/**\n * Build a `sendInvitationEmail` seam backed by Resend. Wire it into\n * `createInvitationsApi({ sendInvitationEmail: createResendInvitationSender({ from }) })`.\n * The client is built lazily on first send; with no key the seam fails typed\n * (the invitation is still created — emailStatus becomes 'failed').\n */\nexport function createResendInvitationSender(opts: ResendInvitationSenderOptions): SendInvitationEmailSeam {\n let client: Resend | null = null\n\n function getClient(): Resend | null {\n if (client) return client\n const key = opts.apiKey ?? (typeof process !== 'undefined' ? process.env.RESEND_API_KEY : undefined)\n if (!key) return null\n client = new Resend(key)\n return client\n }\n\n return async (input) => {\n const resend = getClient()\n if (!resend) return { succeeded: false, error: 'RESEND_API_KEY is not configured' }\n\n const msg = renderInvitationEmail(input, { fromAddress: opts.from })\n try {\n const result = await resend.emails.send({\n from: msg.from,\n to: input.to,\n subject: msg.subject,\n html: msg.html,\n text: msg.text,\n })\n // Resend reports API-level failures in `result.error` WITHOUT throwing — a\n // try/catch alone would mark a failed send as a success.\n if (result.error) return { succeeded: false, error: result.error.message }\n return { succeeded: true }\n } catch (err) {\n return { succeeded: false, error: err instanceof Error ? err.message : 'Invitation email failed to send' }\n }\n }\n}\n"],"mappings":";;;;;AAaA,SAAS,cAAc;AAkBhB,SAAS,6BAA6B,MAA8D;AACzG,MAAI,SAAwB;AAE5B,WAAS,YAA2B;AAClC,QAAI,OAAQ,QAAO;AACnB,UAAM,MAAM,KAAK,WAAW,OAAO,YAAY,cAAc,QAAQ,IAAI,iBAAiB;AAC1F,QAAI,CAAC,IAAK,QAAO;AACjB,aAAS,IAAI,OAAO,GAAG;AACvB,WAAO;AAAA,EACT;AAEA,SAAO,OAAO,UAAU;AACtB,UAAM,SAAS,UAAU;AACzB,QAAI,CAAC,OAAQ,QAAO,EAAE,WAAW,OAAO,OAAO,mCAAmC;AAElF,UAAM,MAAM,sBAAsB,OAAO,EAAE,aAAa,KAAK,KAAK,CAAC;AACnE,QAAI;AACF,YAAM,SAAS,MAAM,OAAO,OAAO,KAAK;AAAA,QACtC,MAAM,IAAI;AAAA,QACV,IAAI,MAAM;AAAA,QACV,SAAS,IAAI;AAAA,QACb,MAAM,IAAI;AAAA,QACV,MAAM,IAAI;AAAA,MACZ,CAAC;AAGD,UAAI,OAAO,MAAO,QAAO,EAAE,WAAW,OAAO,OAAO,OAAO,MAAM,QAAQ;AACzE,aAAO,EAAE,WAAW,KAAK;AAAA,IAC3B,SAAS,KAAK;AACZ,aAAO,EAAE,WAAW,OAAO,OAAO,eAAe,QAAQ,IAAI,UAAU,kCAAkC;AAAA,IAC3G;AAAA,EACF;AACF;","names":[]}
@@ -1,14 +0,0 @@
1
- /**
2
- * Code-split entries for the teams React surface. Products that don't need the
3
- * members UI on initial load import these `React.lazy` handles instead of the
4
- * components directly, so the panel/page chunks load on first render. Mount
5
- * inside a `<Suspense>` boundary; the product provides the fallback.
6
- */
7
- import type { MembersPanelProps, InvitationsPanelProps, InviteAcceptPageProps } from './contracts';
8
- export type { MembersPanelProps, InvitationsPanelProps, InviteAcceptPageProps };
9
- /** Load MembersPanel component lazily to optimize initial rendering performance */
10
- export declare const MembersPanelLazy: import("react").LazyExoticComponent<typeof import("./components").MembersPanel>;
11
- /** Load InvitationsPanel component lazily to optimize initial rendering performance */
12
- export declare const InvitationsPanelLazy: import("react").LazyExoticComponent<typeof import("./components").InvitationsPanel>;
13
- /** Load InviteAcceptPage component lazily for optimized code splitting and performance */
14
- export declare const InviteAcceptPageLazy: import("react").LazyExoticComponent<typeof import("./components").InviteAcceptPage>;
@@ -1,17 +0,0 @@
1
- // src/teams-react/lazy.tsx
2
- import { lazy } from "react";
3
- var MembersPanelLazy = lazy(
4
- () => import("../MembersPanel-3ZK2GCMC.js").then((m) => ({ default: m.MembersPanel }))
5
- );
6
- var InvitationsPanelLazy = lazy(
7
- () => import("../InvitationsPanel-OFCYVSAE.js").then((m) => ({ default: m.InvitationsPanel }))
8
- );
9
- var InviteAcceptPageLazy = lazy(
10
- () => import("../InviteAcceptPage-BDOO4JSE.js").then((m) => ({ default: m.InviteAcceptPage }))
11
- );
12
- export {
13
- InvitationsPanelLazy,
14
- InviteAcceptPageLazy,
15
- MembersPanelLazy
16
- };
17
- //# sourceMappingURL=lazy.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/teams-react/lazy.tsx"],"sourcesContent":["/**\n * Code-split entries for the teams React surface. Products that don't need the\n * members UI on initial load import these `React.lazy` handles instead of the\n * components directly, so the panel/page chunks load on first render. Mount\n * inside a `<Suspense>` boundary; the product provides the fallback.\n */\n\nimport { lazy } from 'react'\nimport type { MembersPanelProps, InvitationsPanelProps, InviteAcceptPageProps } from './contracts'\n\nexport type { MembersPanelProps, InvitationsPanelProps, InviteAcceptPageProps }\n\n/** Load MembersPanel component lazily to optimize initial rendering performance */\nexport const MembersPanelLazy = lazy(\n () => import('./components/MembersPanel').then((m) => ({ default: m.MembersPanel })),\n)\n\n/** Load InvitationsPanel component lazily to optimize initial rendering performance */\nexport const InvitationsPanelLazy = lazy(\n () => import('./components/InvitationsPanel').then((m) => ({ default: m.InvitationsPanel })),\n)\n\n/** Load InviteAcceptPage component lazily for optimized code splitting and performance */\nexport const InviteAcceptPageLazy = lazy(\n () => import('./components/InviteAcceptPage').then((m) => ({ default: m.InviteAcceptPage })),\n)\n"],"mappings":";AAOA,SAAS,YAAY;AAMd,IAAM,mBAAmB;AAAA,EAC9B,MAAM,OAAO,6BAA2B,EAAE,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE;AACrF;AAGO,IAAM,uBAAuB;AAAA,EAClC,MAAM,OAAO,iCAA+B,EAAE,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE;AAC7F;AAGO,IAAM,uBAAuB;AAAA,EAClC,MAAM,OAAO,iCAA+B,EAAE,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE;AAC7F;","names":[]}
@@ -1,39 +0,0 @@
1
- /**
2
- * `inert`, across the React versions this package's peer range admits.
3
- *
4
- * MEASURED, not reasoned. `react` + `react-dom` 18.3.1 and 19.2.8, each
5
- * rendering `<div inert={…}>x</div>` through `renderToStaticMarkup`, and the
6
- * same four cases re-read as `outerHTML` after `createRoot().render` — server
7
- * and client agreed on every row:
8
- *
9
- * | prop | React 18.3.1 | React 19.2.8 |
10
- * | --------------- | ------------------------------- | ------------------------------- |
11
- * | `inert={false}` | `<div>x</div>` — NO attribute | `<div>x</div>` — NO attribute |
12
- * | `inert={''}` | `<div inert="">x</div>` — inert | `<div>x</div>` — NO attribute |
13
- * | `inert={true}` | `<div>x</div>` — NO attribute | `<div inert="">x</div>` — inert |
14
- * | `inert={'1'}` | `<div inert="1">x</div>` — inert | `<div inert="">x</div>` — inert |
15
- *
16
- * React 18 warns on the two it drops (`Received \`false\`/\`true\` for a
17
- * non-boolean attribute \`inert\`.`); React 19 warns on the one it drops
18
- * (`Received an empty string for a boolean attribute \`inert\`.`).
19
- *
20
- * So the FALSE case needs no help: both majors already emit nothing, and a
21
- * plain `inert={!open}` binding never made an open panel inert on either. The
22
- * TRUE case is the defect — `true` is dropped by 18 and `''` is dropped by 19,
23
- * so a plain boolean binding leaves a COLLAPSED panel focusable and
24
- * screen-reader readable on React 18, which `peerDependencies` (`react >=18`)
25
- * admits.
26
- *
27
- * The last row is the answer, and it is why this file no longer detects
28
- * anything. `inert` is an HTML boolean attribute: its PRESENCE is what makes an
29
- * element inert, whatever the value reads. A non-empty string is emitted by
30
- * both majors, warned about by neither, and inert on both — so there is one
31
- * spelling and no branch.
32
- */
33
- /**
34
- * Props that make an element inert when `inert` is true, and nothing at all
35
- * when it is false.
36
- */
37
- export declare function inertProps(inert: boolean): {
38
- inert?: boolean;
39
- };
@@ -1,140 +0,0 @@
1
- /**
2
- * Browser adapter for the Sandbox session gateway.
3
- *
4
- * The Sandbox SDK owns the WebSocket, reconnect, replay, cursor persistence,
5
- * and raw event delivery. This module only composes that client with a
6
- * product-owned grant endpoint and decodes the gateway's event envelope.
7
- *
8
- * Keep this entry separate from `web-react`: `@tangle-network/sandbox` is an
9
- * optional peer, and the dynamic import keeps it out of apps without a
10
- * sandbox-backed session.
11
- */
12
- /** A short-lived, read-only grant for one session's gateway stream. */
13
- export interface SessionStreamGrant {
14
- /** `wss://…/session`, resolved by the product server. */
15
- url: string;
16
- /** Read-only JWT. A browser must never receive a Sandbox API key. */
17
- token: string;
18
- /** Browser-facing session channel selected by the product. */
19
- sessionId: string;
20
- /** Unix seconds, as expected by the SDK token refresher. */
21
- expiresAt: number;
22
- }
23
- /** Common soft-miss reasons a product grant route may report. */
24
- export type SessionGrantUnavailableReason = 'sandbox-absent' | 'sandbox-not-running' | 'session-absent' | 'gateway-unreachable' | 'mint-failed';
25
- /** The grant endpoint response accepted by {@link parseSessionStreamGrant}. */
26
- export type SessionStreamGrantResponse = ({
27
- available: true;
28
- } & SessionStreamGrant) | {
29
- available: false;
30
- reason?: SessionGrantUnavailableReason;
31
- };
32
- /** A decoded event from the raw Sandbox gateway payload. */
33
- export interface GatewayTurnEvent {
34
- type: string;
35
- data?: Record<string, unknown>;
36
- }
37
- /** Event types that terminate a Sandbox execution. */
38
- export declare const GATEWAY_TERMINAL_EVENT_TYPES: ReadonlySet<string>;
39
- /** Gateway bookkeeping events that are not turn feedback. */
40
- export declare const GATEWAY_TRANSPORT_NOTICE_TYPES: ReadonlySet<string>;
41
- /** Report whether a decoded event ends the execution. */
42
- export declare function isTerminalGatewayEvent(type: string): boolean;
43
- /** Report whether a decoded event is gateway bookkeeping. */
44
- export declare function isGatewayTransportNotice(type: string): boolean;
45
- /**
46
- * Decode one raw `onAgentEvent` payload into the event shape a turn reducer
47
- * consumes. The gateway carries both message-lane and run/stream envelopes.
48
- */
49
- export declare function gatewayFrameToTurnEvent(raw: unknown): GatewayTurnEvent | null;
50
- /** Parse a grant response. Invalid or unavailable responses are soft misses. */
51
- export declare function parseSessionStreamGrant(body: unknown): SessionStreamGrant | null;
52
- /** Options for a product-owned grant fetcher. */
53
- export interface SessionStreamGrantFetcherOptions {
54
- /** Endpoint URL, or a function that receives the product scope id. */
55
- url: string | ((scopeId: string) => string);
56
- scopeId: string;
57
- /** Injectable for tests or a product-specific fetch wrapper. */
58
- fetchImpl?: typeof fetch;
59
- /** For example, `{ credentials: 'include' }` on a cross-origin endpoint. */
60
- requestInit?: RequestInit;
61
- }
62
- /**
63
- * Build a grant fetcher that never throws. A grant route is an optional live
64
- * lane, so auth misses, network failures, and malformed bodies fall back to
65
- * the product's durable lane.
66
- */
67
- export declare function createSessionStreamGrantFetcher(options: SessionStreamGrantFetcherOptions): (signal: AbortSignal) => Promise<SessionStreamGrant | null>;
68
- /** Minimal structural surface of the SDK session gateway client. */
69
- export interface SessionGatewayClientLike {
70
- connect(): void;
71
- disconnect(): void;
72
- replay(since: number): void | Promise<void>;
73
- clearReplayState(): void;
74
- }
75
- /** Structural replay storage accepted by the SDK client. */
76
- export interface ReplayCursorStorage {
77
- getItem(key: string): string | null;
78
- setItem(key: string, value: string): void;
79
- removeItem(key: string): void;
80
- }
81
- /** Subset of the SDK client configuration used by this adapter. */
82
- export interface SessionGatewayClientConfigLike {
83
- url: string;
84
- token: string;
85
- sessionId: string;
86
- autoReconnect?: boolean;
87
- enableReplayPersistence?: boolean;
88
- replayStorage?: ReplayCursorStorage;
89
- onTokenRefresh?: () => Promise<{
90
- token: string;
91
- expiresAt: number;
92
- }>;
93
- handlers?: {
94
- onAgentEvent?: (channel: string, data: unknown, sequenceId?: number) => void;
95
- onBackpressureWarning?: (dropped: number, since: number, totalDropped?: number) => void;
96
- onTokenExpired?: () => void;
97
- onError?: (message: string, code?: string) => void;
98
- };
99
- }
100
- /** Injectable SDK-client constructor, used for tests and alternate transports. */
101
- export type SessionGatewayClientFactory = (config: SessionGatewayClientConfigLike) => SessionGatewayClientLike | Promise<SessionGatewayClientLike>;
102
- /** Callbacks driven by one live gateway attachment. */
103
- export interface SessionGatewayLiveViewHandlers {
104
- signal: AbortSignal;
105
- /** Every non-duplicate, non-transport event. */
106
- onEvent: (event: GatewayTurnEvent) => void;
107
- /** Called after the first real turn event, not a gateway notice. */
108
- onFirstTurnEvent?: () => void;
109
- /** Called for each terminal turn event. */
110
- onTerminal?: () => void;
111
- /** Called when an attached lane becomes unusable. */
112
- onUnusable?: (reason: string) => void;
113
- }
114
- /** A handle that stops one gateway attachment. */
115
- export interface SessionGatewayLiveViewAttachment {
116
- close(): void;
117
- }
118
- /** Structural connector returned by {@link createSessionGatewayLane}. */
119
- export type SessionGatewayLiveViewConnector = (handlers: SessionGatewayLiveViewHandlers) => Promise<SessionGatewayLiveViewAttachment | null>;
120
- /** Options for {@link createSessionGatewayLane}. */
121
- export interface SessionGatewayLaneOptions {
122
- /** Mint a grant. `null` is a soft miss with no attachable live stream. */
123
- fetchGrant(signal: AbortSignal): Promise<SessionStreamGrant | null>;
124
- /** Replay cursor storage. Defaults to `window.localStorage`; `null` disables it. */
125
- replayStorage?: ReplayCursorStorage | null;
126
- /** Override the SDK client constructor for tests or another compatible client. */
127
- createClient?: SessionGatewayClientFactory;
128
- /** Maximum sequence ids retained for duplicate suppression. */
129
- appliedSeqCap?: number;
130
- }
131
- /** Default bound on applied sequence ids retained by one attachment. */
132
- export declare const APPLIED_SEQ_CAP = 100000;
133
- /**
134
- * Build a browser-direct Sandbox live-view connector.
135
- *
136
- * The caller supplies a product-authenticated grant fetcher and owns the
137
- * transcript reducer. A missing grant returns `null`, allowing a durable
138
- * replay lane to take over without changing the turn.
139
- */
140
- export declare function createSessionGatewayLane(options: SessionGatewayLaneOptions): SessionGatewayLiveViewConnector;
@@ -1,187 +0,0 @@
1
- // src/web-react/session-gateway.ts
2
- var GATEWAY_TERMINAL_EVENT_TYPES = /* @__PURE__ */ new Set([
3
- "done",
4
- "error",
5
- "result",
6
- "session.run.completed",
7
- "session.run.failed"
8
- ]);
9
- var GATEWAY_TRANSPORT_NOTICE_TYPES = /* @__PURE__ */ new Set([
10
- "connection.established",
11
- "heartbeat",
12
- "ping",
13
- "pong"
14
- ]);
15
- function isTerminalGatewayEvent(type) {
16
- return GATEWAY_TERMINAL_EVENT_TYPES.has(type);
17
- }
18
- function isGatewayTransportNotice(type) {
19
- return GATEWAY_TRANSPORT_NOTICE_TYPES.has(type);
20
- }
21
- function isRecord(value) {
22
- return !!value && typeof value === "object" && !Array.isArray(value);
23
- }
24
- function gatewayFrameToTurnEvent(raw) {
25
- if (!isRecord(raw)) return null;
26
- const type = typeof raw.type === "string" ? raw.type.trim() : "";
27
- if (type) {
28
- const { type: _ignored, properties, ...rest } = raw;
29
- return { type, data: isRecord(properties) ? properties : rest };
30
- }
31
- if (isRecord(raw.outcome) || typeof raw.outcome === "string") {
32
- return { type: "done", data: raw };
33
- }
34
- return null;
35
- }
36
- function parseSessionStreamGrant(body) {
37
- if (!isRecord(body) || body.available !== true) return null;
38
- const { url, token, sessionId, expiresAt } = body;
39
- if (typeof url !== "string" || !url.trim() || !isWebSocketUrl(url) || typeof token !== "string" || !token.trim() || typeof sessionId !== "string" || !sessionId.trim() || typeof expiresAt !== "number" || !Number.isFinite(expiresAt) || expiresAt < 0) {
40
- return null;
41
- }
42
- return { url, token, sessionId, expiresAt };
43
- }
44
- function isWebSocketUrl(value) {
45
- try {
46
- const protocol = new URL(value).protocol;
47
- return protocol === "ws:" || protocol === "wss:";
48
- } catch {
49
- return false;
50
- }
51
- }
52
- function createSessionStreamGrantFetcher(options) {
53
- const fetchImpl = options.fetchImpl ?? fetch;
54
- return async (signal) => {
55
- try {
56
- const url = typeof options.url === "function" ? options.url(options.scopeId) : options.url;
57
- const response = await fetchImpl(url, {
58
- ...options.requestInit,
59
- signal
60
- });
61
- if (!response.ok) return null;
62
- return parseSessionStreamGrant(await response.json());
63
- } catch {
64
- return null;
65
- }
66
- };
67
- }
68
- var APPLIED_SEQ_CAP = 1e5;
69
- async function defaultCreateClient(config) {
70
- const module = await import("@tangle-network/sandbox/session-gateway");
71
- return new module.SessionGatewayClient(config);
72
- }
73
- function defaultReplayStorage() {
74
- try {
75
- return typeof window !== "undefined" && window.localStorage ? window.localStorage : void 0;
76
- } catch {
77
- return void 0;
78
- }
79
- }
80
- function createSessionGatewayLane(options) {
81
- const cap = options.appliedSeqCap ?? APPLIED_SEQ_CAP;
82
- const createClient = options.createClient ?? defaultCreateClient;
83
- return async (handlers) => {
84
- let grant;
85
- try {
86
- grant = await options.fetchGrant(handlers.signal);
87
- } catch {
88
- return null;
89
- }
90
- if (!grant || handlers.signal.aborted) return null;
91
- const appliedSeqs = /* @__PURE__ */ new Set();
92
- let firstTurnEventSent = false;
93
- let closed = false;
94
- let client;
95
- const replayStorage = options.replayStorage === null ? void 0 : options.replayStorage ?? defaultReplayStorage();
96
- const config = {
97
- url: grant.url,
98
- token: grant.token,
99
- sessionId: grant.sessionId,
100
- autoReconnect: true,
101
- ...replayStorage ? { enableReplayPersistence: true, replayStorage } : {},
102
- onTokenRefresh: async () => {
103
- const refreshed = await options.fetchGrant(handlers.signal);
104
- if (!refreshed) throw new Error("stream token refresh unavailable");
105
- return { token: refreshed.token, expiresAt: refreshed.expiresAt };
106
- },
107
- handlers: {
108
- onAgentEvent: (_channel, data, sequenceId) => {
109
- if (closed) return;
110
- if (typeof sequenceId === "number" && Number.isSafeInteger(sequenceId) && sequenceId >= 0) {
111
- if (appliedSeqs.has(sequenceId)) return;
112
- if (appliedSeqs.size < cap) appliedSeqs.add(sequenceId);
113
- }
114
- const event = gatewayFrameToTurnEvent(data);
115
- if (!event || isGatewayTransportNotice(event.type)) return;
116
- if (!firstTurnEventSent) {
117
- firstTurnEventSent = true;
118
- handlers.onFirstTurnEvent?.();
119
- }
120
- handlers.onEvent(event);
121
- if (isTerminalGatewayEvent(event.type)) handlers.onTerminal?.();
122
- },
123
- onBackpressureWarning: (_dropped, since) => {
124
- if (closed) return;
125
- try {
126
- const replay = client.replay(since);
127
- if (replay && typeof replay.then === "function") {
128
- void replay.catch((error) => {
129
- if (!closed) {
130
- handlers.onUnusable?.(
131
- `replay failed: ${error instanceof Error ? error.message : String(error)}`
132
- );
133
- }
134
- });
135
- }
136
- } catch (error) {
137
- handlers.onUnusable?.(
138
- `replay failed: ${error instanceof Error ? error.message : String(error)}`
139
- );
140
- }
141
- },
142
- onTokenExpired: () => {
143
- if (!closed) handlers.onUnusable?.("token expired");
144
- },
145
- onError: (message, code) => {
146
- if (!closed) handlers.onUnusable?.(code ? `${code}: ${message}` : message);
147
- }
148
- }
149
- };
150
- try {
151
- client = await createClient(config);
152
- } catch {
153
- return null;
154
- }
155
- if (handlers.signal.aborted) {
156
- client.disconnect();
157
- return null;
158
- }
159
- try {
160
- client.connect();
161
- } catch {
162
- client.disconnect();
163
- return null;
164
- }
165
- return {
166
- close: () => {
167
- if (closed) return;
168
- closed = true;
169
- appliedSeqs.clear();
170
- client.clearReplayState();
171
- client.disconnect();
172
- }
173
- };
174
- };
175
- }
176
- export {
177
- APPLIED_SEQ_CAP,
178
- GATEWAY_TERMINAL_EVENT_TYPES,
179
- GATEWAY_TRANSPORT_NOTICE_TYPES,
180
- createSessionGatewayLane,
181
- createSessionStreamGrantFetcher,
182
- gatewayFrameToTurnEvent,
183
- isGatewayTransportNotice,
184
- isTerminalGatewayEvent,
185
- parseSessionStreamGrant
186
- };
187
- //# sourceMappingURL=session-gateway.js.map