@punica/editor 1.0.5 → 1.0.7

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 (69) hide show
  1. package/dist/index.bundle.esm.js +1 -1
  2. package/dist/index.bundle.esm.js.map +1 -1
  3. package/dist/index.bundle.umd.js +1 -1
  4. package/dist/index.bundle.umd.js.map +1 -1
  5. package/package.json +28 -3
  6. package/types/index.d.ts +120 -11
  7. package/types/punica.module.bootstrap.d.ts +45 -0
  8. package/types/punica.module.capability.d.ts +359 -0
  9. package/types/punica.module.extensions.api.d.ts +740 -0
  10. package/types/punica.module.extensions.settings.d.ts +106 -0
  11. package/types/punica.module.flow.agent.d.ts +75 -0
  12. package/types/punica.module.flow.api.d.ts +128 -0
  13. package/types/punica.module.flow.d.ts +490 -0
  14. package/types/punica.module.flow.engine.d.ts +228 -0
  15. package/types/punica.module.flow.mcp.d.ts +26 -0
  16. package/types/punica.module.flow.notebook.d.ts +210 -0
  17. package/types/punica.module.flow.primitives.d.ts +700 -0
  18. package/types/punica.module.flow.shell.d.ts +374 -0
  19. package/types/punica.module.kernel.ai.d.ts +462 -0
  20. package/types/punica.module.kernel.commands.d.ts +49 -0
  21. package/types/punica.module.kernel.events.d.ts +274 -0
  22. package/types/punica.module.kernel.history.d.ts +20 -0
  23. package/types/punica.module.kernel.llm.d.ts +343 -0
  24. package/types/punica.module.kernel.notifications.d.ts +64 -0
  25. package/types/punica.module.kernel.policy.d.ts +273 -0
  26. package/types/punica.module.kernel.tasks.d.ts +107 -0
  27. package/types/punica.module.kernel.timeServer.d.ts +16 -0
  28. package/types/punica.module.runtime.api.d.ts +214 -0
  29. package/types/punica.module.runtime.capabilities.d.ts +175 -0
  30. package/types/punica.module.runtime.compute.d.ts +339 -0
  31. package/types/punica.module.runtime.datasets.d.ts +234 -0
  32. package/types/punica.module.runtime.fs.d.ts +385 -0
  33. package/types/punica.module.runtime.harness.d.ts +246 -0
  34. package/types/punica.module.runtime.host.d.ts +272 -0
  35. package/types/punica.module.runtime.inference.d.ts +164 -0
  36. package/types/punica.module.runtime.lifecycle.d.ts +15 -0
  37. package/types/punica.module.runtime.llm.d.ts +470 -0
  38. package/types/punica.module.runtime.mcp.d.ts +139 -0
  39. package/types/punica.module.runtime.modelRuntimes.d.ts +90 -0
  40. package/types/punica.module.runtime.models.d.ts +254 -0
  41. package/types/punica.module.runtime.search.d.ts +59 -0
  42. package/types/punica.module.runtime.secrets.d.ts +26 -0
  43. package/types/punica.module.runtime.tasks.d.ts +27 -0
  44. package/types/punica.module.runtime.vcs.d.ts +67 -0
  45. package/types/punica.module.runtime.vectors.d.ts +74 -0
  46. package/types/punica.module.runtime.workspace.d.ts +134 -0
  47. package/types/punica.module.shell.activityBar.d.ts +42 -0
  48. package/types/punica.module.shell.components.d.ts +87 -0
  49. package/types/punica.module.shell.contentTabs.d.ts +33 -0
  50. package/types/punica.module.shell.dragDrop.d.ts +25 -0
  51. package/types/punica.module.shell.keyboardShortcuts.d.ts +38 -0
  52. package/types/punica.module.shell.layout.d.ts +106 -0
  53. package/types/punica.module.shell.markdown.d.ts +36 -0
  54. package/types/punica.module.shell.panelTabs.d.ts +48 -0
  55. package/types/punica.module.shell.profile.d.ts +278 -0
  56. package/types/punica.module.shell.statusbar.d.ts +26 -0
  57. package/types/punica.module.shell.view.d.ts +455 -0
  58. package/types/punica.module.shell.views.d.ts +150 -0
  59. package/types/punica.module.test.d.ts +562 -0
  60. package/types/punica.module.activityBar.d.ts +0 -21
  61. package/types/punica.module.commands.d.ts +0 -21
  62. package/types/punica.module.dragDrop.d.ts +0 -23
  63. package/types/punica.module.extensions.d.ts +0 -157
  64. package/types/punica.module.history.d.ts +0 -18
  65. package/types/punica.module.keyboardShortcuts.d.ts +0 -29
  66. package/types/punica.module.layout.d.ts +0 -23
  67. package/types/punica.module.statusbar.d.ts +0 -21
  68. package/types/punica.module.timeServer.d.ts +0 -14
  69. package/types/punica.module.view.d.ts +0 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@punica/editor",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Punica Editor",
