@stigmer/client 0.1.3 → 0.3.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 (76) hide show
  1. package/README.md +10 -0
  2. package/app-handover.d.ts +186 -0
  3. package/app-handover.d.ts.map +1 -0
  4. package/app-handover.js +630 -0
  5. package/app-handover.js.map +1 -0
  6. package/gen/agent.d.ts +2 -1
  7. package/gen/agent.d.ts.map +1 -1
  8. package/gen/agent.js +2 -0
  9. package/gen/agent.js.map +1 -1
  10. package/gen/organization.d.ts +2 -0
  11. package/gen/organization.d.ts.map +1 -1
  12. package/gen/organization.js +8 -0
  13. package/gen/organization.js.map +1 -1
  14. package/gen/run.d.ts +7 -1
  15. package/gen/run.d.ts.map +1 -1
  16. package/gen/run.js +23 -1
  17. package/gen/run.js.map +1 -1
  18. package/iam-principal.d.ts +11 -0
  19. package/iam-principal.d.ts.map +1 -1
  20. package/iam-principal.js +16 -0
  21. package/iam-principal.js.map +1 -1
  22. package/index.d.ts +11 -5
  23. package/index.d.ts.map +1 -1
  24. package/index.js +10 -3
  25. package/index.js.map +1 -1
  26. package/node.d.ts.map +1 -1
  27. package/node.js +12 -0
  28. package/node.js.map +1 -1
  29. package/package.json +9 -4
  30. package/platform.d.ts +41 -3
  31. package/platform.d.ts.map +1 -1
  32. package/platform.js +56 -3
  33. package/platform.js.map +1 -1
  34. package/run/format-elapsed.d.ts +10 -0
  35. package/run/format-elapsed.d.ts.map +1 -0
  36. package/run/format-elapsed.js +25 -0
  37. package/run/format-elapsed.js.map +1 -0
  38. package/run/step-words.d.ts +78 -0
  39. package/run/step-words.d.ts.map +1 -0
  40. package/run/step-words.js +316 -0
  41. package/run/step-words.js.map +1 -0
  42. package/run/tool-view.d.ts +49 -2
  43. package/run/tool-view.d.ts.map +1 -1
  44. package/run/tool-view.js +113 -17
  45. package/run/tool-view.js.map +1 -1
  46. package/run/turn-activity.d.ts +9 -7
  47. package/run/turn-activity.d.ts.map +1 -1
  48. package/run/turn-activity.js +24 -144
  49. package/run/turn-activity.js.map +1 -1
  50. package/run/turn-ending.d.ts +59 -0
  51. package/run/turn-ending.d.ts.map +1 -0
  52. package/run/turn-ending.js +405 -0
  53. package/run/turn-ending.js.map +1 -0
  54. package/run/turn-steps.d.ts +16 -0
  55. package/run/turn-steps.d.ts.map +1 -0
  56. package/run/turn-steps.js +65 -0
  57. package/run/turn-steps.js.map +1 -0
  58. package/session-events.d.ts +3 -1
  59. package/session-events.d.ts.map +1 -1
  60. package/session-events.js +1 -0
  61. package/session-events.js.map +1 -1
  62. package/src/app-handover.ts +777 -0
  63. package/src/gen/agent.ts +4 -1
  64. package/src/gen/organization.ts +7 -0
  65. package/src/gen/run.ts +21 -1
  66. package/src/iam-principal.ts +21 -0
  67. package/src/index.ts +55 -1
  68. package/src/node.ts +12 -0
  69. package/src/platform.ts +80 -3
  70. package/src/run/format-elapsed.ts +22 -0
  71. package/src/run/step-words.ts +360 -0
  72. package/src/run/tool-view.ts +133 -19
  73. package/src/run/turn-activity.ts +27 -146
  74. package/src/run/turn-ending.ts +487 -0
  75. package/src/run/turn-steps.ts +81 -0
  76. package/src/session-events.ts +4 -1
