mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 00:04:50 +00:00
Replace hasArtifact with listArtifacts
LLMs don't need to check existence - they can just list all artifacts. Simpler API that returns all filenames at once. Changes: - Replace hasArtifact(filename) with listArtifacts() returning string[] - Add 'list' action handler that returns all artifact keys - Update examples in prompt to use listArtifacts()
This commit is contained in:
parent
7a859cbe52
commit
2e56f77599
2 changed files with 12 additions and 12 deletions
|
|
@ -41,20 +41,19 @@ export class ArtifactsRuntimeProvider implements SandboxRuntimeProvider {
|
|||
// Auto-parse/stringify for .json files
|
||||
const isJsonFile = (filename: string) => filename.endsWith(".json");
|
||||
|
||||
(window as any).hasArtifact = async (filename: string): Promise<boolean> => {
|
||||
(window as any).listArtifacts = async (): Promise<string[]> => {
|
||||
// Online: ask extension
|
||||
if ((window as any).sendRuntimeMessage) {
|
||||
const response = await (window as any).sendRuntimeMessage({
|
||||
type: "artifact-operation",
|
||||
action: "has",
|
||||
filename,
|
||||
action: "list",
|
||||
});
|
||||
if (!response.success) throw new Error(response.error);
|
||||
return response.result;
|
||||
}
|
||||
// Offline: check snapshot
|
||||
// Offline: return snapshot keys
|
||||
else {
|
||||
return !!(window as any).artifacts?.[filename];
|
||||
return Object.keys((window as any).artifacts || {});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -141,9 +140,9 @@ export class ArtifactsRuntimeProvider implements SandboxRuntimeProvider {
|
|||
|
||||
try {
|
||||
switch (action) {
|
||||
case "has": {
|
||||
const exists = this.artifactsPanel.artifacts.has(filename);
|
||||
respond({ success: true, result: exists });
|
||||
case "list": {
|
||||
const filenames = Array.from(this.artifactsPanel.artifacts.keys());
|
||||
respond({ success: true, result: filenames });
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue