pi-durable-bot 0.0.0-stage → 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 (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +279 -2
  3. package/dist/agent/agent.js +244 -0
  4. package/dist/agent/agent.js.map +1 -0
  5. package/dist/agent/judge.js +78 -0
  6. package/dist/agent/judge.js.map +1 -0
  7. package/dist/agent/models.js +72 -0
  8. package/dist/agent/models.js.map +1 -0
  9. package/dist/bot/bot.js +351 -0
  10. package/dist/bot/bot.js.map +1 -0
  11. package/dist/bot/control.js +67 -0
  12. package/dist/bot/control.js.map +1 -0
  13. package/dist/bot/definition.js +123 -0
  14. package/dist/bot/definition.js.map +1 -0
  15. package/dist/bot/machine.js +26 -0
  16. package/dist/bot/machine.js.map +1 -0
  17. package/dist/bot/prompt.js +169 -0
  18. package/dist/bot/prompt.js.map +1 -0
  19. package/dist/bot/timers.js +2 -0
  20. package/dist/bot/timers.js.map +1 -0
  21. package/dist/channels/load.js +21 -0
  22. package/dist/channels/load.js.map +1 -0
  23. package/dist/channels/slack/index.js +518 -0
  24. package/dist/channels/slack/index.js.map +1 -0
  25. package/dist/channels/slack/sdk.js +55 -0
  26. package/dist/channels/slack/sdk.js.map +1 -0
  27. package/dist/channels/terminal/index.js +19 -0
  28. package/dist/channels/terminal/index.js.map +1 -0
  29. package/dist/channels/test/index.js +197 -0
  30. package/dist/channels/test/index.js.map +1 -0
  31. package/dist/cli/agent.js +78 -0
  32. package/dist/cli/agent.js.map +1 -0
  33. package/dist/cli/ai.js +126 -0
  34. package/dist/cli/ai.js.map +1 -0
  35. package/dist/cli/bots.js +57 -0
  36. package/dist/cli/bots.js.map +1 -0
  37. package/dist/cli/chat.js +157 -0
  38. package/dist/cli/chat.js.map +1 -0
  39. package/dist/cli/control.js +52 -0
  40. package/dist/cli/control.js.map +1 -0
  41. package/dist/cli/init.js +104 -0
  42. package/dist/cli/init.js.map +1 -0
  43. package/dist/cli/pots.js +75 -0
  44. package/dist/cli/pots.js.map +1 -0
  45. package/dist/cli/service.js +228 -0
  46. package/dist/cli/service.js.map +1 -0
  47. package/dist/cli/trace.js +172 -0
  48. package/dist/cli/trace.js.map +1 -0
  49. package/dist/core/channel.js +52 -0
  50. package/dist/core/channel.js.map +1 -0
  51. package/dist/core/env-file.js +22 -0
  52. package/dist/core/env-file.js.map +1 -0
  53. package/dist/core/home.js +16 -0
  54. package/dist/core/home.js.map +1 -0
  55. package/dist/core/judge.js +2 -0
  56. package/dist/core/judge.js.map +1 -0
  57. package/dist/core/sql.js +2 -0
  58. package/dist/core/sql.js.map +1 -0
  59. package/dist/core/wake.js +2 -0
  60. package/dist/core/wake.js.map +1 -0
  61. package/dist/gateway/channels.js +69 -0
  62. package/dist/gateway/channels.js.map +1 -0
  63. package/dist/gateway/config.js +4 -0
  64. package/dist/gateway/config.js.map +1 -0
  65. package/dist/gateway/errors.js +54 -0
  66. package/dist/gateway/errors.js.map +1 -0
  67. package/dist/gateway/gateway.js +239 -0
  68. package/dist/gateway/gateway.js.map +1 -0
  69. package/dist/gateway/inbox.js +80 -0
  70. package/dist/gateway/inbox.js.map +1 -0
  71. package/dist/gateway/log.js +251 -0
  72. package/dist/gateway/log.js.map +1 -0
  73. package/dist/gateway/outbox.js +77 -0
  74. package/dist/gateway/outbox.js.map +1 -0
  75. package/dist/gateway/telemetry.js +131 -0
  76. package/dist/gateway/telemetry.js.map +1 -0
  77. package/dist/gateway/timers.js +121 -0
  78. package/dist/gateway/timers.js.map +1 -0
  79. package/dist/gateway/tracing.js +187 -0
  80. package/dist/gateway/tracing.js.map +1 -0
  81. package/dist/gateway/waker.js +226 -0
  82. package/dist/gateway/waker.js.map +1 -0
  83. package/dist/main.js +148 -0
  84. package/dist/main.js.map +1 -0
  85. package/docs/channels/slack-app-manifest.yaml +54 -0
  86. package/docs/channels/slack.md +22 -0
  87. package/package.json +61 -4
@@ -0,0 +1,123 @@
1
+ import { createHash } from "node:crypto";
2
+ import { readFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import { Effect, Schema } from "effect";
6
+ export const DEFAULT_SETTINGS = {
7
+ debounceMs: 3_000,
8
+ debounceMaxMs: 20_000,
9
+ judgeThreshold: 0.5,
10
+ judgeContextMessages: 20,
11
+ fallbackWakeMinutes: 120,
12
+ compaction: {},
13
+ };
14
+ export const DEFAULT_MODEL = "openai/gpt-6.1-sol";
15
+ export const DEFAULT_JUDGE = "main";
16
+ export function botPaths(dir) {
17
+ return {
18
+ dir,
19
+ definition: join(dir, "bot.json"),
20
+ definitionError: join(dir, "bot.json.error"),
21
+ persona: join(dir, "persona.md"),
22
+ responsibilities: join(dir, "responsibilities.md"),
23
+ notes: join(dir, "notes.md"),
24
+ workspace: join(dir, "workspace"),
25
+ db: join(dir, "bot.sqlite"),
26
+ socket: controlAddress(dir),
27
+ crashAfterSend: join(dir, "crash-after-send"),
28
+ crashAfterWake: join(dir, "crash-after-wake"),
29
+ /** A note from pots init: the bot is woken with it at its first start, then the file is removed. */
30
+ firstWake: join(dir, "first-wake.md"),
31
+ };
32
+ }
33
+ /**
34
+ * The control endpoint of a bot: a Unix socket in its folder, or a named pipe on Windows. A Unix socket path must be
35
+ * short (104 bytes on macOS), so a deep folder gets its socket in the temporary directory instead.
36
+ */
37
+ function controlAddress(dir) {
38
+ const name = `pots-${createHash("sha256").update(process.platform === "win32" ? dir.toLowerCase() : dir).digest("hex").slice(0, 16)}`;
39
+ if (process.platform === "win32")
40
+ return `\\\\.\\pipe\\${name}`;
41
+ const socket = join(dir, "control.sock");
42
+ return Buffer.byteLength(socket) < 100 ? socket : join(tmpdir(), `${name}.sock`);
43
+ }
44
+ /** A bot ID: lowercase letters, digits, "_" and "-". It names the bot's folder. */
45
+ export const BOT_ID = /^[a-z0-9][a-z0-9_-]*$/;
46
+ const PROVIDER_MODEL = /^[^/]+\/.+$/;
47
+ /** bot.json as a schema: the checks, the defaults and the types. */
48
+ const Definition = Schema.Struct({
49
+ name: Schema.Trim.check(Schema.isNonEmpty()),
50
+ model: Schema.String.check(Schema.isPattern(PROVIDER_MODEL)).pipe(Schema.withDecodingDefaultKey(Effect.succeed(DEFAULT_MODEL))),
51
+ thinking: Schema.Literals(["off", "minimal", "low", "medium", "high", "xhigh"]).pipe(Schema.withDecodingDefaultKey(Effect.succeed("medium"))),
52
+ judge: Schema.String.check(Schema.makeFilter((judge) => judge === "main" || judge === "off" || PROVIDER_MODEL.test(judge))).pipe(Schema.withDecodingDefaultKey(Effect.succeed(DEFAULT_JUDGE))),
53
+ channels: Schema.Array(Schema.StructWithRest(Schema.Struct({ id: Schema.String.check(Schema.isPattern(/^[a-z0-9][a-z0-9-]*$/)), type: Schema.String }), [
54
+ Schema.Record(Schema.String, Schema.Unknown),
55
+ ])),
56
+ settings: Schema.Struct({
57
+ debounceMs: Schema.Finite.pipe(Schema.withDecodingDefaultKey(Effect.succeed(DEFAULT_SETTINGS.debounceMs))),
58
+ debounceMaxMs: Schema.Finite.pipe(Schema.withDecodingDefaultKey(Effect.succeed(DEFAULT_SETTINGS.debounceMaxMs))),
59
+ judgeThreshold: Schema.Finite.pipe(Schema.withDecodingDefaultKey(Effect.succeed(DEFAULT_SETTINGS.judgeThreshold))),
60
+ judgeContextMessages: Schema.Finite.pipe(Schema.withDecodingDefaultKey(Effect.succeed(DEFAULT_SETTINGS.judgeContextMessages))),
61
+ fallbackWakeMinutes: Schema.Finite.pipe(Schema.withDecodingDefaultKey(Effect.succeed(DEFAULT_SETTINGS.fallbackWakeMinutes))),
62
+ compaction: Schema.Struct({
63
+ reserveTokens: Schema.optionalKey(Schema.Finite),
64
+ keepRecentTokens: Schema.optionalKey(Schema.Finite),
65
+ backgroundTokens: Schema.optionalKey(Schema.Finite),
66
+ }).pipe(Schema.withDecodingDefaultKey(Effect.succeed({}))),
67
+ }).pipe(Schema.withDecodingDefaultKey(Effect.succeed({}))),
68
+ });
69
+ const validate = Schema.toStandardSchemaV1(Definition)["~standard"].validate;
70
+ /** The message for the first problem in bot.json, in the words people know from earlier versions. */
71
+ function problem(raw, issue) {
72
+ const path = (issue.path ?? []).map((part) => (typeof part === "object" ? part.key : part));
73
+ const channel = raw.channels?.[Number(path[1])];
74
+ switch (path[0]) {
75
+ case undefined:
76
+ return `must be a JSON object: ${issue.message}`;
77
+ case "name":
78
+ return `"name" is required`;
79
+ case "model":
80
+ return `"model" must be "provider/modelId"`;
81
+ case "judge":
82
+ return `"judge" must be "main", "off" or "provider/modelId"`;
83
+ case "thinking":
84
+ return `"thinking" must be off, minimal, low, medium, high or xhigh`;
85
+ case "channels":
86
+ if (path.length === 1)
87
+ return `"channels" must be a list`;
88
+ if (path[2] === "type")
89
+ return `channel ${String(channel?.id)} needs a "type"`;
90
+ return `every channel needs an "id" of lowercase letters, digits and dashes`;
91
+ default:
92
+ return `${path.join(".")}: ${issue.message}`;
93
+ }
94
+ }
95
+ /** Read and check bot.json. Throws with a readable message when it is wrong. */
96
+ export function readDefinition(file) {
97
+ const text = readFileSync(file, "utf8");
98
+ const raw = JSON.parse(text);
99
+ const result = validate(raw);
100
+ if (result instanceof Promise)
101
+ throw new Error(`${file}: could not be checked`);
102
+ if (result.issues)
103
+ throw new Error(`${file}: ${problem(raw, result.issues[0])}`);
104
+ const decoded = result.value;
105
+ const ids = new Set();
106
+ for (const channel of decoded.channels) {
107
+ if (ids.has(channel.id))
108
+ throw new Error(`${file}: channel id ${channel.id} is used twice`);
109
+ ids.add(channel.id);
110
+ }
111
+ return {
112
+ text,
113
+ definition: {
114
+ name: decoded.name,
115
+ model: decoded.model,
116
+ thinking: decoded.thinking,
117
+ judge: decoded.judge,
118
+ channels: decoded.channels.map((channel) => ({ ...channel })),
119
+ settings: { ...decoded.settings, compaction: { ...decoded.settings.compaction } },
120
+ },
121
+ };
122
+ }
123
+ //# sourceMappingURL=definition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/bot/defin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G,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,OAAO,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACvC,IAAI,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,gBAAgB,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC;QAC5F,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;IACD,OAAO;QACL,IAAI;QACJ,UAAU,EAAE;YACV,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;YAC7D,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE;SAClF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { execFileSync } from "node:child_process";
2
+ import { arch, hostname, release, userInfo } from "node:os";
3
+ export function describeMachine() {
4
+ const platform = process.platform;
5
+ const os = platform === "darwin"
6
+ ? `macOS ${run("sw_vers", ["-productVersion"]) ?? release()}`
7
+ : platform === "win32"
8
+ ? `Windows ${release()}`
9
+ : `${platform === "linux" ? "Linux" : platform} ${release()}`;
10
+ return {
11
+ os: `${os} (${arch()})`,
12
+ hostname: hostname(),
13
+ user: userInfo().username,
14
+ shell: platform === "win32" ? "Git Bash (Windows paths also work, for example C:/Users)" : "bash",
15
+ sudo: platform !== "win32" && run("sudo", ["-n", "true"]) !== undefined,
16
+ };
17
+ }
18
+ function run(command, args) {
19
+ try {
20
+ return execFileSync(command, args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 5_000 }).trim();
21
+ }
22
+ catch {
23
+ return undefined;
24
+ }
25
+ }
26
+ //# sourceMappingURL=machine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"machine.js","sourceRoot":"","sources":["../../src/bot/machine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAc5D,MAAM,UAAU,eAAe;IAC7B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;IAClC,MAAM,EAAE,GACN,QAAQ,KAAK,QAAQ;QACnB,CAAC,CAAC,SAAS,GAAG,CAAC,SAAS,EAAE,CAAC,iBAAiB,CAAC,CAAC,IAAI,OAAO,EAAE,EAAE;QAC7D,CAAC,CAAC,QAAQ,KAAK,OAAO;YACpB,CAAC,CAAC,WAAW,OAAO,EAAE,EAAE;YACxB,CAAC,CAAC,GAAG,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,IAAI,OAAO,EAAE,EAAE,CAAC;IACpE,OAAO;QACL,EAAE,EAAE,GAAG,EAAE,KAAK,IAAI,EAAE,GAAG;QACvB,QAAQ,EAAE,QAAQ,EAAE;QACpB,IAAI,EAAE,QAAQ,EAAE,CAAC,QAAQ;QACzB,KAAK,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,0DAA0D,CAAC,CAAC,CAAC,MAAM;QACjG,IAAI,EAAE,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,KAAK,SAAS;KACxE,CAAC;AACJ,CAAC;AAED,SAAS,GAAG,CAAC,OAAe,EAAE,IAAc;IAC1C,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACvH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,169 @@
1
+ import { LOG_SCHEMA } from "../gateway/log.js";
2
+ export function identitySection(facts, persona) {
3
+ return `# Who you are\nYou are ${facts.name}.\n\n${persona.trim()}`;
4
+ }
5
+ export function workSection(facts) {
6
+ const accounts = facts.accounts.map((account) => ` - ${account.channel}: ${account.me ? account.me.address : "(not connected yet)"}`).join("\n");
7
+ return `# How you work
8
+ - You are a coworker on a team. You listen to every message in the places you were invited to (channels, DMs, group chats). Every event goes into the message log: messages that do not mention you, edits, deletions, reactions, people joining, and your own messages.
9
+ - You are woken when there is something for you: someone mentions you or sends you a DM; the judge finds that people are talking about something you are responsible for and you need to respond (with the judge off, every message that does not mention you comes to you); a time you set comes; or the fallback check-in. A wake message tells you only where, who, why, the time of each new event and the time now. Read the content yourself in the log.
10
+ - While you are working on a place, new events there come to you as "[new events]".
11
+ - You decide whether to speak, what to say, where and when. You also decide whether a message is out of date and whether it still needs anything. A coworker does not need to answer in seconds: you can think and do the work first, then reply.
12
+ - Your answer text is not sent to anyone. To speak in a channel, use send. To add a reaction, use react. For other platform features, use call.
13
+
14
+ # Addresses
15
+ - An address is an opaque string that points to a place, thread, message or person. It starts with the channel account. Copy addresses from wake messages or the log; do not build them yourself.
16
+ - The "to" of send: a place gives a new message; a thread or message gives a reply in that thread; a person gives a DM.
17
+ - To mention a person in text, put their address in angle brackets: <person address>.
18
+ - Your own address in each channel account:
19
+ ${accounts}
20
+
21
+ # Tools and command line
22
+ - Tools: read, write, edit, bash, and send, react, call.
23
+ - The command line pots does the same channel actions, and also handles timed wakes, turning the page and context use. Your scripts and scheduled jobs can use it too:
24
+ pots send <address> <text, or - to read stdin> [--id <send ID>] a send ID is sent only once; use the same ID when you redo
25
+ pots react <message address> <emoji> [--remove]
26
+ pots call <channel> <method> [JSON params, or -]
27
+ pots wake --in 30m | --at "2026-10-28 09:00" [--note <text>] timed wake; with no time it is now
28
+ pots wake --list | --cancel <id>
29
+ pots context
30
+ pots turn-page --note <text>
31
+ Outside your own bash (for example in cron), write it in full: ${facts.pots} <command> --bot ${facts.id}
32
+
33
+ # This computer
34
+ - It is yours to work on: ${facts.machine.os}, host ${facts.machine.hostname}, user ${facts.machine.user}. The bash tool runs ${facts.machine.shell}.
35
+ - You have all the permissions of this user${facts.machine.sudo ? ", and sudo works without a password" : ""}. Your actions need no approval. You can install what you need.
36
+ - The screen: if this computer has a desktop, use it like a person. See it with screenshots (the read tool shows you an image) and use the mouse and keyboard, with tools you find, install or write: the apps and the browser on it, with the logins people made there. People can watch it and take over at any time. The gateway usually runs as a background service, so your shell may not have the desktop's environment (such as DISPLAY). If there is no desktop, work without a screen, and ask a person before you set up a virtual one.
37
+ - Working directory: ${facts.paths.workspace}`;
38
+ }
39
+ export function logSection(facts) {
40
+ const db = facts.paths.db;
41
+ return `# Message log
42
+ - SQLite file: ${db}. Open it read-only. For example:
43
+ node -e 'const {DatabaseSync}=require("node:sqlite");const db=new DatabaseSync(process.argv[1],{readOnly:true});console.log(db.prepare(process.argv[2]).all())' ${db} "SELECT ..."
44
+ - Tables:
45
+ ${LOG_SCHEMA}
46
+ - bot_wakes(id, at, reason, place, text, submission): each time you were woken, with the full wake message.
47
+ - bot_timers(id, due_at, note, state, set_by, created_at, fired_at): timed wakes. set_by is agent (you set it) or fallback.
48
+ - Tables that start with pi_ are your conversation storage (pi-durable).`;
49
+ }
50
+ export function folderSection(facts) {
51
+ const paths = facts.paths;
52
+ return `# Your folder: ${paths.dir}
53
+ - bot.json: your definition: name, model, thinking, judge, channels (channel accounts), settings. model is "provider/modelId". judge decides which messages that do not mention you wake you: "main" (your own model judges), "off" (all of them), or a classifier "provider/modelId" such as typesafe/jev-latest. Models and logins are pi's: ~/.pi/agent/auth.json, and ~/.pi/agent/models.json for OpenAI-compatible and local endpoints. Changes take effect within a few seconds. If it has an error, the error goes into bot.json.error and the old definition stays in use.
54
+ - persona.md: your personality and how you talk. It is read before each request, so changes take effect at once.
55
+ - responsibilities.md: what you are responsible for. The judge uses it to decide whether an event that does not mention you is about you. When your responsibilities change, update it.
56
+ - notes.md: your notes. After you turn the page, you find what you need again from them and the message log.
57
+ - workspace/: your working directory.
58
+ - Channel types: slack, terminal (the person who set you up, in their terminal), test. How to connect a new chat app yourself is in ${facts.docs}/channels/; put its tokens in ${facts.secretsDir}, readable only by this user.
59
+ - Other bots are in ${facts.botsDir}, one subfolder per bot. You can change their definitions. A new folder with a bot.json is a new bot.`;
60
+ }
61
+ export function memorySection(facts) {
62
+ return `# Context and turning the page
63
+ - You have one long-lived conversation. Events from all channels go into it.
64
+ - Each wake tells you how many tokens the context uses, how large the window is, and at what point pi compacts it automatically. You can also check at any time with pots context.
65
+ - Automatic compaction turns the old conversation into a summary written by pi, and details are lost. You decide when to turn the page. To turn the page: first write what you will need into ${facts.paths.notes}, then run pots turn-page --note "<a message to yourself in the new context>". The first message of the new context is that message and the full notes. After you turn the page you cannot see the old conversation; the message log stays.
66
+ - Turning the page takes effect when the current round of tool calls ends, and that round ends with it.
67
+
68
+ # Timed wakes
69
+ - Use pots wake to set timed wakes. You can have several at once, and you choose the times: look in now and then at what people are talking about, or do something you promised when its time comes.
70
+ - When you have no timed wake, a fallback check-in comes every ${facts.fallbackWakeMinutes} minutes.`;
71
+ }
72
+ /** "2026-10-27 17:04:07 Tuesday (GMT+11)", in the machine's time zone. */
73
+ export function formatTime(ms) {
74
+ const parts = Object.fromEntries(new Intl.DateTimeFormat("en-US", {
75
+ year: "numeric",
76
+ month: "2-digit",
77
+ day: "2-digit",
78
+ hour: "2-digit",
79
+ minute: "2-digit",
80
+ second: "2-digit",
81
+ weekday: "long",
82
+ hourCycle: "h23",
83
+ timeZoneName: "short",
84
+ })
85
+ .formatToParts(new Date(ms))
86
+ .map((part) => [part.type, part.value]));
87
+ return `${parts.year}-${parts.month}-${parts.day} ${parts.hour}:${parts.minute}:${parts.second} ${parts.weekday} (${parts.timeZoneName})`;
88
+ }
89
+ export function renderContext(status) {
90
+ const k = (tokens) => `${Math.round(tokens / 1000)}k`;
91
+ return `Context: about ${k(status.used)} tokens used, window ${k(status.window)}; pi compacts automatically at about ${k(status.compactAt)}.`;
92
+ }
93
+ const KINDS = {
94
+ message: "message",
95
+ edit: "edit",
96
+ delete: "delete",
97
+ reaction_added: "reaction added",
98
+ reaction_removed: "reaction removed",
99
+ join: "joined",
100
+ leave: "left",
101
+ update: "message changed (not the text)",
102
+ };
103
+ const PLACE_KINDS = { channel: "channel", dm: "DM", group: "group chat" };
104
+ function renderEvent(event) {
105
+ const parts = [`${formatTime(event.at)} ${KINDS[event.kind] ?? event.kind}`];
106
+ if (event.person)
107
+ parts.push(`${event.person.name ?? "?"} (${event.person.address})`);
108
+ if (event.message)
109
+ parts.push(`message ${event.message}`);
110
+ if (event.thread && event.thread !== event.message)
111
+ parts.push(`thread ${event.thread}`);
112
+ if (event.mentionsMe)
113
+ parts.push("mentions you");
114
+ return `- ${parts.join(", ")}`;
115
+ }
116
+ export function renderPlaceWake(wake, status) {
117
+ let why;
118
+ switch (wake.reason) {
119
+ case "mention":
120
+ why = "someone mentioned you";
121
+ break;
122
+ case "dm":
123
+ why = "DM";
124
+ break;
125
+ case "steer":
126
+ why = "new events in the place you are working on";
127
+ break;
128
+ case "relevant":
129
+ why =
130
+ wake.judged && "error" in wake.judged
131
+ ? `no mention. The judge could not decide this time (${wake.judged.error}), so it comes to you`
132
+ : `no mention. The judge found that it is about what you are responsible for and you need to respond (related ${wake.judged?.related.toFixed(2)}, respond ${wake.judged?.respond.toFixed(2)})`;
133
+ break;
134
+ case "heard":
135
+ why = "no mention. You have no judge set, so every message comes to you";
136
+ break;
137
+ }
138
+ const place = wake.place;
139
+ const lines = [
140
+ `${wake.reason === "steer" ? "[new events]" : "[wake]"} ${why}`,
141
+ `Now: ${formatTime(Date.now())}`,
142
+ `Place: ${place.name ?? "?"} (${place.address}, ${PLACE_KINDS[place.kind]})`,
143
+ `New events (${wake.events.length}):`,
144
+ ...wake.events.map(renderEvent),
145
+ renderContext(status),
146
+ ];
147
+ return lines.join("\n");
148
+ }
149
+ export function renderTimerWake(timer, status, fallbackMinutes) {
150
+ const why = timer.set_by === "fallback"
151
+ ? `fallback check-in: you have no timed wake, so one comes every ${fallbackMinutes} minutes`
152
+ : `timed wake (you set it at ${formatTime(timer.created_at)})`;
153
+ const lines = [`[wake] ${why}`, `Now: ${formatTime(Date.now())}`, `Due: ${formatTime(timer.due_at)}`];
154
+ if (timer.note)
155
+ lines.push(`Note: ${timer.note}`);
156
+ lines.push(renderContext(status));
157
+ return lines.join("\n");
158
+ }
159
+ export function renderHandoff(note, notes, notesPath) {
160
+ return `[turned the page] A new context starts here. You ended the previous context yourself.
161
+ Now: ${formatTime(Date.now())}
162
+
163
+ ## What you wrote to yourself when you turned the page
164
+ ${note.trim() || "(empty)"}
165
+
166
+ ## Full notes (${notesPath})
167
+ ${notes.trim() || "(the notes are empty)"}`;
168
+ }
169
+ //# sourceMappingURL=prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/bot/prompt.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAwB/C,MAAM,UAAU,eAAe,CAAC,KAAkB,EAAE,OAAe;IACjE,OAAO,0BAA0B,KAAK,CAAC,IAAI,QAAQ,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAkB;IAC5C,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAA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,EAAE,EAAE,QAAQ,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,QAAQ,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACtG,IAAI,KAAK,CAAC,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IAClD,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,KAAa,EAAE,SAAiB;IAC1E,OAAO;OACF,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;;;EAG3B,IAAI,CAAC,IAAI,EAAE,IAAI,SAAS;;iBAET,SAAS;EACxB,KAAK,CAAC,IAAI,EAAE,IAAI,uBAAuB,EAAE,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=timers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timers.js","sourceRoot":"","sources":["../../src/bot/timers.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
2
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
3
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
4
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
5
+ });
6
+ }
7
+ return path;
8
+ };
9
+ /** ".ts" when running from source, ".js" when running the built package. */
10
+ const extension = import.meta.url.slice(import.meta.url.lastIndexOf("."));
11
+ /**
12
+ * Make the adapter for one channel entry of a bot. The type names a folder next to this file: "slack" loads
13
+ * ./slack/index.ts. Adding a channel type is adding a folder; nothing else changes.
14
+ */
15
+ export async function loadChannel(config, env) {
16
+ if (!/^[a-z0-9-]+$/.test(config.type))
17
+ throw new Error(`bad channel type ${JSON.stringify(config.type)}`);
18
+ const module = (await import(__rewriteRelativeImportExtension(new URL(`./${config.type}/index${extension}`, import.meta.url).href)));
19
+ return module.createChannel(config, env);
20
+ }
21
+ //# sourceMappingURL=load.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load.js","sourceRoot":"","sources":["../../src/channels/load.ts"],"names":[],"mappings":";;;;;;;;AAEA,4EAA4E;AAC5E,MAAM,SAAS,GAAG,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1E;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,MAAqB,EAAE,GAAe;IACtE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1G,MAAM,MAAM,GAAG,CAAC,MAAM,MAAM,kCAAC,IAAI,GAAG,CAAC,KAAK,MAAM,CAAC,IAAI,SAAS,SAAS,EAAE,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAC,CAAkB,CAAC;IACpH,OAAO,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAC3C,CAAC"}