talon-agent 4.3.1 → 4.3.2

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 (78) hide show
  1. package/package.json +1 -1
  2. package/src/app.ts +1 -1
  3. package/src/bootstrap.ts +2 -2
  4. package/src/cli/skill.ts +2 -2
  5. package/src/core/background/cron-spec.ts +1 -1
  6. package/src/core/background/cron.ts +1 -1
  7. package/src/core/background/heartbeat/agent.ts +1 -1
  8. package/src/core/background/triggers/command.ts +1 -1
  9. package/src/core/background/triggers/exit.ts +1 -1
  10. package/src/core/background/triggers/output.ts +1 -1
  11. package/src/core/background/triggers/resume.ts +1 -1
  12. package/src/core/background/triggers/spawn.ts +1 -1
  13. package/src/core/engine/gateway-actions/cron.ts +2 -2
  14. package/src/core/engine/gateway-actions/goals.ts +2 -2
  15. package/src/core/engine/gateway-actions/scripts.ts +1 -1
  16. package/src/core/engine/gateway-actions/skills.ts +1 -1
  17. package/src/core/engine/gateway-actions/triggers.ts +2 -2
  18. package/src/core/engine/gateway-actions/{shared.ts → validation.ts} +2 -2
  19. package/src/core/prompt/assemble.ts +2 -2
  20. package/src/core/scripts/runner.ts +1 -1
  21. package/src/core/soul/forgetting.ts +2 -2
  22. package/src/core/soul/salience.ts +8 -4
  23. package/src/frontend/discord/actions/{shared.ts → buttons.ts} +3 -56
  24. package/src/frontend/discord/actions/channels.ts +34 -0
  25. package/src/frontend/discord/actions/chat-info.ts +1 -1
  26. package/src/frontend/discord/actions/index.ts +1 -1
  27. package/src/frontend/discord/actions/media.ts +1 -1
  28. package/src/frontend/discord/actions/messaging.ts +4 -2
  29. package/src/frontend/discord/actions/try-action.ts +24 -0
  30. package/src/frontend/discord/admin.ts +2 -2
  31. package/src/frontend/discord/callbacks/components/settings.ts +1 -1
  32. package/src/frontend/discord/callbacks/modals.ts +1 -1
  33. package/src/frontend/discord/commands/admin.ts +2 -2
  34. package/src/frontend/discord/commands/info.ts +2 -2
  35. package/src/frontend/discord/commands/{shared.ts → interaction.ts} +2 -1
  36. package/src/frontend/discord/commands/router.ts +1 -1
  37. package/src/frontend/discord/commands/session.ts +2 -2
  38. package/src/frontend/discord/commands/settings.ts +2 -2
  39. package/src/frontend/discord/{helpers.ts → render.ts} +2 -1
  40. package/src/frontend/native/extensions.ts +1 -1
  41. package/src/frontend/teams/chat-discovery.ts +69 -0
  42. package/src/frontend/teams/commands.ts +141 -0
  43. package/src/frontend/teams/index.ts +24 -350
  44. package/src/frontend/teams/outbound.ts +44 -0
  45. package/src/frontend/teams/poll.ts +101 -0
  46. package/src/frontend/teams/runtime.ts +51 -0
  47. package/src/frontend/teams/turn.ts +97 -0
  48. package/src/frontend/telegram/actions/messaging.ts +1 -1
  49. package/src/frontend/telegram/actions/shared.ts +4 -4
  50. package/src/frontend/telegram/admin.ts +1 -1
  51. package/src/frontend/telegram/sticker-library.ts +2 -2
  52. package/src/frontend/whatsapp/actions/account.ts +3 -6
  53. package/src/frontend/whatsapp/actions/chat-info.ts +2 -1
  54. package/src/frontend/whatsapp/actions/coerce.ts +30 -0
  55. package/src/frontend/whatsapp/actions/history.ts +1 -1
  56. package/src/frontend/whatsapp/actions/media-upload.ts +82 -0
  57. package/src/frontend/whatsapp/actions/media.ts +3 -8
  58. package/src/frontend/whatsapp/actions/messaging.ts +2 -7
  59. package/src/frontend/whatsapp/actions/moderation.ts +2 -1
  60. package/src/frontend/whatsapp/actions/{shared.ts → send.ts} +4 -124
  61. package/src/frontend/whatsapp/actions/try-action.ts +24 -0
  62. package/src/frontend/whatsapp/commands.ts +1 -1
  63. package/src/frontend/whatsapp/inbound.ts +1 -1
  64. package/src/frontend/whatsapp/index.ts +1 -1
  65. package/src/storage/repositories/cron-repo.ts +1 -1
  66. package/src/storage/repositories/goals-repo.ts +1 -1
  67. package/src/storage/repositories/scripts-repo.ts +1 -1
  68. package/src/storage/repositories/triggers-repo.ts +1 -1
  69. package/src/storage/sql/schema.sql +1 -1
  70. package/src/storage/sql/statements.generated.ts +2 -2
  71. package/src/storage/sql/triggers.sql +1 -1
  72. /package/src/storage/{cron-store.ts → cron.ts} +0 -0
  73. /package/src/storage/{goal-store.ts → goals.ts} +0 -0
  74. /package/src/storage/{scheduled-store.ts → scheduled.ts} +0 -0
  75. /package/src/storage/{script-store.ts → scripts.ts} +0 -0
  76. /package/src/storage/{skill-store.ts → skills.ts} +0 -0
  77. /package/src/storage/{sticker-store.ts → stickers.ts} +0 -0
  78. /package/src/storage/{trigger-store.ts → triggers.ts} +0 -0
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Run a WhatsApp action, converting a throw into a structured failure.
3
+ */
4
+
5
+ import { logError } from "../../../util/log.js";
6
+ import type { ActionResult } from "../../../core/types.js";
7
+
8
+ /**
9
+ * Run an action, converting a throw into a structured failure. WhatsApp
10
+ * errors arrive as Boom objects whose message is the useful part; the
11
+ * model gets that text so it can adapt rather than retry blindly.
12
+ */
13
+ export async function tryAction(
14
+ label: string,
15
+ fn: () => Promise<ActionResult>,
16
+ ): Promise<ActionResult> {
17
+ try {
18
+ return await fn();
19
+ } catch (err) {
20
+ const msg = err instanceof Error ? err.message : String(err);
21
+ logError("whatsapp", `${label} failed: ${msg}`);
22
+ return { ok: false, error: `${label}: ${msg}` };
23
+ }
24
+ }
@@ -42,7 +42,7 @@ import {
42
42
  type ModelCommandDeps,
43
43
  type ModelOverview,
44
44
  } from "../shared/model-commands.js";
