@contentful/experience-design-system-generation 2.36.2-dev-build-a6f80ae6.0 → 2.37.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.
Files changed (65) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/src/agent-names.d.ts +1 -0
  3. package/dist/src/agent-names.js +7 -0
  4. package/dist/src/controller/create-generation-endpoint.d.ts +3 -0
  5. package/dist/src/controller/create-generation-endpoint.js +15 -0
  6. package/dist/src/controller/helpers/validate-generation-request.d.ts +2 -0
  7. package/dist/src/controller/helpers/validate-generation-request.js +18 -0
  8. package/dist/src/index.d.ts +19 -7
  9. package/dist/src/index.js +18 -6
  10. package/dist/src/orchestrator/execute-generation-orchestrator.d.ts +6 -0
  11. package/dist/src/orchestrator/execute-generation-orchestrator.js +12 -0
  12. package/dist/src/services/agent/helpers/build-agent-args.d.ts +6 -0
  13. package/dist/src/services/agent/helpers/build-agent-args.js +58 -0
  14. package/dist/src/services/agent/helpers/check-agent-auth.d.ts +3 -0
  15. package/dist/src/services/agent/helpers/check-agent-auth.js +19 -0
  16. package/dist/src/services/agent/helpers/check-claude-auth.d.ts +2 -0
  17. package/dist/src/services/agent/helpers/check-claude-auth.js +37 -0
  18. package/dist/src/services/agent/helpers/describe-agent-failure.d.ts +2 -0
  19. package/dist/src/services/agent/helpers/describe-agent-failure.js +5 -0
  20. package/dist/src/services/agent/helpers/extract-sentinel-output.d.ts +1 -0
  21. package/dist/src/services/agent/helpers/extract-sentinel-output.js +16 -0
  22. package/dist/src/services/agent/helpers/resolve-agent-binary.d.ts +2 -0
  23. package/dist/src/services/agent/helpers/resolve-agent-binary.js +8 -0
  24. package/dist/src/services/agent/local-cli-agent-invoker.d.ts +3 -0
  25. package/dist/src/{agent-invoker.js → services/agent/local-cli-agent-invoker.js} +2 -2
  26. package/dist/src/services/agent/run-agent.d.ts +15 -0
  27. package/dist/src/services/agent/run-agent.js +70 -0
  28. package/dist/src/services/parsing/helpers/read-tool-call-objects.d.ts +4 -0
  29. package/dist/src/services/parsing/helpers/read-tool-call-objects.js +54 -0
  30. package/dist/src/services/parsing/parse-map-token-tool-calls.d.ts +2 -0
  31. package/dist/src/services/parsing/parse-map-token-tool-calls.js +39 -0
  32. package/dist/src/services/parsing/parse-prop-tool-calls.d.ts +2 -0
  33. package/dist/src/services/parsing/parse-prop-tool-calls.js +91 -0
  34. package/dist/src/services/parsing/parse-select-tool-calls.d.ts +2 -0
  35. package/dist/src/services/parsing/parse-select-tool-calls.js +27 -0
  36. package/dist/src/services/parsing/parse-token-tool-calls.d.ts +2 -0
  37. package/dist/src/services/parsing/parse-token-tool-calls.js +39 -0
  38. package/dist/src/services/prompts/build-prompt.d.ts +4 -0
  39. package/dist/src/services/prompts/build-prompt.js +8 -0
  40. package/dist/src/services/prompts/helpers/build-preamble.d.ts +2 -0
  41. package/dist/src/services/prompts/helpers/build-preamble.js +48 -0
  42. package/dist/src/services/prompts/helpers/build-skill-preambles.d.ts +4 -0
  43. package/dist/src/services/prompts/helpers/build-skill-preambles.js +126 -0
  44. package/dist/src/services/prompts/helpers/format-source-refs.d.ts +2 -0
  45. package/dist/src/services/prompts/helpers/format-source-refs.js +31 -0
  46. package/dist/src/services/prompts/helpers/format-token-candidates.d.ts +8 -0
  47. package/dist/src/services/prompts/helpers/format-token-candidates.js +80 -0
  48. package/dist/src/services/prompts/helpers/resolve-skill-file.d.ts +4 -0
  49. package/dist/src/services/prompts/helpers/resolve-skill-file.js +49 -0
  50. package/dist/src/types/agent.d.ts +10 -0
  51. package/dist/src/types/agent.js +1 -0
  52. package/dist/src/types/contract.d.ts +24 -0
  53. package/dist/src/types/contract.js +1 -0
  54. package/dist/src/types/invoker.d.ts +17 -0
  55. package/dist/src/types/invoker.js +1 -0
  56. package/dist/src/types/prompt.d.ts +53 -0
  57. package/dist/src/types/prompt.js +1 -0
  58. package/dist/src/types/tool-calls.d.ts +91 -0
  59. package/dist/src/types/tool-calls.js +1 -0
  60. package/package.json +2 -2
  61. package/dist/src/agent-invoker.d.ts +0 -25
  62. package/dist/src/agent-runner.d.ts +0 -144
  63. package/dist/src/agent-runner.js +0 -564
  64. package/dist/src/prompt-builder.d.ts +0 -81
  65. package/dist/src/prompt-builder.js +0 -344
