@contentful/experience-design-system-generation 2.36.2-dev-build-7907fec3.0 → 2.36.2-dev-build-a6f80ae6.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-invoker.d.ts +25 -0
  3. package/dist/src/{services/agent/local-cli-agent-invoker.js → agent-invoker.js} +2 -2
  4. package/dist/src/agent-names.d.ts +0 -1
  5. package/dist/src/agent-names.js +0 -7
  6. package/dist/src/agent-runner.d.ts +144 -0
  7. package/dist/src/agent-runner.js +564 -0
  8. package/dist/src/index.d.ts +7 -19
  9. package/dist/src/index.js +6 -18
  10. package/dist/src/prompt-builder.d.ts +81 -0
  11. package/dist/src/prompt-builder.js +344 -0
  12. package/package.json +2 -2
  13. package/dist/src/controller/create-generation-endpoint.d.ts +0 -3
  14. package/dist/src/controller/create-generation-endpoint.js +0 -15
  15. package/dist/src/controller/helpers/validate-generation-request.d.ts +0 -2
  16. package/dist/src/controller/helpers/validate-generation-request.js +0 -18
  17. package/dist/src/orchestrator/execute-generation-orchestrator.d.ts +0 -6
  18. package/dist/src/orchestrator/execute-generation-orchestrator.js +0 -12
  19. package/dist/src/services/agent/helpers/build-agent-args.d.ts +0 -6
  20. package/dist/src/services/agent/helpers/build-agent-args.js +0 -58
  21. package/dist/src/services/agent/helpers/check-agent-auth.d.ts +0 -3
  22. package/dist/src/services/agent/helpers/check-agent-auth.js +0 -19
  23. package/dist/src/services/agent/helpers/check-claude-auth.d.ts +0 -2
  24. package/dist/src/services/agent/helpers/check-claude-auth.js +0 -37
  25. package/dist/src/services/agent/helpers/describe-agent-failure.d.ts +0 -2
  26. package/dist/src/services/agent/helpers/describe-agent-failure.js +0 -5
  27. package/dist/src/services/agent/helpers/extract-sentinel-output.d.ts +0 -1
  28. package/dist/src/services/agent/helpers/extract-sentinel-output.js +0 -16
  29. package/dist/src/services/agent/helpers/resolve-agent-binary.d.ts +0 -2
  30. package/dist/src/services/agent/helpers/resolve-agent-binary.js +0 -8
  31. package/dist/src/services/agent/local-cli-agent-invoker.d.ts +0 -3
  32. package/dist/src/services/agent/run-agent.d.ts +0 -15
  33. package/dist/src/services/agent/run-agent.js +0 -70
  34. package/dist/src/services/parsing/helpers/read-tool-call-objects.d.ts +0 -4
  35. package/dist/src/services/parsing/helpers/read-tool-call-objects.js +0 -54
  36. package/dist/src/services/parsing/parse-map-token-tool-calls.d.ts +0 -2
  37. package/dist/src/services/parsing/parse-map-token-tool-calls.js +0 -39
  38. package/dist/src/services/parsing/parse-prop-tool-calls.d.ts +0 -2
  39. package/dist/src/services/parsing/parse-prop-tool-calls.js +0 -91
  40. package/dist/src/services/parsing/parse-select-tool-calls.d.ts +0 -2
  41. package/dist/src/services/parsing/parse-select-tool-calls.js +0 -27
  42. package/dist/src/services/parsing/parse-token-tool-calls.d.ts +0 -2
  43. package/dist/src/services/parsing/parse-token-tool-calls.js +0 -39
  44. package/dist/src/services/prompts/build-prompt.d.ts +0 -4
  45. package/dist/src/services/prompts/build-prompt.js +0 -8
  46. package/dist/src/services/prompts/helpers/build-preamble.d.ts +0 -2
  47. package/dist/src/services/prompts/helpers/build-preamble.js +0 -48
  48. package/dist/src/services/prompts/helpers/build-skill-preambles.d.ts +0 -4
  49. package/dist/src/services/prompts/helpers/build-skill-preambles.js +0 -126
  50. package/dist/src/services/prompts/helpers/format-source-refs.d.ts +0 -2
  51. package/dist/src/services/prompts/helpers/format-source-refs.js +0 -31
  52. package/dist/src/services/prompts/helpers/format-token-candidates.d.ts +0 -8
  53. package/dist/src/services/prompts/helpers/format-token-candidates.js +0 -80
  54. package/dist/src/services/prompts/helpers/resolve-skill-file.d.ts +0 -4
  55. package/dist/src/services/prompts/helpers/resolve-skill-file.js +0 -49
  56. package/dist/src/types/agent.d.ts +0 -10
  57. package/dist/src/types/agent.js +0 -1
  58. package/dist/src/types/contract.d.ts +0 -24
  59. package/dist/src/types/contract.js +0 -1
  60. package/dist/src/types/invoker.d.ts +0 -17
  61. package/dist/src/types/invoker.js +0 -1
  62. package/dist/src/types/prompt.d.ts +0 -53
  63. package/dist/src/types/prompt.js +0 -1
  64. package/dist/src/types/tool-calls.d.ts +0 -91
  65. package/dist/src/types/tool-calls.js +0 -1
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-generation",
3
- "version": "2.36.2-dev-build-7907fec3.0",
3
+ "version": "2.36.2-dev-build-a6f80ae6.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",
@@ -0,0 +1,25 @@
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,5 +1,5 @@
1
- import { runAgent } from './run-agent.js';
2
- import { checkAgentAuth } from './helpers/check-agent-auth.js';
1
+ import { checkAgentAuth, runAgent } from './agent-runner.js';
2
+ /** Default `AgentInvoker`: spawns the agent CLI binary as a local subprocess. */
3
3
  export function createLocalCliAgentInvoker(options = {}) {
4
4
  const { onDebugEvent } = options;
5
5
  return {
@@ -1,5 +1,4 @@
1
1
  export declare const AGENT_NAMES: readonly ["claude", "codex", "opencode", "cursor", "copilot"];
2
2
  export type AgentName = (typeof AGENT_NAMES)[number];
3
3
  export declare const DEFAULT_AGENT_NAME: AgentName;
4
- export declare const AGENT_BINARIES: Record<AgentName, string>;
5
4
  export declare function isAgentName(value: string): value is AgentName;
@@ -1,12 +1,5 @@
1
1
  export const AGENT_NAMES = ['claude', 'codex', 'opencode', 'cursor', 'copilot'];
2
2
  export const DEFAULT_AGENT_NAME = 'claude';
3
- export const AGENT_BINARIES = {
4
- claude: 'claude',
5
- codex: 'codex',
6
- opencode: 'opencode',
7
- cursor: 'cursor-agent',
8
- copilot: 'copilot',
9
- };
10
3
  export function isAgentName(value) {
11
4
  return AGENT_NAMES.includes(value);
12
5
  }
@@ -0,0 +1,144 @@
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';