@eventmodelers/cli 1.0.162 → 2.0.1
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/README.md +22 -27
- package/RELEASE_NOTES.md +20 -2
- package/cli.js +461 -225
- package/lib/adapters/spec-kitty-adapter.js +3 -7
- package/lib/global-agent-id.js +45 -0
- package/lib/modeling-local-ai.js +4 -2
- package/package.json +1 -1
- package/shared/build-kit/README.md +4 -19
- package/shared/build-kit/lib/agent-lock.js +75 -0
- package/shared/build-kit/lib/agent-name.js +27 -0
- package/shared/build-kit/lib/event-prune.js +58 -0
- package/shared/build-kit/lib/events-view.js +121 -0
- package/shared/build-kit/lib/local-ai-agent.js +14 -26
- package/shared/build-kit/lib/mcp-register.js +17 -1
- package/shared/build-kit/lib/prompt-journal.js +191 -0
- package/shared/build-kit/lib/prompt-replay.js +35 -0
- package/shared/build-kit/lib/ralph.js +250 -163
- package/shared/build-kit/lib/slice-curation.js +40 -0
- package/shared/build-kit/lib/slice-events.js +93 -0
- package/shared/build-kit/lib/slice-git.js +86 -0
- package/shared/build-kit/lib/slice-learnings.js +197 -0
- package/shared/build-kit/lib/slice-projection.js +101 -0
- package/shared/build-kit/lib/slice-run.js +181 -0
- package/shared/build-kit/lib/slice-state.js +182 -0
- package/shared/build-kit/lib/slice-tasks.js +35 -0
- package/shared/build-kit/ralph-claude.js +4 -2
- package/shared/build-kit/ralph-exec.js +4 -2
- package/shared/build-kit/ralph-local-ai.js +5 -3
- package/shared/skills/connect/SKILL.md +1 -5
- package/shared/skills/learn-eventmodelers-api/SKILL.md +13 -0
- package/shared/skills/request-feedback/SKILL.md +1 -2
- package/shared/skills/ui-contract/SKILL.md +5 -3
- package/stacks/axon/templates/build-kit/CLAUDE.md +3 -3
- package/stacks/axon/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/axon/templates/build-kit/lib/backend-prompt.md +20 -42
- package/stacks/axon/templates/build-kit/lib/prompt.md +18 -41
- package/stacks/blank/templates/build-kit/CLAUDE.md +3 -3
- package/stacks/blank/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/blank/templates/build-kit/lib/backend-prompt.md +20 -37
- package/stacks/blank/templates/build-kit/lib/prompt.md +19 -42
- package/stacks/classic/templates/.claude/skills/build-automation/SKILL.md +1 -1
- package/stacks/classic/templates/.claude/skills/build-state-change/SKILL.md +1 -1
- package/stacks/classic/templates/.claude/skills/build-state-view/SKILL.md +2 -2
- package/stacks/classic/templates/.claude/skills/record-evidence/SKILL.md +2 -2
- package/stacks/classic/templates/build-kit/CLAUDE.md +3 -3
- package/stacks/classic/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/classic/templates/build-kit/lib/backend-prompt.md +20 -38
- package/stacks/classic/templates/build-kit/lib/prompt.md +19 -42
- package/stacks/kurrent/templates/build-kit/CLAUDE.md +3 -4
- package/stacks/kurrent/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/kurrent/templates/build-kit/lib/backend-prompt.md +20 -42
- package/stacks/kurrent/templates/build-kit/lib/prompt.md +18 -41
- package/stacks/modeling-kit/templates/.claude/skills/attributes/SKILL.md +1 -17
- package/stacks/modeling-kit/templates/.claude/skills/detect-model-drift/SKILL.md +1 -1
- package/stacks/modeling-kit/templates/.claude/skills/eventmodeling-core-rules/SKILL.md +2 -0
- package/stacks/modeling-kit/templates/.claude/skills/eventmodeling-elaborating-scenarios/SKILL.md +7 -3
- package/stacks/modeling-kit/templates/.claude/skills/examples/SKILL.md +0 -8
- package/stacks/modeling-kit/templates/.claude/skills/stressor-analysis/SKILL.md +0 -2
- package/stacks/modeling-kit/templates/.claude/skills/walkthrough/SKILL.md +1 -1
- package/stacks/modeling-kit/templates/.claude/skills/wdyt/SKILL.md +1 -1
- package/stacks/modeling-kit/templates/kit/AGENTS.md +0 -1
- package/stacks/modeling-kit/templates/kit/CLAUDE-STANDALONE.md +3 -4
- package/stacks/modeling-kit/templates/kit/CLAUDE.md +11 -72
- package/stacks/modeling-kit/templates/kit/README.md +1 -1
- package/stacks/modeling-kit/templates/kit/lib/config.js +1 -1
- package/stacks/node/templates/build-kit/CLAUDE.md +3 -3
- package/stacks/node/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/node/templates/build-kit/lib/backend-prompt.md +20 -42
- package/stacks/node/templates/build-kit/lib/prompt.md +18 -41
- package/stacks/opencqrs/templates/build-kit/CLAUDE.md +3 -4
- package/stacks/opencqrs/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/opencqrs/templates/build-kit/lib/backend-prompt.md +20 -42
- package/stacks/opencqrs/templates/build-kit/lib/prompt.md +18 -41
- package/stacks/react/templates/.claude/skills/build-state-change/SKILL.md +1 -1
- package/stacks/react/templates/.claude/skills/build-state-view/SKILL.md +1 -1
- package/stacks/react/templates/build-kit/CLAUDE.md +3 -3
- package/stacks/react/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/react/templates/build-kit/lib/backend-prompt.md +20 -37
- package/stacks/react/templates/build-kit/lib/prompt.md +19 -42
- package/stacks/supabase/templates/build-kit/CLAUDE.md +3 -3
- package/stacks/supabase/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/supabase/templates/build-kit/lib/backend-prompt.md +20 -42
- package/stacks/supabase/templates/build-kit/lib/prompt.md +18 -41
- package/stacks/supabase-react/templates/.claude/skills/build-state-change/SKILL.md +2 -2
- package/stacks/supabase-react/templates/.claude/skills/build-state-view/SKILL.md +2 -2
- package/stacks/supabase-react/templates/build-kit/CLAUDE.md +3 -3
- package/stacks/supabase-react/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/supabase-react/templates/build-kit/lib/backend-prompt.md +20 -37
- package/stacks/supabase-react/templates/build-kit/lib/prompt.md +19 -42
- package/stacks/umadb/templates/build-kit/CLAUDE.md +3 -3
- package/stacks/umadb/templates/build-kit/lib/AGENT.md +6 -7
- package/stacks/umadb/templates/build-kit/lib/backend-prompt.md +20 -42
- package/stacks/umadb/templates/build-kit/lib/prompt.md +18 -41
- package/shared/bridge/spec-kitty/bridge-spec-kitty-specify/SKILL.md +0 -125
- package/shared/bridge/spec-kitty/bridge-spec-kitty-tasks/SKILL.md +0 -95
- package/shared/build-kit/lib/agent.sh +0 -20
- package/shared/build-kit/ralph.sh +0 -111
- package/shared/build-kit/realtime-agent.js +0 -20
- package/stacks/bridge/templates/bridge/lib/AGENT.md +0 -47
- package/stacks/bridge/templates/bridge/lib/prompt.md +0 -111
- package/stacks/bridge/templates/bridge/ralph-claude.js +0 -50
- package/stacks/bridge/templates/bridge/ralph-hook.js +0 -103
- package/stacks/bridge/templates/bridge/ralph-local-ai.js +0 -43
- package/stacks/bridge/templates/bridge/ralph-static.js +0 -90
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
// The modeling agent's journal of the board prompts it takes: `prompt-received` when it claims one, then
|
|
2
|
+
// `prompt-finished` with the outcome. The platform decides who gets a prompt (an atomic claim); this is the
|
|
3
|
+
// agent's own record of what it had in hand.
|
|
4
|
+
|
|
5
|
+
import { appendEvent, readEvents } from './slice-events.js';
|
|
6
|
+
import { fold } from './slice-state.js';
|
|
7
|
+
import { redactString } from './redact.js';
|
|
8
|
+
|
|
9
|
+
// What identifies the prompt and what `replay` needs to submit it again (text, timeline, canvas context) — not the
|
|
10
|
+
// platform's own columns (status, claim, timestamps).
|
|
11
|
+
export function journalPromptReceived({ kitDir, prompt, meta }) {
|
|
12
|
+
if (!prompt?.id) return;
|
|
13
|
+
appendEvent(kitDir, {
|
|
14
|
+
type: 'prompt-received',
|
|
15
|
+
pid: process.pid,
|
|
16
|
+
prompt: {
|
|
17
|
+
id: prompt.id,
|
|
18
|
+
text: String(prompt.prompt ?? ''),
|
|
19
|
+
board_id: prompt.board_id,
|
|
20
|
+
timeline_id: prompt.timeline_id,
|
|
21
|
+
...(prompt.context ? { context: prompt.context } : {}),
|
|
22
|
+
priority: prompt.priority,
|
|
23
|
+
agent_id: prompt.agent_id ?? null,
|
|
24
|
+
node_id: prompt.node_id,
|
|
25
|
+
comment_id: prompt.comment_id,
|
|
26
|
+
},
|
|
27
|
+
}, meta);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// outcome: worked | released | already-settled | gone. A turn that failed is not finished: its entry stays
|
|
31
|
+
// open, and the next start recovers it.
|
|
32
|
+
export function journalPromptFinished({ kitDir, id, outcome, reason, meta }) {
|
|
33
|
+
appendEvent(kitDir, { type: 'prompt-finished', prompt: id, outcome, ...(reason ? { reason } : {}) }, meta);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ── what a turn did on the board ────────────────────────────────────────────────
|
|
37
|
+
// `prompt-received` and `prompt-finished` say a prompt was taken and a turn ended; they cannot say what happened in
|
|
38
|
+
// between. Each board write the turn makes is journaled as it streams past — a comment, a slice moved to Blocked,
|
|
39
|
+
// nodes placed — so the log reads as what the agent did, and a turn that dies half way still shows how far it got.
|
|
40
|
+
// Reads are not journaled. Only what the runner can see is: a write made through curl in Bash is not.
|
|
41
|
+
|
|
42
|
+
const oneLine = (text, max) => {
|
|
43
|
+
const flat = String(text ?? '').replace(/\s+/g, ' ').trim();
|
|
44
|
+
return flat.length > max ? `${flat.slice(0, max - 1)}…` : flat;
|
|
45
|
+
};
|
|
46
|
+
const plural = (n, word) => `${n} ${word}${n === 1 ? '' : 's'}`;
|
|
47
|
+
const count = (list) => (Array.isArray(list) ? list.length : 1);
|
|
48
|
+
|
|
49
|
+
// tool → what to journal; null for a tool that writes nothing to the board.
|
|
50
|
+
const BOARD_WRITES = {
|
|
51
|
+
add_comment: ({ comments = [] }) => {
|
|
52
|
+
const nodes = new Set(comments.map((c) => c?.nodeId).filter(Boolean)).size;
|
|
53
|
+
const first = oneLine(comments[0]?.text, 100);
|
|
54
|
+
return { action: 'commented', detail: `${plural(comments.length, 'comment')} on ${plural(nodes, 'node')}${first ? `: "${first}"` : ''}` };
|
|
55
|
+
},
|
|
56
|
+
update_comment: ({ action, commentId }) => ({ action: `comment-${action === 'delete' ? 'deleted' : 'resolved'}`, detail: String(commentId ?? '').slice(0, 8) }),
|
|
57
|
+
update_slice_status: ({ newStatus, sliceId, sliceTitle }) => ({ action: 'slice-status', detail: `${sliceTitle ? `"${oneLine(sliceTitle, 60)}"` : String(sliceId ?? '').slice(0, 8)} → ${newStatus}` }),
|
|
58
|
+
submit_node_events: ({ events = [] }) => {
|
|
59
|
+
const by = {};
|
|
60
|
+
for (const e of events) by[e?.type ?? 'event'] = (by[e?.type ?? 'event'] ?? 0) + 1;
|
|
61
|
+
return { action: 'nodes-changed', detail: Object.entries(by).map(([t, n]) => `${n} ${t}`).join(', ') };
|
|
62
|
+
},
|
|
63
|
+
place_element: ({ elements }) => ({ action: 'placed', detail: plural(count(elements), 'element') }),
|
|
64
|
+
delete_node: ({ nodeIds }) => ({ action: 'nodes-deleted', detail: plural(count(nodeIds), 'node') }),
|
|
65
|
+
create_slice: ({ type, status }) => ({ action: 'slice-created', detail: [type, status].filter(Boolean).join(', ') }),
|
|
66
|
+
create_chapter: ({ title }) => ({ action: 'chapter-created', detail: title ? `"${oneLine(title, 60)}"` : '' }),
|
|
67
|
+
add_column: ({ count: n = 1 }) => ({ action: 'columns-added', detail: String(n) }),
|
|
68
|
+
add_lane: ({ lanes }) => ({ action: 'lanes-added', detail: String(count(lanes)) }),
|
|
69
|
+
add_scenario: ({ scenarios }) => ({ action: 'scenarios-added', detail: String(count(scenarios)) }),
|
|
70
|
+
add_storyline: ({ storylines }) => ({ action: 'storylines-added', detail: String(count(storylines)) }),
|
|
71
|
+
set_connection: ({ connections }) => ({ action: 'connections-changed', detail: String(count(connections)) }),
|
|
72
|
+
link_element: () => ({ action: 'linked', detail: '' }),
|
|
73
|
+
create_screen: ({ screens }) => ({ action: 'screens-created', detail: String(count(screens)) }),
|
|
74
|
+
post_chat_message: ({ text }) => ({ action: 'chat-posted', detail: `"${oneLine(text, 100)}"` }),
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// The journal entry for a tool call, or null when it is not a board write.
|
|
78
|
+
export function describeBoardAction(toolName, input) {
|
|
79
|
+
const describe = BOARD_WRITES[String(toolName).split('__').pop()];
|
|
80
|
+
return describe ? describe(input ?? {}) : null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Under `verbose` every call leaves exactly one entry: a board write as its action, any other call (a read, Bash, a
|
|
84
|
+
// skill) as a `tool-call` with `detail` — the caller's one-line account of its input — and both carry the call's full
|
|
85
|
+
// `input`, so `events --verbose` can show what was actually sent. The input is stored with the API token and anything
|
|
86
|
+
// JWT-shaped masked: a skill's arguments can hold credentials, and this log is a plain file.
|
|
87
|
+
//
|
|
88
|
+
// A call is journaled when it ends, as one entry: stamped with when it started, and carrying `durationMs` and, when the
|
|
89
|
+
// tool reported one, `error`. Timing costs nothing beyond a clock read at each end (createCallTracker).
|
|
90
|
+
export function journalPromptAction({ kitDir, id, toolName, input, verbose = false, detail, secrets = [], startedAt, durationMs, error = false, meta }) {
|
|
91
|
+
if (!id) return;
|
|
92
|
+
const done = describeBoardAction(toolName, input);
|
|
93
|
+
if (!done && !verbose) return;
|
|
94
|
+
const payload = verbose && input !== undefined ? { input: JSON.parse(redactString(JSON.stringify(input), secrets)) } : {};
|
|
95
|
+
const timing = { ...(startedAt ? { at: startedAt } : {}), ...(durationMs !== undefined ? { durationMs } : {}), ...(error ? { error: true } : {}) };
|
|
96
|
+
if (done) appendEvent(kitDir, { type: 'prompt-action', prompt: id, ...done, ...timing, ...payload }, meta);
|
|
97
|
+
else appendEvent(kitDir, { type: 'tool-call', prompt: id, tool: toolName, ...(detail ? { detail } : {}), ...timing, ...payload }, meta);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Which calls are in flight, and for how long. `begin` and `end` are a Map operation and a clock read; calls that are
|
|
101
|
+
// never going to be journaled should not be begun (shouldJournalCall). `drain` returns what never ended — a turn that
|
|
102
|
+
// died mid-call — without a duration.
|
|
103
|
+
export const shouldJournalCall = (toolName, input, verbose) => verbose || describeBoardAction(toolName, input) !== null;
|
|
104
|
+
|
|
105
|
+
export function createCallTracker({ now = () => performance.now(), clock = () => new Date().toISOString() } = {}) {
|
|
106
|
+
const open = new Map();
|
|
107
|
+
return {
|
|
108
|
+
begin(id, call) { open.set(id, { ...call, startedAt: clock(), t0: now() }); },
|
|
109
|
+
end(id, { isError = false } = {}) {
|
|
110
|
+
const call = open.get(id);
|
|
111
|
+
if (!call) return null;
|
|
112
|
+
open.delete(id);
|
|
113
|
+
const { t0, ...rest } = call;
|
|
114
|
+
return { ...rest, durationMs: Math.round(now() - t0), error: !!isError };
|
|
115
|
+
},
|
|
116
|
+
drain() {
|
|
117
|
+
const rest = [...open.values()].map(({ t0, ...call }) => call);
|
|
118
|
+
open.clear();
|
|
119
|
+
return rest;
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function openPrompts(kitDir) {
|
|
125
|
+
return fold(readEvents(kitDir)).prompts;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// ── restart recovery ────────────────────────────────────────────────────────────
|
|
129
|
+
// The platform records who holds a prompt (`claimed_by`, the agent id) and never re-queues one by itself. A
|
|
130
|
+
// freshly started agent holds nothing, so whatever the platform still shows as CLAIMED / IN_PROGRESS under its
|
|
131
|
+
// own id is what an earlier run left behind — handed back at start. (Prompts of an agent that never comes back
|
|
132
|
+
// are the platform's to release, once its heartbeat has lapsed.) Two live processes must not share one agent
|
|
133
|
+
// id: the second would hand back the first one's prompts.
|
|
134
|
+
|
|
135
|
+
const REASON = 'recovered after a restart';
|
|
136
|
+
|
|
137
|
+
// `fetchHeld(agentId)` → [{ id, status }] the platform shows as held by that agent; `release(id)` puts a prompt
|
|
138
|
+
// back on the queue and throws an error carrying `status` when the platform refuses. The journal's open entries
|
|
139
|
+
// are closed along the way: released ones as 'released', the rest as 'already-settled'. Whatever cannot be
|
|
140
|
+
// settled now (platform unreachable, a 5xx on a hand-back) stays open and is tried again at the next start.
|
|
141
|
+
export async function recoverOwnPrompts({ kitDir, meta, agentId, fetchHeld, release }) {
|
|
142
|
+
const open = openPrompts(kitDir);
|
|
143
|
+
const result = { released: 0, settled: 0, left: 0 };
|
|
144
|
+
if (!agentId) return { ...result, left: open.length };
|
|
145
|
+
|
|
146
|
+
let held;
|
|
147
|
+
try {
|
|
148
|
+
held = await fetchHeld(agentId);
|
|
149
|
+
} catch (err) {
|
|
150
|
+
console.error(`[modeling] could not ask the platform which prompts this agent was holding${open.length ? ` — leaving ${open.length} unfinished for the next start` : ''}:`, err.message);
|
|
151
|
+
return { ...result, left: open.length };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const finish = (id, outcome) => journalPromptFinished({ kitDir, id, outcome, reason: REASON, meta });
|
|
155
|
+
const isOpen = (id) => open.some((p) => p.id === id);
|
|
156
|
+
for (const { id } of held) {
|
|
157
|
+
try {
|
|
158
|
+
await release(id);
|
|
159
|
+
if (isOpen(id)) finish(id, 'released');
|
|
160
|
+
result.released++;
|
|
161
|
+
} catch (err) {
|
|
162
|
+
// 409: it is already back on the queue; 404: it was deleted — nothing left to hand back.
|
|
163
|
+
if (err?.status === 409 || err?.status === 404) {
|
|
164
|
+
if (isOpen(id)) finish(id, err.status === 404 ? 'gone' : 'already-settled');
|
|
165
|
+
result.settled++;
|
|
166
|
+
} else {
|
|
167
|
+
console.error(`[modeling] could not hand prompt ${id} back — it stays held for the next start:`, err.message);
|
|
168
|
+
result.left++;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// Entries the platform does not show as held any more finished (or went) after all.
|
|
173
|
+
const heldIds = new Set(held.map((h) => h.id));
|
|
174
|
+
for (const p of open) {
|
|
175
|
+
if (heldIds.has(p.id)) continue;
|
|
176
|
+
finish(p.id, 'already-settled');
|
|
177
|
+
result.settled++;
|
|
178
|
+
}
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// What asks the platform which prompts an agent holds: GET /prompts?claimed_by=, which reads and claims nothing.
|
|
183
|
+
// Like the other prompt routes it needs the API token *and* an authenticated user — the realtime JWT the agent
|
|
184
|
+
// already holds for /prompts/next.
|
|
185
|
+
export function heldPromptsRequest({ baseUrl, organizationId, boardId, token, jwt, agentId }) {
|
|
186
|
+
const query = new URLSearchParams({ board_id: boardId, claimed_by: agentId, status: 'CLAIMED,IN_PROGRESS', limit: '500' });
|
|
187
|
+
return {
|
|
188
|
+
url: `${baseUrl}/api/org/${organizationId}/prompts?${query}`,
|
|
189
|
+
headers: { 'x-token': token, Authorization: `Bearer ${jwt}`, 'x-agent-id': agentId },
|
|
190
|
+
};
|
|
191
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// `replay <id>`: put a prompt the journal recorded back on the board's queue as a new prompt. The journal keeps what
|
|
2
|
+
// POST /prompts took — text, board, timeline, node, comment, priority and the canvas context — so the copy asks the
|
|
3
|
+
// same thing, about the same elements, as the original did.
|
|
4
|
+
|
|
5
|
+
// The `prompt-received` event for an id (a unique prefix will do), or an Error saying why there is none.
|
|
6
|
+
export function findPromptEvent(events, idPrefix) {
|
|
7
|
+
const wanted = String(idPrefix ?? '').toLowerCase();
|
|
8
|
+
if (!wanted) throw new Error('give the id of a prompt (`eventmodelers events --type prompt-received` lists them)');
|
|
9
|
+
const hits = events.filter((e) => e?.type === 'prompt-received' && String(e.prompt?.id ?? '').toLowerCase().startsWith(wanted));
|
|
10
|
+
const ids = [...new Set(hits.map((e) => e.prompt.id))];
|
|
11
|
+
if (!ids.length) throw new Error(`no prompt "${idPrefix}" in the log — it may have been pruned (\`events --prune\`) or belong to another kit (--global, --kit)`);
|
|
12
|
+
if (ids.length > 1) throw new Error(`"${idPrefix}" matches ${ids.length} prompts (${ids.map((i) => i.slice(0, 8)).join(', ')}) — give more of the id`);
|
|
13
|
+
const prompt = hits[hits.length - 1];
|
|
14
|
+
if (!prompt.prompt.timeline_id) throw new Error(`prompt ${ids[0].slice(0, 8)} was journaled before replay was supported (no timeline, and its text may be cut short) — it cannot be re-submitted`);
|
|
15
|
+
return prompt;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// The POST /api/org/:orgId/prompts request for a journaled prompt. Auth is the realtime JWT; the API token rides along
|
|
19
|
+
// like it does on the agent's other prompt calls.
|
|
20
|
+
export function replayRequest({ baseUrl, organizationId, token, jwt, event }) {
|
|
21
|
+
const p = event.prompt;
|
|
22
|
+
return {
|
|
23
|
+
url: `${baseUrl}/api/org/${organizationId}/prompts`,
|
|
24
|
+
headers: { 'x-token': token, Authorization: `Bearer ${jwt}`, 'Content-Type': 'application/json' },
|
|
25
|
+
body: {
|
|
26
|
+
prompt: p.text,
|
|
27
|
+
board_id: p.board_id,
|
|
28
|
+
timeline_id: p.timeline_id,
|
|
29
|
+
...(p.node_id ? { node_id: p.node_id } : {}),
|
|
30
|
+
...(p.comment_id ? { comment_id: p.comment_id } : {}),
|
|
31
|
+
...(p.priority ? { priority: true } : {}),
|
|
32
|
+
...(p.context ? { context: p.context } : {}),
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|