@tiledesk/tiledesk-server 3.0.0 → 3.1.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.
- package/.circleci/config.yml +1 -1
- package/CHANGELOG.md +37 -0
- package/Dockerfile +3 -2
- package/Dockerfile-en +3 -2
- package/Dockerfile-jobs +3 -2
- package/Dockerfile-profiler +3 -2
- package/README.md +15 -0
- package/app.js +14 -1
- package/bin/quota-reset +68 -0
- package/bin/quota-restore +86 -0
- package/channels/chat21/chat21Handler.js +50 -34
- package/channels/chat21/chat21JoinTracker.js +43 -0
- package/config/database.js +5 -5
- package/config/native_mcp/native_mcp_servers.json +1 -0
- package/controllers/chatbot.controller.js +80 -27
- package/controllers/intents.controller.js +42 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-chat21-ionic.md +468 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-design-studio.md +1349 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-server.md +1694 -0
- package/docs/superpowers/plans/2026-09-15-webhook-chatbot-hitl-tybot.md +789 -0
- package/docs/superpowers/plans/2026-09-29-hitl-known-limits-server.md +83 -0
- package/docs/superpowers/plans/2026-09-29-hitl-known-limits-tybot.md +76 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-chat21-ionic.md +97 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-design-studio.md +72 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-server.md +223 -0
- package/docs/superpowers/plans/2026-09-29-hitl-participant-removal-tybot.md +121 -0
- package/docs/superpowers/plans/2026-09-29-hitl-pre-branch-ports.md +65 -0
- package/docs/superpowers/plans/2026-09-30-flow-start-points-design-studio.md +88 -0
- package/docs/superpowers/plans/2026-09-30-flow-start-points-server.md +103 -0
- package/docs/superpowers/plans/2026-09-30-flow-start-points-tybot.md +43 -0
- package/docs/superpowers/plans/2026-10-01-scheduled-start-point-design-studio.md +80 -0
- package/docs/superpowers/plans/2026-10-01-scheduled-start-point-runtime.md +39 -0
- package/docs/superpowers/plans/2026-10-01-scheduled-start-point-server.md +106 -0
- package/docs/superpowers/specs/2026-09-15-webhook-chatbot-hitl-design.md +715 -0
- package/docs/superpowers/specs/2026-09-30-flow-start-points-design.md +156 -0
- package/docs/superpowers/specs/2026-10-01-scheduled-start-point-design.md +303 -0
- package/docs/superpowers/todo/2026-09-14-webhook-chatbot-shared-code-fixes.md +191 -0
- package/event/botEvent.js +12 -1
- package/event/emailEvent.js +3 -0
- package/event/messageEvent.js +44 -0
- package/jobs.js +10 -0
- package/jobsManager.js +19 -0
- package/middleware/errorHandler.js +6 -2
- package/models/agentPrompt.js +104 -0
- package/models/analyticResult.js +1 -1
- package/models/channelConstants.js +3 -2
- package/models/quotaUsage.js +71 -0
- package/models/request.js +6 -0
- package/models/requestSnapshot.js +12 -0
- package/models/routerLogger.js +1 -1
- package/models/webhook.js +44 -0
- package/package.json +7 -5
- package/pubmodules/emailNotification/requestNotification.js +14 -22
- package/pubmodules/events/test/eventRoute.js +7 -6
- package/pubmodules/rules/conciergeBot.js +9 -4
- package/routes/agentPrompts.js +132 -0
- package/routes/auth.js +1 -12
- package/routes/campaigns.js +0 -13
- package/routes/dataTable.js +0 -3
- package/routes/faq_kb.js +12 -1
- package/routes/messagesRoot.js +0 -1
- package/routes/quotes.js +38 -1
- package/routes/request.js +81 -5
- package/routes/users.js +0 -1
- package/routes/webhook.js +160 -8
- package/routes/webhooks.js +276 -6
- package/routes/widgetLoader.js +6 -3
- package/services/QuoteManager.js +77 -16
- package/services/aiService.js +1 -1
- package/services/chatbotService.js +55 -1
- package/services/departmentService.js +60 -43
- package/services/dolphinSchedulerClient.js +116 -0
- package/services/emailService.js +6 -1
- package/services/hitlParticipantListener.js +260 -0
- package/services/participantInviteService.js +302 -0
- package/services/participantRemoveService.js +79 -0
- package/services/quotaSnapshotService.js +1167 -0
- package/services/requestService.js +102 -144
- package/services/scheduledStart/dolphinBackend.js +246 -0
- package/services/scheduledStart/schedulerBackend.js +101 -0
- package/services/scheduledStart/schedulerServiceClient.js +41 -0
- package/services/scheduledStartPublishListener.js +186 -0
- package/services/scheduledStartRules.js +173 -0
- package/services/scheduledStartService.js +130 -0
- package/services/startPointCleanupListener.js +30 -0
- package/services/startPointService.js +158 -0
- package/services/testWsService.js +1 -4
- package/services/updateRequestSnapshotQueued.js +8 -9
- package/services/webhookConversationService.js +185 -0
- package/services/webhookSettingsValidator.js +61 -0
- package/template/email/checkpointReachedEmail.html +5 -0
- package/test/agentPromptsRoute.test.js +154 -0
- package/test/agentTokensQuota.js +237 -0
- package/test/botEventHitlFallback.js +19 -0
- package/test/chat21HandlerJoinWiring.js +59 -0
- package/test/dataTablesRoute.test.js +10 -2
- package/test/dateUtils.test.js +0 -3
- package/test/departmentService.js +8 -12
- package/test/{fileRoute.js → deprecated/_deprecated_fileRoute} +2 -2
- package/test/{kbsettingsRoute.js → deprecated/_deprecated_kbsettingsRoute} +3 -3
- package/test/faqRoute.js +6 -1
- package/test/faqkbRoute.js +14 -10
- package/test/faqkbV3Route.js +1 -1
- package/test/filepRoute.js +4 -50
- package/test/hitlParticipantListener.js +446 -0
- package/test/hitlQueueWiring.js +191 -0
- package/test/hitlWaitingReset.js +124 -0
- package/test/inviteParticipantsRoute.js +492 -0
- package/test/kbRoute.js +1 -1
- package/test/messageRoute.js +33 -21
- package/test/nativemcp.test.js +7 -1
- package/test/openaiRoute.js +2 -8
- package/test/publishFailLoud.test.js +414 -0
- package/test/quotaSnapshots.js +1044 -0
- package/test/removeParticipantsRoute.js +186 -0
- package/test/requestService.js +24 -16
- package/test/requestServiceRemoveParticipant.js +144 -0
- package/test/requestVisibility.test.js +186 -0
- package/test/scheduledStartFacade.js +184 -0
- package/test/scheduledStartHandover.js +95 -0
- package/test/scheduledStartPublish.js +320 -0
- package/test/scheduledStartRoute.js +163 -0
- package/test/scheduledStartRules.js +177 -0
- package/test/scheduledStartRun.js +299 -0
- package/test/scheduledStartSchedulerBackend.js +116 -0
- package/test/scheduledStartService.js +290 -0
- package/test/startPointsCleanup.js +69 -0
- package/test/startPointsRegression.js +169 -0
- package/test/startPointsRoute.js +158 -0
- package/test/webhookConversationRoute.js +347 -0
- package/test/webhookConversationService.js +261 -0
- package/test/webhookConversationTestUtils.js +55 -0
- package/utils/aiUtils.js +95 -1
- package/utils/intentFieldNames.js +192 -0
- package/utils/quotaCliUtil.js +43 -0
- package/utils/requestVisibility.js +355 -0
- package/websocket/webSocketServer.js +36 -31
- /package/test/{imageRoute.js → deprecated/_deprecated_imageRoute} +0 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# HITL participant removal and reassignment — tybot (tiledesk-chatbot) Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** `invite_human` tells the server where to resume when nobody can replace a departed human, a new `remove_human` action releases humans, and replies to a waiting question are no longer swallowed by the block lock (TODO item 3).
|
|
6
|
+
|
|
7
|
+
**Architecture:** `DirInviteHuman` adds `fallback_intent` to its invite body. `DirRemoveHuman` mirrors `DirInviteHuman` (same HTTP, token and error-summary rules) against the server's project-scoped remove endpoint. The server's fallback jump reuses the engine's existing explicit-action path (no engine change). The lock fix backports two small parts of `main_pre`: internal jumps bypass the locked intent, and Capture User Reply stops the flow after locking.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** Node, mocha (from `tybotRoute/` with `../node_modules/.bin/mocha`), in-process tilebot on 10001 + mock Tiledesk API on 10002, Redis `tiledesk-test-redis` on 6379.
|
|
10
|
+
|
|
11
|
+
**Spec:** `tiledesk-server/docs/superpowers/specs/2026-09-15-webhook-chatbot-hitl-design.md` §11.5 (and §6 for the v1 `invite_human`); TODO item 3 in `tiledesk-server/docs/superpowers/todo/2026-09-14-webhook-chatbot-shared-code-fixes.md`.
|
|
12
|
+
|
|
13
|
+
## Global Constraints
|
|
14
|
+
|
|
15
|
+
- Repo `tiledesk-chatbot`, branch `feature/webhook-chatbot-hitl` (already checked out, `origin/main` 2.2.0 merged at `4bdccbb8`). Never commit to `main`, never push.
|
|
16
|
+
- Directive name exactly `remove_human` (`Directives.REMOVE_HUMAN`); action fields `scope` (`'invited' | 'all_humans'`, default `'invited'`), `trueIntent`, `falseIntent`, `trueIntentAttributes`, `falseIntentAttributes`.
|
|
17
|
+
- Variables exactly `removed_humans` (array of `{ id_user, fullname }`) and `removed_humans_count`.
|
|
18
|
+
- flowError texts exactly: `(Remove human) An error occurred: <message>` and `(Remove human) requires a conversation`; the server's fallback text `(Invite human) The invited human left and no replacement is available`.
|
|
19
|
+
- Endpoint: `POST ${API_ENDPOINT}/${projectId}/requests/${requestId}/participants/remove`, JSON body `{ scope }`, header `Authorization: JWT <bot token>` (via `DirInviteHuman.fixToken`), timeout `DirInviteHuman.INVITE_TIMEOUT_MS` (30000).
|
|
20
|
+
- Never log a raw HTTP error: log `JSON.stringify(DirInviteHuman.errorSummary(err))` only.
|
|
21
|
+
- Every jump ends with `callback(true)`; the callback runs exactly once (same guard as `DirInviteHuman.execute`).
|
|
22
|
+
- Run tests from `tybotRoute/` with `API_ENDPOINT=http://localhost:10002 TILEBOT_ENDPOINT=http://localhost:10001 REDIS_HOST=localhost REDIS_PORT=6379 ../node_modules/.bin/mocha <files> --timeout 60000 --exit`. Never `npx`, never `npm install`.
|
|
23
|
+
- Commit messages end with `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`.
|
|
24
|
+
|
|
25
|
+
## Review Focus
|
|
26
|
+
|
|
27
|
+
1. A paused Reply V2 must still accept a button click after the lock fix (existing replyv2 suites stay green).
|
|
28
|
+
2. The server's fallback message arrives from sender `system` with subtype `info`: it must jump to the fallback block, not be treated as an answer to the paused question.
|
|
29
|
+
3. `remove_human` in an automation run (request id not starting with `support-group-`) must not call the server.
|
|
30
|
+
4. `remove_human` with no branches configured must let the block continue (callback without `true`), not stop the flow silently.
|
|
31
|
+
5. The Capture User Reply change must not break blocks where it is the last action (`test/conversation-capture_test.js` stays green).
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## File Structure
|
|
36
|
+
|
|
37
|
+
| File | Status | Responsibility |
|
|
38
|
+
|---|---|---|
|
|
39
|
+
| `tybotRoute/tiledeskChatbotPlugs/directives/DirInviteHuman.js` | Modify | send `fallback_intent` |
|
|
40
|
+
| `tybotRoute/tiledeskChatbotPlugs/directives/DirRemoveHuman.js` | Create | `remove_human` directive |
|
|
41
|
+
| `tybotRoute/tiledeskChatbotPlugs/directives/Directives.js`, `tybotRoute/tiledeskChatbotPlugs/DirectivesChatbotPlug.js` | Modify | register `remove_human` |
|
|
42
|
+
| `tybotRoute/engine/TiledeskChatbot.js` | Modify | internal jumps bypass the locked intent |
|
|
43
|
+
| `tybotRoute/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js` | Modify | stop after locking; guarded lock key |
|
|
44
|
+
| `tybotRoute/test/conversation-invite_human_test.js` | Modify | fallback body + fallback jump |
|
|
45
|
+
| `tybotRoute/test/remove_human_test.js`, `conversation-remove_human_bot.js`, `conversation-remove_human_test.js` | Create | remove tests |
|
|
46
|
+
| `tybotRoute/test/conversation-lock_internal_jump_bot.js`, `conversation-lock_internal_jump_test.js` | Create | lock fix tests |
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
### Task 1: `invite_human` sends its fallback block; the fallback jump lands there
|
|
51
|
+
|
|
52
|
+
**Files:**
|
|
53
|
+
- Modify: `tybotRoute/tiledeskChatbotPlugs/directives/DirInviteHuman.js:88` (the `invite({...})` call)
|
|
54
|
+
- Test: `tybotRoute/test/conversation-invite_human_test.js`
|
|
55
|
+
|
|
56
|
+
**Interfaces:**
|
|
57
|
+
- Produces: invite body `{ department_id, members, fallback_intent }` where `fallback_intent = action.falseIntent` when it is a non-empty string, omitted otherwise.
|
|
58
|
+
|
|
59
|
+
- [ ] **Step 1: Write the failing tests**
|
|
60
|
+
- In the first test (`invites the resolved members and continues in the invited block`), add `assert.strictEqual(req.body.fallback_intent, '#noone-id');` next to the existing body assertions.
|
|
61
|
+
- New test `jumps to the "no human available" block when the server sends the fallback action`: invite answers one invited human; when the `invited 1: restart?` message arrives, send
|
|
62
|
+
`userMessage(REQUEST_ID, 'The invited human left and no replacement is available', { sender: 'system', senderFullname: 'System', attributes: { subtype: 'info', hitl_fallback: true, action: '#noone-id{"flowError":"(Invite human) The invited human left and no replacement is available"}' } })`
|
|
63
|
+
(extend the file's `userMessage` helper to accept `attributes` if it does not already), and expect the next bot message to be `no human available|(Invite human) The invited human left and no replacement is available`.
|
|
64
|
+
- [ ] **Step 2: Run to verify** — `../node_modules/.bin/mocha test/conversation-invite_human_test.js …`: the first test FAILS (`undefined !== '#noone-id'`). The jump test is expected to PASS already (engine explicit-action path); if it FAILS, stop and report the output — the spec assumes no engine change.
|
|
65
|
+
- [ ] **Step 3: Implement** the body field.
|
|
66
|
+
- [ ] **Step 4: Run to verify they pass** — same file, all PASS; plus `test/invite_human_members_test.js` PASS.
|
|
67
|
+
- [ ] **Step 5: Commit** — `feat(invite_human): send the no-human block as the server fallback` (+ trailer).
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
### Task 2: `remove_human` directive
|
|
72
|
+
|
|
73
|
+
**Files:**
|
|
74
|
+
- Create: `tybotRoute/tiledeskChatbotPlugs/directives/DirRemoveHuman.js`
|
|
75
|
+
- Modify: `Directives.js` (`static REMOVE_HUMAN = "remove_human";` next to `INVITE_HUMAN`), `DirectivesChatbotPlug.js` (require + `[Directives.REMOVE_HUMAN]: DirRemoveHuman` next to `:315`)
|
|
76
|
+
- Test: `tybotRoute/test/remove_human_test.js` (unit), `conversation-remove_human_bot.js` + `conversation-remove_human_test.js` (copy the harness of `conversation-invite_human_test.js`: tilebot on 10001, mock API on 10002 with a `remove` handler on `POST /:projectId/requests/:requestId/participants/remove`)
|
|
77
|
+
|
|
78
|
+
**Interfaces:**
|
|
79
|
+
- Consumes: `DirInviteHuman.fixToken`, `DirInviteHuman.errorSummary`, `DirInviteHuman.INVITE_TIMEOUT_MS`; the same constructor context fields as `DirInviteHuman` (projectId, requestId, token, API_ENDPOINT, tdcache, chatbot, logger, intentDir).
|
|
80
|
+
- Produces: `class DirRemoveHuman { constructor(context); execute(directive, callback); go(action, callback); remove(body) → Promise<{ request_id, removed }> ; static normalizeScope(scope) → 'invited' | 'all_humans' }` — `normalizeScope` returns `'all_humans'` only for exactly that string, `'invited'` otherwise.
|
|
81
|
+
- Behaviour: automation request (`requestId` not starting with `support-group-`) → flowError `(Remove human) requires a conversation`, jump `falseIntent` (or `callback()` when absent). Success → set `removed_humans` and `removed_humans_count`, jump `trueIntent` (or `callback()` when absent). HTTP error → flowError `(Remove human) An error occurred: ` + `errorSummary(err).message`, jump `falseIntent` (or `callback()`).
|
|
82
|
+
|
|
83
|
+
- [ ] **Step 1: Write the failing tests**
|
|
84
|
+
- `remove_human_test.js`: `normalizeScope(undefined) === 'invited'`, `normalizeScope('all_humans') === 'all_humans'`, `normalizeScope('ALL') === 'invited'`; a directive with `remove` stubbed to resolve `{ removed: [{ id_user: 'u1', fullname: 'A' }] }` sets `removed_humans_count` 1 and jumps once to `#removed…`; with `remove` rejecting `{ message: 'x', config: { headers: { Authorization: 'JWT SECRET' } }, response: { status: 422, data: { error: 'Remove human requires a conversation started by a webhook' } } }` the logged text never contains `SECRET` and `flowError === '(Remove human) An error occurred: Remove human requires a conversation started by a webhook'`; with no branches the callback is called once with `undefined`.
|
|
85
|
+
- Fixture blocks: `remove` (action `remove_human`, `scope: 'all_humans'`, `trueIntent: '#removed-id'`, `falseIntent: '#rmerror-id'`), `removed` (reply `removed {{removed_humans_count}}`), `rmerror` (reply `remove error|{{flowError}}`).
|
|
86
|
+
- Conversation tests: `removes the humans and continues in the removed block` (mock asserts `req.body.scope === 'all_humans'` and the `Authorization` header starts with `JWT `, answers two removed → `removed 2`); `goes to the error block with the server reason` (422 → `remove error|(Remove human) An error occurred: <server error>`); `does not call the server for automation runs` (request id `automation-request-…` → `remove error|(Remove human) requires a conversation`, mock `remove` handler never hit).
|
|
87
|
+
- [ ] **Step 2: Run to verify they fail** — module not found / no directive.
|
|
88
|
+
- [ ] **Step 3: Implement and register.**
|
|
89
|
+
- [ ] **Step 4: Run to verify they pass** — the three new files PASS; `test/conversation-invite_human_test.js` and `test/invite_human_members_test.js` PASS.
|
|
90
|
+
- [ ] **Step 5: Commit** — `feat(directives): add remove_human to release humans from the conversation` (+ trailer).
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
### Task 3: Replies are not swallowed by the block lock (TODO item 3)
|
|
95
|
+
|
|
96
|
+
**Files:**
|
|
97
|
+
- Modify: `tybotRoute/engine/TiledeskChatbot.js` (the `if (locked_intent) {` check after `currentLockedIntent`)
|
|
98
|
+
- Modify: `tybotRoute/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js`
|
|
99
|
+
- Test: `tybotRoute/test/conversation-lock_internal_jump_bot.js`, `conversation-lock_internal_jump_test.js` (capture-test harness)
|
|
100
|
+
|
|
101
|
+
**Interfaces:**
|
|
102
|
+
- Produces: `TiledeskChatbot` treats the locked intent only for messages whose `sender !== '_tdinternal'`.
|
|
103
|
+
- Produces: `DirCaptureUserReply` — after locking it calls `callback(true)` (stops the block); `execute` passes the stop flag through (`this.go(action, (stop) => callback(stop))`); the lock key comes from a private resolver trying, in order, `reply.attributes.intent_info.intent_id` (as `'#' + id`), `reply.attributes.intent_info.intent_name`, `reply.intent_id` (as `'#' + id`), `reply.intent_display_name`; no key → log an error and `callback()` without locking. Port these from `origin/main_pre:tybotRoute/tiledeskChatbotPlugs/directives/DirCaptureUserReply.js` (only these parts; leave the rest of `main_pre` out).
|
|
104
|
+
|
|
105
|
+
- [ ] **Step 1: Write the failing tests** — fixture:
|
|
106
|
+
- `ask` block: reply `question?`, then `capture_user_reply` (`goToIntent: '#answered-id'`, `assignResultTo: 'answer'`), then reply `must not run`.
|
|
107
|
+
- `answered` block: reply `answer: {{answer}}`.
|
|
108
|
+
- `locked_jump` block: reply `waiting`, `capture_user_reply` (`goToIntent: '#answered-id'`, `assignResultTo: 'answer'`), then an `intent` action to `#other-id`.
|
|
109
|
+
- `other` block: reply `other ran`.
|
|
110
|
+
Tests: `stops the block after Capture User Reply` — send `/ask`: messages seen are `question?` then, after sending `yes` as the user, `answer: yes`; `must not run` never arrives. `does not treat an internal jump as the reply` — send `/locked_jump`: `waiting` then no `other ran` before the user replies (Capture stops the block), and after the user sends `ok` → `answer: ok`. Add a direct engine test: with the conversation locked on `ask`, a `_tdinternal` message `/other` produces `other ran` and leaves the lock in place (the next user text `yes` → `answer: yes`).
|
|
111
|
+
- [ ] **Step 2: Run to verify they fail** — `must not run` arrives / `/other` is captured as the answer.
|
|
112
|
+
- [ ] **Step 3: Implement** both changes.
|
|
113
|
+
- [ ] **Step 4: Run to verify they pass** — new file PASS; regression: `test/conversation-capture_test.js test/conversation-locked-intent-test.js test/conversation-replyv2_button_match_test.js test/conversation-replyv2_noinput_test.js test/conversation-invite_human_test.js test/conversation-remove_human_test.js` all PASS.
|
|
114
|
+
- [ ] **Step 5: Commit** — `fix(engine): internal jumps skip the locked intent; Capture User Reply stops the block` (+ trailer); then update TODO item 3 in `tiledesk-server/docs/superpowers/todo/2026-09-14-webhook-chatbot-shared-code-fixes.md` with "Done on tiledesk-chatbot feature/webhook-chatbot-hitl <sha>" and commit it in tiledesk-server with `docs(todo): …` (+ trailer).
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
### Task 4: Suite comparison
|
|
119
|
+
|
|
120
|
+
- [ ] **Step 1:** Run the whole suite from `tybotRoute/` on the branch head and on `origin/main` (temporary worktree with `node_modules` symlinked, removed afterwards); compare failing test titles.
|
|
121
|
+
- [ ] **Step 2:** Expected: no title fails only on the branch, apart from tests failing on the known port-10002 `EADDRINUSE` cascade that pass when their file is run alone (verify each such file alone). Report the counts.
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# HITL feature — pre-branch ports Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** In each of the four repos, build a local `feature/webhook-chatbot-hitl-PRE` branch from the pre branch that carries the whole webhook-chatbot HITL feature, tested there.
|
|
6
|
+
|
|
7
|
+
**Architecture:** One repo at a time, in the existing checkout (no new worktrees — limited disk). Create the branch from the pre branch, reinstall dependencies in place from its lockfile, cherry-pick every non-merge feature commit, resolve conflicts keeping pre-branch behaviour, test against the pre branch, then switch back and restore the feature branch's dependencies.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** git cherry-pick; npm ci; mocha (server, tybot); Angular/Karma + `ng build` (chat21-ionic Node 14, design-studio Node 16).
|
|
10
|
+
|
|
11
|
+
**Spec:** `docs/superpowers/specs/2026-09-15-webhook-chatbot-hitl-design.md` §12.1 decisions 2–3, §12.4, §12.5.
|
|
12
|
+
|
|
13
|
+
## Global Constraints
|
|
14
|
+
|
|
15
|
+
- Runs AFTER `2026-09-29-hitl-known-limits-server.md` and `2026-09-29-hitl-known-limits-tybot.md` are complete (their commits are part of the port).
|
|
16
|
+
- Pre branches exactly: tiledesk-server `origin/master-COLLAUDO`, tiledesk-chatbot `origin/main_pre`, chat21-ionic `origin/master-PRE`, design-studio `origin/master-pre`. `git fetch origin` first.
|
|
17
|
+
- New branch name exactly `feature/webhook-chatbot-hitl-PRE`, upstream unset. Never push, never merge.
|
|
18
|
+
- Commits to port: `git rev-list --reverse --no-merges origin/<default>..feature/webhook-chatbot-hitl` (defaults: server `master`, tybot `main`, chat21-ionic `master`, design-studio `master`), cherry-picked in that order with `git cherry-pick -x`.
|
|
19
|
+
- Conflict rule: keep the pre branch's code and add the feature's change; never delete pre-branch behaviour to make the change fit. Every resolution goes in the task report (file, what each side had, what was kept).
|
|
20
|
+
- No new git worktrees except a temporary one for a comparison run that has no `node_modules` of its own (symlinked) — and only with `df -h` showing > 2 GB free. Build outputs (`www/`, `dist/`) deleted after the build check.
|
|
21
|
+
- Dependencies: install in place from the checked-out lockfile — server `npm ci`; tybot `npm ci` at the repo root; chat21-ionic `source ~/.nvm/nvm.sh >/dev/null && nvm use 14 >/dev/null && npm ci --ignore-scripts`; design-studio `… nvm use 16 … npm ci`. Before each install check `df -h` shows > 5 GB free; if not, stop and report.
|
|
22
|
+
- End state per repo: back on `feature/webhook-chatbot-hitl`, dependencies reinstalled from its lockfile, `git status` clean (apart from pre-existing untracked files), and the controller notified that the checkout is usable again.
|
|
23
|
+
- Conflict-resolution commits keep the cherry-picked commit's message (git's default) — the `(cherry picked from commit …)` line from `-x` plus the original `Co-Authored-By` trailer; an extra fix commit, if needed, ends with `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>` after a blank line.
|
|
24
|
+
|
|
25
|
+
## Review Focus
|
|
26
|
+
|
|
27
|
+
1. A cherry-pick that applies cleanly but references code the pre branch renamed or removed → caught only by tests/build; the build and feature suites must run after the last pick, not just "no conflicts".
|
|
28
|
+
2. tybot `main_pre` internal jumps go through `/exec`: the lock fix and lock-ownership tests must pass there, or the adaptation must be recorded.
|
|
29
|
+
3. Server `master-COLLAUDO` has different routes/middleware (`routes/request.js`, `middleware/has-role.js`): the invite/remove routes must keep project scoping and role checks.
|
|
30
|
+
4. A pre branch that already contains an equivalent change → `git cherry-pick` reports an empty commit; skip it with `--skip` and record it.
|
|
31
|
+
5. Restoring the feature branch's dependencies after the port — the feature branch's own test must pass again before handing the checkout back.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
### Task 1: tiledesk-server → `master-COLLAUDO`
|
|
36
|
+
|
|
37
|
+
**Files:** all files touched by the ported commits.
|
|
38
|
+
|
|
39
|
+
- [ ] **Step 1:** Branch from `origin/master-COLLAUDO`; `npm ci`.
|
|
40
|
+
- [ ] **Step 2:** Cherry-pick the commit list; resolve conflicts per the rule; record each.
|
|
41
|
+
- [ ] **Step 3:** Feature suites: `./node_modules/.bin/mocha test/webhookRoute.js test/webhookConversationRoute.js test/webhookConversationService.js test/inviteParticipantsRoute.js test/removeParticipantsRoute.js test/hitlWaitingReset.js test/hitlParticipantListener.js test/botEventHitlFallback.js test/requestServiceRemoveParticipant.js --timeout 60000 --exit` → all pass (MongoDB/Redis test containers running).
|
|
42
|
+
- [ ] **Step 4:** Full-suite comparison: `npm test` on the `-PRE` head, then on `origin/master-COLLAUDO` (detached checkout in the same directory — lockfile identical, no reinstall; return to the `-PRE` branch afterwards). Compare failing titles: none failing only on `-PRE`; branch-only titles re-run alone on both sides.
|
|
43
|
+
- [ ] **Step 5:** Switch back to `feature/webhook-chatbot-hitl`, `npm ci`, run `test/hitlParticipantListener.js` once → passes. Report.
|
|
44
|
+
|
|
45
|
+
### Task 2: tiledesk-chatbot → `main_pre`
|
|
46
|
+
|
|
47
|
+
- [ ] **Step 1:** Branch from `origin/main_pre`; `npm ci` at the repo root.
|
|
48
|
+
- [ ] **Step 2:** Cherry-pick the list; resolve conflicts (known: `tybotRoute/engine/TiledeskChatbot.js`, `tiledeskChatbotPlugs/directives/Directives.js`, `utils/HttpUtils.js`).
|
|
49
|
+
- [ ] **Step 3:** Feature suites from `tybotRoute/`, each file alone: `invite_human_members_test.js`, `remove_human_test.js`, `http_utils_test.js`, `capture_user_reply_test.js`, `conversation-invite_human_test.js`, `conversation-remove_human_test.js`, `conversation-lock_internal_jump_test.js`, `conversation-lock_ownership_test.js`, `conversation-capture_test.js`, `conversation-replyv2_button_match_test.js`, `conversation-replyv2_noinput_test.js`. If a lock test fails because internal jumps use `/exec` on this branch, adapt the fix (not the test's intent) in a separate commit and record why.
|
|
50
|
+
- [ ] **Step 4:** Full-suite comparison with `origin/main_pre` (detached in the same directory; no reinstall — same lockfile); failing-title diff; port-10002 cascades verified file by file.
|
|
51
|
+
- [ ] **Step 5:** Switch back, `npm ci`, run `test/conversation-invite_human_test.js` once → passes. Report.
|
|
52
|
+
|
|
53
|
+
### Task 3: chat21-ionic → `master-PRE`
|
|
54
|
+
|
|
55
|
+
- [ ] **Step 1:** Branch from `origin/master-PRE`; Node 14 `npm ci --ignore-scripts`.
|
|
56
|
+
- [ ] **Step 2:** Cherry-pick the list; resolve conflicts (known candidates: `src/app/app.component.ts`, `src/app/services/websocket/websocket.service.ts`, `package.json`/lock/CHANGELOG from version bumps — keep the pre branch's versions).
|
|
57
|
+
- [ ] **Step 3:** Specs with the workspace harness `.superpowers/sdd/2026-09-29-hitl-participant-removal-chat21-ionic/tsconfig.leave-specs.json` (same command as that plan's Ruling 1) → `TOTAL: 15 SUCCESS`; `npx ng build` → exit 0; compare its warnings with a build of `origin/master-PRE` (same directory, detached) — no new warnings; delete `www/`.
|
|
58
|
+
- [ ] **Step 4:** Switch back, Node 14 `npm ci --ignore-scripts`, run the spec command once → 15 SUCCESS. Report.
|
|
59
|
+
|
|
60
|
+
### Task 4: design-studio → `master-pre`
|
|
61
|
+
|
|
62
|
+
- [ ] **Step 1:** Branch from `origin/master-pre`; Node 16 `npm ci`.
|
|
63
|
+
- [ ] **Step 2:** Cherry-pick the list; resolve conflicts (known: `cds-canvas.component.ts`, `cds-intent.component.{ts,html}`, `cds-header.component.ts`, `intent.service.ts`, `utils-actions.ts`). `master-pre` may have new actions/enum entries next to ours — keep both.
|
|
64
|
+
- [ ] **Step 3:** Specs with `.superpowers/sdd/2026-09-29-hitl-participant-removal-design-studio/test-hitl.ts` + `tsconfig.hitl-specs.json` → `TOTAL: 13 SUCCESS`; `npx ng build` → exit 0; warnings compared with a build of `origin/master-pre` — no new ones; delete `dist/`.
|
|
65
|
+
- [ ] **Step 4:** Switch back, Node 16 `npm ci`, run the spec command once → 13 SUCCESS. Report.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Flow start points — design-studio Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** A "Start points" palette section to drop a Webhook start box on the canvas, a webhook box panel, and the `start` box labelled "Web start", replacing the "Start from webhook" toggle of the `start` panel.
|
|
6
|
+
|
|
7
|
+
**Architecture:** `WebhookService` gains start-point calls matching the server routes; a pure `utils-start-points.ts` holds the type list and the "one per type" rule; the palette gets a new category whose items create a marker block (`attributes.start_point`) instead of an action; the intent component renders marker blocks as start boxes; a start-point panel replaces the webhook section of the start panel.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** Angular 14, Node 16 (nvm), Jasmine/Karma via the workspace harness.
|
|
10
|
+
|
|
11
|
+
**Spec:** `tiledesk-server/docs/superpowers/specs/2026-09-30-flow-start-points-design.md` (§6, §8).
|
|
12
|
+
|
|
13
|
+
## Global Constraints
|
|
14
|
+
|
|
15
|
+
- Repo `/Users/nicocardone/Desktop/DEV/TILEDESK/design-studio`, branch `feature/webhook-chatbot-hitl`. Never push. Commit trailer: blank line + `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`.
|
|
16
|
+
- Node 16 prefix for every npm/npx: `source ~/.nvm/nvm.sh >/dev/null && nvm use 16 >/dev/null && `. Never npm install/ci.
|
|
17
|
+
- Server API (tiledesk-server plan): `PUT {API}/{projectId}/webhooks/{chatbot_id}/start_points/{type}` body `{block_id, enabled?, mapping?:{source_name?}, confirm?}`; `DELETE` same path; 409 = automation webhook exists (confirm needed); `GET {API}/{projectId}/webhooks/{chatbot_id}` returns `start_points`.
|
|
18
|
+
- Start point types in UI: `web` (implicit = the `start` block, never sent to the server) and `webhook`. Block marker `attributes.start_point = 'webhook'`; default block name `"Webhook start"`; identify start boxes by the marker, never by name.
|
|
19
|
+
- Palette category key `START_POINTS`, label key `CDSActionCategory.StartPoints` = "Start points"; shown only for chatbot subtype `chatbot`.
|
|
20
|
+
- One per type: an item whose type is present is disabled with tooltip "Already in this flow"; click focuses the box.
|
|
21
|
+
- Automation-webhook confirmation text (reuse existing i18n key of `needsSwitchConfirmation`): "This chatbot already has a webhook that runs a block without a conversation. Switching it will make calls start conversations from the start block. Continue?" → retry with `confirm: true`.
|
|
22
|
+
- Change department help (en.json `CDSActionList.DOC.ChangeDept` description) gains: "In conversations started by a webhook, changing department re-routes the conversation and removes the chatbot."
|
|
23
|
+
- Remove from the `start` panel the "Start from webhook" section and its code (`createStartWebhook`, `updateWebhookSettings`, `utils-webhook.ts` toggle helpers and their specs) — replaced, not kept.
|
|
24
|
+
- Specs run with the workspace harness: `npx ng test --watch=false --browsers=ChromeHeadless --main=.superpowers/sdd/2026-09-29-hitl-participant-removal-design-studio/test-hitl.ts --ts-config=.superpowers/sdd/2026-09-29-hitl-participant-removal-design-studio/tsconfig.hitl-specs.json` (untracked harness; register new specs there, don't commit it). `npx ng build` must exit 0 with no new warnings; delete `dist/`.
|
|
25
|
+
- A live `ng serve --port 4204` of this checkout may be running; don't kill it.
|
|
26
|
+
|
|
27
|
+
## Review Focus
|
|
28
|
+
|
|
29
|
+
1. Dropping Webhook start twice quickly → one box, one start point (disable the item while the create is pending).
|
|
30
|
+
2. PUT fails after the block was created → the block is deleted again and an error toast shown (no orphan box).
|
|
31
|
+
3. Chatbot subtype `webhook`/`copilot` → no "Start points" category; their `webhook` block unchanged.
|
|
32
|
+
4. Reloading a flow whose webhook has a start point whose block is missing → the palette item is enabled again (start point treated as absent).
|
|
33
|
+
5. Published/read-only mode (`readOnlyService` if present on the branch) → palette items disabled, panel read-only.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### Task 1: start-point service calls and type rules
|
|
38
|
+
|
|
39
|
+
**Files:**
|
|
40
|
+
- Modify: `src/app/chatbot-design-studio/services/webhook-service.service.ts` (add methods; remove `createStartWebhook`, `updateWebhookSettings`)
|
|
41
|
+
- Create: `src/app/chatbot-design-studio/utils-start-points.ts`
|
|
42
|
+
- Replace: `src/app/chatbot-design-studio/utils-webhook.ts` toggle helpers (delete the file and its spec if nothing else uses them)
|
|
43
|
+
- Test: `webhook-service.service.spec.ts`, `utils-start-points.spec.ts`
|
|
44
|
+
|
|
45
|
+
**Interfaces:**
|
|
46
|
+
- Produces `WebhookService.upsertStartPoint(chatbot_id: string, type: 'webhook', body: { block_id: string, enabled?: boolean, mapping?: { source_name?: string }, confirm?: boolean }): Observable<any>` and `deleteStartPoint(chatbot_id: string, type: 'webhook'): Observable<any>`.
|
|
47
|
+
- Produces in `utils-start-points.ts`: `START_POINT_TYPES = ['web','webhook']`, `START_POINT_MARKER = 'start_point'`, `startPointTypeOf(intent): 'web' | 'webhook' | null` (`web` for the block named `start`, marker value otherwise), `presentStartPointTypes(intents, webhook): string[]` (web always; webhook only when the webhook has a `webhook` start point whose `block_id` is an existing intent carrying the marker).
|
|
48
|
+
|
|
49
|
+
- [ ] **Step 1: Failing specs:** HttpTestingController asserts PUT/DELETE URLs and bodies (`{block_id:'b1', enabled:true}` → `PUT https://api.test/p1/webhooks/bot1/start_points/webhook`); `presentStartPointTypes` cases: no webhook → `['web']`; start point + marker block → `['web','webhook']`; start point whose block is missing → `['web']` (Review Focus 4).
|
|
50
|
+
- [ ] **Step 2: Run** the harness → compile errors for the missing members.
|
|
51
|
+
- [ ] **Step 3: Implement**; remove the old toggle helpers and the `start` panel webhook section together with its template/i18n usage.
|
|
52
|
+
- [ ] **Step 4: Run** the harness → pass; report TOTAL.
|
|
53
|
+
- [ ] **Step 5: Commit** — `feat(start-points): service calls and start point rules`.
|
|
54
|
+
|
|
55
|
+
### Task 2: "Start points" palette section
|
|
56
|
+
|
|
57
|
+
**Files:**
|
|
58
|
+
- Modify: `src/app/chatbot-design-studio/utils-actions.ts` (`TYPE_ACTION_CATEGORY.START_POINTS = 'Start points'`, `ACTION_CATEGORY` entry, icon `assets/images/actions_category/start_points.svg` new)
|
|
59
|
+
- Modify: `cds-dashboard/cds-canvas/cds-panel-elements/cds-panel-elements.component.{ts,html}` (category items come from start point types, not `ACTIONS_LIST`; disabled state; hidden unless subtype `chatbot`)
|
|
60
|
+
- Modify: `cds-dashboard/cds-canvas/cds-canvas.component.ts` (drop of a start-point item → create marker block at the drop position, then `upsertStartPoint`; 409 → confirmation → retry with `confirm:true`; failure → delete the block, toast)
|
|
61
|
+
- Modify: `src/assets/i18n/en.json`
|
|
62
|
+
- Test: `cds-panel-elements.component.spec.ts` (harness), plus a pure helper spec if the drop logic is extracted (`createStartPointBox(...)` in `utils-start-points.ts` recommended)
|
|
63
|
+
|
|
64
|
+
**Interfaces:**
|
|
65
|
+
- Consumes Task 1 methods and helpers.
|
|
66
|
+
- Produces `createStartPointBlock(type: 'webhook', pos: {x:number,y:number}): Intent` — name "Webhook start", `attributes.start_point = type`, `attributes.position = pos`, `attributes.readonly = true`, actions `[ { _tdActionType: 'intent', intentName: '' } ]` like the `start` block.
|
|
67
|
+
|
|
68
|
+
- [ ] **Step 1: Failing specs:** category hidden for subtype `webhook`; items `Web` (always disabled, focus action) and `Webhook` (enabled when absent, disabled with tooltip "Already in this flow" when present, disabled while a create is pending — Review Focus 1); `createStartPointBlock` output as above.
|
|
69
|
+
- [ ] **Step 2: Run** → fail.
|
|
70
|
+
- [ ] **Step 3: Implement.**
|
|
71
|
+
- [ ] **Step 4: Run** harness → pass.
|
|
72
|
+
- [ ] **Step 5: Commit** — `feat(start-points): palette section to add a webhook start box`.
|
|
73
|
+
|
|
74
|
+
### Task 3: start boxes and the webhook box panel
|
|
75
|
+
|
|
76
|
+
**Files:**
|
|
77
|
+
- Modify: `cds-dashboard/cds-canvas/cds-intent/cds-intent.component.{ts,html}` (`isStart` also true for marker blocks; label "Web start" for `start`, "Webhook start" + webhook icon for the marker; no add-action, no "Start test from here" on start boxes)
|
|
78
|
+
- Modify: `cds-dashboard/cds-canvas/cds-panel-intent-detail/cds-panel-intent-detail.component.{ts,html}` (webhook box panel: enabled switch → `upsertStartPoint({block_id, enabled})`; production/dev URL with copy/regenerate (existing methods); Source name → `mapping.source_name` on change; Test webhook start button (existing controller subject); hint text; Delete button → confirm → `deleteStartPoint` → delete block)
|
|
79
|
+
- Modify: `cds-dashboard/cds-header/cds-header.component.ts` (Test webhook start highlights the webhook box by marker instead of `start`)
|
|
80
|
+
- Modify: `src/assets/i18n/en.json` (labels, hint, Change department help line from Global Constraints)
|
|
81
|
+
- Test: `cds-panel-intent-detail` pure logic extracted to `utils-start-points.ts` where possible (`startPointPanelState(webhook, intent)` → `{enabled, sourceName, url, devUrl}`) with specs
|
|
82
|
+
|
|
83
|
+
- [ ] **Step 1: Failing specs:** `startPointPanelState` for enabled/disabled/absent; start box detection by marker (renamed block still detected; a user block named "Webhook start" without marker is not).
|
|
84
|
+
- [ ] **Step 2: Run** → fail.
|
|
85
|
+
- [ ] **Step 3: Implement.**
|
|
86
|
+
- [ ] **Step 4: Run** harness → pass; `npx ng build` → exit 0, no new warnings; delete `dist/`.
|
|
87
|
+
- [ ] **Step 5: Manual check** on the local stack (record as pending if not running): drag Webhook start, copy URL, curl → conversation runs the box; disable → 422; delete box → palette item enabled again.
|
|
88
|
+
- [ ] **Step 6: Commit** — `feat(start-points): start boxes and webhook start panel`.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Flow start points — tiledesk-server Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** Conversation webhooks carry `start_points`; a webhook call starts the flow at the webhook start box, with no change for widget starts and automation webhooks.
|
|
6
|
+
|
|
7
|
+
**Architecture:** `start_points` lives on the existing per-chatbot webhook record, managed by two new admin routes and a small service. The public conversation path looks up the `webhook` start point, resolves the department from the chatbot, and sends the system `/start` with `attributes.action = '#<block_id>'`. A `faq.delete` listener removes start points whose box is deleted.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** Node/Express, Mongoose, mocha + chai-http (test MongoDB + Redis).
|
|
10
|
+
|
|
11
|
+
**Spec:** `docs/superpowers/specs/2026-09-30-flow-start-points-design.md` (§4, §8, §9).
|
|
12
|
+
|
|
13
|
+
## Global Constraints
|
|
14
|
+
|
|
15
|
+
- Branch `feature/webhook-chatbot-hitl` (checked out). Never push, never commit to master. Commit messages end with a blank line + `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`.
|
|
16
|
+
- Start point types: enum exactly `['webhook']` in this plan (`'web'` is implicit, never stored). At most one entry per type, enforced by the service (400), not by an index.
|
|
17
|
+
- Start point shape: `{ type, block_id, enabled (default true), mapping: { source_name } }`.
|
|
18
|
+
- Webhook stays unique per chatbot; the automation path (no `mode`) is untouched: `block_id`, `webhookService.run`, `/block` sync/async.
|
|
19
|
+
- Remove `department_id` and `source_name` from the conversation webhook (model, validator, routes); no migration.
|
|
20
|
+
- Start text stays `/start`; the box is selected with `attributes.action = '#' + block_id`.
|
|
21
|
+
- Department of a webhook conversation: the project's default department if its `id_bot` is this chatbot; else the oldest department (by `createdAt`) whose `id_bot` is this chatbot; else the project default department.
|
|
22
|
+
- Error bodies `{ success: false, error: <message> }`; 422 message for a missing/disabled start point exactly `"Webhook start is not enabled"`.
|
|
23
|
+
- All new routes project-scoped under the existing `routes/webhooks.js` mount (admin role).
|
|
24
|
+
- Tests: `NODE_ENV=test` DB (`tiledesk-test`); run with `./node_modules/.bin/mocha <files> --timeout 60000 --exit`. If a local RabbitMQ that rejects guest is running on 5672 (container `td-e2e-rabbitmq`), stop it for the run and restart it after.
|
|
25
|
+
|
|
26
|
+
## Review Focus
|
|
27
|
+
|
|
28
|
+
1. A chatbot whose webhook has no `start_points` yet but `mode: 'conversation'` (created by the old toggle on this branch) → calls answer 422 "Webhook start is not enabled", never 500.
|
|
29
|
+
2. `PUT …/start_points/webhook` on a chatbot with an automation webhook (no mode) without `confirm` → 409, and the automation webhook still runs its block afterwards.
|
|
30
|
+
3. `block_id` of another chatbot, or a random string → 404, nothing saved.
|
|
31
|
+
4. Deleting the start box by `intentId…` and by `_id` (both DELETE forms in `routes/faq.js:492-535`) → start point removed.
|
|
32
|
+
5. Widget `/start` launch of the same chatbot → unchanged (no `attributes.action`, no `start_type`).
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
### Task 1: start_points model, service and admin API
|
|
37
|
+
|
|
38
|
+
**Files:**
|
|
39
|
+
- Modify: `models/webhook.js` (add `start_points` subdocument array; remove `department_id`, `source_name`)
|
|
40
|
+
- Create: `services/startPointService.js`
|
|
41
|
+
- Modify: `services/webhookSettingsValidator.js` (drop department_id/source_name handling)
|
|
42
|
+
- Modify: `routes/webhooks.js` (two routes; GET already returns the document)
|
|
43
|
+
- Test: `test/startPointsRoute.js`; update existing tests that use `department_id`/`source_name` (`test/webhookRoute.js`, `test/webhookConversationRoute.js`, `test/webhookConversationService.js`, `test/webhookConversationTestUtils.js`)
|
|
44
|
+
|
|
45
|
+
**Interfaces:**
|
|
46
|
+
- Produces `startPointService.TYPES = ['webhook']`.
|
|
47
|
+
- Produces `startPointService.upsert(id_project, chatbot, type, body) → Promise<webhook>`; body `{ block_id, enabled?, mapping?: { source_name? }, confirm? }`. Throws `StartPointError(status, message)` for 400/404/409.
|
|
48
|
+
- Produces `startPointService.remove(id_project, chatbot_id, type) → Promise<webhook>` (404 when absent).
|
|
49
|
+
- Produces `startPointService.find(webhook, type) → startPoint | undefined`.
|
|
50
|
+
- Routes: `PUT /:projectid/webhooks/:chatbot_id/start_points/:type`, `DELETE /:projectid/webhooks/:chatbot_id/start_points/:type`, both answer the updated webhook.
|
|
51
|
+
|
|
52
|
+
- [ ] **Step 1: Write the failing tests** in `test/startPointsRoute.js`:
|
|
53
|
+
- PUT on a chatbot (subtype `chatbot`) without webhook → 200; webhook created with `mode: 'conversation'`, `start_points: [{type:'webhook', block_id:<start box intent_id>, enabled:true, mapping:{source_name:'Grafana'}}]`.
|
|
54
|
+
- PUT again with `enabled:false` → same single entry updated (length 1).
|
|
55
|
+
- PUT `type: 'scheduled'` → 400; chatbot subtype `webhook` → 400; `block_id` of another chatbot → 404; `block_id: 'nope'` → 404.
|
|
56
|
+
- Existing webhook without mode: PUT → 409, webhook unchanged; PUT with `confirm: true` → 200, `mode: 'conversation'`, automation `block_id` kept.
|
|
57
|
+
- DELETE → 200, `start_points` empty; DELETE again → 404.
|
|
58
|
+
- Agent-role user → 403 (admin only); other project's chatbot → 404.
|
|
59
|
+
- [ ] **Step 2: Run to verify they fail** — `./node_modules/.bin/mocha test/startPointsRoute.js --timeout 60000 --exit` → 404s on the new routes.
|
|
60
|
+
- [ ] **Step 3: Implement** model field, `startPointService`, routes; remove `department_id`/`source_name` from model and validator, and adapt the existing tests that set them (drop those assertions; department cases move to Task 2).
|
|
61
|
+
- [ ] **Step 4: Run** `./node_modules/.bin/mocha test/startPointsRoute.js test/webhookRoute.js test/webhookConversationRoute.js test/webhookConversationService.js --timeout 60000 --exit` → all pass.
|
|
62
|
+
- [ ] **Step 5: Commit** — `feat(webhooks): start points on conversation webhooks`.
|
|
63
|
+
|
|
64
|
+
### Task 2: webhook call starts at the start box
|
|
65
|
+
|
|
66
|
+
**Files:**
|
|
67
|
+
- Modify: `routes/webhook.js` (`router.all('/:webhook_id')` ~311 and `/:webhook_id/dev` ~368: after `checkEnabledAndRateLimit`, conversation mode requires the enabled `webhook` start point)
|
|
68
|
+
- Modify: `services/webhookConversationService.js` (`start()`: department rule, lead name from mapping, `/start` with action)
|
|
69
|
+
- Test: `test/webhookConversationRoute.js`, `test/webhookConversationService.js`
|
|
70
|
+
|
|
71
|
+
**Interfaces:**
|
|
72
|
+
- Consumes Task 1 `startPointService.find(webhook, 'webhook')`.
|
|
73
|
+
- Produces `webhookConversationService.resolveChatbotDepartment(id_project, chatbot_id) → Promise<department>` (rule in Global Constraints).
|
|
74
|
+
- `start(webhook, chatbot, payload, options)` now reads `startPoint = find(webhook,'webhook')`; lead fullname `startPoint.mapping.source_name || webhook.name || 'Webhook'`; sends `messageService.send('system','Bot',request_id,'/start',id_project,null,{subtype:'info',updateconversation:false, action:'#'+startPoint.block_id})`.
|
|
75
|
+
|
|
76
|
+
- [ ] **Step 1: Write the failing tests:**
|
|
77
|
+
- Conversation webhook with enabled start point → 202; the system message stored for the request has text `/start` and `attributes.action === '#<block_id>'`; request `attributes.start_type === 'webhook'`.
|
|
78
|
+
- Lead fullname = `mapping.source_name`; empty mapping → webhook name.
|
|
79
|
+
- Department: bot attached to a non-default department → that department; attached to the default department and another → default; not attached → project default.
|
|
80
|
+
- `mode:'conversation'` with no start points → 422 `"Webhook start is not enabled"`; start point `enabled:false` → same 422; `/dev` preloaded run with disabled start point → 422.
|
|
81
|
+
- Automation webhook (no mode) → still calls tybot `/block` (existing webhookRoute tests stay green).
|
|
82
|
+
- [ ] **Step 2: Run to verify they fail** (`test/webhookConversationRoute.js test/webhookConversationService.js`).
|
|
83
|
+
- [ ] **Step 3: Implement.**
|
|
84
|
+
- [ ] **Step 4: Run** the two files plus `test/webhookRoute.js test/inviteParticipantsRoute.js test/hitlParticipantListener.js` → all pass.
|
|
85
|
+
- [ ] **Step 5: Commit** — `feat(webhook): conversation webhooks start at the webhook start box`.
|
|
86
|
+
|
|
87
|
+
### Task 3: box deletion cleanup and regression
|
|
88
|
+
|
|
89
|
+
**Files:**
|
|
90
|
+
- Create: `services/startPointCleanupListener.js` (listens to `faqBotEvent` `faq.delete`; `$pull` start points whose `block_id` equals the deleted faq's `intent_id` for that chatbot)
|
|
91
|
+
- Modify: `app.js` (wire the listener next to the HITL listener)
|
|
92
|
+
- Test: `test/startPointsCleanup.js`; `test/startPointsRegression.js`
|
|
93
|
+
|
|
94
|
+
**Interfaces:**
|
|
95
|
+
- Consumes the faq document emitted by `routes/faq.js` (`id_faq_kb`, `intent_id`, `id_project`).
|
|
96
|
+
|
|
97
|
+
- [ ] **Step 1: Write the failing tests:**
|
|
98
|
+
- `startPointsCleanup`: DELETE the box via `/:projectid/faq/intentId<intent_id>?id_faq_kb=<bot>` → start point removed; via `/:projectid/faq/<_id>` → removed; deleting another block → start point kept.
|
|
99
|
+
- `startPointsRegression`: automation webhook sync (`async:false`) answers the stubbed tybot response; async → 200; a chatbot published via `PUT /:projectid/faq_kb/:id/publish` keeps its start point `block_id` resolvable in the published copy (faq with same `intent_id` exists under the published bot); widget-like start (`rulesTrigger` bot launch) sends `/start` without `attributes.action`.
|
|
100
|
+
- [ ] **Step 2: Run to verify** the cleanup tests fail and the regression tests pass on the current code (they pin behaviour).
|
|
101
|
+
- [ ] **Step 3: Implement** the listener and wiring.
|
|
102
|
+
- [ ] **Step 4: Run** `./node_modules/.bin/mocha test/startPointsCleanup.js test/startPointsRegression.js test/startPointsRoute.js test/webhookConversationRoute.js test/webhookRoute.js --timeout 60000 --exit` → all pass.
|
|
103
|
+
- [ ] **Step 5: Commit** — `feat(webhooks): remove a start point when its box is deleted`.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Flow start points — tybot Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** Flows can read `start_type`, and a `/start` pointing to a missing start box falls back to the `start` block.
|
|
6
|
+
|
|
7
|
+
**Architecture:** Two small changes in the tybot engine: `TiledeskChatbotUtil.updateRequestAttributes` adds the `start_type` variable from request attributes; the explicit-intent branch of `TiledeskChatbot` retries with the `start` intent when an action from a `/start` message resolves to nothing.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** Node, mocha (in-process tilebot on 10001 + mock Tiledesk API on 10002, Redis).
|
|
10
|
+
|
|
11
|
+
**Spec:** `tiledesk-server/docs/superpowers/specs/2026-09-30-flow-start-points-design.md` (§5).
|
|
12
|
+
|
|
13
|
+
## Global Constraints
|
|
14
|
+
|
|
15
|
+
- Repo `/Users/nicocardone/Desktop/DEV/TILEDESK/tiledesk-chatbot`, branch `feature/webhook-chatbot-hitl`. Never push. Commit trailer: blank line + `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`.
|
|
16
|
+
- Variable name exactly `start_type`, value copied from `message.request.attributes.start_type`; not set when absent.
|
|
17
|
+
- Fallback only when `message.text === '/start'` and `message.attributes.action` resolves to no intent; fallback intent name `start`; warn log `"(TiledeskChatbot) Start box not found: <action>, falling back to start"`.
|
|
18
|
+
- Tests from `tybotRoute/`, one file per process: `API_ENDPOINT=http://localhost:10002 TILEBOT_ENDPOINT=http://localhost:10001 REDIS_HOST=localhost REDIS_PORT=6379 ../node_modules/.bin/mocha test/<file> --exit`. A live tybot may run on 3001: don't kill it.
|
|
19
|
+
|
|
20
|
+
## Review Focus
|
|
21
|
+
|
|
22
|
+
1. A widget `/start` without `action` → runs `start`, no `start_type` variable (unchanged).
|
|
23
|
+
2. An `action` on a non-`/start` message (e.g. a button) that points to a missing block → unchanged behaviour ("Intent not found"), no fallback.
|
|
24
|
+
3. `start_type` present with a payload → both `start_type` and payload keys available.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
### Task 1: start_type variable and missing-box fallback
|
|
29
|
+
|
|
30
|
+
**Files:**
|
|
31
|
+
- Modify: `tybotRoute/utils/TiledeskChatbotUtil.js` (`updateRequestAttributes`, near the payload import ~850-870)
|
|
32
|
+
- Modify: `tybotRoute/engine/TiledeskChatbot.js` (explicit intent "Intent not found" branch ~180)
|
|
33
|
+
- Create: `tybotRoute/test/conversation-start_point_bot.js`, `tybotRoute/test/conversation-start_point_test.js` (mirror `conversation-webhook_bot.js` / `conversation-webhook_test.js`)
|
|
34
|
+
|
|
35
|
+
- [ ] **Step 1: Write the failing conversation tests** with a bot having blocks `start` (reply "web start|{{start_type}}") and `wbox` (intent_id `wbox-id`, reply "webhook box|{{start_type}}|{{alertname}}"):
|
|
36
|
+
- `/start` with `attributes.action: '#wbox-id'` and request attributes `{start_type:'webhook', payload:{alertname:'X'}}` → reply `webhook box|webhook|X`.
|
|
37
|
+
- `/start` with `attributes.action: '#missing-id'` → reply starts with `web start|`.
|
|
38
|
+
- `/start` without action and no start_type → reply `web start|` (empty variable renders empty).
|
|
39
|
+
- A text `hello` with `attributes.action: '#missing-id'` → no `web start` reply (no fallback).
|
|
40
|
+
- [ ] **Step 2: Run to verify they fail** (the first renders an empty start_type; the second answers nothing).
|
|
41
|
+
- [ ] **Step 3: Implement** both changes.
|
|
42
|
+
- [ ] **Step 4: Run** the new file, then `conversation-webhook_test.js`, `conversation-invite_human_test.js`, `conversation-remove_human_test.js` (one per process) → all pass.
|
|
43
|
+
- [ ] **Step 5: Commit** — `feat(engine): start_type variable and start box fallback`.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Scheduled start point — design-studio Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** A Scheduled item in the Start points palette that drops a Scheduled start box, and a panel to edit its schedule, Source name and run data (visual payload builder), see whether it is live, test-run the draft and delete it.
|
|
6
|
+
|
|
7
|
+
**Architecture:** Pure helpers in `utils-start-points.ts` (types, block factory, palette items, schedule summary/validation, payload rows ↔ JSON, live status) are unit-tested; `WebhookService` gains the test and sync calls; the canvas drop path and the intent panel reuse the webhook start box code with a `scheduled` branch.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** Angular 14, Node 16 (nvm), Jasmine/Karma via the workspace harness.
|
|
10
|
+
|
|
11
|
+
**Spec:** `tiledesk-server/docs/superpowers/specs/2026-10-01-scheduled-start-point-design.md` (§9).
|
|
12
|
+
|
|
13
|
+
## Global Constraints
|
|
14
|
+
|
|
15
|
+
- Repo `/Users/nicocardone/Desktop/DEV/TILEDESK/design-studio`, branch `feature/scheduled-start-point` (create it from `feature/webhook-chatbot-hitl` after `git pull`). Never push. Commit trailer: blank line + `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`.
|
|
16
|
+
- Node 16 prefix for every npm/npx: `source ~/.nvm/nvm.sh >/dev/null && nvm use 16 >/dev/null && `. Never npm install/ci.
|
|
17
|
+
- Specs run with the untracked harness: `npx ng test --watch=false --browsers=ChromeHeadless --main=.superpowers/sdd/2026-09-29-hitl-participant-removal-design-studio/test-hitl.ts --ts-config=.superpowers/sdd/2026-09-29-hitl-participant-removal-design-studio/tsconfig.hitl-specs.json`; register new spec files in its regex (don't commit the harness). `npx ng build` exits 0 with no new warnings; delete `dist/`.
|
|
18
|
+
- Server contract (tiledesk-server plan): `PUT {API}/{projectId}/webhooks/{chatbot_id}/start_points/scheduled` body `{ block_id, enabled?, mapping?: { source_name?, payload? }, schedule, confirm? }` → webhook + `schedule_summary` (+ `live_summary`); `POST …/start_points/scheduled/test` → `{ request_id }`; `POST …/start_points/scheduled/sync` → `scheduled_live`; `GET {API}/{projectId}/webhooks/{chatbot_id}` → `start_points`, `scheduled_live`, `scheduled_available`, `next_runs`; 503 when not configured.
|
|
19
|
+
- `schedule` shape: `{ frequency: 'interval'|'daily'|'weekly'|'monthly', every?, unit?: 'minutes'|'hours', time?: 'HH:MM', weekdays?: ('mon'..'sun')[], day_of_month?: 1..28|'last', timezone }`. Same validation values as the server (interval minutes 5/10/15/20/30, hours 1..12, ≥1 weekday, day 1..28 or last, payload keys `^[A-Za-z_][A-Za-z0-9_]*$`, unique, ≤ 50).
|
|
20
|
+
- Marker `attributes.start_point = 'scheduled'`; default block name `"Scheduled start"`; drop defaults: `{ frequency: 'daily', time: '09:00', timezone: Intl.DateTimeFormat().resolvedOptions().timeZone }`, enabled, `source_name` = chatbot name, `payload` `{}`.
|
|
21
|
+
- Status values and copy (en.json): `live` "Live — {summary} · next run {next}", `not_live` "Not live — publish to activate", `changes` "Changes not live — publish to apply", `error` "Couldn't update the live schedule — Retry". Badge labels "Live", "Changes not live", "Not live". Switch hint "Takes effect when you publish". Delete help "A live schedule stops at the next publish." Payload hint "Each field is a variable in the flow, e.g. {{check}} — {{start_type}} is scheduled".
|
|
22
|
+
- Palette item hidden when `scheduled_available` is false; one per type ("Already in this flow"); subtype `chatbot` only.
|
|
23
|
+
- Pre branch (`master-pre`) read-only adaptation is done at merge time, not in this plan.
|
|
24
|
+
|
|
25
|
+
## Review Focus
|
|
26
|
+
|
|
27
|
+
1. Switching Repeat from Weekly to Daily and back → the weekday selection is not sent while Daily is selected, and an invalid intermediate state (Weekly with no weekday) is never PUT.
|
|
28
|
+
2. Payload builder: a number field typed "08" or a true/false field → stored as number 8 / boolean, and reloading the panel shows the same rows in the same order.
|
|
29
|
+
3. Draft equal to live except key order of payload → status `live`, not `changes`.
|
|
30
|
+
4. `scheduled_available` false (GET) → no Scheduled palette item, and an existing Scheduled box still opens its panel showing the 503 message instead of breaking.
|
|
31
|
+
5. Fast consecutive edits (time typed digit by digit) → debounced to one PUT after the last change.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
### Task 1: scheduled start point helpers
|
|
36
|
+
|
|
37
|
+
**Files:**
|
|
38
|
+
- Modify: `src/app/chatbot-design-studio/utils-start-points.ts`
|
|
39
|
+
- Test: `src/app/chatbot-design-studio/utils-start-points.spec.ts`, new `src/app/chatbot-design-studio/utils-schedule.spec.ts`
|
|
40
|
+
- Create: `src/app/chatbot-design-studio/utils-schedule.ts`
|
|
41
|
+
|
|
42
|
+
**Interfaces:**
|
|
43
|
+
- `START_POINT_TYPES = ['web', 'webhook', 'scheduled']`; `startPointTypeOf(intent)` returns `'scheduled'` for the marker; `createStartPointBlock(type: 'webhook'|'scheduled', pos)` (name `"Webhook start"` / `"Scheduled start"`); `buildStartPointItems(present: string[], pending: boolean, scheduledAvailable: boolean)` adds the Scheduled item (`start_point: 'scheduled'`, name key `CDSActionList.NAME.StartPointScheduled`); `createStartPointBox(deps, type: 'webhook'|'scheduled', pos)`.
|
|
44
|
+
- `utils-schedule.ts`: `defaultSchedule(timezone: string)`, `describeSchedule(schedule): string` (same sentences as the server's `summarize`), `scheduleError(schedule): string|null`, `cleanSchedule(schedule)` (drops fields not used by the frequency), `payloadToRows(payload): { name, type: 'text'|'number'|'boolean', value }[]`, `rowsToPayload(rows): { payload, error: string|null }`, `scheduledStatus(startPoint, live): 'live'|'changes'|'not_live'|'error'` (deep compare of enabled, block_id, mapping, cleaned schedule; payload compared key-order-insensitively).
|
|
45
|
+
|
|
46
|
+
- [ ] **Step 1: Failing specs:** marker detection and block factory for `scheduled`; palette items (Scheduled hidden when `scheduledAvailable` false, disabled with tooltip when present); `describeSchedule` examples ("Every weekday at 08:30 (Europe/Rome)", "Every 15 minutes (UTC)", "Monthly on the last day at 07:00 (UTC)"); `scheduleError` for each invalid case; `cleanSchedule` drops `weekdays` from a daily schedule (Review Focus 1); rows ↔ payload round trip with number "08" → 8 and boolean (Review Focus 2), duplicate/invalid names → error; `scheduledStatus` for no live, equal (payload key order swapped → `live`, Review Focus 3), different, `live.error` set.
|
|
47
|
+
- [ ] **Step 2: Run** the harness → compile errors / failures.
|
|
48
|
+
- [ ] **Step 3: Implement.**
|
|
49
|
+
- [ ] **Step 4: Run** the harness → pass; report TOTAL.
|
|
50
|
+
- [ ] **Step 5: Commit** — `feat(scheduled-start): schedule and payload helpers`.
|
|
51
|
+
|
|
52
|
+
### Task 2: palette, drop and service calls
|
|
53
|
+
|
|
54
|
+
**Files:**
|
|
55
|
+
- Modify: `src/app/chatbot-design-studio/services/webhook-service.service.ts` (`testScheduledStart(chatbot_id)`, `syncScheduledStart(chatbot_id)`; `upsertStartPoint` type widened to `'webhook'|'scheduled'`)
|
|
56
|
+
- Modify: `cds-dashboard/cds-canvas/cds-panel-elements/cds-panel-elements.component.ts` (pass `scheduled_available` from the webhook GET into `buildStartPointItems`)
|
|
57
|
+
- Modify: `cds-dashboard/cds-canvas/cds-canvas.component.ts` (drop of `scheduled` → `createStartPointBox(…, 'scheduled', pos)` with upsert body including the drop defaults of Global Constraints)
|
|
58
|
+
- Modify: `cds-dashboard/cds-canvas/cds-intent/cds-intent.component.{ts,html}` (box rendering for `scheduled`: clock icon, summary line, badge)
|
|
59
|
+
- Modify: `src/assets/i18n/en.json`, new icon `src/assets/images/actions_category/start_point_scheduled.svg`
|
|
60
|
+
- Test: `webhook-service.service.spec.ts`, `start-points-wiring.spec.ts`
|
|
61
|
+
|
|
62
|
+
- [ ] **Step 1: Failing specs:** HttpTestingController — test/sync URLs `POST https://api.test/p1/webhooks/bot1/start_points/scheduled/test` and `/sync`; PUT body on drop equals `{ block_id, enabled: true, mapping: { source_name: <chatbot name>, payload: {} }, schedule: { frequency: 'daily', time: '09:00', timezone: <tz> } }`; wiring: palette without `scheduled_available` has no Scheduled item (Review Focus 4).
|
|
63
|
+
- [ ] **Step 2: Run** → fail.
|
|
64
|
+
- [ ] **Step 3: Implement** (box badge from `scheduledStatus`, summary from `describeSchedule`; reuse the start box toolbar guards via `isStartBox`).
|
|
65
|
+
- [ ] **Step 4: Run** harness → pass.
|
|
66
|
+
- [ ] **Step 5: Commit** — `feat(scheduled-start): palette item, drop and box`.
|
|
67
|
+
|
|
68
|
+
### Task 3: the Scheduled box panel
|
|
69
|
+
|
|
70
|
+
**Files:**
|
|
71
|
+
- Modify: `cds-dashboard/cds-canvas/cds-panel-intent-detail/cds-panel-intent-detail.component.{ts,html,scss}` (scheduled section; reuse `upsertStartPoint`, delete flow and test-run log opening of the webhook box)
|
|
72
|
+
- Modify: `src/assets/i18n/en.json`
|
|
73
|
+
- Test: extend `start-points-wiring.spec.ts` with the panel logic extracted as pure functions where possible
|
|
74
|
+
|
|
75
|
+
- [ ] **Step 1: Failing specs:** status line text per `scheduledStatus` value, with `next_runs[0]` formatted in the schedule's timezone; Retry calls `syncScheduledStart` then reloads; editing calls PUT once after a 600 ms debounce for several quick changes (fakeAsync, Review Focus 5); invalid schedule or payload → no PUT and the field error key shown; 503 on GET → panel shows "Scheduled starts are not available on this installation" (Review Focus 4).
|
|
76
|
+
- [ ] **Step 2: Run** → fail.
|
|
77
|
+
- [ ] **Step 3: Implement** the panel per spec §9 (status, Enabled switch + hint, Repeat with conditional fields, Timezone searchable select from `Intl.supportedValuesOf('timeZone')`, summary, Source name with chatbot-name placeholder, payload rows Name · Type · Value · remove + "Add field", Test scheduled start, Delete with confirmation and help text).
|
|
78
|
+
- [ ] **Step 4: Run** harness → pass; `npx ng build` → exit 0, no new warnings; delete `dist/`.
|
|
79
|
+
- [ ] **Step 5: Manual check** on the local stack (record as pending if DolphinScheduler is not running): drop the box, edit schedule and payload, Test scheduled start opens a conversation with `{{start_type}}` = scheduled and the payload variables; publish → status Live with next run.
|
|
80
|
+
- [ ] **Step 6: Commit** — `feat(scheduled-start): Scheduled box panel`.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Scheduled start point — tiledesk-agent-runtime Implementation Plan
|
|
2
|
+
|
|
3
|
+
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
|
4
|
+
|
|
5
|
+
**Goal:** The flow-building agent knows the Scheduled start box: how to recognise and wire it, what a scheduled run reads, that it goes live at publish, and that Invite/Remove human work there.
|
|
6
|
+
|
|
7
|
+
**Architecture:** Prompt and skill text only: `system.md` §1c, the catalogue overlay of the HITL actions, the back-office pattern; pinned by `tests/test_examples.py`.
|
|
8
|
+
|
|
9
|
+
**Tech Stack:** Markdown prompt + Node generators; pytest.
|
|
10
|
+
|
|
11
|
+
**Spec:** `tiledesk-server/docs/superpowers/specs/2026-10-01-scheduled-start-point-design.md` (§10).
|
|
12
|
+
|
|
13
|
+
## Global Constraints
|
|
14
|
+
|
|
15
|
+
- Repo `/Users/nicocardone/Desktop/DEV/TILEDESK/tiledesk-agent-runtime`, branch `feature/scheduled-start-point` from `feature/webhook-chatbot-hitl` (after `git pull`). Never push. Commit trailer: blank line + `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`.
|
|
16
|
+
- Generated files are never hand-edited: change `catalogue/overlay.json`, then `node definitions/tiledesk-flow-builder/generators/build-prompt.mjs --design-studio ../design-studio` with design-studio on `master-pre`.
|
|
17
|
+
- Marker `attributes.start_point: "scheduled"`; `{{start_type}}` = `scheduled`; payload fields are variables, `{{payload}}` the object; live only after publish; the agent cannot create the box nor set its timing or data.
|
|
18
|
+
- Tests: `.venv/bin/python -m pytest -q --deselect tests/test_version.py::test_version_is_the_one_pyproject_declares` (that test fails locally on stale metadata, not a regression).
|
|
19
|
+
- Version 0.9.0 in `pyproject.toml` and a `CHANGELOG.md` entry.
|
|
20
|
+
|
|
21
|
+
## Review Focus
|
|
22
|
+
|
|
23
|
+
1. A request "every morning check X and tell someone if it's broken" with no Scheduled box → the agent builds the blocks and asks the user to add Scheduled from Start points (not Webhook).
|
|
24
|
+
2. A flow with both Webhook and Scheduled boxes → the agent wires each box to its own path and does not route the Web start into invite/remove.
|
|
25
|
+
3. The agent never promises a timing ("I set it to run at 8") — timing is the user's, in the panel.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
### Task 1: teach the Scheduled start box
|
|
30
|
+
|
|
31
|
+
**Files:**
|
|
32
|
+
- Modify: `definitions/tiledesk-flow-builder/prompts/system.md` (§1c), `catalogue/overlay.json` (`invite_human`, `remove_human` notes: "started by a webhook or a schedule"), `skills/tiledesk-flow-patterns/patterns/back-office.md` (scheduled example), `CHANGELOG.md`, `pyproject.toml`
|
|
33
|
+
- Test: `tests/test_examples.py`
|
|
34
|
+
|
|
35
|
+
- [ ] **Step 1: Failing test** `test_the_prompt_teaches_the_scheduled_start`: the prompt contains `'attributes.start_point: "scheduled"'`, `"{{start_type}}"` together with `"scheduled"`, and the sentence fragment `"drag **Scheduled** from **Start points**"`; the materialized `invite_human.md` and `remove_human.md` contain `"started by a webhook or a schedule"`; `back-office.md` contains the heading `"## Started by a schedule"`.
|
|
36
|
+
- [ ] **Step 2: Run** → fail.
|
|
37
|
+
- [ ] **Step 3: Write the text** (Review Focus 1–3 are prose rules in §1c: ask for Scheduled when the request is periodic, one path per box, never state a timing), regenerate, bump to 0.9.0, changelog entry.
|
|
38
|
+
- [ ] **Step 4: Run** the suite → pass.
|
|
39
|
+
- [ ] **Step 5: Commit** — `feat(flow-builder): teach the Scheduled start box`.
|