@@ -0,0 +1,53 @@
1
+ import type { CDFComponentEntry } from '@contentful/experience-design-system-types';
2
+ export type Skill = 'components' | 'tokens' | 'select' | 'map-tokens';
3
+ export type Mode = 'autonomous';
4
+ export interface ComponentSourceRef {
5
+ component: string;
6
+ sourcePath: string;
7
+ content: string | null;
8
+ siblingFiles?: Array<{
9
+ path: string;
10
+ content: string;
11
+ }>;
12
+ truncatedSiblingCount?: number;
13
+ /**
14
+ * Properties with at least one use that fell outside the excerpt budget of
15
+ * the file it sits in. The reader cannot see that use, so its absence is a
16
+ * gap in the evidence, not evidence of absence.
17
+ */
18
+ usesNotShown?: string[];
19
+ }
20
+ /** Plain-data shape of the CDF generated so far — component name -> component entry. */
21
+ export type GeneratedCdf = Record<string, CDFComponentEntry>;
22
+ export interface PromptOptions {
23
+ skill: Skill;
24
+ mode: Mode;
25
+ rawComponentsInline?: string;
26
+ rawTokensInline?: string;
27
+ /** Original filename for raw tokens — used to set the correct code fence language. */
28
+ rawTokensFilename?: string;
29
+ tokensInline?: string;
30
+ tokenMapInline?: string;
31
+ outDir: string;
32
+ /** For components skill only: the single component's name (used in error messages). */
33
+ componentName?: string;
34
+ /** For map-tokens skill: the CDF generated so far. Filtered internally to design-category token-typed props only. */
35
+ generatedCdf?: GeneratedCdf;
36
+ /** For map-tokens skill: the full DTCG token tree. Flattened internally to a path+`$type` index, with `$value` stripped. */
37
+ tokenTree?: Record<string, unknown>;
38
+ /** Component source file references — consumption evidence for the components skill, explicit-restriction evidence for map-tokens. */
39
+ componentSourceRefs?: ComponentSourceRef[];
40
+ /**
41
+ * When set, this absolute or relative `.md` path is read in place of the
42
+ * bundled skill file. Bundled-prompt invariants do NOT apply.
43
+ */
44
+ skillPathOverride?: string;
45
+ /** Inline prompt instructions, taking precedence over the bundled skill or path override. */
46
+ skillContentOverride?: string;
47
+ /** JSON-serialized summary of existing space Components. */
48
+ existingComponentsInline?: string;
49
+ /** JSON-serialized summary of existing space DesignTokens. */
50
+ existingTokensInline?: string;
51
+ /** JSON-serialized hard allowlist for generated slot allowed-components references. */
52
+ componentAllowlistInline?: string;
53
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,91 @@
1
+ export interface ClassifyPropCall {
2
+ tool: 'classify_prop';
3
+ prop: string;
4
+ cdf_type: string;
5
+ cdf_category: 'content' | 'design' | 'state';
6
+ values?: string[];
7
+ token_kind?: string;
8
+ required?: boolean;
9
+ description?: string;
10
+ default?: string | boolean;
11
+ /** Internal LLM rationale; not customer-facing. Persisted to raw_props.rationale. */
12
+ reason?: string;
13
+ }
14
+ export interface ExcludePropCall {
15
+ tool: 'exclude_prop';
16
+ prop: string;
17
+ reason: string;
18
+ }
19
+ export interface ClassifyComponentCall {
20
+ tool: 'classify_component';
21
+ description?: string;
22
+ /**
23
+ * Component-level rationale strings. Surfaced by the `I` ComponentRationalePanel.
24
+ * Each field is optional; missing fields leave existing DB values untouched
25
+ * (sparse update semantics in applyToolCalls).
26
+ */
27
+ rationale?: {
28
+ description?: string;
29
+ props?: string;
30
+ slots?: string;
31
+ };
32
+ }
33
+ export interface ClassifySlotCall {
34
+ tool: 'classify_slot';
35
+ slot: string;
36
+ required?: boolean;
37
+ allowed_components?: string[];
38
+ description?: string;
39
+ /** Per-slot rationale; persisted to raw_slots.rationale. */
40
+ rationale?: string;
41
+ }
42
+ export type ToolCall = ClassifyPropCall | ExcludePropCall | ClassifyComponentCall | ClassifySlotCall;
43
+ export interface ParsedToolCalls {
44
+ calls: ToolCall[];
45
+ warnings: string[];
46
+ }
47
+ export interface SelectComponentCall {
48
+ tool: 'select_component';
49
+ name: string;
50
+ reason?: string;
51
+ confidence?: number;
52
+ }
53
+ export interface RejectComponentCall {
54
+ tool: 'reject_component';
55
+ name: string;
56
+ reason?: string;
57
+ confidence?: number;
58
+ }
59
+ export type SelectToolCall = SelectComponentCall | RejectComponentCall;
60
+ export interface ParsedSelectToolCalls {
61
+ calls: SelectToolCall[];
62
+ warnings: string[];
63
+ }
64
+ export interface SetTokenCall {
65
+ tool: 'set_token';
66
+ path: string;
67
+ type: string;
68
+ value: unknown;
69
+ description?: string;
70
+ }
71
+ export interface SetGroupCall {
72
+ tool: 'set_group';
73
+ path: string;
74
+ description?: string;
75
+ }
76
+ export type TokenToolCall = SetTokenCall | SetGroupCall;
77
+ export interface ParsedTokenToolCalls {
78
+ calls: TokenToolCall[];
79
+ warnings: string[];
80
+ }
81
+ export interface MapTokenPropCall {
82
+ tool: 'map_token_prop';
83
+ component: string;
84
+ prop: string;
85
+ /** Narrowed subset of tokens the prop may draw from. Required and non-empty. */
86
+ token_allowed: string[];
87
+ }
88
+ export interface ParsedMapTokenPropToolCalls {
89
+ calls: MapTokenPropCall[];
90
+ warnings: string[];
91
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-generation",
3
- "version": "2.36.2-dev-build-a6f80ae6.0",
3
+ "version": "2.37.0",
4
4
  "description": "Agent-invocation and skill-prompt engine for the Contentful Experience Design System SDK",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -22,7 +22,7 @@
22
22
  "skills/"
23
23
  ],
24
24
  "dependencies": {
25
- "@contentful/experience-design-system-types": "2.36.2-dev-build-a6f80ae6.0"
25
+ "@contentful/experience-design-system-types": "2.37.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@tsconfig/node24": "^24.0.4",
@@ -1,25 +0,0 @@
1
- import type { AgentDebugEvent, AgentAuthStatus, AgentName, AgentRunResult } from './agent-runner.js';
2
- export interface InvokeAgentOptions {
3
- agent: AgentName;
4
- model?: string;
5
- bedrock?: boolean;
6
- prompt: string;
7
- timeoutMs: number;
8
- onOutput?: (chunk: string) => void;
9
- }
10
- /**
11
- * Abstracts "invoke an agent and get a result back" from the local-subprocess
12
- * mechanism `runAgent` uses today. A remote implementation (e.g. against an
13
- * internal agents service) implements the same contract without importing
14
- * this package's subprocess transport.
15
- */
16
- export interface AgentInvoker {
17
- invoke(options: InvokeAgentOptions): Promise<AgentRunResult>;
18
- checkAuth(agent: AgentName): Promise<AgentAuthStatus>;
19
- }
20
- export interface CreateLocalCliAgentInvokerOptions {
21
- /** Wire in a debug-event sink (e.g. the CLI's own debug logger). No-op by default. */
22
- onDebugEvent?: AgentDebugEvent;
23
- }
24
- /** Default `AgentInvoker`: spawns the agent CLI binary as a local subprocess. */
25
- export declare function createLocalCliAgentInvoker(options?: CreateLocalCliAgentInvokerOptions): AgentInvoker;
@@ -1,144 +0,0 @@
1
- import type { AgentName } from './agent-names.js';
2
- export { AGENT_NAMES, DEFAULT_AGENT_NAME, isAgentName, type AgentName } from './agent-names.js';
3
- export interface AgentRunResult {
4
- exitCode: number;
5
- stdout: string;
6
- stderr: string;
7
- timedOut: boolean;
8
- }
9
- export interface ClassifyPropCall {
10
- tool: 'classify_prop';
11
- prop: string;
12
- cdf_type: string;
13
- cdf_category: 'content' | 'design' | 'state';
14
- values?: string[];
15
- token_kind?: string;
16
- required?: boolean;
17
- description?: string;
18
- default?: string | boolean;
19
- /** Internal LLM rationale; not customer-facing. Persisted to raw_props.rationale. */
20
- reason?: string;
21
- }
22
- export interface ExcludePropCall {
23
- tool: 'exclude_prop';
24
- prop: string;
25
- reason: string;
26
- }
27
- export interface ClassifyComponentCall {
28
- tool: 'classify_component';
29
- description?: string;
30
- /**
31
- * Component-level rationale strings. Surfaced by the `I` ComponentRationalePanel.
32
- * Each field is optional; missing fields leave existing DB values untouched
33
- * (sparse update semantics in applyToolCalls).
34
- */
35
- rationale?: {
36
- description?: string;
37
- props?: string;
38
- slots?: string;
39
- };
40
- }
41
- export interface ClassifySlotCall {
42
- tool: 'classify_slot';
43
- slot: string;
44
- required?: boolean;
45
- allowed_components?: string[];
46
- description?: string;
47
- /** Per-slot rationale; persisted to raw_slots.rationale. */
48
- rationale?: string;
49
- }
50
- export type ToolCall = ClassifyPropCall | ExcludePropCall | ClassifyComponentCall | ClassifySlotCall;
51
- export interface SelectComponentCall {
52
- tool: 'select_component';
53
- name: string;
54
- reason?: string;
55
- confidence?: number;
56
- }
57
- export interface RejectComponentCall {
58
- tool: 'reject_component';
59
- name: string;
60
- reason?: string;
61
- confidence?: number;
62
- }
63
- export type SelectToolCall = SelectComponentCall | RejectComponentCall;
64
- export interface ParsedSelectToolCalls {
65
- calls: SelectToolCall[];
66
- warnings: string[];
67
- }
68
- export declare function parseSelectToolCallLines(stdout: string): ParsedSelectToolCalls;
69
- export interface SetTokenCall {
70
- tool: 'set_token';
71
- path: string;
72
- type: string;
73
- value: unknown;
74
- description?: string;
75
- }
76
- export interface SetGroupCall {
77
- tool: 'set_group';
78
- path: string;
79
- description?: string;
80
- }
81
- export type TokenToolCall = SetTokenCall | SetGroupCall;
82
- export interface ParsedTokenToolCalls {
83
- calls: TokenToolCall[];
84
- warnings: string[];
85
- }
86
- export interface ParsedToolCalls {
87
- calls: ToolCall[];
88
- warnings: string[];
89
- }
90
- export declare function parseToolCallLines(stdout: string): ParsedToolCalls;
91
- export declare function parseTokenToolCallLines(stdout: string): ParsedTokenToolCalls;
92
- export interface MapTokenPropCall {
93
- tool: 'map_token_prop';
94
- component: string;
95
- prop: string;
96
- /** Narrowed subset of tokens the prop may draw from. Required and non-empty. */
97
- token_allowed: string[];
98
- }
99
- export interface ParsedMapTokenPropToolCalls {
100
- calls: MapTokenPropCall[];
101
- warnings: string[];
102
- }
103
- export declare function parseMapTokenPropToolCallLines(stdout: string): ParsedMapTokenPropToolCalls;
104
- export declare function resolveBinary(agent: AgentName): string;
105
- export declare function agentSupportsBedrock(agent: AgentName): boolean;
106
- /**
107
- * Resolve the model for an agent. Explicit flag/creds value wins, then a
108
- * per-agent `EDS_AGENT_MODEL_<AGENT>` env override (mirrors the
109
- * `EDS_AGENT_BINARY_<AGENT>` pattern), otherwise the lightweight default for
110
- * that agent. `bedrock` only affects the fallback default, and only for
111
- * agents whose model id changes shape under Bedrock (codex, opencode) — an
112
- * explicit value or env override is never rewritten.
113
- */
114
- export declare function resolveAgentModel(agent: AgentName, explicit?: string, bedrock?: boolean): string | undefined;
115
- export type AgentDebugEvent = (name: string, payload?: Record<string, unknown>) => void;
116
- export declare function buildArgs(agent: AgentName, prompt: string, model?: string, promptViaStdin?: boolean, bedrock?: boolean): string[];
117
- export declare function runAgent(options: {
118
- agent: AgentName;
119
- prompt: string;
120
- timeoutMs: number;
121
- model?: string;
122
- /** Apply the selected agent's Bedrock-routing env vars when enabled. */
123
- bedrock?: boolean;
124
- onOutput?: (chunk: string) => void;
125
- /**
126
- * Deliver the prompt on stdin instead of as an argv positional. Required for
127
- * large prompts (e.g. the composition resolver inlining candidate files),
128
- * which overflow ARG_MAX when passed as an argument.
129
- */
130
- promptViaStdin?: boolean;
131
- /** Optional debug-event sink; callers own how/where events get logged. */
132
- onDebugEvent?: AgentDebugEvent;
133
- }): Promise<AgentRunResult>;
134
- export type AgentAuthStatus = 'ok' | 'unauthenticated' | 'not-found';
135
- export declare function checkAgentAuth(agent: AgentName): Promise<AgentAuthStatus>;
136
- /**
137
- * Build a diagnostic string from a failed agent run, surfacing the agent's own
138
- * stderr (or stdout, when stderr is empty) so callers never emit a context-free
139
- * "agent failed". Callers only invoke this on a failed run: either a non-zero
140
- * exit, or a zero exit that produced no tool calls. A non-zero exit is reported
141
- * as such; a zero exit is therefore the "produced no tool calls" case.
142
- */
143
- export declare function describeAgentFailure(result: AgentRunResult, maxDetail?: number): string;
144
- export declare function extractSentinelOutput(stdout: string): string | null | 'multiple';