ftown 0.19.67 → 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 (60) hide show
  1. package/dist/ask-question-hook.d.ts +46 -0
  2. package/dist/ask-question-hook.js +192 -0
  3. package/dist/ask-question-hook.js.map +1 -0
  4. package/dist/attention-events.d.ts +38 -2
  5. package/dist/attention-events.js +70 -0
  6. package/dist/attention-events.js.map +1 -1
  7. package/dist/attention-prompt-protocol.d.ts +92 -0
  8. package/dist/attention-prompt-protocol.js +28 -0
  9. package/dist/attention-prompt-protocol.js.map +1 -0
  10. package/dist/attention-prompt.d.ts +12 -0
  11. package/dist/attention-prompt.js +333 -0
  12. package/dist/attention-prompt.js.map +1 -0
  13. package/dist/attention-store.d.ts +29 -1
  14. package/dist/attention-store.js +218 -18
  15. package/dist/attention-store.js.map +1 -1
  16. package/dist/browser-access.js +7 -1
  17. package/dist/browser-access.js.map +1 -1
  18. package/dist/command-rpc.d.ts +8 -0
  19. package/dist/command-rpc.js +76 -18
  20. package/dist/command-rpc.js.map +1 -1
  21. package/dist/harness-commands.js +7 -0
  22. package/dist/harness-commands.js.map +1 -1
  23. package/dist/hook-installer.d.ts +2 -0
  24. package/dist/hook-installer.js +83 -9
  25. package/dist/hook-installer.js.map +1 -1
  26. package/dist/index.js +6 -0
  27. package/dist/index.js.map +1 -1
  28. package/dist/local-api-server.d.ts +4 -1
  29. package/dist/local-api-server.js +148 -11
  30. package/dist/local-api-server.js.map +1 -1
  31. package/dist/mcp/fleet.d.ts +1 -1
  32. package/dist/mcp/fleet.js +2 -2
  33. package/dist/mcp/fleet.js.map +1 -1
  34. package/dist/mcp/security-events.js +3 -3
  35. package/dist/mcp/security-events.js.map +1 -1
  36. package/dist/mcp/server.js +59 -9
  37. package/dist/mcp/server.js.map +1 -1
  38. package/dist/preview-chat-protocol.d.ts +50 -0
  39. package/dist/preview-chat-protocol.js +9 -0
  40. package/dist/preview-chat-protocol.js.map +1 -0
  41. package/dist/preview-chat.d.ts +18 -0
  42. package/dist/preview-chat.js +155 -0
  43. package/dist/preview-chat.js.map +1 -0
  44. package/dist/security/bridge/account-state.d.ts +4 -4
  45. package/dist/security/bridge/audit.js +2 -2
  46. package/dist/security/bridge/audit.js.map +1 -1
  47. package/dist/security/bridge/identity.d.ts +3 -3
  48. package/dist/security/bridge/metadata.d.ts +2 -2
  49. package/dist/security/bridge/permissions.js +17 -4
  50. package/dist/security/bridge/permissions.js.map +1 -1
  51. package/dist/session-controller.d.ts +32 -0
  52. package/dist/session-controller.js +49 -0
  53. package/dist/session-controller.js.map +1 -1
  54. package/dist/sessions-commands.d.ts +5 -0
  55. package/dist/sessions-commands.js +218 -5
  56. package/dist/sessions-commands.js.map +1 -1
  57. package/dist/types.d.ts +4 -2
  58. package/package.json +2 -2
  59. package/skills/ftown/SKILL.md +35 -6
  60. package/skills/ftown/references/sessions.md +80 -5
@@ -67,12 +67,41 @@ network access are not. Write a temporary file and rename it over the registered
67
67
  file to publish a complete update. Closing the dashboard preview does not clear
68
68
  the registration; `--clear` removes the registration without deleting the file.
69
69
 
70
+ Preview conversation input arrives through the session's existing ftown mail.
71
+ Post a tool-authored reply with:
72
+
73
+ ```bash
74
+ ftown sessions preview-reply --message "The preview is ready."
75
+ ftown sessions preview-reply --message-file ./reply.txt
76
+ printf 'First line\nSecond line\n' | ftown sessions preview-reply --message-file -
77
+ ```
78
+
79
+ The target defaults to `FTOWN_SESSION_ID`; `--session-id` selects an explicit
80
+ session. Replies are limited to 4096 UTF-8 bytes. Preserve the returned ID and
81
+ pass it with `--id <uuid>` alongside the same text when retrying an uncertain
82
+ result. An MCP controller can instead call `preview_chat_reply` with explicit
83
+ machine and session ID. A queued message does not mean an agent has read it.
84
+
70
85
  ## Ask the human or associate a pull request
71
86
 
