@geminixiang/mikan 1.0.0-beta.57 → 1.0.0-beta.59
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.
- package/CHANGELOG.md +24 -0
- package/README.md +2 -1
- package/dist/adapters/commands/admin.d.ts.map +1 -1
- package/dist/adapters/commands/admin.js +7 -1
- package/dist/adapters/commands/admin.js.map +1 -1
- package/dist/adapters/commands/auto-reply.d.ts +5 -0
- package/dist/adapters/commands/auto-reply.d.ts.map +1 -0
- package/dist/adapters/commands/auto-reply.js +38 -0
- package/dist/adapters/commands/auto-reply.js.map +1 -0
- package/dist/adapters/commands/manifest.d.ts.map +1 -1
- package/dist/adapters/commands/manifest.js +15 -0
- package/dist/adapters/commands/manifest.js.map +1 -1
- package/dist/adapters/commands/registry.d.ts.map +1 -1
- package/dist/adapters/commands/registry.js +2 -0
- package/dist/adapters/commands/registry.js.map +1 -1
- package/dist/adapters/progressive-renderer.d.ts.map +1 -1
- package/dist/adapters/progressive-renderer.js +8 -2
- package/dist/adapters/progressive-renderer.js.map +1 -1
- package/dist/adapters/slack/bot.d.ts.map +1 -1
- package/dist/adapters/slack/bot.js +8 -8
- package/dist/adapters/slack/bot.js.map +1 -1
- package/dist/adapters/slack/response-lifecycle.d.ts.map +1 -1
- package/dist/adapters/slack/response-lifecycle.js +4 -1
- package/dist/adapters/slack/response-lifecycle.js.map +1 -1
- package/dist/adapters/web/admin/portal.js +155 -85
- package/dist/adapters/web/admin/portal.js.map +1 -1
- package/dist/cli/arg-grammar.d.ts +7 -45
- package/dist/cli/arg-grammar.d.ts.map +1 -1
- package/dist/cli/arg-grammar.js +38 -80
- package/dist/cli/arg-grammar.js.map +1 -1
- package/dist/cli/boot.d.ts.map +1 -1
- package/dist/cli/boot.js +34 -47
- package/dist/cli/boot.js.map +1 -1
- package/dist/cli/office.d.ts.map +1 -1
- package/dist/cli/office.js +30 -21
- package/dist/cli/office.js.map +1 -1
- package/dist/cli/onboard.d.ts.map +1 -1
- package/dist/cli/onboard.js +35 -51
- package/dist/cli/onboard.js.map +1 -1
- package/dist/cli/sessions.d.ts.map +1 -1
- package/dist/cli/sessions.js +24 -16
- package/dist/cli/sessions.js.map +1 -1
- package/dist/cli/types.d.ts +2 -0
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/cli/types.js.map +1 -1
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +20 -1
- package/dist/config.js.map +1 -1
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,30 @@ any release.
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [1.0.0-beta.59]
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- Keep Slack's working indicator in its own paragraph so progressive heading and table updates can replace existing rich-text messages without `block_mismatch`.
|
|
17
|
+
- Pace failed progressive redraws as well as successful ones, retaining accumulated text for recovery instead of retrying on every delta.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Use Commander for CLI option parsing, subcommand validation, and generated help.
|
|
22
|
+
- Guide interactive onboarding with arrow-key selections, masked credentials, and a final confirmation before saving. Cancel without writing settings.
|
|
23
|
+
- Refuse custom-provider onboarding when models.json already exists, without printing credentials or writing partial settings.
|
|
24
|
+
|
|
25
|
+
## [1.0.0-beta.58]
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
|
|
29
|
+
- Restore Slack `/pi-auto-reply on|off` with the original per-conversation marker files, without judge models or rules.
|
|
30
|
+
- Expose the admin portal command on Discord and Telegram.
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
|
|
34
|
+
- Collapse conversation sections in the Admin portal, load their data only when opened, remember their open state, and open Vault and Session View links in new tabs.
|
|
35
|
+
|
|
12
36
|
## [1.0.0-beta.57]
|
|
13
37
|
|
|
14
38
|
### Changed
|
package/README.md
CHANGED
|
@@ -140,6 +140,7 @@ For routing, mounts, vault behavior, managed container details, and Cloudflare n
|
|
|
140
140
|
| `/new` / `/pi-new` | Reset the current session |
|
|
141
141
|
| `/model` / `/pi-model provider/model[:thinking]` | Switch the LLM for the current conversation |
|
|
142
142
|
| `/sandbox` / `/pi-sandbox [boost\|door …]` | Show sandbox status, boost limits, or set the office door policy |
|
|
143
|
+
| `/pi-auto-reply <on\|off>` | Toggle mention-free replies for the current Slack channel |
|
|
143
144
|
| `/admin` / `/pi-admin` | Open the admin portal |
|
|
144
145
|
| `stop` / `/stop` | Stop the current run (works on every platform) |
|
|
145
146
|
|
|
@@ -224,4 +225,4 @@ PRs welcome — see [CONTRIBUTING.md](CONTRIBUTING.md) for dev setup, commit sty
|
|
|
224
225
|
|
|
225
226
|
MIT — see [LICENSE](LICENSE).
|
|
226
227
|
|
|
227
|
-
|
|
228
|
+
Slack auto-reply uses the conversation's `auto-reply` / `auto-reply.disabled` marker files. File contents are ignored: only the on/off marker name matters; rules and `llm.autoReply` judge-model settings remain retired.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../../src/adapters/commands/admin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAKjE,qBAAa,mBAAoB,YAAW,cAAc;IAClD,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../../../src/adapters/commands/admin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAKjE,qBAAa,mBAAoB,YAAW,cAAc;IAClD,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CA8BzD;CACF"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { slashForms, matchCommand } from "./manifest.js";
|
|
2
|
-
import { portalNotConfiguredLines, replySummaryPrivately } from "./utils.js";
|
|
2
|
+
import { portalNotConfiguredLines, replySummary, replySummaryPrivately } from "./utils.js";
|
|
3
3
|
const ADMIN_COMMANDS = slashForms("admin");
|
|
4
4
|
export class AdminCommandHandler {
|
|
5
5
|
async tryHandle(context) {
|
|
6
6
|
if (!matchCommand(context.commandText, ADMIN_COMMANDS, { stripMention: true }))
|
|
7
7
|
return false;
|
|
8
|
+
if (!context.privateConversation && !context.bot.postPrivate) {
|
|
9
|
+
await replySummary(context, "Admin", [
|
|
10
|
+
"For privacy, open a direct conversation with mikan and run `/admin` there.",
|
|
11
|
+
]);
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
8
14
|
if (!context.services.portalBaseUrl) {
|
|
9
15
|
await replySummaryPrivately(context, "Admin", portalNotConfiguredLines("Admin portal"));
|
|
10
16
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../../src/adapters/commands/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"admin.js","sourceRoot":"","sources":["../../../src/adapters/commands/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE3F,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;AAE3C,MAAM,OAAO,mBAAmB;IAC9B,KAAK,CAAC,SAAS,CAAC,OAAuB;QACrC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,WAAW,EAAE,cAAc,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,CAA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chCommand } from \"./manifest.js\";\nimport type { CommandContext, CommandHandler } from \"./types.js\";\nimport { portalNotConfiguredLines, replySummary, replySummaryPrivately } from \"./utils.js\";\n\nconst ADMIN_COMMANDS = slashForms(\"admin\");\n\nexport class AdminCommandHandler implements CommandHandler {\n async tryHandle(context: CommandContext): Promise<boolean> {\n if (!matchCommand(context.commandText, ADMIN_COMMANDS, { stripMention: true })) return false;\n\n if (!context.privateConversation && !context.bot.postPrivate) {\n await replySummary(context, \"Admin\", [\n \"For privacy, open a direct conversation with mikan and run `/admin` there.\",\n ]);\n return true;\n }\n\n if (!context.services.portalBaseUrl) {\n await replySummaryPrivately(context, \"Admin\", portalNotConfiguredLines(\"Admin portal\"));\n return true;\n }\n\n const platformUser = context.bot\n .getMessagingInfo()\n .users.find((user) => user.id === context.platformUserId);\n const platformUserName = platformUser?.userName || platformUser?.displayName;\n\n const token = context.services.adminTokenStore.create({\n platform: context.platform,\n platformUserId: context.platformUserId,\n conversationId: context.conversationId,\n ...(platformUserName ? { platformUserName } : {}),\n });\n\n const url = `${context.services.portalBaseUrl}/admin?token=${token.token}`;\n await replySummaryPrivately(context, \"Admin\", [url, \"Expires: 30 minutes\"]);\n return true;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-reply.d.ts","sourceRoot":"","sources":["../../../src/adapters/commands/auto-reply.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAKjE,qBAAa,uBAAwB,YAAW,cAAc;IACtD,SAAS,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,CAiCzD;CACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { setSlackConversationAutoReply, slackConversationAutoReplyEnabled } from "../../config.js";
|
|
2
|
+
import { slashForms, matchCommand } from "./manifest.js";
|
|
3
|
+
import { replySummary } from "./utils.js";
|
|
4
|
+
const AUTO_REPLY_COMMANDS = slashForms("autoreply");
|
|
5
|
+
export class AutoReplyCommandHandler {
|
|
6
|
+
async tryHandle(context) {
|
|
7
|
+
const matched = matchCommand(context.commandText, AUTO_REPLY_COMMANDS);
|
|
8
|
+
if (!matched)
|
|
9
|
+
return false;
|
|
10
|
+
if (context.platform !== "slack") {
|
|
11
|
+
await replySummary(context, "Auto-reply", [
|
|
12
|
+
"Auto-reply is currently available on Slack only.",
|
|
13
|
+
]);
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
if (context.privateConversation) {
|
|
17
|
+
await replySummary(context, "Auto-reply", [
|
|
18
|
+
"Auto-reply only applies to shared channels. Direct messages already reply automatically.",
|
|
19
|
+
]);
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
const value = matched.args[0]?.toLowerCase();
|
|
23
|
+
if ((value !== "on" && value !== "off") || matched.args.length !== 1) {
|
|
24
|
+
await replySummary(context, "Auto-reply", ["Usage: `/pi-auto-reply <on|off>`"]);
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
const office = context.services.workspace.office(context.address);
|
|
28
|
+
setSlackConversationAutoReply(office, value === "on");
|
|
29
|
+
const enabled = slackConversationAutoReplyEnabled(office);
|
|
30
|
+
await replySummary(context, "Auto-reply", [
|
|
31
|
+
enabled
|
|
32
|
+
? "Enabled. New messages in this channel will trigger mikan without a mention."
|
|
33
|
+
: "Disabled. New messages in this channel must address mikan explicitly.",
|
|
34
|
+
]);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=auto-reply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-reply.js","sourceRoot":"","sources":["../../../src/adapters/commands/auto-reply.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AACnG,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eA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,EAAE;YACxC,OAAO;gBACL,CAAC,CAAC,6EAA6E;gBAC/E,CAAC,CAAC,uEAAuE;SAC5E,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import { setSlackConversationAutoReply, slackConversationAutoReplyEnabled } from \"../../config.js\";\nimport { slashForms, matchCommand } from \"./manifest.js\";\nimport type { CommandContext, CommandHandler } from \"./types.js\";\nimport { replySummary } from \"./utils.js\";\n\nconst AUTO_REPLY_COMMANDS = slashForms(\"autoreply\");\n\nexport class AutoReplyCommandHandler implements CommandHandler {\n async tryHandle(context: CommandContext): Promise<boolean> {\n const matched = matchCommand(context.commandText, AUTO_REPLY_COMMANDS);\n if (!matched) return false;\n\n if (context.platform !== \"slack\") {\n await replySummary(context, \"Auto-reply\", [\n \"Auto-reply is currently available on Slack only.\",\n ]);\n return true;\n }\n\n if (context.privateConversation) {\n await replySummary(context, \"Auto-reply\", [\n \"Auto-reply only applies to shared channels. Direct messages already reply automatically.\",\n ]);\n return true;\n }\n\n const value = matched.args[0]?.toLowerCase();\n if ((value !== \"on\" && value !== \"off\") || matched.args.length !== 1) {\n await replySummary(context, \"Auto-reply\", [\"Usage: `/pi-auto-reply <on|off>`\"]);\n return true;\n }\n\n const office = context.services.workspace.office(context.address);\n setSlackConversationAutoReply(office, value === \"on\");\n const enabled = slackConversationAutoReplyEnabled(office);\n await replySummary(context, \"Auto-reply\", [\n enabled\n ? \"Enabled. New messages in this channel will trigger mikan without a mention.\"\n : \"Disabled. New messages in this channel must address mikan explicitly.\",\n ]);\n return true;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/adapters/commands/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,YAAY,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAExE,sDAAsD;AACtD,eAAO,MAAM,gBAAgB,EAAE,SAAS,oBAAoB,
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../src/adapters/commands/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,YAAY,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAExE,sDAAsD;AACtD,eAAO,MAAM,gBAAgB,EAAE,SAAS,oBAAoB,EAwF3D,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,oBAAoB,CAIvE;AAED,4FAA4F;AAC5F,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAM1D;AAED,0FAA0F;AAC1F,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAG5D;AAED,iFAAiF;AACjF,wBAAgB,mBAAmB,IAAI;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,EAAE,CAKhF;AAED,wBAAgB,YAAY,CAAC,OAAO,SAAS,MAAM,EACjD,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,OAAO,EAAE,EAC3B,OAAO,CAAC,EAAE;IAAE,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,GACnC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,IAAI,CAQ7C;AAkBD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEnD"}
|
|
@@ -65,6 +65,18 @@ export const COMMAND_MANIFEST = [
|
|
|
65
65
|
telegramMenu: { description: "Show or boost sandbox limits" },
|
|
66
66
|
telegramCommand: true,
|
|
67
67
|
},
|
|
68
|
+
{
|
|
69
|
+
name: "autoreply",
|
|
70
|
+
aliases: ["auto-reply"],
|
|
71
|
+
description: "Enable or disable replies without mentions",
|
|
72
|
+
arg: {
|
|
73
|
+
name: "state",
|
|
74
|
+
description: "on or off",
|
|
75
|
+
required: true,
|
|
76
|
+
},
|
|
77
|
+
slackCommand: "/pi-auto-reply",
|
|
78
|
+
slackRoute: { includeText: true },
|
|
79
|
+
},
|
|
68
80
|
{
|
|
69
81
|
name: "stop",
|
|
70
82
|
description: "Stop the current conversation",
|
|
@@ -86,6 +98,9 @@ export const COMMAND_MANIFEST = [
|
|
|
86
98
|
description: "Open the admin portal",
|
|
87
99
|
slackCommand: "/pi-admin",
|
|
88
100
|
slackRoute: { thread: true },
|
|
101
|
+
discord: true,
|
|
102
|
+
telegramMenu: {},
|
|
103
|
+
telegramCommand: true,
|
|
89
104
|
},
|
|
90
105
|
];
|
|
91
106
|
export function commandManifestEntry(name) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../../src/adapters/commands/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,sDAAsD;AACtD,MAAM,CAAC,MAAM,gBAAgB,GAAoC;IAC/D;QACE,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,yCAAyC;QACtD,YAAY,EAAE,WAAW;QACzB,UAAU,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE;QACvD,OAAO,EAAE,IAAI;QACb,YAAY,EAAE,EAAE;KACjB;IACD;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,4CAA4C;QACzD,IAAI,EAAE,IAAI;QACV,YAAY,EAAE,aAAa;QAC3B,UAAU,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;QAC5B,OAAO,EAAE,IAAI;QACb,YAAY,EAAE,EAAE;KACjB;IACD;QACE,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,sCAAsC;QACnD,GA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AAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACxD,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACxB,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAErC,MAAM,KAAK,GAAG,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1E,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,EAAa,CAAC;IAC/C,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/E,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;AAEpG,MAAM,oBAAoB,GAAG,IAAI,MAAM,CACrC,qBAAqB,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,sBAAsB,EAClE,GAAG,CACJ,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AAChD,CAAC","sourcesContent":["/**\n * Platform-agnostic command manifest — the single inventory that platform\n * adapters derive their native slash-command registration and routing from,\n * and that `isCommandText` and the handler grammars mirror.\n *\n * Adding a command means adding a manifest entry plus a handler in this\n * directory; adapters pick up registration and routing from the entry instead\n * of hand-restating the inventory (where a missed spot used to mean a silent\n * no-response).\n *\n * Per CONTEXT.md, slash commands are a minimal chat control surface: detailed\n * or infrequent settings belong in Admin, and bare commands are limited to\n * `session`. `stop` is listed for platform registration/UI only — it is a\n * magic word owned by conversation intake, not a command handler.\n */\n\nimport type { CommandManifestEntry } from \"./types.js\";\n\nexport type { CommandManifestEntry, SlackSlashRoute } from \"./types.js\";\n\n/** Entry order is the Telegram command-menu order. */\nexport const COMMAND_MANIFEST: readonly CommandManifestEntry[] = [\n {\n name: \"login\",\n description: \"Store credentials in your private vault\",\n slackCommand: \"/pi-login\",\n slackRoute: { includeText: true, privateCommand: true },\n discord: true,\n telegramMenu: {},\n },\n {\n name: \"session\",\n description: \"Open the current session in the web viewer\",\n bare: true,\n slackCommand: \"/pi-session\",\n slackRoute: { thread: true },\n discord: true,\n telegramMenu: {},\n },\n {\n name: \"model\",\n description: \"Switch this conversation's LLM model\",\n arg: {\n name: \"model\",\n description: \"provider/model[:thinking], e.g. anthropic/claude-sonnet-4-6:off\",\n required: false,\n },\n slackCommand: \"/pi-model\",\n slackRoute: { includeText: true },\n discord: true,\n telegramMenu: {},\n },\n {\n name: \"sandbox\",\n description: \"Show sandbox status or boost limits\",\n arg: {\n name: \"action\",\n // Discord caps option descriptions at 100 characters (registration\n // fails otherwise); commands.test.ts enforces the budget.\n // The `door` action still works but is deliberately undocumented: the\n // workspace posture follows the platform's own channel visibility\n // automatically, and overriding it is an admin escape hatch, not a\n // user-facing feature.\n description: \"'boost' temporarily applies the configured boost limits\",\n required: false,\n },\n slackCommand: \"/pi-sandbox\",\n slackRoute: { includeText: true },\n discord: true,\n telegramMenu: { description: \"Show or boost sandbox limits\" },\n telegramCommand: true,\n },\n {\n name: \"stop\",\n description: \"Stop the current conversation\",\n magicWord: true,\n discord: true,\n telegramMenu: { description: \"Stop ongoing conversation\" },\n },\n {\n name: \"new\",\n description: \"Reset conversation history and start fresh\",\n slackCommand: \"/pi-new\",\n slackRoute: {},\n discord: true,\n telegramMenu: {},\n telegramCommand: true,\n },\n {\n name: \"admin\",\n description: \"Open the admin portal\",\n slackCommand: \"/pi-admin\",\n slackRoute: { thread: true },\n },\n];\n\nexport function commandManifestEntry(name: string): CommandManifestEntry {\n const entry = COMMAND_MANIFEST.find((candidate) => candidate.name === name);\n if (!entry) throw new Error(`Unknown command in manifest: ${name}`);\n return entry;\n}\n\n/** Slash spellings of a command: `/<name>` and `/pi-<name>` for the name and each alias. */\nexport function slashForms(name: string): readonly string[] {\n const entry = commandManifestEntry(name);\n return [entry.name, ...(entry.aliases ?? [])].flatMap((spelling) => [\n `/${spelling}`,\n `/pi-${spelling}`,\n ]);\n}\n\n/** Every accepted spelling: the bare name (when the command is bare) plus slash forms. */\nexport function commandForms(name: string): readonly string[] {\n const entry = commandManifestEntry(name);\n return [...(entry.bare ? [entry.name] : []), ...slashForms(name)];\n}\n\n/** Telegram `setMyCommands` payload (menu registration; routing is separate). */\nexport function telegramCommandMenu(): { command: string; description: string }[] {\n return COMMAND_MANIFEST.filter((entry) => entry.telegramMenu).map((entry) => ({\n command: entry.name,\n description: entry.telegramMenu?.description ?? entry.description,\n }));\n}\n\nexport function matchCommand<Command extends string>(\n text: string,\n aliases: readonly Command[],\n options?: { stripMention?: boolean },\n): { command: Command; args: string[] } | null {\n const tokens = text.trim().split(/\\s+/).filter(Boolean);\n const first = tokens[0];\n if (first === undefined) return null;\n\n const token = options?.stripMention ? first.replace(/@\\w+$/i, \"\") : first;\n const command = token.toLowerCase() as Command;\n return aliases.includes(command) ? { command, args: tokens.slice(1) } : null;\n}\n\n/**\n * Chat-command text recognition, derived from the command manifest so the\n * inventory has a single source of truth. Session resume uses it to keep\n * command messages out of replayed history.\n *\n * The `pi-[\\w-]+` alternative is a catch-all for platform-prefixed command\n * names (including ones a platform registers but this build no longer\n * handles), independent of the manifest.\n */\nconst COMMAND_NAMES = COMMAND_MANIFEST.flatMap((entry) => [entry.name].concat(entry.aliases ?? []));\n\nconst COMMAND_TEXT_PATTERN = new RegExp(\n `^\\\\/(?:pi-[\\\\w-]+|${COMMAND_NAMES.join(\"|\")})(?:@\\\\w+)?(?:\\\\s|$)`,\n \"i\",\n);\n\nexport function isCommandText(text: string): boolean {\n return COMMAND_TEXT_PATTERN.test(text.trim());\n}\n"]}
|
|
1
|
+
{"version":3,"file":"manifest.js","sourceRoot":"","sources":["../../../src/adapters/commands/manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,sDAAsD;AACtD,MAAM,CAAC,MAAM,gBAAgB,GAAoC;IAC/D;QACE,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,yCAAyC;QACtD,YAAY,EAAE,WAAW;QACzB,UAAU,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE;QACvD,OAAO,EAAE,IAAI;QACb,YAAY,EAAE,EAAE;KACjB;IACD;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,4CAA4C;QACzD,IAAI,EAAE,IAAI;QACV,YAAY,EAAE,aAAa;QAC3B,UAAU,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;QAC5B,OAAO,EAAE,IAAI;QACb,YAAY,EAAE,EAAE;KACjB;IACD;QACE,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,sCAAsC;QACnD,GAAG,EAAE;YACH,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,iEAAiE;YAC9E,QAAQ,EAAE,KAAK;SAChB;QACD,YAAY,EAAE,WAAW;QACzB,UAAU,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;QACjC,OAAO,EAAE,IAAI;QACb,YAAY,EAAE,EAAE;KACjB;IACD;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,qCAAqC;QAClD,GAAG,EAAE;YACH,IAAI,EAAE,QAAQ;YACd,mEAAmE;YACnE,0DAA0D;YAC1D,sEAAsE;YACtE,kEAAkE;YAClE,mEAAmE;YACnE,uBAAuB;YACvB,WAAW,EAAE,yDAAyD;YACtE,QAAQ,EAAE,KAAK;SAChB;QACD,YAAY,EAAE,aAAa;QAC3B,UAAU,EAAE,EAAE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I,CAAC;IAErC,MAAM,KAAK,GAAG,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1E,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,EAAa,CAAC;IAC/C,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/E,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;AAEpG,MAAM,oBAAoB,GAAG,IAAI,MAAM,CACrC,qBAAqB,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,sBAAsB,EAClE,GAAG,CACJ,CAAC;AAEF,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AAChD,CAAC","sourcesContent":["/**\n * Platform-agnostic command manifest — the single inventory that platform\n * adapters derive their native slash-command registration and routing from,\n * and that `isCommandText` and the handler grammars mirror.\n *\n * Adding a command means adding a manifest entry plus a handler in this\n * directory; adapters pick up registration and routing from the entry instead\n * of hand-restating the inventory (where a missed spot used to mean a silent\n * no-response).\n *\n * Per CONTEXT.md, slash commands are a minimal chat control surface: detailed\n * or infrequent settings belong in Admin, and bare commands are limited to\n * `session`. `stop` is listed for platform registration/UI only — it is a\n * magic word owned by conversation intake, not a command handler.\n */\n\nimport type { CommandManifestEntry } from \"./types.js\";\n\nexport type { CommandManifestEntry, SlackSlashRoute } from \"./types.js\";\n\n/** Entry order is the Telegram command-menu order. */\nexport const COMMAND_MANIFEST: readonly CommandManifestEntry[] = [\n {\n name: \"login\",\n description: \"Store credentials in your private vault\",\n slackCommand: \"/pi-login\",\n slackRoute: { includeText: true, privateCommand: true },\n discord: true,\n telegramMenu: {},\n },\n {\n name: \"session\",\n description: \"Open the current session in the web viewer\",\n bare: true,\n slackCommand: \"/pi-session\",\n slackRoute: { thread: true },\n discord: true,\n telegramMenu: {},\n },\n {\n name: \"model\",\n description: \"Switch this conversation's LLM model\",\n arg: {\n name: \"model\",\n description: \"provider/model[:thinking], e.g. anthropic/claude-sonnet-4-6:off\",\n required: false,\n },\n slackCommand: \"/pi-model\",\n slackRoute: { includeText: true },\n discord: true,\n telegramMenu: {},\n },\n {\n name: \"sandbox\",\n description: \"Show sandbox status or boost limits\",\n arg: {\n name: \"action\",\n // Discord caps option descriptions at 100 characters (registration\n // fails otherwise); commands.test.ts enforces the budget.\n // The `door` action still works but is deliberately undocumented: the\n // workspace posture follows the platform's own channel visibility\n // automatically, and overriding it is an admin escape hatch, not a\n // user-facing feature.\n description: \"'boost' temporarily applies the configured boost limits\",\n required: false,\n },\n slackCommand: \"/pi-sandbox\",\n slackRoute: { includeText: true },\n discord: true,\n telegramMenu: { description: \"Show or boost sandbox limits\" },\n telegramCommand: true,\n },\n {\n name: \"autoreply\",\n aliases: [\"auto-reply\"],\n description: \"Enable or disable replies without mentions\",\n arg: {\n name: \"state\",\n description: \"on or off\",\n required: true,\n },\n slackCommand: \"/pi-auto-reply\",\n slackRoute: { includeText: true },\n },\n {\n name: \"stop\",\n description: \"Stop the current conversation\",\n magicWord: true,\n discord: true,\n telegramMenu: { description: \"Stop ongoing conversation\" },\n },\n {\n name: \"new\",\n description: \"Reset conversation history and start fresh\",\n slackCommand: \"/pi-new\",\n slackRoute: {},\n discord: true,\n telegramMenu: {},\n telegramCommand: true,\n },\n {\n name: \"admin\",\n description: \"Open the admin portal\",\n slackCommand: \"/pi-admin\",\n slackRoute: { thread: true },\n discord: true,\n telegramMenu: {},\n telegramCommand: true,\n },\n];\n\nexport function commandManifestEntry(name: string): CommandManifestEntry {\n const entry = COMMAND_MANIFEST.find((candidate) => candidate.name === name);\n if (!entry) throw new Error(`Unknown command in manifest: ${name}`);\n return entry;\n}\n\n/** Slash spellings of a command: `/<name>` and `/pi-<name>` for the name and each alias. */\nexport function slashForms(name: string): readonly string[] {\n const entry = commandManifestEntry(name);\n return [entry.name, ...(entry.aliases ?? [])].flatMap((spelling) => [\n `/${spelling}`,\n `/pi-${spelling}`,\n ]);\n}\n\n/** Every accepted spelling: the bare name (when the command is bare) plus slash forms. */\nexport function commandForms(name: string): readonly string[] {\n const entry = commandManifestEntry(name);\n return [...(entry.bare ? [entry.name] : []), ...slashForms(name)];\n}\n\n/** Telegram `setMyCommands` payload (menu registration; routing is separate). */\nexport function telegramCommandMenu(): { command: string; description: string }[] {\n return COMMAND_MANIFEST.filter((entry) => entry.telegramMenu).map((entry) => ({\n command: entry.name,\n description: entry.telegramMenu?.description ?? entry.description,\n }));\n}\n\nexport function matchCommand<Command extends string>(\n text: string,\n aliases: readonly Command[],\n options?: { stripMention?: boolean },\n): { command: Command; args: string[] } | null {\n const tokens = text.trim().split(/\\s+/).filter(Boolean);\n const first = tokens[0];\n if (first === undefined) return null;\n\n const token = options?.stripMention ? first.replace(/@\\w+$/i, \"\") : first;\n const command = token.toLowerCase() as Command;\n return aliases.includes(command) ? { command, args: tokens.slice(1) } : null;\n}\n\n/**\n * Chat-command text recognition, derived from the command manifest so the\n * inventory has a single source of truth. Session resume uses it to keep\n * command messages out of replayed history.\n *\n * The `pi-[\\w-]+` alternative is a catch-all for platform-prefixed command\n * names (including ones a platform registers but this build no longer\n * handles), independent of the manifest.\n */\nconst COMMAND_NAMES = COMMAND_MANIFEST.flatMap((entry) => [entry.name].concat(entry.aliases ?? []));\n\nconst COMMAND_TEXT_PATTERN = new RegExp(\n `^\\\\/(?:pi-[\\\\w-]+|${COMMAND_NAMES.join(\"|\")})(?:@\\\\w+)?(?:\\\\s|$)`,\n \"i\",\n);\n\nexport function isCommandText(text: string): boolean {\n return COMMAND_TEXT_PATTERN.test(text.trim());\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/adapters/commands/registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/adapters/commands/registry.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAmBhF,wBAAgB,sBAAsB,CACpC,aAAa,GAAE,aAAoC,GAClD,cAAc,EAAE,CAUlB;AAED,gFAAgF;AAChF,wBAAsB,eAAe,CACnC,QAAQ,EAAE,SAAS,cAAc,EAAE,EACnC,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,OAAO,CAAC,CAKlB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MikanModels } from "../../harness/index.js";
|
|
2
2
|
import { AdminCommandHandler } from "./admin.js";
|
|
3
|
+
import { AutoReplyCommandHandler } from "./auto-reply.js";
|
|
3
4
|
import { LoginCommandHandler } from "./login.js";
|
|
4
5
|
import { COMMAND_MANIFEST } from "./manifest.js";
|
|
5
6
|
import { ModelCommandHandler } from "./model.js";
|
|
@@ -15,6 +16,7 @@ import { SessionViewCommandHandler } from "./session-view.js";
|
|
|
15
16
|
*/
|
|
16
17
|
const HANDLER_FACTORIES = {
|
|
17
18
|
admin: () => new AdminCommandHandler(),
|
|
19
|
+
autoreply: () => new AutoReplyCommandHandler(),
|
|
18
20
|
login: () => new LoginCommandHandler(),
|
|
19
21
|
session: () => new SessionViewCommandHandler(),
|
|
20
22
|
model: (modelRegistry) => new ModelCommandHandler(modelRegistry),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/adapters/commands/regist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,CACxF,CAAC;QACJ,CAAC;QACD,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,gFAAgF;AAChF,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,QAAmC,EACnC,OAAuB;IAEvB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,MAAM,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC;YAAE,OAAO,IAAI,CAAC;IACpD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { MikanModels } from \"../../harness/index.js\";\nimport { AdminCommandHandler } from \"./admin.js\";\nimport { LoginCommandHandler } from \"./login.js\";\nimport { COMMAND_MANIFEST } from \"./manifest.js\";\nimport { ModelCommandHandler } from \"./model.js\";\nimport { NewCommandHandler } from \"./new.js\";\nimport { SandboxCommandHandler } from \"./sandbox.js\";\nimport { SessionViewCommandHandler } from \"./session-view.js\";\nimport type { CommandContext, CommandHandler, ModelRegistry } from \"./types.js\";\n\n/**\n * Handler factory per manifest command name. The manifest is the inventory\n * authority; this map only binds each entry to its implementation, and\n * `defaultCommandHandlers` verifies the binding is complete so a manifest\n * entry without a handler fails at construction instead of dispatching into\n * silence. Magic-word entries (routed by conversation intake) are exempt.\n */\nconst HANDLER_FACTORIES: Record<string, (modelRegistry: ModelRegistry) => CommandHandler> = {\n admin: () => new AdminCommandHandler(),\n login: () => new LoginCommandHandler(),\n session: () => new SessionViewCommandHandler(),\n model: (modelRegistry) => new ModelCommandHandler(modelRegistry),\n sandbox: () => new SandboxCommandHandler(),\n new: () => new NewCommandHandler(),\n};\n\nexport function defaultCommandHandlers(\n modelRegistry: ModelRegistry = MikanModels.create(),\n): CommandHandler[] {\n return COMMAND_MANIFEST.filter((entry) => !entry.magicWord).map((entry) => {\n const factory = HANDLER_FACTORIES[entry.name];\n if (!factory) {\n throw new Error(\n `Command manifest entry \"${entry.name}\" has no handler factory in commands/registry.ts`,\n );\n }\n return factory(modelRegistry);\n });\n}\n\n/** Run handlers in order, returning true as soon as one accepts the command. */\nexport async function dispatchCommand(\n handlers: readonly CommandHandler[],\n context: CommandContext,\n): Promise<boolean> {\n for (const handler of handlers) {\n if (await handler.tryHandle(context)) return true;\n }\n return false;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/adapters/commands/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAG9D;;;;;;GAMG;AACH,MAAM,iBAAiB,GAAqE;IAC1F,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,mBAAmB,EAAE;IACtC,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,uBAAuB,EAAE;IAC9C,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,mBAAmB,EAAE;IACtC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,yBAAyB,EAAE;IAC9C,KAAK,EAAE,CAAC,aAAa,EAAE,EAAE,CAAC,IAAI,mBAAmB,CAAC,aAAa,CAAC;IAChE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,qBAAqB,EAAE;IAC1C,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,iBAAiB,EAAE;CACnC,CAAC;AAEF,MAAM,UAAU,sBAAsB,CACpC,aAAa,GAAkB,WAAW,CAAC,MAAM,EAAE;IAEnD,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QACxE,MAAM,OAAO,GAAG,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CACb,2BAA2B,KAAK,CAAC,IAAI,kDAAkD,CACxF,CAAC;QACJ,CAAC;QACD,OAAO,OAAO,CAAC,aAAa,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,gFAAgF;AAChF,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,QAAmC,EACnC,OAAuB;IAEvB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,MAAM,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC;YAAE,OAAO,IAAI,CAAC;IACpD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { MikanModels } from \"../../harness/index.js\";\nimport { AdminCommandHandler } from \"./admin.js\";\nimport { AutoReplyCommandHandler } from \"./auto-reply.js\";\nimport { LoginCommandHandler } from \"./login.js\";\nimport { COMMAND_MANIFEST } from \"./manifest.js\";\nimport { ModelCommandHandler } from \"./model.js\";\nimport { NewCommandHandler } from \"./new.js\";\nimport { SandboxCommandHandler } from \"./sandbox.js\";\nimport { SessionViewCommandHandler } from \"./session-view.js\";\nimport type { CommandContext, CommandHandler, ModelRegistry } from \"./types.js\";\n\n/**\n * Handler factory per manifest command name. The manifest is the inventory\n * authority; this map only binds each entry to its implementation, and\n * `defaultCommandHandlers` verifies the binding is complete so a manifest\n * entry without a handler fails at construction instead of dispatching into\n * silence. Magic-word entries (routed by conversation intake) are exempt.\n */\nconst HANDLER_FACTORIES: Record<string, (modelRegistry: ModelRegistry) => CommandHandler> = {\n admin: () => new AdminCommandHandler(),\n autoreply: () => new AutoReplyCommandHandler(),\n login: () => new LoginCommandHandler(),\n session: () => new SessionViewCommandHandler(),\n model: (modelRegistry) => new ModelCommandHandler(modelRegistry),\n sandbox: () => new SandboxCommandHandler(),\n new: () => new NewCommandHandler(),\n};\n\nexport function defaultCommandHandlers(\n modelRegistry: ModelRegistry = MikanModels.create(),\n): CommandHandler[] {\n return COMMAND_MANIFEST.filter((entry) => !entry.magicWord).map((entry) => {\n const factory = HANDLER_FACTORIES[entry.name];\n if (!factory) {\n throw new Error(\n `Command manifest entry \"${entry.name}\" has no handler factory in commands/registry.ts`,\n );\n }\n return factory(modelRegistry);\n });\n}\n\n/** Run handlers in order, returning true as soon as one accepts the command. */\nexport async function dispatchCommand(\n handlers: readonly CommandHandler[],\n context: CommandContext,\n): Promise<boolean> {\n for (const handler of handlers) {\n if (await handler.tryHandle(context)) return true;\n }\n return false;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progressive-renderer.d.ts","sourceRoot":"","sources":["../../src/adapters/progressive-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EAEtB,MAAM,eAAe,CAAC;AAQvB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAE9D,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CASvE;
|
|
1
|
+
{"version":3,"file":"progressive-renderer.d.ts","sourceRoot":"","sources":["../../src/adapters/progressive-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EAEtB,MAAM,eAAe,CAAC;AAQvB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAE9D,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CASvE;AA0hBD,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,2BAA2B,GAAG;IAChF,SAAS,EAAE,qBAAqB,CAAC;CAClC,CAEA"}
|
|
@@ -264,8 +264,14 @@ class ProgressiveRenderer {
|
|
|
264
264
|
if (this.state.lastFlushAt === 0 ||
|
|
265
265
|
(elapsed >= this.flushIntervalMs && this.state.pendingChars > 0)) {
|
|
266
266
|
this.state.pendingChars = 0;
|
|
267
|
-
|
|
268
|
-
|
|
267
|
+
try {
|
|
268
|
+
this.state.source = await this.renderDelta(this.state.source);
|
|
269
|
+
}
|
|
270
|
+
finally {
|
|
271
|
+
// A rejected edit still spent an API call. Pace subsequent deltas
|
|
272
|
+
// from its completion too, retaining source for the next attempt.
|
|
273
|
+
this.state.lastFlushAt = this.now();
|
|
274
|
+
}
|
|
269
275
|
}
|
|
270
276
|
}, () => ({ textLength: delta.length, accumulatedLength: this.state.source.length }));
|
|
271
277
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progressive-renderer.js","sourceRoot":"","sources":["../../src/adapters/progressive-renderer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,+BAA+B,EAC/B,cAAc,EACd,SAAS,GAEV,MAAM,aAAa,CAAC;AAGrB,MAAM,UAAU,wBAAwB,CAAC,MAAsB;IAC7D,MAAM,aAAa,GAAG,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACvD,IAAI,IAAI,GAAG,KAAK,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC;IACzE,IAAI,MAAM,CAAC,KAAK;QAAE,IAAI,IAAI,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC;IAC9C,IAAI,IAAI,KA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AC,CAAC;QACrE,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAED,MAAM,UAAU,yBAAyB,CAAC,QAAqC;IAG7E,OAAO,EAAE,SAAS,EAAE,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC,SAAS,EAAE,CAAC;AACpE,CAAC","sourcesContent":["import type {\n ChatToolResult,\n ConversationResponder,\n SubagentProgressSnapshot,\n} from \"../adapter.js\";\nimport * as log from \"../log.js\";\nimport {\n createChatResponseErrorReporter,\n formatToolArgs,\n splitText,\n type ChatResponseErrorOperation,\n} from \"./shared.js\";\nimport type { ProgressiveRendererPlatform } from \"./types.js\";\n\nexport function formatMarkdownToolResult(result: ChatToolResult): string {\n const argsFormatted = formatToolArgs(result.args);\n const duration = (result.durationMs / 1000).toFixed(1);\n let text = `**${result.isError ? \"Error\" : \"Done\"} ${result.toolName}**`;\n if (result.label) text += `: ${result.label}`;\n text += ` (${duration}s)\\n`;\n if (argsFormatted) text += `\\`\\`\\`\\n${argsFormatted}\\n\\`\\`\\`\\n`;\n text += `**Result:**\\n\\`\\`\\`\\n${result.result}\\n\\`\\`\\``;\n return text;\n}\n\ninterface RendererState {\n responseId: string | null;\n source: string;\n working: boolean;\n streamActive: boolean;\n streamUnavailable: boolean;\n streamedSource: string;\n pendingChars: number;\n lastFlushAt: number;\n resetDelta: boolean;\n typingInterval: ReturnType<typeof setInterval> | null;\n typingFailureWarned: boolean;\n extraIds: Array<string | number>;\n /**\n * Messages holding the overflow of a response too long for one message,\n * in order. Reused across redraws — see `postSplit`.\n */\n continuationIds: Array<string | number>;\n}\n\n/**\n * Floor on how often a streaming response redraws.\n *\n * Every platform meters edits per channel — Slack's is the tightest at roughly\n * fifty a minute — and a redraw sends the whole message, so the cost is the\n * number of calls, not their size. One second keeps a long answer inside that\n * budget while still reading as live.\n *\n * This is a floor, not a target: the interval is measured from when the last\n * redraw *finished*, so a platform that slows down under load slows the redraw\n * rate with it instead of queueing work it cannot deliver.\n */\nconst DEFAULT_FLUSH_INTERVAL_MS = 1000;\n\nclass ProgressiveRenderer {\n readonly responder: ConversationResponder;\n private readonly state: RendererState;\n private readonly sanitize: (text: string) => string;\n private readonly reportResponseError;\n private readonly now = Date.now;\n private readonly flushIntervalMs: number;\n private queueTail = Promise.resolve();\n\n constructor(private readonly platform: ProgressiveRendererPlatform) {\n this.state = {\n responseId: platform.initialResponseId ?? null,\n source: \"\",\n working: true,\n streamActive: false,\n streamUnavailable: false,\n streamedSource: \"\",\n pendingChars: 0,\n lastFlushAt: 0,\n resetDelta: false,\n typingInterval: null,\n typingFailureWarned: false,\n extraIds: [],\n continuationIds: [],\n };\n this.sanitize = platform.sanitize ?? ((text: string) => text);\n this.reportResponseError = platform.responseErrorContext\n ? createChatResponseErrorReporter(() => platform.responseErrorContext!(this.state.responseId))\n : undefined;\n this.flushIntervalMs = platform.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS;\n this.responder = this.createResponder();\n }\n\n private createResponder(): ConversationResponder {\n return {\n respond: (text) => this.respond(text),\n appendResponseDelta:\n this.platform.supportsDeltas || this.platform.stream\n ? (delta) => this.appendDelta(delta)\n : undefined,\n finishResponse:\n this.platform.supportsDeltas || this.platform.stream\n ? (finalText) => this.finishResponse(finalText)\n : undefined,\n replaceResponse: (text, options) => this.replaceResponse(text, options),\n replaceSubagentProgress: this.platform.formatSubagentProgress\n ? (progress, finalText) => this.replaceSubagentProgress(progress, finalText)\n : undefined,\n respondDiagnostic: (text, options) => this.respondDiagnostic(text, options),\n respondToolResult: (result) => this.respondToolResult(result),\n setTyping: (isTyping) => this.setTyping(isTyping),\n setWorking: (working) => this.setWorking(working),\n uploadFile: (filePath, title) => this.uploadFile(filePath, title),\n ...(this.platform.react ? { react: this.platform.react } : {}),\n deleteResponse: () => this.deleteResponse(),\n };\n }\n\n private stopTyping(): void {\n if (this.state.typingInterval !== null) {\n clearInterval(this.state.typingInterval);\n this.state.typingInterval = null;\n }\n }\n\n private provisional(text: string, working: boolean): string {\n if (this.platform.formatProvisional) return this.platform.formatProvisional(text, working);\n return working && this.platform.workingIndicator ? text + this.platform.workingIndicator : text;\n }\n\n private split(text: string): string[] {\n return splitText(text, this.platform.maxLength, this.platform.formatContinuation);\n }\n\n private async postOrUpdate(text: string): Promise<void> {\n if (this.state.responseId !== null) {\n await this.platform.update(this.state.responseId, text);\n return;\n }\n if (this.platform.typing?.stopOnSend) this.stopTyping();\n this.state.responseId = await this.platform.post(text);\n }\n\n private async postSplit(text: string): Promise<void> {\n const [head = text, ...tail] = this.split(text);\n await this.postOrUpdate(head);\n for (const [index, part] of tail.entries()) {\n const existing = this.state.continuationIds[index];\n if (existing !== undefined) {\n await this.platform.update(String(existing), part);\n continue;\n }\n if (this.platform.typing?.stopOnSend) this.stopTyping();\n const id = await this.platform.postExtra(part, this.state.responseId);\n if (id !== undefined && id !== null) this.state.continuationIds[index] = id;\n }\n }\n\n private async postExtra(text: string): Promise<void> {\n if (this.platform.typing?.stopOnSend) this.stopTyping();\n await this.platform.postExtra(text, this.state.responseId);\n }\n\n private async stopNativeStream(): Promise<void> {\n if (!this.state.streamActive || this.state.responseId === null || !this.platform.stream) return;\n const streamId = this.state.responseId;\n this.state.streamActive = false;\n this.state.streamedSource = \"\";\n await this.platform.stream.stop(streamId);\n }\n\n private async abandonNativeStream(): Promise<void> {\n if (!this.platform.stream || this.state.responseId === null) return;\n const streamId = this.state.responseId;\n this.state.streamActive = false;\n this.state.streamedSource = \"\";\n await this.platform.stream.stop(streamId).catch(() => undefined);\n if (this.state.responseId === streamId) this.state.responseId = null;\n }\n\n private async renderRaw(\n text: string,\n operation: \"render\" | \"replace\",\n options?: { createOverflowLink?: () => string },\n canonicalText = text,\n ): Promise<string> {\n try {\n await this.postSplit(text);\n return canonicalText;\n } catch (err) {\n if (!this.platform.handleTooLong) throw err;\n if (this.platform.isTooLongError && !this.platform.isTooLongError(err)) throw err;\n const fallback = await this.platform.handleTooLong({\n text: canonicalText,\n operation,\n options,\n responseId: this.state.responseId,\n write: (fallbackText) => this.postSplit(fallbackText),\n getResponseId: () => this.state.responseId,\n });\n return fallback.text;\n }\n }\n\n private async renderDelta(text: string): Promise<string> {\n if (this.state.working && !text.trim()) return text;\n const prepared = this.platform.prepareSource?.(text, this.state.working) ?? text;\n const stream = this.platform.stream;\n const display = this.provisional(prepared, this.state.working);\n if (!stream || this.state.streamUnavailable) {\n await this.renderRaw(display, \"render\", undefined, prepared);\n return prepared;\n }\n if (this.state.responseId !== null && !this.state.streamActive) {\n await this.renderRaw(display, \"render\", undefined, prepared);\n return prepared;\n }\n if (\n this.state.responseId !== null &&\n this.state.streamActive &&\n !prepared.startsWith(this.state.streamedSource)\n ) {\n await this.abandonNativeStream();\n await this.renderRaw(display, \"render\", undefined, prepared);\n return prepared;\n }\n\n try {\n if (this.state.responseId !== null) {\n const delta = prepared.slice(this.state.streamedSource.length);\n if (delta && delta.length >= (stream.minDeltaChars ?? 0)) {\n await stream.append(this.state.responseId, delta);\n this.state.streamedSource = prepared;\n }\n return prepared;\n }\n this.state.responseId = await stream.start(prepared);\n this.state.streamActive = true;\n this.state.streamedSource = prepared;\n return prepared;\n } catch (err) {\n this.state.streamUnavailable = true;\n log.logWarning(\n \"Native response streaming unavailable; falling back to message updates\",\n err instanceof Error ? err.message : String(err),\n );\n await this.abandonNativeStream();\n await this.renderRaw(display, \"render\", undefined, prepared);\n return prepared;\n }\n }\n\n private async renderFinal(text: string): Promise<string> {\n const stream = this.platform.stream;\n if (stream && this.state.streamActive && this.state.responseId !== null) {\n let streamed = false;\n try {\n if (text.startsWith(this.state.streamedSource)) {\n const delta = text.slice(this.state.streamedSource.length);\n if (delta) await stream.append(this.state.responseId, delta);\n await stream.stop(this.state.responseId);\n streamed = true;\n }\n } catch (err) {\n this.state.streamUnavailable = true;\n log.logWarning(\n \"Native response streaming unavailable; falling back to message updates\",\n err instanceof Error ? err.message : String(err),\n );\n }\n this.state.streamActive = false;\n this.state.streamedSource = \"\";\n if (streamed) {\n if (this.platform.needsCanonicalRender?.(text)) await this.renderRaw(text, \"render\");\n return text;\n }\n await this.abandonNativeStream();\n }\n if (this.state.responseId !== null || text) return this.renderRaw(text, \"render\");\n return text;\n }\n\n private async run(\n label: string,\n operation: ChatResponseErrorOperation,\n work: () => Promise<void>,\n extra: () => Record<string, unknown>,\n ): Promise<void> {\n const operationPromise = this.queueTail.then(work);\n const handled = operationPromise.catch(async (err) => {\n const message = err instanceof Error ? err.message : String(err);\n log.logWarning(`${this.platform.label} ${label} error`, message);\n this.reportResponseError?.(err, operation, extra());\n if (this.platform.notifySendFailure) {\n try {\n await this.platform.notifySendFailure(message);\n } catch {\n // A secondary notification must not poison the response queue.\n }\n }\n });\n this.queueTail = handled.catch(() => undefined);\n return handled;\n }\n\n private async appendDelta(delta: string): Promise<void> {\n await this.run(\n \"appendResponseDelta\",\n \"respond\",\n async () => {\n if (!delta) return;\n if (this.state.resetDelta) {\n this.state.source = \"\";\n this.state.pendingChars = 0;\n this.state.resetDelta = false;\n }\n const sanitized = this.sanitize(delta);\n this.state.source += sanitized;\n this.state.pendingChars += sanitized.length;\n const elapsed = this.now() - this.state.lastFlushAt;\n if (\n this.state.lastFlushAt === 0 ||\n (elapsed >= this.flushIntervalMs && this.state.pendingChars > 0)\n ) {\n this.state.pendingChars = 0;\n this.state.source = await this.renderDelta(this.state.source);\n this.state.lastFlushAt = this.now();\n }\n },\n () => ({ textLength: delta.length, accumulatedLength: this.state.source.length }),\n );\n }\n\n private async respond(text: string): Promise<void> {\n await this.run(\n \"respond\",\n \"respond\",\n async () => {\n const sanitized = this.sanitize(text);\n this.state.source = this.state.source ? `${this.state.source}\\n${sanitized}` : sanitized;\n this.state.pendingChars = 0;\n this.state.source = await this.renderDelta(this.state.source);\n if (this.state.responseId !== null && this.platform.logIntermediateResponses) {\n this.platform.logBotResponse?.(text, this.state.responseId);\n }\n },\n () => ({\n phase: this.state.responseId ? \"update\" : \"initial_post\",\n textLength: text.length,\n accumulatedLength: this.state.source.length,\n }),\n );\n }\n\n private async finishResponse(finalText?: string): Promise<void> {\n await this.run(\n \"finishResponse\",\n \"set_working\",\n async () => {\n if (finalText !== undefined) this.state.source = this.sanitize(finalText);\n this.state.resetDelta = false;\n this.state.pendingChars = 0;\n this.stopTyping();\n this.state.working = false;\n this.state.source = await this.renderFinal(this.state.source);\n if (this.state.responseId !== null) {\n this.platform.logBotResponse?.(this.state.source, this.state.responseId);\n }\n await this.platform.onFinish?.(this.state.source, this.state.responseId);\n },\n () => ({ finalTextLength: finalText?.length }),\n );\n }\n\n private async replaceResponse(\n text: string,\n options?: { createOverflowLink?: () => string },\n ): Promise<void> {\n await this.run(\n \"replaceResponse\",\n \"replace_response\",\n async () => {\n this.state.source = this.sanitize(text);\n this.state.pendingChars = 0;\n this.state.resetDelta = true;\n if (this.state.streamActive) await this.stopNativeStream();\n if (this.state.working && !this.state.source.trim()) return;\n const prepared =\n this.platform.prepareSource?.(this.state.source, this.state.working) ?? this.state.source;\n this.state.source = await this.renderRaw(\n this.provisional(prepared, this.state.working),\n \"replace\",\n options,\n prepared,\n );\n },\n () => ({ textLength: text.length, hadExistingResponse: Boolean(this.state.responseId) }),\n );\n }\n\n private async replaceSubagentProgress(\n progress: SubagentProgressSnapshot,\n finalText?: string,\n ): Promise<void> {\n const dashboard = this.platform.formatSubagentProgress!(progress);\n await this.responder.replaceResponse(finalText ? `${dashboard}\\n\\n${finalText}` : dashboard);\n }\n\n private async respondDiagnostic(\n text: string,\n options: { style?: \"muted\" | \"error\" } = {},\n ): Promise<void> {\n await this.run(\n \"respondDiagnostic\",\n \"respond_diagnostic\",\n async () => {\n const ids = this.platform.postDiagnostic\n ? await this.platform.postDiagnostic(text, options, this.state.responseId)\n : await this.postDefaultDiagnostic(text, options);\n this.state.extraIds.push(...ids);\n },\n () => ({ textLength: text.length, style: options.style }),\n );\n }\n\n private async respondToolResult(result: ChatToolResult): Promise<void> {\n await this.responder.respondDiagnostic(this.platform.formatToolResult(result));\n }\n\n private async setTyping(isTyping: boolean): Promise<void> {\n await this.run(\n \"setTyping\",\n \"set_working\",\n async () => {\n if (this.platform.setTyping) {\n await this.platform.setTyping(isTyping, this.state.responseId);\n return;\n }\n const typing = this.platform.typing;\n if (!typing) return;\n const onTypingError = (err: unknown): void => {\n if (this.state.typingFailureWarned) return;\n this.state.typingFailureWarned = true;\n log.logWarning(\n `${this.platform.label} sendTyping failed (further occurrences suppressed for this session)`,\n err instanceof Error ? err.message : String(err),\n );\n };\n if (isTyping && this.state.typingInterval === null) {\n typing.send().catch(onTypingError);\n this.state.typingInterval = setInterval(() => {\n typing.send().catch(onTypingError);\n }, typing.intervalMs);\n } else if (!isTyping) {\n this.stopTyping();\n }\n },\n () => ({ working: isTyping }),\n );\n }\n\n private async setWorking(working: boolean): Promise<void> {\n await this.run(\n \"setWorking\",\n \"set_working\",\n async () => {\n this.state.working = working;\n if (!working) this.stopTyping();\n await this.platform.onWorkingChanged?.(working, this.state.responseId);\n if (\n this.state.responseId === null ||\n (!this.platform.workingIndicator && !this.platform.stream)\n ) {\n return;\n }\n if (working && !this.state.source.trim()) return;\n if (this.state.streamActive && !working) {\n await this.stopNativeStream();\n return;\n }\n if (this.state.responseId !== null) {\n this.state.source = await this.renderRaw(\n this.provisional(this.state.source, working),\n \"render\",\n undefined,\n this.state.source,\n );\n }\n },\n () => ({ working }),\n );\n }\n\n private async uploadFile(filePath: string, title?: string): Promise<void> {\n if (this.platform.uploadFile) {\n await this.platform.uploadFile(filePath, title);\n return;\n }\n const note = this.platform.uploadFallbackNote?.(title ?? filePath);\n if (note === undefined) return;\n await this.run(\n \"uploadFile\",\n \"respond_diagnostic\",\n () => this.postExtra(note),\n () => ({ filePath }),\n );\n }\n\n private async deleteResponse(): Promise<void> {\n await this.run(\n \"deleteResponse\",\n \"respond\",\n async () => {\n this.stopTyping();\n if (this.state.streamActive) await this.stopNativeStream().catch(() => undefined);\n for (const id of [...this.state.extraIds, ...this.state.continuationIds]) {\n try {\n await this.platform.deleteExtra?.(id);\n } catch {\n // Deleting diagnostics is best effort.\n }\n }\n this.state.extraIds = [];\n this.state.continuationIds = [];\n if (this.state.responseId !== null) {\n try {\n await this.platform.delete?.(this.state.responseId);\n } catch {\n // Deleting the main response is best effort.\n }\n }\n this.state.responseId = null;\n this.state.source = \"\";\n this.state.streamUnavailable = false;\n this.state.streamedSource = \"\";\n this.state.streamActive = false;\n this.state.resetDelta = false;\n this.state.working = true;\n },\n () => ({}),\n );\n }\n\n private async postDefaultDiagnostic(\n text: string,\n options: { style?: \"muted\" | \"error\" },\n ): Promise<Array<string | number>> {\n const prefix = options.style === \"error\" ? this.platform.errorPrefix : \"\";\n const ids: Array<string | number> = [];\n for (const part of this.split(this.sanitize(`${prefix}${text}`))) {\n const id = await this.platform.postExtra(part, this.state.responseId);\n if (typeof id === \"string\" || typeof id === \"number\") ids.push(id);\n }\n return ids;\n }\n}\n\nexport function createProgressiveRenderer(platform: ProgressiveRendererPlatform): {\n responder: ConversationResponder;\n} {\n return { responder: new ProgressiveRenderer(platform).responder };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"progressive-renderer.js","sourceRoot":"","sources":["../../src/adapters/progressive-renderer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,+BAA+B,EAC/B,cAAc,EACd,SAAS,GAEV,MAAM,aAAa,CAAC;AAGrB,MAAM,UAAU,wBAAwB,CAAC,MAAsB;IAC7D,MAAM,aAAa,GAAG,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,CAAC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACvD,IAAI,IAAI,GAAG,KAAK,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,IAAI,CAAC;IACzE,IAAI,MAAM,CAAC,KAAK;QAAE,IAAI,IA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I,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;YACtE,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,OAAO,EAAE,KAAK,QAAQ;gBAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AAED,MAAM,UAAU,yBAAyB,CAAC,QAAqC;IAG7E,OAAO,EAAE,SAAS,EAAE,IAAI,mBAAmB,CAAC,QAAQ,CAAC,CAAC,SAAS,EAAE,CAAC;AACpE,CAAC","sourcesContent":["import type {\n ChatToolResult,\n ConversationResponder,\n SubagentProgressSnapshot,\n} from \"../adapter.js\";\nimport * as log from \"../log.js\";\nimport {\n createChatResponseErrorReporter,\n formatToolArgs,\n splitText,\n type ChatResponseErrorOperation,\n} from \"./shared.js\";\nimport type { ProgressiveRendererPlatform } from \"./types.js\";\n\nexport function formatMarkdownToolResult(result: ChatToolResult): string {\n const argsFormatted = formatToolArgs(result.args);\n const duration = (result.durationMs / 1000).toFixed(1);\n let text = `**${result.isError ? \"Error\" : \"Done\"} ${result.toolName}**`;\n if (result.label) text += `: ${result.label}`;\n text += ` (${duration}s)\\n`;\n if (argsFormatted) text += `\\`\\`\\`\\n${argsFormatted}\\n\\`\\`\\`\\n`;\n text += `**Result:**\\n\\`\\`\\`\\n${result.result}\\n\\`\\`\\``;\n return text;\n}\n\ninterface RendererState {\n responseId: string | null;\n source: string;\n working: boolean;\n streamActive: boolean;\n streamUnavailable: boolean;\n streamedSource: string;\n pendingChars: number;\n lastFlushAt: number;\n resetDelta: boolean;\n typingInterval: ReturnType<typeof setInterval> | null;\n typingFailureWarned: boolean;\n extraIds: Array<string | number>;\n /**\n * Messages holding the overflow of a response too long for one message,\n * in order. Reused across redraws — see `postSplit`.\n */\n continuationIds: Array<string | number>;\n}\n\n/**\n * Floor on how often a streaming response redraws.\n *\n * Every platform meters edits per channel — Slack's is the tightest at roughly\n * fifty a minute — and a redraw sends the whole message, so the cost is the\n * number of calls, not their size. One second keeps a long answer inside that\n * budget while still reading as live.\n *\n * This is a floor, not a target: the interval is measured from when the last\n * redraw *finished*, so a platform that slows down under load slows the redraw\n * rate with it instead of queueing work it cannot deliver.\n */\nconst DEFAULT_FLUSH_INTERVAL_MS = 1000;\n\nclass ProgressiveRenderer {\n readonly responder: ConversationResponder;\n private readonly state: RendererState;\n private readonly sanitize: (text: string) => string;\n private readonly reportResponseError;\n private readonly now = Date.now;\n private readonly flushIntervalMs: number;\n private queueTail = Promise.resolve();\n\n constructor(private readonly platform: ProgressiveRendererPlatform) {\n this.state = {\n responseId: platform.initialResponseId ?? null,\n source: \"\",\n working: true,\n streamActive: false,\n streamUnavailable: false,\n streamedSource: \"\",\n pendingChars: 0,\n lastFlushAt: 0,\n resetDelta: false,\n typingInterval: null,\n typingFailureWarned: false,\n extraIds: [],\n continuationIds: [],\n };\n this.sanitize = platform.sanitize ?? ((text: string) => text);\n this.reportResponseError = platform.responseErrorContext\n ? createChatResponseErrorReporter(() => platform.responseErrorContext!(this.state.responseId))\n : undefined;\n this.flushIntervalMs = platform.flushIntervalMs ?? DEFAULT_FLUSH_INTERVAL_MS;\n this.responder = this.createResponder();\n }\n\n private createResponder(): ConversationResponder {\n return {\n respond: (text) => this.respond(text),\n appendResponseDelta:\n this.platform.supportsDeltas || this.platform.stream\n ? (delta) => this.appendDelta(delta)\n : undefined,\n finishResponse:\n this.platform.supportsDeltas || this.platform.stream\n ? (finalText) => this.finishResponse(finalText)\n : undefined,\n replaceResponse: (text, options) => this.replaceResponse(text, options),\n replaceSubagentProgress: this.platform.formatSubagentProgress\n ? (progress, finalText) => this.replaceSubagentProgress(progress, finalText)\n : undefined,\n respondDiagnostic: (text, options) => this.respondDiagnostic(text, options),\n respondToolResult: (result) => this.respondToolResult(result),\n setTyping: (isTyping) => this.setTyping(isTyping),\n setWorking: (working) => this.setWorking(working),\n uploadFile: (filePath, title) => this.uploadFile(filePath, title),\n ...(this.platform.react ? { react: this.platform.react } : {}),\n deleteResponse: () => this.deleteResponse(),\n };\n }\n\n private stopTyping(): void {\n if (this.state.typingInterval !== null) {\n clearInterval(this.state.typingInterval);\n this.state.typingInterval = null;\n }\n }\n\n private provisional(text: string, working: boolean): string {\n if (this.platform.formatProvisional) return this.platform.formatProvisional(text, working);\n return working && this.platform.workingIndicator ? text + this.platform.workingIndicator : text;\n }\n\n private split(text: string): string[] {\n return splitText(text, this.platform.maxLength, this.platform.formatContinuation);\n }\n\n private async postOrUpdate(text: string): Promise<void> {\n if (this.state.responseId !== null) {\n await this.platform.update(this.state.responseId, text);\n return;\n }\n if (this.platform.typing?.stopOnSend) this.stopTyping();\n this.state.responseId = await this.platform.post(text);\n }\n\n private async postSplit(text: string): Promise<void> {\n const [head = text, ...tail] = this.split(text);\n await this.postOrUpdate(head);\n for (const [index, part] of tail.entries()) {\n const existing = this.state.continuationIds[index];\n if (existing !== undefined) {\n await this.platform.update(String(existing), part);\n continue;\n }\n if (this.platform.typing?.stopOnSend) this.stopTyping();\n const id = await this.platform.postExtra(part, this.state.responseId);\n if (id !== undefined && id !== null) this.state.continuationIds[index] = id;\n }\n }\n\n private async postExtra(text: string): Promise<void> {\n if (this.platform.typing?.stopOnSend) this.stopTyping();\n await this.platform.postExtra(text, this.state.responseId);\n }\n\n private async stopNativeStream(): Promise<void> {\n if (!this.state.streamActive || this.state.responseId === null || !this.platform.stream) return;\n const streamId = this.state.responseId;\n this.state.streamActive = false;\n this.state.streamedSource = \"\";\n await this.platform.stream.stop(streamId);\n }\n\n private async abandonNativeStream(): Promise<void> {\n if (!this.platform.stream || this.state.responseId === null) return;\n const streamId = this.state.responseId;\n this.state.streamActive = false;\n this.state.streamedSource = \"\";\n await this.platform.stream.stop(streamId).catch(() => undefined);\n if (this.state.responseId === streamId) this.state.responseId = null;\n }\n\n private async renderRaw(\n text: string,\n operation: \"render\" | \"replace\",\n options?: { createOverflowLink?: () => string },\n canonicalText = text,\n ): Promise<string> {\n try {\n await this.postSplit(text);\n return canonicalText;\n } catch (err) {\n if (!this.platform.handleTooLong) throw err;\n if (this.platform.isTooLongError && !this.platform.isTooLongError(err)) throw err;\n const fallback = await this.platform.handleTooLong({\n text: canonicalText,\n operation,\n options,\n responseId: this.state.responseId,\n write: (fallbackText) => this.postSplit(fallbackText),\n getResponseId: () => this.state.responseId,\n });\n return fallback.text;\n }\n }\n\n private async renderDelta(text: string): Promise<string> {\n if (this.state.working && !text.trim()) return text;\n const prepared = this.platform.prepareSource?.(text, this.state.working) ?? text;\n const stream = this.platform.stream;\n const display = this.provisional(prepared, this.state.working);\n if (!stream || this.state.streamUnavailable) {\n await this.renderRaw(display, \"render\", undefined, prepared);\n return prepared;\n }\n if (this.state.responseId !== null && !this.state.streamActive) {\n await this.renderRaw(display, \"render\", undefined, prepared);\n return prepared;\n }\n if (\n this.state.responseId !== null &&\n this.state.streamActive &&\n !prepared.startsWith(this.state.streamedSource)\n ) {\n await this.abandonNativeStream();\n await this.renderRaw(display, \"render\", undefined, prepared);\n return prepared;\n }\n\n try {\n if (this.state.responseId !== null) {\n const delta = prepared.slice(this.state.streamedSource.length);\n if (delta && delta.length >= (stream.minDeltaChars ?? 0)) {\n await stream.append(this.state.responseId, delta);\n this.state.streamedSource = prepared;\n }\n return prepared;\n }\n this.state.responseId = await stream.start(prepared);\n this.state.streamActive = true;\n this.state.streamedSource = prepared;\n return prepared;\n } catch (err) {\n this.state.streamUnavailable = true;\n log.logWarning(\n \"Native response streaming unavailable; falling back to message updates\",\n err instanceof Error ? err.message : String(err),\n );\n await this.abandonNativeStream();\n await this.renderRaw(display, \"render\", undefined, prepared);\n return prepared;\n }\n }\n\n private async renderFinal(text: string): Promise<string> {\n const stream = this.platform.stream;\n if (stream && this.state.streamActive && this.state.responseId !== null) {\n let streamed = false;\n try {\n if (text.startsWith(this.state.streamedSource)) {\n const delta = text.slice(this.state.streamedSource.length);\n if (delta) await stream.append(this.state.responseId, delta);\n await stream.stop(this.state.responseId);\n streamed = true;\n }\n } catch (err) {\n this.state.streamUnavailable = true;\n log.logWarning(\n \"Native response streaming unavailable; falling back to message updates\",\n err instanceof Error ? err.message : String(err),\n );\n }\n this.state.streamActive = false;\n this.state.streamedSource = \"\";\n if (streamed) {\n if (this.platform.needsCanonicalRender?.(text)) await this.renderRaw(text, \"render\");\n return text;\n }\n await this.abandonNativeStream();\n }\n if (this.state.responseId !== null || text) return this.renderRaw(text, \"render\");\n return text;\n }\n\n private async run(\n label: string,\n operation: ChatResponseErrorOperation,\n work: () => Promise<void>,\n extra: () => Record<string, unknown>,\n ): Promise<void> {\n const operationPromise = this.queueTail.then(work);\n const handled = operationPromise.catch(async (err) => {\n const message = err instanceof Error ? err.message : String(err);\n log.logWarning(`${this.platform.label} ${label} error`, message);\n this.reportResponseError?.(err, operation, extra());\n if (this.platform.notifySendFailure) {\n try {\n await this.platform.notifySendFailure(message);\n } catch {\n // A secondary notification must not poison the response queue.\n }\n }\n });\n this.queueTail = handled.catch(() => undefined);\n return handled;\n }\n\n private async appendDelta(delta: string): Promise<void> {\n await this.run(\n \"appendResponseDelta\",\n \"respond\",\n async () => {\n if (!delta) return;\n if (this.state.resetDelta) {\n this.state.source = \"\";\n this.state.pendingChars = 0;\n this.state.resetDelta = false;\n }\n const sanitized = this.sanitize(delta);\n this.state.source += sanitized;\n this.state.pendingChars += sanitized.length;\n const elapsed = this.now() - this.state.lastFlushAt;\n if (\n this.state.lastFlushAt === 0 ||\n (elapsed >= this.flushIntervalMs && this.state.pendingChars > 0)\n ) {\n this.state.pendingChars = 0;\n try {\n this.state.source = await this.renderDelta(this.state.source);\n } finally {\n // A rejected edit still spent an API call. Pace subsequent deltas\n // from its completion too, retaining source for the next attempt.\n this.state.lastFlushAt = this.now();\n }\n }\n },\n () => ({ textLength: delta.length, accumulatedLength: this.state.source.length }),\n );\n }\n\n private async respond(text: string): Promise<void> {\n await this.run(\n \"respond\",\n \"respond\",\n async () => {\n const sanitized = this.sanitize(text);\n this.state.source = this.state.source ? `${this.state.source}\\n${sanitized}` : sanitized;\n this.state.pendingChars = 0;\n this.state.source = await this.renderDelta(this.state.source);\n if (this.state.responseId !== null && this.platform.logIntermediateResponses) {\n this.platform.logBotResponse?.(text, this.state.responseId);\n }\n },\n () => ({\n phase: this.state.responseId ? \"update\" : \"initial_post\",\n textLength: text.length,\n accumulatedLength: this.state.source.length,\n }),\n );\n }\n\n private async finishResponse(finalText?: string): Promise<void> {\n await this.run(\n \"finishResponse\",\n \"set_working\",\n async () => {\n if (finalText !== undefined) this.state.source = this.sanitize(finalText);\n this.state.resetDelta = false;\n this.state.pendingChars = 0;\n this.stopTyping();\n this.state.working = false;\n this.state.source = await this.renderFinal(this.state.source);\n if (this.state.responseId !== null) {\n this.platform.logBotResponse?.(this.state.source, this.state.responseId);\n }\n await this.platform.onFinish?.(this.state.source, this.state.responseId);\n },\n () => ({ finalTextLength: finalText?.length }),\n );\n }\n\n private async replaceResponse(\n text: string,\n options?: { createOverflowLink?: () => string },\n ): Promise<void> {\n await this.run(\n \"replaceResponse\",\n \"replace_response\",\n async () => {\n this.state.source = this.sanitize(text);\n this.state.pendingChars = 0;\n this.state.resetDelta = true;\n if (this.state.streamActive) await this.stopNativeStream();\n if (this.state.working && !this.state.source.trim()) return;\n const prepared =\n this.platform.prepareSource?.(this.state.source, this.state.working) ?? this.state.source;\n this.state.source = await this.renderRaw(\n this.provisional(prepared, this.state.working),\n \"replace\",\n options,\n prepared,\n );\n },\n () => ({ textLength: text.length, hadExistingResponse: Boolean(this.state.responseId) }),\n );\n }\n\n private async replaceSubagentProgress(\n progress: SubagentProgressSnapshot,\n finalText?: string,\n ): Promise<void> {\n const dashboard = this.platform.formatSubagentProgress!(progress);\n await this.responder.replaceResponse(finalText ? `${dashboard}\\n\\n${finalText}` : dashboard);\n }\n\n private async respondDiagnostic(\n text: string,\n options: { style?: \"muted\" | \"error\" } = {},\n ): Promise<void> {\n await this.run(\n \"respondDiagnostic\",\n \"respond_diagnostic\",\n async () => {\n const ids = this.platform.postDiagnostic\n ? await this.platform.postDiagnostic(text, options, this.state.responseId)\n : await this.postDefaultDiagnostic(text, options);\n this.state.extraIds.push(...ids);\n },\n () => ({ textLength: text.length, style: options.style }),\n );\n }\n\n private async respondToolResult(result: ChatToolResult): Promise<void> {\n await this.responder.respondDiagnostic(this.platform.formatToolResult(result));\n }\n\n private async setTyping(isTyping: boolean): Promise<void> {\n await this.run(\n \"setTyping\",\n \"set_working\",\n async () => {\n if (this.platform.setTyping) {\n await this.platform.setTyping(isTyping, this.state.responseId);\n return;\n }\n const typing = this.platform.typing;\n if (!typing) return;\n const onTypingError = (err: unknown): void => {\n if (this.state.typingFailureWarned) return;\n this.state.typingFailureWarned = true;\n log.logWarning(\n `${this.platform.label} sendTyping failed (further occurrences suppressed for this session)`,\n err instanceof Error ? err.message : String(err),\n );\n };\n if (isTyping && this.state.typingInterval === null) {\n typing.send().catch(onTypingError);\n this.state.typingInterval = setInterval(() => {\n typing.send().catch(onTypingError);\n }, typing.intervalMs);\n } else if (!isTyping) {\n this.stopTyping();\n }\n },\n () => ({ working: isTyping }),\n );\n }\n\n private async setWorking(working: boolean): Promise<void> {\n await this.run(\n \"setWorking\",\n \"set_working\",\n async () => {\n this.state.working = working;\n if (!working) this.stopTyping();\n await this.platform.onWorkingChanged?.(working, this.state.responseId);\n if (\n this.state.responseId === null ||\n (!this.platform.workingIndicator && !this.platform.stream)\n ) {\n return;\n }\n if (working && !this.state.source.trim()) return;\n if (this.state.streamActive && !working) {\n await this.stopNativeStream();\n return;\n }\n if (this.state.responseId !== null) {\n this.state.source = await this.renderRaw(\n this.provisional(this.state.source, working),\n \"render\",\n undefined,\n this.state.source,\n );\n }\n },\n () => ({ working }),\n );\n }\n\n private async uploadFile(filePath: string, title?: string): Promise<void> {\n if (this.platform.uploadFile) {\n await this.platform.uploadFile(filePath, title);\n return;\n }\n const note = this.platform.uploadFallbackNote?.(title ?? filePath);\n if (note === undefined) return;\n await this.run(\n \"uploadFile\",\n \"respond_diagnostic\",\n () => this.postExtra(note),\n () => ({ filePath }),\n );\n }\n\n private async deleteResponse(): Promise<void> {\n await this.run(\n \"deleteResponse\",\n \"respond\",\n async () => {\n this.stopTyping();\n if (this.state.streamActive) await this.stopNativeStream().catch(() => undefined);\n for (const id of [...this.state.extraIds, ...this.state.continuationIds]) {\n try {\n await this.platform.deleteExtra?.(id);\n } catch {\n // Deleting diagnostics is best effort.\n }\n }\n this.state.extraIds = [];\n this.state.continuationIds = [];\n if (this.state.responseId !== null) {\n try {\n await this.platform.delete?.(this.state.responseId);\n } catch {\n // Deleting the main response is best effort.\n }\n }\n this.state.responseId = null;\n this.state.source = \"\";\n this.state.streamUnavailable = false;\n this.state.streamedSource = \"\";\n this.state.streamActive = false;\n this.state.resetDelta = false;\n this.state.working = true;\n },\n () => ({}),\n );\n }\n\n private async postDefaultDiagnostic(\n text: string,\n options: { style?: \"muted\" | \"error\" },\n ): Promise<Array<string | number>> {\n const prefix = options.style === \"error\" ? this.platform.errorPrefix : \"\";\n const ids: Array<string | number> = [];\n for (const part of this.split(this.sanitize(`${prefix}${text}`))) {\n const id = await this.platform.postExtra(part, this.state.responseId);\n if (typeof id === \"string\" || typeof id === \"number\") ids.push(id);\n }\n return ids;\n }\n}\n\nexport function createProgressiveRenderer(platform: ProgressiveRendererPlatform): {\n responder: ConversationResponder;\n} {\n return { responder: new ProgressiveRenderer(platform).responder };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bot.d.ts","sourceRoot":"","sources":["../../../src/adapters/slack/bot.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,YAAY,EAEjB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAI1B,KAAK,aAAa,EAElB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAuB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAG5E,OAAO,KAAK,EAAE,aAA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{ createOfficeAddress } from "../../office/index.js";
|
|
8
8
|
import { COMMAND_MANIFEST } from "../commands/manifest.js";
|
|
9
|
-
import { resolveConversationSettings } from "../../config.js";
|
|
9
|
+
import { slackConversationAutoReplyEnabled, resolveConversationSettings } from "../../config.js";
|
|
10
10
|
import * as log from "../../log.js";
|
|
11
11
|
import { isRecord, readTextFileIfExists } from "../../file-guards.js";
|
|
12
12
|
import { PRODUCT_NAME, formatForceStopped } from "../../platform-messages.js";
|
|
@@ -760,7 +760,10 @@ export class SlackMessagingBot {
|
|
|
760
760
|
return processMessageIntake({
|
|
761
761
|
eventBase: options.event,
|
|
762
762
|
addressed: options.addressed,
|
|
763
|
-
magicWord: {
|
|
763
|
+
magicWord: {
|
|
764
|
+
addressed: options.magicWordAddressed ?? options.addressed,
|
|
765
|
+
scopeFallback: "top-level",
|
|
766
|
+
},
|
|
764
767
|
busyPolicy: "queue",
|
|
765
768
|
logEntryBase: {},
|
|
766
769
|
processAttachments: () => options.attachmentsPromise,
|
|
@@ -1187,17 +1190,14 @@ export class SlackMessagingBot {
|
|
|
1187
1190
|
return;
|
|
1188
1191
|
}
|
|
1189
1192
|
const activeSessionKey = slackEvent.sessionKey ?? resolveSlackSessionKey(e.channel, e.thread_ts);
|
|
1190
|
-
// Auto-reply top-level channel messages start with no sessionKey because
|
|
1191
|
-
// they are only candidates until the policy allows them. Persist the
|
|
1192
|
-
// resolved key on the event; otherwise the runtime fallback treats the
|
|
1193
|
-
// message ts as a thread session (`channel:ts`) instead of the persistent
|
|
1194
|
-
// top-level channel session.
|
|
1195
1193
|
slackEvent.sessionKey = activeSessionKey;
|
|
1194
|
+
const autoReply = !isDM && slackConversationAutoReplyEnabled(this.workspace.office(slackEvent.address));
|
|
1196
1195
|
const intake = this.processSlackMessageIntake({
|
|
1197
1196
|
event: slackEvent,
|
|
1198
1197
|
attachmentsPromise,
|
|
1199
1198
|
queueKey: this.resolveQueueKey(e.channel, activeSessionKey),
|
|
1200
|
-
addressed: isDM,
|
|
1199
|
+
addressed: isDM || autoReply,
|
|
1200
|
+
magicWordAddressed: isDM,
|
|
1201
1201
|
});
|
|
1202
1202
|
ack();
|
|
1203
1203
|
await intake;
|