@stigmer/sdk 3.1.7 → 3.1.9

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 (58) hide show
  1. package/__tests__/errors.test.js +42 -0
  2. package/__tests__/errors.test.js.map +1 -1
  3. package/__tests__/guest-auth.test.d.ts +2 -0
  4. package/__tests__/guest-auth.test.d.ts.map +1 -0
  5. package/__tests__/guest-auth.test.js +223 -0
  6. package/__tests__/guest-auth.test.js.map +1 -0
  7. package/__tests__/sharing.test.d.ts +2 -0
  8. package/__tests__/sharing.test.d.ts.map +1 -0
  9. package/__tests__/sharing.test.js +106 -0
  10. package/__tests__/sharing.test.js.map +1 -0
  11. package/gen/agentshare.d.ts +45 -0
  12. package/gen/agentshare.d.ts.map +1 -0
  13. package/gen/agentshare.js +142 -0
  14. package/gen/agentshare.js.map +1 -0
  15. package/gen/authorization-config.d.ts.map +1 -1
  16. package/gen/authorization-config.js +1 -0
  17. package/gen/authorization-config.js.map +1 -1
  18. package/gen/client.d.ts +4 -0
  19. package/gen/client.d.ts.map +1 -1
  20. package/gen/client.js +4 -0
  21. package/gen/client.js.map +1 -1
  22. package/gen/environment.d.ts +2 -0
  23. package/gen/environment.d.ts.map +1 -1
  24. package/gen/environment.js +8 -0
  25. package/gen/environment.js.map +1 -1
  26. package/gen/platformclient.d.ts +2 -1
  27. package/gen/platformclient.d.ts.map +1 -1
  28. package/gen/platformclient.js +8 -0
  29. package/gen/platformclient.js.map +1 -1
  30. package/gen/session.d.ts +2 -2
  31. package/gen/session.d.ts.map +1 -1
  32. package/gen/session.js +2 -2
  33. package/gen/session.js.map +1 -1
  34. package/guest-auth.d.ts +175 -0
  35. package/guest-auth.d.ts.map +1 -0
  36. package/guest-auth.js +227 -0
  37. package/guest-auth.js.map +1 -0
  38. package/index.d.ts +3 -0
  39. package/index.d.ts.map +1 -1
  40. package/index.js +5 -0
  41. package/index.js.map +1 -1
  42. package/package.json +2 -2
  43. package/sharing.d.ts +76 -0
  44. package/sharing.d.ts.map +1 -0
  45. package/sharing.js +117 -0
  46. package/sharing.js.map +1 -0
  47. package/src/__tests__/errors.test.ts +56 -0
  48. package/src/__tests__/guest-auth.test.ts +287 -0
  49. package/src/__tests__/sharing.test.ts +159 -0
  50. package/src/gen/agentshare.ts +148 -0
  51. package/src/gen/authorization-config.ts +1 -0
  52. package/src/gen/client.ts +5 -0
  53. package/src/gen/environment.ts +7 -1
  54. package/src/gen/platformclient.ts +7 -1
  55. package/src/gen/session.ts +3 -3
  56. package/src/guest-auth.ts +334 -0
  57. package/src/index.ts +25 -0
  58. package/src/sharing.ts +135 -0
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Minimal persistence contract for the visitor's guest id.
3
+ *
4
+ * Matches the subset of the Web Storage API that {@link GuestAuth}
5
+ * needs, so `localStorage` satisfies it directly. Inject a custom
6
+ * implementation for non-browser environments or tests.
7
+ */
8
+ export interface GuestIdStorage {
9
+ getItem(key: string): string | null;
10
+ setItem(key: string, value: string): void;
11
+ }
12
+ /**
13
+ * Configuration for a guest token-minting helper.
14
+ *
15
+ * Unlike {@link PlatformClientAuthConfig}, this carries **no
16
+ * credentials** — `mintGuestToken` is a public RPC gated server-side
17
+ * on an enabled AgentShare at the given org/slug. It is therefore safe
18
+ * to use directly from a browser.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * import { createGuestAuth } from "@stigmer/sdk";
23
+ *
24
+ * const guestAuth = createGuestAuth({
25
+ * baseUrl: "https://api.stigmer.ai",
26
+ * org: "acme",
27
+ * slug: "support-agent",
28
+ * });
29
+ * ```
30
+ */
31
+ export interface GuestAuthConfig {
32
+ /** Stigmer API server URL (e.g., "https://api.stigmer.ai"). */
33
+ readonly baseUrl: string;
34
+ /** Organization slug from the share URL. */
35
+ readonly org: string;
36
+ /**
37
+ * Share slug from the share URL. Defaults to the shared agent's slug
38
+ * when the owner never customized it, so existing links pass the
39
+ * agent's slug here unchanged.
40
+ */
41
+ readonly slug: string;
42
+ /**
43
+ * Where to persist the visitor's guest id across visits.
44
+ *
45
+ * Defaults to `localStorage` when available, falling back to
46
+ * in-memory storage (guest identity then lasts one page load).
47
+ * The stored value is an opaque server-generated id — not a
48
+ * credential — that keys this browser's session read-isolation.
49
+ */
50
+ readonly storage?: GuestIdStorage;
51
+ /**
52
+ * Web origin of the page embedding the shared agent.
53
+ *
54
+ * Set this when the chat runs embedded — inside an iframe (the
55
+ * embedding page's origin, discovered via `@stigmer/embed`'s
56
+ * `resolveParentOrigin`) or directly in your own app
57
+ * (`window.location.origin`). Leave unset on the unframed hosted
58
+ * page. The server validates it against the share's
59
+ * `allowed_origins` at mint (an empty list admits any origin) and
60
+ * refuses with `"permission-denied"` when the origin is not allowed.
61
+ */
62
+ readonly embedOrigin?: string;
63
+ /**
64
+ * Share-link token from the URL's `?k=` parameter.
65
+ *
66
+ * Required when the share link has been locked with a rotatable
67
+ * token; harmless (ignored server-side) on plain links. On a locked
68
+ * link a missing or rotated-away token refuses the mint with
69
+ * `"not-found"` — deliberately indistinguishable from an agent that
70
+ * does not exist.
71
+ */
72
+ readonly linkToken?: string;
73
+ }
74
+ /**
75
+ * Guest token-minting helper for shared-agent pages.
76
+ *
77
+ * A minimal, purpose-built companion to the main Stigmer client: it
78
+ * lazily mints short-lived guest JWTs via the public `mintGuestToken`
79
+ * RPC, caches them in memory until just before expiry, and persists
80
+ * the server-issued guest id so the same browser resolves to the same
81
+ * guest across visits.
82
+ *
83
+ * Wire {@link getAccessToken} into a `Stigmer` client — the SDK calls
84
+ * it per request, so refresh is automatic and no token ever needs to
85
+ * be stored outside memory.
86
+ *
87
+ * Failure semantics: when minting fails (e.g. sharing was revoked —
88
+ * the server answers NOT_FOUND, indistinguishable from "no such
89
+ * agent"), {@link getAccessToken} rejects with a `StigmerError`, which
90
+ * fails the triggering request with the real cause instead of sending
91
+ * it unauthenticated.
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * const guestAuth = createGuestAuth({
96
+ * baseUrl: "https://api.stigmer.ai",
97
+ * org: "acme",
98
+ * slug: "support-agent",
99
+ * });
100
+ *
101
+ * const client = new Stigmer({
102
+ * baseUrl: "https://api.stigmer.ai",
103
+ * getAccessToken: guestAuth.getAccessToken,
104
+ * });
105
+ * ```
106
+ */
107
+ export declare class GuestAuth {
108
+ private readonly tokenClient;
109
+ private readonly org;
110
+ private readonly slug;
111
+ private readonly storage;
112
+ private readonly storageKey;
113
+ private readonly embedOrigin;
114
+ private readonly linkToken;
115
+ private cached;
116
+ private pendingMint;
117
+ /** @internal Use {@link createGuestAuth} instead. */
118
+ constructor(config: GuestAuthConfig);
119
+ /**
120
+ * The visitor's persisted guest id, or `null` before the first
121
+ * successful mint in this browser.
122
+ */
123
+ get guestCookieId(): string | null;
124
+ /**
125
+ * Token provider for `StigmerConfig.getAccessToken`.
126
+ *
127
+ * Returns the cached guest JWT while it has more than a minute of
128
+ * life left; otherwise mints a fresh one. Concurrent callers during
129
+ * a mint share the same in-flight request (single-flight).
130
+ *
131
+ * Defined as an arrow property so it can be passed detached:
132
+ * `new Stigmer({ ..., getAccessToken: guestAuth.getAccessToken })`.
133
+ *
134
+ * @throws {StigmerError} with code `"not-found"` when the agent is
135
+ * not shared (or sharing was revoked — the server keeps the two
136
+ * indistinguishable by design)
137
+ * @throws {StigmerError} with code `"permission-denied"` when
138
+ * `embedOrigin` is not in the agent's `allowed_origins` — embeds
139
+ * should hide the widget on this code rather than surface an error
140
+ * @throws {StigmerError} with code `"invalid-argument"` when org or
141
+ * slug is malformed
142
+ */
143
+ readonly getAccessToken: () => Promise<string | null>;
144
+ private mint;
145
+ }
146
+ /**
147
+ * Create a guest token-minting helper for a shared agent's hosted page
148
+ * or embed.
149
+ *
150
+ * This is the browser-side counterpart of `createPlatformClientAuth`:
151
+ * it involves **no credentials** — the server gates minting on an
152
+ * enabled AgentShare and issues a short-lived guest JWT scoped to the
153
+ * sharing org. Pass {@link GuestAuth.getAccessToken} to a `Stigmer`
154
+ * client and every request authenticates as this visitor.
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * import { Stigmer, createGuestAuth } from "@stigmer/sdk";
159
+ *
160
+ * const guestAuth = createGuestAuth({
161
+ * baseUrl: "https://api.stigmer.ai",
162
+ * org: "acme",
163
+ * slug: "support-agent",
164
+ * });
165
+ *
166
+ * const client = new Stigmer({
167
+ * baseUrl: "https://api.stigmer.ai",
168
+ * getAccessToken: guestAuth.getAccessToken,
169
+ * });
170
+ * ```
171
+ *
172
+ * @throws {Error} if `baseUrl`, `org`, or `slug` is missing or empty
173
+ */
174
+ export declare function createGuestAuth(config: GuestAuthConfig): GuestAuth;
175
+ //# sourceMappingURL=guest-auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guest-auth.d.ts","sourceRoot":"","sources":["../src/guest-auth.ts"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACpC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,eAAe;IAC9B,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,4CAA4C;IAC5C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;;;;;OAOG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,cAAc,CAAC;IAElC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;;;;;OAQG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAYD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA+C;IAC3E,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IAEnC,OAAO,CAAC,MAAM,CAA2D;IACzE,OAAO,CAAC,WAAW,CAAgC;IAEnD,qDAAqD;gBACzC,MAAM,EAAE,eAAe;IAgBnC;;;OAGG;IACH,IAAI,aAAa,IAAI,MAAM,GAAG,IAAI,CAEjC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,CAAC,cAAc,QAAa,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAcxD;YAEY,IAAI;CAsBnB;AA2DD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAkBlE"}
package/guest-auth.js ADDED
@@ -0,0 +1,227 @@
1
+ import { createGrpcWebTransport } from "@connectrpc/connect-web";
2
+ import { createClient } from "@connectrpc/connect";
3
+ import { create } from "@bufbuild/protobuf";
4
+ import { PlatformClientTokenController } from "@stigmer/protos/ai/stigmer/iam/platformclient/v1/token_pb";
5
+ import { MintGuestTokenRequestSchema } from "@stigmer/protos/ai/stigmer/iam/platformclient/v1/token_pb";
6
+ import { wrapError } from "./gen/errors.js";
7
+ import { rpcMetadataInterceptor, errorStripInterceptor, } from "./internal/interceptors.js";
8
+ /**
9
+ * How long before expiry a cached guest token is considered stale.
10
+ * Re-minting inside this window keeps long-lived streams from starting
11
+ * with a token that expires moments later.
12
+ */
13
+ const EXPIRY_SKEW_MS = 60_000;
14
+ /** Storage key prefix for the persisted guest id, namespaced per org. */
15
+ const GUEST_ID_STORAGE_PREFIX = "stigmer:guest-id:";
16
+ /**
17
+ * Guest token-minting helper for shared-agent pages.
18
+ *
19
+ * A minimal, purpose-built companion to the main Stigmer client: it
20
+ * lazily mints short-lived guest JWTs via the public `mintGuestToken`
21
+ * RPC, caches them in memory until just before expiry, and persists
22
+ * the server-issued guest id so the same browser resolves to the same
23
+ * guest across visits.
24
+ *
25
+ * Wire {@link getAccessToken} into a `Stigmer` client — the SDK calls
26
+ * it per request, so refresh is automatic and no token ever needs to
27
+ * be stored outside memory.
28
+ *
29
+ * Failure semantics: when minting fails (e.g. sharing was revoked —
30
+ * the server answers NOT_FOUND, indistinguishable from "no such
31
+ * agent"), {@link getAccessToken} rejects with a `StigmerError`, which
32
+ * fails the triggering request with the real cause instead of sending
33
+ * it unauthenticated.
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const guestAuth = createGuestAuth({
38
+ * baseUrl: "https://api.stigmer.ai",
39
+ * org: "acme",
40
+ * slug: "support-agent",
41
+ * });
42
+ *
43
+ * const client = new Stigmer({
44
+ * baseUrl: "https://api.stigmer.ai",
45
+ * getAccessToken: guestAuth.getAccessToken,
46
+ * });
47
+ * ```
48
+ */
49
+ export class GuestAuth {
50
+ tokenClient;
51
+ org;
52
+ slug;
53
+ storage;
54
+ storageKey;
55
+ embedOrigin;
56
+ linkToken;
57
+ cached = null;
58
+ pendingMint = null;
59
+ /** @internal Use {@link createGuestAuth} instead. */
60
+ constructor(config) {
61
+ this.org = config.org;
62
+ this.slug = config.slug;
63
+ this.storage = config.storage ?? resolveDefaultStorage();
64
+ this.storageKey = `${GUEST_ID_STORAGE_PREFIX}${config.org}`;
65
+ this.embedOrigin = config.embedOrigin ?? "";
66
+ this.linkToken = config.linkToken ?? "";
67
+ const transport = createGrpcWebTransport({
68
+ baseUrl: config.baseUrl,
69
+ interceptors: [rpcMetadataInterceptor, errorStripInterceptor],
70
+ });
71
+ this.tokenClient = createClient(PlatformClientTokenController, transport);
72
+ }
73
+ /**
74
+ * The visitor's persisted guest id, or `null` before the first
75
+ * successful mint in this browser.
76
+ */
77
+ get guestCookieId() {
78
+ return safeGetItem(this.storage, this.storageKey);
79
+ }
80
+ /**
81
+ * Token provider for `StigmerConfig.getAccessToken`.
82
+ *
83
+ * Returns the cached guest JWT while it has more than a minute of
84
+ * life left; otherwise mints a fresh one. Concurrent callers during
85
+ * a mint share the same in-flight request (single-flight).
86
+ *
87
+ * Defined as an arrow property so it can be passed detached:
88
+ * `new Stigmer({ ..., getAccessToken: guestAuth.getAccessToken })`.
89
+ *
90
+ * @throws {StigmerError} with code `"not-found"` when the agent is
91
+ * not shared (or sharing was revoked — the server keeps the two
92
+ * indistinguishable by design)
93
+ * @throws {StigmerError} with code `"permission-denied"` when
94
+ * `embedOrigin` is not in the agent's `allowed_origins` — embeds
95
+ * should hide the widget on this code rather than surface an error
96
+ * @throws {StigmerError} with code `"invalid-argument"` when org or
97
+ * slug is malformed
98
+ */
99
+ getAccessToken = async () => {
100
+ if (this.cached && this.cached.expiresAt - Date.now() > EXPIRY_SKEW_MS) {
101
+ return this.cached.accessToken;
102
+ }
103
+ // Single-flight: the provider is invoked once per request, so a
104
+ // burst at page load (registry fetches + profile resolution) must
105
+ // collapse into one mint — both for latency and because concurrent
106
+ // first mints would otherwise race to persist different guest ids.
107
+ this.pendingMint ??= this.mint().finally(() => {
108
+ this.pendingMint = null;
109
+ });
110
+ return this.pendingMint;
111
+ };
112
+ async mint() {
113
+ try {
114
+ const response = await this.tokenClient.mintGuestToken(create(MintGuestTokenRequestSchema, {
115
+ org: this.org,
116
+ slug: this.slug,
117
+ guestCookieId: safeGetItem(this.storage, this.storageKey) ?? "",
118
+ embedOrigin: this.embedOrigin,
119
+ linkToken: this.linkToken,
120
+ }));
121
+ safeSetItem(this.storage, this.storageKey, response.guestCookieId);
122
+ this.cached = {
123
+ accessToken: response.accessToken,
124
+ expiresAt: Date.now() + response.expiresIn * 1000,
125
+ };
126
+ return response.accessToken;
127
+ }
128
+ catch (e) {
129
+ throw wrapError(e);
130
+ }
131
+ }
132
+ }
133
+ /**
134
+ * `localStorage` when usable, otherwise an in-memory fallback.
135
+ *
136
+ * Access is probed inside try/catch because merely touching
137
+ * `localStorage` can throw (e.g. sandboxed iframes with storage
138
+ * blocked). With the fallback, the chat still works — the visitor
139
+ * just gets a fresh guest identity per page load.
140
+ *
141
+ * `globalThis` is typed structurally because this package compiles
142
+ * without DOM libs (it is also consumed from Node, where
143
+ * `localStorage` does not exist).
144
+ */
145
+ function resolveDefaultStorage() {
146
+ try {
147
+ const { localStorage: storage } = globalThis;
148
+ if (storage) {
149
+ const probeKey = "stigmer:storage-probe";
150
+ storage.setItem(probeKey, "1");
151
+ storage.removeItem(probeKey);
152
+ return storage;
153
+ }
154
+ }
155
+ catch {
156
+ // Fall through to the in-memory storage below.
157
+ }
158
+ const memory = new Map();
159
+ return {
160
+ getItem: (key) => memory.get(key) ?? null,
161
+ setItem: (key, value) => {
162
+ memory.set(key, value);
163
+ },
164
+ };
165
+ }
166
+ /**
167
+ * Storage reads/writes never fail the mint: the guest id is a
168
+ * convenience (stable identity across visits), not a requirement —
169
+ * the server issues a fresh id when none is presented.
170
+ */
171
+ function safeGetItem(storage, key) {
172
+ try {
173
+ return storage.getItem(key);
174
+ }
175
+ catch {
176
+ return null;
177
+ }
178
+ }
179
+ function safeSetItem(storage, key, value) {
180
+ try {
181
+ storage.setItem(key, value);
182
+ }
183
+ catch {
184
+ // Persisting the id is best-effort; see safeGetItem.
185
+ }
186
+ }
187
+ /**
188
+ * Create a guest token-minting helper for a shared agent's hosted page
189
+ * or embed.
190
+ *
191
+ * This is the browser-side counterpart of `createPlatformClientAuth`:
192
+ * it involves **no credentials** — the server gates minting on an
193
+ * enabled AgentShare and issues a short-lived guest JWT scoped to the
194
+ * sharing org. Pass {@link GuestAuth.getAccessToken} to a `Stigmer`
195
+ * client and every request authenticates as this visitor.
196
+ *
197
+ * @example
198
+ * ```typescript
199
+ * import { Stigmer, createGuestAuth } from "@stigmer/sdk";
200
+ *
201
+ * const guestAuth = createGuestAuth({
202
+ * baseUrl: "https://api.stigmer.ai",
203
+ * org: "acme",
204
+ * slug: "support-agent",
205
+ * });
206
+ *
207
+ * const client = new Stigmer({
208
+ * baseUrl: "https://api.stigmer.ai",
209
+ * getAccessToken: guestAuth.getAccessToken,
210
+ * });
211
+ * ```
212
+ *
213
+ * @throws {Error} if `baseUrl`, `org`, or `slug` is missing or empty
214
+ */
215
+ export function createGuestAuth(config) {
216
+ if (!config.baseUrl) {
217
+ throw new Error("createGuestAuth: baseUrl is required (e.g., \"https://api.stigmer.ai\")");
218
+ }
219
+ if (!config.org) {
220
+ throw new Error("createGuestAuth: org is required — the organization slug from the share URL");
221
+ }
222
+ if (!config.slug) {
223
+ throw new Error("createGuestAuth: slug is required — the share slug from the share URL");
224
+ }
225
+ return new GuestAuth(config);
226
+ }
227
+ //# sourceMappingURL=guest-auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guest-auth.js","sourceRoot":"","sources":["../src/guest-auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAe,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,6BAA6B,EAAE,MAAM,2DAA2D,CAAC;AAC1G,OAAO,EAAE,2BAA2B,EAAE,MAAM,2DAA2D,CAAC;AACxG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,4BAA4B,CAAC;AAkFpC;;;;GAIG;AACH,MAAM,cAAc,GAAG,MAAM,CAAC;AAE9B,yEAAyE;AACzE,MAAM,uBAAuB,GAAG,mBAAmB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,OAAO,SAAS;IACH,WAAW,CAA+C;IAC1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M,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC"}
package/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export { Stigmer } from "./stigmer.js";
2
2
  export { type RunnerAdapter, type RunnerWorkerHost, createRunnerAdapter, } from "./runner-adapter.js";