72
87
  ```bash
73
88
  # Request human input for this session (JSON {event} by default)
74
89
  ftown sessions attention --message "Please review the migration plan" --title "Review requested"
75
90
 
91
+ # Ask a single-select question and block until the human answers (default timeout 600 s)
92
+ ftown sessions attention --title "Pick a database" --message "Which database should I use?" \
93
+ --option Postgres --option SQLite --wait
94
+
95
+ # Multi-select without free text
96
+ ftown sessions attention --message "Which checks should run?" --option Lint --option Test --option Typecheck --multi --no-text
97
+
98
+ # Several questions (array or {"questions": [...]})
99
+ ftown sessions attention --message "Setup" --questions-json '[{"question":"Runtime?","options":["Node","Bun"]},{"question":"Notes?"}]'
100
+
101
+ # Check a question later (one GET; --wait long-polls)
102
+ ftown sessions attention-status <event-id>
103
+ ftown sessions attention-status <event-id> --wait --timeout 300
104
+
76
105
  # Set or replace this session's single GitHub PR link (JSON {session})
77
106
  ftown sessions pr https://github.com/owner/repo/pull/123
78
107
 
@@ -98,6 +127,43 @@ Only creation triggers notification, and hosted push remains opt-in with existin
98
127
  session/harness eligibility. Do not automatically retry an uncertain mutation.
99
128
  Acknowledging/resolving an event never answers or approves a CLI prompt.
100
129
 
130
+ ### Questions and answers
131
+
132
+ `--option <label>` is repeatable and builds one question whose message is the
133
+ `--message` text, with those labels as choices. `--multi` allows several choices
134
+ and `--no-text` disallows free text; without options the question is free text.
135
+ `--questions-json` takes an array of questions or `{ "questions": [...] }`, where
136
+ each question has `question`, optional `header`, `options` (strings or
137
+ `{label, description?}`, at most 8), `multiSelect` and `allowText`. It cannot be
138
+ combined with `--option`, `--multi` or `--no-text`. `--multi` and `--no-text`
139
+ need `--option`; `--timeout` needs `--wait`; `--wait` needs questions. Questions
140
+ require a bridge reporting `capabilities.attention.prompt === true`; otherwise
141
+ the command fails before writing and asks you to update the bridge.
142
+
143
+ `--wait` and `attention-status --wait` print `Waiting for an answer (attention <id>)...`
144
+ to stderr and poll until the item is resolved or the deadline (`--timeout`
145
+ `--timeout <s>`, 1..86400, default 600). Exit codes:
146
+
147
+ | Exit | Meaning |
148
+ |------|---------|
149
+ | 0 | Answered; the formatted answer is printed to stdout |
150
+ | 2 | Resolved without an answer (dismissed or otherwise closed) |
151
+ | 3 | Still pending (`attention-status` without `--wait`) |
152
+ | 124 | Timed out; check later with `attention-status <id> --wait` |
153
+ | 1 | Error, including invalid flags or JSON and transient failures after retries |
154
+
155
+ Without `--wait`, `attention` prints the event ID when questions are present, so
156
+ the agent can check later with `attention-status`.
157
+
158
+ Delivery: the human answers in the dashboard inbox. A live waiter (`--wait`,
159
+ `attention-status --wait`, or MCP `attention_get` polling) receives the answer
160
+ directly. If nobody is waiting, the answer is sent as ftown mail from "You"
161
+ (`fromName` "You", thread `attention:<id>`) whose body starts with
162
+ `[ftown attention answer id=<id>]`. Claude Code `AskUserQuestion` calls inside an
163
+ FTown session follow the same path and are answered from the dashboard inbox.
164
+ The terminal picker appears only if the human chooses "Answer in terminal" or
165
+ after an hour.
166
+
101
167
  PR links accept only HTTPS GitHub `/owner/repo/pull/<positive-number>` URLs.
102
168
  Outer whitespace, query/fragment and a trailing slash are normalized; credentials,
103
169
  nondefault ports and other paths/hosts are rejected. No GitHub request is made.
@@ -107,10 +173,17 @@ its value. New sessions/children do not implicitly inherit a parent's PR.
107
173
  New commands probe the exact bridge capability before writing; update old bridges
108
174
  with the exact version setup command in their readiness hint. For remote MCP,
109
175
  `attention_request` requires explicit `{machine, sessionId, message, title?}` and
110
- returns `{machine, sessionId, event}`. `sessions_update` accepts `pullRequestUrl`
111
- (string or null), alongside existing name/parent fields. A mixed PR+name update
112
- rejects an old bridge before changing either field. Read-only MCP clients cannot
113
- see these mutation tools; control authorization and machine ownership still apply.
176
+ returns `{machine, sessionId, event}`; it also accepts optional `questions` (1 to
177
+ 4 entries, shaped as above) when the bridge reports `prompt`. `attention_get`
178
+ takes `{machine, sessionId, eventId, waitSeconds?}` (`waitSeconds` 0..25) and
179
+ returns `{machine, sessionId, event}`. Poll it until the event is resolved
180
+ (`resolvedAt` set): `event.answer` holds the answer, and a resolution without an
181
+ answer means the question was dismissed.
182
+
183
+ `sessions_update` accepts `pullRequestUrl` (string or null), alongside existing
184
+ name/parent fields. A mixed PR+name update rejects an old bridge before changing
185
+ either field. Read-only MCP clients cannot see these mutation tools; control
186
+ authorization and machine ownership still apply.
114
187
 
115
188
  ## Messaging (mail)
116
189
 
@@ -231,7 +304,9 @@ The CLI wraps the loopback API. Raw access if needed:
231
304
  | GET | `/api/sessions` | List |
232
305
  | POST | `/api/sessions` | Create |
233
306
  | PATCH | `/api/sessions/:id` | Rename, move or associate a PR (`{ name?, parentSessionId?, pullRequestUrl? }`; `null` detaches/clears) |
234
- | POST | `/api/sessions/:id/attention` | Request human input (`{ message, title? }`) → `{ event }` |
307
+ | POST | `/api/sessions/:id/attention` | Request human input (`{ message, title?, questions? }`) → `{ event }`; invalid `questions` → 400 `invalid_prompt` |
308
+ | GET | `/api/sessions/:id/attention/:eventId` | Read one item (`?waitSeconds=0..25` long-polls until resolved) → `{ event }`; 404 `attention_not_found` |
309
+ | POST | `/api/sessions/:id/attention/ask` | Harness hook: record an AskUserQuestion (`{ toolName, toolUseId, toolInput }`) → `{ event }` or `null` if not promptable |
235
310
  | GET | `/api/sessions/:id/screen` | Terminal lines |
236
311
  | POST | `/api/sessions/:id/grep` | Search |
237
312
  | POST | `/api/sessions/:id/keys` | Send keys |