5
5
  "private": false,
6
6
  "type": "module",
@@ -13,8 +13,25 @@
13
13
  },
14
14
  "scripts": {
15
15
  "build": "rollup -c",
16
+ "build:watch": "rollup -c -w",
17
+ "fixture:validate": "node scripts/fixtures/validate.mjs",
18
+ "test:ivy-node-runner": "node scripts/test-ivy-node-runner.mjs",
19
+ "migrate:capabilities": "node scripts/migrate/extensions-to-capabilities.mjs",
20
+ "docs:capabilities": "node scripts/generate-capability-docs.mjs",
21
+ "test:workflow": "node scripts/test-workflow-pipeline.mjs",
16
22
  "lint": "eslint . --ext .js,.ts",
17
23
  "lint:fix": "eslint . --ext .js,.ts --fix",
24
+ "check:types": "node scripts/check-types-references.mjs",
25
+ "test": "vitest run",
26
+ "test:watch": "vitest",
27
+ "test:ui": "vitest --ui",
28
+ "test:coverage": "vitest run --coverage",
29
+ "test:e2e": "vitest run --config vitest.e2e.config.ts",
30
+ "test:e2e:watch": "vitest --config vitest.e2e.config.ts",
31
+ "test:e2e:ui": "vitest --ui --config vitest.e2e.config.ts",
32
+ "test:host": "vitest run --config vitest.host.config.ts",
33
+ "test:host:watch": "vitest --config vitest.host.config.ts",
34
+ "test:host:ui": "vitest --ui --config vitest.host.config.ts",
18
35
  "format": "prettier --write \"./**/*.{ts,js,json,md}\"",
19
36
  "prepare": "husky install"
20
37
  },
@@ -33,7 +50,8 @@
33
50
  ],
34
51
  "dependencies": {
35
52
  "@punica/common": "^1.0.2",
36
- "classnames": "^2.3.2",
53
+ "highlight.js": "^11.11.1",
54
+ "markdown-it": "^14.2.0",
37
55
  "yaml": "^2.4.5"
38
56
  },
39
57
  "devDependencies": {
@@ -43,14 +61,21 @@
43
61
  "@rollup/plugin-node-resolve": "^15.3.1",
44
62
  "@rollup/plugin-terser": "^0.4.4",
45
63
  "@rollup/plugin-typescript": "^12.3.0",
64
+ "@types/markdown-it": "^14.1.2",
46
65
  "@types/node": "^20.14.10",
47
66
  "@typescript-eslint/eslint-plugin": "",
48
67
  "@typescript-eslint/parser": "^7.16.0",
68
+ "@vitest/coverage-v8": "^4.1.7",
69
+ "@vitest/ui": "^4.1.5",
49
70
  "eslint": "^8.56.0",
71
+ "eslint-import-resolver-typescript": "^4.4.4",
72
+ "eslint-plugin-import": "^2.32.0",
73
+ "happy-dom": "^20.9.0",
50
74
  "husky": "^9.1.1",
51
75
  "prettier": "^3.3.2",
52
76
  "rollup": "^4.53.2",
53
77
  "tslib": "^2.8.1",
54
- "typescript": "^5.5.3"
78
+ "typescript": "^5.5.3",
79
+ "vitest": "^4.1.5"
55
80
  }
56
81
  }
