@agimon-ai/po-codemode 0.0.1-alpha.14 → 0.0.1-alpha.140
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 +19 -67
- package/dist/apiContracts.cjs +20 -3
- package/dist/apiContracts.cjs.map +1 -1
- package/dist/apiContracts.d.mts +4 -3
- package/dist/apiContracts.d.mts.map +1 -1
- package/dist/apiContracts.mjs +18 -2
- package/dist/apiContracts.mjs.map +1 -1
- package/dist/codemodeTools-DQOpNO5B.cjs +1032 -0
- package/dist/codemodeTools-DQOpNO5B.cjs.map +1 -0
- package/dist/codemodeTools-butGjhru.mjs +992 -0
- package/dist/codemodeTools-butGjhru.mjs.map +1 -0
- package/dist/extensions/native.mjs +622 -0
- package/dist/extensions/native.mjs.map +1 -0
- package/dist/extensions/server.cjs +186 -13
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.d.mts.map +1 -1
- package/dist/extensions/server.mjs +187 -14
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/extensions/web.mjs +435 -124
- package/dist/extensions/web.mjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.mts +29 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/llms.txt +1 -0
- package/package.json +90 -11
- package/src/prompts/codemode-how-to-page/SKILL.md +38 -0
- package/src/prompts/codemode-how-to-shell/SKILL.md +4 -0
- package/src/prompts/how-to-codemode/SKILL.md +6 -0
- package/dist/codemodeTools-A-6aAXeW.cjs +0 -622
- package/dist/codemodeTools-A-6aAXeW.cjs.map +0 -1
- package/dist/codemodeTools-gfHLLrAt.mjs +0 -611
- package/dist/codemodeTools-gfHLLrAt.mjs.map +0 -1
|
@@ -0,0 +1,622 @@
|
|
|
1
|
+
import { defineChannelFile, defineFill, defineNativePlugin, defineSessionStore, defineToolRenderer } from "@agimon-ai/po-core/native";
|
|
2
|
+
import { View } from "react-native-unistyles/components/native/View";
|
|
3
|
+
import { Text } from "react-native-unistyles/components/native/Text";
|
|
4
|
+
import { Button, CodeBlock, Dot, LiveDuration, Markdown, MessageItem, MessageItemBody, MessageItemHeader, ToolResultImage, fontOf, toolTone } from "@agimon-ai/po-native-components";
|
|
5
|
+
import { useCallback, useState, useSyncExternalStore } from "react";
|
|
6
|
+
import { StyleSheet } from "react-native-unistyles";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Pressable } from "react-native-unistyles/components/native/Pressable";
|
|
9
|
+
//#region src/constants/backgroundScripts.ts
|
|
10
|
+
/** The hub channel frame carrying one session's running background scripts. */
|
|
11
|
+
const CODEMODE_BACKGROUND_TYPE = "codemode_background";
|
|
12
|
+
/** The slash command the page sends to stop one background script. */
|
|
13
|
+
const CODEMODE_STOP_COMMAND = "background-scripts-stop";
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/extensions/workspaces/sessions/(frontend)/_lib/backgroundScriptsFeed.ts
|
|
16
|
+
const EMPTY_BACKGROUND_SCRIPTS = {
|
|
17
|
+
scripts: [],
|
|
18
|
+
stopRequested: []
|
|
19
|
+
};
|
|
20
|
+
function isScript(value) {
|
|
21
|
+
if (typeof value !== "object" || value === null) return false;
|
|
22
|
+
const script = value;
|
|
23
|
+
return typeof script.id === "string" && typeof script.label === "string" && typeof script.startedAt === "string" && (script.status === "running" || script.status === "reporting");
|
|
24
|
+
}
|
|
25
|
+
/** Gates the wire: a payload without a script list is dropped, malformed scripts are skipped. */
|
|
26
|
+
function parseBackgroundScripts(input) {
|
|
27
|
+
if (typeof input !== "object" || input === null) return null;
|
|
28
|
+
const scripts = input.scripts;
|
|
29
|
+
return Array.isArray(scripts) ? { scripts: scripts.filter(isScript) } : null;
|
|
30
|
+
}
|
|
31
|
+
/** A stop request is spent once its script stops running or leaves the feed. */
|
|
32
|
+
function reduceBackgroundScripts(current, payload) {
|
|
33
|
+
const live = new Set(payload.scripts.filter((script) => script.status === "running").map((script) => script.id));
|
|
34
|
+
return {
|
|
35
|
+
...payload,
|
|
36
|
+
stopRequested: current.stopRequested.filter((id) => live.has(id))
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/** Records a stop the page asked for, once. */
|
|
40
|
+
function withStopRequested(current, id) {
|
|
41
|
+
return {
|
|
42
|
+
...current,
|
|
43
|
+
stopRequested: [...current.stopRequested.filter((known) => known !== id), id]
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//#endregion
|
|
47
|
+
//#region src/extensions/workspaces/sessions/(frontend)/_lib/backgroundScriptsStore.native.ts
|
|
48
|
+
const backgroundScripts = defineSessionStore(EMPTY_BACKGROUND_SCRIPTS);
|
|
49
|
+
/** Asks the session to stop one script; the request holds until the script leaves the feed. */
|
|
50
|
+
function requestScriptStop(send, sessionId, id) {
|
|
51
|
+
send(sessionId, {
|
|
52
|
+
type: "prompt",
|
|
53
|
+
message: `/${CODEMODE_STOP_COMMAND} ${id}`
|
|
54
|
+
});
|
|
55
|
+
backgroundScripts.update(sessionId, (current) => withStopRequested(current, id));
|
|
56
|
+
}
|
|
57
|
+
/** The session's background-script channel: 'codemode_background' payloads into the store. */
|
|
58
|
+
const backgroundScriptsChannel = backgroundScripts.channel({
|
|
59
|
+
channel: CODEMODE_BACKGROUND_TYPE,
|
|
60
|
+
parse: parseBackgroundScripts,
|
|
61
|
+
reduce: reduceBackgroundScripts
|
|
62
|
+
});
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/extensions/workspaces/sessions/(frontend)/channel/codemode-background.native.ts
|
|
65
|
+
var codemode_background_native_default = defineChannelFile(backgroundScriptsChannel);
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/extensions/workspaces/sessions/(frontend)/fill/_components/BackgroundScriptsSection.native.tsx
|
|
68
|
+
/**
|
|
69
|
+
* The session's running `exec_background` scripts, under the runners in the Runners group.
|
|
70
|
+
* Nothing renders while none runs, so the runners' own idle line stays the group's only line.
|
|
71
|
+
*/
|
|
72
|
+
function BackgroundScriptsSection({ sessionId, sendSessionFrame }) {
|
|
73
|
+
const subscribe = useCallback((listener) => {
|
|
74
|
+
const subscription = backgroundScripts.store.subscribe(listener);
|
|
75
|
+
return () => subscription.unsubscribe();
|
|
76
|
+
}, []);
|
|
77
|
+
const session = useSyncExternalStore(subscribe, () => backgroundScripts.select(backgroundScripts.store.state, sessionId));
|
|
78
|
+
if (session.scripts.length === 0) return null;
|
|
79
|
+
return /* @__PURE__ */ jsx(View, {
|
|
80
|
+
testID: "activity-background-scripts",
|
|
81
|
+
children: session.scripts.map((script) => {
|
|
82
|
+
const stopping = session.stopRequested.includes(script.id);
|
|
83
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
84
|
+
testID: `activity-background-script-${script.id}`,
|
|
85
|
+
style: styles$1.row,
|
|
86
|
+
children: [/* @__PURE__ */ jsxs(View, {
|
|
87
|
+
style: styles$1.line,
|
|
88
|
+
children: [
|
|
89
|
+
/* @__PURE__ */ jsx(Dot, {
|
|
90
|
+
tone: "yellow",
|
|
91
|
+
pulse: script.status === "running"
|
|
92
|
+
}),
|
|
93
|
+
/* @__PURE__ */ jsx(Text, {
|
|
94
|
+
numberOfLines: 1,
|
|
95
|
+
style: styles$1.name,
|
|
96
|
+
children: "Background script"
|
|
97
|
+
}),
|
|
98
|
+
script.status === "reporting" ? /* @__PURE__ */ jsx(Text, {
|
|
99
|
+
style: styles$1.meta,
|
|
100
|
+
children: "finishing…"
|
|
101
|
+
}) : /* @__PURE__ */ jsx(LiveDuration, {
|
|
102
|
+
label: "up",
|
|
103
|
+
since: Date.parse(script.startedAt),
|
|
104
|
+
style: styles$1.meta
|
|
105
|
+
}),
|
|
106
|
+
sessionId !== null && script.status === "running" ? /* @__PURE__ */ jsx(Button, {
|
|
107
|
+
testID: `activity-background-script-stop-${script.id}`,
|
|
108
|
+
size: "xs",
|
|
109
|
+
variant: stopping ? "outline" : "danger-outline",
|
|
110
|
+
disabled: stopping,
|
|
111
|
+
onPress: () => requestScriptStop(sendSessionFrame, sessionId, script.id),
|
|
112
|
+
children: stopping ? "Stopping…" : "Stop"
|
|
113
|
+
}) : null
|
|
114
|
+
]
|
|
115
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
116
|
+
numberOfLines: 1,
|
|
117
|
+
style: styles$1.label,
|
|
118
|
+
children: script.label
|
|
119
|
+
})]
|
|
120
|
+
}, script.id);
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
const styles$1 = StyleSheet.create((theme) => ({
|
|
125
|
+
row: {
|
|
126
|
+
gap: theme.spacing(1),
|
|
127
|
+
paddingVertical: theme.spacing(2),
|
|
128
|
+
uni__dependencies: [0]
|
|
129
|
+
},
|
|
130
|
+
line: {
|
|
131
|
+
flexDirection: "row",
|
|
132
|
+
alignItems: "center",
|
|
133
|
+
gap: theme.spacing(2),
|
|
134
|
+
uni__dependencies: [0]
|
|
135
|
+
},
|
|
136
|
+
name: {
|
|
137
|
+
flex: 1,
|
|
138
|
+
color: theme.colors.hi,
|
|
139
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
140
|
+
fontSize: theme.fontSize.base,
|
|
141
|
+
lineHeight: theme.lineHeight.base,
|
|
142
|
+
fontWeight: theme.fontWeight.medium,
|
|
143
|
+
uni__dependencies: [0]
|
|
144
|
+
},
|
|
145
|
+
label: {
|
|
146
|
+
paddingLeft: theme.spacing(3.5),
|
|
147
|
+
color: theme.colors.dim,
|
|
148
|
+
fontFamily: fontOf(theme.fontFamily.mono),
|
|
149
|
+
fontSize: theme.fontSize.sm,
|
|
150
|
+
lineHeight: theme.lineHeight.sm,
|
|
151
|
+
uni__dependencies: [0]
|
|
152
|
+
},
|
|
153
|
+
meta: {
|
|
154
|
+
color: theme.colors.dim,
|
|
155
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
156
|
+
fontSize: theme.fontSize.sm,
|
|
157
|
+
lineHeight: theme.lineHeight.sm,
|
|
158
|
+
uni__dependencies: [0]
|
|
159
|
+
}
|
|
160
|
+
}));
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/extensions/workspaces/sessions/(frontend)/fill/BackgroundScripts.activity.runners.native.tsx
|
|
163
|
+
var BackgroundScripts_activity_runners_native_default = defineFill({
|
|
164
|
+
slot: "activity.runners",
|
|
165
|
+
id: "background-scripts",
|
|
166
|
+
order: 1100,
|
|
167
|
+
component: BackgroundScriptsSection
|
|
168
|
+
});
|
|
169
|
+
//#endregion
|
|
170
|
+
//#region src/extensions/workspaces/sessions/(frontend)/tool/_lib/execToolView.ts
|
|
171
|
+
/** Tool names this package registers (registerTool's `name`). */
|
|
172
|
+
const execToolName = "exec";
|
|
173
|
+
const SUMMARY_MAX = 120;
|
|
174
|
+
const ARGS_MAX = 160;
|
|
175
|
+
const CALLS_MAX = 50;
|
|
176
|
+
const IMAGE_TYPES = /^image\/(?:png|jpeg|webp|gif)$/u;
|
|
177
|
+
const SAVED_LINE = /^Saved as (\S+) \((.+)\)$/u;
|
|
178
|
+
const DOCUMENT_LINE = /^(?:#{1,6} |```)/mu;
|
|
179
|
+
function record(value) {
|
|
180
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
|
|
181
|
+
}
|
|
182
|
+
function clip(text, max) {
|
|
183
|
+
return text.length <= max ? text : `${text.slice(0, max - 1)}…`;
|
|
184
|
+
}
|
|
185
|
+
/** The script the call ran, exactly as the agent wrote it. */
|
|
186
|
+
function execCode(args) {
|
|
187
|
+
return typeof args.code === "string" ? args.code : "";
|
|
188
|
+
}
|
|
189
|
+
/** The header line: the script's first line, with a leading `//` comment marker dropped. */
|
|
190
|
+
function execSummary(args) {
|
|
191
|
+
const first = execCode(args).split("\n").map((line) => line.trim()).find((line) => line !== "");
|
|
192
|
+
if (first === void 0) return "script";
|
|
193
|
+
return clip(first.replace(/^\/\/+\s*/u, ""), SUMMARY_MAX);
|
|
194
|
+
}
|
|
195
|
+
function callOf(value) {
|
|
196
|
+
const call = record(value);
|
|
197
|
+
if (call === void 0 || typeof call.name !== "string" || call.name === "") return void 0;
|
|
198
|
+
const result = record(call.result);
|
|
199
|
+
return {
|
|
200
|
+
name: call.name,
|
|
201
|
+
args: record(call.args) ?? {},
|
|
202
|
+
ok: call.ok !== false,
|
|
203
|
+
ms: typeof call.ms === "number" && Number.isFinite(call.ms) && call.ms >= 0 ? Math.round(call.ms) : 0,
|
|
204
|
+
...typeof call.tool === "string" && call.tool !== "" ? { tool: call.tool } : {},
|
|
205
|
+
...typeof call.error === "string" && call.error !== "" ? { error: call.error } : {},
|
|
206
|
+
...result !== void 0 && Array.isArray(result.content) ? { result: {
|
|
207
|
+
content: result.content,
|
|
208
|
+
details: result.details
|
|
209
|
+
} } : {}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/** The nested calls recorded in a result's details; anything malformed is skipped. */
|
|
213
|
+
function execCalls(details) {
|
|
214
|
+
const calls = record(details)?.calls;
|
|
215
|
+
if (!Array.isArray(calls)) return [];
|
|
216
|
+
return calls.slice(0, CALLS_MAX).map(callOf).filter((call) => call !== void 0);
|
|
217
|
+
}
|
|
218
|
+
/** A call's arguments on one line, for a row that has no card of its own: `key: value · key: value`, strings unquoted. */
|
|
219
|
+
function callArgsSummary(args) {
|
|
220
|
+
return clip(Object.entries(args).map(([key, value]) => `${key}: ${typeof value === "string" ? value : JSON.stringify(value) ?? String(value)}`).join(" · "), ARGS_MAX);
|
|
221
|
+
}
|
|
222
|
+
/** A script's return on one line: a JSON object folds like call arguments, other JSON compacts, plain text joins its lines. */
|
|
223
|
+
function returnSummary(text) {
|
|
224
|
+
let value;
|
|
225
|
+
try {
|
|
226
|
+
value = JSON.parse(text);
|
|
227
|
+
} catch {
|
|
228
|
+
return text.split("\n").join(" ");
|
|
229
|
+
}
|
|
230
|
+
const object = record(value);
|
|
231
|
+
return object !== void 0 && Object.keys(object).length > 0 ? callArgsSummary(object) : clip(JSON.stringify(value), ARGS_MAX);
|
|
232
|
+
}
|
|
233
|
+
/** What a result holds, with the saved-script footer and the pictures taken out of the text. */
|
|
234
|
+
function execResultView(result) {
|
|
235
|
+
if (result === null) return {
|
|
236
|
+
lines: [],
|
|
237
|
+
images: []
|
|
238
|
+
};
|
|
239
|
+
let saved;
|
|
240
|
+
const texts = [];
|
|
241
|
+
const images = [];
|
|
242
|
+
for (const block of result.content) {
|
|
243
|
+
const item = record(block);
|
|
244
|
+
if (item?.type === "text" && typeof item.text === "string") {
|
|
245
|
+
const match = SAVED_LINE.exec(item.text.trim());
|
|
246
|
+
if (match?.[1] !== void 0 && match[2] !== void 0) saved = {
|
|
247
|
+
id: match[1],
|
|
248
|
+
path: match[2]
|
|
249
|
+
};
|
|
250
|
+
else texts.push(item.text);
|
|
251
|
+
} else if (item?.type === "image" && typeof item.data === "string" && typeof item.mimeType === "string" && IMAGE_TYPES.test(item.mimeType)) images.push({
|
|
252
|
+
mimeType: item.mimeType,
|
|
253
|
+
data: item.data
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
const lines = texts.join("\n").replaceAll("\r\n", "\n").replaceAll("\r", "\n").replaceAll(" ", " ").split("\n");
|
|
257
|
+
while (lines.length > 0 && lines.at(-1)?.trim() === "") lines.pop();
|
|
258
|
+
return {
|
|
259
|
+
lines,
|
|
260
|
+
...saved === void 0 ? {} : { saved },
|
|
261
|
+
images
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/** Whether result text is a document, such as a report or a mermaid diagram, to draw rather than print. */
|
|
265
|
+
function readsAsDocument(text) {
|
|
266
|
+
return DOCUMENT_LINE.test(text);
|
|
267
|
+
}
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/extensions/workspaces/sessions/(frontend)/tool/_components/ExecToolCard.native.tsx
|
|
270
|
+
/** Pictures and documents stay on screen whether or not their row is open: they are the point of the call. */
|
|
271
|
+
function Visuals({ text, images, label, host }) {
|
|
272
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [readsAsDocument(text) ? /* @__PURE__ */ jsx(Markdown, { text }) : null, images.map((image, index) => /* @__PURE__ */ jsx(ToolResultImage, {
|
|
273
|
+
host,
|
|
274
|
+
data: image.data,
|
|
275
|
+
mimeType: image.mimeType,
|
|
276
|
+
accessibilityLabel: `${label} image ${String(index + 1)}`,
|
|
277
|
+
resizeMode: "contain",
|
|
278
|
+
style: styles.image
|
|
279
|
+
}, `${image.mimeType}-${String(index)}`))] });
|
|
280
|
+
}
|
|
281
|
+
/** One call on the rail. Tapping it opens its whole args and result; its pictures and documents show either way. */
|
|
282
|
+
function CallRow({ call, host }) {
|
|
283
|
+
const [open, setOpen] = useState(false);
|
|
284
|
+
const view = execResultView(call.result ?? null);
|
|
285
|
+
const text = view.lines.join("\n");
|
|
286
|
+
const printed = text !== "" && (!call.ok || !readsAsDocument(text));
|
|
287
|
+
const hasArgs = Object.keys(call.args).length > 0;
|
|
288
|
+
const opens = hasArgs || printed || call.error !== void 0;
|
|
289
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
290
|
+
testID: "exec-call",
|
|
291
|
+
style: styles.call,
|
|
292
|
+
children: [
|
|
293
|
+
/* @__PURE__ */ jsxs(Pressable, {
|
|
294
|
+
disabled: !opens,
|
|
295
|
+
onPress: () => setOpen((value) => !value),
|
|
296
|
+
accessibilityRole: opens ? "button" : void 0,
|
|
297
|
+
accessibilityState: opens ? { expanded: open } : void 0,
|
|
298
|
+
accessibilityHint: opens ? "Shows the whole arguments and result" : void 0,
|
|
299
|
+
style: styles.press,
|
|
300
|
+
children: [/* @__PURE__ */ jsxs(View, {
|
|
301
|
+
style: styles.argsLine,
|
|
302
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
303
|
+
numberOfLines: 1,
|
|
304
|
+
style: [
|
|
305
|
+
styles.mono,
|
|
306
|
+
styles.name,
|
|
307
|
+
styles.shrink
|
|
308
|
+
],
|
|
309
|
+
children: call.name
|
|
310
|
+
}), opens ? /* @__PURE__ */ jsx(Text, {
|
|
311
|
+
style: [
|
|
312
|
+
styles.sans,
|
|
313
|
+
styles.dim,
|
|
314
|
+
styles.keep
|
|
315
|
+
],
|
|
316
|
+
children: open ? "⌄" : "›"
|
|
317
|
+
}) : null]
|
|
318
|
+
}), /* @__PURE__ */ jsxs(View, {
|
|
319
|
+
style: styles.argsLine,
|
|
320
|
+
children: [
|
|
321
|
+
/* @__PURE__ */ jsx(Text, {
|
|
322
|
+
numberOfLines: 1,
|
|
323
|
+
style: [styles.mono, styles.args],
|
|
324
|
+
children: open ? "" : callArgsSummary(call.args)
|
|
325
|
+
}),
|
|
326
|
+
/* @__PURE__ */ jsx(Text, {
|
|
327
|
+
accessibilityLabel: call.ok ? "completed" : "failed",
|
|
328
|
+
style: [styles.sans, call.ok ? styles.ok : styles.error],
|
|
329
|
+
children: call.ok ? "✓" : "✗"
|
|
330
|
+
}),
|
|
331
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
332
|
+
style: [styles.sans, styles.dim],
|
|
333
|
+
children: [call.ms, " ms"]
|
|
334
|
+
})
|
|
335
|
+
]
|
|
336
|
+
})]
|
|
337
|
+
}),
|
|
338
|
+
open && hasArgs ? /* @__PURE__ */ jsx(CodeBlock, {
|
|
339
|
+
text: JSON.stringify(call.args, null, 2),
|
|
340
|
+
language: "json"
|
|
341
|
+
}) : null,
|
|
342
|
+
open && printed ? /* @__PURE__ */ jsx(Text, {
|
|
343
|
+
testID: "exec-call-output",
|
|
344
|
+
selectable: true,
|
|
345
|
+
style: [styles.mono, styles.text],
|
|
346
|
+
children: text
|
|
347
|
+
}) : null,
|
|
348
|
+
open && call.error !== void 0 ? /* @__PURE__ */ jsx(Text, {
|
|
349
|
+
style: [styles.sans, styles.error],
|
|
350
|
+
children: call.error
|
|
351
|
+
}) : null,
|
|
352
|
+
/* @__PURE__ */ jsx(Visuals, {
|
|
353
|
+
text: call.ok ? text : "",
|
|
354
|
+
images: view.images,
|
|
355
|
+
label: call.name,
|
|
356
|
+
host
|
|
357
|
+
})
|
|
358
|
+
]
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
/** The script's outcome as the rail's last leaf: one line while the card is folded, all of it once opened. */
|
|
362
|
+
function Returned({ result, isError, expanded, host }) {
|
|
363
|
+
const view = execResultView(result);
|
|
364
|
+
const text = view.lines.join("\n");
|
|
365
|
+
const document = !isError && readsAsDocument(text);
|
|
366
|
+
return /* @__PURE__ */ jsxs(View, {
|
|
367
|
+
testID: `tool-result-${execToolName}`,
|
|
368
|
+
style: styles.leaf,
|
|
369
|
+
children: [view.lines.length === 0 ? /* @__PURE__ */ jsx(Text, {
|
|
370
|
+
style: [styles.sans, styles.dim],
|
|
371
|
+
children: isError ? "Failed with no output." : "Returned nothing."
|
|
372
|
+
}) : document ? /* @__PURE__ */ jsx(Text, {
|
|
373
|
+
style: [
|
|
374
|
+
styles.sans,
|
|
375
|
+
styles.dim,
|
|
376
|
+
styles.label
|
|
377
|
+
],
|
|
378
|
+
children: isError ? "Error" : "Returned"
|
|
379
|
+
}) : /* @__PURE__ */ jsxs(View, {
|
|
380
|
+
style: expanded ? styles.stack : styles.argsLine,
|
|
381
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
382
|
+
style: [
|
|
383
|
+
styles.sans,
|
|
384
|
+
styles.dim,
|
|
385
|
+
styles.label
|
|
386
|
+
],
|
|
387
|
+
children: isError ? "Error" : "Returned"
|
|
388
|
+
}), /* @__PURE__ */ jsx(Text, {
|
|
389
|
+
selectable: true,
|
|
390
|
+
numberOfLines: expanded ? void 0 : 1,
|
|
391
|
+
style: [
|
|
392
|
+
styles.mono,
|
|
393
|
+
styles.args,
|
|
394
|
+
isError ? styles.error : styles.text
|
|
395
|
+
],
|
|
396
|
+
children: expanded ? text : returnSummary(text)
|
|
397
|
+
})]
|
|
398
|
+
}), /* @__PURE__ */ jsx(Visuals, {
|
|
399
|
+
text: isError ? "" : text,
|
|
400
|
+
images: view.images,
|
|
401
|
+
label: "Script",
|
|
402
|
+
host
|
|
403
|
+
})]
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* The exec tool's timeline item on native, as the web's ExecToolCard: the
|
|
408
|
+
* calls the script made hang under it on a rail, each as the owning tool's own
|
|
409
|
+
* card when one exists, with what it returned as the last leaf. Opening the
|
|
410
|
+
* item shows the script itself.
|
|
411
|
+
*/
|
|
412
|
+
function ExecToolCard(props) {
|
|
413
|
+
const { args, result, running, isError, defaultExpanded = false, renderTool } = props;
|
|
414
|
+
const code = execCode(args);
|
|
415
|
+
const calls = execCalls(result?.details);
|
|
416
|
+
const failed = calls.filter((call) => !call.ok).length;
|
|
417
|
+
const settled = !running || result !== null;
|
|
418
|
+
return /* @__PURE__ */ jsx(MessageItem, {
|
|
419
|
+
tone: toolTone({
|
|
420
|
+
running,
|
|
421
|
+
isError
|
|
422
|
+
}),
|
|
423
|
+
expandable: code !== "" || isError,
|
|
424
|
+
defaultExpanded,
|
|
425
|
+
children: ({ expanded }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
426
|
+
/* @__PURE__ */ jsx(MessageItemHeader, {
|
|
427
|
+
title: execToolName,
|
|
428
|
+
children: /* @__PURE__ */ jsxs(View, {
|
|
429
|
+
testID: `tool-call-${execToolName}`,
|
|
430
|
+
style: styles.summary,
|
|
431
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
432
|
+
numberOfLines: 1,
|
|
433
|
+
style: [
|
|
434
|
+
styles.sans,
|
|
435
|
+
styles.text,
|
|
436
|
+
styles.shrink
|
|
437
|
+
],
|
|
438
|
+
children: execSummary(args)
|
|
439
|
+
}), calls.length > 0 ? /* @__PURE__ */ jsxs(Text, {
|
|
440
|
+
numberOfLines: 1,
|
|
441
|
+
style: [
|
|
442
|
+
styles.sans,
|
|
443
|
+
styles.dim,
|
|
444
|
+
styles.keep
|
|
445
|
+
],
|
|
446
|
+
children: [
|
|
447
|
+
calls.length,
|
|
448
|
+
" ",
|
|
449
|
+
calls.length === 1 ? "call" : "calls",
|
|
450
|
+
failed > 0 ? /* @__PURE__ */ jsxs(Text, {
|
|
451
|
+
style: styles.error,
|
|
452
|
+
children: [
|
|
453
|
+
", ",
|
|
454
|
+
failed,
|
|
455
|
+
" failed"
|
|
456
|
+
]
|
|
457
|
+
}) : null
|
|
458
|
+
]
|
|
459
|
+
}) : null]
|
|
460
|
+
})
|
|
461
|
+
}),
|
|
462
|
+
expanded ? /* @__PURE__ */ jsx(MessageItemBody, { children: /* @__PURE__ */ jsx(CodeBlock, {
|
|
463
|
+
text: code,
|
|
464
|
+
language: "ts"
|
|
465
|
+
}) }) : null,
|
|
466
|
+
settled ? /* @__PURE__ */ jsxs(View, {
|
|
467
|
+
accessibilityLabel: "Script calls",
|
|
468
|
+
style: styles.rail,
|
|
469
|
+
children: [calls.map((call, index) => {
|
|
470
|
+
const card = call.tool === void 0 || renderTool === void 0 ? null : renderTool({
|
|
471
|
+
toolName: call.tool,
|
|
472
|
+
args: call.args,
|
|
473
|
+
result: call.result ?? null,
|
|
474
|
+
isError: !call.ok
|
|
475
|
+
});
|
|
476
|
+
return card === null || card === void 0 ? /* @__PURE__ */ jsx(CallRow, {
|
|
477
|
+
call,
|
|
478
|
+
host: props
|
|
479
|
+
}, `${String(index)}-${call.name}`) : /* @__PURE__ */ jsxs(View, {
|
|
480
|
+
style: styles.call,
|
|
481
|
+
children: [card, /* @__PURE__ */ jsx(Visuals, {
|
|
482
|
+
text: "",
|
|
483
|
+
images: execResultView(call.result ?? null).images,
|
|
484
|
+
label: call.name,
|
|
485
|
+
host: props
|
|
486
|
+
})]
|
|
487
|
+
}, `${String(index)}-${call.name}`);
|
|
488
|
+
}), running ? null : /* @__PURE__ */ jsx(Returned, {
|
|
489
|
+
result,
|
|
490
|
+
isError,
|
|
491
|
+
expanded,
|
|
492
|
+
host: props
|
|
493
|
+
})]
|
|
494
|
+
}) : null
|
|
495
|
+
] })
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
const styles = StyleSheet.create((theme) => ({
|
|
499
|
+
summary: {
|
|
500
|
+
flex: 1,
|
|
501
|
+
flexDirection: "row",
|
|
502
|
+
alignItems: "center",
|
|
503
|
+
gap: theme.spacing(2),
|
|
504
|
+
minWidth: 0,
|
|
505
|
+
uni__dependencies: [0]
|
|
506
|
+
},
|
|
507
|
+
shrink: { flexShrink: 1 },
|
|
508
|
+
keep: { flexShrink: 0 },
|
|
509
|
+
rail: {
|
|
510
|
+
gap: theme.spacing(2),
|
|
511
|
+
marginHorizontal: theme.spacing(4),
|
|
512
|
+
marginBottom: theme.spacing(3),
|
|
513
|
+
paddingLeft: theme.spacing(3),
|
|
514
|
+
borderLeftWidth: 1,
|
|
515
|
+
borderColor: theme.colors["border-soft"],
|
|
516
|
+
uni__dependencies: [0]
|
|
517
|
+
},
|
|
518
|
+
call: {
|
|
519
|
+
gap: theme.spacing(2),
|
|
520
|
+
uni__dependencies: [0]
|
|
521
|
+
},
|
|
522
|
+
press: {
|
|
523
|
+
minHeight: 44,
|
|
524
|
+
justifyContent: "center",
|
|
525
|
+
gap: theme.spacing(.5),
|
|
526
|
+
paddingVertical: theme.spacing(1),
|
|
527
|
+
uni__dependencies: [0]
|
|
528
|
+
},
|
|
529
|
+
argsLine: {
|
|
530
|
+
flexDirection: "row",
|
|
531
|
+
alignItems: "center",
|
|
532
|
+
gap: theme.spacing(2),
|
|
533
|
+
uni__dependencies: [0]
|
|
534
|
+
},
|
|
535
|
+
stack: {
|
|
536
|
+
gap: theme.spacing(1),
|
|
537
|
+
uni__dependencies: [0]
|
|
538
|
+
},
|
|
539
|
+
leaf: {
|
|
540
|
+
gap: theme.spacing(2),
|
|
541
|
+
uni__dependencies: [0]
|
|
542
|
+
},
|
|
543
|
+
sans: {
|
|
544
|
+
fontFamily: fontOf(theme.fontFamily.sans),
|
|
545
|
+
fontSize: theme.fontSize.sm,
|
|
546
|
+
lineHeight: theme.lineHeight.sm,
|
|
547
|
+
uni__dependencies: [0]
|
|
548
|
+
},
|
|
549
|
+
mono: {
|
|
550
|
+
fontFamily: fontOf(theme.fontFamily.mono),
|
|
551
|
+
fontSize: theme.fontSize.sm,
|
|
552
|
+
lineHeight: theme.lineHeight.sm,
|
|
553
|
+
uni__dependencies: [0]
|
|
554
|
+
},
|
|
555
|
+
name: {
|
|
556
|
+
fontWeight: "600",
|
|
557
|
+
color: theme.colors.text,
|
|
558
|
+
uni__dependencies: [0]
|
|
559
|
+
},
|
|
560
|
+
args: {
|
|
561
|
+
flex: 1,
|
|
562
|
+
minWidth: 0,
|
|
563
|
+
color: theme.colors.dim,
|
|
564
|
+
uni__dependencies: [0]
|
|
565
|
+
},
|
|
566
|
+
label: { fontWeight: "600" },
|
|
567
|
+
text: {
|
|
568
|
+
color: theme.colors.text,
|
|
569
|
+
uni__dependencies: [0]
|
|
570
|
+
},
|
|
571
|
+
dim: {
|
|
572
|
+
color: theme.colors.dim,
|
|
573
|
+
uni__dependencies: [0]
|
|
574
|
+
},
|
|
575
|
+
ok: {
|
|
576
|
+
color: theme.colors.green,
|
|
577
|
+
uni__dependencies: [0]
|
|
578
|
+
},
|
|
579
|
+
error: {
|
|
580
|
+
color: theme.colors.red,
|
|
581
|
+
uni__dependencies: [0]
|
|
582
|
+
},
|
|
583
|
+
image: {
|
|
584
|
+
width: "100%",
|
|
585
|
+
aspectRatio: 16 / 9,
|
|
586
|
+
borderWidth: 1,
|
|
587
|
+
borderRadius: theme.borderRadius.md,
|
|
588
|
+
borderColor: theme.colors["border-soft"],
|
|
589
|
+
uni__dependencies: [0]
|
|
590
|
+
}
|
|
591
|
+
}));
|
|
592
|
+
//#endregion
|
|
593
|
+
//#region src/extensions/workspaces/sessions/(frontend)/tool/exec.native.tsx
|
|
594
|
+
var exec_native_default = defineToolRenderer({ message: ExecToolCard });
|
|
595
|
+
//#endregion
|
|
596
|
+
//#region generated/native.ts
|
|
597
|
+
const via = (identity, value) => value === void 0 ? void 0 : {
|
|
598
|
+
...identity,
|
|
599
|
+
...value
|
|
600
|
+
};
|
|
601
|
+
const nativePlugin = defineNativePlugin({
|
|
602
|
+
id: "codemode",
|
|
603
|
+
packageName: "@agimon-ai/po-codemode",
|
|
604
|
+
session: {
|
|
605
|
+
get channels() {
|
|
606
|
+
return [via({ channel: "codemode_background" }, codemode_background_native_default)];
|
|
607
|
+
},
|
|
608
|
+
get fills() {
|
|
609
|
+
return [via({
|
|
610
|
+
slot: "activity.runners",
|
|
611
|
+
id: "background-scripts"
|
|
612
|
+
}, BackgroundScripts_activity_runners_native_default)];
|
|
613
|
+
},
|
|
614
|
+
get toolRenderers() {
|
|
615
|
+
return [via({ tools: ["exec"] }, exec_native_default)];
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
//#endregion
|
|
620
|
+
export { nativePlugin };
|
|
621
|
+
|
|
622
|
+
//# sourceMappingURL=native.mjs.map
|