3
3
  export { type StigmerConfig, type TokenProvider } from "./config.js";
4
+ export { createGuestAuth, GuestAuth, type GuestAuthConfig, type GuestIdStorage, } from "./guest-auth.js";
5
+ export { MAX_ALLOWED_ORIGINS, LINK_TOKEN_PARAM, validateOrigin, chatPath, buildChatUrl, appendLinkToken, buildEmbedLoaderUrl, buildEmbedSnippet, } from "./sharing.js";
4
6
  export { StigmerError, type ErrorCode, isNotFound, isUnauthenticated, isPermissionDenied, isRetryable, type ErrorCategory, isConnectError, classifyError, isRetryableError, isTransientStreamError, getUserMessage, type RpcErrorMetadata, annotateRpcError, getRpcMetadata, } from "./errors.js";
5
7
  export { type DeploymentMode, isResourceAvailable, } from "./resource-availability.js";
6
8
  export { getGrantableRoles, hasGrantableRoles, isRoleGrantable, } from "./authorization-config.js";
@@ -16,6 +18,7 @@ export { type DeleteResourceInput, type ResourceRef, type Page, type ListParams,
16
18
  export { AgentClient, type AgentInput, type McpServerUsageInput, type ToolApprovalOverrideInput, type SubAgentInput, type McpAccessInput, } from "./gen/agent.js";
17
19
  export { AgentExecutionClient, type AgentExecutionInput, type ExecutionConfigInput, type ContextManagementConfigInput, type AttachmentInput, } from "./gen/agentexecution.js";
18
20
  export { AgentInstanceClient, type AgentInstanceInput, } from "./gen/agentinstance.js";
21
+ export { AgentShareClient, type AgentShareInput, type AgentShareMessagesInput, } from "./gen/agentshare.js";
19
22
  export { ApiKeyClient, type ApiKeyInput } from "./gen/apikey.js";
20
23
  export { EnvironmentClient, type EnvironmentInput, } from "./gen/environment.js";
21
24
  export { ExecutionContextClient, type ExecutionContextInput, } from "./gen/executioncontext.js";
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAGrE,OAAO,EACL,YAAY,EACZ,KAAK,SAAS,EACd,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,KAAK,aAAa,EAClB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,KAAK,gBAAgB,EACrB,gBAAgB,EAChB,cAAc,GACf,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,KAAK,cAAc,EACnB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,GAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAC;AAGpE,OAAO,EACL,cAAc,EACd,KAAK,wBAAwB,EAC7B,KAAK,0BAA0B,GAChC,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,mBAAmB,IAAI,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAGrF,OAAO,EACL,aAAa,EACb,KAAK,2BAA2B,EAChC,KAAK,gCAAgC,EACrC,KAAK,2BAA2B,EAChC,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,6BAA6B,GACnC,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,YAA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AK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,gBAAgB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,uBAAuB,EACvB,KAAK,sBAAsB,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,sBAAsB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,2BAA2B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAGrE,OAAO,EACL,eAAe,EACf,SAAS,EACT,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,YAAY,EACZ,KAAK,SAAS,EACd,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,KAAK,aAAa,EAClB,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,KAAK,gBAAgB,EACrB,gBAAgB,EAChB,cAAc,GACf,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,KAAK,cAAc,EACnB,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,GAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,e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AsB,EACtB,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,yBAAyB,GAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EACL,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EACL,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,gBAAgB,GACtB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,uBAAuB,EACvB,KAAK,sBAAsB,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,sBAAsB,EACtB,KAAK,qBAAqB,GAC3B,MAAM,2BAA2B,CAAC"}
package/index.js CHANGED
@@ -3,6 +3,10 @@
3
3
  export { Stigmer } from "./stigmer.js";
4
4
  // Runner adapter
5
5
  export { createRunnerAdapter, } from "./runner-adapter.js";
6
+ // Guest auth (shared-agent pages and embeds; browser-safe, credential-free)
7
+ export { createGuestAuth, GuestAuth, } from "./guest-auth.js";
8
+ // Agent sharing (hosted link + embed snippet; framework-free)
9
+ export { MAX_ALLOWED_ORIGINS, LINK_TOKEN_PARAM, validateOrigin, chatPath, buildChatUrl, appendLinkToken, buildEmbedLoaderUrl, buildEmbedSnippet, } from "./sharing.js";
6
10
  // Error handling
7
11
  export { StigmerError, isNotFound, isUnauthenticated, isPermissionDenied, isRetryable, isConnectError, classifyError, isRetryableError, isTransientStreamError, getUserMessage, annotateRpcError, getRpcMetadata, } from "./errors.js";
8
12
  // Resource availability
@@ -25,6 +29,7 @@ export { PlatformClient, } from "./platform.js";
25
29
  export { AgentClient, } from "./gen/agent.js";
26
30
  export { AgentExecutionClient, } from "./gen/agentexecution.js";
27
31
  export { AgentInstanceClient, } from "./gen/agentinstance.js";
32
+ export { AgentShareClient, } from "./gen/agentshare.js";
28
33
  export { ApiKeyClient } from "./gen/apikey.js";
29
34
  export { EnvironmentClient, } from "./gen/environment.js";
30
35
  export { ExecutionContextClient, } from "./gen/executioncontext.js";
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAE9B,mBAAmB;AACnB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,iBAAiB;AACjB,OAAO,EAGL,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAK7B,iBAAiB;AACjB,OAAO,EACL,YAAY,EAEZ,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EAEX,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EAEd,gBAAgB,EAChB,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,wBAAwB;AACxB,OAAO,EAEL,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AAEpC,8CAA8C;AAC9C,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,GAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,2CAA2C,CAAC;AAEpE,oCAAoC;AACpC,OAAO,EACL,cAAc,GAGf,MAAM,eAAe,CAAC;AAGvB,iBAAiB;AACjB,OAAO,EACL,aAAa,GAOd,MAAM,cAAc,CAAC;AAEtB,gBAAgB;AAChB,OAAO,EACL,YAAY,EA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AAO,EACL,oBAAoB,GAErB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAqB,MAAM,kBAAkB,CAAC;AACpE,OAAO,EACL,aAAa,GAMd,MAAM,kBAAkB,CAAC;AAE1B,mCAAmC;AACnC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEhE,uFAAuF;AACvF,OAAO,EACL,QAAQ,EACR,sBAAsB,EACtB,eAAe,EACf,qBAAqB,EACrB,mBAAmB,GAIpB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,yBAAyB,GAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EACL,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAmB,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EACL,cAAc,GAMf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,uBAAuB,GAExB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,sBAAsB,GAEvB,MAAM,2BAA2B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stigmer/sdk",
3
- "version": "3.1.7",
3
+ "version": "3.1.9",
4
4
  "description": "Stigmer TypeScript SDK — typed API client for all Stigmer platform resources",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -44,6 +44,6 @@
44
44
  "peerDependencies": {
45
45
  "@bufbuild/protobuf": "^2.0.0",
46
46
  "@connectrpc/connect-node": "^2.0.0",
47
- "@stigmer/protos": "3.1.7"
47
+ "@stigmer/protos": "3.1.9"
48
48
  }
49
49
  }
