@molecule/app-ide-panel-logic 0.0.0-stage → 0.0.1-stage
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/LICENSE +202 -0
- package/README.md +2925 -2
- package/dist/chatTimelineOrdering.d.ts +50 -0
- package/dist/chatTimelineOrdering.d.ts.map +1 -0
- package/dist/chatTimelineOrdering.js +46 -0
- package/dist/chatTimelineOrdering.js.map +1 -0
- package/dist/command-metadata.d.ts +117 -0
- package/dist/command-metadata.d.ts.map +1 -0
- package/dist/command-metadata.js +271 -0
- package/dist/command-metadata.js.map +1 -0
- package/dist/components/activity-utilities.d.ts +107 -0
- package/dist/components/activity-utilities.d.ts.map +1 -0
- package/dist/components/activity-utilities.js +154 -0
- package/dist/components/activity-utilities.js.map +1 -0
- package/dist/components/chat-autocommit-utilities.d.ts +172 -0
- package/dist/components/chat-autocommit-utilities.d.ts.map +1 -0
- package/dist/components/chat-autocommit-utilities.js +185 -0
- package/dist/components/chat-autocommit-utilities.js.map +1 -0
- package/dist/components/chat-card-style.d.ts +81 -0
- package/dist/components/chat-card-style.d.ts.map +1 -0
- package/dist/components/chat-card-style.js +78 -0
- package/dist/components/chat-card-style.js.map +1 -0
- package/dist/components/chat-commands.d.ts +17 -0
- package/dist/components/chat-commands.d.ts.map +1 -0
- package/dist/components/chat-commands.js +17 -0
- package/dist/components/chat-commands.js.map +1 -0
- package/dist/components/chat-commit-utilities.d.ts +29 -0
- package/dist/components/chat-commit-utilities.d.ts.map +1 -0
- package/dist/components/chat-commit-utilities.js +31 -0
- package/dist/components/chat-commit-utilities.js.map +1 -0
- package/dist/components/chat-cost-utilities.d.ts +62 -0
- package/dist/components/chat-cost-utilities.d.ts.map +1 -0
- package/dist/components/chat-cost-utilities.js +66 -0
- package/dist/components/chat-cost-utilities.js.map +1 -0
- package/dist/components/chat-effort-utilities.d.ts +104 -0
- package/dist/components/chat-effort-utilities.d.ts.map +1 -0
- package/dist/components/chat-effort-utilities.js +99 -0
- package/dist/components/chat-effort-utilities.js.map +1 -0
- package/dist/components/chat-help-utilities.d.ts +89 -0
- package/dist/components/chat-help-utilities.d.ts.map +1 -0
- package/dist/components/chat-help-utilities.js +131 -0
- package/dist/components/chat-help-utilities.js.map +1 -0
- package/dist/components/chat-model-mode-utilities.d.ts +169 -0
- package/dist/components/chat-model-mode-utilities.d.ts.map +1 -0
- package/dist/components/chat-model-mode-utilities.js +221 -0
- package/dist/components/chat-model-mode-utilities.js.map +1 -0
- package/dist/components/chat-models-utilities.d.ts +162 -0
- package/dist/components/chat-models-utilities.d.ts.map +1 -0
- package/dist/components/chat-models-utilities.js +302 -0
- package/dist/components/chat-models-utilities.js.map +1 -0
- package/dist/components/chat-report-utilities.d.ts +149 -0
- package/dist/components/chat-report-utilities.d.ts.map +1 -0
- package/dist/components/chat-report-utilities.js +151 -0
- package/dist/components/chat-report-utilities.js.map +1 -0
- package/dist/components/chat-scripts-utilities.d.ts +185 -0
- package/dist/components/chat-scripts-utilities.d.ts.map +1 -0
- package/dist/components/chat-scripts-utilities.js +199 -0
- package/dist/components/chat-scripts-utilities.js.map +1 -0
- package/dist/components/chat-settings-utilities.d.ts +72 -0
- package/dist/components/chat-settings-utilities.d.ts.map +1 -0
- package/dist/components/chat-settings-utilities.js +56 -0
- package/dist/components/chat-settings-utilities.js.map +1 -0
- package/dist/components/chat-share-utilities.d.ts +110 -0
- package/dist/components/chat-share-utilities.d.ts.map +1 -0
- package/dist/components/chat-share-utilities.js +90 -0
- package/dist/components/chat-share-utilities.js.map +1 -0
- package/dist/components/chat-skills-utilities.d.ts +242 -0
- package/dist/components/chat-skills-utilities.d.ts.map +1 -0
- package/dist/components/chat-skills-utilities.js +433 -0
- package/dist/components/chat-skills-utilities.js.map +1 -0
- package/dist/components/chat-stream-utilities.d.ts +74 -0
- package/dist/components/chat-stream-utilities.d.ts.map +1 -0
- package/dist/components/chat-stream-utilities.js +103 -0
- package/dist/components/chat-stream-utilities.js.map +1 -0
- package/dist/components/chat-timestamps-utilities.d.ts +123 -0
- package/dist/components/chat-timestamps-utilities.d.ts.map +1 -0
- package/dist/components/chat-timestamps-utilities.js +177 -0
- package/dist/components/chat-timestamps-utilities.js.map +1 -0
- package/dist/components/chat-tips-utilities.d.ts +108 -0
- package/dist/components/chat-tips-utilities.d.ts.map +1 -0
- package/dist/components/chat-tips-utilities.js +137 -0
- package/dist/components/chat-tips-utilities.js.map +1 -0
- package/dist/components/device-cycle.d.ts +84 -0
- package/dist/components/device-cycle.d.ts.map +1 -0
- package/dist/components/device-cycle.js +77 -0
- package/dist/components/device-cycle.js.map +1 -0
- package/dist/components/fileExplorerPersistence.d.ts +50 -0
- package/dist/components/fileExplorerPersistence.d.ts.map +1 -0
- package/dist/components/fileExplorerPersistence.js +63 -0
- package/dist/components/fileExplorerPersistence.js.map +1 -0
- package/dist/components/search-utilities.d.ts +15 -0
- package/dist/components/search-utilities.d.ts.map +1 -0
- package/dist/components/search-utilities.js +26 -0
- package/dist/components/search-utilities.js.map +1 -0
- package/dist/components/tests-bar-utilities.d.ts +106 -0
- package/dist/components/tests-bar-utilities.d.ts.map +1 -0
- package/dist/components/tests-bar-utilities.js +167 -0
- package/dist/components/tests-bar-utilities.js.map +1 -0
- package/dist/components/tests-card-utilities.d.ts +280 -0
- package/dist/components/tests-card-utilities.d.ts.map +1 -0
- package/dist/components/tests-card-utilities.js +591 -0
- package/dist/components/tests-card-utilities.js.map +1 -0
- package/dist/components/tool-call-utilities.d.ts +256 -0
- package/dist/components/tool-call-utilities.d.ts.map +1 -0
- package/dist/components/tool-call-utilities.js +1004 -0
- package/dist/components/tool-call-utilities.js.map +1 -0
- package/dist/components/user-avatar-utilities.d.ts +41 -0
- package/dist/components/user-avatar-utilities.d.ts.map +1 -0
- package/dist/components/user-avatar-utilities.js +56 -0
- package/dist/components/user-avatar-utilities.js.map +1 -0
- package/dist/components/workspace-layout-utilities.d.ts +37 -0
- package/dist/components/workspace-layout-utilities.d.ts.map +1 -0
- package/dist/components/workspace-layout-utilities.js +58 -0
- package/dist/components/workspace-layout-utilities.js.map +1 -0
- package/dist/customEventCards.d.ts +147 -0
- package/dist/customEventCards.d.ts.map +1 -0
- package/dist/customEventCards.js +36 -0
- package/dist/customEventCards.js.map +1 -0
- package/dist/icon-names.d.ts +26 -0
- package/dist/icon-names.d.ts.map +1 -0
- package/dist/icon-names.js +14 -0
- package/dist/icon-names.js.map +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/keyboard-shortcut-utilities.d.ts +63 -0
- package/dist/keyboard-shortcut-utilities.d.ts.map +1 -0
- package/dist/keyboard-shortcut-utilities.js +100 -0
- package/dist/keyboard-shortcut-utilities.js.map +1 -0
- package/dist/panels.d.ts +26 -0
- package/dist/panels.d.ts.map +1 -0
- package/dist/panels.js +26 -0
- package/dist/panels.js.map +1 -0
- package/dist/settings-metadata.d.ts +78 -0
- package/dist/settings-metadata.d.ts.map +1 -0
- package/dist/settings-metadata.js +137 -0
- package/dist/settings-metadata.js.map +1 -0
- package/dist/types.d.ts +588 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +9 -0
- package/dist/types.js.map +1 -0
- package/dist/viewport-queries.d.ts +19 -0
- package/dist/viewport-queries.d.ts.map +1 -0
- package/dist/viewport-queries.js +19 -0
- package/dist/viewport-queries.js.map +1 -0
- package/package.json +74 -4
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timeline ordering for the chat transcript.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/** The minimal shape {@link timelineSortKey} reads from a timeline item. */
|
|
7
|
+
interface OrderableItem {
|
|
8
|
+
kind: string;
|
|
9
|
+
msg?: {
|
|
10
|
+
timestamp: number;
|
|
11
|
+
isStreaming?: boolean;
|
|
12
|
+
content?: string;
|
|
13
|
+
blocks?: unknown[];
|
|
14
|
+
queued?: boolean;
|
|
15
|
+
};
|
|
16
|
+
card?: {
|
|
17
|
+
timestamp: number;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Sort key for a chat-timeline item (message or any card). Items normally order by
|
|
22
|
+
* their `timestamp`, with TWO exceptions: a streaming assistant message that has not
|
|
23
|
+
* yet produced any content sorts after every timestamped item, and a QUEUED user
|
|
24
|
+
* message sorts dead last.
|
|
25
|
+
*
|
|
26
|
+
* Why (empty streaming): a turn's preamble cards (the model / "Building your app"
|
|
27
|
+
* notices, the "models_intro" note, the onboarding tip) are emitted a beat BEFORE the
|
|
28
|
+
* response content. The server defers each assistant message's `message_start` — and
|
|
29
|
+
* thus its timestamp — to that message's FIRST content event, so the message is
|
|
30
|
+
* timestamped when it visually appears, strictly after every preamble item, and orders
|
|
31
|
+
* below them. This rule only covers the brief window between `message_start` and the
|
|
32
|
+
* first flushed content: while still empty the message sorts last (bottom of the turn)
|
|
33
|
+
* instead of leap-frogging the cards on an earlier timestamp; once content lands it
|
|
34
|
+
* orders by its first-content timestamp, still after the preamble. No card opts in by
|
|
35
|
+
* name, and because that timestamp is the server's persisted value, live and reload
|
|
36
|
+
* order identically.
|
|
37
|
+
*
|
|
38
|
+
* Why (queued): a message queued while a response streams belongs to a FUTURE turn —
|
|
39
|
+
* it must pin to the very bottom of the transcript, below everything the current turn
|
|
40
|
+
* keeps streaming (new assistant messages, cards), instead of drifting up as later-
|
|
41
|
+
* timestamped items are appended after it. Multiple queued messages keep their queue
|
|
42
|
+
* order via sort stability. When the queue drains, useChat re-stamps the message to
|
|
43
|
+
* its actual send time, so it settles exactly where the transcript reached.
|
|
44
|
+
*
|
|
45
|
+
* @param item - A timeline item.
|
|
46
|
+
* @returns The numeric key to sort ascending by.
|
|
47
|
+
*/
|
|
48
|
+
export declare function timelineSortKey(item: OrderableItem): number;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=chatTimelineOrdering.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatTimelineOrdering.d.ts","sourceRoot":"","sources":["../src/chatTimelineOrdering.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,4EAA4E;AAC5E,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE;QACJ,SAAS,EAAE,MAAM,CAAA;QACjB,WAAW,CAAC,EAAE,OAAO,CAAA;QACrB,OAAO,CAAC,EAAE,MAAM,CAAA;QAChB,MAAM,CAAC,EAAE,OAAO,EAAE,CAAA;QAClB,MAAM,CAAC,EAAE,OAAO,CAAA;KACjB,CAAA;IACD,IAAI,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAA;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAS3D"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timeline ordering for the chat transcript.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Sort key for a chat-timeline item (message or any card). Items normally order by
|
|
8
|
+
* their `timestamp`, with TWO exceptions: a streaming assistant message that has not
|
|
9
|
+
* yet produced any content sorts after every timestamped item, and a QUEUED user
|
|
10
|
+
* message sorts dead last.
|
|
11
|
+
*
|
|
12
|
+
* Why (empty streaming): a turn's preamble cards (the model / "Building your app"
|
|
13
|
+
* notices, the "models_intro" note, the onboarding tip) are emitted a beat BEFORE the
|
|
14
|
+
* response content. The server defers each assistant message's `message_start` — and
|
|
15
|
+
* thus its timestamp — to that message's FIRST content event, so the message is
|
|
16
|
+
* timestamped when it visually appears, strictly after every preamble item, and orders
|
|
17
|
+
* below them. This rule only covers the brief window between `message_start` and the
|
|
18
|
+
* first flushed content: while still empty the message sorts last (bottom of the turn)
|
|
19
|
+
* instead of leap-frogging the cards on an earlier timestamp; once content lands it
|
|
20
|
+
* orders by its first-content timestamp, still after the preamble. No card opts in by
|
|
21
|
+
* name, and because that timestamp is the server's persisted value, live and reload
|
|
22
|
+
* order identically.
|
|
23
|
+
*
|
|
24
|
+
* Why (queued): a message queued while a response streams belongs to a FUTURE turn —
|
|
25
|
+
* it must pin to the very bottom of the transcript, below everything the current turn
|
|
26
|
+
* keeps streaming (new assistant messages, cards), instead of drifting up as later-
|
|
27
|
+
* timestamped items are appended after it. Multiple queued messages keep their queue
|
|
28
|
+
* order via sort stability. When the queue drains, useChat re-stamps the message to
|
|
29
|
+
* its actual send time, so it settles exactly where the transcript reached.
|
|
30
|
+
*
|
|
31
|
+
* @param item - A timeline item.
|
|
32
|
+
* @returns The numeric key to sort ascending by.
|
|
33
|
+
*/
|
|
34
|
+
export function timelineSortKey(item) {
|
|
35
|
+
if (item.kind === 'message' && item.msg) {
|
|
36
|
+
const m = item.msg;
|
|
37
|
+
if (m.queued)
|
|
38
|
+
return Number.MAX_SAFE_INTEGER;
|
|
39
|
+
const empty = !m.content && (!m.blocks || m.blocks.length === 0);
|
|
40
|
+
if (m.isStreaming && empty)
|
|
41
|
+
return Number.MAX_SAFE_INTEGER - 1;
|
|
42
|
+
return m.timestamp;
|
|
43
|
+
}
|
|
44
|
+
return item.card?.timestamp ?? 0;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=chatTimelineOrdering.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatTimelineOrdering.js","sourceRoot":"","sources":["../src/chatTimelineOrdering.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAeH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,eAAe,CAAC,IAAmB;IACjD,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;QACxC,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAA;QAClB,IAAI,CAAC,CAAC,MAAM;YAAE,OAAO,MAAM,CAAC,gBAAgB,CAAA;QAC5C,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAA;QAChE,IAAI,CAAC,CAAC,WAAW,IAAI,KAAK;YAAE,OAAO,MAAM,CAAC,gBAAgB,GAAG,CAAC,CAAA;QAC9D,OAAO,CAAC,CAAC,SAAS,CAAA;IACpB,CAAC;IACD,OAAO,IAAI,CAAC,IAAI,EAAE,SAAS,IAAI,CAAC,CAAA;AAClC,CAAC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React-free slash-command metadata — the single source of truth for every
|
|
3
|
+
* `/command` the user can run.
|
|
4
|
+
*
|
|
5
|
+
* This module deliberately imports **nothing** (no React, no app-ui, no i18n)
|
|
6
|
+
* so it can be consumed on *either* side of the api/app boundary. The IDE chat
|
|
7
|
+
* surfaces (command menu, keyboard dispatcher, `/help`, the `/settings` card)
|
|
8
|
+
* all read from {@link COMMANDS} here, AND the molecule.dev API system prompt
|
|
9
|
+
* can import the same array (via the package's `./command-metadata` subpath
|
|
10
|
+
* export) to render Synthase's "Available Commands" section. One list, two
|
|
11
|
+
* consumers — so the agent can never claim a shipped command (e.g. `/share`)
|
|
12
|
+
* does not exist, and the prompt can never drift behind the registry.
|
|
13
|
+
*
|
|
14
|
+
* Add a new command here (plus a branch in `executeCommand`) and it shows up
|
|
15
|
+
* everywhere automatically — menu, `/help`, `/settings`, and the system prompt.
|
|
16
|
+
*
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
/** Category keys used to group commands in the menu and in `/help`. */
|
|
20
|
+
export type CommandCategoryKey = 'context' | 'code' | 'collaborate' | 'model' | 'settings' | 'support';
|
|
21
|
+
/** A command category with its display label. */
|
|
22
|
+
export interface CommandCategory {
|
|
23
|
+
/** Stable category key referenced by {@link CommandDef.category}. */
|
|
24
|
+
key: CommandCategoryKey;
|
|
25
|
+
/** Human-readable category heading (English default; wrapped in `t()` at render). */
|
|
26
|
+
label: string;
|
|
27
|
+
}
|
|
28
|
+
/** Ordered list of command categories used as section headings. */
|
|
29
|
+
export declare const COMMAND_CATEGORIES: readonly CommandCategory[];
|
|
30
|
+
/** Metadata describing a single slash command. */
|
|
31
|
+
export interface CommandDef {
|
|
32
|
+
/** Command id (the part after the slash, e.g. `'help'`). */
|
|
33
|
+
id: string;
|
|
34
|
+
/** Display label including the leading slash (e.g. `'/help'`). */
|
|
35
|
+
label: string;
|
|
36
|
+
/**
|
|
37
|
+
* Short description shown in the menu and in `/help` (English default). May
|
|
38
|
+
* contain the `{{agentName}}` interpolation token, filled in by the render
|
|
39
|
+
* sites (command menu, `/help`, `/settings` card) from the host's agent
|
|
40
|
+
* identity (neutral default: "the assistant").
|
|
41
|
+
*/
|
|
42
|
+
description: string;
|
|
43
|
+
/** Category this command is grouped under. */
|
|
44
|
+
category: CommandCategoryKey;
|
|
45
|
+
/**
|
|
46
|
+
* Argument syntax for commands that take options, shown in the `/settings`
|
|
47
|
+
* command reference (English default). `[…]` = optional, `<…>` = required.
|
|
48
|
+
* Omit for commands that take no arguments.
|
|
49
|
+
*/
|
|
50
|
+
usage?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Alternate short forms (WITHOUT the slash) that also invoke this command —
|
|
53
|
+
* e.g. `['t']` lets `/t <message>` invoke `/teamsay`. Matched by the chat
|
|
54
|
+
* input's command dispatch alongside {@link id}.
|
|
55
|
+
*/
|
|
56
|
+
aliases?: string[];
|
|
57
|
+
/**
|
|
58
|
+
* True for a human-only side-channel command handled by the HOST's server
|
|
59
|
+
* (e.g. a team-chat note the agent never sees): the raw `/command` text is
|
|
60
|
+
* sent to the backend, but NO optimistic user bubble is rendered — the server
|
|
61
|
+
* emits the canonical `message` stream event (see the `ChatStreamEvent`
|
|
62
|
+
* union), which IS the visible message, persisted and fanned out live to
|
|
63
|
+
* every project member.
|
|
64
|
+
*/
|
|
65
|
+
sideChannel?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* True for commands a read-only project VIEWER may run — the ones that only
|
|
68
|
+
* read, open a view-only surface, or set a per-user/per-device preference
|
|
69
|
+
* (`/cost`, `/settings`, `/help`, `/mic`, …). Everything else writes shared
|
|
70
|
+
* project state or triggers a Synthase turn (which the server 403s for a
|
|
71
|
+
* viewer), so it is **default-denied** for viewers: omitting this flag means a
|
|
72
|
+
* viewer cannot run the command, which is the safe default for any command
|
|
73
|
+
* added later. Host side-channel commands (`sideChannel`, e.g. `/teamsay`) are
|
|
74
|
+
* team communication, not project mutation — they set this so viewers can talk.
|
|
75
|
+
*/
|
|
76
|
+
viewerSafe?: boolean;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Every available slash command, grouped by category order. This is the
|
|
80
|
+
* authoritative list — the menu, key handling, `/help`, AND the system prompt's
|
|
81
|
+
* "Available Commands" section all read from it.
|
|
82
|
+
*/
|
|
83
|
+
export declare const COMMANDS: readonly CommandDef[];
|
|
84
|
+
/** Union of all command ids (loosely `string`, since {@link CommandDef.id} is a string). */
|
|
85
|
+
export type CommandId = CommandDef['id'];
|
|
86
|
+
/** A category paired with the commands that belong to it. */
|
|
87
|
+
export interface CommandGroup {
|
|
88
|
+
/** The category metadata (key + label). */
|
|
89
|
+
category: CommandCategory;
|
|
90
|
+
/** Commands in this category, in registry order. */
|
|
91
|
+
commands: CommandDef[];
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Groups commands under their categories, preserving category and command
|
|
95
|
+
* order and dropping empty categories. Used by the `/settings` command
|
|
96
|
+
* reference (and any other view that lists commands by section) so the
|
|
97
|
+
* grouping stays in sync with the registry automatically.
|
|
98
|
+
*
|
|
99
|
+
* @param commands - Command registry to group (defaults to {@link COMMANDS}).
|
|
100
|
+
* @param categories - Ordered categories (defaults to {@link COMMAND_CATEGORIES}).
|
|
101
|
+
* @returns One {@link CommandGroup} per non-empty category, in category order.
|
|
102
|
+
*/
|
|
103
|
+
export declare function groupCommandsByCategory(commands?: readonly CommandDef[], categories?: readonly CommandCategory[]): CommandGroup[];
|
|
104
|
+
/**
|
|
105
|
+
* True when `text` invokes a side-channel command ({@link CommandDef.sideChannel})
|
|
106
|
+
* from `defs`, matched against the leading `/token` by command id or alias
|
|
107
|
+
* (case-insensitive). Used by the chat input's dispatch AND the auto-send
|
|
108
|
+
* (initialMessage) path so a side-channel send never renders an optimistic
|
|
109
|
+
* "/command …" echo — the server's emitted `message` stream event is the one
|
|
110
|
+
* visible message.
|
|
111
|
+
*
|
|
112
|
+
* @param defs - The command registry to consult (e.g. shared ∪ host commands).
|
|
113
|
+
* @param text - The raw outgoing message text.
|
|
114
|
+
* @returns Whether the text invokes a side-channel command.
|
|
115
|
+
*/
|
|
116
|
+
export declare function matchesSideChannelCommand(defs: readonly CommandDef[] | undefined, text: string): boolean;
|
|
117
|
+
//# sourceMappingURL=command-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-metadata.d.ts","sourceRoot":"","sources":["../src/command-metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,uEAAuE;AACvE,MAAM,MAAM,kBAAkB,GAC5B,SAAS,GAAG,MAAM,GAAG,aAAa,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAAA;AAEvE,iDAAiD;AACjD,MAAM,WAAW,eAAe;IAC9B,qEAAqE;IACrE,GAAG,EAAE,kBAAkB,CAAA;IACvB,qFAAqF;IACrF,KAAK,EAAE,MAAM,CAAA;CACd;AAED,mEAAmE;AACnE,eAAO,MAAM,kBAAkB,EAAE,SAAS,eAAe,EAO/C,CAAA;AAEV,kDAAkD;AAClD,MAAM,WAAW,UAAU;IACzB,4DAA4D;IAC5D,EAAE,EAAE,MAAM,CAAA;IACV,kEAAkE;IAClE,KAAK,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB,8CAA8C;IAC9C,QAAQ,EAAE,kBAAkB,CAAA;IAC5B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;;;;;;;;OASG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,SAAS,UAAU,EA0MhC,CAAA;AAEV,4FAA4F;AAC5F,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,IAAI,CAAC,CAAA;AAExC,6DAA6D;AAC7D,MAAM,WAAW,YAAY;IAC3B,2CAA2C;IAC3C,QAAQ,EAAE,eAAe,CAAA;IACzB,oDAAoD;IACpD,QAAQ,EAAE,UAAU,EAAE,CAAA;CACvB;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,GAAE,SAAS,UAAU,EAAa,EAC1C,UAAU,GAAE,SAAS,eAAe,EAAuB,GAC1D,YAAY,EAAE,CAOhB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,SAAS,UAAU,EAAE,GAAG,SAAS,EACvC,IAAI,EAAE,MAAM,GACX,OAAO,CAST"}
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React-free slash-command metadata — the single source of truth for every
|
|
3
|
+
* `/command` the user can run.
|
|
4
|
+
*
|
|
5
|
+
* This module deliberately imports **nothing** (no React, no app-ui, no i18n)
|
|
6
|
+
* so it can be consumed on *either* side of the api/app boundary. The IDE chat
|
|
7
|
+
* surfaces (command menu, keyboard dispatcher, `/help`, the `/settings` card)
|
|
8
|
+
* all read from {@link COMMANDS} here, AND the molecule.dev API system prompt
|
|
9
|
+
* can import the same array (via the package's `./command-metadata` subpath
|
|
10
|
+
* export) to render Synthase's "Available Commands" section. One list, two
|
|
11
|
+
* consumers — so the agent can never claim a shipped command (e.g. `/share`)
|
|
12
|
+
* does not exist, and the prompt can never drift behind the registry.
|
|
13
|
+
*
|
|
14
|
+
* Add a new command here (plus a branch in `executeCommand`) and it shows up
|
|
15
|
+
* everywhere automatically — menu, `/help`, `/settings`, and the system prompt.
|
|
16
|
+
*
|
|
17
|
+
* @module
|
|
18
|
+
*/
|
|
19
|
+
/** Ordered list of command categories used as section headings. */
|
|
20
|
+
export const COMMAND_CATEGORIES = [
|
|
21
|
+
{ key: 'context', label: 'Context' },
|
|
22
|
+
{ key: 'code', label: 'Code' },
|
|
23
|
+
{ key: 'collaborate', label: 'Collaborate' },
|
|
24
|
+
{ key: 'model', label: 'Model' },
|
|
25
|
+
{ key: 'settings', label: 'Settings' },
|
|
26
|
+
{ key: 'support', label: 'Support' },
|
|
27
|
+
];
|
|
28
|
+
/**
|
|
29
|
+
* Every available slash command, grouped by category order. This is the
|
|
30
|
+
* authoritative list — the menu, key handling, `/help`, AND the system prompt's
|
|
31
|
+
* "Available Commands" section all read from it.
|
|
32
|
+
*/
|
|
33
|
+
export const COMMANDS = [
|
|
34
|
+
// Context
|
|
35
|
+
{ id: 'clear', label: '/clear', description: 'Clear conversation', category: 'context' },
|
|
36
|
+
{
|
|
37
|
+
id: 'compact',
|
|
38
|
+
label: '/compact',
|
|
39
|
+
description: 'Compress context to free space',
|
|
40
|
+
category: 'context',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 'cost',
|
|
44
|
+
label: '/cost',
|
|
45
|
+
description: "Show token usage & share of the project's AI allowance",
|
|
46
|
+
category: 'context',
|
|
47
|
+
viewerSafe: true,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: 'skills',
|
|
51
|
+
label: '/skills',
|
|
52
|
+
description: 'Browse & load project skills',
|
|
53
|
+
category: 'context',
|
|
54
|
+
usage: '/skills [query]',
|
|
55
|
+
},
|
|
56
|
+
// Code
|
|
57
|
+
{ id: 'commit', label: '/commit', description: 'Commit current changes', category: 'code' },
|
|
58
|
+
{
|
|
59
|
+
id: 'explain',
|
|
60
|
+
label: '/explain',
|
|
61
|
+
description: 'Explain code (e.g. /explain @file)',
|
|
62
|
+
category: 'code',
|
|
63
|
+
usage: '/explain [@file | topic]',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 'lint',
|
|
67
|
+
label: '/lint',
|
|
68
|
+
description: 'Run linter and fix issues',
|
|
69
|
+
category: 'code',
|
|
70
|
+
usage: '/lint [path]',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: 'test',
|
|
74
|
+
label: '/test',
|
|
75
|
+
description: "List and run the project's tests",
|
|
76
|
+
category: 'code',
|
|
77
|
+
usage: '/test [query | all]',
|
|
78
|
+
aliases: ['tests'],
|
|
79
|
+
// Listing is a read (the platform serves it to viewers too); RUNNING is an
|
|
80
|
+
// editor action, refused by the server and disabled in the card with its
|
|
81
|
+
// reason shown. So a viewer opens the browser and sees what is tested.
|
|
82
|
+
viewerSafe: true,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: 'undo',
|
|
86
|
+
label: '/undo',
|
|
87
|
+
description: "Revert last AI turn's file changes",
|
|
88
|
+
category: 'code',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: 'scripts',
|
|
92
|
+
label: '/scripts',
|
|
93
|
+
description: 'Browse & run saved scripts and built-in actions',
|
|
94
|
+
category: 'code',
|
|
95
|
+
usage: '/scripts [query]',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: 'run',
|
|
99
|
+
label: '/run',
|
|
100
|
+
description: 'Run a saved script or built-in by name',
|
|
101
|
+
category: 'code',
|
|
102
|
+
usage: '/run <name> [--option value]',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
id: 'autocommit',
|
|
106
|
+
label: '/autocommit',
|
|
107
|
+
description: 'Auto-commit N seconds after the last file change (0 cancels)',
|
|
108
|
+
category: 'code',
|
|
109
|
+
usage: '/autocommit <seconds>',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: 'autofix',
|
|
113
|
+
label: '/autofix',
|
|
114
|
+
description: 'Toggle auto-fix after AI file changes',
|
|
115
|
+
category: 'code',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
id: 'autoapprove',
|
|
119
|
+
label: '/autoapprove',
|
|
120
|
+
description: 'Toggle auto-approving destructive commands (skip the Proceed confirm)',
|
|
121
|
+
category: 'code',
|
|
122
|
+
},
|
|
123
|
+
// Collaborate
|
|
124
|
+
{
|
|
125
|
+
id: 'share',
|
|
126
|
+
label: '/share',
|
|
127
|
+
description: 'Create a public share link for this project',
|
|
128
|
+
category: 'collaborate',
|
|
129
|
+
usage: '/share [viewer | commenter | editor | owner]',
|
|
130
|
+
},
|
|
131
|
+
// Model
|
|
132
|
+
{
|
|
133
|
+
id: 'model',
|
|
134
|
+
label: '/model',
|
|
135
|
+
description: 'Switch the model for any mode (plan, execute, commit messages, compaction)',
|
|
136
|
+
category: 'model',
|
|
137
|
+
usage: '/model [name | --plan | --execute | --commit | --compact]',
|
|
138
|
+
},
|
|
139
|
+
{ id: 'plan', label: '/plan', description: 'Toggle plan/execute mode', category: 'model' },
|
|
140
|
+
{
|
|
141
|
+
id: 'maxloops',
|
|
142
|
+
label: '/maxloops',
|
|
143
|
+
description: 'Set max tool iterations',
|
|
144
|
+
category: 'model',
|
|
145
|
+
usage: '/maxloops <n>',
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
id: 'effort',
|
|
149
|
+
label: '/effort',
|
|
150
|
+
description: "Pick reasoning effort per mode from the model's own levels",
|
|
151
|
+
category: 'model',
|
|
152
|
+
usage: '/effort [--plan|--execute] [level]',
|
|
153
|
+
},
|
|
154
|
+
// Settings
|
|
155
|
+
{
|
|
156
|
+
id: 'settings',
|
|
157
|
+
label: '/settings',
|
|
158
|
+
description: "View & change {{agentName}}'s settings",
|
|
159
|
+
category: 'settings',
|
|
160
|
+
// The settings modal renders read-only for a viewer (every write control is
|
|
161
|
+
// disabled), so opening it to look is fine.
|
|
162
|
+
viewerSafe: true,
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
id: 'sounds',
|
|
166
|
+
label: '/sounds',
|
|
167
|
+
description: 'Notification sounds',
|
|
168
|
+
category: 'settings',
|
|
169
|
+
// Per-user, per-device preference (localStorage) — nothing project-shared.
|
|
170
|
+
viewerSafe: true,
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
id: 'timestamps',
|
|
174
|
+
label: '/timestamps',
|
|
175
|
+
description: 'Show or hide the time on chat messages and events',
|
|
176
|
+
category: 'settings',
|
|
177
|
+
usage: '/timestamps [on | off]',
|
|
178
|
+
// Per-user, per-device display preference (localStorage) — nothing project-shared.
|
|
179
|
+
viewerSafe: true,
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
id: 'mic',
|
|
183
|
+
label: '/mic',
|
|
184
|
+
description: 'Choose the dictation engine (on-device / browser native)',
|
|
185
|
+
category: 'settings',
|
|
186
|
+
viewerSafe: true,
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
id: 'dictate',
|
|
190
|
+
label: '/dictate',
|
|
191
|
+
description: 'Choose the dictation engine (alias for /mic)',
|
|
192
|
+
category: 'settings',
|
|
193
|
+
viewerSafe: true,
|
|
194
|
+
},
|
|
195
|
+
// Support
|
|
196
|
+
{
|
|
197
|
+
id: 'help',
|
|
198
|
+
label: '/help',
|
|
199
|
+
description: 'Workflow guide & tips',
|
|
200
|
+
category: 'support',
|
|
201
|
+
viewerSafe: true,
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
id: 'report',
|
|
205
|
+
label: '/report',
|
|
206
|
+
description: 'Report a bug or send feedback',
|
|
207
|
+
category: 'support',
|
|
208
|
+
usage: '/report [title]',
|
|
209
|
+
viewerSafe: true,
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
id: 'bug',
|
|
213
|
+
label: '/bug',
|
|
214
|
+
description: 'Report a bug (alias for /report)',
|
|
215
|
+
category: 'support',
|
|
216
|
+
usage: '/bug [title]',
|
|
217
|
+
viewerSafe: true,
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
id: 'version',
|
|
221
|
+
label: '/version',
|
|
222
|
+
// Host-neutral: carries NO version number (the registry is also rendered into
|
|
223
|
+
// the molecule.dev API system prompt, which can't reach the IDE's version). The
|
|
224
|
+
// IDE menu appends the live version as an inline suffix at its render site —
|
|
225
|
+
// same mechanism as /model's `(Claude)` / /maxloops's `(50)`. See ChatPanel.
|
|
226
|
+
description: 'Show the app version',
|
|
227
|
+
category: 'support',
|
|
228
|
+
viewerSafe: true,
|
|
229
|
+
},
|
|
230
|
+
];
|
|
231
|
+
/**
|
|
232
|
+
* Groups commands under their categories, preserving category and command
|
|
233
|
+
* order and dropping empty categories. Used by the `/settings` command
|
|
234
|
+
* reference (and any other view that lists commands by section) so the
|
|
235
|
+
* grouping stays in sync with the registry automatically.
|
|
236
|
+
*
|
|
237
|
+
* @param commands - Command registry to group (defaults to {@link COMMANDS}).
|
|
238
|
+
* @param categories - Ordered categories (defaults to {@link COMMAND_CATEGORIES}).
|
|
239
|
+
* @returns One {@link CommandGroup} per non-empty category, in category order.
|
|
240
|
+
*/
|
|
241
|
+
export function groupCommandsByCategory(commands = COMMANDS, categories = COMMAND_CATEGORIES) {
|
|
242
|
+
const groups = [];
|
|
243
|
+
for (const category of categories) {
|
|
244
|
+
const inCategory = commands.filter((c) => c.category === category.key);
|
|
245
|
+
if (inCategory.length > 0)
|
|
246
|
+
groups.push({ category, commands: inCategory });
|
|
247
|
+
}
|
|
248
|
+
return groups;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* True when `text` invokes a side-channel command ({@link CommandDef.sideChannel})
|
|
252
|
+
* from `defs`, matched against the leading `/token` by command id or alias
|
|
253
|
+
* (case-insensitive). Used by the chat input's dispatch AND the auto-send
|
|
254
|
+
* (initialMessage) path so a side-channel send never renders an optimistic
|
|
255
|
+
* "/command …" echo — the server's emitted `message` stream event is the one
|
|
256
|
+
* visible message.
|
|
257
|
+
*
|
|
258
|
+
* @param defs - The command registry to consult (e.g. shared ∪ host commands).
|
|
259
|
+
* @param text - The raw outgoing message text.
|
|
260
|
+
* @returns Whether the text invokes a side-channel command.
|
|
261
|
+
*/
|
|
262
|
+
export function matchesSideChannelCommand(defs, text) {
|
|
263
|
+
const token = text
|
|
264
|
+
.trim()
|
|
265
|
+
.match(/^\/(\S+)(?:\s|$)/)?.[1]
|
|
266
|
+
?.toLowerCase();
|
|
267
|
+
if (!token)
|
|
268
|
+
return false;
|
|
269
|
+
return !!defs?.some((c) => c.sideChannel && (c.id.toLowerCase() === token || c.aliases?.includes(token)));
|
|
270
|
+
}
|
|
271
|
+
//# sourceMappingURL=command-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-metadata.js","sourceRoot":"","sources":["../src/command-metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAcH,mEAAmE;AACnE,MAAM,CAAC,MAAM,kBAAkB,GAA+B;IAC5D,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;IACpC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;IAC9B,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,EAAE;IAC5C,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE;IAChC,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE;IACtC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE;CAC5B,CAAA;AAmDV;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAA0B;IAC7C,UAAU;IACV,EAAE,EAAE,EAA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C"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for dev-capture Activity cards and the Activity panel.
|
|
3
|
+
*
|
|
4
|
+
* The chat handler streams an `activity` SSE event for every captured outbound
|
|
5
|
+
* side effect (email/sms/push/webhook/channel). These helpers turn that event
|
|
6
|
+
* into the bits of UI state the inline card and the panel render — themed-icon
|
|
7
|
+
* name, one-line summary, status-pill styling — without any React/DOM dependency
|
|
8
|
+
* so they can be unit-tested in a node environment.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import type { IconName } from '@molecule/app-icons';
|
|
13
|
+
/** Channel categories a captured activity can belong to. */
|
|
14
|
+
export type ActivityType = 'email' | 'sms' | 'push' | 'webhook' | 'channel';
|
|
15
|
+
/** Lifecycle status of a captured activity. */
|
|
16
|
+
export type ActivityStatus = 'captured' | 'sent' | 'delivered' | 'failed';
|
|
17
|
+
/**
|
|
18
|
+
* A single captured activity. Mirrors the SSE `activity.activity` payload; the
|
|
19
|
+
* REST list endpoint additionally returns `payload` and `result` for the
|
|
20
|
+
* expanded detail view.
|
|
21
|
+
*/
|
|
22
|
+
export interface Activity {
|
|
23
|
+
id: string;
|
|
24
|
+
type: ActivityType;
|
|
25
|
+
status: ActivityStatus;
|
|
26
|
+
recipient?: string;
|
|
27
|
+
summary?: string;
|
|
28
|
+
/** ISO 8601 timestamp. */
|
|
29
|
+
timestamp: string;
|
|
30
|
+
/** Full captured payload — only present on the REST detail response (dev only). */
|
|
31
|
+
payload?: unknown;
|
|
32
|
+
/** Provider result / synthetic success record — only present on the REST detail response. */
|
|
33
|
+
result?: unknown;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Returns the bonded-icon-set glyph NAME for an activity type — pass it to
|
|
37
|
+
* `<Icon name={…} />` to render the themed SVG. Unknown/future types (which
|
|
38
|
+
* {@link activityFromEvent} normalizes to `webhook`) reuse the `link` glyph
|
|
39
|
+
* rather than risk a `getIcon` throw.
|
|
40
|
+
* @param type - The activity channel type.
|
|
41
|
+
* @returns The icon-set glyph name for the type.
|
|
42
|
+
*/
|
|
43
|
+
export declare function activityIconName(type: ActivityType): IconName;
|
|
44
|
+
/**
|
|
45
|
+
* Human-readable, translated label for a channel type (used as filter-tab labels).
|
|
46
|
+
* @param type - The activity channel type.
|
|
47
|
+
* @returns The translated channel label.
|
|
48
|
+
*/
|
|
49
|
+
export declare function activityTypeLabel(type: ActivityType): string;
|
|
50
|
+
/**
|
|
51
|
+
* Human-readable, translated label for a status (shown in the status pill).
|
|
52
|
+
* @param status - The activity status.
|
|
53
|
+
* @returns The translated status label.
|
|
54
|
+
*/
|
|
55
|
+
export declare function activityStatusLabel(status: ActivityStatus): string;
|
|
56
|
+
/**
|
|
57
|
+
* Resolves the status-pill colors for a given status. Uses RGBA literals (not
|
|
58
|
+
* ClassMap classes) because these semantic status hues are not part of the
|
|
59
|
+
* surface/text token set — the same approach `VerificationBadge` takes for its
|
|
60
|
+
* pass/fail coloring.
|
|
61
|
+
* @param status - The activity status.
|
|
62
|
+
* @returns An object with `fg` (text) and `bg` (background) CSS color strings.
|
|
63
|
+
*/
|
|
64
|
+
export declare function activityStatusColors(status: ActivityStatus): {
|
|
65
|
+
fg: string;
|
|
66
|
+
bg: string;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Builds the one-line summary shown on the inline card: the activity's own
|
|
70
|
+
* summary, with the recipient appended after an arrow when present
|
|
71
|
+
* (e.g. `Welcome email → user@example.com`). Falls back to a translated,
|
|
72
|
+
* type-specific default when no summary was captured.
|
|
73
|
+
* @param activity - The activity to summarize.
|
|
74
|
+
* @returns The single-line summary string.
|
|
75
|
+
*/
|
|
76
|
+
export declare function activitySummaryLine(activity: Pick<Activity, 'type' | 'recipient' | 'summary'>): string;
|
|
77
|
+
/**
|
|
78
|
+
* Maps a raw SSE `activity` event payload into a normalized {@link Activity}.
|
|
79
|
+
* Tolerates missing optional fields and supplies an id/timestamp if absent.
|
|
80
|
+
* @param raw - The `activity` field from the SSE event.
|
|
81
|
+
* @param raw.id - Activity id; generated if absent.
|
|
82
|
+
* @param raw.type - Channel type; defaults to `webhook` if absent.
|
|
83
|
+
* @param raw.status - Lifecycle status; defaults to `captured` if absent.
|
|
84
|
+
* @param raw.recipient - Optional recipient.
|
|
85
|
+
* @param raw.summary - Optional short summary.
|
|
86
|
+
* @param raw.timestamp - ISO timestamp; defaults to now if absent.
|
|
87
|
+
* @returns A normalized Activity object.
|
|
88
|
+
*/
|
|
89
|
+
export declare function activityFromEvent(raw: {
|
|
90
|
+
id?: string;
|
|
91
|
+
type?: string;
|
|
92
|
+
status?: string;
|
|
93
|
+
recipient?: string;
|
|
94
|
+
summary?: string;
|
|
95
|
+
timestamp?: string;
|
|
96
|
+
}): Activity;
|
|
97
|
+
/** All channel types, in the order their filter tabs should appear. */
|
|
98
|
+
export declare const ACTIVITY_TYPES: ActivityType[];
|
|
99
|
+
/**
|
|
100
|
+
* Filters a list of activities by channel type. `null` (the "All" tab) returns
|
|
101
|
+
* every activity unchanged.
|
|
102
|
+
* @param activities - The activities to filter.
|
|
103
|
+
* @param type - The channel type to keep, or `null` for all.
|
|
104
|
+
* @returns The filtered list (a new array unless `type` is null).
|
|
105
|
+
*/
|
|
106
|
+
export declare function filterActivitiesByType(activities: Activity[], type: ActivityType | null): Activity[];
|
|
107
|
+
//# sourceMappingURL=activity-utilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activity-utilities.d.ts","sourceRoot":"","sources":["../../src/components/activity-utilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEnD,4DAA4D;AAC5D,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAA;AAE3E,+CAA+C;AAC/C,MAAM,MAAM,cAAc,GA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