package/types/index.d.ts CHANGED
@@ -1,25 +1,134 @@
1
- /// <reference path="punica.module.activityBar.d.ts" />
2
- /// <reference path="punica.module.commands.d.ts" />
3
- /// <reference path="punica.module.history.d.ts" />
4
- /// <reference path="punica.module.dragDrop.d.ts" />
5
- /// <reference path="punica.module.extensions.d.ts" />
6
- /// <reference path="punica.module.keyboardShortcuts.d.ts" />
7
- /// <reference path="punica.module.layout.d.ts" />
8
- /// <reference path="punica.module.statusbar.d.ts" />
9
- /// <reference path="punica.module.timeServer.d.ts" />
10
- /// <reference path="punica.module.view.d.ts" />
1
+ /// <reference path="punica.module.shell.activityBar.d.ts" />
2
+ /// <reference path="punica.module.shell.keyboardShortcuts.d.ts" />
3
+ /// <reference path="punica.module.shell.dragDrop.d.ts" />
4
+ /// <reference path="punica.module.shell.layout.d.ts" />
5
+ /// <reference path="punica.module.shell.statusbar.d.ts" />
6
+ /// <reference path="punica.module.shell.contentTabs.d.ts" />
7
+ /// <reference path="punica.module.shell.components.d.ts" />
8
+ /// <reference path="punica.module.shell.view.d.ts" />
9
+ /// <reference path="punica.module.shell.views.d.ts" />
10
+ /// <reference path="punica.module.shell.panelTabs.d.ts" />
11
+ /// <reference path="punica.module.shell.profile.d.ts" />
12
+ /// <reference path="punica.module.shell.markdown.d.ts" />
13
+ /// <reference path="punica.module.kernel.commands.d.ts" />
14
+ /// <reference path="punica.module.kernel.history.d.ts" />
15
+ /// <reference path="punica.module.kernel.timeServer.d.ts" />
16
+ /// <reference path="punica.module.kernel.events.d.ts" />
17
+ /// <reference path="punica.module.kernel.ai.d.ts" />
18
+ /// <reference path="punica.module.kernel.llm.d.ts" />
19
+ /// <reference path="punica.module.kernel.policy.d.ts" />
20
+ /// <reference path="punica.module.kernel.notifications.d.ts" />
21
+ /// <reference path="punica.module.kernel.tasks.d.ts" />
22
+ /// <reference path="punica.module.extensions.api.d.ts" />
23
+ /// <reference path="punica.module.extensions.settings.d.ts" />
24
+ /// <reference path="punica.module.runtime.fs.d.ts" />
25
+ /// <reference path="punica.module.runtime.search.d.ts" />
26
+ /// <reference path="punica.module.runtime.vcs.d.ts" />
27
+ /// <reference path="punica.module.runtime.workspace.d.ts" />
28
+ /// <reference path="punica.module.runtime.llm.d.ts" />
29
+ /// <reference path="punica.module.runtime.compute.d.ts" />
30
+ /// <reference path="punica.module.runtime.datasets.d.ts" />
31
+ /// <reference path="punica.module.runtime.models.d.ts" />
32
+ /// <reference path="punica.module.runtime.modelRuntimes.d.ts" />
33
+ /// <reference path="punica.module.runtime.inference.d.ts" />
34
+ /// <reference path="punica.module.runtime.vectors.d.ts" />
35
+ /// <reference path="punica.module.runtime.host.d.ts" />
36
+ /// <reference path="punica.module.runtime.tasks.d.ts" />
37
+ /// <reference path="punica.module.runtime.secrets.d.ts" />
38
+ /// <reference path="punica.module.runtime.mcp.d.ts" />
39
+ /// <reference path="punica.module.runtime.lifecycle.d.ts" />
40
+ /// <reference path="punica.module.runtime.capabilities.d.ts" />
41
+ /// <reference path="punica.module.runtime.harness.d.ts" />
42
+ /// <reference path="punica.module.runtime.api.d.ts" />
43
+ /// <reference path="punica.module.flow.d.ts" />
44
+ /// <reference path="punica.module.flow.primitives.d.ts" />
45
+ /// <reference path="punica.module.flow.shell.d.ts" />
46
+ /// <reference path="punica.module.flow.engine.d.ts" />
47
+ /// <reference path="punica.module.flow.api.d.ts" />
48
+ /// <reference path="punica.module.flow.notebook.d.ts" />
49
+ /// <reference path="punica.module.flow.agent.d.ts" />
50
+ /// <reference path="punica.module.flow.mcp.d.ts" />
51
+ /// <reference path="punica.module.bootstrap.d.ts" />
52
+ /// <reference path="punica.module.capability.d.ts" />
53
+ /// <reference path="punica.module.test.d.ts" />
11
54
  /// <reference path="punica.types.d.ts" />
12
55
 
