@fastagent-sh/fastagent 0.19.0 → 0.20.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 (131) hide show
  1. package/dist/atomic-write.d.ts +11 -7
  2. package/dist/atomic-write.js +16 -11
  3. package/dist/channels/agentcore-limits.d.ts +9 -0
  4. package/dist/channels/agentcore-limits.js +9 -0
  5. package/dist/channels/agentcore-service.d.ts +12 -11
  6. package/dist/channels/agentcore-service.js +14 -18
  7. package/dist/channels/agentcore.d.ts +11 -19
  8. package/dist/channels/agentcore.js +14 -7
  9. package/dist/channels/control.d.ts +50 -12
  10. package/dist/channels/control.js +239 -96
  11. package/dist/channels/discover.d.ts +26 -4
  12. package/dist/channels/discover.js +12 -23
  13. package/dist/channels/feishu/feishu-api.js +5 -8
  14. package/dist/channels/feishu/feishu.js +35 -18
  15. package/dist/channels/kit/attachment-path.d.ts +12 -0
  16. package/dist/channels/kit/attachment-path.js +43 -0
  17. package/dist/channels/kit/context-buffer.d.ts +9 -0
  18. package/dist/channels/kit/context-buffer.js +11 -0
  19. package/dist/channels/kit/signature.d.ts +12 -0
  20. package/dist/channels/kit/signature.js +17 -0
  21. package/dist/channels/kit/stop-command.js +3 -3
  22. package/dist/channels/kit/tasks.d.ts +1 -1
  23. package/dist/channels/kit/tasks.js +10 -4
  24. package/dist/channels/kit/turn-store.d.ts +19 -3
  25. package/dist/channels/kit/turn-store.js +29 -2
  26. package/dist/channels/slack/invoke-turn.d.ts +1 -1
  27. package/dist/channels/slack/invoke-turn.js +5 -1
  28. package/dist/channels/slack/onboard.js +5 -5
  29. package/dist/channels/slack/onboarding-state.d.ts +7 -3
  30. package/dist/channels/slack/onboarding-state.js +13 -20
  31. package/dist/channels/slack/register-webhook.js +1 -1
  32. package/dist/channels/slack/scaffold/slack-send.ts +2 -17
  33. package/dist/channels/slack/slack-api.js +22 -54
  34. package/dist/channels/slack/slack.js +13 -13
  35. package/dist/channels/telegram/parse.d.ts +21 -1
  36. package/dist/channels/telegram/parse.js +65 -11
  37. package/dist/channels/telegram/scaffold/channel.ts +7 -3
  38. package/dist/channels/telegram/telegram-api.js +5 -6
  39. package/dist/channels/telegram/telegram.d.ts +2 -2
  40. package/dist/channels/telegram/telegram.js +57 -69
  41. package/dist/cli/add-slack.js +6 -5
  42. package/dist/cli/commands/add.js +1 -5
  43. package/dist/cli/commands/attach.d.ts +2 -4
  44. package/dist/cli/commands/attach.js +17 -15
  45. package/dist/cli/commands/deploy.d.ts +50 -5
  46. package/dist/cli/commands/deploy.js +183 -134
  47. package/dist/cli/commands/dev.js +4 -31
  48. package/dist/cli/commands/info.js +1 -2
  49. package/dist/cli/commands/init.js +1 -2
  50. package/dist/cli/commands/start.js +31 -41
  51. package/dist/cli/serve.d.ts +12 -21
  52. package/dist/cli/serve.js +20 -25
  53. package/dist/cli/shared.d.ts +40 -10
  54. package/dist/cli/shared.js +51 -4
  55. package/dist/deploy/agentcore/logs.d.ts +2 -2
  56. package/dist/deploy/agentcore/logs.js +2 -2
  57. package/dist/deploy/agentcore/plan.d.ts +12 -10
  58. package/dist/deploy/agentcore/plan.js +39 -31
  59. package/dist/deploy/agentcore/run.d.ts +5 -4
  60. package/dist/deploy/agentcore/run.js +13 -36
  61. package/dist/deploy/channel-ingress.d.ts +73 -0
  62. package/dist/deploy/channel-ingress.js +101 -0
  63. package/dist/deploy/docker/plan.d.ts +3 -7
  64. package/dist/deploy/docker/plan.js +4 -15
  65. package/dist/deploy/docker/run.d.ts +18 -1
  66. package/dist/deploy/docker/run.js +10 -0
  67. package/dist/deploy/fly/plan.d.ts +4 -5
  68. package/dist/deploy/fly/plan.js +7 -22
  69. package/dist/deploy/fly/run.d.ts +9 -23
  70. package/dist/deploy/fly/run.js +32 -68
  71. package/dist/deploy/preflight.d.ts +6 -7
  72. package/dist/deploy/preflight.js +26 -22
  73. package/dist/deploy/railway/plan.d.ts +4 -5
  74. package/dist/deploy/railway/plan.js +11 -26
  75. package/dist/deploy/railway/run.d.ts +9 -9
  76. package/dist/deploy/railway/run.js +40 -40
  77. package/dist/deploy/runner.js +22 -2
  78. package/dist/deploy/secrets.d.ts +18 -9
  79. package/dist/deploy/secrets.js +64 -12
  80. package/dist/dev-supervisor.js +3 -4
  81. package/dist/engines/pi/agent-session-factory.js +20 -39
  82. package/dist/engines/pi/auth.js +43 -43
  83. package/dist/engines/pi/config.d.ts +1 -1
  84. package/dist/engines/pi/create.d.ts +14 -2
  85. package/dist/engines/pi/create.js +2 -2
  86. package/dist/engines/pi/definition.d.ts +1 -1
  87. package/dist/engines/pi/definition.js +3 -4
  88. package/dist/engines/pi/login.js +32 -16
  89. package/dist/engines/pi/open.d.ts +1 -2
  90. package/dist/engines/pi/open.js +1 -1
  91. package/dist/engines/pi/search-tools.js +1 -1
  92. package/dist/engines/pi/service.d.ts +1 -1
  93. package/dist/engines/pi/service.js +8 -0
  94. package/dist/engines/pi/session-builder.js +6 -33
  95. package/dist/engines/pi/session-control.d.ts +19 -6
  96. package/dist/engines/pi/session-control.js +565 -470
  97. package/dist/engines/pi/session-inheritance.d.ts +8 -22
  98. package/dist/engines/pi/session-inheritance.js +95 -76
  99. package/dist/engines/pi/session-markers.d.ts +48 -0
  100. package/dist/engines/pi/session-markers.js +59 -0
  101. package/dist/engines/pi/session-settings.d.ts +4 -4
  102. package/dist/engines/pi/session-settings.js +7 -4
  103. package/dist/engines/pi/session-store.d.ts +83 -13
  104. package/dist/engines/pi/session-store.js +408 -55
  105. package/dist/engines/pi/tool-context.d.ts +21 -8
  106. package/dist/engines/pi/tool-context.js +29 -4
  107. package/dist/engines/pi/tool.js +2 -2
  108. package/dist/env.js +1 -2
  109. package/dist/loader.d.ts +49 -7
  110. package/dist/loader.js +79 -18
  111. package/dist/paths.d.ts +19 -0
  112. package/dist/paths.js +27 -2
  113. package/dist/scaffold/add-channel.js +2 -2
  114. package/dist/scaffold/init.js +7 -2
  115. package/dist/scaffold/templates/tools/fetch-url.ts +0 -2
  116. package/dist/schedule/discover.js +3 -15
  117. package/dist/schedule/wake-alarm.d.ts +13 -7
  118. package/dist/schedule/wake-alarm.js +88 -46
  119. package/dist/schedule/wakeups.d.ts +1 -1
  120. package/dist/schedule/wakeups.js +10 -7
  121. package/dist/service.d.ts +1 -2
  122. package/dist/service.js +27 -5
  123. package/dist/session-remote.d.ts +7 -2
  124. package/dist/session-remote.js +162 -92
  125. package/dist/session.d.ts +226 -92
  126. package/dist/session.js +61 -23
  127. package/dist/telegram.d.ts +1 -1
  128. package/dist/telegram.js +1 -1
  129. package/dist/tunnel.d.ts +18 -3
  130. package/dist/tunnel.js +32 -40
  131. package/package.json +1 -1
