@cogenta/agents-builtin 0.1.4 → 0.3.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/designer/agent.d.ts +42 -0
- package/dist/designer/agent.d.ts.map +1 -0
- package/dist/designer/agent.js +59 -0
- package/dist/designer/agent.js.map +1 -0
- package/dist/developer/agent.d.ts +31 -0
- package/dist/developer/agent.d.ts.map +1 -0
- package/dist/developer/agent.js +48 -0
- package/dist/developer/agent.js.map +1 -0
- package/dist/developer/patch-tool.d.ts +45 -0
- package/dist/developer/patch-tool.d.ts.map +1 -0
- package/dist/developer/patch-tool.js +86 -0
- package/dist/developer/patch-tool.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/theme-creator/agent.d.ts +34 -0
- package/dist/theme-creator/agent.d.ts.map +1 -0
- package/dist/theme-creator/agent.js +42 -0
- package/dist/theme-creator/agent.js.map +1 -0
- package/dist/theme-creator/propose-theme-tool.d.ts +72 -0
- package/dist/theme-creator/propose-theme-tool.d.ts.map +1 -0
- package/dist/theme-creator/propose-theme-tool.js +91 -0
- package/dist/theme-creator/propose-theme-tool.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type AgentDeclaration } from '@cogenta/agents';
|
|
2
|
+
/**
|
|
3
|
+
* "Doit pouvoir proposer une modification de code réelle (diff), jamais
|
|
4
|
+
* l'appliquer sans validation humaine explicite au niveau `autopilot` le
|
|
5
|
+
* plus élevé accordé par l'admin — même politique que les autres agents
|
|
6
|
+
* intégrés." (`docs/lots/L24-langgraph-agents-avances.md`, tâche 3, which
|
|
7
|
+
* points at task 2's own wording for what "same policy" means.)
|
|
8
|
+
*
|
|
9
|
+
* There is, as of this lot, no contract C tool that writes a theme file, a
|
|
10
|
+
* skin token sheet or a block layout anywhere in `packages/agents/src/tools`
|
|
11
|
+
* — `generateSkin`/`generateSkinCandidates` (`packages/agents/src/skin/`,
|
|
12
|
+
* `packages/agents/src/site-plan/skin-candidates.ts`) are library functions
|
|
13
|
+
* the installer and the admin site-plan router call directly, never
|
|
14
|
+
* something exposed through `withAutonomy`/a `ToolRegistry` entry a running
|
|
15
|
+
* agent can invoke. So "jamais l'appliquer sans validation humaine" is not
|
|
16
|
+
* merely this declaration's intent, it is structural in the same sense
|
|
17
|
+
* `contentAgent`/`seoAgent` document for `content.publish`: the runtime
|
|
18
|
+
* cannot grant a write path that was never built. `channel.send` is this
|
|
19
|
+
* agent's only way to hand a human a proposal (a described change, a token
|
|
20
|
+
* table, a rendered comparison) — never a file write.
|
|
21
|
+
*
|
|
22
|
+
* `build.trigger` is granted for the one legitimate read-adjacent use a
|
|
23
|
+
* design proposal has for it: asking CI to typecheck/test a *branch* a human
|
|
24
|
+
* has already pushed from this agent's suggestion, the same non-destructive
|
|
25
|
+
* use `performanceAgent` documents for its own budget-regression reports. It
|
|
26
|
+
* does not let this agent publish anything — `deploy.trigger` is
|
|
27
|
+
* deliberately absent.
|
|
28
|
+
*
|
|
29
|
+
* Disabled by default, the same structural mechanism as every other seed in
|
|
30
|
+
* this package (`securityAgent`, `contentAgent`, `seoAgent`,
|
|
31
|
+
* `performanceAgent`): nothing exports a "designer" entry from
|
|
32
|
+
* `builtinAgentSeeds()` (`@cogenta/agents`' own `agents/builtins.ts`, the
|
|
33
|
+
* file that actually seeds a live per-site `AgentDeclarationStore` with
|
|
34
|
+
* `enabled: true|false`), and `defineAgent`'s own `AgentDeclaration` type
|
|
35
|
+
* (contract C) has no `enabled` field to begin with — this catalog entry is
|
|
36
|
+
* inert until an operator wires it into their own site's agent store, the
|
|
37
|
+
* same way `docs/lots/L9-ecosysteme.md`'s blueprint recommendations
|
|
38
|
+
* (`STORE_RECOMMENDED_AGENTS`) already point at `seoAgent`/`performanceAgent`
|
|
39
|
+
* from this very package without ever activating them automatically.
|
|
40
|
+
*/
|
|
41
|
+
export declare const designerAgent: AgentDeclaration;
|
|
42
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/designer/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAe,MAAM,iBAAiB,CAAA;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,eAAO,MAAM,aAAa,EAAE,gBAiB1B,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { defineAgent } from '@cogenta/agents';
|
|
2
|
+
/**
|
|
3
|
+
* "Doit pouvoir proposer une modification de code réelle (diff), jamais
|
|
4
|
+
* l'appliquer sans validation humaine explicite au niveau `autopilot` le
|
|
5
|
+
* plus élevé accordé par l'admin — même politique que les autres agents
|
|
6
|
+
* intégrés." (`docs/lots/L24-langgraph-agents-avances.md`, tâche 3, which
|
|
7
|
+
* points at task 2's own wording for what "same policy" means.)
|
|
8
|
+
*
|
|
9
|
+
* There is, as of this lot, no contract C tool that writes a theme file, a
|
|
10
|
+
* skin token sheet or a block layout anywhere in `packages/agents/src/tools`
|
|
11
|
+
* — `generateSkin`/`generateSkinCandidates` (`packages/agents/src/skin/`,
|
|
12
|
+
* `packages/agents/src/site-plan/skin-candidates.ts`) are library functions
|
|
13
|
+
* the installer and the admin site-plan router call directly, never
|
|
14
|
+
* something exposed through `withAutonomy`/a `ToolRegistry` entry a running
|
|
15
|
+
* agent can invoke. So "jamais l'appliquer sans validation humaine" is not
|
|
16
|
+
* merely this declaration's intent, it is structural in the same sense
|
|
17
|
+
* `contentAgent`/`seoAgent` document for `content.publish`: the runtime
|
|
18
|
+
* cannot grant a write path that was never built. `channel.send` is this
|
|
19
|
+
* agent's only way to hand a human a proposal (a described change, a token
|
|
20
|
+
* table, a rendered comparison) — never a file write.
|
|
21
|
+
*
|
|
22
|
+
* `build.trigger` is granted for the one legitimate read-adjacent use a
|
|
23
|
+
* design proposal has for it: asking CI to typecheck/test a *branch* a human
|
|
24
|
+
* has already pushed from this agent's suggestion, the same non-destructive
|
|
25
|
+
* use `performanceAgent` documents for its own budget-regression reports. It
|
|
26
|
+
* does not let this agent publish anything — `deploy.trigger` is
|
|
27
|
+
* deliberately absent.
|
|
28
|
+
*
|
|
29
|
+
* Disabled by default, the same structural mechanism as every other seed in
|
|
30
|
+
* this package (`securityAgent`, `contentAgent`, `seoAgent`,
|
|
31
|
+
* `performanceAgent`): nothing exports a "designer" entry from
|
|
32
|
+
* `builtinAgentSeeds()` (`@cogenta/agents`' own `agents/builtins.ts`, the
|
|
33
|
+
* file that actually seeds a live per-site `AgentDeclarationStore` with
|
|
34
|
+
* `enabled: true|false`), and `defineAgent`'s own `AgentDeclaration` type
|
|
35
|
+
* (contract C) has no `enabled` field to begin with — this catalog entry is
|
|
36
|
+
* inert until an operator wires it into their own site's agent store, the
|
|
37
|
+
* same way `docs/lots/L9-ecosysteme.md`'s blueprint recommendations
|
|
38
|
+
* (`STORE_RECOMMENDED_AGENTS`) already point at `seoAgent`/`performanceAgent`
|
|
39
|
+
* from this very package without ever activating them automatically.
|
|
40
|
+
*/
|
|
41
|
+
export const designerAgent = defineAgent({
|
|
42
|
+
name: 'designer',
|
|
43
|
+
identity: './identity.md',
|
|
44
|
+
model: { preferred: 'claude-sonnet', fallback: 'local' },
|
|
45
|
+
tools: [
|
|
46
|
+
'content.read',
|
|
47
|
+
'media.read',
|
|
48
|
+
'site.config_read',
|
|
49
|
+
'http.fetch',
|
|
50
|
+
'channel.send',
|
|
51
|
+
'build.trigger',
|
|
52
|
+
],
|
|
53
|
+
skills: ['design-system-audit', 'accessible-color-tokens'],
|
|
54
|
+
autonomy: { default: 'propose' },
|
|
55
|
+
budget: { tokensPerDay: 150_000, eurPerMonth: 8, callsPerHour: 20 },
|
|
56
|
+
memory: { episodic: true, semantic: true, scope: 'site' },
|
|
57
|
+
triggers: [{ on: 'schedule', cron: '0 5 * * 1' }, { on: 'content.structure_changed' }],
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/designer/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,CAAC,MAAM,aAAa,GAAqB,WAAW,CAAC;IACzD,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,eAAe;IACzB,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,EAAE;IACxD,KAAK,EAAE;QACL,cAAc;QACd,YAAY;QACZ,kBAAkB;QAClB,YAAY;QACZ,cAAc;QACd,eAAe;KAChB;IACD,MAAM,EAAE,CAAC,qBAAqB,EAAE,yBAAyB,CAAC;IAC1D,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,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;IACzD,QAAQ,EAAE,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,EAAE,2BAA2B,EAAE,CAAC;CACvF,CAAC,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type AgentDeclaration } from '@cogenta/agents';
|
|
2
|
+
/**
|
|
3
|
+
* "Câblé désactivé par défaut, comme les deux agents intégrés de L22
|
|
4
|
+
* (Security Scanner, Content Watch)." `@cogenta/agents-builtin` has no
|
|
5
|
+
* `enabled` flag to set — `AgentDeclaration` (Contract C's own shape,
|
|
6
|
+
* `packages/agents/src/agents/types.ts`) never carried one, and none of
|
|
7
|
+
* `contentAgent`/`performanceAgent`/`securityAgent`/`seoAgent` in this
|
|
8
|
+
* package are wired into any site's live `AgentDeclarationStore` either
|
|
9
|
+
* (confirmed by search: nothing outside this package and its own tests
|
|
10
|
+
* imports them — `create-cogenta`'s blueprints only cite them as prose
|
|
11
|
+
* recommendations, e.g. `BLOG_RECOMMENDED_AGENTS`). This package is a
|
|
12
|
+
* catalogue an operator opts into, never a registry that runs anything on
|
|
13
|
+
* its own — every agent declared here is already "disabled by default" in
|
|
14
|
+
* the only sense that applies to a catalogue entry: nothing activates it
|
|
15
|
+
* without a human registering it on a real site. `developerAgent` follows
|
|
16
|
+
* the same shape for the same reason, not a special case.
|
|
17
|
+
*
|
|
18
|
+
* The four *live*, store-seeded agents ("Cogenta Agent", "Security
|
|
19
|
+
* Scanner", "Content Watch", "Site Monitor" — `packages/agents/src/agents/
|
|
20
|
+
* builtins.ts`, `ensureBuiltinAgents`) are a different mechanism entirely:
|
|
21
|
+
* inline identities, an `enabled: boolean` the store actually persists,
|
|
22
|
+
* auto-seeded at every `cogenta serve` boot. Wiring `developerAgent` into
|
|
23
|
+
* that store as a fifth seed is explicitly out of scope for this task — the
|
|
24
|
+
* mission that produced this file asked for the `agents-builtin` shape
|
|
25
|
+
* (`security/agent.ts`'s `agent.ts` + `identity.md` pattern), and mixing
|
|
26
|
+
* the two mechanisms in one change would blur which one this agent
|
|
27
|
+
* actually belongs to. A future lot can promote it into `builtins.ts` if a
|
|
28
|
+
* site should ship with it pre-seeded (disabled) rather than catalogue-only.
|
|
29
|
+
*/
|
|
30
|
+
export declare const developerAgent: AgentDeclaration;
|
|
31
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/developer/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAe,MAAM,iBAAiB,CAAA;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,cAAc,EAAE,gBAiB3B,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { defineAgent } from '@cogenta/agents';
|
|
2
|
+
/**
|
|
3
|
+
* "Câblé désactivé par défaut, comme les deux agents intégrés de L22
|
|
4
|
+
* (Security Scanner, Content Watch)." `@cogenta/agents-builtin` has no
|
|
5
|
+
* `enabled` flag to set — `AgentDeclaration` (Contract C's own shape,
|
|
6
|
+
* `packages/agents/src/agents/types.ts`) never carried one, and none of
|
|
7
|
+
* `contentAgent`/`performanceAgent`/`securityAgent`/`seoAgent` in this
|
|
8
|
+
* package are wired into any site's live `AgentDeclarationStore` either
|
|
9
|
+
* (confirmed by search: nothing outside this package and its own tests
|
|
10
|
+
* imports them — `create-cogenta`'s blueprints only cite them as prose
|
|
11
|
+
* recommendations, e.g. `BLOG_RECOMMENDED_AGENTS`). This package is a
|
|
12
|
+
* catalogue an operator opts into, never a registry that runs anything on
|
|
13
|
+
* its own — every agent declared here is already "disabled by default" in
|
|
14
|
+
* the only sense that applies to a catalogue entry: nothing activates it
|
|
15
|
+
* without a human registering it on a real site. `developerAgent` follows
|
|
16
|
+
* the same shape for the same reason, not a special case.
|
|
17
|
+
*
|
|
18
|
+
* The four *live*, store-seeded agents ("Cogenta Agent", "Security
|
|
19
|
+
* Scanner", "Content Watch", "Site Monitor" — `packages/agents/src/agents/
|
|
20
|
+
* builtins.ts`, `ensureBuiltinAgents`) are a different mechanism entirely:
|
|
21
|
+
* inline identities, an `enabled: boolean` the store actually persists,
|
|
22
|
+
* auto-seeded at every `cogenta serve` boot. Wiring `developerAgent` into
|
|
23
|
+
* that store as a fifth seed is explicitly out of scope for this task — the
|
|
24
|
+
* mission that produced this file asked for the `agents-builtin` shape
|
|
25
|
+
* (`security/agent.ts`'s `agent.ts` + `identity.md` pattern), and mixing
|
|
26
|
+
* the two mechanisms in one change would blur which one this agent
|
|
27
|
+
* actually belongs to. A future lot can promote it into `builtins.ts` if a
|
|
28
|
+
* site should ship with it pre-seeded (disabled) rather than catalogue-only.
|
|
29
|
+
*/
|
|
30
|
+
export const developerAgent = defineAgent({
|
|
31
|
+
name: 'developer',
|
|
32
|
+
identity: './identity.md',
|
|
33
|
+
model: { preferred: 'claude-sonnet', fallback: 'local' },
|
|
34
|
+
tools: ['schema.read', 'site.config_read', 'code.propose_patch'],
|
|
35
|
+
skills: ['cogenta-architecture', 'contract-review'],
|
|
36
|
+
// No override, ever, for `code.propose_patch` — a code change always
|
|
37
|
+
// waits for a human, exactly the reasoning `securityAgent`'s comment
|
|
38
|
+
// gives for `deps.patch` staying at the agent's `default`. Unlike
|
|
39
|
+
// `securityAgent` (whose `deps.scan` is read-only and safe to run
|
|
40
|
+
// unattended), nothing this agent can call is read-write-safe to
|
|
41
|
+
// automate: `schema.read`/`site.config_read` are read-only tools with no
|
|
42
|
+
// side effect to gate in the first place, so there is no second
|
|
43
|
+
// permission here that could plausibly earn `autonomous` either.
|
|
44
|
+
autonomy: { default: 'propose' },
|
|
45
|
+
budget: { tokensPerDay: 300_000, eurPerMonth: 15, callsPerHour: 20 },
|
|
46
|
+
memory: { episodic: true, semantic: true, scope: 'site' },
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/developer/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,MAAM,cAAc,GAAqB,WAAW,CAAC;IAC1D,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,eAAe;IACzB,KAAK,EAAE,EAAE,SAAS,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,EAAE;IACxD,KAAK,EAAE,CAAC,aAAa,EAAE,kBAAkB,EAAE,oBAAoB,CAAC;IAChE,MAAM,EAAE,CAAC,sBAAsB,EAAE,iBAAiB,CAAC;IACnD,qEAAqE;IACrE,qEAAqE;IACrE,kEAAkE;IAClE,kEAAkE;IAClE,iEAAiE;IACjE,yEAAyE;IACzE,gEAAgE;IAChE,iEAAiE;IACjE,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE;IAChC,MAAM,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE;IACpE,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;CAC1D,CAAC,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type ToolDefinition } from '@cogenta/agents';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import type { PrClient } from '../security/pr-client.js';
|
|
4
|
+
export interface CodePatchToolOptions {
|
|
5
|
+
readonly prClient: PrClient;
|
|
6
|
+
readonly baseBranch?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const CodePatchInputSchema: z.ZodObject<{
|
|
9
|
+
summary: z.ZodString;
|
|
10
|
+
rationale: z.ZodString;
|
|
11
|
+
files: z.ZodArray<z.ZodObject<{
|
|
12
|
+
path: z.ZodString;
|
|
13
|
+
content: z.ZodString;
|
|
14
|
+
}, z.core.$strip>>;
|
|
15
|
+
testPlan: z.ZodString;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type CodePatchInput = z.infer<typeof CodePatchInputSchema>;
|
|
18
|
+
declare const CodePatchOutputSchema: z.ZodObject<{
|
|
19
|
+
prUrl: z.ZodString;
|
|
20
|
+
prNumber: z.ZodNumber;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
export type CodePatchOutput = z.infer<typeof CodePatchOutputSchema>;
|
|
23
|
+
/**
|
|
24
|
+
* `code.patch` (`tools@1.3`, docs/04-contrats.md) — the Cogenta Developer
|
|
25
|
+
* agent's only way to change the codebase, and it does not change the
|
|
26
|
+
* codebase: it opens a pull request. Deliberately built the same way
|
|
27
|
+
* `security`'s `deps.patch` (`deps-patch-tool.ts`) already is, reusing the
|
|
28
|
+
* exact same `PrClient` capability rather than inventing a second "how do I
|
|
29
|
+
* reach a forge" abstraction — the only new surface here is this tool's own
|
|
30
|
+
* input/output shape (a general set of file contents instead of one
|
|
31
|
+
* dependency-file bump) and the `code.patch` permission it declares.
|
|
32
|
+
*
|
|
33
|
+
* `reversible: true` — `revert` closes the PR without merging it, same
|
|
34
|
+
* meaning as `deps.patch`'s. `sideEffects: true` plus `reversible: true` is
|
|
35
|
+
* exactly what keeps this out of `withAutonomy`'s forced-approval path
|
|
36
|
+
* (`packages/agents/src/autonomy/with-autonomy.ts`) — the tool is still
|
|
37
|
+
* gated, but by the *configured* autonomy level, which `developerAgent`
|
|
38
|
+
* pins to `propose` and never overrides. Nothing in this file grants
|
|
39
|
+
* `autonomous`; only a site operator editing the stored agent could, and
|
|
40
|
+
* that is the same "the safeguard is what does not appear here" reasoning
|
|
41
|
+
* `security/agent.ts` documents for `deps.patch`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function createCodePatchTool(options: CodePatchToolOptions): ToolDefinition<CodePatchInput, CodePatchOutput>;
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=patch-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patch-tool.d.ts","sourceRoot":"","sources":["../../src/developer/patch-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAExD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;IAC3B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC7B;AAQD,QAAA,MAAM,oBAAoB;;;;;;;;iBASxB,CAAA;AACF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEjE,QAAA,MAAM,qBAAqB;;;iBAAwD,CAAA;AACnF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAmBnE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,oBAAoB,GAC5B,cAAc,CAAC,cAAc,EAAE,eAAe,CAAC,CA+BjD"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { defineTool } from '@cogenta/agents';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
const ChangedFileSchema = z.object({
|
|
4
|
+
/** Repo-relative path, e.g. "packages/blocks/src/hero.ts". Never absolute — a tool has no filesystem of its own, only what `PrClient` commits. */
|
|
5
|
+
path: z.string(),
|
|
6
|
+
content: z.string(),
|
|
7
|
+
});
|
|
8
|
+
const CodePatchInputSchema = z.object({
|
|
9
|
+
/** Short, imperative summary — becomes the PR title prefix. */
|
|
10
|
+
summary: z.string(),
|
|
11
|
+
/** Why this change is being proposed, in the operator's own terms. */
|
|
12
|
+
rationale: z.string(),
|
|
13
|
+
/** Full new content for every file the patch touches — never a unified diff, so `PrClient.open` can commit it byte for byte with no merge logic of its own. */
|
|
14
|
+
files: z.array(ChangedFileSchema).min(1),
|
|
15
|
+
/** How this was (or should be) verified — the PR body always shows this so a human reviewer knows what the CI run and the manual check already covered. */
|
|
16
|
+
testPlan: z.string(),
|
|
17
|
+
});
|
|
18
|
+
const CodePatchOutputSchema = z.object({ prUrl: z.string(), prNumber: z.number() });
|
|
19
|
+
function buildPrBody(input) {
|
|
20
|
+
return [
|
|
21
|
+
input.rationale,
|
|
22
|
+
'',
|
|
23
|
+
'## Files changed',
|
|
24
|
+
...input.files.map((f) => `- \`${f.path}\``),
|
|
25
|
+
'',
|
|
26
|
+
'## Test plan',
|
|
27
|
+
input.testPlan,
|
|
28
|
+
'',
|
|
29
|
+
'---',
|
|
30
|
+
'Proposed by the Cogenta Developer agent. Nothing here was applied directly — this ' +
|
|
31
|
+
'pull request is the only artefact this run produced; a human review and merge ' +
|
|
32
|
+
'is what actually changes the codebase.',
|
|
33
|
+
].join('\n');
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* `code.patch` (`tools@1.3`, docs/04-contrats.md) — the Cogenta Developer
|
|
37
|
+
* agent's only way to change the codebase, and it does not change the
|
|
38
|
+
* codebase: it opens a pull request. Deliberately built the same way
|
|
39
|
+
* `security`'s `deps.patch` (`deps-patch-tool.ts`) already is, reusing the
|
|
40
|
+
* exact same `PrClient` capability rather than inventing a second "how do I
|
|
41
|
+
* reach a forge" abstraction — the only new surface here is this tool's own
|
|
42
|
+
* input/output shape (a general set of file contents instead of one
|
|
43
|
+
* dependency-file bump) and the `code.patch` permission it declares.
|
|
44
|
+
*
|
|
45
|
+
* `reversible: true` — `revert` closes the PR without merging it, same
|
|
46
|
+
* meaning as `deps.patch`'s. `sideEffects: true` plus `reversible: true` is
|
|
47
|
+
* exactly what keeps this out of `withAutonomy`'s forced-approval path
|
|
48
|
+
* (`packages/agents/src/autonomy/with-autonomy.ts`) — the tool is still
|
|
49
|
+
* gated, but by the *configured* autonomy level, which `developerAgent`
|
|
50
|
+
* pins to `propose` and never overrides. Nothing in this file grants
|
|
51
|
+
* `autonomous`; only a site operator editing the stored agent could, and
|
|
52
|
+
* that is the same "the safeguard is what does not appear here" reasoning
|
|
53
|
+
* `security/agent.ts` documents for `deps.patch`.
|
|
54
|
+
*/
|
|
55
|
+
export function createCodePatchTool(options) {
|
|
56
|
+
return defineTool({
|
|
57
|
+
name: 'code.propose_patch',
|
|
58
|
+
version: '1.0.0',
|
|
59
|
+
description: 'Opens a pull request with a real code change (one or more full file contents) — never writes to the repository directly.',
|
|
60
|
+
input: CodePatchInputSchema,
|
|
61
|
+
output: CodePatchOutputSchema,
|
|
62
|
+
permissions: ['code.patch'],
|
|
63
|
+
sideEffects: true,
|
|
64
|
+
reversible: true,
|
|
65
|
+
cost: 'medium',
|
|
66
|
+
async execute(input) {
|
|
67
|
+
const branchSuffix = input.summary
|
|
68
|
+
.toLowerCase()
|
|
69
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
70
|
+
.replace(/^-+|-+$/g, '')
|
|
71
|
+
.slice(0, 48);
|
|
72
|
+
const result = await options.prClient.open({
|
|
73
|
+
baseBranch: options.baseBranch ?? 'main',
|
|
74
|
+
branchName: `agent/developer/${branchSuffix || 'patch'}`,
|
|
75
|
+
title: `feat: ${input.summary}`,
|
|
76
|
+
body: buildPrBody(input),
|
|
77
|
+
files: input.files.map((f) => ({ path: f.path, content: f.content })),
|
|
78
|
+
});
|
|
79
|
+
return { prUrl: result.url, prNumber: result.number };
|
|
80
|
+
},
|
|
81
|
+
async revert(receipt) {
|
|
82
|
+
await options.prClient.close(receipt.prNumber);
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=patch-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"patch-tool.js","sourceRoot":"","sources":["../../src/developer/patch-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAuB,MAAM,iBAAiB,CAAA;AACjE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAQvB,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,kJAAkJ;IAClJ,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;CACpB,CAAC,CAAA;AAEF,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,+DAA+D;IAC/D,OAAO,EA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b,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;iBAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;iBACvB,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;YACf,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACzC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,MAAM;gBACxC,UAAU,EAAE,mBAAmB,YAAY,IAAI,OAAO,EAAE;gBACxD,KAAK,EAAE,SAAS,KAAK,CAAC,OAAO,EAAE;gBAC/B,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC;gBACxB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;aACtE,CAAC,CAAA;YACF,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAAA;QACvD,CAAC;QACD,KAAK,CAAC,MAAM,CAAC,OAAO;YAClB,MAAM,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QAChD,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ export { checkTerminology } from './content/terminology.js';
|
|
|
6
6
|
export type { ExistingContent, SuggestTopicGapsOptions, TopicCandidate, TopicGapSuggestion, } from './content/topic-gaps.js';
|
|
7
7
|
export { suggestTopicGaps } from './content/topic-gaps.js';
|
|
8
8
|
export type { ContentFinding, ContentProvenance, ContentSeverity } from './content/types.js';
|
|
9
|
+
export { designerAgent } from './designer/agent.js';
|
|
10
|
+
export { developerAgent } from './developer/agent.js';
|
|
11
|
+
export type { CodePatchInput, CodePatchOutput, CodePatchToolOptions, } from './developer/patch-tool.js';
|
|
12
|
+
export { createCodePatchTool } from './developer/patch-tool.js';
|
|
9
13
|
export { performanceAgent } from './performance/agent.js';
|
|
10
14
|
export { compareToBudget } from './performance/budget.js';
|
|
11
15
|
export type { CruxFormFactor, QueryCruxOptions } from './performance/crux-client.js';
|
|
@@ -46,4 +50,7 @@ export type { Redirect } from './seo/redirects.js';
|
|
|
46
50
|
export { findOrphanedRedirects } from './seo/redirects.js';
|
|
47
51
|
export { cosineSimilarity } from './seo/similarity.js';
|
|
48
52
|
export type { SeoAuditResult, SeoFinding, SeoHeading, SeoImage, SeoIssueSeverity, SeoPageInput, } from './seo/types.js';
|
|
53
|
+
export { themeCreatorAgent } from './theme-creator/agent.js';
|
|
54
|
+
export type { ProposeThemeInput, ProposeThemeOutput, ProposeThemeToolOptions, } from './theme-creator/propose-theme-tool.js';
|
|
55
|
+
export { createProposeThemeTool } from './theme-creator/propose-theme-tool.js';
|
|
49
56
|
//# 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,EAA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,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,YAAY,EACV,4BAA4B,EAC5B,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAChE,YAAY,EACV,yBAAyB,EACzB,oBAAoB,EACpB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAChE,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACrF,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;AACpE,YAAY,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,YAAY,EACV,cAAc,EACd,UAAU,EACV,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,YAAY,GACb,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,YAAY,EACV,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,uCAAuC,CAAA;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,9 @@ export { contentAgent } from './content/agent.js';
|
|
|
2
2
|
export { createContentDraftTool } from './content/provenance.js';
|
|
3
3
|
export { checkTerminology } from './content/terminology.js';
|
|
4
4
|
export { suggestTopicGaps } from './content/topic-gaps.js';
|
|
5
|
+
export { designerAgent } from './designer/agent.js';
|
|
6
|
+
export { developerAgent } from './developer/agent.js';
|
|
7
|
+
export { createCodePatchTool } from './developer/patch-tool.js';
|
|
5
8
|
export { performanceAgent } from './performance/agent.js';
|
|
6
9
|
export { compareToBudget } from './performance/budget.js';
|
|
7
10
|
export { queryCrux } from './performance/crux-client.js';
|
|
@@ -26,4 +29,6 @@ export { validateLlmsTxt } from './seo/llms-txt.js';
|
|
|
26
29
|
export { countWords, fleschReadingEase } from './seo/readability.js';
|
|
27
30
|
export { findOrphanedRedirects } from './seo/redirects.js';
|
|
28
31
|
export { cosineSimilarity } from './seo/similarity.js';
|
|
32
|
+
export { themeCreatorAgent } from './theme-creator/agent.js';
|
|
33
|
+
export { createProposeThemeTool } from './theme-creator/propose-theme-tool.js';
|
|
29
34
|
//# 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,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,EAA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AAM,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;AAM5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type AgentDeclaration } from '@cogenta/agents';
|
|
2
|
+
/**
|
|
3
|
+
* "Un bouton sur l'écran Apparence de l'admin qui ouvre une page pleine où
|
|
4
|
+
* décrire un thème... génère un ou plusieurs thèmes prévisualisables et
|
|
5
|
+
* activables... construire un agent 'Theme Creator' avec un vrai prompt
|
|
6
|
+
* système détaillé pour ça." (L26 tâche 5, demandé en direct.)
|
|
7
|
+
*
|
|
8
|
+
* `theme.propose_theme` (`tools@1.5`) is `sideEffects: false` and has no
|
|
9
|
+
* write path at any autonomy level — there is nothing this agent can do
|
|
10
|
+
* other than propose, structurally, the same guarantee `designerAgent`
|
|
11
|
+
* documents for its own lack of a write tool. `autonomy: propose` is set
|
|
12
|
+
* anyway, for the same reason `developerAgent` pins it despite
|
|
13
|
+
* `code.propose_patch` already being reversible: this is a user-facing,
|
|
14
|
+
* review-worthy action (a new theme candidate an admin will look at before
|
|
15
|
+
* doing anything), and `propose` is this codebase's established default
|
|
16
|
+
* posture for that shape of feature, not a gate against a write this tool
|
|
17
|
+
* could not perform anyway.
|
|
18
|
+
*
|
|
19
|
+
* Disabled by default, the same structural mechanism as every other seed in
|
|
20
|
+
* this package: nothing exports a "theme-creator" entry from
|
|
21
|
+
* `builtinAgentSeeds()` (`@cogenta/agents`' own `agents/builtins.ts`), and
|
|
22
|
+
* `AgentDeclaration` (contract C) has no `enabled` field to begin with —
|
|
23
|
+
* this catalog entry is inert until an operator wires it into their own
|
|
24
|
+
* site's agent store. The admin-facing "Theme Creator" screen this lot also
|
|
25
|
+
* ships calls `theme.propose_theme` directly (through `POST
|
|
26
|
+
* /api/theme/generate`, widened for this lot), not through this agent
|
|
27
|
+
* declaration or the runtime's agent-run endpoint — the same relationship
|
|
28
|
+
* `generateSkinCandidates` already had with the site-plan screen before
|
|
29
|
+
* this agent existed. This declaration exists so the tool is also reachable
|
|
30
|
+
* as a real, catalog-registered agent (a scheduled trigger, a delegated
|
|
31
|
+
* subagent call) rather than only as a bare function a router calls.
|
|
32
|
+
*/
|
|
33
|
+
export declare const themeCreatorAgent: AgentDeclaration;
|
|
34
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/theme-creator/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAe,MAAM,iBAAiB,CAAA;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,iBAAiB,EAAE,gBAQ9B,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { defineAgent } from '@cogenta/agents';
|
|
2
|
+
/**
|
|
3
|
+
* "Un bouton sur l'écran Apparence de l'admin qui ouvre une page pleine où
|
|
4
|
+
* décrire un thème... génère un ou plusieurs thèmes prévisualisables et
|
|
5
|
+
* activables... construire un agent 'Theme Creator' avec un vrai prompt
|
|
6
|
+
* système détaillé pour ça." (L26 tâche 5, demandé en direct.)
|
|
7
|
+
*
|
|
8
|
+
* `theme.propose_theme` (`tools@1.5`) is `sideEffects: false` and has no
|
|
9
|
+
* write path at any autonomy level — there is nothing this agent can do
|
|
10
|
+
* other than propose, structurally, the same guarantee `designerAgent`
|
|
11
|
+
* documents for its own lack of a write tool. `autonomy: propose` is set
|
|
12
|
+
* anyway, for the same reason `developerAgent` pins it despite
|
|
13
|
+
* `code.propose_patch` already being reversible: this is a user-facing,
|
|
14
|
+
* review-worthy action (a new theme candidate an admin will look at before
|
|
15
|
+
* doing anything), and `propose` is this codebase's established default
|
|
16
|
+
* posture for that shape of feature, not a gate against a write this tool
|
|
17
|
+
* could not perform anyway.
|
|
18
|
+
*
|
|
19
|
+
* Disabled by default, the same structural mechanism as every other seed in
|
|
20
|
+
* this package: nothing exports a "theme-creator" entry from
|
|
21
|
+
* `builtinAgentSeeds()` (`@cogenta/agents`' own `agents/builtins.ts`), and
|
|
22
|
+
* `AgentDeclaration` (contract C) has no `enabled` field to begin with —
|
|
23
|
+
* this catalog entry is inert until an operator wires it into their own
|
|
24
|
+
* site's agent store. The admin-facing "Theme Creator" screen this lot also
|
|
25
|
+
* ships calls `theme.propose_theme` directly (through `POST
|
|
26
|
+
* /api/theme/generate`, widened for this lot), not through this agent
|
|
27
|
+
* declaration or the runtime's agent-run endpoint — the same relationship
|
|
28
|
+
* `generateSkinCandidates` already had with the site-plan screen before
|
|
29
|
+
* this agent existed. This declaration exists so the tool is also reachable
|
|
30
|
+
* as a real, catalog-registered agent (a scheduled trigger, a delegated
|
|
31
|
+
* subagent call) rather than only as a bare function a router calls.
|
|
32
|
+
*/
|
|
33
|
+
export const themeCreatorAgent = defineAgent({
|
|
34
|
+
name: 'theme-creator',
|
|
35
|
+
identity: './identity.md',
|
|
36
|
+
model: { preferred: 'claude-sonnet', fallback: 'local' },
|
|
37
|
+
tools: ['theme.propose_theme'],
|
|
38
|
+
autonomy: { default: 'propose' },
|
|
39
|
+
budget: { tokensPerDay: 100_000, eurPerMonth: 6, callsPerHour: 20 },
|
|
40
|
+
memory: { episodic: false, semantic: false, scope: 'site' },
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/theme-creator/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;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,qBAAqB,CAAC;IAC9B,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,72 @@
|
|
|
1
|
+
import { type ProviderClient, type ThemeCreatorTargetTheme, type ToolDefinition } from '@cogenta/agents';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* `theme.propose_theme` (`tools@1.5`, `docs/04-contrats.md`) — the Cogenta
|
|
5
|
+
* Theme Creator's only tool, and its only way to touch a site's appearance:
|
|
6
|
+
* it never touches it. `sideEffects: false` is not a policy this tool
|
|
7
|
+
* chooses to respect, it is the whole of what the tool can do — pick a base
|
|
8
|
+
* theme from what is actually installed, and fill contract D's token schema
|
|
9
|
+
* via the same generate/validate/correct loop the installer and the
|
|
10
|
+
* site-plan screen already use (`generateSkinCandidates`, unchanged).
|
|
11
|
+
* Activating a candidate stays the human action it already was for a skin
|
|
12
|
+
* gallery entry: `PUT /api/theme/overrides`.
|
|
13
|
+
*
|
|
14
|
+
* `resolveProvider`/`availableThemes` are factory options, not part of the
|
|
15
|
+
* Zod input schema a model fills in — the same shape every other AI-backed
|
|
16
|
+
* tool in this codebase uses (`AssistToolset`'s `runtime`, `deps-patch-tool
|
|
17
|
+
* .ts`'s `PrClient`): Contract C's frozen `ToolContext` carries no
|
|
18
|
+
* `ProviderClient` slot, and a tool whose own job *is* to call a model gets
|
|
19
|
+
* one from the site's configured provider — never from anything a model
|
|
20
|
+
* could name. `resolveProvider` is called **fresh on every `execute()`**,
|
|
21
|
+
* never resolved once and captured: the provider store it wraps
|
|
22
|
+
* (`@cogenta/cli`'s `resolveThemeProvider`) is admin-configurable at
|
|
23
|
+
* runtime, and a client resolved once at wiring time would go stale the
|
|
24
|
+
* moment an admin saved a new key — the exact bug this shape was written to
|
|
25
|
+
* avoid. `availableThemes` is threaded the same way for the same reason: it
|
|
26
|
+
* is `@cogenta/cli`'s `availableThemes()`, which this package cannot import
|
|
27
|
+
* without inverting the dependency arrow.
|
|
28
|
+
*/
|
|
29
|
+
export interface ProposeThemeToolOptions {
|
|
30
|
+
readonly resolveProvider: () => Promise<{
|
|
31
|
+
readonly client: ProviderClient;
|
|
32
|
+
readonly model: string;
|
|
33
|
+
} | undefined>;
|
|
34
|
+
readonly availableThemes: readonly ThemeCreatorTargetTheme[];
|
|
35
|
+
}
|
|
36
|
+
declare const ProposeThemeInputSchema: z.ZodObject<{
|
|
37
|
+
description: z.ZodString;
|
|
38
|
+
siteName: z.ZodString;
|
|
39
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
40
|
+
filename: z.ZodString;
|
|
41
|
+
mimeType: z.ZodString;
|
|
42
|
+
dataBase64: z.ZodString;
|
|
43
|
+
}, z.core.$strip>>>;
|
|
44
|
+
baseline: z.ZodOptional<z.ZodObject<{
|
|
45
|
+
themeName: z.ZodString;
|
|
46
|
+
tokens: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
47
|
+
}, z.core.$strip>>;
|
|
48
|
+
maxCandidates: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
export type ProposeThemeInput = z.infer<typeof ProposeThemeInputSchema>;
|
|
51
|
+
declare const ProposeThemeOutputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
52
|
+
ok: z.ZodLiteral<true>;
|
|
53
|
+
candidates: z.ZodArray<z.ZodObject<{
|
|
54
|
+
id: z.ZodString;
|
|
55
|
+
label: z.ZodString;
|
|
56
|
+
rationale: z.ZodString;
|
|
57
|
+
tokens: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
58
|
+
themeName: z.ZodString;
|
|
59
|
+
chromeInput: z.ZodOptional<z.ZodObject<{
|
|
60
|
+
tagline: z.ZodOptional<z.ZodString>;
|
|
61
|
+
footerNote: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}, z.core.$strip>>;
|
|
63
|
+
}, z.core.$strip>>;
|
|
64
|
+
warnings: z.ZodArray<z.ZodString>;
|
|
65
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
66
|
+
ok: z.ZodLiteral<false>;
|
|
67
|
+
reason: z.ZodString;
|
|
68
|
+
}, z.core.$strip>], "ok">;
|
|
69
|
+
export type ProposeThemeOutput = z.infer<typeof ProposeThemeOutputSchema>;
|
|
70
|
+
export declare function createProposeThemeTool(options: ProposeThemeToolOptions): ToolDefinition<ProposeThemeInput, ProposeThemeOutput>;
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=propose-theme-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propose-theme-tool.d.ts","sourceRoot":"","sources":["../../src/theme-creator/propose-theme-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,cAAc,EAEnB,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,eAAe,EAAE,MAAM,OAAO,CACrC;QAAE,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CACxE,CAAA;IACD,QAAQ,CAAC,eAAe,EAAE,SAAS,uBAAuB,EAAE,CAAA;CAC7D;AAcD,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;iBAO3B,CAAA;AACF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAgBvE,QAAA,MAAM,wBAAwB;;;;;;;;;;;;;;;;;yBAO5B,CAAA;AACF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAA;AAEzE,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,uBAAuB,GAC/B,cAAc,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,CAqDvD"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { defineTool, proposeThemeCandidates, } from '@cogenta/agents';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
const AttachmentSchema = z.object({
|
|
4
|
+
filename: z.string().min(1),
|
|
5
|
+
mimeType: z.string().min(1),
|
|
6
|
+
/** Raw base64 — no `data:` URI prefix, same convention as `theme-router.ts`'s `contentBase64`. */
|
|
7
|
+
dataBase64: z.string().min(1),
|
|
8
|
+
});
|
|
9
|
+
const BaselineSchema = z.object({
|
|
10
|
+
themeName: z.string().min(1),
|
|
11
|
+
tokens: z.record(z.string(), z.unknown()),
|
|
12
|
+
});
|
|
13
|
+
const ProposeThemeInputSchema = z.object({
|
|
14
|
+
description: z.string().min(1).max(4000),
|
|
15
|
+
siteName: z.string().min(1),
|
|
16
|
+
attachments: z.array(AttachmentSchema).max(5).optional(),
|
|
17
|
+
/** Present for "adjust the current theme" rather than "design a new one". */
|
|
18
|
+
baseline: BaselineSchema.optional(),
|
|
19
|
+
maxCandidates: z.number().int().min(2).max(5).optional(),
|
|
20
|
+
});
|
|
21
|
+
const ChromeInputSchema = z.object({
|
|
22
|
+
tagline: z.string().optional(),
|
|
23
|
+
footerNote: z.string().optional(),
|
|
24
|
+
});
|
|
25
|
+
const CandidateSchema = z.object({
|
|
26
|
+
id: z.string(),
|
|
27
|
+
label: z.string(),
|
|
28
|
+
rationale: z.string(),
|
|
29
|
+
tokens: z.record(z.string(), z.unknown()),
|
|
30
|
+
themeName: z.string(),
|
|
31
|
+
chromeInput: ChromeInputSchema.optional(),
|
|
32
|
+
});
|
|
33
|
+
const ProposeThemeOutputSchema = z.discriminatedUnion('ok', [
|
|
34
|
+
z.object({
|
|
35
|
+
ok: z.literal(true),
|
|
36
|
+
candidates: z.array(CandidateSchema),
|
|
37
|
+
warnings: z.array(z.string()),
|
|
38
|
+
}),
|
|
39
|
+
z.object({ ok: z.literal(false), reason: z.string() }),
|
|
40
|
+
]);
|
|
41
|
+
export function createProposeThemeTool(options) {
|
|
42
|
+
return defineTool({
|
|
43
|
+
name: 'theme.propose_theme',
|
|
44
|
+
version: '1.0.0',
|
|
45
|
+
description: 'Proposes one to five theme candidates (a base theme package plus contract D skin tokens) from a free-text description and optional attachments. Never applies anything.',
|
|
46
|
+
input: ProposeThemeInputSchema,
|
|
47
|
+
output: ProposeThemeOutputSchema,
|
|
48
|
+
permissions: ['theme.customize'],
|
|
49
|
+
sideEffects: false,
|
|
50
|
+
reversible: false,
|
|
51
|
+
cost: 'medium',
|
|
52
|
+
async execute(input) {
|
|
53
|
+
const resolved = await options.resolveProvider();
|
|
54
|
+
if (resolved === undefined) {
|
|
55
|
+
return { ok: false, reason: 'No LLM provider is configured.' };
|
|
56
|
+
}
|
|
57
|
+
const attachments = (input.attachments ?? []).map((attachment) => ({
|
|
58
|
+
filename: attachment.filename,
|
|
59
|
+
mimeType: attachment.mimeType,
|
|
60
|
+
data: Uint8Array.from(Buffer.from(attachment.dataBase64, 'base64')),
|
|
61
|
+
}));
|
|
62
|
+
const result = await proposeThemeCandidates({
|
|
63
|
+
client: resolved.client,
|
|
64
|
+
model: resolved.model,
|
|
65
|
+
description: input.description,
|
|
66
|
+
siteName: input.siteName,
|
|
67
|
+
availableThemes: options.availableThemes,
|
|
68
|
+
...(attachments.length === 0 ? {} : { attachments }),
|
|
69
|
+
...(input.baseline === undefined ? {} : { baseline: input.baseline }),
|
|
70
|
+
...(input.maxCandidates === undefined ? {} : { maxCandidates: input.maxCandidates }),
|
|
71
|
+
});
|
|
72
|
+
if (!result.ok)
|
|
73
|
+
return { ok: false, reason: result.reason };
|
|
74
|
+
return {
|
|
75
|
+
ok: true,
|
|
76
|
+
candidates: result.candidates.map((candidate) => ({
|
|
77
|
+
id: candidate.id,
|
|
78
|
+
label: candidate.label,
|
|
79
|
+
rationale: candidate.rationale,
|
|
80
|
+
tokens: candidate.tokens,
|
|
81
|
+
themeName: candidate.themeName,
|
|
82
|
+
...(candidate.chromeInput === undefined
|
|
83
|
+
? {}
|
|
84
|
+
: { chromeInput: { ...candidate.chromeInput } }),
|
|
85
|
+
})),
|
|
86
|
+
warnings: [...result.warnings],
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=propose-theme-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propose-theme-tool.js","sourceRoot":"","sources":["../../src/theme-creator/propose-theme-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,sBAAsB,GAGvB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAoCvB,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3B,kGAAkG;IAClG,UAAU,EAAE,CAAC,CAAC,MAAM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AAK,EAAE,SAAS,CAAC,KAAK;oBACtB,SAAS,EAAE,SAAS,CAAC,SAAS;oBAC9B,MAAM,EAAE,SAAS,CAAC,MAAM;oBACxB,SAAS,EAAE,SAAS,CAAC,SAAS;oBAC9B,GAAG,CAAC,SAAS,CAAC,WAAW,KAAK,SAAS;wBACrC,CAAC,CAAC,EAAE;wBACJ,CAAC,CAAC,EAAE,WAAW,EAAE,EAAE,GAAG,SAAS,CAAC,WAAW,EAAE,EAAE,CAAC;iBACnD,CAAC,CAAC;gBACH,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC;aAC/B,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cogenta/agents-builtin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "The built-in agents shipped with Cogenta — Security, SEO, Content, Performance.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"zod": "^4.4.3",
|
|
31
|
-
"@cogenta/
|
|
32
|
-
"@cogenta/
|
|
31
|
+
"@cogenta/agents": "0.4.0",
|
|
32
|
+
"@cogenta/core": "0.6.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"typescript": "^7.0.2",
|