package/sharing.d.ts ADDED
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Agent-sharing helpers — the single source of truth for the hosted chat
3
+ * URL shape, the embed snippet, and client-side `allowed_origins`
4
+ * validation. Framework-free by design: consumed by the web console and
5
+ * desktop app (via `@stigmer/react`), the `stigmer` CLI, and any platform
6
+ * builder that wants to construct share links or embed snippets itself.
7
+ *
8
+ * The canonical URL shape is `<app-origin>/chat/<org>/<slug>` (a T01
9
+ * design decision), and `embed.js` is served from the root of that same
10
+ * app origin (T04). Callers supply the origin — resolving it is a host
11
+ * concern (the console knows its `appUrl`, the CLI resolves it from the
12
+ * backend type) — while the path and snippet shapes live here so every
13
+ * surface emits byte-identical output.
14
+ */
15
+ /** Maximum number of allowed origins (proto: `repeated.max_items = 32`). */
16
+ export declare const MAX_ALLOWED_ORIGINS = 32;
17
+ /**
18
+ * Validate a single `allowed_origins` entry.
19
+ *
20
+ * Returns `null` when valid, or a user-facing message explaining what
21
+ * to fix (DD-006: errors state what happened and what to do).
22
+ */
23
+ export declare function validateOrigin(value: string): string | null;
24
+ /**
25
+ * Query parameter carrying the share-link token on a locked link:
26
+ * `/chat/<org>/<slug>?k=<token>`. Short by design — the token rides every
27
+ * copied link, and `k` (for "key") is the platform's one-character
28
+ * convention, mirrored by the hosted page and the embed widget.
29
+ */
30
+ export declare const LINK_TOKEN_PARAM = "k";
31
+ /**
32
+ * The hosted chat page path for a shared agent: `/chat/<org>/<slug>`
33
+ * (the AgentShare's org and slug — the slug defaults to the agent's),
34
+ * plus `?k=<token>` when the share link is locked with a rotatable
35
+ * token (`AgentShareStatus.share_link_token`).
36
+ *
37
+ * Useful on its own when the caller renders relative to the current
38
+ * origin (e.g. a host that never configured an absolute app URL).
39
+ */
40
+ export declare function chatPath(org: string, slug: string, linkToken?: string): string;
41
+ /**
42
+ * The absolute hosted chat URL for a shared agent:
43
+ * `<appOrigin>/chat/<org>/<slug>[?k=<token>]`.
44
+ *
45
+ * A trailing slash on `appOrigin` is tolerated so callers can pass
46
+ * user-configured values verbatim. An empty `appOrigin` degrades to the
47
+ * relative {@link chatPath} — the same graceful fallback a host without a
48
+ * configured public origin gets in the share dialog.
49
+ */
50
+ export declare function buildChatUrl(appOrigin: string, org: string, slug: string, linkToken?: string): string;
51
+ /**
52
+ * Append the share-link token to an already-built chat URL.
53
+ *
54
+ * For hosts that construct the base URL through their own callback (the
55
+ * share dialog's `buildShareUrl` prop) rather than {@link buildChatUrl}.
56
+ * A `null`/empty token returns the URL unchanged, so callers can pass
57
+ * `share.status?.shareLinkToken` straight through. Emits the identical
58
+ * `?k=` shape as {@link chatPath} — one URL grammar across every surface.
59
+ */
60
+ export declare function appendLinkToken(url: string, linkToken: string | null | undefined): string;
61
+ /**
62
+ * The embed loader URL: `embed.js` lives at the root of the app origin
63
+ * (the loader derives the chat-page origin from its own script URL, so
64
+ * the two must share an origin). An empty `appOrigin` degrades to the
65
+ * relative `/embed.js`.
66
+ */
67
+ export declare function buildEmbedLoaderUrl(appOrigin: string): string;
68
+ /**
69
+ * The two-line embed snippet an owner pastes into any website: the
70
+ * loader script plus the `<stigmer-agent>` element where the widget
71
+ * renders. A locked share link adds the `token` attribute, which the
72
+ * widget forwards as `?k=` on its iframe URL. Every surface (share
73
+ * dialog, CLI, docs) emits exactly this.
74
+ */
75
+ export declare function buildEmbedSnippet(appOrigin: string, org: string, slug: string, linkToken?: string): string;
76
+ //# sourceMappingURL=sharing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sharing.d.ts","sourceRoot":"","sources":["../src/sharing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,4EAA4E;AAC5E,eAAO,MAAM,mBAAmB,KAAK,CAAC;AActC;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAO3D;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAK9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAER;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAIzF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAMR"}