package/dist/tunnel.js CHANGED
@@ -7,11 +7,10 @@
7
7
  * Process orchestration, not assembly — lives outside the engine, beside dev-supervisor.ts.
8
8
  */
9
9
  import { spawn } from "node:child_process";
10
- import { readdirSync } from "node:fs";
11
- import { join } from "node:path";
12
10
  import { registerFeishuWebhook } from "./channels/feishu/register-webhook.js";
13
11
  import { registerSlackWebhook } from "./channels/slack/register-webhook.js";
14
12
  import { registerTelegramWebhook } from "./channels/telegram/register-webhook.js";
13
+ import { pointChannelsAt } from "./deploy/channel-ingress.js";
15
14
  import { dotEnvPath, loadDotEnv } from "./env.js";
16
15
  import { resolveStateRoot } from "./paths.js";
17
16
  import { log } from "./log.js";
@@ -106,23 +105,23 @@ function lastErrorLine(tail) {
106
105
  .filter(Boolean);
107
106
  return ([...lines].reverse().find((l) => /err|error|failed/i.test(l)) ?? lines.at(-1) ?? "").slice(0, 200);
108
107
  }
109
- /** Channel basenames present in `<dir>/channels/`. */
110
- function channelBasenames(dir) {
111
- try {
112
- return readdirSync(join(dir, "channels"))
113
- .filter((n) => /\.(ts|js|mjs)$/.test(n) && !n.endsWith(".d.ts"))
114
- .map((n) => n.replace(/\.(ts|js|mjs)$/, ""));
115
- }
116
- catch {
117
- return [];
118
- }
119
- }
120
108
  /**
121
109
  * Print the public URL and wire up first-party webhook channels found under `dir` (the agent
122
110
  * ROOT): Telegram and Feishu/Lark use runtime credentials; onboarded Slack uses its owner-local config
123
111
  * token; GitHub and a manually scaffolded Slack app receive explicit console URLs.
112
+ *
113
+ * Returns what each registrar ANSWERED, because two kinds of caller need different things from a
114
+ * failure. `dev`/`start` are long-running: a webhook that did not register is a logged problem, not
115
+ * a reason to stop serving, and they void this. `deploy … --run` is a command that exits, and an
116
+ * exit 0 there tells its caller the deployment is reachable — so it feeds these through
117
+ * `registrationGate`, exactly as the fly/railway/agentcore runners feed their own registrar calls
118
+ * (docker used to be the one host that could not, because this returned nothing).
124
119
  */
