@picassohq/cli 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents/browser_agent.yaml +53 -0
- package/agents/code_reviewer.yaml +49 -0
- package/agents/codebase_investigator.yaml +70 -0
- package/agents/design_auditor.yaml +50 -0
- package/agents/devex_auditor.yaml +50 -0
- package/agents/doc_writer.yaml +54 -0
- package/agents/engineering_architect.yaml +51 -0
- package/agents/generalist.yaml +55 -0
- package/agents/migration_planner.yaml +51 -0
- package/agents/product_reviewer.yaml +48 -0
- package/agents/qa_operator.yaml +52 -0
- package/agents/release_engineer.yaml +50 -0
- package/agents/security_auditor.yaml +62 -0
- package/agents/test_writer.yaml +52 -0
- package/assets/first-light-lockup.png +0 -0
- package/assets/first-light-tagline.png +0 -0
- package/assets/house/README.md +26 -0
- package/assets/house/auraone-banner.png +0 -0
- package/assets/house/auraone-logo.png +0 -0
- package/assets/house/kiro-prism-banner.png +0 -0
- package/assets/house/kiro-prism-logo.png +0 -0
- package/assets/house/picasso-banner.png +0 -0
- package/assets/house/picasso-logo.png +0 -0
- package/assets/wordmark-app.png +0 -0
- package/assets/wordmark-tight.png +0 -0
- package/assets/wordmark.png +0 -0
- package/design/styles.css +1042 -0
- package/dist/build-info.json +37 -0
- package/dist/index.js +3028 -0
- package/goals/cli-hardening.yaml +40 -0
- package/goals/repo-maintenance.yaml +40 -0
- package/package.json +49 -4
- package/runtime/dsh/picasso-ecosystem.community.amendments.yml +24 -0
- package/runtime/dsh/picasso-ecosystem.community.json +185 -0
- package/runtime/dsh/picasso-ecosystem.community.patch.yml +40 -0
- package/runtime/dsh/picasso-ecosystem.cordis.patch.yml +143 -0
- package/runtime/dsh/picasso-isolation.patch.yml +25 -0
- package/runtime/dsh/picasso-providers.patch.yml +373 -0
- package/runtime/dsh/picasso-runtime.cordis.yml +738 -0
- package/runtime/dsh/picasso-sdk.patch.yml +204 -0
- package/runtime/engine-manifest.json +214 -0
- package/runtime/package.json +6 -0
- package/runtime/packages/picasso-cache-probe/cordis.patch.yml +5 -0
- package/runtime/packages/picasso-cache-probe/index.js +477 -0
- package/runtime/packages/picasso-cache-probe/package.json +38 -0
- package/runtime/packages/picasso-commands/cordis.patch.yml +4 -0
- package/runtime/packages/picasso-commands/fresh-review.js +573 -0
- package/runtime/packages/picasso-commands/index.js +497 -0
- package/runtime/packages/picasso-commands/package.json +28 -0
- package/runtime/packages/picasso-instructions/conflicts.js +115 -0
- package/runtime/packages/picasso-instructions/formats.js +145 -0
- package/runtime/packages/picasso-instructions/frontmatter.js +175 -0
- package/runtime/packages/picasso-instructions/glob.js +114 -0
- package/runtime/packages/picasso-instructions/globals.js +90 -0
- package/runtime/packages/picasso-instructions/imports.js +123 -0
- package/runtime/packages/picasso-instructions/index.js +326 -0
- package/runtime/packages/picasso-instructions/modes.js +64 -0
- package/runtime/packages/picasso-instructions/package.json +30 -0
- package/runtime/packages/picasso-instructions/parse.js +134 -0
- package/runtime/packages/picasso-instructions/report.js +161 -0
- package/runtime/packages/picasso-instructions/resolve.js +939 -0
- package/runtime/packages/picasso-instructions/scan.js +181 -0
- package/runtime/packages/picasso-instructions/settings.js +150 -0
- package/runtime/packages/picasso-instructions/skills.js +345 -0
- package/runtime/packages/picasso-lean-context/cordis.patch.yml +13 -0
- package/runtime/packages/picasso-lean-context/index.js +6049 -0
- package/runtime/packages/picasso-lean-context/package.json +26 -0
- package/runtime/packages/picasso-lean-context/timeline.js +417 -0
- package/runtime/packages/picasso-librarian/classify.js +146 -0
- package/runtime/packages/picasso-librarian/cordis.patch.yml +10 -0
- package/runtime/packages/picasso-librarian/index.js +878 -0
- package/runtime/packages/picasso-librarian/notes.js +159 -0
- package/runtime/packages/picasso-librarian/package.json +34 -0
- package/runtime/packages/picasso-librarian/state.js +478 -0
- package/runtime/packages/picasso-memory/index.js +1184 -0
- package/runtime/packages/picasso-memory/package.json +21 -0
- package/runtime/packages/picasso-model-router/connections.js +895 -0
- package/runtime/packages/picasso-model-router/cordis.patch.yml +17 -0
- package/runtime/packages/picasso-model-router/index.js +1081 -0
- package/runtime/packages/picasso-model-router/package.json +30 -0
- package/runtime/packages/picasso-options/cordis.patch.yml +4 -0
- package/runtime/packages/picasso-options/index.js +263 -0
- package/runtime/packages/picasso-options/package.json +28 -0
- package/runtime/packages/picasso-progress-reports/cordis.patch.yml +10 -0
- package/runtime/packages/picasso-progress-reports/index.js +267 -0
- package/runtime/packages/picasso-progress-reports/package.json +30 -0
- package/runtime/packages/picasso-progress-reports/report.js +235 -0
- package/runtime/packages/picasso-sdk-server/aside.js +128 -0
- package/runtime/packages/picasso-sdk-server/connections.js +38 -0
- package/runtime/packages/picasso-sdk-server/context-timeline.js +27 -0
- package/runtime/packages/picasso-sdk-server/egress-gate.js +520 -0
- package/runtime/packages/picasso-sdk-server/failure-policy.js +246 -0
- package/runtime/packages/picasso-sdk-server/file-input.js +169 -0
- package/runtime/packages/picasso-sdk-server/goal.js +131 -0
- package/runtime/packages/picasso-sdk-server/ignore-file.js +458 -0
- package/runtime/packages/picasso-sdk-server/ignore-plugin.js +12 -0
- package/runtime/packages/picasso-sdk-server/ignore-sandbox.js +122 -0
- package/runtime/packages/picasso-sdk-server/ignore-snapshot.js +131 -0
- package/runtime/packages/picasso-sdk-server/image-input.js +44 -0
- package/runtime/packages/picasso-sdk-server/index.js +886 -0
- package/runtime/packages/picasso-sdk-server/instructions.js +34 -0
- package/runtime/packages/picasso-sdk-server/jobs.js +113 -0
- package/runtime/packages/picasso-sdk-server/mcp-gate.js +51 -0
- package/runtime/packages/picasso-sdk-server/model-selection.js +162 -0
- package/runtime/packages/picasso-sdk-server/package.json +50 -0
- package/runtime/packages/picasso-sdk-server/picasso-records.js +50 -0
- package/runtime/packages/picasso-sdk-server/provider-reload.js +84 -0
- package/runtime/packages/picasso-sdk-server/queue.js +322 -0
- package/runtime/packages/picasso-sdk-server/requester.js +43 -0
- package/runtime/packages/picasso-sdk-server/rewind.js +108 -0
- package/runtime/packages/picasso-sdk-server/schedule.js +187 -0
- package/runtime/packages/picasso-sdk-server/session-grants.js +35 -0
- package/runtime/packages/picasso-sdk-server/session-state.js +118 -0
- package/runtime/packages/picasso-sdk-server/shell-paths.js +869 -0
- package/runtime/packages/picasso-sdk-server/stream-deltas.js +211 -0
- package/runtime/packages/picasso-sdk-server/team-tasks.js +451 -0
- package/runtime/packages/picasso-sdk-server/tool-output.js +128 -0
- package/runtime/packages/picasso-sdk-server/tools-list.js +51 -0
- package/runtime/packages/picasso-sdk-server/wave2-hooks.js +612 -0
- package/runtime/packages/picasso-sdk-server/workspace-archive.js +170 -0
- package/runtime/packages/picasso-sdk-server/workspace-restore.js +180 -0
- package/runtime/packages/picasso-web-search/backends.js +350 -0
- package/runtime/packages/picasso-web-search/config.js +121 -0
- package/runtime/packages/picasso-web-search/cordis.patch.yml +7 -0
- package/runtime/packages/picasso-web-search/failure.js +111 -0
- package/runtime/packages/picasso-web-search/format.js +35 -0
- package/runtime/packages/picasso-web-search/index.js +66 -0
- package/runtime/packages/picasso-web-search/package.json +38 -0
- package/runtime/packages/picasso-web-search/router.js +155 -0
- package/runtime/packages/picasso-x-reader/circle.js +324 -0
- package/runtime/packages/picasso-x-reader/command.js +169 -0
- package/runtime/packages/picasso-x-reader/cordis.patch.yml +8 -0
- package/runtime/packages/picasso-x-reader/index.js +170 -0
- package/runtime/packages/picasso-x-reader/package.json +39 -0
- package/runtime/packages/picasso-x-reader/read.js +370 -0
- package/runtime/packages/picasso-x-reader/rewrite.js +38 -0
- package/runtime/packages/picasso-x-reader/settings.js +131 -0
- package/runtime/packages/picasso-x-reader/urls.js +154 -0
- package/runtime/packages/picasso-x-reader/xmd.js +512 -0
- package/runtime/plugins/picasso-auth-bridge/index.js +380 -0
- package/runtime/plugins/picasso-auth-bridge/package.json +28 -0
- package/runtime/plugins/picasso-auto-approve/index.js +1003 -0
- package/runtime/plugins/picasso-auto-approve/package.json +28 -0
- package/runtime/plugins/picasso-browser/index.js +424 -0
- package/runtime/plugins/picasso-browser/package.json +28 -0
- package/runtime/plugins/picasso-checkpoints/evidence.js +210 -0
- package/runtime/plugins/picasso-checkpoints/index.js +885 -0
- package/runtime/plugins/picasso-checkpoints/package.json +29 -0
- package/runtime/plugins/picasso-commands/fresh-review.js +573 -0
- package/runtime/plugins/picasso-commands/index.js +497 -0
- package/runtime/plugins/picasso-commands/package.json +28 -0
- package/runtime/plugins/picasso-instructions/conflicts.js +115 -0
- package/runtime/plugins/picasso-instructions/formats.js +145 -0
- package/runtime/plugins/picasso-instructions/frontmatter.js +175 -0
- package/runtime/plugins/picasso-instructions/glob.js +114 -0
- package/runtime/plugins/picasso-instructions/globals.js +90 -0
- package/runtime/plugins/picasso-instructions/imports.js +123 -0
- package/runtime/plugins/picasso-instructions/index.js +326 -0
- package/runtime/plugins/picasso-instructions/modes.js +64 -0
- package/runtime/plugins/picasso-instructions/package.json +30 -0
- package/runtime/plugins/picasso-instructions/parse.js +134 -0
- package/runtime/plugins/picasso-instructions/report.js +161 -0
- package/runtime/plugins/picasso-instructions/resolve.js +939 -0
- package/runtime/plugins/picasso-instructions/scan.js +181 -0
- package/runtime/plugins/picasso-instructions/settings.js +150 -0
- package/runtime/plugins/picasso-instructions/skills.js +345 -0
- package/runtime/plugins/picasso-lean-context/index.js +6049 -0
- package/runtime/plugins/picasso-lean-context/package.json +26 -0
- package/runtime/plugins/picasso-lean-context/timeline.js +417 -0
- package/runtime/plugins/picasso-librarian/classify.js +146 -0
- package/runtime/plugins/picasso-librarian/index.js +878 -0
- package/runtime/plugins/picasso-librarian/notes.js +159 -0
- package/runtime/plugins/picasso-librarian/package.json +34 -0
- package/runtime/plugins/picasso-librarian/state.js +478 -0
- package/runtime/plugins/picasso-lifecycle-hooks/index.js +186 -0
- package/runtime/plugins/picasso-lifecycle-hooks/package.json +25 -0
- package/runtime/plugins/picasso-mail/inbox.js +207 -0
- package/runtime/plugins/picasso-mail/index.js +293 -0
- package/runtime/plugins/picasso-mail/package.json +22 -0
- package/runtime/plugins/picasso-memory/index.js +1184 -0
- package/runtime/plugins/picasso-memory/package.json +21 -0
- package/runtime/plugins/picasso-model-router/connections.js +895 -0
- package/runtime/plugins/picasso-model-router/index.js +1081 -0
- package/runtime/plugins/picasso-model-router/package.json +30 -0
- package/runtime/plugins/picasso-options/index.js +263 -0
- package/runtime/plugins/picasso-options/package.json +28 -0
- package/runtime/plugins/picasso-progress-reports/index.js +267 -0
- package/runtime/plugins/picasso-progress-reports/package.json +30 -0
- package/runtime/plugins/picasso-progress-reports/report.js +235 -0
- package/runtime/plugins/picasso-provider-models/index.js +436 -0
- package/runtime/plugins/picasso-provider-models/package.json +28 -0
- package/runtime/plugins/picasso-repo-index/index.js +1850 -0
- package/runtime/plugins/picasso-repo-index/package.json +28 -0
- package/runtime/plugins/picasso-schedule-pause/index.js +344 -0
- package/runtime/plugins/picasso-schedule-pause/package.json +28 -0
- package/runtime/plugins/picasso-session-lifecycle/index.js +796 -0
- package/runtime/plugins/picasso-session-lifecycle/package.json +28 -0
- package/runtime/plugins/picasso-trackers/index.js +895 -0
- package/runtime/plugins/picasso-trackers/package.json +28 -0
- package/runtime/plugins/picasso-web-search/backends.js +350 -0
- package/runtime/plugins/picasso-web-search/config.js +121 -0
- package/runtime/plugins/picasso-web-search/failure.js +111 -0
- package/runtime/plugins/picasso-web-search/format.js +35 -0
- package/runtime/plugins/picasso-web-search/index.js +66 -0
- package/runtime/plugins/picasso-web-search/package.json +38 -0
- package/runtime/plugins/picasso-web-search/router.js +155 -0
- package/runtime/plugins/picasso-x-reader/circle.js +324 -0
- package/runtime/plugins/picasso-x-reader/command.js +169 -0
- package/runtime/plugins/picasso-x-reader/index.js +170 -0
- package/runtime/plugins/picasso-x-reader/package.json +39 -0
- package/runtime/plugins/picasso-x-reader/read.js +370 -0
- package/runtime/plugins/picasso-x-reader/rewrite.js +38 -0
- package/runtime/plugins/picasso-x-reader/settings.js +131 -0
- package/runtime/plugins/picasso-x-reader/urls.js +154 -0
- package/runtime/plugins/picasso-x-reader/xmd.js +512 -0
- package/runtime/relay/attachment-text.mjs +737 -0
- package/runtime/relay/companion/companion.css +126 -0
- package/runtime/relay/companion/companion.js +648 -0
- package/runtime/relay/companion/icon.svg +5 -0
- package/runtime/relay/companion/index.html +25 -0
- package/runtime/relay/companion/manifest.json +13 -0
- package/runtime/relay/companion/sw.js +41 -0
- package/runtime/relay/main.mjs +37252 -0
- package/runtime/relay/model-listing.mjs +614 -0
- package/runtime/relay/versions-routes.mjs +1198 -0
- package/runtime/verify-plugins.mjs +205 -0
- package/runtime-lock/package-lock.json +10779 -0
- package/runtime-lock/package.json +7 -0
- package/scripts/install-runtime.mjs +400 -0
- package/README.md +0 -3
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// Live shell output for SDK clients.
|
|
2
|
+
//
|
|
3
|
+
// dsh's shell tools (`dsh-tool-bash`, `dsh-tool-pwsh`) register every call's
|
|
4
|
+
// process with the job registry (`ctx.jobs`, dsh-jobs-local) as it starts,
|
|
5
|
+
// foreground calls included; the registry pumps the process's stdout/stderr
|
|
6
|
+
// into the job's output ring and announces each append with a `{ type:
|
|
7
|
+
// 'output', id, owner, total }` event. The SDK server only notifies the
|
|
8
|
+
// durable `tool/result` once the command ends, so this subscribes to those
|
|
9
|
+
// events, reads the new bytes with the observer read (`readAt`, which never
|
|
10
|
+
// moves the model's cursor) and mirrors them as `session.delta`
|
|
11
|
+
// `{ sessionId, kind: 'tool-output', jobId, callId?, channel, text, offset,
|
|
12
|
+
// gap? }`. The tool call id comes from the durable `job/registered` session
|
|
13
|
+
// event dsh appends before the job's first output.
|
|
14
|
+
//
|
|
15
|
+
// Like stream-deltas.js: forwarding is gated by the client's `deltas` opt-in,
|
|
16
|
+
// is best-effort (every failure is swallowed, so a read can never break the
|
|
17
|
+
// command or the registry) and never durable.
|
|
18
|
+
|
|
19
|
+
import { SESSION_DELTA_METHOD } from './stream-deltas.js';
|
|
20
|
+
|
|
21
|
+
export const TOOL_OUTPUT_KIND = 'tool-output';
|
|
22
|
+
|
|
23
|
+
/** Tracked jobs before the oldest is forgotten (a client that never drains cannot grow this without bound). */
|
|
24
|
+
const MAX_TRACKED = 256;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Consecutive same-channel chunks of one read as deltas, from `offset`.
|
|
28
|
+
* Chunks starting before `offset` were forwarded already (a read resumes at a
|
|
29
|
+
* chunk boundary, so a chunk is never split). Exported for tests.
|
|
30
|
+
*/
|
|
31
|
+
export function outputDeltas({ sessionId, jobId, callId }, read, offset) {
|
|
32
|
+
const deltas = [];
|
|
33
|
+
let gap = read?.lossy === true;
|
|
34
|
+
for (const chunk of Array.isArray(read?.chunks) ? read.chunks : []) {
|
|
35
|
+
if (typeof chunk?.text !== 'string' || chunk.text.length === 0 || !Number.isSafeInteger(chunk.at) || chunk.at < offset) continue;
|
|
36
|
+
const channel = chunk.channel === 'stderr' || chunk.channel === 'log' ? chunk.channel : 'stdout';
|
|
37
|
+
const last = deltas.at(-1);
|
|
38
|
+
if (last !== undefined && last.channel === channel && chunk.gapBefore !== true) {
|
|
39
|
+
last.text += chunk.text;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
deltas.push({
|
|
43
|
+
sessionId,
|
|
44
|
+
kind: TOOL_OUTPUT_KIND,
|
|
45
|
+
jobId,
|
|
46
|
+
...(callId === undefined ? {} : { callId }),
|
|
47
|
+
channel,
|
|
48
|
+
text: chunk.text,
|
|
49
|
+
offset: chunk.at,
|
|
50
|
+
...(gap || chunk.gapBefore === true ? { gap: true } : {}),
|
|
51
|
+
});
|
|
52
|
+
gap = false;
|
|
53
|
+
}
|
|
54
|
+
return deltas;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Install the forwarder. `enabled()` gates it (the client opts in through
|
|
59
|
+
* `picasso/capabilities`); `notify(method, params)` writes the notification.
|
|
60
|
+
* The job registry may mount after this plugin, so it subscribes whenever a
|
|
61
|
+
* registry is (re)provided.
|
|
62
|
+
*/
|
|
63
|
+
export function installToolOutputDeltas(ctx, { enabled, notify }) {
|
|
64
|
+
/** jobId -> { sessionId, callId?, offset } for jobs whose output is being forwarded. */
|
|
65
|
+
const tracked = new Map();
|
|
66
|
+
/** jobId -> callId from `job/registered`, consumed when the job is first tracked. */
|
|
67
|
+
const callIds = new Map();
|
|
68
|
+
const remember = (map, key, value) => {
|
|
69
|
+
map.set(key, value);
|
|
70
|
+
while (map.size > MAX_TRACKED) map.delete(map.keys().next().value);
|
|
71
|
+
};
|
|
72
|
+
const disposeEvents = ctx.on('session/event', (_session, event) => {
|
|
73
|
+
if (event?.type !== 'job/registered') return;
|
|
74
|
+
const jobId = event.data?.jobId;
|
|
75
|
+
const callId = event.data?.toolCall?.callId;
|
|
76
|
+
if (typeof jobId !== 'string' || typeof callId !== 'string') return;
|
|
77
|
+
const entry = tracked.get(jobId);
|
|
78
|
+
if (entry !== undefined) entry.callId ??= callId;
|
|
79
|
+
else remember(callIds, jobId, callId);
|
|
80
|
+
});
|
|
81
|
+
const forward = (registry, jobId, owner) => {
|
|
82
|
+
let entry = tracked.get(jobId);
|
|
83
|
+
if (entry === undefined) {
|
|
84
|
+
if (typeof owner !== 'string' || owner.length === 0) return;
|
|
85
|
+
const callId = callIds.get(jobId);
|
|
86
|
+
callIds.delete(jobId);
|
|
87
|
+
entry = { sessionId: owner, ...(callId === undefined ? {} : { callId }), offset: 0 };
|
|
88
|
+
remember(tracked, jobId, entry);
|
|
89
|
+
}
|
|
90
|
+
const read = registry.readAt(jobId, entry.offset, entry.sessionId);
|
|
91
|
+
const deltas = outputDeltas({ sessionId: entry.sessionId, jobId, callId: entry.callId }, read, entry.offset);
|
|
92
|
+
if (Number.isSafeInteger(read?.next) && read.next >= entry.offset) entry.offset = read.next;
|
|
93
|
+
for (const delta of deltas) notify(SESSION_DELTA_METHOD, delta);
|
|
94
|
+
};
|
|
95
|
+
const subscribe = (registry) => registry?.events?.subscribe?.({ owners: 'all' }, (event) => {
|
|
96
|
+
try {
|
|
97
|
+
if (event?.type === 'output') {
|
|
98
|
+
if (tracked.get(event.id)?.done !== true && enabled()) forward(registry, event.id, event.owner);
|
|
99
|
+
} else if (event?.type === 'settled') {
|
|
100
|
+
// The pump drained before settlement; the `output` announced after
|
|
101
|
+
// `settled` carries nothing new, so the job is closed here.
|
|
102
|
+
const entry = tracked.get(event.job?.id);
|
|
103
|
+
if (entry !== undefined && enabled()) forward(registry, event.job.id, entry.sessionId);
|
|
104
|
+
if (entry !== undefined) entry.done = true;
|
|
105
|
+
else remember(tracked, event.job?.id, { done: true });
|
|
106
|
+
callIds.delete(event.job?.id);
|
|
107
|
+
} else if (event?.type === 'removed') {
|
|
108
|
+
tracked.delete(event.job?.id);
|
|
109
|
+
callIds.delete(event.job?.id);
|
|
110
|
+
}
|
|
111
|
+
} catch {
|
|
112
|
+
// forwarding is best-effort and never affects the job
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
let disposeJobs;
|
|
116
|
+
if (typeof ctx.inject === 'function') {
|
|
117
|
+
ctx.inject(['jobs'], (jobCtx) => {
|
|
118
|
+
// The subscription is an effect of `jobCtx`: it ends with that registry.
|
|
119
|
+
subscribe(jobCtx.jobs);
|
|
120
|
+
});
|
|
121
|
+
} else {
|
|
122
|
+
disposeJobs = subscribe(ctx.get?.('jobs') ?? ctx.jobs);
|
|
123
|
+
}
|
|
124
|
+
return () => {
|
|
125
|
+
disposeEvents?.();
|
|
126
|
+
disposeJobs?.();
|
|
127
|
+
};
|
|
128
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// `picasso/tools/list`: the tool definitions an agent of this engine would be offered, read without a model call.
|
|
2
|
+
//
|
|
3
|
+
// The background engine updater boots a staged engine headless (initialize -> picasso/capabilities ->
|
|
4
|
+
// picasso/tools/list -> shutdown) to prove our plugins load on it and that the tools the lean-context Tier 1 relies on
|
|
5
|
+
// are still there with compatible schemas. It opens one throwaway agent (no prompt, so no request ever reaches a
|
|
6
|
+
// model and no turn is synthesized), reads its tool schemas, and disposes it again.
|
|
7
|
+
|
|
8
|
+
export const TOOLS_LIST_METHOD = 'picasso/tools/list';
|
|
9
|
+
export const TOOLS_LIST_METHODS = Object.freeze([TOOLS_LIST_METHOD]);
|
|
10
|
+
|
|
11
|
+
/** `{ name, description, parameters }` for each schema the tools service projects (`schemas`, else the older `list`). */
|
|
12
|
+
export function projectToolSchemas(toolsSvc, scope) {
|
|
13
|
+
if (toolsSvc === undefined || toolsSvc === null) throw new Error('the tools service is not available');
|
|
14
|
+
const raw = typeof toolsSvc.schemas === 'function'
|
|
15
|
+
? toolsSvc.schemas(scope)
|
|
16
|
+
: typeof toolsSvc.list === 'function'
|
|
17
|
+
? toolsSvc.list(scope)
|
|
18
|
+
: undefined;
|
|
19
|
+
if (!Array.isArray(raw)) throw new Error('the tools service exposes neither schemas() nor list()');
|
|
20
|
+
const out = [];
|
|
21
|
+
for (const tool of raw) {
|
|
22
|
+
if (tool === null || typeof tool !== 'object' || typeof tool.name !== 'string') continue;
|
|
23
|
+
out.push({
|
|
24
|
+
name: tool.name,
|
|
25
|
+
description: typeof tool.description === 'string' ? tool.description : '',
|
|
26
|
+
parameters: tool.parameters ?? tool.inputSchema ?? {},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return out.sort((a, b) => a.name.localeCompare(b.name));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @param {{ tools: () => unknown, openProbe: (sessionId: string) => Promise<{ agent: unknown, dispose: () => Promise<void> }> }} deps
|
|
34
|
+
*/
|
|
35
|
+
export function createToolsList({ tools, openProbe }) {
|
|
36
|
+
return {
|
|
37
|
+
methods: {
|
|
38
|
+
async [TOOLS_LIST_METHOD](params) {
|
|
39
|
+
const sessionId = typeof params?.sessionId === 'string' && params.sessionId.length > 0
|
|
40
|
+
? params.sessionId
|
|
41
|
+
: `picasso-engine-probe-${Date.now().toString(36)}`;
|
|
42
|
+
const probe = await openProbe(sessionId);
|
|
43
|
+
try {
|
|
44
|
+
return { sessionId, tools: projectToolSchemas(tools(), probe.agent) };
|
|
45
|
+
} finally {
|
|
46
|
+
await probe.dispose();
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|