13
56
  declare module 'punica' {
14
57
  export const version: string;
58
+
59
+ /**
60
+ * Core / domain-level APIs (commands, history, time server, flow, ...).
61
+ */
62
+ export namespace kernel {}
63
+
64
+ /**
65
+ * Shell / UI-facing APIs (activity bar, layout, views, status bar, ...).
66
+ */
67
+ export namespace shell {}
68
+
69
+ /**
70
+ * Host/runtime façade (fs, search, vcs, workspace, tasks, events, ...).
71
+ */
72
+ export const runtime: runtime.RuntimeApi;
73
+
74
+ /**
75
+ * Extension system APIs (extension manager, metadata, decorators, ...).
76
+ */
77
+ export namespace extensions {}
78
+
79
+ /**
80
+ * Flow APIs (graph engine, node registry, validator, renderer, runner, test).
81
+ */
82
+ export namespace flow {}
15
83
  }
16
84
 
17
85
  declare global {
86
+ /**
87
+ * Global `punica` object exposed by the host/runtime.
88
+ *
89
+ * This mirrors the shape of the `'punica'` module so that code can use
90
+ * `punica.kernel`, `punica.shell`, `punica.runtime`, `punica.extensions`
91
+ * without importing the module explicitly.
92
+ */
93
+ const punica: typeof import('punica') & {
94
+ runtime: import('punica').runtime.RuntimeApi;
95
+ flow: import('punica').flow.FlowApi;
96
+ };
97
+
18
98
  interface Window {
19
- punica: typeof import('punica');
99
+ /**
100
+ * Browser/Electron hosts also surface the same global under `window.punica`.
101
+ * Prefer importing from the 'punica' module or using the global `punica`
102
+ * binding where possible.
103
+ */
104
+ punica: typeof import('punica') & {
105
+ runtime: import('punica').runtime.RuntimeApi;
106
+ flow: import('punica').flow.FlowApi;
107
+ };
20
108
  }
21
109
  }
22
110
 
23
111
  export function initialize(): void;
24
112
 
113
+ /**
114
+ * Bootstrap all modules after core initialization.
115
+ * This should be called after initialize() to set up module-specific initialization.
116
+ *
117
+ * @param options - Optional bootstrap options. Pass `profile` to activate a
118
+ * specific ApplicationProfile before module registration. When omitted the
119
+ * built-in `ivyx-classic` default profile is used (full backward compat).
120
+ * @returns Promise that resolves when all modules are bootstrapped
121
+ */
122
+ export function bootstrap(options?: {
123
+ profile?: shell.Profile.ApplicationProfile | string;
124
+ }): Promise<void>;
125
+
126
+ /**
127
+ * Start the system after all modules are bootstrapped.
128
+ * This should be called after bootstrap() to begin system operation.
129
+ *
130
+ * @returns Promise that resolves when system is started
131
+ */
132
+ export function start(): Promise<void>;
133
+
25
134
  export {};
@@ -0,0 +1,45 @@
1
+ declare module 'punica' {
2
+ /**
3
+ * Bootstrap context passed to module bootstrap and start methods.
4
+ */
5
+ export interface BootstrapContext {
6
+ /**
7
+ * Current bootstrap phase.
8
+ */
9
+ readonly phase: 'bootstrap' | 'start';
10
+
11
+ /**
12
+ * Optional bootstrap options (reserved for future use).
13
+ */
14
+ readonly options?: BootstrapOptions;
15
+ }
16
+
17
+ /**
18
+ * Bootstrap options (reserved for future configuration).
19
+ */
20
+ export interface BootstrapOptions {
21
+ // Future: configuration options for bootstrap
22
+ }
23
+
24
+ /**
25
+ * Interface for modules that support bootstrap lifecycle.
26
+ */
27
+ export interface Bootstrapable {
28
+ /**
29
+ * Bootstrap this module after core initialization.
30
+ * Called after punica global is set and core capabilities are registered.
31
+ *
32
+ * @param context - Bootstrap context
33
+ * @returns Promise that resolves when bootstrap is complete, or void for synchronous bootstrap
34
+ */
35
+ bootstrap?(context: BootstrapContext): Promise<void> | void;
36
+
37
+ /**
38
+ * Optional: Called when system is starting (after all modules bootstrapped).
39
+ *
40
+ * @param context - Bootstrap context
41
+ * @returns Promise that resolves when start is complete, or void for synchronous start
42
+ */
43
+ start?(context: BootstrapContext): Promise<void> | void;
44
+ }
45
+ }
@@ -0,0 +1,359 @@
1
+ declare module 'punica' {
2
+ /**
3
+ * Stable capability identifier.
4
+ * Format: namespace-prefixed, kebab-case (e.g., "ivy.node.http.fetch", "mcp.github.search").
5
+ */
6
+ export type CapabilityId = string;
7
+
8
+ /**
9
+ * Jitter strategy for retry backoff to avoid stampedes.
10
+ */
11
+ export type JitterStrategy = 'none' | 'full' | 'decorrelated';
12
+
13
+ /**
14
+ * Retry policy configuration.
15
+ */
16
+ export interface CapabilityRetryPolicy {
17
+ /**
18
+ * Maximum number of retry attempts (default: 0, no retries).
19
+ */
20
+ maxAttempts?: number;
21
+ /**
22
+ * Initial delay in milliseconds before first retry (default: 1000).
23
+ */
24
+ initialDelayMs?: number;
25
+ /**
26
+ * Maximum delay in milliseconds between retries (default: 30000).
27
+ */
28
+ maxDelayMs?: number;
29
+ /**
30
+ * Multiplier for exponential backoff (default: 2).
31
+ */
32
+ backoffMultiplier?: number;
33
+ /**
34
+ * Jitter strategy to avoid synchronized retries (default: 'none').
35
+ */
36
+ jitter?: JitterStrategy;
37
+ /**
38
+ * Whether to retry on timeout errors (default: false).
39
+ */
40
+ retryOnTimeout?: boolean;
41
+ }
42
+
43
+ /**
44
+ * Rate limit policy configuration.
45
+ */
46
+ export interface CapabilityRateLimitPolicy {
47
+ /**
48
+ * Maximum requests per second.
49
+ */
50
+ perSecond?: number;
51
+ /**
52
+ * Maximum requests per minute.
53
+ */
54
+ perMinute?: number;
55
+ }
56
+
57
+ /**
58
+ * Concurrency control policy.
59
+ */
60
+ export interface CapabilityConcurrencyPolicy {
61
+ /**
62
+ * Key template for semaphore (e.g., "workspace:{workspaceId}", "capability:{capabilityId}").
63
+ * Template variables are resolved from invocation context.
64
+ */
65
+ key: string;
66
+ /**
67
+ * Maximum concurrent executions for this key.
68
+ */
69
+ max: number;
70
+ }
71
+
72
+ /**
73
+ * Idempotency declaration for a capability — Sub-step 3.I.
74
+ *
75
+ * - `required` — gateway MUST receive a unique `idempotencyKey`
76
+ * in every invocation; calling without one is rejected with
77
+ * `CAPABILITY_IDEMPOTENCY_KEY_MISSING` (3.K). Used by safety-
78
+ * critical writes (secrets.set, tasks.run).
79
+ * - `optional` — gateway accepts invocations with or without a
80
+ * key. When the key is supplied, the response is cached so
81
+ * replays return the cached value (3.J/3.K). Default for
82
+ * non-critical writes (fs.writeFile, vcs.commit, …).
83
+ * - `none` — capability is naturally idempotent (reads) or
84
+ * does not benefit from de-duplication. The gateway ignores
85
+ * `idempotencyKey` even if supplied. Default for read +
86
+ * network-read sideEffects.
87
+ *
88
+ * Capabilities that don't declare a value default to `'none'`
89
+ * — preserves pre-3.I behavior (no enforcement) for already-
90
+ * deployed specs.
91
+ */
92
+ export type CapabilityIdempotency = 'required' | 'optional' | 'none';
93
+
94
+ /**
95
+ * Execution defaults for a capability.
96
+ * These defaults are applied unless overridden at workflow node or run level.
97
+ */
98
+ export interface CapabilityExecutionDefaults {
99
+ /**
100
+ * Execution timeout in milliseconds (default: capability-specific or 30000).
101
+ */
102
+ timeoutMs?: number;
103
+ /**
104
+ * Retry policy configuration.
105
+ */
106
+ retry?: CapabilityRetryPolicy;
107
+ /**
108
+ * Rate limiting policy.
109
+ */
110
+ rateLimit?: CapabilityRateLimitPolicy;
111
+ /**
112
+ * Concurrency control policy.
113
+ */
114
+ concurrency?: CapabilityConcurrencyPolicy;
115
+ /**
116
+ * For write side-effect capabilities, require idempotencyKey for safe retries.
117
+ * If true and sideEffect includes 'write', retries are only allowed when idempotencyKey is provided.
118
+ */
119
+ requireIdempotencyKeyForWriteRetry?: boolean;
120
+ /**
121
+ * Idempotency declaration — Sub-step 3.I. See
122
+ * `CapabilityIdempotency`. Absent = `'none'` (substrate-honest
123
+ * default — pre-3.I capabilities had no enforcement). The 3.K
124
+ * gateway middleware reads this field to decide whether to
125
+ * reject missing keys, cache responses, or pass through.
126
+ */
127
+ idempotency?: CapabilityIdempotency;
128
+ }
129
+
130
+ /**
131
+ * JSON Schema type definition for capability inputs/outputs.
132
+ * Based on JSON Schema Draft 7 specification, matching .punica/capabilities.yaml format.
133
+ */
134
+ export interface JSONSchema {
135
+ // Core schema properties
136
+ type?:
137
+ | 'object'
138
+ | 'string'
139
+ | 'number'
140
+ | 'boolean'
141
+ | 'array'
142
+ | 'null'
143
+ | string;
144
+ properties?: Record<string, JSONSchema>;
145
+ required?: string[];
146
+ description?: string;
147
+
148
+ // String constraints
149
+ enum?: unknown[];
150
+ pattern?: string;
151
+ minLength?: number;
152
+ maxLength?: number;
153
+
154
+ // Number constraints
155
+ minimum?: number;
156
+ maximum?: number;
157
+
158
+ // Array constraints
159
+ items?: JSONSchema | JSONSchema[];
160
+ minItems?: number;
161
+ maxItems?: number;
162
+
163
+ // Object constraints
164
+ additionalProperties?: boolean | JSONSchema;
165
+
166
+ // Composition
167
+ oneOf?: JSONSchema[];
168
+ anyOf?: JSONSchema[];
169
+ allOf?: JSONSchema[];
170
+
171
+ // Common
172
+ default?: unknown;
173
+ examples?: unknown[];
174
+
175
+ // Allow additional JSON Schema properties
176
+ [key: string]: unknown;
177
+ }
178
+
179
+ /**
180
+ * Unified Capability Definition - Base interface for all capability types.
181
+ *
182
+ * This is the single source of truth for capability definitions across:
183
+ * - Extensions (Extensions.CapabilityDefinition)
184
+ * - Ivy Nodes (IvyNodeMetadata.capability)
185
+ * - LLM Runtime (kernel.llm.InstructionClass → CapabilityDefinition)
186
+ *
187
+ * LLM planners and orchestrators use this unified format to understand
188
+ * and reason about capabilities from all sources.
189
+ */
190
+ export interface CapabilityDefinition {
191
+ /**
192
+ * Stable capability identifier (required).
193
+ * Format: namespace-prefixed, kebab-case (e.g., "ivy.node.http.fetch", "mcp.github.search").
194
+ * Used for capability registry, workflow references, and execution tracking.
195
+ */
196
+ id: CapabilityId;
197
+
198
+ /**
199
+ * Human-readable title for this capability.
200
+ * Used in UI and LLM prompts.
201
+ */
202
+ title: string;
203
+
204
+ /**
205
+ * Optional detailed description of what this capability does.
206
+ * Critical for LLM understanding and planning.
207
+ */
208
+ description?: string;
209
+
210
+ /**
211
+ * Input contract definition.
212
+ * Schema is JSON Schema format (as defined in capabilities.yaml).
213
+ */
214
+ inputs?: {
215
+ /**
216
+ * JSON Schema for input validation and LLM consumption.
217
+ * Matches the format used in .punica/capabilities.yaml files.
218
+ */
219
+ schema?: JSONSchema;
220
+ };
221
+
222
+ /**
223
+ * Output contract definition.
224
+ */
225
+ outputs?: {
226
+ /**
227
+ * JSON Schema for output structure (optional).
228
+ */
229
+ schema?: JSONSchema;
230
+ /**
231
+ * Output delivery mechanism.
232
+ */
233
+ kind?: 'event' | 'direct';
234
+ /**
235
+ * Event name emitted when capability succeeds (for event-based outputs).
236
+ */
237
+ resultEvent?: string;
238
+ /**
239
+ * Event name emitted when capability fails (for event-based outputs).
240
+ */
241
+ errorEvent?: string;
242
+ };
243
+
244
+ /**
245
+ * Policy and security metadata.
246
+ * Critical for LLM risk assessment and approval workflows.
247
+ */
248
+ policy?: {
249
+ /**
250
+ * Risk level: 'low' | 'medium' | 'high'
251
+ * Used by LLM planners to assess capability safety.
252
+ */
253
+ risk: 'low' | 'medium' | 'high';
254
+ /**
255
+ * Approval requirement: 'none' | 'plan' | 'step'
256
+ * - 'none': No approval needed
257
+ * - 'plan': Approval needed at workflow planning time
258
+ * - 'step': Approval needed before each execution
259
+ */
260
+ approval: 'none' | 'plan' | 'step';
261
+ };
262
+
263
+ /**
264
+ * Declared side effects this capability may produce.
265
+ * Examples: ['file-write', 'network-request', 'database-modify']
266
+ * Used by LLM planners to understand capability impact.
267
+ */
268
+ sideEffects?: string[];
269
+
270
+ /**
271
+ * Required context for this capability to execute.
272
+ * Examples: ['workspace', 'active-file', 'selection']
273
+ * Used by LLM planners to ensure prerequisites are met.
274
+ */
275
+ requiredContext?: string[];
276
+
277
+ /**
278
+ * Example usage scenarios.
279
+ * Helps LLM planners understand when and how to use this capability.
280
+ */
281
+ examples?: Array<{
282
+ /**
283
+ * Example input for this capability.
284
+ */
285
+ input: unknown;
286
+ /**
287
+ * Example output (if applicable).
288
+ */
289
+ output?: unknown;
290
+ /**
291
+ * Description of what this example demonstrates.
292
+ */
293
+ description?: string;
294
+ }>;
295
+
296
+ /**
297
+ * Semantic version for this capability definition (required).
298
+ * Used for versioning, dependency resolution, and capability registry.
299
+ */
300
+ version: string;
301
+
302
+ /**
303
+ * Optional tags for categorization and discovery.
304
+ */
305
+ tags?: string[];
306
+
307
+ /**
308
+ * Execution defaults for this capability.
309
+ * These defaults are applied unless overridden at workflow node or run level.
310
+ * Flow Engine uses these to safely schedule and execute capability calls.
311
+ */
312
+ execution?: CapabilityExecutionDefaults;
313
+
314
+ /**
315
+ * Deprecation metadata (Sub-step 2.H). When set, the capability
316
+ * gateway publishes a `capability.deprecated_called` kernel
317
+ * event on every invocation. Non-deprecated capabilities leave
318
+ * this unset.
319
+ */
320
+ deprecated?: CapabilityDeprecation;
321
+
322
+ /**
323
+ * Capability dependencies (Sub-step 2.I). When present, every
324
+ * id in this array must be registered before this capability
325
+ * can be invoked. The gateway runs a preflight check at call
326
+ * time and rejects the invocation with PROVIDER_MISSING +
327
+ * `details.missingRequirement` if any dependency is absent.
328
+ * Registration-time cycle detection rejects specs whose
329
+ * `requires` would close a loop in the dependency graph.
330
+ */
331
+ requires?: readonly CapabilityId[];
332
+
333
+ /**
334
+ * Allow domain-specific extensions while maintaining type safety.
335
+ */
336
+ [key: string]: unknown;
337
+ }
338
+
339
+ /**
340
+ * Deprecation metadata for a capability (Sub-step 2.H).
341
+ *
342
+ * Set on `CapabilityDefinition.deprecated` to mark a capability
343
+ * as scheduled for removal. The gateway keeps invoking the
344
+ * provider but publishes a warning event so audit / observability
345
+ * consumers see the drift before the eventual breaking removal.
346
+ */
347
+ export interface CapabilityDeprecation {
348
+ /** Version in which the capability was deprecated (semver). */
349
+ since: string;
350
+ /** Human-readable reason — surfaced in the warning event payload. */
351
+ reason: string;
352
+ /**
353
+ * Optional id of the capability callers should migrate to. When
354
+ * supplied, the warning event includes it so an LLM agent
355
+ * reading the audit trail can re-plan automatically.
356
+ */
357
+ replacement?: string;
358
+ }
359
+ }