@cogenta/agents-builtin 0.4.0 → 0.5.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/dist/image-creator/agent.d.ts +40 -0
- package/dist/image-creator/agent.d.ts.map +1 -0
- package/dist/image-creator/agent.js +48 -0
- package/dist/image-creator/agent.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/theme-creator/generate-sandbox-theme.d.ts +84 -9
- package/dist/theme-creator/generate-sandbox-theme.d.ts.map +1 -1
- package/dist/theme-creator/generate-sandbox-theme.js +157 -38
- package/dist/theme-creator/generate-sandbox-theme.js.map +1 -1
- package/dist/theme-creator/generate-theme-candidates.d.ts +23 -0
- package/dist/theme-creator/generate-theme-candidates.d.ts.map +1 -1
- package/dist/theme-creator/generate-theme-candidates.js +30 -7
- package/dist/theme-creator/generate-theme-candidates.js.map +1 -1
- package/dist/theme-creator/preview-sandbox-tool.d.ts +57 -0
- package/dist/theme-creator/preview-sandbox-tool.d.ts.map +1 -0
- package/dist/theme-creator/preview-sandbox-tool.js +48 -0
- package/dist/theme-creator/preview-sandbox-tool.js.map +1 -0
- package/dist/theme-creator/read-sandbox-tool.d.ts +57 -0
- package/dist/theme-creator/read-sandbox-tool.d.ts.map +1 -0
- package/dist/theme-creator/read-sandbox-tool.js +55 -0
- package/dist/theme-creator/read-sandbox-tool.js.map +1 -0
- package/dist/theme-creator/theme-spec.d.ts +31 -0
- package/dist/theme-creator/theme-spec.d.ts.map +1 -0
- package/dist/theme-creator/theme-spec.js +254 -0
- package/dist/theme-creator/theme-spec.js.map +1 -0
- package/dist/theme-creator/write-sandbox-file-tool.d.ts +2 -0
- package/dist/theme-creator/write-sandbox-file-tool.d.ts.map +1 -1
- package/dist/theme-creator/write-sandbox-file-tool.js +13 -2
- package/dist/theme-creator/write-sandbox-file-tool.js.map +1 -1
- package/package.json +3 -3
|
@@ -47,6 +47,26 @@ export interface GenerateThemeCandidatesInput {
|
|
|
47
47
|
readonly sandboxId: string;
|
|
48
48
|
readonly path: string;
|
|
49
49
|
}) => Promise<void>;
|
|
50
|
+
/** Threaded straight through to `generateSandboxTheme`, where it becomes the run's `theme.preview_sandbox` tool — the difference between a writer that sees its own output and one that does not. */
|
|
51
|
+
readonly renderPreview?: (input: {
|
|
52
|
+
readonly sandboxId: string;
|
|
53
|
+
}) => Promise<{
|
|
54
|
+
readonly ok: true;
|
|
55
|
+
readonly html: string;
|
|
56
|
+
} | {
|
|
57
|
+
readonly ok: false;
|
|
58
|
+
readonly error: string;
|
|
59
|
+
}>;
|
|
60
|
+
/** The site's real content model, forwarded so a generated theme fetches what this site actually stores instead of inventing collections. */
|
|
61
|
+
readonly contentModel?: string;
|
|
62
|
+
/** Also threaded through — together they let a run change an existing theme instead of only writing a new one. */
|
|
63
|
+
readonly listFiles?: (input: {
|
|
64
|
+
readonly sandboxId: string;
|
|
65
|
+
}) => Promise<readonly string[]>;
|
|
66
|
+
readonly readFile?: (input: {
|
|
67
|
+
readonly sandboxId: string;
|
|
68
|
+
readonly path: string;
|
|
69
|
+
}) => Promise<string>;
|
|
50
70
|
readonly onProgress?: ProgressReporter;
|
|
51
71
|
readonly auditLog?: AuditLogLike;
|
|
52
72
|
readonly signal?: AbortSignal;
|
|
@@ -57,7 +77,10 @@ export type ThemeCandidate = ({
|
|
|
57
77
|
readonly kind: 'sandbox';
|
|
58
78
|
readonly id: string;
|
|
59
79
|
readonly label: string;
|
|
80
|
+
/** The agent's whole closing text — for the conversation, where it has room. */
|
|
60
81
|
readonly rationale: string;
|
|
82
|
+
/** The card-sized version of it, guaranteed short. */
|
|
83
|
+
readonly summary: string;
|
|
61
84
|
readonly sandboxId: string;
|
|
62
85
|
readonly filesWritten: readonly string[];
|
|
63
86
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-theme-candidates.d.ts","sourceRoot":"","sources":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F,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,sDAAsD;IACtD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;CACzC,CAAA;AAEL,MAAM,MAAM,6BAA6B,GACrC;IACE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAA;IACjB,QAAQ,CAAC,UAAU,EAAE,SAAS,cAAc,EAAE,CAAA;IAC9C,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAA;IACpC,qIAAqI;IACrI,QAAQ,CAAC,cAAc,EAAE;QAAE,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAA;CAC1F,GACD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnD,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE,4BAA4B,GAClC,OAAO,CAAC,6BAA6B,CAAC,CAuIxC"}
|
|
@@ -39,6 +39,17 @@ export async function generateThemeCandidates(input) {
|
|
|
39
39
|
};
|
|
40
40
|
const warnings = [...classification.processed.warnings];
|
|
41
41
|
const candidates = [];
|
|
42
|
+
// One answer unless more were asked for. A live run made the case against
|
|
43
|
+
// the old behaviour better than any argument could: a request for "un thème
|
|
44
|
+
// complet à partir du design sur la capture" came back as the one real
|
|
45
|
+
// custom layout plus three recolours of an installed blog theme, and the
|
|
46
|
+
// answer was buried among alternatives nobody wanted. The classifier reads
|
|
47
|
+
// the brief for an explicit count; everything else gets exactly one.
|
|
48
|
+
// Defended rather than trusted, even though the type says it is always
|
|
49
|
+
// there: this number is a loop bound, and an `undefined` one silently
|
|
50
|
+
// produces zero candidates — a feature that answers with nothing at all
|
|
51
|
+
// rather than with an error anyone could act on.
|
|
52
|
+
const requestedVariants = classification.requestedVariants ?? 1;
|
|
42
53
|
async function tryTokensCandidates() {
|
|
43
54
|
const result = await proposeThemeCandidates({
|
|
44
55
|
client: input.client,
|
|
@@ -48,7 +59,9 @@ export async function generateThemeCandidates(input) {
|
|
|
48
59
|
availableThemes: input.availableThemes,
|
|
49
60
|
...(input.attachments === undefined ? {} : { attachments: input.attachments }),
|
|
50
61
|
...(input.baseline === undefined ? {} : { baseline: input.baseline }),
|
|
51
|
-
|
|
62
|
+
// The brief's own count wins; an explicit caller-supplied ceiling
|
|
63
|
+
// still overrides it, which is what keeps existing callers unchanged.
|
|
64
|
+
maxCandidates: input.maxCandidates ?? requestedVariants,
|
|
52
65
|
...(input.onProgress === undefined ? {} : { onProgress: input.onProgress }),
|
|
53
66
|
});
|
|
54
67
|
if (!result.ok) {
|
|
@@ -62,7 +75,9 @@ export async function generateThemeCandidates(input) {
|
|
|
62
75
|
}
|
|
63
76
|
async function trySandboxCandidate() {
|
|
64
77
|
const sandboxId = input.mintSandboxId();
|
|
65
|
-
progress.report(`Writing a custom layout into sandbox "${sandboxId}"
|
|
78
|
+
progress.report(`Writing a custom layout into sandbox "${sandboxId}"…`, {
|
|
79
|
+
kind: 'stage',
|
|
80
|
+
});
|
|
66
81
|
const result = await generateSandboxTheme({
|
|
67
82
|
client: input.client,
|
|
68
83
|
model: input.model,
|
|
@@ -71,6 +86,10 @@ export async function generateThemeCandidates(input) {
|
|
|
71
86
|
sandboxId,
|
|
72
87
|
writeFile: input.writeFile,
|
|
73
88
|
deleteFile: input.deleteFile,
|
|
89
|
+
...(input.renderPreview === undefined ? {} : { renderPreview: input.renderPreview }),
|
|
90
|
+
...(input.contentModel === undefined ? {} : { contentModel: input.contentModel }),
|
|
91
|
+
...(input.listFiles === undefined ? {} : { listFiles: input.listFiles }),
|
|
92
|
+
...(input.readFile === undefined ? {} : { readFile: input.readFile }),
|
|
74
93
|
...(input.attachments === undefined ? {} : { attachments: input.attachments }),
|
|
75
94
|
...(input.onProgress === undefined ? {} : { onProgress: input.onProgress }),
|
|
76
95
|
...(input.auditLog === undefined ? {} : { auditLog: input.auditLog }),
|
|
@@ -85,16 +104,20 @@ export async function generateThemeCandidates(input) {
|
|
|
85
104
|
id: result.sandboxId,
|
|
86
105
|
label: 'Custom layout',
|
|
87
106
|
rationale: result.rationale,
|
|
107
|
+
summary: result.summary,
|
|
88
108
|
sandboxId: result.sandboxId,
|
|
89
109
|
filesWritten: result.filesWritten,
|
|
90
110
|
});
|
|
91
111
|
}
|
|
92
112
|
if (needsCustomLayout) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
113
|
+
for (let index = 0; index < requestedVariants; index++) {
|
|
114
|
+
await trySandboxCandidate();
|
|
115
|
+
}
|
|
116
|
+
// Only as a rescue: if writing a custom layout produced nothing at all,
|
|
117
|
+
// a tokens-only proposal is still better than an empty screen. When the
|
|
118
|
+
// custom layout worked, adding recolours beside it is noise.
|
|
119
|
+
if (candidates.length === 0)
|
|
120
|
+
await tryTokensCandidates();
|
|
98
121
|
}
|
|
99
122
|
else {
|
|
100
123
|
await tryTokensCandidates();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-theme-candidates.js","sourceRoot":"","sources":["../../src/theme-creator/generate-theme-candidates.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,uBAAuB,EACvB,aAAa,EAGb,sBAAsB,GAIvB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"generate-theme-candidates.js","sourceRoot":"","sources":["../../src/theme-creator/generate-theme-candidates.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,uBAAuB,EACvB,aAAa,EAGb,sBAAsB,GAIvB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAyFlE,MAAM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,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,YAAY,EAAE,MAAM,CAAC,YAAY;SAClC,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,iBAAiB,EAAE,CAAC;QACtB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,iBAAiB,EAAE,KAAK,EAAE,EAAE,CAAC;YACvD,MAAM,mBAAmB,EAAE,CAAA;QAC7B,CAAC;QACD,wEAAwE;QACxE,wEAAwE;QACxE,6DAA6D;QAC7D,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM,mBAAmB,EAAE,CAAA;IAC1D,CAAC;SAAM,CAAC;QACN,MAAM,mBAAmB,EAAE,CAAA;IAC7B,CAAC;IAED,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO;YACL,EAAE,EAAE,KAAK;YACT,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,gCAAgC;SAC5D,CAAA;IACH,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAA;AAC3D,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type ToolDefinition } from '@cogenta/agents';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* The feedback signal the theme writer never had.
|
|
5
|
+
*
|
|
6
|
+
* Before this tool, a generation run was open-loop: the model wrote files and
|
|
7
|
+
* heard back only "written" or a structural rejection (module failed to load,
|
|
8
|
+
* manifest field wrong). It never saw the page its own code produced, which
|
|
9
|
+
* is why asking it to reproduce a reference screenshot behaved like asking
|
|
10
|
+
* someone to paint blindfolded — no amount of prompt work fixes a control
|
|
11
|
+
* loop with no measurement in it.
|
|
12
|
+
*
|
|
13
|
+
* `renderSandboxPreview` (`@cogenta/cli`'s `theme-sandbox.ts`) already
|
|
14
|
+
* rendered a sandbox theme to real HTML in an isolated module, and the admin
|
|
15
|
+
* preview screen already used it. This exposes exactly that, unchanged, as a
|
|
16
|
+
* tool — so the writer can render, read what it actually produced, and
|
|
17
|
+
* correct it before finishing.
|
|
18
|
+
*
|
|
19
|
+
* Read-only by construction: `sideEffects: false`, no `revert` to have, and
|
|
20
|
+
* the injected `renderPreview` neither writes to the sandbox nor touches
|
|
21
|
+
* `themes/`. The HTML it returns is this theme's own output against a fixed
|
|
22
|
+
* demo page — never real site content, so nothing a visitor stored can reach
|
|
23
|
+
* the model through it.
|
|
24
|
+
*/
|
|
25
|
+
export interface PreviewSandboxToolOptions {
|
|
26
|
+
/** Exactly `renderSandboxPreview`'s own result shape (`@cogenta/cli`), threaded in as a plain function — this package cannot import `@cogenta/cli`, the dependency arrow runs the other way. The returned HTML is a whole document, the theme's stylesheet included inline. */
|
|
27
|
+
readonly renderPreview: (input: {
|
|
28
|
+
readonly sandboxId: string;
|
|
29
|
+
}) => Promise<{
|
|
30
|
+
readonly ok: true;
|
|
31
|
+
readonly html: string;
|
|
32
|
+
} | {
|
|
33
|
+
readonly ok: false;
|
|
34
|
+
readonly error: string;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* Guard against one render filling the whole context window: a theme that
|
|
38
|
+
* loops over demo entries can emit a lot of markup, and the model needs
|
|
39
|
+
* enough to judge structure, not every last node.
|
|
40
|
+
*/
|
|
41
|
+
readonly maxHtmlChars?: number;
|
|
42
|
+
}
|
|
43
|
+
declare const PreviewSandboxInputSchema: z.ZodObject<{
|
|
44
|
+
sandboxId: z.ZodString;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
export type PreviewSandboxInput = z.infer<typeof PreviewSandboxInputSchema>;
|
|
47
|
+
declare const PreviewSandboxOutputSchema: z.ZodObject<{
|
|
48
|
+
ok: z.ZodBoolean;
|
|
49
|
+
html: z.ZodOptional<z.ZodString>;
|
|
50
|
+
hasStylesheet: z.ZodOptional<z.ZodBoolean>;
|
|
51
|
+
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
52
|
+
error: z.ZodOptional<z.ZodString>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
export type PreviewSandboxOutput = z.infer<typeof PreviewSandboxOutputSchema>;
|
|
55
|
+
export declare function createPreviewSandboxTool(options: PreviewSandboxToolOptions): ToolDefinition<PreviewSandboxInput, PreviewSandboxOutput>;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=preview-sandbox-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-sandbox-tool.d.ts","sourceRoot":"","sources":["../../src/theme-creator/preview-sandbox-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,MAAM,WAAW,yBAAyB;IACxC,+QAA+Q;IAC/Q,QAAQ,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE;QAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;KAC3B,KAAK,OAAO,CACX;QAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAC9F,CAAA;IACD;;;;OAIG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAC/B;AAID,QAAA,MAAM,yBAAyB;;iBAE7B,CAAA;AACF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAE3E,QAAA,MAAM,0BAA0B;;;;;;iBAO9B,CAAA;AACF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAE7E,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,yBAAyB,GACjC,cAAc,CAAC,mBAAmB,EAAE,oBAAoB,CAAC,CAgC3D"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { defineTool } from '@cogenta/agents';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
const DEFAULT_MAX_HTML_CHARS = 12_000;
|
|
4
|
+
const PreviewSandboxInputSchema = z.object({
|
|
5
|
+
sandboxId: z.string().min(1),
|
|
6
|
+
});
|
|
7
|
+
const PreviewSandboxOutputSchema = z.object({
|
|
8
|
+
ok: z.boolean(),
|
|
9
|
+
html: z.string().optional(),
|
|
10
|
+
/** `false` means the rendered document carries no stylesheet at all — the theme will render as unstyled text no matter how good its markup is, and that is worth saying outright rather than leaving the model to notice. */
|
|
11
|
+
hasStylesheet: z.boolean().optional(),
|
|
12
|
+
truncated: z.boolean().optional(),
|
|
13
|
+
error: z.string().optional(),
|
|
14
|
+
});
|
|
15
|
+
export function createPreviewSandboxTool(options) {
|
|
16
|
+
const limit = options.maxHtmlChars ?? DEFAULT_MAX_HTML_CHARS;
|
|
17
|
+
return defineTool({
|
|
18
|
+
name: 'theme.preview_sandbox',
|
|
19
|
+
version: '1.0.0',
|
|
20
|
+
description: `Renders the theme currently written in a sandbox and returns the real HTML it produces, against a fixed demo page. This is the only way to find out what the theme you just wrote actually looks like — writing a file only reports that it was accepted, never that it renders the design you intended.
|
|
21
|
+
|
|
22
|
+
Call it after the theme's files are in place, and again after any correction. Read the returned markup as the page a visitor would get: check that the regions you designed are really there and really nested the way you meant, that no section silently rendered empty, and that the class names your CSS targets are the class names the markup actually carries — a selector that matches nothing is the single most common reason a written theme renders as unstyled text.
|
|
23
|
+
|
|
24
|
+
A render failure comes back with the real error message: fix the file it names and preview again. Never finish a run on a sandbox whose last preview failed.`,
|
|
25
|
+
input: PreviewSandboxInputSchema,
|
|
26
|
+
output: PreviewSandboxOutputSchema,
|
|
27
|
+
permissions: ['theme.write_sandbox'],
|
|
28
|
+
sideEffects: false,
|
|
29
|
+
// Nothing to undo: this tool only reads. `false` here is the honest
|
|
30
|
+
// declaration for a read-only tool, not a refusal to support undo.
|
|
31
|
+
reversible: false,
|
|
32
|
+
cost: 'low',
|
|
33
|
+
async execute(input) {
|
|
34
|
+
const result = await options.renderPreview({ sandboxId: input.sandboxId });
|
|
35
|
+
if (!result.ok) {
|
|
36
|
+
return { ok: false, error: result.error };
|
|
37
|
+
}
|
|
38
|
+
const truncated = result.html.length > limit;
|
|
39
|
+
return {
|
|
40
|
+
ok: true,
|
|
41
|
+
html: truncated ? `${result.html.slice(0, limit)}\n<!-- …truncated -->` : result.html,
|
|
42
|
+
hasStylesheet: /<style[\s>]/u.test(result.html),
|
|
43
|
+
truncated,
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=preview-sandbox-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview-sandbox-tool.js","sourceRoot":"","sources":["../../src/theme-creator/preview-sandbox-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAuB,MAAM,iBAAiB,CAAA;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAwCvB,MAAM,sBAAsB,GAAG,MAAM,CAAA;AAErC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IACzC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CAC7B,CAAC,CAAA;AAGF,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE;IACf,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,6NAA6N;IAC7N,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,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J,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type ToolDefinition } from '@cogenta/agents';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* What was missing for a theme to be *adjusted* rather than only created.
|
|
5
|
+
*
|
|
6
|
+
* The sandbox tools could write a file and render the result, but never read
|
|
7
|
+
* one back. Inside a single generation run that is survivable — the agent
|
|
8
|
+
* still has its own transcript, so it knows what it wrote. Across a second
|
|
9
|
+
* conversation turn ("make it darker", "put the grid on two columns") it is
|
|
10
|
+
* fatal: the agent is handed a theme it has never seen, and its only options
|
|
11
|
+
* are to guess or to rewrite the whole thing from scratch, throwing away
|
|
12
|
+
* every decision the operator just approved.
|
|
13
|
+
*
|
|
14
|
+
* Two tools, because listing and reading are genuinely different questions
|
|
15
|
+
* and a model asked to "read the theme" should not have to guess filenames:
|
|
16
|
+
* `theme.list_sandbox_files` answers "what is in here", and
|
|
17
|
+
* `theme.read_sandbox_file` answers "what does this one say".
|
|
18
|
+
*
|
|
19
|
+
* Both are read-only (`sideEffects: false`) and confined to one sandbox
|
|
20
|
+
* directory — the same directory `theme.write_sandbox_file` already writes
|
|
21
|
+
* to, with the same host-side path-escape guard in `@cogenta/cli`, which is
|
|
22
|
+
* where the real filesystem lives.
|
|
23
|
+
*/
|
|
24
|
+
export interface ReadSandboxToolsOptions {
|
|
25
|
+
readonly listFiles: (input: {
|
|
26
|
+
readonly sandboxId: string;
|
|
27
|
+
}) => Promise<readonly string[]>;
|
|
28
|
+
readonly readFile: (input: {
|
|
29
|
+
readonly sandboxId: string;
|
|
30
|
+
readonly path: string;
|
|
31
|
+
}) => Promise<string>;
|
|
32
|
+
/** A theme file that is genuinely enormous is truncated rather than allowed to crowd out the rest of the conversation. */
|
|
33
|
+
readonly maxFileChars?: number;
|
|
34
|
+
}
|
|
35
|
+
declare const ListInputSchema: z.ZodObject<{
|
|
36
|
+
sandboxId: z.ZodString;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
export type ListSandboxFilesInput = z.infer<typeof ListInputSchema>;
|
|
39
|
+
declare const ListOutputSchema: z.ZodObject<{
|
|
40
|
+
files: z.ZodArray<z.ZodString>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
export type ListSandboxFilesOutput = z.infer<typeof ListOutputSchema>;
|
|
43
|
+
declare const ReadInputSchema: z.ZodObject<{
|
|
44
|
+
sandboxId: z.ZodString;
|
|
45
|
+
path: z.ZodString;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
export type ReadSandboxFileInput = z.infer<typeof ReadInputSchema>;
|
|
48
|
+
declare const ReadOutputSchema: z.ZodObject<{
|
|
49
|
+
path: z.ZodString;
|
|
50
|
+
content: z.ZodString;
|
|
51
|
+
truncated: z.ZodOptional<z.ZodBoolean>;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
export type ReadSandboxFileOutput = z.infer<typeof ReadOutputSchema>;
|
|
54
|
+
export declare function createListSandboxFilesTool(options: Pick<ReadSandboxToolsOptions, 'listFiles'>): ToolDefinition<ListSandboxFilesInput, ListSandboxFilesOutput>;
|
|
55
|
+
export declare function createReadSandboxFileTool(options: Pick<ReadSandboxToolsOptions, 'readFile' | 'maxFileChars'>): ToolDefinition<ReadSandboxFileInput, ReadSandboxFileOutput>;
|
|
56
|
+
export {};
|
|
57
|
+
//# sourceMappingURL=read-sandbox-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-sandbox-tool.d.ts","sourceRoot":"","sources":["../../src/theme-creator/read-sandbox-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,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000;
|
|
4
|
+
const ListInputSchema = z.object({ sandboxId: z.string().min(1) });
|
|
5
|
+
const ListOutputSchema = z.object({ files: z.array(z.string()) });
|
|
6
|
+
const ReadInputSchema = z.object({
|
|
7
|
+
sandboxId: z.string().min(1),
|
|
8
|
+
/** Sandbox-relative, exactly as `theme.list_sandbox_files` returned it. */
|
|
9
|
+
path: z.string().min(1),
|
|
10
|
+
});
|
|
11
|
+
const ReadOutputSchema = z.object({
|
|
12
|
+
path: z.string(),
|
|
13
|
+
content: z.string(),
|
|
14
|
+
truncated: z.boolean().optional(),
|
|
15
|
+
});
|
|
16
|
+
export function createListSandboxFilesTool(options) {
|
|
17
|
+
return defineTool({
|
|
18
|
+
name: 'theme.list_sandbox_files',
|
|
19
|
+
version: '1.0.0',
|
|
20
|
+
description: `Lists every file currently in a theme sandbox, as sandbox-relative paths. Call it first when you are changing a theme you did not write in this conversation — you cannot correct a file whose name you had to guess, and a theme's stylesheet can be called anything.`,
|
|
21
|
+
input: ListInputSchema,
|
|
22
|
+
output: ListOutputSchema,
|
|
23
|
+
permissions: ['theme.write_sandbox'],
|
|
24
|
+
sideEffects: false,
|
|
25
|
+
reversible: false,
|
|
26
|
+
cost: 'low',
|
|
27
|
+
async execute(input) {
|
|
28
|
+
return { files: [...(await options.listFiles({ sandboxId: input.sandboxId }))] };
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export function createReadSandboxFileTool(options) {
|
|
33
|
+
const limit = options.maxFileChars ?? DEFAULT_MAX_FILE_CHARS;
|
|
34
|
+
return defineTool({
|
|
35
|
+
name: 'theme.read_sandbox_file',
|
|
36
|
+
version: '1.0.0',
|
|
37
|
+
description: `Returns the current contents of one file in a theme sandbox. Read a file before changing it: a write replaces the whole file, so editing from memory — or from what you assume a previous run wrote — silently drops everything you did not happen to reproduce. When a request asks to adjust part of a theme, read the file, change that part, and write the whole corrected file back.`,
|
|
38
|
+
input: ReadInputSchema,
|
|
39
|
+
output: ReadOutputSchema,
|
|
40
|
+
permissions: ['theme.write_sandbox'],
|
|
41
|
+
sideEffects: false,
|
|
42
|
+
reversible: false,
|
|
43
|
+
cost: 'low',
|
|
44
|
+
async execute(input) {
|
|
45
|
+
const content = await options.readFile({ sandboxId: input.sandboxId, path: input.path });
|
|
46
|
+
const truncated = content.length > limit;
|
|
47
|
+
return {
|
|
48
|
+
path: input.path,
|
|
49
|
+
content: truncated ? `${content.slice(0, limit)}\n/* …truncated */` : content,
|
|
50
|
+
truncated,
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=read-sandbox-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-sandbox-tool.js","sourceRoot":"","sources":["../../src/theme-creator/read-sandbox-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAuB,MAAM,iBAAiB,CAAA;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAkCvB,MAAM,sBAAsB,GAAG,MAAM,CAAA;AAErC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;AAGlE,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAA;AAGjE,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,2EAA2E;IAC3E,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACxB,CAAC,CAAA;AAGF,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC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AAC,CAAA;YACxF,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,KAAK,CAAA;YACxC,OAAO;gBACL,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC,OAAO;gBAC7E,SAAS;aACV,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The structure and composition of a Cogenta theme, as one standing
|
|
3
|
+
* specification handed to the model in the system prompt's own
|
|
4
|
+
* `<specification>` section (`assembleContext`, `@cogenta/agents`).
|
|
5
|
+
*
|
|
6
|
+
* **Why this file exists.** Every fact below already existed — scattered
|
|
7
|
+
* across `theme.write_sandbox_file`'s tool `description`, a 311-line
|
|
8
|
+
* `identity.md` no admin flow ever loads, and the contract D docs. A live
|
|
9
|
+
* report ("I attach a screenshot and what comes back is nowhere near it")
|
|
10
|
+
* traced back to that scattering: a tool description is read as API
|
|
11
|
+
* reference for one call, not as standing knowledge about what is being
|
|
12
|
+
* built, and the writer agent's actual system prompt was a one-sentence role
|
|
13
|
+
* plus ten bullets. The tool description keeps only what belongs to the
|
|
14
|
+
* tool (its arguments and what it rejects); everything about what a theme
|
|
15
|
+
* *is* lives here.
|
|
16
|
+
*
|
|
17
|
+
* **The palette rule reversed, deliberately.** The previous brief told the
|
|
18
|
+
* model "colour/font/spacing VALUES are not invented here — reference
|
|
19
|
+
* --cogenta-*". Those custom properties are generated exclusively from the
|
|
20
|
+
* *site's* skin (`theme-wiring.ts`'s `computeEffectiveStyles`), so a theme
|
|
21
|
+
* asked to reproduce a specific design was structurally repainted in
|
|
22
|
+
* whatever palette the site already had — the single largest cause of "far
|
|
23
|
+
* from the screenshot", and no amount of layout accuracy could compensate.
|
|
24
|
+
* A theme's own stylesheet is emitted *after* the skin stylesheet
|
|
25
|
+
* (`joinStyles`, `theme-render.ts`), so a theme can and should carry its own
|
|
26
|
+
* design palette. The namespaced pattern below keeps the site's brand colours
|
|
27
|
+
* reachable rather than simply overwriting `--cogenta-*` at `:root`, which
|
|
28
|
+
* would silently disable the operator's own colour controls.
|
|
29
|
+
*/
|
|
30
|
+
export declare const COGENTA_THEME_SPECIFICATION: string;
|
|
31
|
+
//# sourceMappingURL=theme-spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-spec.d.ts","sourceRoot":"","sources":["../../src/theme-creator/theme-spec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,2BAA2B,QA+NhC,CAAA"}
|