@stigmer/client 0.1.3 → 0.2.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 (61) hide show
  1. package/app-handover.d.ts +119 -0
  2. package/app-handover.d.ts.map +1 -0
  3. package/app-handover.js +523 -0
  4. package/app-handover.js.map +1 -0
  5. package/gen/organization.d.ts +2 -0
  6. package/gen/organization.d.ts.map +1 -1
  7. package/gen/organization.js +8 -0
  8. package/gen/organization.js.map +1 -1
  9. package/iam-principal.d.ts +11 -0
  10. package/iam-principal.d.ts.map +1 -1
  11. package/iam-principal.js +16 -0
  12. package/iam-principal.js.map +1 -1
  13. package/index.d.ts +11 -5
  14. package/index.d.ts.map +1 -1
  15. package/index.js +10 -3
  16. package/index.js.map +1 -1
  17. package/package.json +3 -3
  18. package/platform.d.ts +41 -3
  19. package/platform.d.ts.map +1 -1
  20. package/platform.js +56 -3
  21. package/platform.js.map +1 -1
  22. package/run/format-elapsed.d.ts +10 -0
  23. package/run/format-elapsed.d.ts.map +1 -0
  24. package/run/format-elapsed.js +25 -0
  25. package/run/format-elapsed.js.map +1 -0
  26. package/run/step-words.d.ts +78 -0
  27. package/run/step-words.d.ts.map +1 -0
  28. package/run/step-words.js +316 -0
  29. package/run/step-words.js.map +1 -0
  30. package/run/tool-view.d.ts +26 -2
  31. package/run/tool-view.d.ts.map +1 -1
  32. package/run/tool-view.js +83 -17
  33. package/run/tool-view.js.map +1 -1
  34. package/run/turn-activity.d.ts +9 -7
  35. package/run/turn-activity.d.ts.map +1 -1
  36. package/run/turn-activity.js +24 -144
  37. package/run/turn-activity.js.map +1 -1
  38. package/run/turn-ending.d.ts +59 -0
  39. package/run/turn-ending.d.ts.map +1 -0
  40. package/run/turn-ending.js +394 -0
  41. package/run/turn-ending.js.map +1 -0
  42. package/run/turn-steps.d.ts +16 -0
  43. package/run/turn-steps.d.ts.map +1 -0
  44. package/run/turn-steps.js +65 -0
  45. package/run/turn-steps.js.map +1 -0
  46. package/session-events.d.ts +3 -1
  47. package/session-events.d.ts.map +1 -1
  48. package/session-events.js +1 -0
  49. package/session-events.js.map +1 -1
  50. package/src/app-handover.ts +613 -0
  51. package/src/gen/organization.ts +7 -0
  52. package/src/iam-principal.ts +21 -0
  53. package/src/index.ts +49 -1
  54. package/src/platform.ts +80 -3
  55. package/src/run/format-elapsed.ts +22 -0
  56. package/src/run/step-words.ts +360 -0
  57. package/src/run/tool-view.ts +102 -19
  58. package/src/run/turn-activity.ts +27 -146
  59. package/src/run/turn-ending.ts +475 -0
  60. package/src/run/turn-steps.ts +81 -0
  61. package/src/session-events.ts +4 -1
@@ -0,0 +1,119 @@
1
+ /**
2
+ * The code that puts an agent's chat in a builder's own app: one source for
3
+ * the text every surface hands over (the console's agent page, and anything
4
+ * else that writes a builder's token route and chat), so each says exactly
5
+ * the same thing and a compiler can hold all of it (the docs snippet gate
6
+ * compiles every stack's output as whole files).
7
+ *
8
+ * Two files, for a server that signs people in:
9
+ *
10
+ * - a token route for the builder's backend, `GET /api/stigmer-token`,
11
+ * answering `{ accessToken, expiresAt }` (the shape `createTokenCache`
12
+ * takes), minted with an admin service account's key read from
13
+ * `STIGMER_API_KEY`; one per stack, on the stack's standard library
14
+ * (Node's `node:http`, Python's `http.server`, Go's `net/http`, the JDK's
15
+ * `com.sun.net.httpserver`), or a Next.js route handler. A standard
16
+ * library route is something every reader can compile and run as it
17
+ * stands, and its one minting call moves into any framework;
18
+ * - the chat for their React app, `<AgentChat>` behind `createTokenCache`.
19
+ *
20
+ * Who is signed in is the one thing Stigmer cannot know. Every route asks one
21
+ * function, `currentUser`, which the builder replaces with their own sign-in.
22
+ * Until then it answers the person named by `STIGMER_DEV_USER` while that is
23
+ * set, and nobody otherwise, so a route pasted into production unchanged
24
+ * refuses everyone rather than minting for whoever calls it.
25
+ *
26
+ * For a server that trusts every caller (`stigmer up`), only the chat, with
27
+ * no token at all: there is no one to sign in, and the server refuses to
28
+ * mint. That text says it is for development.
29
+ *
30
+ * The text carries no secret: the key is read from the environment, and the
31
+ * functions here never take one. Every value written into code (the
32
+ * organization, the agent, the address) is written as a string literal by
33
+ * `JSON.stringify`, whose escapes are valid in all five languages, so no
34
+ * value can break out of its literal. Framework-free and import-free, so the
35
+ * plain-Node docs gate loads the built module as it stands.
36
+ */
37
+ /** A backend the handover writes a token route for. */
38
+ export type AppHandoverStack = "nextjs" | "node" | "python" | "go" | "java";
39
+ /** The backends, in the order a picker offers them, with their names. */
40
+ export declare const APP_HANDOVER_STACKS: readonly {
41
+ readonly id: AppHandoverStack;
42
+ readonly name: string;
43
+ }[];
44
+ /**
45
+ * Which server the code talks to: `"sign-in"`, one that signs its callers in
46
+ * (Stigmer Cloud, or a self-hosted server with sign-in turned on), where a
47
+ * backend mints each user's token; `"local"`, one that trusts every caller,
48
+ * where the chat sends no token and there is no backend.
49
+ */
50
+ export type AppHandoverMode = "sign-in" | "local";
51
+ /** The language a handed-over block is written in, for highlighting. */
52
+ export type AppHandoverLanguage = "bash" | "xml" | "typescript" | "tsx" | "python" | "go" | "java";
53
+ /** One file to add, and what to install for it. */
54
+ export interface AppHandoverFile {
55
+ /** The install command (or, for Java, the Maven dependency). */
56
+ readonly install: string;
57
+ readonly installLanguage: "bash" | "xml";
58
+ /** The file's path in the builder's project ("server.ts", "app/api/stigmer-token/route.ts"). */
59
+ readonly file: string;
60
+ readonly language: AppHandoverLanguage;
61
+ /** The whole file. */
62
+ readonly code: string;
63
+ }
64
+ /** What the handover gives a builder. */
65
+ export interface AppHandover {
66
+ /** The token route, for a server that signs people in; absent for a local one. */
67
+ readonly backend?: AppHandoverFile;
68
+ /** The chat component for their React app. */
69
+ readonly chat: AppHandoverFile;
70
+ }
71
+ /** What {@link buildAppHandover} writes the code for. */
72
+ export interface AppHandoverInput {
73
+ readonly mode: AppHandoverMode;
74
+ /** The backend, for the token route. The chat is the same for every stack. */
75
+ readonly stack: AppHandoverStack;
76
+ /** The Stigmer API's public address, `https://…` or `http://…`. */
77
+ readonly baseUrl: string;
78
+ /** The organization's slug. */
79
+ readonly org: string;
80
+ /** The agent's slug. */
81
+ readonly agent: string;
82
+ /**
83
+ * A published release of the SDKs (`"0.1.3"`), named in Java's Maven
84
+ * dependency. Without one, the dependency takes the newest 0.x release and
85
+ * says where to find it to pin it.
86
+ */
87
+ readonly sdkVersion?: string;
88
+ }
89
+ /** The path every token route serves and the chat fetches. */
90
+ export declare const APP_TOKEN_ROUTE = "/api/stigmer-token";
91
+ /** The environment variable the routes read the service account's key from. */
92
+ export declare const APP_API_KEY_VARIABLE = "STIGMER_API_KEY";
93
+ /** The environment variable naming the person a route signs in until the builder's own sign-in replaces it. */
94
+ export declare const APP_DEV_USER_VARIABLE = "STIGMER_DEV_USER";
95
+ /** The chat component's name, as the builder mounts it: `<StigmerAgentChat />`. */
96
+ export declare const APP_CHAT_COMPONENT = "StigmerAgentChat";
97
+ /** The port a standard-library route listens on when `PORT` is unset. */
98
+ export declare const APP_TOKEN_ROUTE_PORT = 3001;
99
+ /**
100
+ * The code that puts `org/agent`'s chat in a builder's app, for their stack.
101
+ *
102
+ * @throws {Error} when `baseUrl` is not an absolute `http://` or `https://` address
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * import { buildAppHandover } from "@stigmer/client";
107
+ *
108
+ * const { backend, chat } = buildAppHandover({
109
+ * mode: "sign-in",
110
+ * stack: "node",
111
+ * baseUrl: "https://api.stigmer.ai",
112
+ * org: "acme",
113
+ * agent: "variance-reporter",
114
+ * });
115
+ * // backend.file === "server.ts"; chat.file === "StigmerAgentChat.tsx"
116
+ * ```
117
+ */
118
+ export declare function buildAppHandover(input: AppHandoverInput): AppHandover;
119
+ //# sourceMappingURL=app-handover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-handover.d.ts","sourceRoot":"","sources":["src/app-handover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,uDAAuD;AACvD,MAAM,MAAM,gBA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AAE,MAAM,CAAC;IACvB;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,8DAA8D;AAC9D,eAAO,MAAM,eAAe,uBAAuB,CAAC;AAEpD,+EAA+E;AAC/E,eAAO,MAAM,oBAAoB,oBAAoB,CAAC;AAEtD,+GAA+G;AAC/G,eAAO,MAAM,qBAAqB,qBAAqB,CAAC;AAExD,mFAAmF;AACnF,eAAO,MAAM,kBAAkB,qBAAqB,CAAC;AAErD,yEAAyE;AACzE,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAEzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,WAAW,CAKrE"}
@@ -0,0 +1,523 @@
1
+ /**
2
+ * The code that puts an agent's chat in a builder's own app: one source for
3
+ * the text every surface hands over (the console's agent page, and anything
4
+ * else that writes a builder's token route and chat), so each says exactly
5
+ * the same thing and a compiler can hold all of it (the docs snippet gate
6
+ * compiles every stack's output as whole files).
7
+ *
8
+ * Two files, for a server that signs people in:
9
+ *
10
+ * - a token route for the builder's backend, `GET /api/stigmer-token`,
11
+ * answering `{ accessToken, expiresAt }` (the shape `createTokenCache`
12
+ * takes), minted with an admin service account's key read from
13
+ * `STIGMER_API_KEY`; one per stack, on the stack's standard library
14
+ * (Node's `node:http`, Python's `http.server`, Go's `net/http`, the JDK's
15
+ * `com.sun.net.httpserver`), or a Next.js route handler. A standard
16
+ * library route is something every reader can compile and run as it
17
+ * stands, and its one minting call moves into any framework;
18
+ * - the chat for their React app, `<AgentChat>` behind `createTokenCache`.
19
+ *
20
+ * Who is signed in is the one thing Stigmer cannot know. Every route asks one
21
+ * function, `currentUser`, which the builder replaces with their own sign-in.
22
+ * Until then it answers the person named by `STIGMER_DEV_USER` while that is
23
+ * set, and nobody otherwise, so a route pasted into production unchanged
24
+ * refuses everyone rather than minting for whoever calls it.
25
+ *
26
+ * For a server that trusts every caller (`stigmer up`), only the chat, with
27
+ * no token at all: there is no one to sign in, and the server refuses to
28
+ * mint. That text says it is for development.
29
+ *
30
+ * The text carries no secret: the key is read from the environment, and the
31
+ * functions here never take one. Every value written into code (the
32
+ * organization, the agent, the address) is written as a string literal by
33
+ * `JSON.stringify`, whose escapes are valid in all five languages, so no
34
+ * value can break out of its literal. Framework-free and import-free, so the
35
+ * plain-Node docs gate loads the built module as it stands.
36
+ */
37
+ /** The backends, in the order a picker offers them, with their names. */
38
+ export const APP_HANDOVER_STACKS = [
39
+ { id: "nextjs", name: "Next.js" },
40
+ { id: "node", name: "Node" },
41
+ { id: "python", name: "Python" },
42
+ { id: "go", name: "Go" },
43
+ { id: "java", name: "Java" },
44
+ ];
45
+ /** The path every token route serves and the chat fetches. */
46
+ export const APP_TOKEN_ROUTE = "/api/stigmer-token";
47
+ /** The environment variable the routes read the service account's key from. */
48
+ export const APP_API_KEY_VARIABLE = "STIGMER_API_KEY";
49
+ /** The environment variable naming the person a route signs in until the builder's own sign-in replaces it. */
50
+ export const APP_DEV_USER_VARIABLE = "STIGMER_DEV_USER";
51
+ /** The chat component's name, as the builder mounts it: `<StigmerAgentChat />`. */
52
+ export const APP_CHAT_COMPONENT = "StigmerAgentChat";
53
+ /** The port a standard-library route listens on when `PORT` is unset. */
54
+ export const APP_TOKEN_ROUTE_PORT = 3001;
55
+ /**
56
+ * The code that puts `org/agent`'s chat in a builder's app, for their stack.
57
+ *
58
+ * @throws {Error} when `baseUrl` is not an absolute `http://` or `https://` address
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * import { buildAppHandover } from "@stigmer/client";
63
+ *
64
+ * const { backend, chat } = buildAppHandover({
65
+ * mode: "sign-in",
66
+ * stack: "node",
67
+ * baseUrl: "https://api.stigmer.ai",
68
+ * org: "acme",
69
+ * agent: "variance-reporter",
70
+ * });
71
+ * // backend.file === "server.ts"; chat.file === "StigmerAgentChat.tsx"
72
+ * ```
73
+ */
74
+ export function buildAppHandover(input) {
75
+ const server = serverOf(input.baseUrl);
76
+ const code = { org: lit(input.org), agentRef: lit(`${input.org}/${input.agent}`), server };
77
+ if (input.mode === "local")
78
+ return { chat: localChat(code) };
79
+ return { backend: backendFor(input.stack, code, input.sdkVersion), chat: signInChat(code) };
80
+ }
81
+ function serverOf(baseUrl) {
82
+ let url;
83
+ try {
84
+ url = new URL(baseUrl);
85
+ }
86
+ catch {
87
+ throw new Error(`buildAppHandover: baseUrl must be an absolute address, like https://api.stigmer.ai (got ${JSON.stringify(baseUrl)})`);
88
+ }
89
+ if (url.protocol !== "https:" && url.protocol !== "http:") {
90
+ throw new Error(`buildAppHandover: baseUrl must be http:// or https:// (got ${JSON.stringify(baseUrl)})`);
91
+ }
92
+ const plaintext = url.protocol === "http:";
93
+ // The server answers gRPC and Connect on one port, so the target is the
94
+ // address's own host and port; a URL leaves out a port its scheme implies.
95
+ const port = url.port !== "" ? url.port : plaintext ? "80" : "443";
96
+ const origin = `${url.protocol}//${url.host}${url.pathname === "/" ? "" : url.pathname.replace(/\/$/, "")}`;
97
+ return { url: lit(origin), target: lit(`${url.hostname}:${port}`), plaintext };
98
+ }
99
+ /** A string literal for any of the five languages. */
100
+ function lit(value) {
101
+ return JSON.stringify(value);
102
+ }
103
+ /** Each stack's route; a typed record, so a stack without one fails to compile. */
104
+ const BACKENDS = {
105
+ nextjs: (code) => ({ install: "npm install @stigmer/client", installLanguage: "bash", file: "app/api/stigmer-token/route.ts", language: "typescript", code: nextRoute(code) }),
106
+ node: (code) => ({ install: "npm install @stigmer/client", installLanguage: "bash", file: "server.ts", language: "typescript", code: nodeRoute(code) }),
107
+ python: (code) => ({ install: "pip install stigmer-sdk", installLanguage: "bash", file: "stigmer_token.py", language: "python", code: pythonRoute(code) }),
108
+ go: (code) => ({ install: "go get go.stigmer.ai/sdk", installLanguage: "bash", file: "main.go", language: "go", code: goRoute(code) }),
109
+ java: (code, sdkVersion) => ({ install: mavenDependency(sdkVersion), installLanguage: "xml", file: "StigmerToken.java", language: "java", code: javaRoute(code) }),
110
+ };
111
+ function backendFor(stack, code, sdkVersion) {
112
+ return BACKENDS[stack](code, sdkVersion);
113
+ }
114
+ /** A version is pinned only when it is a plain release; anything else (a dev build) is not on Maven Central. */
115
+ const RELEASE = /^\d+\.\d+\.\d+$/;
116
+ function mavenDependency(sdkVersion) {
117
+ const pinned = sdkVersion !== undefined && RELEASE.test(sdkVersion);
118
+ return [
119
+ ...(pinned ? [] : ["<!-- The newest 0.x release. Pin the one you test with: https://central.sonatype.com/artifact/ai.stigmer/stigmer-sdk -->"]),
120
+ "<dependency>",
121
+ " <groupId>ai.stigmer</groupId>",
122
+ " <artifactId>stigmer-sdk</artifactId>",
123
+ ` <version>${pinned ? sdkVersion : "[0.1,1.0)"}</version>`,
124
+ "</dependency>",
125
+ ].join("\n");
126
+ }
127
+ const CURRENT_USER_NOTE = [
128
+ "Replace this with your own sign-in: return the person this request is",
129
+ "from, or nobody. Until then it signs in the email in STIGMER_DEV_USER",
130
+ "while that is set, and nobody otherwise.",
131
+ ];
132
+ const REFUSED = "Stigmer refused the token; the reason is in your server's log.";
133
+ function nodeRoute({ org, server }) {
134
+ return `// Your backend's Stigmer token route. GET /api/stigmer-token answers the
135
+ // signed-in person's token, { accessToken, expiresAt }, which the chat in
136
+ // your app asks for. Run it with: npx tsx server.ts
137
+ import { createServer, type IncomingMessage } from "node:http";
138
+ import { createNodeClient } from "@stigmer/client/node";
139
+
140
+ const ORG = ${org};
141
+
142
+ // The service account's key, never sent to a browser.
143
+ const stigmer = createNodeClient({
144
+ baseUrl: ${server.url},
145
+ apiKey: process.env.STIGMER_API_KEY!,
146
+ });
147
+
148
+ interface User {
149
+ id: string;
150
+ email?: string;
151
+ name?: string;
152
+ }
153
+
154
+ ${CURRENT_USER_NOTE.map((l) => `// ${l}`).join("\n")}
155
+ function currentUser(req: IncomingMessage): User | null {
156
+ const devUser = process.env.STIGMER_DEV_USER;
157
+ return devUser ? { id: devUser, email: devUser } : null;
158
+ }
159
+
160
+ createServer(async (req, res) => {
161
+ if (req.method !== "GET" || req.url !== "/api/stigmer-token") {
162
+ res.writeHead(404).end();
163
+ return;
164
+ }
165
+ const user = currentUser(req);
166
+ if (!user) {
167
+ res.writeHead(401, { "content-type": "text/plain" }).end("Nobody is signed in.");
168
+ return;
169
+ }
170
+ try {
171
+ const { accessToken, expiresAt } = await stigmer.tokens.mintUserToken({
172
+ org: ORG,
173
+ userId: user.id,
174
+ userEmail: user.email,
175
+ userName: user.name,
176
+ });
177
+ res.writeHead(200, { "content-type": "application/json" });
178
+ res.end(JSON.stringify({ accessToken, expiresAt: expiresAt.toISOString() }));
179
+ } catch (err) {
180
+ console.error(err);
181
+ res.writeHead(502, { "content-type": "text/plain" }).end(${lit(REFUSED)});
182
+ }
183
+ }).listen(Number(process.env.PORT ?? ${APP_TOKEN_ROUTE_PORT}));
184
+ `;
185
+ }
186
+ function nextRoute({ org, server }) {
187
+ return `// Your app's Stigmer token route. GET /api/stigmer-token answers the
188
+ // signed-in person's token, { accessToken, expiresAt }, which the chat asks for.
189
+ import { createNodeClient } from "@stigmer/client/node";
190
+
191
+ // Every request mints for whoever is signed in: never prerender it.
192
+ export const dynamic = "force-dynamic";
193
+
194
+ const ORG = ${org};
195
+
196
+ // The service account's key, never sent to a browser.
197
+ const stigmer = createNodeClient({
198
+ baseUrl: ${server.url},
199
+ apiKey: process.env.STIGMER_API_KEY!,
200
+ });
201
+
202
+ interface User {
203
+ id: string;
204
+ email?: string;
205
+ name?: string;
206
+ }
207
+
208
+ ${CURRENT_USER_NOTE.map((l) => `// ${l}`).join("\n")}
209
+ async function currentUser(request: Request): Promise<User | null> {
210
+ const devUser = process.env.STIGMER_DEV_USER;
211
+ return devUser ? { id: devUser, email: devUser } : null;
212
+ }
213
+
214
+ export async function GET(request: Request): Promise<Response> {
215
+ const user = await currentUser(request);
216
+ if (!user) return new Response("Nobody is signed in.", { status: 401 });
217
+ try {
218
+ const { accessToken, expiresAt } = await stigmer.tokens.mintUserToken({
219
+ org: ORG,
220
+ userId: user.id,
221
+ userEmail: user.email,
222
+ userName: user.name,
223
+ });
224
+ return Response.json({ accessToken, expiresAt: expiresAt.toISOString() });
225
+ } catch (err) {
226
+ console.error(err);
227
+ return new Response(${lit(REFUSED)}, { status: 502 });
228
+ }
229
+ }
230
+ `;
231
+ }
232
+ function pythonRoute({ org, server }) {
233
+ const insecure = server.plaintext ? ", insecure=True" : "";
234
+ return `"""Your backend's Stigmer token route.
235
+
236
+ GET /api/stigmer-token answers the signed-in person's token,
237
+ { accessToken, expiresAt }, which the chat in your app asks for.
238
+ Run it with: python stigmer_token.py
239
+ """
240
+
241
+ import json
242
+ import logging
243
+ import os
244
+ from dataclasses import dataclass
245
+ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
246
+
247
+ from stigmer import StigmerClient
248
+
249
+ ORG = ${org}
250
+
251
+ # The service account's key, never sent to a browser.
252
+ client = StigmerClient(os.environ["STIGMER_API_KEY"], base_url=${server.target}${insecure})
253
+
254
+
255
+ @dataclass
256
+ class User:
257
+ id: str
258
+ email: str | None = None
259
+ name: str | None = None
260
+
261
+
262
+ def current_user(request: BaseHTTPRequestHandler) -> User | None:
263
+ """${CURRENT_USER_NOTE.join("\n ")}
264
+ """
265
+ dev_user = os.environ.get("STIGMER_DEV_USER")
266
+ return User(id=dev_user, email=dev_user) if dev_user else None
267
+
268
+
269
+ class TokenRoute(BaseHTTPRequestHandler):
270
+ def do_GET(self) -> None:
271
+ if self.path != "/api/stigmer-token":
272
+ self.send_error(404)
273
+ return
274
+ user = current_user(self)
275
+ if user is None:
276
+ self.answer(401, "text/plain", b"Nobody is signed in.")
277
+ return
278
+ try:
279
+ token = client.tokens.mint_user_token(
280
+ org=ORG, user_id=user.id, user_email=user.email, user_name=user.name
281
+ )
282
+ except Exception:
283
+ logging.exception("minting a Stigmer token")
284
+ self.answer(502, "text/plain", ${lit(REFUSED)}.encode())
285
+ return
286
+ body = {"accessToken": token.access_token, "expiresAt": token.expires_at.isoformat()}
287
+ self.answer(200, "application/json", json.dumps(body).encode())
288
+
289
+ def answer(self, status: int, content_type: str, body: bytes) -> None:
290
+ self.send_response(status)
291
+ self.send_header("Content-Type", content_type)
292
+ self.end_headers()
293
+ self.wfile.write(body)
294
+
295
+
296
+ if __name__ == "__main__":
297
+ port = int(os.environ.get("PORT", "${APP_TOKEN_ROUTE_PORT}"))
298
+ ThreadingHTTPServer(("", port), TokenRoute).serve_forever()
299
+ `;
300
+ }
301
+ function goRoute({ org, server }) {
302
+ const insecure = server.plaintext ? ",\n\t\tstigmer.WithInsecure()," : ",";
303
+ return `// Your backend's Stigmer token route. GET /api/stigmer-token answers the
304
+ // signed-in person's token, { accessToken, expiresAt }, which the chat in
305
+ // your app asks for. Run it with: go run .
306
+ package main
307
+
308
+ import (
309
+ "encoding/json"
310
+ "log"
311
+ "net/http"
312
+ "os"
313
+ "time"
314
+
315
+ stigmer "go.stigmer.ai/sdk"
316
+ )
317
+
318
+ const org = ${org}
319
+
320
+ type user struct{ ID, Email, Name string }
321
+
322
+ ${CURRENT_USER_NOTE.map((l) => `// ${l}`).join("\n")}
323
+ func currentUser(r *http.Request) *user {
324
+ if devUser := os.Getenv("STIGMER_DEV_USER"); devUser != "" {
325
+ return &user{ID: devUser, Email: devUser}
326
+ }
327
+ return nil
328
+ }
329
+
330
+ func main() {
331
+ // The service account's key, never sent to a browser.
332
+ client, err := stigmer.NewClient(
333
+ stigmer.WithAPIKey(os.Getenv("STIGMER_API_KEY")),
334
+ stigmer.WithBaseURL(${server.target})${insecure}
335
+ )
336
+ if err != nil {
337
+ log.Fatal(err)
338
+ }
339
+ defer client.Close()
340
+
341
+ http.HandleFunc("GET /api/stigmer-token", func(w http.ResponseWriter, r *http.Request) {
342
+ u := currentUser(r)
343
+ if u == nil {
344
+ http.Error(w, "Nobody is signed in.", http.StatusUnauthorized)
345
+ return
346
+ }
347
+ token, err := client.Tokens.MintUserToken(r.Context(), &stigmer.MintUserTokenInput{
348
+ Org: org,
349
+ UserID: u.ID,
350
+ UserEmail: u.Email,
351
+ UserName: u.Name,
352
+ })
353
+ if err != nil {
354
+ log.Print(err)
355
+ http.Error(w, ${lit(REFUSED)}, http.StatusBadGateway)
356
+ return
357
+ }
358
+ w.Header().Set("Content-Type", "application/json")
359
+ json.NewEncoder(w).Encode(map[string]string{
360
+ "accessToken": token.AccessToken,
361
+ "expiresAt": token.ExpiresAt.Format(time.RFC3339),
362
+ })
363
+ })
364
+
365
+ port := os.Getenv("PORT")
366
+ if port == "" {
367
+ port = "${APP_TOKEN_ROUTE_PORT}"
368
+ }
369
+ log.Fatal(http.ListenAndServe(":"+port, nil))
370
+ }
371
+ `;
372
+ }
373
+ function javaRoute({ org, server }) {
374
+ const insecure = server.plaintext ? "\n .insecure()" : "";
375
+ return `// Your backend's Stigmer token route. GET /api/stigmer-token answers the
376
+ // signed-in person's token, { accessToken, expiresAt }, which the chat in
377
+ // your app asks for.
378
+ import ai.stigmer.sdk.MintUserTokenInput;
379
+ import ai.stigmer.sdk.MintUserTokenResult;
380
+ import ai.stigmer.sdk.StigmerClient;
381
+ import com.sun.net.httpserver.HttpExchange;
382
+ import com.sun.net.httpserver.HttpServer;
383
+ import java.io.IOException;
384
+ import java.io.OutputStream;
385
+ import java.net.InetSocketAddress;
386
+ import java.nio.charset.StandardCharsets;
387
+
388
+ public class StigmerToken {
389
+ static final String ORG = ${org};
390
+
391
+ record User(String id, String email, String name) {}
392
+
393
+ ${CURRENT_USER_NOTE.map((l) => ` // ${l}`).join("\n")}
394
+ static User currentUser(HttpExchange exchange) {
395
+ String devUser = System.getenv("STIGMER_DEV_USER");
396
+ return devUser == null || devUser.isEmpty() ? null : new User(devUser, devUser, null);
397
+ }
398
+
399
+ public static void main(String[] args) throws IOException {
400
+ // The service account's key, never sent to a browser.
401
+ StigmerClient client = StigmerClient.builder(System.getenv("STIGMER_API_KEY"))
402
+ .baseUrl(${server.target})${insecure}
403
+ .build();
404
+
405
+ int port = Integer.parseInt(System.getenv().getOrDefault("PORT", "${APP_TOKEN_ROUTE_PORT}"));
406
+ HttpServer server = HttpServer.create(new InetSocketAddress(port), 0);
407
+ server.createContext("/api/stigmer-token", exchange -> {
408
+ if (!exchange.getRequestMethod().equals("GET") || !exchange.getRequestURI().getPath().equals("/api/stigmer-token")) {
409
+ answer(exchange, 404, "text/plain", "Not found.");
410
+ return;
411
+ }
412
+ User user = currentUser(exchange);
413
+ if (user == null) {
414
+ answer(exchange, 401, "text/plain", "Nobody is signed in.");
415
+ return;
416
+ }
417
+ MintUserTokenResult token;
418
+ try {
419
+ token = client.tokens().mintUserToken(MintUserTokenInput.builder()
420
+ .org(ORG)
421
+ .userId(user.id())
422
+ .userEmail(user.email())
423
+ .userName(user.name())
424
+ .build());
425
+ } catch (RuntimeException err) {
426
+ err.printStackTrace();
427
+ answer(exchange, 502, "text/plain", ${lit(REFUSED)});
428
+ return;
429
+ }
430
+ // A token and an ISO 8601 instant hold no character JSON escapes.
431
+ answer(exchange, 200, "application/json",
432
+ "{\\"accessToken\\":\\"" + token.accessToken() + "\\",\\"expiresAt\\":\\"" + token.expiresAt() + "\\"}");
433
+ });
434
+ server.start();
435
+ }
436
+
437
+ static void answer(HttpExchange exchange, int status, String contentType, String body) throws IOException {
438
+ byte[] bytes = body.getBytes(StandardCharsets.UTF_8);
439
+ exchange.getResponseHeaders().set("Content-Type", contentType);
440
+ exchange.sendResponseHeaders(status, bytes.length);
441
+ try (OutputStream out = exchange.getResponseBody()) {
442
+ out.write(bytes);
443
+ }
444
+ }
445
+ }
446
+ `;
447
+ }
448
+ const CHAT_INSTALL = "npm install @stigmer/client @stigmer/react-sdk @stigmer/apis @bufbuild/protobuf";
449
+ function signInChat({ agentRef, server }) {
450
+ return {
451
+ install: CHAT_INSTALL,
452
+ installLanguage: "bash",
453
+ file: `${APP_CHAT_COMPONENT}.tsx`,
454
+ language: "tsx",
455
+ code: `"use client";
456
+
457
+ // The agent's chat, for the person signed in to your app. Mount it as
458
+ // <StigmerAgentChat /> in a box with a height: it fills the box.
459
+ import { Stigmer, createTokenCache } from "@stigmer/client";
460
+ import { AgentChat, StigmerProvider } from "@stigmer/react-sdk/chat";
461
+ import "@stigmer/react-sdk/styles.css";
462
+
463
+ // Your backend's token route. A backend apart from this app is reached
464
+ // through this app's proxy, or by its full address.
465
+ const TOKEN_ROUTE = ${lit(APP_TOKEN_ROUTE)};
466
+
467
+ // Asks your backend for a token once, and again a minute before it expires.
468
+ // When your user signs out, call tokens.invalidate().
469
+ const tokens = createTokenCache(async () => {
470
+ const res = await fetch(TOKEN_ROUTE);
471
+ if (!res.ok) throw new Error(\`\${TOKEN_ROUTE} answered \${res.status}: \${await res.text()}\`);
472
+ return res.json();
473
+ });
474
+
475
+ const stigmer = new Stigmer({
476
+ baseUrl: ${server.url},
477
+ getAccessToken: tokens.getAccessToken,
478
+ });
479
+
480
+ export function ${APP_CHAT_COMPONENT}() {
481
+ return (
482
+ <StigmerProvider client={stigmer}>
483
+ <AgentChat agent={${agentRef}} />
484
+ </StigmerProvider>
485
+ );
486
+ }
487
+ `,
488
+ };
489
+ }
490
+ function localChat({ agentRef, server }) {
491
+ return {
492
+ install: CHAT_INSTALL,
493
+ installLanguage: "bash",
494
+ file: `${APP_CHAT_COMPONENT}.tsx`,
495
+ language: "tsx",
496
+ code: `"use client";
497
+
498
+ // Development only. This Stigmer runs on your computer and trusts every
499
+ // caller, so your app talks to it with no sign-in while you build. Going
500
+ // live needs a Stigmer that signs people in, and a token route.
501
+ //
502
+ // The agent's chat. Mount it as <StigmerAgentChat /> in a box with a
503
+ // height: it fills the box.
504
+ import { Stigmer } from "@stigmer/client";
505
+ import { AgentChat, StigmerProvider } from "@stigmer/react-sdk/chat";
506
+ import "@stigmer/react-sdk/styles.css";
507
+
508
+ const stigmer = new Stigmer({
509
+ baseUrl: ${server.url},
510
+ getAccessToken: () => null,
511
+ });
512
+
513
+ export function ${APP_CHAT_COMPONENT}() {
514
+ return (
515
+ <StigmerProvider client={stigmer}>
516
+ <AgentChat agent={${agentRef}} />
517
+ </StigmerProvider>
518
+ );
519
+ }
520
+ `,
521
+ };
522
+ }
523
+ //# sourceMappingURL=app-handover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-handover.js","sourceRoot":"","sources":["src/app-handover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAKH,yEAAyE;AACzE,MAAM,CAAC,MAAM,mBAAmB,GAAwE;IACtG,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;IACjC,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;IAC5B,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;IAChC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;IACxB,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;CAC7B,CAAC;AAoDF,8DAA8D;AAC9D,MAAM,CAAC,MAAM,eAAe,GAAG,oBAAoB,CAAC;AAEpD,+EAA+E;AAC/E,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AAEtD,+GAA+G;AAC/G,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAExD,mFAAmF;AACnF,MAAM,CAAC,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAErD,yEAAyE;AACzE,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAEzC;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAuB;IACtD,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,IAAI,GAAS,EAAE,GAAG,EAAE,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,KAA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 +6,7 @@ import { type RenameInputSchema } from "@stigmer/apis/ai/stigmer/commons/apireso
6
6
  import { IamRole } from "@stigmer/apis/ai/stigmer/iam/v1/enum_pb";
7
7
  import { OrganizationSchema, type Organization } from "@stigmer/apis/ai/stigmer/tenancy/organization/v1/api_pb";
8
8
  import { UpdateOrganizationPoliciesInputSchema, UpdateOrganizationEmbeddingInputSchema, ListMyOrganizationsInputSchema, OrganizationExternalLookupSchema, ListChildOrgsInputSchema, type Organizations, type ChildOrgList } from "@stigmer/apis/ai/stigmer/tenancy/organization/v1/io_pb";
9
+ import { type OnboardingProgress } from "@stigmer/apis/ai/stigmer/tenancy/organization/v1/onboarding_pb";
9
10
  /** Provides operations on organization resources. */
10
11
  export declare class OrganizationClient {
11
12
  private readonly command;
@@ -32,6 +33,7 @@ export declare class OrganizationClient {
32
33
  * until the list ends. Breaking out of the loop stops the reads.
33
34
  */
34
35
  listChildOrgsAll(input: MessageInitShape<typeof ListChildOrgsInputSchema>): AsyncGenerator<ChildOrgList["entries"][number]>;
36
+ getOnboarding(id: string): Promise<OnboardingProgress>;
35
37
  }
36
38
  /** Input for creating or applying an Organization. */
37
39
  export interface OrganizationInput {