125
- export async function announceWebhooks(dir, baseUrl, opts = {}) {
120
+ export async function announceWebhooks(dir, baseUrl,
121
+ /** Every declared channel with its ingress. Not a pre-filtered list: this used to accept "the route
122
+ * channels" and default to every basename in `channels/`, which pointed a webhook at a
123
+ * long-connection channel whenever a caller forgot to filter. {@link pointChannelsAt} filters. */
124
+ channels, opts = {}) {
126
125
  log.info(`[fastagent] public URL: ${baseUrl}`);
127
126
  try {
128
127
  loadDotEnv(dir); // webhook registrars read channel credentials from .env
@@ -135,33 +134,26 @@ export async function announceWebhooks(dir, baseUrl, opts = {}) {
135
134
  // missing-credential guidance. loadDotEnv keeps throwing for the synchronous command callers.
136
135
  log.warn(`[fastagent] could not read ${dotEnvPath(dir)}: ${error.message} — continuing without it`);
137
136
  }
138
- // Serving passes the validated route-channel subset. The basename fallback preserves the public
139
- // helper's behavior for callers that did not assemble channels first.
140
- const routeChannels = opts.routeChannels ?? channelBasenames(dir);
141
- if (routeChannels.length === 0)
142
- return;
143
- // Readiness is the registrar's job now: a fresh quick tunnel returns Cloudflare 530 for ~20-30s before
144
- // its origin connects, and the automatic registrars poll /health before configuring the platform (the
145
- // same wait the deploy runners rely on). GitHub needs no wait — the operator adds that webhook by hand.
146
- if (routeChannels.includes("telegram"))
147
- await registerTelegramWebhook(baseUrl);
148
- if (routeChannels.includes("github")) {
149
- log.info(`[fastagent] github: add a webhook in your repo (Settings → Webhooks): Payload URL = ${baseUrl}/webhook, content type application/json, secret = GITHUB_WEBHOOK_SECRET`);
150
- }
151
- if (routeChannels.includes("slack")) {
152
- await registerSlackWebhook(baseUrl, {
153
- stateRoot: opts.stateRoot ?? resolveStateRoot(dir),
154
- log: (message) => log.info(message),
155
- });
156
- }
157
- // feishu/lark register programmatically too (application-v7 config PATCH — telegram-setWebhook
158
- // parity), once per mounted kind (each kind is its own app with its own credentials); the registrar
159
- // owns its own health wait and degrades to the manual console instruction.
137
+ // Readiness is the registrar's job: a fresh quick tunnel returns Cloudflare 530 for ~20-30s before its
138
+ // origin connects, and the automatic registrars poll /health before configuring the platform (the same
139
+ // wait the deploy runners rely on). GitHub needs no wait — the operator adds that webhook by hand.
140
+ //
141
+ // The registrars differ from the deploy path's in what they carry, not in which channels they answer
142
+ // for: this one narrates to the log and opens the console for a manual Feishu step.
160
143
  const feishuOptions = {
161
144
  onManualRegistration: ({ consoleUrl }) => opts.openUrl?.(consoleUrl),
162
145
  };
163
- if (routeChannels.includes("feishu"))
164
- await registerFeishuWebhook(baseUrl, "feishu", feishuOptions);
165
- if (routeChannels.includes("lark"))
166
- await registerFeishuWebhook(baseUrl, "lark", feishuOptions);
146
+ return pointChannelsAt({
147
+ baseUrl,
148
+ channels,
149
+ log: (message) => log.info(`[fastagent] ${message}`),
150
+ registrars: {
151
+ telegram: (url) => registerTelegramWebhook(url),
152
+ slack: (url) => registerSlackWebhook(url, {
153
+ stateRoot: opts.stateRoot ?? resolveStateRoot(dir),
154
+ log: (message) => log.info(message),
155
+ }),
156
+ feishu: (url, kind) => registerFeishuWebhook(url, kind, feishuOptions),
157
+ },
158
+ });
167
159
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastagent-sh/fastagent",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "Vibe first. Then FastAgent: turn a local agent directory into a live service in your app, on GitHub, Telegram, Slack, or behind any channel.",
5
5
  "keywords": [
6
6
  "agent",