45
- import { sendText } from "./actions/shared.js";
45
+ import { sendText } from "./actions/send.js";
46
46
  import { identityAllowed, type Identity } from "./identity.js";
47
47
  import type { WhatsAppChatInfo } from "./registry.js";
48
48
  import type { WhatsAppRuntime } from "./runtime.js";
@@ -18,7 +18,7 @@ import {
18
18
  } from "../../util/watchdog.js";
19
19
  import { isAddressedToSelf, isGroupAllowed } from "./access.js";
20
20
  import { handleWhatsAppCommand } from "./commands.js";
21
- import { sendText } from "./actions/shared.js";
21
+ import { sendText } from "./actions/send.js";
22
22
  import {
23
23
  bareId,
24
24
  canonicalId,
@@ -25,7 +25,7 @@ import type { Gateway } from "../../core/engine/gateway.js";
25
25
  import { log, logError, logWarn } from "../../util/log.js";
26
26
  import { maxMsgIdForChatPrefix } from "../../storage/history.js";
27
27
  import { createWhatsAppActionHandler } from "./actions/index.js";
28
- import { sendText, setWhatsAppBotName } from "./actions/shared.js";
28
+ import { sendText, setWhatsAppBotName } from "./actions/send.js";
29
29
  import { seedMessageStore } from "./message-store.js";
30
30
  import {
31
31
  maxWhatsAppMsgId,
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Cron repository — executes the statements in sql/cron.sql against
3
3
  * the `cron_jobs` table; no SQL text lives here. The public store
4
- * (storage/cron-store.ts) holds the domain API and validation; this
4
+ * (storage/cron.ts) holds the domain API and validation; this
5
5
  * module owns statement execution and the row↔domain mapping.
6
6
  */
7
7
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Goals repository — executes the statements in sql/goals.sql against
3
3
  * the `goals` table; no SQL text lives here. The public store
4
- * (storage/goal-store.ts) holds the domain API and validation; this
4
+ * (storage/goals.ts) holds the domain API and validation; this
5
5
  * module owns statement execution and the row↔domain mapping.
6
6
  */
7
7
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Scripts repository — executes the statements in sql/scripts.sql
3
3
  * against the `scripts` table; no SQL text lives here. The public
4
- * store (storage/script-store.ts) holds the domain API, validation,
4
+ * store (storage/scripts.ts) holds the domain API, validation,
5
5
  * and the on-disk script files; this module owns statement execution
6
6
  * and the row↔domain mapping.
7
7
  */
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Triggers repository — executes the statements in sql/triggers.sql
3
3
  * against the `triggers` table; no SQL text lives here. The public
4
- * store (storage/trigger-store.ts) holds the domain API, validation
4
+ * store (storage/triggers.ts) holds the domain API, validation
5
5
  * and the on-disk script/log handling; this module owns statement
6
6
  * execution and the row↔domain mapping.
7
7
  */
@@ -140,7 +140,7 @@ CREATE INDEX IF NOT EXISTS idx_goals_chat_status ON goals(chat_id, status, updat
140
140
  CREATE INDEX IF NOT EXISTS idx_goals_status ON goals(status, updated_at DESC);
141
141
 
142
142
  -- Agent-authored scripts. Metadata rows only: the script body lives on
143
- -- disk under ~/.talon/workspace/scripts/ (mirroring the trigger-store
143
+ -- disk under ~/.talon/workspace/scripts/ (mirroring the triggers store
144
144
  -- split) so the agent can also Read/Edit a script as a normal workspace
145
145
  -- file. Scripts are global capabilities, not chat data — no chat_id
146
146
  -- column. `name` is the lookup key; UNIQUE enforces one per name.
@@ -145,7 +145,7 @@ CREATE INDEX IF NOT EXISTS idx_goals_chat_status ON goals(chat_id, status, updat
145
145
  CREATE INDEX IF NOT EXISTS idx_goals_status ON goals(status, updated_at DESC);
146
146
 
147
147
  -- Agent-authored scripts. Metadata rows only: the script body lives on
148
- -- disk under ~/.talon/workspace/scripts/ (mirroring the trigger-store
148
+ -- disk under ~/.talon/workspace/scripts/ (mirroring the triggers store
149
149
  -- split) so the agent can also Read/Edit a script as a normal workspace
150
150
  -- file. Scripts are global capabilities, not chat data — no chat_id
151
151
  -- column. \`name\` is the lookup key; UNIQUE enforces one per name.
@@ -561,7 +561,7 @@ FROM triggers ORDER BY created_at`,
561
561
  SET status = 'terminated',
562
562
  pid = NULL,
563
563
  ended_at = COALESCE(ended_at, ?),
564
- -- Literal must match RESTART_KILL_ERROR in storage/trigger-store.ts.
564
+ -- Literal must match RESTART_KILL_ERROR in storage/triggers.ts.
565
565
  last_error = COALESCE(last_error, 'Talon restarted while trigger was running')
566
566
  WHERE status IN ('running', 'pending') AND persistent = 0
567
567
 
@@ -56,7 +56,7 @@ UPDATE triggers
56
56
  SET status = 'terminated',
57
57
  pid = NULL,
58
58
  ended_at = COALESCE(ended_at, ?),
59
- -- Literal must match RESTART_KILL_ERROR in storage/trigger-store.ts.
59
+ -- Literal must match RESTART_KILL_ERROR in storage/triggers.ts.
60
60
  last_error = COALESCE(last_error, 'Talon restarted while trigger was running')
61
61
  WHERE status IN ('running', 'pending') AND persistent = 0
62
62
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes