@cogenta/agents-builtin 0.4.0 → 0.6.4
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 +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/plugin-builder/agent.d.ts +14 -0
- package/dist/plugin-builder/agent.d.ts.map +1 -0
- package/dist/plugin-builder/agent.js +22 -0
- package/dist/plugin-builder/agent.js.map +1 -0
- package/dist/plugin-builder/sandbox-tools.d.ts +89 -0
- package/dist/plugin-builder/sandbox-tools.d.ts.map +1 -0
- package/dist/plugin-builder/sandbox-tools.js +109 -0
- package/dist/plugin-builder/sandbox-tools.js.map +1 -0
- 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
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type AgentDeclaration } from '@cogenta/agents';
|
|
2
|
+
/**
|
|
3
|
+
* "Je pense qu'on doit ajouter un agent de génération d'image, ça permet
|
|
4
|
+
* qu'on le configure en choisissant le bon modèle" — the product owner,
|
|
5
|
+
* asking for images to have an owner rather than being a function call
|
|
6
|
+
* buried in another feature.
|
|
7
|
+
*
|
|
8
|
+
* The model choice that request is about is now real: a provider entry can
|
|
9
|
+
* declare an `imageModel` alongside its text one (`StoredProviderConfig`,
|
|
10
|
+
* `@cogenta/agents`), so an admin picks the image model from the same
|
|
11
|
+
* Providers screen as everything else. A multimodal vendor is one entry
|
|
12
|
+
* sharing one key — which is why this agent's own `model` field still names
|
|
13
|
+
* a *text* provider: it is the model that reasons about what to draw, and
|
|
14
|
+
* the image model is resolved separately from the provider registry. Putting
|
|
15
|
+
* an image model in `model.preferred` would conflate two different kinds of
|
|
16
|
+
* client behind one name, and a fallback chain "anthropic → openai" means
|
|
17
|
+
* nothing for pixels.
|
|
18
|
+
*
|
|
19
|
+
* **What it may do, and what it structurally cannot.** Two tools:
|
|
20
|
+
* `assist.generate_image` (`sideEffects: false` — it returns data URLs and
|
|
21
|
+
* stores nothing, by its own contract) and
|
|
22
|
+
* `media.store_generated_image` (`sideEffects: true`, `reversible: false`).
|
|
23
|
+
* That second pair of flags is not decoration: `withAutonomy` forces an
|
|
24
|
+
* approval for a side-effecting tool that is not reversible *whatever* the
|
|
25
|
+
* configured level, so `autonomous` cannot make this agent fill a library on
|
|
26
|
+
* its own. A human confirms every file that lands. `autonomy: propose` is
|
|
27
|
+
* pinned on top of that, so even the proposal is deliberate.
|
|
28
|
+
*
|
|
29
|
+
* Disabled by default, like every other seed here: nothing exports an
|
|
30
|
+
* "image-creator" entry from `builtinAgentSeeds()`, so this catalog entry is
|
|
31
|
+
* inert until an operator wires it into their own site.
|
|
32
|
+
*
|
|
33
|
+
* Its budget is deliberately small. Image generation is the most expensive
|
|
34
|
+
* call in this codebase by an order of magnitude — `assist.generate_image`
|
|
35
|
+
* carries its own `rateLimit` of 30/hour for that reason — and an agent that
|
|
36
|
+
* can quietly bill a site for a hundred pictures is a bug even when every
|
|
37
|
+
* picture is good.
|
|
38
|
+
*/
|
|
39
|
+
export declare const imageCreatorAgent: AgentDeclaration;
|
|
40
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/image-creator/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAe,MAAM,iBAAiB,CAAA;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAQ9B,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { defineAgent } from '@cogenta/agents';
|
|
2
|
+
/**
|
|
3
|
+
* "Je pense qu'on doit ajouter un agent de génération d'image, ça permet
|
|
4
|
+
* qu'on le configure en choisissant le bon modèle" — the product owner,
|
|
5
|
+
* asking for images to have an owner rather than being a function call
|
|
6
|
+
* buried in another feature.
|
|
7
|
+
*
|
|
8
|
+
* The model choice that request is about is now real: a provider entry can
|
|
9
|
+
* declare an `imageModel` alongside its text one (`StoredProviderConfig`,
|
|
10
|
+
* `@cogenta/agents`), so an admin picks the image model from the same
|
|
11
|
+
* Providers screen as everything else. A multimodal vendor is one entry
|
|
12
|
+
* sharing one key — which is why this agent's own `model` field still names
|
|
13
|
+
* a *text* provider: it is the model that reasons about what to draw, and
|
|
14
|
+
* the image model is resolved separately from the provider registry. Putting
|
|
15
|
+
* an image model in `model.preferred` would conflate two different kinds of
|
|
16
|
+
* client behind one name, and a fallback chain "anthropic → openai" means
|
|
17
|
+
* nothing for pixels.
|
|
18
|
+
*
|
|
19
|
+
* **What it may do, and what it structurally cannot.** Two tools:
|
|
20
|
+
* `assist.generate_image` (`sideEffects: false` — it returns data URLs and
|
|
21
|
+
* stores nothing, by its own contract) and
|
|
22
|
+
* `media.store_generated_image` (`sideEffects: true`, `reversible: false`).
|
|
23
|
+
* That second pair of flags is not decoration: `withAutonomy` forces an
|
|
24
|
+
* approval for a side-effecting tool that is not reversible *whatever* the
|
|
25
|
+
* configured level, so `autonomous` cannot make this agent fill a library on
|
|
26
|
+
* its own. A human confirms every file that lands. `autonomy: propose` is
|
|
27
|
+
* pinned on top of that, so even the proposal is deliberate.
|
|
28
|
+
*
|
|
29
|
+
* Disabled by default, like every other seed here: nothing exports an
|
|
30
|
+
* "image-creator" entry from `builtinAgentSeeds()`, so this catalog entry is
|
|
31
|
+
* inert until an operator wires it into their own site.
|
|
32
|
+
*
|
|
33
|
+
* Its budget is deliberately small. Image generation is the most expensive
|
|
34
|
+
* call in this codebase by an order of magnitude — `assist.generate_image`
|
|
35
|
+
* carries its own `rateLimit` of 30/hour for that reason — and an agent that
|
|
36
|
+
* can quietly bill a site for a hundred pictures is a bug even when every
|
|
37
|
+
* picture is good.
|
|
38
|
+
*/
|
|
39
|
+
export const imageCreatorAgent = defineAgent({
|
|
40
|
+
name: 'image-creator',
|
|
41
|
+
identity: './identity.md',
|
|
42
|
+
model: { preferred: 'claude-sonnet', fallback: 'local' },
|
|
43
|
+
tools: ['assist.generate_image', 'media.store_generated_image'],
|
|
44
|
+
autonomy: { default: 'propose' },
|
|
45
|
+
budget: { tokensPerDay: 40_000, eurPerMonth: 8, callsPerHour: 12 },
|
|
46
|
+
memory: { episodic: false, semantic: false, scope: 'site' },
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/image-creator/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAqB,WAAW,CAAC;IAC7D,IAAI,EAAE,eAAe;IACrB,QAAQ,EAAE,eAAe;IACzB,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,EAAE;IACxD,KAAK,EAAE,CAAC,uBAAuB,EAAE,6BAA6B,CAAC;IAC/D,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;IAChC,MAAM,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE;IAClE,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE;CAC5D,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { designerAgent } from './designer/agent.js';
|
|
|
10
10
|
export { developerAgent } from './developer/agent.js';
|
|
11
11
|
export type { CodePatchInput, CodePatchOutput, CodePatchToolOptions, } from './developer/patch-tool.js';
|
|
12
12
|
export { createCodePatchTool } from './developer/patch-tool.js';
|
|
13
|
+
export { imageCreatorAgent } from './image-creator/agent.js';
|
|
13
14
|
export { performanceAgent } from './performance/agent.js';
|
|
14
15
|
export { compareToBudget } from './performance/budget.js';
|
|
15
16
|
export type { CruxFormFactor, QueryCruxOptions } from './performance/crux-client.js';
|
|
@@ -19,6 +20,9 @@ export { medianMetrics, medianOf } from './performance/median.js';
|
|
|
19
20
|
export type { DetectRegressionOptions } from './performance/regression.js';
|
|
20
21
|
export { detectRegression } from './performance/regression.js';
|
|
21
22
|
export type { CruxMetrics, PerformanceBudget, PerformanceFinding, PerformanceImage, PerformancePageInput, PerformanceSeverity, } from './performance/types.js';
|
|
23
|
+
export { pluginBuilderAgent } from './plugin-builder/agent.js';
|
|
24
|
+
export type { CheckPluginSandboxInput, CheckPluginSandboxOutput, PluginSandboxToolOptions, ReadPluginSandboxInput, ReadPluginSandboxOutput, WritePluginSandboxFileInput, WritePluginSandboxFileOutput, } from './plugin-builder/sandbox-tools.js';
|
|
25
|
+
export { createCheckPluginSandboxTool, createReadPluginSandboxTool, createWritePluginSandboxFileTool, } from './plugin-builder/sandbox-tools.js';
|
|
22
26
|
export { securityAgent } from './security/agent.js';
|
|
23
27
|
export { bumpDependencyVersion } from './security/bump-version.js';
|
|
24
28
|
export type { DepsPatchInput, DepsPatchOutput, DepsPatchToolOptions, } from './security/deps-patch-tool.js';
|
|
@@ -55,8 +59,13 @@ export type { GenerateSandboxThemeInput, GenerateSandboxThemeResult, } from './t
|
|
|
55
59
|
export { generateSandboxTheme } from './theme-creator/generate-sandbox-theme.js';
|
|
56
60
|
export type { GenerateThemeCandidatesInput, GenerateThemeCandidatesResult, ThemeCandidate, } from './theme-creator/generate-theme-candidates.js';
|
|
57
61
|
export { generateThemeCandidates } from './theme-creator/generate-theme-candidates.js';
|
|
62
|
+
export type { PreviewSandboxInput, PreviewSandboxOutput, PreviewSandboxToolOptions, } from './theme-creator/preview-sandbox-tool.js';
|
|
63
|
+
export { createPreviewSandboxTool } from './theme-creator/preview-sandbox-tool.js';
|
|
58
64
|
export type { ProposeThemeInput, ProposeThemeOutput, ProposeThemeToolOptions, } from './theme-creator/propose-theme-tool.js';
|
|
59
65
|
export { createProposeThemeTool } from './theme-creator/propose-theme-tool.js';
|
|
66
|
+
export type { ListSandboxFilesInput, ListSandboxFilesOutput, ReadSandboxFileInput, ReadSandboxFileOutput, ReadSandboxToolsOptions, } from './theme-creator/read-sandbox-tool.js';
|
|
67
|
+
export { createListSandboxFilesTool, createReadSandboxFileTool, } from './theme-creator/read-sandbox-tool.js';
|
|
68
|
+
export { COGENTA_THEME_SPECIFICATION } from './theme-creator/theme-spec.js';
|
|
60
69
|
export type { WriteSandboxFileInput, WriteSandboxFileOutput, WriteSandboxFileToolOptions, } from './theme-creator/write-sandbox-file-tool.js';
|
|
61
70
|
export { createWriteSandboxFileTool } from './theme-creator/write-sandbox-file-tool.js';
|
|
62
71
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,YAAY,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAChE,YAAY,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAC3D,YAAY,EACV,eAAe,EACf,uBAAuB,EACvB,cAAc,EACd,kBAAkB,GACnB,MAAM,yBAAyB,CAAA;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,YAAY,EAAE,cAAc,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,YAAY,EACV,cAAc,EACd,eAAe,EACf,oBAAoB,GACrB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,yB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AAM,sCAAsC,CAAA;AAC7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAA;AAC3E,YAAY,EACV,qBAAqB,EACrB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,4CAA4C,CAAA;AACnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -5,12 +5,15 @@ export { suggestTopicGaps } from './content/topic-gaps.js';
|
|
|
5
5
|
export { designerAgent } from './designer/agent.js';
|
|
6
6
|
export { developerAgent } from './developer/agent.js';
|
|
7
7
|
export { createCodePatchTool } from './developer/patch-tool.js';
|
|
8
|
+
export { imageCreatorAgent } from './image-creator/agent.js';
|
|
8
9
|
export { performanceAgent } from './performance/agent.js';
|
|
9
10
|
export { compareToBudget } from './performance/budget.js';
|
|
10
11
|
export { queryCrux } from './performance/crux-client.js';
|
|
11
12
|
export { diagnosePerformanceRisks } from './performance/diagnosis.js';
|
|
12
13
|
export { medianMetrics, medianOf } from './performance/median.js';
|
|
13
14
|
export { detectRegression } from './performance/regression.js';
|
|
15
|
+
export { pluginBuilderAgent } from './plugin-builder/agent.js';
|
|
16
|
+
export { createCheckPluginSandboxTool, createReadPluginSandboxTool, createWritePluginSandboxFileTool, } from './plugin-builder/sandbox-tools.js';
|
|
14
17
|
export { securityAgent } from './security/agent.js';
|
|
15
18
|
export { bumpDependencyVersion } from './security/bump-version.js';
|
|
16
19
|
export { createDepsPatchTool } from './security/deps-patch-tool.js';
|
|
@@ -32,6 +35,9 @@ export { cosineSimilarity } from './seo/similarity.js';
|
|
|
32
35
|
export { themeCreatorAgent } from './theme-creator/agent.js';
|
|
33
36
|
export { generateSandboxTheme } from './theme-creator/generate-sandbox-theme.js';
|
|
34
37
|
export { generateThemeCandidates } from './theme-creator/generate-theme-candidates.js';
|
|
38
|
+
export { createPreviewSandboxTool } from './theme-creator/preview-sandbox-tool.js';
|
|
35
39
|
export { createProposeThemeTool } from './theme-creator/propose-theme-tool.js';
|
|
40
|
+
export { createListSandboxFilesTool, createReadSandboxFileTool, } from './theme-creator/read-sandbox-tool.js';
|
|
41
|
+
export { COGENTA_THEME_SPECIFICATION } from './theme-creator/theme-spec.js';
|
|
36
42
|
export { createWriteSandboxFileTool } from './theme-creator/write-sandbox-file-tool.js';
|
|
37
43
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAEhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAO3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAMrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAEzD,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAS9D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAMlE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAMnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,8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AM,gBAAgB,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAM7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAOhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAEhE,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAEpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAStD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAK5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAMhF,OAAO,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAA;AAMtF,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAA;AAMlF,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA;AAQ9E,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,GAC1B,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAA;AAM3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type AgentDeclaration } from '@cogenta/agents';
|
|
2
|
+
/**
|
|
3
|
+
* "Cogenta Plugin Builder" (L31 step 4): the agent a person asks for a
|
|
4
|
+
* feature this CMS does not have, which writes a real plugin for it.
|
|
5
|
+
*
|
|
6
|
+
* `autonomy: 'propose'` is pinned for the same reason the theme creator pins
|
|
7
|
+
* it: what this agent writes is code, and code reaches a site only when a
|
|
8
|
+
* human deploys the sandbox it was written in. There is deliberately no
|
|
9
|
+
* deploy tool — not because the agent cannot be trusted with one, but because
|
|
10
|
+
* "an agent proposes, a human applies" (R6) stops being true the moment such
|
|
11
|
+
* a tool exists.
|
|
12
|
+
*/
|
|
13
|
+
export declare const pluginBuilderAgent: AgentDeclaration;
|
|
14
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/plugin-builder/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAe,MAAM,iBAAiB,CAAA;AAEpE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAQ/B,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineAgent } from '@cogenta/agents';
|
|
2
|
+
/**
|
|
3
|
+
* "Cogenta Plugin Builder" (L31 step 4): the agent a person asks for a
|
|
4
|
+
* feature this CMS does not have, which writes a real plugin for it.
|
|
5
|
+
*
|
|
6
|
+
* `autonomy: 'propose'` is pinned for the same reason the theme creator pins
|
|
7
|
+
* it: what this agent writes is code, and code reaches a site only when a
|
|
8
|
+
* human deploys the sandbox it was written in. There is deliberately no
|
|
9
|
+
* deploy tool — not because the agent cannot be trusted with one, but because
|
|
10
|
+
* "an agent proposes, a human applies" (R6) stops being true the moment such
|
|
11
|
+
* a tool exists.
|
|
12
|
+
*/
|
|
13
|
+
export const pluginBuilderAgent = defineAgent({
|
|
14
|
+
name: 'plugin-builder',
|
|
15
|
+
identity: './identity.md',
|
|
16
|
+
model: { preferred: 'claude-sonnet', fallback: 'local' },
|
|
17
|
+
tools: ['plugin.write_sandbox_file', 'plugin.read_sandbox_file', 'plugin.check_sandbox'],
|
|
18
|
+
autonomy: { default: 'propose' },
|
|
19
|
+
budget: { tokensPerDay: 120_000, eurPerMonth: 8, callsPerHour: 20 },
|
|
20
|
+
memory: { episodic: false, semantic: false, scope: 'site' },
|
|
21
|
+
});
|
|
22
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/plugin-builder/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAEpE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAqB,WAAW,CAAC;IAC9D,IAAI,EAAE,gBAAgB;IACtB,QAAQ,EAAE,eAAe;IACzB,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,EAAE;IACxD,KAAK,EAAE,CAAC,2BAA2B,EAAE,0BAA0B,EAAE,sBAAsB,CAAC;IACxF,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;IAChC,MAAM,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE;IACnE,MAAM,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE;CAC5D,CAAC,CAAA"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type ToolDefinition } from '@cogenta/agents';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* The three tools "Cogenta Plugin Builder" has (L31 step 4), mirroring the
|
|
5
|
+
* theme workshop's (fiche 73 task 7) down to the same guarantees:
|
|
6
|
+
*
|
|
7
|
+
* - they write into `<projectRoot>/.cogenta/plugin-sandbox/<id>/` and nowhere
|
|
8
|
+
* else — never `plugins/`, so nothing an agent writes is ever something a
|
|
9
|
+
* running site would load;
|
|
10
|
+
* - the write is `sideEffects: true` + `reversible: true` with a real
|
|
11
|
+
* `revert` (it deletes the file it wrote), so `withAutonomy` governs it
|
|
12
|
+
* like any other write rather than the tool policing itself (R4);
|
|
13
|
+
* - the filesystem guards live host-side, in `@cogenta/cli`'s
|
|
14
|
+
* `plugin-sandbox.ts`: this package has no filesystem of its own to guard,
|
|
15
|
+
* and a path that leaves the sandbox is refused there, on the real disk.
|
|
16
|
+
*
|
|
17
|
+
* Installing what the sandbox holds is deliberately **not** a tool. It is a
|
|
18
|
+
* human action, from the admin or the CLI, after reading what the plugin
|
|
19
|
+
* asks for.
|
|
20
|
+
*/
|
|
21
|
+
export interface PluginSandboxToolOptions {
|
|
22
|
+
readonly writeFile: (input: {
|
|
23
|
+
readonly sandboxId: string;
|
|
24
|
+
readonly path: string;
|
|
25
|
+
readonly content: string;
|
|
26
|
+
}) => Promise<{
|
|
27
|
+
readonly path: string;
|
|
28
|
+
}>;
|
|
29
|
+
readonly deleteFile: (input: {
|
|
30
|
+
readonly sandboxId: string;
|
|
31
|
+
readonly path: string;
|
|
32
|
+
}) => Promise<void>;
|
|
33
|
+
readonly readFile: (input: {
|
|
34
|
+
readonly sandboxId: string;
|
|
35
|
+
readonly path: string;
|
|
36
|
+
}) => Promise<{
|
|
37
|
+
readonly content: string;
|
|
38
|
+
}>;
|
|
39
|
+
readonly listFiles: (input: {
|
|
40
|
+
readonly sandboxId: string;
|
|
41
|
+
}) => Promise<readonly string[]>;
|
|
42
|
+
readonly check: (input: {
|
|
43
|
+
readonly sandboxId: string;
|
|
44
|
+
}) => Promise<{
|
|
45
|
+
readonly ok: boolean;
|
|
46
|
+
readonly problems: readonly string[];
|
|
47
|
+
readonly handlers: readonly string[];
|
|
48
|
+
readonly capabilities: readonly string[];
|
|
49
|
+
}>;
|
|
50
|
+
}
|
|
51
|
+
declare const WriteInput: z.ZodObject<{
|
|
52
|
+
sandboxId: z.ZodString;
|
|
53
|
+
path: z.ZodString;
|
|
54
|
+
content: z.ZodString;
|
|
55
|
+
}, z.core.$strip>;
|
|
56
|
+
export type WritePluginSandboxFileInput = z.infer<typeof WriteInput>;
|
|
57
|
+
declare const WriteOutput: z.ZodObject<{
|
|
58
|
+
sandboxId: z.ZodString;
|
|
59
|
+
path: z.ZodString;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
export type WritePluginSandboxFileOutput = z.infer<typeof WriteOutput>;
|
|
62
|
+
export declare function createWritePluginSandboxFileTool(options: PluginSandboxToolOptions): ToolDefinition<WritePluginSandboxFileInput, WritePluginSandboxFileOutput>;
|
|
63
|
+
declare const ReadInput: z.ZodObject<{
|
|
64
|
+
sandboxId: z.ZodString;
|
|
65
|
+
path: z.ZodOptional<z.ZodString>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export type ReadPluginSandboxInput = z.infer<typeof ReadInput>;
|
|
68
|
+
declare const ReadOutput: z.ZodObject<{
|
|
69
|
+
sandboxId: z.ZodString;
|
|
70
|
+
files: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
71
|
+
path: z.ZodOptional<z.ZodString>;
|
|
72
|
+
content: z.ZodOptional<z.ZodString>;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
export type ReadPluginSandboxOutput = z.infer<typeof ReadOutput>;
|
|
75
|
+
export declare function createReadPluginSandboxTool(options: PluginSandboxToolOptions): ToolDefinition<ReadPluginSandboxInput, ReadPluginSandboxOutput>;
|
|
76
|
+
declare const CheckInput: z.ZodObject<{
|
|
77
|
+
sandboxId: z.ZodString;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
export type CheckPluginSandboxInput = z.infer<typeof CheckInput>;
|
|
80
|
+
declare const CheckOutput: z.ZodObject<{
|
|
81
|
+
ok: z.ZodBoolean;
|
|
82
|
+
problems: z.ZodArray<z.ZodString>;
|
|
83
|
+
handlers: z.ZodArray<z.ZodString>;
|
|
84
|
+
capabilities: z.ZodArray<z.ZodString>;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
export type CheckPluginSandboxOutput = z.infer<typeof CheckOutput>;
|
|
87
|
+
export declare function createCheckPluginSandboxTool(options: PluginSandboxToolOptions): ToolDefinition<CheckPluginSandboxInput, CheckPluginSandboxOutput>;
|
|
88
|
+
export {};
|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1C,OAAO,EAAE,wBAAwB,GAChC,cAAc,CAAC,uBAAuB,EAAE,wBAAwB,CAAC,CAsBnE"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { defineTool } from '@cogenta/agents';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
const WriteInput = z.object({
|
|
4
|
+
sandboxId: z.string().min(1),
|
|
5
|
+
/** Sandbox-relative: `plugin.manifest.json`, `plugin.js`, `lib/feed.js`. Never absolute, never `../`. */
|
|
6
|
+
path: z.string().min(1),
|
|
7
|
+
content: z.string(),
|
|
8
|
+
});
|
|
9
|
+
const WriteOutput = z.object({ sandboxId: z.string(), path: z.string() });
|
|
10
|
+
const WRITE_DESCRIPTION = `Writes one real source file into a plugin sandbox — actual JavaScript, not a description of it. A plugin is how this CMS gains a feature it does not have: it reacts to content events, serves its own page, or runs on a cadence, inside an isolated worker with only the capabilities a human granted it.
|
|
11
|
+
|
|
12
|
+
Two files matter. \`plugin.manifest.json\` is a JSON object — data, never code, because a manifest is read and never executed — with EXACTLY these fields: name (a package-like name, e.g. 'newsletter-digest'), version ('1.0.0', exact semver), engine ('^1.0.0', a semver RANGE), capabilities (string[], see below), provides (object, see below), runtime: 'server', isolated: true, and optionally main (the code file, 'plugin.js' by default).
|
|
13
|
+
|
|
14
|
+
\`plugin.js\` is a classic script — no import, no require, no top-level await. Its completion value is the set of handlers the site can call, written as an expression statement:
|
|
15
|
+
|
|
16
|
+
;({
|
|
17
|
+
onContentEvent: async (event) => { /* event.event, event.collection, event.id */ },
|
|
18
|
+
onRequest: async (request) => ({ status: 200, contentType: 'text/html', body: '<p>hi</p>' }),
|
|
19
|
+
onSchedule: async ({ name }) => 'what it did',
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
Which handlers to write follows from \`provides\`: eventSubscriptions: ['content.publish'|'content.unpublish'|'content.delete'] needs onContentEvent; routes: ['/hello'] needs onRequest (served at /_cogenta/plugins/<name>/hello, and the answer may set a status, a contentType among text/plain, text/html, application/json, application/xml, text/csv, and a body — never a header); schedules: [{ name: 'digest', everyMinutes: 1440 }] needs onSchedule (five minutes minimum).
|
|
23
|
+
|
|
24
|
+
Capabilities a host implements today, and nothing else: content.read, content.write_draft, content.publish, content.delete, media.read, schema.read, http.fetch:<hostname>, storage.read:plugins/<plugin name>, storage.write:plugins/<plugin name>. The four content ones may name a collection (content.write_draft:article). Ask for the fewest that do the job — each one is something a person must agree to, and a plugin that asks for more than it uses is harder to say yes to. Anything not on that list (channel.send, agent.delegate, memory.*, deps.*, build.trigger, deploy.trigger, site.config_*, media.write) cannot be granted and would leave the method absent from \`sdk\`.
|
|
25
|
+
|
|
26
|
+
Inside a handler, \`sdk\` is the only global that matters: sdk.content.read({id}), sdk.content.write_draft({collection, values}), sdk.schema.read({}), sdk.http.fetch({url}), sdk.storage.read({key})/write({key, content}). A capability that was not granted is ABSENT from sdk — not a refusing stub — so guard with \`if (!sdk.storage) …\` when it is optional.
|
|
27
|
+
|
|
28
|
+
Write the manifest first, then the code, then call plugin.check_sandbox and fix what it names. Never write into plugins/: deploying the sandbox is a separate action a human takes after reading what the plugin asks for.`;
|
|
29
|
+
export function createWritePluginSandboxFileTool(options) {
|
|
30
|
+
return defineTool({
|
|
31
|
+
name: 'plugin.write_sandbox_file',
|
|
32
|
+
version: '1.0.0',
|
|
33
|
+
description: WRITE_DESCRIPTION,
|
|
34
|
+
input: WriteInput,
|
|
35
|
+
output: WriteOutput,
|
|
36
|
+
permissions: ['plugin.write_sandbox'],
|
|
37
|
+
sideEffects: true,
|
|
38
|
+
reversible: true,
|
|
39
|
+
cost: 'low',
|
|
40
|
+
async execute(input) {
|
|
41
|
+
const written = await options.writeFile(input);
|
|
42
|
+
return { sandboxId: input.sandboxId, path: written.path };
|
|
43
|
+
},
|
|
44
|
+
async revert(receipt) {
|
|
45
|
+
await options.deleteFile({ sandboxId: receipt.sandboxId, path: receipt.path });
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const ReadInput = z.object({
|
|
50
|
+
sandboxId: z.string().min(1),
|
|
51
|
+
/** Omitted: the sandbox's file list, which is where to start on a sandbox someone else began. */
|
|
52
|
+
path: z.string().min(1).optional(),
|
|
53
|
+
});
|
|
54
|
+
const ReadOutput = z.object({
|
|
55
|
+
sandboxId: z.string(),
|
|
56
|
+
files: z.array(z.string()).optional(),
|
|
57
|
+
path: z.string().optional(),
|
|
58
|
+
content: z.string().optional(),
|
|
59
|
+
});
|
|
60
|
+
export function createReadPluginSandboxTool(options) {
|
|
61
|
+
return defineTool({
|
|
62
|
+
name: 'plugin.read_sandbox_file',
|
|
63
|
+
version: '1.0.0',
|
|
64
|
+
description: 'Reads what a plugin sandbox already holds: its file list with no path, or one file’s content with one. Read before rewriting — a sandbox may already hold work, yours or a person’s.',
|
|
65
|
+
input: ReadInput,
|
|
66
|
+
output: ReadOutput,
|
|
67
|
+
permissions: ['plugin.write_sandbox'],
|
|
68
|
+
sideEffects: false,
|
|
69
|
+
reversible: false,
|
|
70
|
+
cost: 'low',
|
|
71
|
+
async execute(input) {
|
|
72
|
+
if (input.path === undefined) {
|
|
73
|
+
return { sandboxId: input.sandboxId, files: [...(await options.listFiles(input))] };
|
|
74
|
+
}
|
|
75
|
+
const file = await options.readFile({ sandboxId: input.sandboxId, path: input.path });
|
|
76
|
+
return { sandboxId: input.sandboxId, path: input.path, content: file.content };
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const CheckInput = z.object({ sandboxId: z.string().min(1) });
|
|
81
|
+
const CheckOutput = z.object({
|
|
82
|
+
ok: z.boolean(),
|
|
83
|
+
problems: z.array(z.string()),
|
|
84
|
+
handlers: z.array(z.string()),
|
|
85
|
+
capabilities: z.array(z.string()),
|
|
86
|
+
});
|
|
87
|
+
export function createCheckPluginSandboxTool(options) {
|
|
88
|
+
return defineTool({
|
|
89
|
+
name: 'plugin.check_sandbox',
|
|
90
|
+
version: '1.0.0',
|
|
91
|
+
description: 'Checks a plugin sandbox the way the site would before installing it: the manifest must validate, the code must evaluate inside the real isolated worker with nothing granted, every declared event, route and schedule must have its handler, and every capability must be one a host implements. Returns the problems by name — fix them and check again. It runs the code with no capability at all, so it can touch nothing.',
|
|
92
|
+
input: CheckInput,
|
|
93
|
+
output: CheckOutput,
|
|
94
|
+
permissions: ['plugin.write_sandbox'],
|
|
95
|
+
sideEffects: false,
|
|
96
|
+
reversible: false,
|
|
97
|
+
cost: 'low',
|
|
98
|
+
async execute(input) {
|
|
99
|
+
const result = await options.check(input);
|
|
100
|
+
return {
|
|
101
|
+
ok: result.ok,
|
|
102
|
+
problems: [...result.problems],
|
|
103
|
+
handlers: [...result.handlers],
|
|
104
|
+
capabilities: [...result.capabilities],
|
|
105
|
+
};
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=sandbox-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sandbox-tools.js","sourceRoot":"","sources":["../../src/plugin-builder/sandbox-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAuB,MAAM,iBAAiB,CAAA;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AA4CvB,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1B,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,yGAAyG;IACzG,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAA;AAGF,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AAGzE,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;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AAC,MAAM,EAAE,CAAC;IAC7B,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC7B,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CAClC,CAAC,CAAA;AAGF,MAAM,UAAU,4BAA4B,CAC1C,OAAiC;IAEjC,OAAO,UAAU,CAAC;QAChB,IAAI,EAAE,sBAAsB;QAC5B,OAAO,EAAE,OAAO;QAChB,WAAW,EACT,iaAAia;QACna,KAAK,EAAE,UAAU;QACjB,MAAM,EAAE,WAAW;QACnB,WAAW,EAAE,CAAC,sBAAsB,CAAC;QACrC,WAAW,EAAE,KAAK;QAClB,UAAU,EAAE,KAAK;QACjB,IAAI,EAAE,KAAK;QACX,KAAK,CAAC,OAAO,CAAC,KAAK;YACjB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YACzC,OAAO;gBACL,EAAE,EAAE,MAAM,CAAC,EAAE;gBACb,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;gBAC9B,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;gBAC9B,YAAY,EAAE,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC;aACvC,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -5,13 +5,27 @@ import { type AuditLogLike, type ProgressReporter, type ProviderClient, type The
|
|
|
5
5
|
* already active (`theme.propose_theme` → contract D tokens), never write
|
|
6
6
|
* the actual page layout a reference screenshot or a "make it look exactly
|
|
7
7
|
* like this" request asked for. `theme.write_sandbox_file` already existed
|
|
8
|
-
* (fiche 73 task 7)
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
8
|
+
* (fiche 73 task 7) but no admin-facing flow ever drove a model through
|
|
9
|
+
* calling it. This is that flow.
|
|
10
|
+
*
|
|
11
|
+
* **Why it was rebuilt.** The first version of this run did produce themes,
|
|
12
|
+
* and they still came back nowhere near an attached screenshot. Three
|
|
13
|
+
* reasons, all fixed here rather than by asking for a better model:
|
|
14
|
+
*
|
|
15
|
+
* - It ran **open-loop**. The only feedback a write earned was "accepted" or
|
|
16
|
+
* a structural rejection; the model never saw the page its code rendered.
|
|
17
|
+
* `theme.preview_sandbox` (`preview-sandbox-tool.ts`) closes that loop with
|
|
18
|
+
* the render the admin preview screen was already using.
|
|
19
|
+
* - It **began by writing**. The opening message was "write the theme files
|
|
20
|
+
* now", so the first act on a barely-examined screenshot was a manifest,
|
|
21
|
+
* and every later file inherited that first guess. The objectives below
|
|
22
|
+
* now impose look → plan → write → preview → correct.
|
|
23
|
+
* - Its **system prompt was one sentence and ten bullets**, while everything
|
|
24
|
+
* about what a theme actually is sat in a tool `description` — read as API
|
|
25
|
+
* reference for one call, not as standing knowledge. That structural brief
|
|
26
|
+
* is now its own system-prompt section (`theme-spec.ts`), which is also
|
|
27
|
+
* where the palette rule was corrected: a theme owns its design colours
|
|
28
|
+
* instead of inheriting whatever skin the site already had.
|
|
15
29
|
*
|
|
16
30
|
* **Autonomy, deliberately local to this call, not the catalog agent's own.**
|
|
17
31
|
* The "Cogenta Theme Creator" catalog declaration
|
|
@@ -51,11 +65,57 @@ export interface GenerateSandboxThemeInput {
|
|
|
51
65
|
readonly sandboxId: string;
|
|
52
66
|
readonly path: string;
|
|
53
67
|
}) => Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Present when this run continues an earlier one instead of starting a
|
|
70
|
+
* theme — the operator has seen the result and is asking for a change
|
|
71
|
+
* ("plus sombre", "la grille en deux colonnes"). `description` then holds
|
|
72
|
+
* the change, not the original brief.
|
|
73
|
+
*/
|
|
74
|
+
readonly refine?: {
|
|
75
|
+
readonly originalBrief: string;
|
|
76
|
+
/** What was already said, oldest first — so a third request can refer to what the second one settled. */
|
|
77
|
+
readonly priorTurns?: readonly {
|
|
78
|
+
readonly role: 'user' | 'assistant';
|
|
79
|
+
readonly text: string;
|
|
80
|
+
}[];
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* What this site actually stores, described in plain terms — collection
|
|
84
|
+
* names, their fields, and whether each has a public page.
|
|
85
|
+
*
|
|
86
|
+
* A theme renders the site's content, so a writer that does not know the
|
|
87
|
+
* real collection names invents them; an invented `posts` on a site whose
|
|
88
|
+
* entries live in `article` renders nothing, and the tempting fix is to
|
|
89
|
+
* hardcode articles into the markup, where nobody can edit or translate
|
|
90
|
+
* them. Absent only when the caller has no schema in hand.
|
|
91
|
+
*/
|
|
92
|
+
readonly contentModel?: string;
|
|
93
|
+
/** Lists what is already in the sandbox. Required, with `readFile`, for a run that adjusts an existing theme rather than writing a new one. */
|
|
94
|
+
readonly listFiles?: (input: {
|
|
95
|
+
readonly sandboxId: string;
|
|
96
|
+
}) => Promise<readonly string[]>;
|
|
97
|
+
/** Reads one existing sandbox file, so a change can be made to what is really there instead of to what the agent assumes is there. */
|
|
98
|
+
readonly readFile?: (input: {
|
|
99
|
+
readonly sandboxId: string;
|
|
100
|
+
readonly path: string;
|
|
101
|
+
}) => Promise<string>;
|
|
102
|
+
/** Renders what has been written so far, so the run is a closed loop rather than a blind one — see `preview-sandbox-tool.ts`. Omitting it silently returns this run to the old write-and-hope behaviour. */
|
|
103
|
+
readonly renderPreview?: (input: {
|
|
104
|
+
readonly sandboxId: string;
|
|
105
|
+
}) => Promise<{
|
|
106
|
+
readonly ok: true;
|
|
107
|
+
readonly html: string;
|
|
108
|
+
} | {
|
|
109
|
+
readonly ok: false;
|
|
110
|
+
readonly error: string;
|
|
111
|
+
}>;
|
|
54
112
|
readonly onProgress?: ProgressReporter;
|
|
55
113
|
/** R6 — every write this run makes is journalled, the same way every other agent tool call already is. Absent only when the caller has no audit log available yet (never the common case). */
|
|
56
114
|
readonly auditLog?: AuditLogLike;
|
|
57
|
-
/** Hard ceiling on model turns — config + render +
|
|
115
|
+
/** Hard ceiling on model turns — analysis, a plan, config + render + CSS, then preview-and-correct cycles, all fit under the default. */
|
|
58
116
|
readonly maxSteps?: number;
|
|
117
|
+
/** How many byte-identical tool calls this run tolerates before it stops — see where it is passed for why the runtime default is wrong for this particular loop. */
|
|
118
|
+
readonly maxRepeats?: number;
|
|
59
119
|
readonly signal?: AbortSignal;
|
|
60
120
|
}
|
|
61
121
|
export type GenerateSandboxThemeResult = {
|
|
@@ -63,11 +123,26 @@ export type GenerateSandboxThemeResult = {
|
|
|
63
123
|
readonly sandboxId: string;
|
|
64
124
|
/** Sandbox-relative paths, in the order they were successfully written. */
|
|
65
125
|
readonly filesWritten: readonly string[];
|
|
66
|
-
/** The model's own closing
|
|
126
|
+
/** The model's own closing text, whole — it belongs in the conversation, where length is not a problem. */
|
|
67
127
|
readonly rationale: string;
|
|
128
|
+
/**
|
|
129
|
+
* The same thing, cut to something a card can hold.
|
|
130
|
+
*
|
|
131
|
+
* The prompt asks for at most three sentences, and a live run answered
|
|
132
|
+
* with its entire page-by-page analysis instead — several thousand
|
|
133
|
+
* words that stretched the candidate card past any usable height. An
|
|
134
|
+
* instruction is a request; this is the guarantee.
|
|
135
|
+
*/
|
|
136
|
+
readonly summary: string;
|
|
68
137
|
} | {
|
|
69
138
|
readonly ok: false;
|
|
70
139
|
readonly reason: string;
|
|
71
140
|
};
|
|
141
|
+
/**
|
|
142
|
+
* Cuts the model's closing text down to a card-sized line: whole sentences
|
|
143
|
+
* while they fit, then a hard character stop so a single unpunctuated
|
|
144
|
+
* paragraph cannot defeat it either.
|
|
145
|
+
*/
|
|
146
|
+
export declare function summarise(text: string, limit?: number): string;
|
|
72
147
|
export declare function generateSandboxTheme(input: GenerateSandboxThemeInput): Promise<GenerateSandboxThemeResult>;
|
|
73
148
|
//# sourceMappingURL=generate-sandbox-theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-sandbox-theme.d.ts","sourceRoot":"","sources":["../../src/theme-creator/generate-sandbox-theme.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EAOjB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EAGnB,KAAK,sBAAsB,EAI5B,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"generate-sandbox-theme.d.ts","sourceRoot":"","sources":["../../src/theme-creator/generate-sandbox-theme.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EAOjB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EAGnB,KAAK,sBAAsB,EAI5B,MAAM,iBAAiB,CAAA;AAMxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,qEAAqE;IACrE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,sBAAsB,EAAE,CAAA;IACxD,4GAA4G;IAC5G,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE;QAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;QAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;QACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KACzB,KAAK,OAAO,CAAC;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACxC,QAAQ,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE;QAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;QAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KACtB,KAAK,OAAO,CAAC,IAAI,CAA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