@@ -0,0 +1,630 @@
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
+ * in the light or dark of the person's system, as most apps start out.
20
+ *
21
+ * Beside them, what the builder needs to see it run: a short page that shows
22
+ * the chat in a box with a height, and the settings file the backend reads
23
+ * its key and development user from (`appSettingsText`). Every file is named
24
+ * by its path in the builder's project: a Next.js app is one app, holding the
25
+ * route, the chat and the page, so one install covers it; the other stacks'
26
+ * backends serve a React app of its own, which holds the chat and the page.
27
+ * The client's Node transport (`@connectrpc/connect-node`, an optional peer
28
+ * of `@stigmer/client`) is installed only by a line whose files run
29
+ * `@stigmer/client/node`: the Node and Next.js routes. A React app of its own
30
+ * runs the chat in the browser and installs no transport.
31
+ *
32
+ * Who is signed in is the one thing Stigmer cannot know. Every route asks one
33
+ * function, `currentUser`, which the builder replaces with their own sign-in.
34
+ * Until then it answers the person named by `STIGMER_DEV_USER` while that is
35
+ * set, and nobody otherwise, so a route pasted into production unchanged
36
+ * refuses everyone rather than minting for whoever calls it.
37
+ *
38
+ * For a server that trusts every caller (`stigmer up`), only the chat, with
39
+ * no token at all: there is no one to sign in, and the server refuses to
40
+ * mint. That text says it is for development.
41
+ *
42
+ * The text carries no secret: the key is read from the environment, and the
43
+ * functions here never take one. Every value written into code (the
44
+ * organization, the agent, the address) is written as a string literal by
45
+ * `JSON.stringify`, whose escapes are valid in all five languages, so no
46
+ * value can break out of its literal. Framework-free and import-free, so the
47
+ * plain-Node docs gate loads the built module as it stands.
48
+ */
49
+ /** The backends, in the order a picker offers them, with their names. */
50
+ export const APP_HANDOVER_STACKS = [
51
+ { id: "nextjs", name: "Next.js" },
52
+ { id: "node", name: "Node" },
53
+ { id: "python", name: "Python" },
54
+ { id: "go", name: "Go" },
55
+ { id: "java", name: "Java" },
56
+ ];
57
+ /** The path every token route serves and the chat fetches. */
58
+ export const APP_TOKEN_ROUTE = "/api/stigmer-token";
59
+ /** The environment variable the routes read the service account's key from. */
60
+ export const APP_API_KEY_VARIABLE = "STIGMER_API_KEY";
61
+ /** The environment variable naming the person a route signs in until the builder's own sign-in replaces it. */
62
+ export const APP_DEV_USER_VARIABLE = "STIGMER_DEV_USER";
63
+ /** The chat component's name, as the builder mounts it: `<StigmerAgentChat />`. */
64
+ export const APP_CHAT_COMPONENT = "StigmerAgentChat";
65
+ /** The port a standard-library route listens on when `PORT` is unset. */
66
+ export const APP_TOKEN_ROUTE_PORT = 3001;
67
+ /** What the settings file holds in place of the key while the key is not on screen: where the key goes. */
68
+ export const APP_API_KEY_PLACEHOLDER = "<paste your service account's key here>";
69
+ /** What the settings file holds in place of the developer's email while it is not known. */
70
+ export const APP_DEV_USER_PLACEHOLDER = "<your email>";
71
+ /**
72
+ * The backend's settings file (`AppHandover.settingsFile`): the service
73
+ * account's key, and the person the route signs in while the app has no
74
+ * sign-in of its own. A value not given is a placeholder that says what
75
+ * goes there. A line break in a value is dropped, so a value is one line.
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * appSettingsText({ devUser: "ada@acme.example" });
80
+ * // STIGMER_API_KEY=<paste your service account's key here>
81
+ * // STIGMER_DEV_USER=ada@acme.example
82
+ * ```
83
+ */
84
+ export function appSettingsText(values = {}) {
85
+ const line = (value, placeholder) => value === undefined || value.trim() === "" ? placeholder : value.replace(/[\r\n]/g, "");
86
+ return [
87
+ `${APP_API_KEY_VARIABLE}=${line(values.apiKey, APP_API_KEY_PLACEHOLDER)}`,
88
+ `${APP_DEV_USER_VARIABLE}=${line(values.devUser, APP_DEV_USER_PLACEHOLDER)}`,
89
+ "",
90
+ ].join("\n");
91
+ }
92
+ /**
93
+ * The code that puts `org/agent`'s chat in a builder's app, for their stack.
94
+ *
95
+ * @throws {Error} when `baseUrl` is not an absolute `http://` or `https://` address
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * import { buildAppHandover } from "@stigmer/client";
100
+ *
101
+ * const { backend, chat, page } = buildAppHandover({
102
+ * mode: "sign-in",
103
+ * stack: "node",
104
+ * baseUrl: "https://api.stigmer.ai",
105
+ * org: "acme",
106
+ * agent: "variance-reporter",
107
+ * });
108
+ * // backend.file === "server.ts"; chat.file === "src/StigmerAgentChat.tsx"; page.file === "src/App.tsx"
109
+ * ```
110
+ */
111
+ export function buildAppHandover(input) {
112
+ const server = serverOf(input.baseUrl);
113
+ const code = { org: lit(input.org), agentRef: lit(`${input.org}/${input.agent}`), server };
114
+ const app = APPS[input.stack];
115
+ const where = { page: app.page, pagePath: app.pagePath, oneApp: app.oneApp };
116
+ if (input.mode === "local")
117
+ return { chat: localChat(code, app.chatFile), ...where };
118
+ return {
119
+ backend: backendFor(input.stack, code, input.sdkVersion),
120
+ chat: signInChat(code, app.chatFile),
121
+ ...where,
122
+ settingsFile: app.settingsFile,
123
+ readsSettingsFile: READS_SETTINGS_FILE[input.stack],
124
+ };
125
+ }
126
+ function serverOf(baseUrl) {
127
+ let url;
128
+ try {
129
+ url = new URL(baseUrl);
130
+ }
131
+ catch {
132
+ throw new Error(`buildAppHandover: baseUrl must be an absolute address, like https://api.stigmer.ai (got ${JSON.stringify(baseUrl)})`);
133
+ }
134
+ if (url.protocol !== "https:" && url.protocol !== "http:") {
135
+ throw new Error(`buildAppHandover: baseUrl must be http:// or https:// (got ${JSON.stringify(baseUrl)})`);
136
+ }
137
+ const plaintext = url.protocol === "http:";
138
+ // The server answers gRPC and Connect on one port, so the target is the
139
+ // address's own host and port; a URL leaves out a port its scheme implies.
140
+ const port = url.port !== "" ? url.port : plaintext ? "80" : "443";
141
+ const origin = `${url.protocol}//${url.host}${url.pathname === "/" ? "" : url.pathname.replace(/\/$/, "")}`;
142
+ return { url: lit(origin), target: lit(`${url.hostname}:${port}`), plaintext };
143
+ }
144
+ /** A string literal for any of the five languages. */
145
+ function lit(value) {
146
+ return JSON.stringify(value);
147
+ }
148
+ /** Each stack's route; a typed record, so a stack without one fails to compile. */
149
+ const BACKENDS = {
150
+ // One app: its one install covers the route, the chat and the page.
151
+ nextjs: (code) => ({ install: NEXT_APP_INSTALL, installLanguage: "bash", file: "app/api/stigmer-token/route.ts", language: "typescript", code: nextRoute(code) }),
152
+ node: (code) => ({ install: "npm install @stigmer/client @connectrpc/connect-node", installLanguage: "bash", file: "server.ts", language: "typescript", code: nodeRoute(code) }),
153
+ python: (code) => ({ install: "pip install stigmer-sdk", installLanguage: "bash", file: "stigmer_token.py", language: "python", code: pythonRoute(code) }),
154
+ go: (code) => ({ install: "go get go.stigmer.ai/sdk", installLanguage: "bash", file: "main.go", language: "go", code: goRoute(code) }),
155
+ java: (code, sdkVersion) => ({ install: mavenDependency(sdkVersion), installLanguage: "xml", file: "StigmerToken.java", language: "java", code: javaRoute(code) }),
156
+ };
157
+ function backendFor(stack, code, sdkVersion) {
158
+ return BACKENDS[stack](code, sdkVersion);
159
+ }
160
+ /** Whether each stack's route, run as it says, reads the settings file itself. */
161
+ const READS_SETTINGS_FILE = {
162
+ nextjs: true,
163
+ node: true,
164
+ python: false,
165
+ go: false,
166
+ java: false,
167
+ };
168
+ /** A Next.js app: the route, the chat and a page of its own, one app; Next.js reads `.env.local` itself. */
169
+ const NEXT_APP = {
170
+ oneApp: true,
171
+ chatFile: `components/${APP_CHAT_COMPONENT}.tsx`,
172
+ page: {
173
+ file: "app/agent/page.tsx",
174
+ language: "tsx",
175
+ code: `import { ${APP_CHAT_COMPONENT} } from "@/components/${APP_CHAT_COMPONENT}";
176
+
177
+ export default function AgentPage() {
178
+ return (
179
+ <main style={{ height: "100vh" }}>
180
+ <${APP_CHAT_COMPONENT} />
181
+ </main>
182
+ );
183
+ }
184
+ `,
185
+ },
186
+ pagePath: "/agent",
187
+ settingsFile: ".env.local",
188
+ };
189
+ /** A React app of its own (as `npm create vite` makes one) beside a backend: the chat and its root page in `src`. */
190
+ const REACT_APP = {
191
+ oneApp: false,
192
+ chatFile: `src/${APP_CHAT_COMPONENT}.tsx`,
193
+ page: {
194
+ file: "src/App.tsx",
195
+ language: "tsx",
196
+ code: `import { ${APP_CHAT_COMPONENT} } from "./${APP_CHAT_COMPONENT}";
197
+
198
+ export default function App() {
199
+ return (
200
+ <main style={{ height: "100vh" }}>
201
+ <${APP_CHAT_COMPONENT} />
202
+ </main>
203
+ );
204
+ }
205
+ `,
206
+ },
207
+ pagePath: "/",
208
+ settingsFile: ".env",
209
+ };
210
+ /** Each stack's app side; a typed record, so a stack without one fails to compile. */
211
+ const APPS = {
212
+ nextjs: NEXT_APP,
213
+ node: REACT_APP,
214
+ python: REACT_APP,
215
+ go: REACT_APP,
216
+ java: REACT_APP,
217
+ };
218
+ /** A version is pinned only when it is a plain release; anything else (a dev build) is not on Maven Central. */
219
+ const RELEASE = /^\d+\.\d+\.\d+$/;
220
+ function mavenDependency(sdkVersion) {
221
+ const pinned = sdkVersion !== undefined && RELEASE.test(sdkVersion);
222
+ return [
223
+ ...(pinned ? [] : ["<!-- The newest 0.x release. Pin the one you test with: https://central.sonatype.com/artifact/ai.stigmer/stigmer-sdk -->"]),
224
+ "<dependency>",
225
+ " <groupId>ai.stigmer</groupId>",
226
+ " <artifactId>stigmer-sdk</artifactId>",
227
+ ` <version>${pinned ? sdkVersion : "[0.1,1.0)"}</version>`,
228
+ "</dependency>",
229
+ ].join("\n");
230
+ }
231
+ const CURRENT_USER_NOTE = [
232
+ "Replace this with your own sign-in: return the person this request is",
233
+ "from, or nobody. Until then it signs in the email in STIGMER_DEV_USER",
234
+ "while that is set, and nobody otherwise.",
235
+ ];
236
+ const REFUSED = "Stigmer refused the token; the reason is in your server's log.";
237
+ function nodeRoute({ org, server }) {
238
+ return `// Your backend's Stigmer token route. GET /api/stigmer-token answers the
239
+ // signed-in person's token, { accessToken, expiresAt }, which the chat in
240
+ // your app asks for. Run it with: npx tsx --env-file=.env server.ts
241
+ import { createServer, type IncomingMessage } from "node:http";
242
+ import { createNodeClient } from "@stigmer/client/node";
243
+
244
+ const ORG = ${org};
245
+
246
+ // The service account's key, never sent to a browser.
247
+ const stigmer = createNodeClient({
248
+ baseUrl: ${server.url},
249
+ apiKey: process.env.STIGMER_API_KEY!,
250
+ });
251
+
252
+ interface User {
253
+ id: string;
254
+ email?: string;
255
+ name?: string;
256
+ }
257
+
258
+ ${CURRENT_USER_NOTE.map((l) => `// ${l}`).join("\n")}
259
+ function currentUser(req: IncomingMessage): User | null {
260
+ const devUser = process.env.STIGMER_DEV_USER;
261
+ return devUser ? { id: devUser, email: devUser } : null;
262
+ }
263
+
264
+ createServer(async (req, res) => {
265
+ if (req.method !== "GET" || req.url !== "/api/stigmer-token") {
266
+ res.writeHead(404).end();
267
+ return;
268
+ }
269
+ const user = currentUser(req);
270
+ if (!user) {
271
+ res.writeHead(401, { "content-type": "text/plain" }).end("Nobody is signed in.");
272
+ return;
273
+ }
274
+ try {
275
+ const { accessToken, expiresAt } = await stigmer.tokens.mintUserToken({
276
+ org: ORG,
277
+ userId: user.id,
278
+ userEmail: user.email,
279
+ userName: user.name,
280
+ });
281
+ res.writeHead(200, { "content-type": "application/json" });
282
+ res.end(JSON.stringify({ accessToken, expiresAt: expiresAt.toISOString() }));
283
+ } catch (err) {
284
+ console.error(err);
285
+ res.writeHead(502, { "content-type": "text/plain" }).end(${lit(REFUSED)});
286
+ }
287
+ }).listen(Number(process.env.PORT ?? ${APP_TOKEN_ROUTE_PORT}));
288
+ `;
289
+ }
290
+ function nextRoute({ org, server }) {
291
+ return `// Your app's Stigmer token route. GET /api/stigmer-token answers the
292
+ // signed-in person's token, { accessToken, expiresAt }, which the chat asks for.
293
+ import { createNodeClient } from "@stigmer/client/node";
294
+
295
+ // Every request answers for whoever is signed in: never prerender it.
296
+ export const dynamic = "force-dynamic";
297
+
298
+ const ORG = ${org};
299
+
300
+ // The service account's key, never sent to a browser.
301
+ const stigmer = createNodeClient({
302
+ baseUrl: ${server.url},
303
+ apiKey: process.env.STIGMER_API_KEY!,
304
+ });
305
+
306
+ interface User {
307
+ id: string;
308
+ email?: string;
309
+ name?: string;
310
+ }
311
+
312
+ ${CURRENT_USER_NOTE.map((l) => `// ${l}`).join("\n")}
313
+ async function currentUser(request: Request): Promise<User | null> {
314
+ const devUser = process.env.STIGMER_DEV_USER;
315
+ return devUser ? { id: devUser, email: devUser } : null;
316
+ }
317
+
318
+ export async function GET(request: Request): Promise<Response> {
319
+ const user = await currentUser(request);
320
+ if (!user) return new Response("Nobody is signed in.", { status: 401 });
321
+ try {
322
+ const { accessToken, expiresAt } = await stigmer.tokens.mintUserToken({
323
+ org: ORG,
324
+ userId: user.id,
325
+ userEmail: user.email,
326
+ userName: user.name,
327
+ });
328
+ return Response.json({ accessToken, expiresAt: expiresAt.toISOString() });
329
+ } catch (err) {
330
+ console.error(err);
331
+ return new Response(${lit(REFUSED)}, { status: 502 });
332
+ }
333
+ }
334
+ `;
335
+ }
336
+ function pythonRoute({ org, server }) {
337
+ const insecure = server.plaintext ? ", insecure=True" : "";
338
+ return `"""Your backend's Stigmer token route.
339
+
340
+ GET /api/stigmer-token answers the signed-in person's token,
341
+ { accessToken, expiresAt }, which the chat in your app asks for.
342
+ Run it with: python stigmer_token.py
343
+ """
344
+
345
+ import json
346
+ import logging
347
+ import os
348
+ from dataclasses import dataclass
349
+ from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
350
+
351
+ from stigmer import StigmerClient
352
+
353
+ ORG = ${org}
354
+
355
+ # The service account's key, never sent to a browser.
356
+ client = StigmerClient(os.environ["STIGMER_API_KEY"], base_url=${server.target}${insecure})
357
+
358
+
359
+ @dataclass
360
+ class User:
361
+ id: str
362
+ email: str | None = None
363
+ name: str | None = None
364
+
365
+
366
+ def current_user(request: BaseHTTPRequestHandler) -> User | None:
367
+ """${CURRENT_USER_NOTE.join("\n ")}
368
+ """
369
+ dev_user = os.environ.get("STIGMER_DEV_USER")
370
+ return User(id=dev_user, email=dev_user) if dev_user else None
371
+
372
+
373
+ class TokenRoute(BaseHTTPRequestHandler):
374
+ def do_GET(self) -> None:
375
+ if self.path != "/api/stigmer-token":
376
+ self.send_error(404)
377
+ return
378
+ user = current_user(self)
379
+ if user is None:
380
+ self.answer(401, "text/plain", b"Nobody is signed in.")
381
+ return
382
+ try:
383
+ token = client.tokens.mint_user_token(
384
+ org=ORG, user_id=user.id, user_email=user.email, user_name=user.name
385
+ )
386
+ except Exception:
387
+ logging.exception("minting a Stigmer token")
388
+ self.answer(502, "text/plain", ${lit(REFUSED)}.encode())
389
+ return
390
+ body = {"accessToken": token.access_token, "expiresAt": token.expires_at.isoformat()}
391
+ self.answer(200, "application/json", json.dumps(body).encode())
392
+
393
+ def answer(self, status: int, content_type: str, body: bytes) -> None:
394
+ self.send_response(status)
395
+ self.send_header("Content-Type", content_type)
396
+ self.end_headers()
397
+ self.wfile.write(body)
398
+
399
+
400
+ if __name__ == "__main__":
401
+ port = int(os.environ.get("PORT", "${APP_TOKEN_ROUTE_PORT}"))
402
+ ThreadingHTTPServer(("", port), TokenRoute).serve_forever()
403
+ `;
404
+ }
405
+ function goRoute({ org, server }) {
406
+ const insecure = server.plaintext ? ",\n\t\tstigmer.WithInsecure()," : ",";
407
+ return `// Your backend's Stigmer token route. GET /api/stigmer-token answers the
408
+ // signed-in person's token, { accessToken, expiresAt }, which the chat in
409
+ // your app asks for. Run it with: go run .
410
+ package main
411
+
412
+ import (
413
+ "encoding/json"
414
+ "log"
415
+ "net/http"
416
+ "os"
417
+ "time"
418
+
419
+ stigmer "go.stigmer.ai/sdk"
420
+ )
421
+
422
+ const org = ${org}
423
+
424
+ type user struct{ ID, Email, Name string }
425
+
426
+ ${CURRENT_USER_NOTE.map((l) => `// ${l}`).join("\n")}
427
+ func currentUser(r *http.Request) *user {
428
+ if devUser := os.Getenv("STIGMER_DEV_USER"); devUser != "" {
429
+ return &user{ID: devUser, Email: devUser}
430
+ }
431
+ return nil
432
+ }
433
+
434
+ func main() {
435
+ // The service account's key, never sent to a browser.
436
+ client, err := stigmer.NewClient(
437
+ stigmer.WithAPIKey(os.Getenv("STIGMER_API_KEY")),
438
+ stigmer.WithBaseURL(${server.target})${insecure}
439
+ )
440
+ if err != nil {
441
+ log.Fatal(err)
442
+ }
443
+ defer client.Close()
444
+
445
+ http.HandleFunc("GET /api/stigmer-token", func(w http.ResponseWriter, r *http.Request) {
446
+ u := currentUser(r)
447
+ if u == nil {
448
+ http.Error(w, "Nobody is signed in.", http.StatusUnauthorized)
449
+ return
450
+ }
451
+ token, err := client.Tokens.MintUserToken(r.Context(), &stigmer.MintUserTokenInput{
452
+ Org: org,
453
+ UserID: u.ID,
454
+ UserEmail: u.Email,
455
+ UserName: u.Name,
456
+ })
457
+ if err != nil {
458
+ log.Print(err)
459
+ http.Error(w, ${lit(REFUSED)}, http.StatusBadGateway)
460
+ return
461
+ }
462
+ w.Header().Set("Content-Type", "application/json")
463
+ json.NewEncoder(w).Encode(map[string]string{
464
+ "accessToken": token.AccessToken,
465
+ "expiresAt": token.ExpiresAt.Format(time.RFC3339),
466
+ })
467
+ })
468
+
469
+ port := os.Getenv("PORT")
470
+ if port == "" {
471
+ port = "${APP_TOKEN_ROUTE_PORT}"
472
+ }
473
+ log.Fatal(http.ListenAndServe(":"+port, nil))
474
+ }
475
+ `;
476
+ }
477
+ function javaRoute({ org, server }) {
478
+ const insecure = server.plaintext ? "\n .insecure()" : "";
479
+ return `// Your backend's Stigmer token route. GET /api/stigmer-token answers the
480
+ // signed-in person's token, { accessToken, expiresAt }, which the chat in
481
+ // your app asks for.
482
+ import ai.stigmer.sdk.MintUserTokenInput;
483
+ import ai.stigmer.sdk.MintUserTokenResult;
484
+ import ai.stigmer.sdk.StigmerClient;
485
+ import com.sun.net.httpserver.HttpExchange;
486
+ import com.sun.net.httpserver.HttpServer;
487
+ import java.io.IOException;
488
+ import java.io.OutputStream;
489
+ import java.net.InetSocketAddress;
490
+ import java.nio.charset.StandardCharsets;
491
+
492
+ public class StigmerToken {
493
+ static final String ORG = ${org};
494
+
495
+ record User(String id, String email, String name) {}
496
+
497
+ ${CURRENT_USER_NOTE.map((l) => ` // ${l}`).join("\n")}
498
+ static User currentUser(HttpExchange exchange) {
499
+ String devUser = System.getenv("STIGMER_DEV_USER");
500
+ return devUser == null || devUser.isEmpty() ? null : new User(devUser, devUser, null);
501
+ }
502
+
503
+ public static void main(String[] args) throws IOException {
504
+ // The service account's key, never sent to a browser.
505
+ StigmerClient client = StigmerClient.builder(System.getenv("STIGMER_API_KEY"))
506
+ .baseUrl(${server.target})${insecure}
507
+ .build();
508
+
509
+ int port = Integer.parseInt(System.getenv().getOrDefault("PORT", "${APP_TOKEN_ROUTE_PORT}"));
510
+ HttpServer server = HttpServer.create(new InetSocketAddress(port), 0);
511
+ server.createContext("/api/stigmer-token", exchange -> {
512
+ if (!exchange.getRequestMethod().equals("GET") || !exchange.getRequestURI().getPath().equals("/api/stigmer-token")) {
513
+ answer(exchange, 404, "text/plain", "Not found.");
514
+ return;
515
+ }
516
+ User user = currentUser(exchange);
517
+ if (user == null) {
518
+ answer(exchange, 401, "text/plain", "Nobody is signed in.");
519
+ return;
520
+ }
521
+ MintUserTokenResult token;
522
+ try {
523
+ token = client.tokens().mintUserToken(MintUserTokenInput.builder()
524
+ .org(ORG)
525
+ .userId(user.id())
526
+ .userEmail(user.email())
527
+ .userName(user.name())
528
+ .build());
529
+ } catch (RuntimeException err) {
530
+ err.printStackTrace();
531
+ answer(exchange, 502, "text/plain", ${lit(REFUSED)});
532
+ return;
533
+ }
534
+ // A token and an ISO 8601 instant hold no character JSON escapes.
535
+ answer(exchange, 200, "application/json",
536
+ "{\\"accessToken\\":\\"" + token.accessToken() + "\\",\\"expiresAt\\":\\"" + token.expiresAt() + "\\"}");
537
+ });
538
+ server.start();
539
+ }
540
+
541
+ static void answer(HttpExchange exchange, int status, String contentType, String body) throws IOException {
542
+ byte[] bytes = body.getBytes(StandardCharsets.UTF_8);
543
+ exchange.getResponseHeaders().set("Content-Type", contentType);
544
+ exchange.sendResponseHeaders(status, bytes.length);
545
+ try (OutputStream out = exchange.getResponseBody()) {
546
+ out.write(bytes);
547
+ }
548
+ }
549
+ }
550
+ `;
551
+ }
552
+ /** The chat's install: browser code only, so no Node transport. */
553
+ const CHAT_INSTALL = "npm install @stigmer/client @stigmer/react-sdk @stigmer/apis @bufbuild/protobuf";
554
+ /** A Next.js app's one install: the chat's, and the transport its route runs on `@stigmer/client/node`. */
555
+ const NEXT_APP_INSTALL = `${CHAT_INSTALL} @connectrpc/connect-node`;
556
+ function signInChat({ agentRef, server }, file) {
557
+ return {
558
+ install: CHAT_INSTALL,
559
+ installLanguage: "bash",
560
+ file,
561
+ language: "tsx",
562
+ code: `"use client";
563
+
564
+ // The agent's chat, for the person signed in to your app. Mount it as
565
+ // <StigmerAgentChat /> in a box with a height: it fills the box.
566
+ import { Stigmer, createTokenCache } from "@stigmer/client";
567
+ import { AgentChat, StigmerProvider } from "@stigmer/react-sdk/chat";
568
+ import "@stigmer/react-sdk/styles.css";
569
+
570
+ // Your backend's token route. A backend apart from this app is reached
571
+ // through this app's proxy, or by its full address.
572
+ const TOKEN_ROUTE = ${lit(APP_TOKEN_ROUTE)};
573
+
574
+ // Asks your backend for a token once, and again a minute before it expires.
575
+ // When your user signs out, call tokens.invalidate().
576
+ const tokens = createTokenCache(async () => {
577
+ const res = await fetch(TOKEN_ROUTE);
578
+ if (!res.ok) throw new Error(\`\${TOKEN_ROUTE} answered \${res.status}: \${await res.text()}\`);
579
+ return res.json();
580
+ });
581
+
582
+ const stigmer = new Stigmer({
583
+ baseUrl: ${server.url},
584
+ getAccessToken: tokens.getAccessToken,
585
+ });
586
+
587
+ export function ${APP_CHAT_COMPONENT}() {
588
+ return (
589
+ <StigmerProvider client={stigmer} colorMode="system">
590
+ <AgentChat agent={${agentRef}} />
591
+ </StigmerProvider>
592
+ );
593
+ }
594
+ `,
595
+ };
596
+ }
597
+ function localChat({ agentRef, server }, file) {
598
+ return {
599
+ install: CHAT_INSTALL,
600
+ installLanguage: "bash",
601
+ file,
602
+ language: "tsx",
603
+ code: `"use client";
604
+
605
+ // Development only. This Stigmer runs on your computer and trusts every
606
+ // caller, so your app talks to it with no sign-in while you build. Going
607
+ // live needs a Stigmer that signs people in, and a token route.
608
+ //
609
+ // The agent's chat. Mount it as <StigmerAgentChat /> in a box with a
610
+ // height: it fills the box.
611
+ import { Stigmer } from "@stigmer/client";
612
+ import { AgentChat, StigmerProvider } from "@stigmer/react-sdk/chat";
613
+ import "@stigmer/react-sdk/styles.css";
614
+
615
+ const stigmer = new Stigmer({
616
+ baseUrl: ${server.url},
617
+ getAccessToken: () => null,
618
+ });
619
+
620
+ export function ${APP_CHAT_COMPONENT}() {
621
+ return (
622
+ <StigmerProvider client={stigmer} colorMode="system">
623
+ <AgentChat agent={${agentRef}} />
624
+ </StigmerProvider>
625
+ );
626
+ }
627
+ `,
628
+ };
629
+ }
630
+ //# sourceMappingURL=app-handover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-handover.js","sourceRoot":"","sources":["src/app-handover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;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;AAmFF,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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,7 +6,7 @@ import { ListAgentsRequestSchema, type AgentList } from "@stigmer/apis/ai/stigme
6
6
  import { TagAgentVersionInputSchema, ListAgentVersionsInputSchema, GetAgentVersionInputSchema, type ListAgentVersionsResponse, type AgentVersionEntry } from "@stigmer/apis/ai/stigmer/agentic/agent/v1/version_pb";
7
7
  import { HookFormat } from "@stigmer/apis/ai/stigmer/agentic/plugin/v1/hooks_pb";
8
8
  import { ServiceTier, ThinkingMode } from "@stigmer/apis/ai/stigmer/agentic/run/v1/enum_pb";
9
- import { Harness } from "@stigmer/apis/ai/stigmer/agentic/session/v1/enum_pb";
9
+ import { Harness, Computer } from "@stigmer/apis/ai/stigmer/agentic/session/v1/enum_pb";
10
10
  import { ApiResourceVisibility } from "@stigmer/apis/ai/stigmer/commons/apiresource/enum_pb";
11
11
  import { type UpdateVisibilityInputSchema, type RenameInputSchema } from "@stigmer/apis/ai/stigmer/commons/apiresource/io_pb";
12
12
  /** Provides operations on agent resources. */
@@ -66,6 +66,7 @@ export interface AgentInput {
66
66
  subagents?: ResourceRef[];
67
67
  mcpServers?: AgentMcpServerInput[];
68
68
  environmentRef?: ResourceRef;
69
+ computer?: Computer;
69
70
  }
70
71
  /** SDK input type for EnvVarDeclaration. */
71
72
  export interface EnvVarDeclarationInput {