@rise-x/apps-sdk 0.6.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/LICENSE +1 -0
- package/README.md +553 -0
- package/build/_internal.d.ts +2 -0
- package/build/_internal.js +23 -0
- package/build/accessors.d.ts +8 -0
- package/build/accessors.js +40 -0
- package/build/cli/index.d.ts +13 -0
- package/build/cli/index.js +54 -0
- package/build/cli/init.d.ts +6 -0
- package/build/cli/init.js +179 -0
- package/build/cli/templating.d.ts +2 -0
- package/build/cli/templating.js +84 -0
- package/build/connectors/agents.d.ts +85 -0
- package/build/connectors/agents.js +404 -0
- package/build/connectors/assets.d.ts +76 -0
- package/build/connectors/assets.js +204 -0
- package/build/connectors/deps.d.ts +4 -0
- package/build/connectors/deps.js +2 -0
- package/build/connectors/errors.d.ts +11 -0
- package/build/connectors/errors.js +67 -0
- package/build/connectors/flows.d.ts +37 -0
- package/build/connectors/flows.js +191 -0
- package/build/connectors/index.d.ts +8 -0
- package/build/connectors/index.js +50 -0
- package/build/connectors/sse.d.ts +12 -0
- package/build/connectors/sse.js +157 -0
- package/build/connectors/types.d.ts +285 -0
- package/build/connectors/types.js +419 -0
- package/build/connectors/work.d.ts +84 -0
- package/build/connectors/work.js +224 -0
- package/build/hooks.d.ts +4 -0
- package/build/hooks.js +28 -0
- package/build/index.d.ts +6 -0
- package/build/index.js +34 -0
- package/build/lifecycle.d.ts +23 -0
- package/build/lifecycle.js +6 -0
- package/build/mockShell.d.ts +10 -0
- package/build/mockShell.js +55 -0
- package/build/query/agents.d.ts +80 -0
- package/build/query/agents.js +143 -0
- package/build/query/assets.d.ts +73 -0
- package/build/query/assets.js +152 -0
- package/build/query/client.d.ts +5 -0
- package/build/query/client.js +68 -0
- package/build/query/context.d.ts +2 -0
- package/build/query/context.js +34 -0
- package/build/query/flows.d.ts +54 -0
- package/build/query/flows.js +81 -0
- package/build/query/index.d.ts +10 -0
- package/build/query/index.js +85 -0
- package/build/query/keys.d.ts +51 -0
- package/build/query/keys.js +79 -0
- package/build/query/layer.d.ts +175 -0
- package/build/query/layer.js +35 -0
- package/build/query/shared.d.ts +43 -0
- package/build/query/shared.js +116 -0
- package/build/query/work.d.ts +75 -0
- package/build/query/work.js +172 -0
- package/build/shell/index.d.ts +1 -0
- package/build/shell/index.js +6 -0
- package/build/shell/installShellBridge.d.ts +11 -0
- package/build/shell/installShellBridge.js +104 -0
- package/build/shellBridge.d.ts +36 -0
- package/build/shellBridge.js +10 -0
- package/build/topBar.d.ts +25 -0
- package/build/topBar.js +17 -0
- package/build/ui/components/ai.d.ts +49 -0
- package/build/ui/components/alert-dialog.d.ts +27 -0
- package/build/ui/components/alert.d.ts +14 -0
- package/build/ui/components/avatar.d.ts +17 -0
- package/build/ui/components/badge.d.ts +19 -0
- package/build/ui/components/button.d.ts +13 -0
- package/build/ui/components/calendar.d.ts +21 -0
- package/build/ui/components/card.d.ts +16 -0
- package/build/ui/components/chart.d.ts +124 -0
- package/build/ui/components/checkbox.d.ts +4 -0
- package/build/ui/components/data-table.d.ts +70 -0
- package/build/ui/components/dialog.d.ts +17 -0
- package/build/ui/components/dropdown-menu.d.ts +29 -0
- package/build/ui/components/empty-state.d.ts +7 -0
- package/build/ui/components/file-upload.d.ts +17 -0
- package/build/ui/components/input.d.ts +8 -0
- package/build/ui/components/label.d.ts +4 -0
- package/build/ui/components/list.d.ts +24 -0
- package/build/ui/components/map.d.ts +26 -0
- package/build/ui/components/message.d.ts +24 -0
- package/build/ui/components/nav.d.ts +12 -0
- package/build/ui/components/page-header.d.ts +27 -0
- package/build/ui/components/popover.d.ts +10 -0
- package/build/ui/components/progress.d.ts +4 -0
- package/build/ui/components/radio.d.ts +6 -0
- package/build/ui/components/resizable.d.ts +7 -0
- package/build/ui/components/scroll-area.d.ts +5 -0
- package/build/ui/components/segmented.d.ts +6 -0
- package/build/ui/components/select.d.ts +15 -0
- package/build/ui/components/separator.d.ts +4 -0
- package/build/ui/components/sheet.d.ts +14 -0
- package/build/ui/components/skeleton.d.ts +3 -0
- package/build/ui/components/slider.d.ts +15 -0
- package/build/ui/components/snackbar.d.ts +3 -0
- package/build/ui/components/sonner.d.ts +4 -0
- package/build/ui/components/spinner.d.ts +5 -0
- package/build/ui/components/statistic.d.ts +19 -0
- package/build/ui/components/stepper.d.ts +12 -0
- package/build/ui/components/switch.d.ts +6 -0
- package/build/ui/components/table.d.ts +24 -0
- package/build/ui/components/textarea.d.ts +3 -0
- package/build/ui/components/timeline.d.ts +15 -0
- package/build/ui/components/toggle-group.d.ts +10 -0
- package/build/ui/components/toggle.d.ts +9 -0
- package/build/ui/components/tooltip.d.ts +7 -0
- package/build/ui/index.d.ts +46 -0
- package/build/ui/index.js +8 -0
- package/build/ui/lib/utils.d.ts +2 -0
- package/build/ui/reference/README.md +11 -0
- package/build/ui/reference/components/ai.tsx +291 -0
- package/build/ui/reference/components/alert-dialog.tsx +208 -0
- package/build/ui/reference/components/alert.tsx +112 -0
- package/build/ui/reference/components/avatar.tsx +158 -0
- package/build/ui/reference/components/badge.tsx +160 -0
- package/build/ui/reference/components/button.tsx +100 -0
- package/build/ui/reference/components/calendar.tsx +119 -0
- package/build/ui/reference/components/card.tsx +144 -0
- package/build/ui/reference/components/chart.tsx +1394 -0
- package/build/ui/reference/components/checkbox.tsx +44 -0
- package/build/ui/reference/components/data-table.tsx +480 -0
- package/build/ui/reference/components/dialog.tsx +172 -0
- package/build/ui/reference/components/dropdown-menu.tsx +245 -0
- package/build/ui/reference/components/empty-state.tsx +63 -0
- package/build/ui/reference/components/file-upload.tsx +116 -0
- package/build/ui/reference/components/input.tsx +114 -0
- package/build/ui/reference/components/label.tsx +19 -0
- package/build/ui/reference/components/list.tsx +191 -0
- package/build/ui/reference/components/map.css +251 -0
- package/build/ui/reference/components/map.tsx +294 -0
- package/build/ui/reference/components/message.tsx +171 -0
- package/build/ui/reference/components/nav.tsx +113 -0
- package/build/ui/reference/components/page-header.tsx +213 -0
- package/build/ui/reference/components/popover.tsx +76 -0
- package/build/ui/reference/components/progress.tsx +31 -0
- package/build/ui/reference/components/radio.tsx +65 -0
- package/build/ui/reference/components/resizable.tsx +40 -0
- package/build/ui/reference/components/scroll-area.tsx +55 -0
- package/build/ui/reference/components/segmented.tsx +45 -0
- package/build/ui/reference/components/select.tsx +185 -0
- package/build/ui/reference/components/separator.tsx +26 -0
- package/build/ui/reference/components/sheet.tsx +173 -0
- package/build/ui/reference/components/skeleton.tsx +15 -0
- package/build/ui/reference/components/slider.tsx +161 -0
- package/build/ui/reference/components/snackbar.tsx +27 -0
- package/build/ui/reference/components/sonner.tsx +43 -0
- package/build/ui/reference/components/spinner.tsx +27 -0
- package/build/ui/reference/components/statistic.tsx +122 -0
- package/build/ui/reference/components/stepper.tsx +138 -0
- package/build/ui/reference/components/switch.tsx +47 -0
- package/build/ui/reference/components/table.tsx +233 -0
- package/build/ui/reference/components/textarea.tsx +28 -0
- package/build/ui/reference/components/timeline.tsx +94 -0
- package/build/ui/reference/components/toggle-group.tsx +86 -0
- package/build/ui/reference/components/toggle.tsx +46 -0
- package/build/ui/reference/components/tooltip.tsx +53 -0
- package/build/ui/reference/index.ts +49 -0
- package/build/ui/reference/lib/utils.ts +34 -0
- package/build/ui/standalone-stub.js +5 -0
- package/build/ui/standalone.js +135 -0
- package/build/ui/styles.css +3 -0
- package/connectors/package.json +8 -0
- package/package.json +114 -0
- package/query/package.json +8 -0
- package/shell/package.json +8 -0
- package/template/AGENTS.md +70 -0
- package/template/CLAUDE.md +4 -0
- package/template/README.md +102 -0
- package/template/_gitignore +6 -0
- package/template/commitlint.config.js +12 -0
- package/template/package.json +31 -0
- package/template/public/index.html +13 -0
- package/template/src/App.tsx +171 -0
- package/template/src/bootstrap.tsx +13 -0
- package/template/src/index.tsx +1 -0
- package/template/src/lifecycle.ts +20 -0
- package/template/tsconfig.json +31 -0
- package/template/webpack.config.js +112 -0
- package/template/webpack.local.config.js +68 -0
- package/ui/package.json +8 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
export type FlowStatus = "Active" | "Archived" | "Deleted";
|
|
2
|
+
export interface FlowSummary {
|
|
3
|
+
id: string;
|
|
4
|
+
flowOriginId: string;
|
|
5
|
+
name: string;
|
|
6
|
+
displayName: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
status?: FlowStatus;
|
|
9
|
+
}
|
|
10
|
+
export interface FlowAction {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
displayName: string;
|
|
14
|
+
stepId: string;
|
|
15
|
+
canExecute: boolean;
|
|
16
|
+
eventName?: string;
|
|
17
|
+
submitUri?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface FlowStep {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
displayName: string;
|
|
23
|
+
isActive?: boolean;
|
|
24
|
+
isComplete?: boolean;
|
|
25
|
+
isEndNode?: boolean;
|
|
26
|
+
steps: FlowStep[];
|
|
27
|
+
actions: FlowAction[];
|
|
28
|
+
}
|
|
29
|
+
export interface Flow extends FlowSummary {
|
|
30
|
+
steps: FlowStep[];
|
|
31
|
+
activeStepId?: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function mapFlowSummary(value: unknown): FlowSummary;
|
|
34
|
+
export declare function mapFlowAction(value: unknown): FlowAction;
|
|
35
|
+
export declare function mapFlowStep(value: unknown): FlowStep;
|
|
36
|
+
export declare function mapFlow(value: unknown, steps?: unknown[]): Flow;
|
|
37
|
+
export interface FlowConfigTask {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
layoutId?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface FlowConfigStep {
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
tasks: FlowConfigTask[];
|
|
46
|
+
}
|
|
47
|
+
export interface FlowConfig {
|
|
48
|
+
flowId: string;
|
|
49
|
+
steps: FlowConfigStep[];
|
|
50
|
+
nameMap: Map<string, string>;
|
|
51
|
+
}
|
|
52
|
+
export declare function mapFlowConfig(flowId: string, value: unknown): FlowConfig;
|
|
53
|
+
export interface LayoutComponent {
|
|
54
|
+
component: string;
|
|
55
|
+
name?: string;
|
|
56
|
+
label?: string | null;
|
|
57
|
+
dataPath?: string;
|
|
58
|
+
components?: LayoutComponent[];
|
|
59
|
+
}
|
|
60
|
+
export interface Layout {
|
|
61
|
+
id: string;
|
|
62
|
+
components: LayoutComponent[];
|
|
63
|
+
}
|
|
64
|
+
export interface LayoutField {
|
|
65
|
+
label: string;
|
|
66
|
+
type: string;
|
|
67
|
+
dataPath: string;
|
|
68
|
+
}
|
|
69
|
+
export declare function mapLayout(layoutId: string, value: unknown): Layout;
|
|
70
|
+
export interface WorkRow {
|
|
71
|
+
id: string;
|
|
72
|
+
displayName: string;
|
|
73
|
+
workCode?: string;
|
|
74
|
+
activeStepId?: string;
|
|
75
|
+
data?: Record<string, unknown>;
|
|
76
|
+
}
|
|
77
|
+
export declare function mapWorkRow(value: unknown): WorkRow;
|
|
78
|
+
export interface WorkAction {
|
|
79
|
+
id?: string;
|
|
80
|
+
name?: string;
|
|
81
|
+
displayName?: string;
|
|
82
|
+
eventName?: string;
|
|
83
|
+
canExecute?: boolean;
|
|
84
|
+
}
|
|
85
|
+
export interface WorkDetail {
|
|
86
|
+
id: string;
|
|
87
|
+
code?: string;
|
|
88
|
+
name?: string;
|
|
89
|
+
displayName: string;
|
|
90
|
+
flowId?: string;
|
|
91
|
+
flowOriginId?: string;
|
|
92
|
+
status?: string;
|
|
93
|
+
state?: string;
|
|
94
|
+
actions: WorkAction[];
|
|
95
|
+
}
|
|
96
|
+
export declare function mapWorkDetail(value: unknown): WorkDetail;
|
|
97
|
+
export interface WorkAuditFieldUpdate {
|
|
98
|
+
path: string;
|
|
99
|
+
fromValue?: string;
|
|
100
|
+
toValue?: string;
|
|
101
|
+
timeStamp?: string;
|
|
102
|
+
}
|
|
103
|
+
export interface WorkAuditEvent {
|
|
104
|
+
timeStamp?: string;
|
|
105
|
+
user: {
|
|
106
|
+
displayName?: string;
|
|
107
|
+
email?: string;
|
|
108
|
+
} | null;
|
|
109
|
+
activity: {
|
|
110
|
+
type: string;
|
|
111
|
+
taskName?: string | null;
|
|
112
|
+
message?: string | null;
|
|
113
|
+
fieldUpdates?: WorkAuditFieldUpdate[] | null;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
export declare function mapWorkAuditEvent(value: unknown): WorkAuditEvent;
|
|
117
|
+
export interface AssetType {
|
|
118
|
+
entityType: string;
|
|
119
|
+
displayName: string;
|
|
120
|
+
total: number;
|
|
121
|
+
imageUrl?: string;
|
|
122
|
+
flow: FlowSummary | null;
|
|
123
|
+
}
|
|
124
|
+
export declare function mapAssetType(value: unknown): AssetType;
|
|
125
|
+
export interface AssetSummary {
|
|
126
|
+
id: string;
|
|
127
|
+
displayName: string;
|
|
128
|
+
entityType?: string;
|
|
129
|
+
originId?: string;
|
|
130
|
+
flowOriginId?: string;
|
|
131
|
+
code?: string;
|
|
132
|
+
imageUrl?: string;
|
|
133
|
+
activeStepId?: string;
|
|
134
|
+
data?: Record<string, unknown>;
|
|
135
|
+
}
|
|
136
|
+
export declare function mapAssetSummary(value: unknown): AssetSummary;
|
|
137
|
+
export interface AssetRelationship {
|
|
138
|
+
id?: string;
|
|
139
|
+
name: string;
|
|
140
|
+
entityId: string;
|
|
141
|
+
dataType?: number;
|
|
142
|
+
code?: string;
|
|
143
|
+
flowOriginId?: string;
|
|
144
|
+
workName?: string;
|
|
145
|
+
}
|
|
146
|
+
export interface AssetDetail extends AssetSummary {
|
|
147
|
+
canEdit?: boolean;
|
|
148
|
+
canDelete?: boolean;
|
|
149
|
+
canClone?: boolean;
|
|
150
|
+
draftWorkId?: string;
|
|
151
|
+
relationships: AssetRelationship[];
|
|
152
|
+
}
|
|
153
|
+
export declare function mapAssetDetail(value: unknown): AssetDetail;
|
|
154
|
+
export type McpTransport = "Http" | "Sse" | "Stdio";
|
|
155
|
+
export type McpAuthType = "None" | "Bearer" | "ApiKey" | "CallerToken";
|
|
156
|
+
export interface McpServerConfig {
|
|
157
|
+
name: string;
|
|
158
|
+
url: string;
|
|
159
|
+
transport: McpTransport;
|
|
160
|
+
authType: McpAuthType;
|
|
161
|
+
apiKey?: string | null;
|
|
162
|
+
headers?: Record<string, string> | null;
|
|
163
|
+
}
|
|
164
|
+
export interface OpenAiToolConfig {
|
|
165
|
+
name: string;
|
|
166
|
+
config?: Record<string, unknown> | null;
|
|
167
|
+
}
|
|
168
|
+
export interface RiseAgent {
|
|
169
|
+
id: string;
|
|
170
|
+
name: string;
|
|
171
|
+
description?: string | null;
|
|
172
|
+
systemPrompt?: string | null;
|
|
173
|
+
model: string;
|
|
174
|
+
mcpServers: McpServerConfig[];
|
|
175
|
+
defaultOpenAiTools: OpenAiToolConfig[];
|
|
176
|
+
environmentId?: string;
|
|
177
|
+
createdAt?: string;
|
|
178
|
+
createdBy?: string;
|
|
179
|
+
lastModified?: string;
|
|
180
|
+
lastModifiedBy?: string;
|
|
181
|
+
}
|
|
182
|
+
export interface AgentCreateInput {
|
|
183
|
+
name: string;
|
|
184
|
+
model: string;
|
|
185
|
+
description?: string;
|
|
186
|
+
systemPrompt?: string;
|
|
187
|
+
mcpServers?: McpServerConfig[];
|
|
188
|
+
defaultOpenAiTools?: OpenAiToolConfig[];
|
|
189
|
+
}
|
|
190
|
+
export type AgentPatch = Partial<AgentCreateInput>;
|
|
191
|
+
export interface AgentPage {
|
|
192
|
+
items: RiseAgent[];
|
|
193
|
+
page: number;
|
|
194
|
+
pageSize: number;
|
|
195
|
+
total?: number;
|
|
196
|
+
}
|
|
197
|
+
export declare function mapMcpServerConfig(value: unknown): McpServerConfig;
|
|
198
|
+
export declare function mapAgent(value: unknown): RiseAgent;
|
|
199
|
+
export declare function mapAgentPage(raw: unknown, fallback: {
|
|
200
|
+
page: number;
|
|
201
|
+
pageSize: number;
|
|
202
|
+
}): AgentPage;
|
|
203
|
+
export interface AgentRunEvent<TData = unknown> {
|
|
204
|
+
event: string;
|
|
205
|
+
id?: string;
|
|
206
|
+
data: TData;
|
|
207
|
+
}
|
|
208
|
+
export declare const AGENT_EVENT = "agent_event";
|
|
209
|
+
export declare const AGENT_END_OF_STREAM = "end_of_stream";
|
|
210
|
+
export declare const AGENT_ERROR = "error";
|
|
211
|
+
export type AgentEventType = "MESSAGE" | "REASONING" | "TOOL_CALL" | "HANDOFF";
|
|
212
|
+
export interface AgentToolCall {
|
|
213
|
+
tool_name?: string;
|
|
214
|
+
result?: string;
|
|
215
|
+
status?: string;
|
|
216
|
+
}
|
|
217
|
+
export interface AgentEventData {
|
|
218
|
+
event_type?: AgentEventType;
|
|
219
|
+
text?: string;
|
|
220
|
+
item_id?: string;
|
|
221
|
+
agent_name?: string;
|
|
222
|
+
conversation_id?: string;
|
|
223
|
+
is_chunk_completed?: boolean;
|
|
224
|
+
is_final?: boolean;
|
|
225
|
+
tool_call?: AgentToolCall;
|
|
226
|
+
handoff_agent?: string;
|
|
227
|
+
}
|
|
228
|
+
export type AgentRunEndReason = "COMPLETED" | "TIMEOUT" | "CANCELLED" | "ERROR";
|
|
229
|
+
export interface AgentEndData {
|
|
230
|
+
reason?: AgentRunEndReason;
|
|
231
|
+
chat_id?: string | null;
|
|
232
|
+
timestamp?: number;
|
|
233
|
+
}
|
|
234
|
+
export interface AgentErrorData {
|
|
235
|
+
error?: string;
|
|
236
|
+
code?: string;
|
|
237
|
+
}
|
|
238
|
+
export interface AgentChat {
|
|
239
|
+
id: string;
|
|
240
|
+
agentId: string;
|
|
241
|
+
agentName: string;
|
|
242
|
+
title: string;
|
|
243
|
+
summary?: string;
|
|
244
|
+
lastSeq: number;
|
|
245
|
+
createdAt?: string;
|
|
246
|
+
lastModified?: string;
|
|
247
|
+
lastMessageAt?: string;
|
|
248
|
+
}
|
|
249
|
+
export interface AgentChatPage {
|
|
250
|
+
items: AgentChat[];
|
|
251
|
+
page: number;
|
|
252
|
+
pageSize: number;
|
|
253
|
+
total?: number;
|
|
254
|
+
}
|
|
255
|
+
export interface AgentChatMessage {
|
|
256
|
+
id: string;
|
|
257
|
+
chatId: string;
|
|
258
|
+
seq: number;
|
|
259
|
+
turnId: string;
|
|
260
|
+
itemType: string;
|
|
261
|
+
role?: string;
|
|
262
|
+
text?: string;
|
|
263
|
+
toolName?: string;
|
|
264
|
+
callId?: string;
|
|
265
|
+
arguments?: string;
|
|
266
|
+
result?: string;
|
|
267
|
+
createdAt?: string;
|
|
268
|
+
}
|
|
269
|
+
export declare function mapAgentChat(value: unknown): AgentChat;
|
|
270
|
+
export declare function mapAgentChatPage(raw: unknown, fallback: {
|
|
271
|
+
page: number;
|
|
272
|
+
pageSize: number;
|
|
273
|
+
}): AgentChatPage;
|
|
274
|
+
export declare function mapAgentChatMessage(value: unknown, chatId?: string): AgentChatMessage;
|
|
275
|
+
export interface AgentChatMessagePage {
|
|
276
|
+
items: AgentChatMessage[];
|
|
277
|
+
fromSeq?: number;
|
|
278
|
+
pageSize: number;
|
|
279
|
+
nextSeq?: number;
|
|
280
|
+
}
|
|
281
|
+
export declare function mapAgentChatMessagePage(raw: unknown, fallback: {
|
|
282
|
+
fromSeq?: number;
|
|
283
|
+
pageSize: number;
|
|
284
|
+
chatId?: string;
|
|
285
|
+
}): AgentChatMessagePage;
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Slim, closed DTOs for the connector layer plus the raw→DTO mappers.
|
|
3
|
+
//
|
|
4
|
+
// The platform's full models live in @diana/core, which federated apps must not
|
|
5
|
+
// import — so we re-declare only the fields that are (a) verified against the
|
|
6
|
+
// deployed v3/v4 responses (cross-checked with apps/work-audit and
|
|
7
|
+
// apps/bwo-insights, the two apps consuming these endpoints today) and (b)
|
|
8
|
+
// actually needed by the connector use cases. Runtime objects carry more
|
|
9
|
+
// fields; apps that accept the risk can cast. Every response passes through a
|
|
10
|
+
// tolerant mapX() so shape drift is contained in this one file.
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AGENT_ERROR = exports.AGENT_END_OF_STREAM = exports.AGENT_EVENT = void 0;
|
|
13
|
+
exports.mapFlowSummary = mapFlowSummary;
|
|
14
|
+
exports.mapFlowAction = mapFlowAction;
|
|
15
|
+
exports.mapFlowStep = mapFlowStep;
|
|
16
|
+
exports.mapFlow = mapFlow;
|
|
17
|
+
exports.mapFlowConfig = mapFlowConfig;
|
|
18
|
+
exports.mapLayout = mapLayout;
|
|
19
|
+
exports.mapWorkRow = mapWorkRow;
|
|
20
|
+
exports.mapWorkDetail = mapWorkDetail;
|
|
21
|
+
exports.mapWorkAuditEvent = mapWorkAuditEvent;
|
|
22
|
+
exports.mapAssetType = mapAssetType;
|
|
23
|
+
exports.mapAssetSummary = mapAssetSummary;
|
|
24
|
+
exports.mapAssetDetail = mapAssetDetail;
|
|
25
|
+
exports.mapMcpServerConfig = mapMcpServerConfig;
|
|
26
|
+
exports.mapAgent = mapAgent;
|
|
27
|
+
exports.mapAgentPage = mapAgentPage;
|
|
28
|
+
exports.mapAgentChat = mapAgentChat;
|
|
29
|
+
exports.mapAgentChatPage = mapAgentChatPage;
|
|
30
|
+
exports.mapAgentChatMessage = mapAgentChatMessage;
|
|
31
|
+
exports.mapAgentChatMessagePage = mapAgentChatMessagePage;
|
|
32
|
+
const str = (v) => typeof v === "string" && v !== "" ? v : undefined;
|
|
33
|
+
// Mappers accept `unknown` so call sites can feed raw axios payloads directly;
|
|
34
|
+
// anything non-object maps as an empty record (tolerant by contract).
|
|
35
|
+
const asRecord = (value) => value !== null && typeof value === "object" ? value : {};
|
|
36
|
+
function mapFlowSummary(value) {
|
|
37
|
+
const raw = asRecord(value);
|
|
38
|
+
const id = String(raw.id ?? "");
|
|
39
|
+
return {
|
|
40
|
+
id,
|
|
41
|
+
flowOriginId: str(raw?.flowOriginId) ?? id,
|
|
42
|
+
name: str(raw?.name) ?? id,
|
|
43
|
+
displayName: str(raw?.displayName) ?? str(raw?.name) ?? id,
|
|
44
|
+
description: str(raw?.description),
|
|
45
|
+
status: str(raw?.status),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function mapFlowAction(value) {
|
|
49
|
+
const raw = asRecord(value);
|
|
50
|
+
const id = String(raw.id ?? "");
|
|
51
|
+
return {
|
|
52
|
+
id,
|
|
53
|
+
name: str(raw?.name) ?? id,
|
|
54
|
+
displayName: str(raw?.displayName) ?? str(raw?.name) ?? id,
|
|
55
|
+
stepId: String(raw?.stepId ?? ""),
|
|
56
|
+
canExecute: raw?.canExecute === true,
|
|
57
|
+
eventName: str(raw?.eventName),
|
|
58
|
+
submitUri: str(raw?.submitUri),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function mapFlowStep(value) {
|
|
62
|
+
const raw = asRecord(value);
|
|
63
|
+
const id = String(raw.id ?? "");
|
|
64
|
+
return {
|
|
65
|
+
id,
|
|
66
|
+
name: str(raw?.name) ?? id,
|
|
67
|
+
displayName: str(raw?.displayName) ?? str(raw?.name) ?? id,
|
|
68
|
+
isActive: typeof raw?.isActive === "boolean" ? raw.isActive : undefined,
|
|
69
|
+
isComplete: typeof raw?.isComplete === "boolean" ? raw.isComplete : undefined,
|
|
70
|
+
isEndNode: typeof raw?.isEndNode === "boolean" ? raw.isEndNode : undefined,
|
|
71
|
+
steps: Array.isArray(raw?.steps) ? raw.steps.map(mapFlowStep) : [],
|
|
72
|
+
actions: Array.isArray(raw?.actions) ? raw.actions.map(mapFlowAction) : [],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// `steps` (from GET /api/v3/flow/steps) overrides whatever the flow payload
|
|
76
|
+
// itself carried — same merge the shell's workboard query does.
|
|
77
|
+
function mapFlow(value, steps) {
|
|
78
|
+
const raw = asRecord(value);
|
|
79
|
+
const stepSource = steps ?? (Array.isArray(raw.steps) ? raw.steps : []);
|
|
80
|
+
return {
|
|
81
|
+
...mapFlowSummary(raw),
|
|
82
|
+
activeStepId: str(raw?.activeStepId),
|
|
83
|
+
steps: stepSource.map(mapFlowStep),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// GET /api/v4/config/flow/{id} returns flat {steps: [{stepId, stepName?,
|
|
87
|
+
// stepDisplayName?, taskId, taskName?, taskDisplayName?, layoutId}]} rows;
|
|
88
|
+
// group them by step preserving server order.
|
|
89
|
+
function mapFlowConfig(flowId, value) {
|
|
90
|
+
const raw = asRecord(value);
|
|
91
|
+
const byStep = new Map();
|
|
92
|
+
const order = [];
|
|
93
|
+
const nameMap = new Map();
|
|
94
|
+
const rows = Array.isArray(raw?.steps) ? raw.steps : [];
|
|
95
|
+
for (const row of rows) {
|
|
96
|
+
const stepId = str(row?.stepId);
|
|
97
|
+
if (!stepId)
|
|
98
|
+
continue;
|
|
99
|
+
let step = byStep.get(stepId);
|
|
100
|
+
if (!step) {
|
|
101
|
+
step = {
|
|
102
|
+
id: stepId,
|
|
103
|
+
name: str(row?.stepDisplayName) ?? str(row?.stepName) ?? stepId,
|
|
104
|
+
tasks: [],
|
|
105
|
+
};
|
|
106
|
+
byStep.set(stepId, step);
|
|
107
|
+
order.push(stepId);
|
|
108
|
+
nameMap.set(stepId, step.name);
|
|
109
|
+
}
|
|
110
|
+
const taskId = str(row?.taskId);
|
|
111
|
+
if (taskId && !step.tasks.some((t) => t.id === taskId)) {
|
|
112
|
+
const name = str(row?.taskDisplayName) ?? str(row?.taskName) ?? taskId;
|
|
113
|
+
step.tasks.push({ id: taskId, name, layoutId: str(row?.layoutId) });
|
|
114
|
+
nameMap.set(taskId, name);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return { flowId, steps: order.map((id) => byStep.get(id)), nameMap };
|
|
118
|
+
}
|
|
119
|
+
function mapLayout(layoutId, value) {
|
|
120
|
+
const raw = asRecord(value);
|
|
121
|
+
return {
|
|
122
|
+
id: layoutId,
|
|
123
|
+
components: Array.isArray(raw.components)
|
|
124
|
+
? raw.components
|
|
125
|
+
: [],
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function mapWorkRow(value) {
|
|
129
|
+
const raw = asRecord(value);
|
|
130
|
+
const id = String(raw.id ?? "");
|
|
131
|
+
return {
|
|
132
|
+
id,
|
|
133
|
+
displayName: str(raw?.displayName) ?? str(raw?.workCode) ?? id,
|
|
134
|
+
workCode: str(raw?.workCode),
|
|
135
|
+
activeStepId: str(raw?.activeStepId),
|
|
136
|
+
data: raw?.data && typeof raw.data === "object"
|
|
137
|
+
? raw.data
|
|
138
|
+
: undefined,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function mapWorkDetail(value) {
|
|
142
|
+
const raw = asRecord(value);
|
|
143
|
+
const id = String(raw.id ?? "");
|
|
144
|
+
const actions = Array.isArray(raw.actions) ? raw.actions : [];
|
|
145
|
+
return {
|
|
146
|
+
id,
|
|
147
|
+
code: str(raw?.code),
|
|
148
|
+
name: str(raw?.name),
|
|
149
|
+
displayName: str(raw?.displayName) ?? str(raw?.name) ?? id,
|
|
150
|
+
flowId: str(raw?.flowId),
|
|
151
|
+
flowOriginId: str(raw?.flowOriginId),
|
|
152
|
+
status: str(raw?.status),
|
|
153
|
+
state: str(raw?.state),
|
|
154
|
+
actions: actions.map((a) => ({
|
|
155
|
+
id: str(a?.id),
|
|
156
|
+
name: str(a?.name),
|
|
157
|
+
displayName: str(a?.displayName),
|
|
158
|
+
eventName: str(a?.eventName),
|
|
159
|
+
canExecute: typeof a?.canExecute === "boolean" ? a.canExecute : undefined,
|
|
160
|
+
})),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function mapWorkAuditEvent(value) {
|
|
164
|
+
const raw = asRecord(value);
|
|
165
|
+
const activity = raw.activity && typeof raw.activity === "object" ? raw.activity : {};
|
|
166
|
+
const updates = Array.isArray(activity?.fieldUpdates)
|
|
167
|
+
? activity.fieldUpdates
|
|
168
|
+
: [];
|
|
169
|
+
return {
|
|
170
|
+
timeStamp: str(raw?.timeStamp),
|
|
171
|
+
user: raw?.user && typeof raw.user === "object"
|
|
172
|
+
? { displayName: str(raw.user.displayName), email: str(raw.user.email) }
|
|
173
|
+
: null,
|
|
174
|
+
activity: {
|
|
175
|
+
type: str(activity?.type) ?? "",
|
|
176
|
+
taskName: str(activity?.taskName) ?? null,
|
|
177
|
+
message: str(activity?.message) ?? null,
|
|
178
|
+
fieldUpdates: updates.map((u) => ({
|
|
179
|
+
path: String(u?.path ?? ""),
|
|
180
|
+
fromValue: str(u?.fromValue),
|
|
181
|
+
toValue: str(u?.toValue),
|
|
182
|
+
timeStamp: str(u?.timeStamp),
|
|
183
|
+
})),
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function mapAssetType(value) {
|
|
188
|
+
const raw = asRecord(value);
|
|
189
|
+
const entityType = str(raw.entityType) ?? "";
|
|
190
|
+
return {
|
|
191
|
+
entityType,
|
|
192
|
+
displayName: str(raw?.displayName) ?? entityType,
|
|
193
|
+
total: typeof raw?.totalList === "number" ? raw.totalList : 0,
|
|
194
|
+
imageUrl: str(raw?.imageUrl),
|
|
195
|
+
flow: raw?.flow && typeof raw.flow === "object"
|
|
196
|
+
? mapFlowSummary(raw.flow)
|
|
197
|
+
: null,
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function mapAssetSummary(value) {
|
|
201
|
+
const raw = asRecord(value);
|
|
202
|
+
const id = String(raw.id ?? "");
|
|
203
|
+
return {
|
|
204
|
+
id,
|
|
205
|
+
displayName: str(raw?.displayName) ?? str(raw?.name) ?? id,
|
|
206
|
+
entityType: str(raw?.entityType),
|
|
207
|
+
originId: str(raw?.originId),
|
|
208
|
+
flowOriginId: str(raw?.flowOriginId),
|
|
209
|
+
code: str(raw?.code) ?? str(raw?.workCode),
|
|
210
|
+
imageUrl: str(raw?.imageUrl) ?? str(raw?.imageUri),
|
|
211
|
+
activeStepId: str(raw?.activeStepId),
|
|
212
|
+
data: raw?.data && typeof raw.data === "object"
|
|
213
|
+
? raw.data
|
|
214
|
+
: undefined,
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
const bool = (v) => typeof v === "boolean" ? v : undefined;
|
|
218
|
+
function mapAssetDetail(value) {
|
|
219
|
+
const raw = asRecord(value);
|
|
220
|
+
const relationships = Array.isArray(raw?.relationships)
|
|
221
|
+
? raw.relationships
|
|
222
|
+
: [];
|
|
223
|
+
return {
|
|
224
|
+
...mapAssetSummary(raw),
|
|
225
|
+
canEdit: bool(raw?.canEdit),
|
|
226
|
+
canDelete: bool(raw?.canDelete),
|
|
227
|
+
canClone: bool(raw?.canClone),
|
|
228
|
+
draftWorkId: str(raw?.draftWorkId),
|
|
229
|
+
relationships: relationships.map((r) => ({
|
|
230
|
+
id: str(r?.id),
|
|
231
|
+
name: str(r?.name) ?? "",
|
|
232
|
+
entityId: String(r?.entityId ?? ""),
|
|
233
|
+
dataType: typeof r?.entityType === "number" ? r.entityType : undefined,
|
|
234
|
+
code: str(r?.code),
|
|
235
|
+
flowOriginId: str(r?.flowOriginId),
|
|
236
|
+
workName: str(r?.workName),
|
|
237
|
+
})),
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function mapMcpServerConfig(value) {
|
|
241
|
+
const raw = asRecord(value);
|
|
242
|
+
return {
|
|
243
|
+
name: str(raw.name) ?? "",
|
|
244
|
+
url: str(raw?.url) ?? "",
|
|
245
|
+
transport: str(raw?.transport) ?? "Http",
|
|
246
|
+
authType: str(raw?.authType) ?? "None",
|
|
247
|
+
apiKey: str(raw?.apiKey) ?? null,
|
|
248
|
+
headers: raw?.headers && typeof raw.headers === "object"
|
|
249
|
+
? raw.headers
|
|
250
|
+
: null,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
function mapAgent(value) {
|
|
254
|
+
const raw = asRecord(value);
|
|
255
|
+
const id = String(raw.id ?? "");
|
|
256
|
+
return {
|
|
257
|
+
id,
|
|
258
|
+
name: str(raw?.name) ?? id,
|
|
259
|
+
description: str(raw?.description) ?? null,
|
|
260
|
+
systemPrompt: str(raw?.systemPrompt) ?? null,
|
|
261
|
+
model: str(raw?.model) ?? "",
|
|
262
|
+
mcpServers: Array.isArray(raw?.mcpServers)
|
|
263
|
+
? raw.mcpServers.map(mapMcpServerConfig)
|
|
264
|
+
: [],
|
|
265
|
+
defaultOpenAiTools: Array.isArray(raw?.defaultOpenAiTools)
|
|
266
|
+
? raw.defaultOpenAiTools.map((t) => ({
|
|
267
|
+
name: str(t?.name) ?? "",
|
|
268
|
+
config: t?.config && typeof t.config === "object"
|
|
269
|
+
? t.config
|
|
270
|
+
: null,
|
|
271
|
+
}))
|
|
272
|
+
: [],
|
|
273
|
+
environmentId: str(raw?.environmentId),
|
|
274
|
+
createdAt: str(raw?.createdAt),
|
|
275
|
+
createdBy: str(raw?.createdBy),
|
|
276
|
+
lastModified: str(raw?.lastModified),
|
|
277
|
+
lastModifiedBy: str(raw?.lastModifiedBy),
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
// The list endpoint's envelope is normalized defensively — accept a bare array
|
|
281
|
+
// or {items|data|results: [...]} with optional paging meta.
|
|
282
|
+
function mapAgentPage(raw, fallback) {
|
|
283
|
+
const record = (raw ?? {});
|
|
284
|
+
const items = Array.isArray(raw)
|
|
285
|
+
? raw
|
|
286
|
+
: Array.isArray(record.items)
|
|
287
|
+
? record.items
|
|
288
|
+
: Array.isArray(record.data)
|
|
289
|
+
? record.data
|
|
290
|
+
: Array.isArray(record.results)
|
|
291
|
+
? record.results
|
|
292
|
+
: [];
|
|
293
|
+
const total = typeof record.total === "number"
|
|
294
|
+
? record.total
|
|
295
|
+
: typeof record.totalCount === "number"
|
|
296
|
+
? record.totalCount
|
|
297
|
+
: undefined;
|
|
298
|
+
return {
|
|
299
|
+
items: items.map(mapAgent),
|
|
300
|
+
page: typeof record.page === "number" ? record.page : fallback.page,
|
|
301
|
+
pageSize: typeof record.pageSize === "number" ? record.pageSize : fallback.pageSize,
|
|
302
|
+
total,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
// --- AI gateway run-event contract (POST /api/v1/agent/run SSE) -------------
|
|
306
|
+
// The gateway names each SSE frame; helpers below key on these. Assistant
|
|
307
|
+
// output arrives as `agent_event` frames, the terminal frame is `end_of_stream`,
|
|
308
|
+
// and mid-stream failures arrive as `error` (always before end_of_stream).
|
|
309
|
+
exports.AGENT_EVENT = "agent_event";
|
|
310
|
+
exports.AGENT_END_OF_STREAM = "end_of_stream";
|
|
311
|
+
exports.AGENT_ERROR = "error";
|
|
312
|
+
const num = (v) => typeof v === "number" && Number.isFinite(v) ? v : undefined;
|
|
313
|
+
// Summary is stored server-side as { text, coversThroughSeq, updatedAt }; the
|
|
314
|
+
// DTO only surfaces the text. Accept a bare string too (tolerant).
|
|
315
|
+
function mapChatSummary(value) {
|
|
316
|
+
if (typeof value === "string")
|
|
317
|
+
return str(value);
|
|
318
|
+
const raw = asRecord(value);
|
|
319
|
+
return str(raw?.text);
|
|
320
|
+
}
|
|
321
|
+
function mapAgentChat(value) {
|
|
322
|
+
const raw = asRecord(value);
|
|
323
|
+
const id = String(raw.id ?? "");
|
|
324
|
+
return {
|
|
325
|
+
id,
|
|
326
|
+
agentId: str(raw?.agentId) ?? "",
|
|
327
|
+
agentName: str(raw?.agentName) ?? "",
|
|
328
|
+
title: str(raw?.title) ?? "",
|
|
329
|
+
summary: mapChatSummary(raw?.summary),
|
|
330
|
+
lastSeq: num(raw?.lastSeq) ?? 0,
|
|
331
|
+
createdAt: str(raw?.createdAt),
|
|
332
|
+
lastModified: str(raw?.lastModified),
|
|
333
|
+
lastMessageAt: str(raw?.lastMessageAt),
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
// The list envelope is normalized defensively — accept a bare array or
|
|
337
|
+
// {items|data|results: [...]} with optional paging meta (mirrors mapAgentPage).
|
|
338
|
+
function mapAgentChatPage(raw, fallback) {
|
|
339
|
+
const record = (raw ?? {});
|
|
340
|
+
const items = Array.isArray(raw)
|
|
341
|
+
? raw
|
|
342
|
+
: Array.isArray(record.items)
|
|
343
|
+
? record.items
|
|
344
|
+
: Array.isArray(record.data)
|
|
345
|
+
? record.data
|
|
346
|
+
: Array.isArray(record.results)
|
|
347
|
+
? record.results
|
|
348
|
+
: [];
|
|
349
|
+
const total = typeof record.total === "number"
|
|
350
|
+
? record.total
|
|
351
|
+
: typeof record.totalCount === "number"
|
|
352
|
+
? record.totalCount
|
|
353
|
+
: undefined;
|
|
354
|
+
return {
|
|
355
|
+
items: items.map(mapAgentChat),
|
|
356
|
+
page: typeof record.page === "number" ? record.page : fallback.page,
|
|
357
|
+
pageSize: typeof record.pageSize === "number" ? record.pageSize : fallback.pageSize,
|
|
358
|
+
total,
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
// Canonical item kinds. The C# API serializes the enum member name, but which
|
|
362
|
+
// casing reaches the wire depends on its serializer registration (Newtonsoft
|
|
363
|
+
// PascalCase today; STJ camelCase if that order ever changes). Normalize known
|
|
364
|
+
// kinds to PascalCase so consumers can switch on a stable set; unknown values
|
|
365
|
+
// pass through untouched.
|
|
366
|
+
const AGENT_CHAT_ITEM_TYPES = [
|
|
367
|
+
"Message",
|
|
368
|
+
"ToolCall",
|
|
369
|
+
"ToolResult",
|
|
370
|
+
"Reasoning",
|
|
371
|
+
];
|
|
372
|
+
function normalizeItemType(raw) {
|
|
373
|
+
const lower = raw.toLowerCase();
|
|
374
|
+
return AGENT_CHAT_ITEM_TYPES.find((t) => t.toLowerCase() === lower) ?? raw;
|
|
375
|
+
}
|
|
376
|
+
function mapAgentChatMessage(value, chatId) {
|
|
377
|
+
const raw = asRecord(value);
|
|
378
|
+
const id = String(raw.id ?? "");
|
|
379
|
+
return {
|
|
380
|
+
id,
|
|
381
|
+
// The API does not echo chatId per item — prefer the call-site chat id.
|
|
382
|
+
chatId: str(raw?.chatId) ?? chatId ?? "",
|
|
383
|
+
seq: num(raw?.seq) ?? 0,
|
|
384
|
+
turnId: str(raw?.turnId) ?? "",
|
|
385
|
+
itemType: normalizeItemType(str(raw?.itemType) ?? ""),
|
|
386
|
+
role: str(raw?.role),
|
|
387
|
+
text: str(raw?.text),
|
|
388
|
+
toolName: str(raw?.toolName),
|
|
389
|
+
callId: str(raw?.callId),
|
|
390
|
+
arguments: str(raw?.arguments),
|
|
391
|
+
result: str(raw?.result),
|
|
392
|
+
createdAt: str(raw?.createdAt),
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
function mapAgentChatMessagePage(raw, fallback) {
|
|
396
|
+
const record = (raw ?? {});
|
|
397
|
+
const items = Array.isArray(raw)
|
|
398
|
+
? raw
|
|
399
|
+
: Array.isArray(record.items)
|
|
400
|
+
? record.items
|
|
401
|
+
: Array.isArray(record.data)
|
|
402
|
+
? record.data
|
|
403
|
+
: Array.isArray(record.results)
|
|
404
|
+
? record.results
|
|
405
|
+
: [];
|
|
406
|
+
const messages = items.map((item) => mapAgentChatMessage(item, fallback.chatId));
|
|
407
|
+
// fromSeq is INCLUSIVE server-side (returns seq >= fromSeq), so page forward
|
|
408
|
+
// from one past the highest seq — otherwise the boundary row repeats and a
|
|
409
|
+
// seq of 0 never advances.
|
|
410
|
+
const nextSeq = messages.length
|
|
411
|
+
? Math.max(...messages.map((m) => m.seq)) + 1
|
|
412
|
+
: undefined;
|
|
413
|
+
return {
|
|
414
|
+
items: messages,
|
|
415
|
+
fromSeq: num(record.fromSeq) ?? fallback.fromSeq,
|
|
416
|
+
pageSize: num(record.pageSize) ?? fallback.pageSize,
|
|
417
|
+
nextSeq,
|
|
418
|
+
};
|
|
419
|
+
}
|