@punica/editor 1.0.6 → 1.0.8
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/index.bundle.esm.js +2 -1
- package/dist/index.bundle.esm.js.map +1 -1
- package/dist/index.bundle.umd.js +2 -1
- package/dist/index.bundle.umd.js.map +1 -1
- package/package.json +28 -3
- package/types/index.d.ts +120 -11
- package/types/punica.module.bootstrap.d.ts +45 -0
- package/types/punica.module.capability.d.ts +359 -0
- package/types/punica.module.extensions.api.d.ts +766 -0
- package/types/punica.module.extensions.settings.d.ts +106 -0
- package/types/punica.module.flow.agent.d.ts +75 -0
- package/types/punica.module.flow.api.d.ts +128 -0
- package/types/punica.module.flow.d.ts +490 -0
- package/types/punica.module.flow.engine.d.ts +228 -0
- package/types/punica.module.flow.mcp.d.ts +26 -0
- package/types/punica.module.flow.notebook.d.ts +210 -0
- package/types/punica.module.flow.primitives.d.ts +700 -0
- package/types/punica.module.flow.shell.d.ts +374 -0
- package/types/punica.module.kernel.ai.d.ts +462 -0
- package/types/punica.module.kernel.commands.d.ts +49 -0
- package/types/punica.module.kernel.events.d.ts +274 -0
- package/types/punica.module.kernel.history.d.ts +20 -0
- package/types/punica.module.kernel.llm.d.ts +343 -0
- package/types/punica.module.kernel.notifications.d.ts +64 -0
- package/types/punica.module.kernel.policy.d.ts +273 -0
- package/types/punica.module.kernel.tasks.d.ts +107 -0
- package/types/punica.module.kernel.timeServer.d.ts +16 -0
- package/types/punica.module.runtime.api.d.ts +214 -0
- package/types/punica.module.runtime.capabilities.d.ts +175 -0
- package/types/punica.module.runtime.compute.d.ts +339 -0
- package/types/punica.module.runtime.datasets.d.ts +234 -0
- package/types/punica.module.runtime.fs.d.ts +385 -0
- package/types/punica.module.runtime.harness.d.ts +246 -0
- package/types/punica.module.runtime.host.d.ts +272 -0
- package/types/punica.module.runtime.inference.d.ts +164 -0
- package/types/punica.module.runtime.lifecycle.d.ts +15 -0
- package/types/punica.module.runtime.llm.d.ts +470 -0
- package/types/punica.module.runtime.mcp.d.ts +139 -0
- package/types/punica.module.runtime.modelRuntimes.d.ts +90 -0
- package/types/punica.module.runtime.models.d.ts +254 -0
- package/types/punica.module.runtime.search.d.ts +59 -0
- package/types/punica.module.runtime.secrets.d.ts +26 -0
- package/types/punica.module.runtime.tasks.d.ts +27 -0
- package/types/punica.module.runtime.vcs.d.ts +67 -0
- package/types/punica.module.runtime.vectors.d.ts +74 -0
- package/types/punica.module.runtime.workspace.d.ts +134 -0
- package/types/punica.module.shell.activityBar.d.ts +42 -0
- package/types/punica.module.shell.components.d.ts +87 -0
- package/types/punica.module.shell.contentTabs.d.ts +33 -0
- package/types/punica.module.shell.dragDrop.d.ts +25 -0
- package/types/punica.module.shell.keyboardShortcuts.d.ts +38 -0
- package/types/punica.module.shell.layout.d.ts +106 -0
- package/types/punica.module.shell.markdown.d.ts +36 -0
- package/types/punica.module.shell.panelTabs.d.ts +71 -0
- package/types/punica.module.shell.profile.d.ts +278 -0
- package/types/punica.module.shell.statusbar.d.ts +26 -0
- package/types/punica.module.shell.view.d.ts +455 -0
- package/types/punica.module.shell.views.d.ts +150 -0
- package/types/punica.module.test.d.ts +562 -0
- package/types/punica.module.activityBar.d.ts +0 -21
- package/types/punica.module.commands.d.ts +0 -21
- package/types/punica.module.dragDrop.d.ts +0 -23
- package/types/punica.module.extensions.d.ts +0 -157
- package/types/punica.module.history.d.ts +0 -18
- package/types/punica.module.keyboardShortcuts.d.ts +0 -29
- package/types/punica.module.layout.d.ts +0 -22
- package/types/punica.module.statusbar.d.ts +0 -21
- package/types/punica.module.timeServer.d.ts +0 -14
- package/types/punica.module.view.d.ts +0 -8
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
declare module 'punica' {
|
|
2
|
+
export namespace kernel {
|
|
3
|
+
export type KernelEventKind = 'result' | 'progress' | 'error' | 'info';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Standard event envelope for correlation, auditing and tracing.
|
|
7
|
+
*/
|
|
8
|
+
export interface KernelEventEnvelope {
|
|
9
|
+
/**
|
|
10
|
+
* Unique id for this specific event instance.
|
|
11
|
+
*/
|
|
12
|
+
id: string;
|
|
13
|
+
/**
|
|
14
|
+
* Optional correlation id that ties multiple events together (e.g. a
|
|
15
|
+
* capability execution producing progress + result).
|
|
16
|
+
*/
|
|
17
|
+
correlationId?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Optional distributed trace id. When omitted, consumers may treat
|
|
20
|
+
* correlationId (or id) as the trace identifier.
|
|
21
|
+
*/
|
|
22
|
+
traceId?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Optional span id within a trace.
|
|
25
|
+
*/
|
|
26
|
+
spanId?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Optional parent span id within a trace (for nesting).
|
|
29
|
+
*/
|
|
30
|
+
parentSpanId?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Timestamp (ms since epoch) when this event was published.
|
|
33
|
+
*/
|
|
34
|
+
timestampMs: number;
|
|
35
|
+
/**
|
|
36
|
+
* Optional source identifier (e.g. "ai-core", "extension:file-explorer").
|
|
37
|
+
*/
|
|
38
|
+
source?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Optional high-level kind for consumers.
|
|
41
|
+
*/
|
|
42
|
+
kind?: KernelEventKind;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Standard kernel event record published through the EventsApi.
|
|
47
|
+
*/
|
|
48
|
+
export interface KernelEvent {
|
|
49
|
+
name: string;
|
|
50
|
+
envelope: KernelEventEnvelope;
|
|
51
|
+
payload?: any;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Broker-side subscription filter (Sub-step 6.H).
|
|
56
|
+
*
|
|
57
|
+
* Declarative description of which events a subscription wants.
|
|
58
|
+
* All fields optional; an empty filter matches every event.
|
|
59
|
+
* Fields combine with AND; values inside an array combine with OR.
|
|
60
|
+
*
|
|
61
|
+
* - `name`: exact event name, a `prefix.*` wildcard, or the bare
|
|
62
|
+
* `*` catch-all. Same grammar as the retention module.
|
|
63
|
+
* - `correlationId` / `traceId`: exact match against the matching
|
|
64
|
+
* envelope field.
|
|
65
|
+
* - `kind` / `source`: single value or array (OR within array).
|
|
66
|
+
*/
|
|
67
|
+
export interface EventSubscriptionFilter {
|
|
68
|
+
name?: string | string[];
|
|
69
|
+
correlationId?: string;
|
|
70
|
+
traceId?: string;
|
|
71
|
+
kind?: KernelEventKind | KernelEventKind[];
|
|
72
|
+
source?: string | string[];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* In-memory event bus for cross-module communication.
|
|
77
|
+
*/
|
|
78
|
+
export interface EventsApi {
|
|
79
|
+
/**
|
|
80
|
+
* Publish an event with an optional payload. Event names are free-form
|
|
81
|
+
* but using dot-separated namespaces (e.g. "tasks.runChanged",
|
|
82
|
+
* "workspace.changed") is recommended.
|
|
83
|
+
*/
|
|
84
|
+
publish(name: string, payload?: any): void;
|
|
85
|
+
/**
|
|
86
|
+
* Subscribe to a single event name. The listener receives the
|
|
87
|
+
* original payload (NOT the wrapped KernelEvent) — this is the
|
|
88
|
+
* legacy contract preserved for binary compatibility.
|
|
89
|
+
*
|
|
90
|
+
* Returns an unsubscribe function.
|
|
91
|
+
*/
|
|
92
|
+
subscribe(name: string, listener: (payload: any) => void): () => void;
|
|
93
|
+
/**
|
|
94
|
+
* Subscribe with a broker-side filter (Sub-step 6.H). The
|
|
95
|
+
* listener receives the full `KernelEvent` (so it can read
|
|
96
|
+
* envelope metadata) and is invoked ONLY when the event matches
|
|
97
|
+
* `filter`. Filters combine with AND; array values within a
|
|
98
|
+
* field combine with OR; an empty filter matches every event.
|
|
99
|
+
*
|
|
100
|
+
* Returns an unsubscribe function.
|
|
101
|
+
*/
|
|
102
|
+
subscribe(
|
|
103
|
+
filter: EventSubscriptionFilter,
|
|
104
|
+
listener: (event: KernelEvent) => void
|
|
105
|
+
): () => void;
|
|
106
|
+
/**
|
|
107
|
+
* Subscribe to multiple events at once. Returns an unsubscribe
|
|
108
|
+
* function that removes all registered listeners.
|
|
109
|
+
*/
|
|
110
|
+
subscribeMany(
|
|
111
|
+
names: string[],
|
|
112
|
+
listener: (event: { name: string; payload: any }) => void
|
|
113
|
+
): () => void;
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Create a correlation id suitable for tying multiple events together.
|
|
117
|
+
*/
|
|
118
|
+
createCorrelationId(): string;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Publish a standard KernelEvent record. Returns the normalized envelope.
|
|
122
|
+
*/
|
|
123
|
+
publishEvent(event: KernelEvent): KernelEventEnvelope;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Returns the most recent published events (in-memory audit buffer).
|
|
127
|
+
*/
|
|
128
|
+
getRecent(limit?: number): KernelEvent[];
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Filter events by various criteria.
|
|
132
|
+
* By default, only searches in-memory audit buffer.
|
|
133
|
+
* Set includePersisted=true to also search disk-persisted events (may be slower).
|
|
134
|
+
*/
|
|
135
|
+
filterEvents(options?: {
|
|
136
|
+
correlationId?: string;
|
|
137
|
+
name?: string | string[];
|
|
138
|
+
kind?: KernelEventKind | KernelEventKind[];
|
|
139
|
+
source?: string | string[];
|
|
140
|
+
since?: number; // timestampMs
|
|
141
|
+
until?: number; // timestampMs
|
|
142
|
+
limit?: number;
|
|
143
|
+
includePersisted?: boolean;
|
|
144
|
+
}): KernelEvent[];
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Load persisted events from disk (async).
|
|
148
|
+
* Useful for searching historical events beyond the in-memory audit buffer.
|
|
149
|
+
*/
|
|
150
|
+
loadPersistedEvents?(options?: {
|
|
151
|
+
since?: number;
|
|
152
|
+
until?: number;
|
|
153
|
+
name?: string | string[];
|
|
154
|
+
limit?: number;
|
|
155
|
+
}): Promise<KernelEvent[]>;
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Get all events for a specific correlationId (trace drilldown).
|
|
159
|
+
*/
|
|
160
|
+
getTrace(correlationId: string): KernelEvent[];
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Export events as JSON.
|
|
164
|
+
*/
|
|
165
|
+
exportEvents(options?: {
|
|
166
|
+
format?: 'json' | 'csv';
|
|
167
|
+
filter?: Parameters<EventsApi['filterEvents']>[0];
|
|
168
|
+
}): string;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Clears the in-memory audit buffer.
|
|
172
|
+
*/
|
|
173
|
+
clearAudit(): void;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Walk historical events (in-memory audit + persisted store)
|
|
177
|
+
* and either log them or re-publish them through the bus
|
|
178
|
+
* (Sub-step 6.I).
|
|
179
|
+
*
|
|
180
|
+
* - `mode: 'log'` writes each matching event to console.log
|
|
181
|
+
* in chronological order. Pure read; only stdout side-effect.
|
|
182
|
+
* - `mode: 'dispatch'` re-publishes events so listeners fire
|
|
183
|
+
* again. Dangerous in production — gated by the host-level
|
|
184
|
+
* `setReplayDispatchAllowed(true)` flag.
|
|
185
|
+
*
|
|
186
|
+
* Filter fields share semantics with `EventSubscriptionFilter`
|
|
187
|
+
* (AND across fields, OR within arrays); `since`/`until` scope
|
|
188
|
+
* the time range; `limit` keeps the tail-most N matches.
|
|
189
|
+
*/
|
|
190
|
+
replay(opts: EventReplayOptions): Promise<EventReplayResult>;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Replay scope + control (Sub-step 6.I). The first group of
|
|
195
|
+
* fields mirrors `EventSubscriptionFilter` matching semantics;
|
|
196
|
+
* the time-range fields scope the historical window; the
|
|
197
|
+
* mode/`includePersisted` fields select replay behavior.
|
|
198
|
+
*/
|
|
199
|
+
export interface EventReplayOptions {
|
|
200
|
+
name?: string | string[];
|
|
201
|
+
correlationId?: string;
|
|
202
|
+
traceId?: string;
|
|
203
|
+
kind?: KernelEventKind | KernelEventKind[];
|
|
204
|
+
source?: string | string[];
|
|
205
|
+
since?: number;
|
|
206
|
+
until?: number;
|
|
207
|
+
limit?: number;
|
|
208
|
+
mode: 'log' | 'dispatch';
|
|
209
|
+
/** Defaults to true — historical replay queries the store. */
|
|
210
|
+
includePersisted?: boolean;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** Outcome of an `events.replay(...)` call. */
|
|
214
|
+
export interface EventReplayResult {
|
|
215
|
+
count: number;
|
|
216
|
+
events: KernelEvent[];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* OTel-compatible point-in-time span emitted for every published
|
|
221
|
+
* kernel event (Sub-step 6.L). Maps 1:1 to an `@opentelemetry/api`
|
|
222
|
+
* Span snapshot — hosts wrap their OTel SDK in an
|
|
223
|
+
* `EventTelemetryExporter` without translation work.
|
|
224
|
+
*/
|
|
225
|
+
export interface EventSpan {
|
|
226
|
+
traceId?: string;
|
|
227
|
+
spanId: string;
|
|
228
|
+
parentSpanId?: string;
|
|
229
|
+
correlationId?: string;
|
|
230
|
+
name: string;
|
|
231
|
+
timestampMs: number;
|
|
232
|
+
kind?: KernelEventKind;
|
|
233
|
+
source?: string;
|
|
234
|
+
attributes: Record<string, unknown>;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Host contract for receiving event spans (Sub-step 6.L).
|
|
239
|
+
* Implementations MUST be non-blocking (queue + flush async).
|
|
240
|
+
* The substrate calls `exportSpan` from `publishEvent` on every
|
|
241
|
+
* event; throwing is tolerated (swallowed) but slow exporters
|
|
242
|
+
* will slow down every publish call directly.
|
|
243
|
+
*/
|
|
244
|
+
export interface EventTelemetryExporter {
|
|
245
|
+
exportSpan(span: EventSpan): void;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Host contract for receiving EventStore self-metrics (Sub-step 6.L).
|
|
250
|
+
* Closes CONSTITUTION § Kapı 4's `events.store.write_lag` and
|
|
251
|
+
* `events.store.queue_depth` requirements. Callbacks are optional
|
|
252
|
+
* — observers implement only the metrics they care about.
|
|
253
|
+
*/
|
|
254
|
+
export interface EventStoreMetricsObserver {
|
|
255
|
+
onWrite?(durationMs: number, count: number): void;
|
|
256
|
+
onQueueDepthChange?(depth: number): void;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Events module façade surfaced under `punica.kernel.Events`.
|
|
261
|
+
*
|
|
262
|
+
* Hosts/extensions can use this to create an EventsApi instance that backs
|
|
263
|
+
* the in-memory event bus used across the workbench.
|
|
264
|
+
*/
|
|
265
|
+
export namespace Events {
|
|
266
|
+
/**
|
|
267
|
+
* Default event bus instance used across the workbench.
|
|
268
|
+
*/
|
|
269
|
+
const manager: EventsApi;
|
|
270
|
+
function createEventsApi(): EventsApi;
|
|
271
|
+
function createCorrelationId(): string;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare module 'punica' {
|
|
2
|
+
export namespace kernel {
|
|
3
|
+
export namespace History {
|
|
4
|
+
interface ICommand {
|
|
5
|
+
id: string;
|
|
6
|
+
execute(): void;
|
|
7
|
+
undo(): void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface IHistoryManager {
|
|
11
|
+
registerCommand(command: ICommand): void;
|
|
12
|
+
executeCommand(commandId: string): void;
|
|
13
|
+
undo(): void;
|
|
14
|
+
redo(): void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const manager: IHistoryManager;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
declare module 'punica' {
|
|
2
|
+
export namespace kernel {
|
|
3
|
+
export namespace llm {
|
|
4
|
+
/**
|
|
5
|
+
* LLM Instruction Class - Rule-based behavior definition for LLM capabilities.
|
|
6
|
+
*
|
|
7
|
+
* Paradigm: "LLM = CPU değil, instruction-class"
|
|
8
|
+
* LLM'ler artık bir kimlik (identity) değil, bir yetenek (capability) olarak görülür.
|
|
9
|
+
* Her instruction class bir role tanımlar ve deterministic, rule-based behavior sağlar.
|
|
10
|
+
*/
|
|
11
|
+
export interface InstructionClass {
|
|
12
|
+
/** Unique identifier for this instruction class (e.g. 'planner', 'code-generator') */
|
|
13
|
+
id: string;
|
|
14
|
+
/** Role name (e.g. 'planner', 'code-generator', 'validator', 'reviewer') */
|
|
15
|
+
role: string;
|
|
16
|
+
/** System prompt that defines the LLM's behavior and rules */
|
|
17
|
+
systemPrompt: string;
|
|
18
|
+
/** Optional JSON Schema for structured output validation */
|
|
19
|
+
outputSchema?: JSONObject;
|
|
20
|
+
/** Default temperature for this instruction class */
|
|
21
|
+
temperature?: number;
|
|
22
|
+
/** Default max tokens for this instruction class */
|
|
23
|
+
maxTokens?: number;
|
|
24
|
+
/** Response format: 'json_object' for structured output, 'text' for free-form */
|
|
25
|
+
responseFormat?: 'json_object' | 'text';
|
|
26
|
+
/**
|
|
27
|
+
* Preferred model identifier for this instruction class (e.g. 'llama-3.2-8b-instruct-q4_k_m').
|
|
28
|
+
* Used by expert routing to select a single expert model.
|
|
29
|
+
*/
|
|
30
|
+
expertModelId?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Optional static risk level override for this instruction class.
|
|
33
|
+
* When not provided, risk is determined dynamically via LLM-based assessment.
|
|
34
|
+
*/
|
|
35
|
+
riskLevel?: 'low' | 'medium' | 'high';
|
|
36
|
+
/**
|
|
37
|
+
* Optional explicit list of expert model identifiers for multi-expert scenarios.
|
|
38
|
+
* When provided, auto-selection can use or extend this list.
|
|
39
|
+
*/
|
|
40
|
+
expertModelIds?: string[];
|
|
41
|
+
/**
|
|
42
|
+
* Unified capability definition for LLM consumption.
|
|
43
|
+
* If not provided, can be auto-generated from InstructionClass fields.
|
|
44
|
+
* This enables LLM planners to understand and reason about instruction classes
|
|
45
|
+
* in the same format as Extensions and Ivy Node capabilities.
|
|
46
|
+
*/
|
|
47
|
+
capability?: CapabilityDefinition;
|
|
48
|
+
/**
|
|
49
|
+
* Origin extension ID that registered this instruction class.
|
|
50
|
+
* Used for lifecycle management and governance introspection.
|
|
51
|
+
* Example: 'extension-ivy-node', 'extension-ivy-agent'
|
|
52
|
+
*/
|
|
53
|
+
originExtension?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Product ID that this instruction class belongs to.
|
|
56
|
+
* Used for product-scoped routing.
|
|
57
|
+
* Example: 'ivy-node', 'ivy-agent', 'ivy-mcp', 'ivy-flowbook'
|
|
58
|
+
*/
|
|
59
|
+
productId?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Input for LLM capability invocation via instruction class.
|
|
64
|
+
* Used by capabilities like 'llm.invoke', 'llm.plan', etc.
|
|
65
|
+
*/
|
|
66
|
+
export interface CapabilityInput {
|
|
67
|
+
/** Instruction class ID to use (references InstructionClass.id) */
|
|
68
|
+
instructionClass: string;
|
|
69
|
+
/** User prompt/query */
|
|
70
|
+
userPrompt: string;
|
|
71
|
+
/** Optional context for the LLM invocation */
|
|
72
|
+
context?: {
|
|
73
|
+
workspaceId?: string;
|
|
74
|
+
filePath?: string;
|
|
75
|
+
previousOutputs?: Record<string, unknown>;
|
|
76
|
+
capabilities?: Array<{ id: string; definition: unknown }>;
|
|
77
|
+
};
|
|
78
|
+
/** Optional overrides for instruction class defaults */
|
|
79
|
+
options?: {
|
|
80
|
+
temperature?: number;
|
|
81
|
+
maxTokens?: number;
|
|
82
|
+
timeoutMs?: number;
|
|
83
|
+
/** Skip cache lookup (force fresh response) */
|
|
84
|
+
skipCache?: boolean;
|
|
85
|
+
/** Enable streaming response (if supported by provider) */
|
|
86
|
+
stream?: boolean;
|
|
87
|
+
/** Skip multi-model fallback on failure */
|
|
88
|
+
skipFallback?: boolean;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Successful output from LLM capability invocation.
|
|
94
|
+
*/
|
|
95
|
+
export interface CapabilityOutput {
|
|
96
|
+
ok: true;
|
|
97
|
+
/** Raw text output from LLM */
|
|
98
|
+
text: string;
|
|
99
|
+
/** Parsed structured output (if outputSchema was provided) */
|
|
100
|
+
structured?: unknown;
|
|
101
|
+
/** Metadata about the invocation */
|
|
102
|
+
metadata: {
|
|
103
|
+
instructionClass: string;
|
|
104
|
+
role: string;
|
|
105
|
+
originExtension?: string;
|
|
106
|
+
productId?: string;
|
|
107
|
+
tokensUsed?: number;
|
|
108
|
+
inputTokens?: number;
|
|
109
|
+
outputTokens?: number;
|
|
110
|
+
latencyMs?: number;
|
|
111
|
+
modelId?: string;
|
|
112
|
+
provider?: string;
|
|
113
|
+
cacheHit?: boolean;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Error output from LLM capability invocation.
|
|
119
|
+
*/
|
|
120
|
+
export interface CapabilityError {
|
|
121
|
+
ok: false;
|
|
122
|
+
error: string;
|
|
123
|
+
/**
|
|
124
|
+
* Blocked status indicates the operation was prevented by policy/gate.
|
|
125
|
+
*/
|
|
126
|
+
blocked?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Stable reason code for blocked operations (e.g., 'LLM_PROFILE_NOT_REGISTERED').
|
|
129
|
+
*/
|
|
130
|
+
reasonCode?: string;
|
|
131
|
+
metadata: {
|
|
132
|
+
instructionClass: string;
|
|
133
|
+
role: string;
|
|
134
|
+
originExtension?: string;
|
|
135
|
+
productId?: string;
|
|
136
|
+
cacheHit?: boolean;
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Union type for LLM capability result.
|
|
142
|
+
*/
|
|
143
|
+
export type CapabilityResult = CapabilityOutput | CapabilityError;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Instruction class summary for introspection/governance.
|
|
147
|
+
*/
|
|
148
|
+
export interface InstructionClassSummary {
|
|
149
|
+
id: string;
|
|
150
|
+
role: string;
|
|
151
|
+
originExtension?: string;
|
|
152
|
+
productId?: string;
|
|
153
|
+
outputSchemaSummary?: string;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* LLM Instruction Class Registry API.
|
|
158
|
+
* Allows registration and lookup of instruction classes for LLM capabilities.
|
|
159
|
+
*/
|
|
160
|
+
export interface InstructionClassRegistry {
|
|
161
|
+
/**
|
|
162
|
+
* Register an instruction class.
|
|
163
|
+
* @param instructionClass The instruction class to register
|
|
164
|
+
* @param originExtension Optional origin extension ID (auto-detected if not provided)
|
|
165
|
+
*/
|
|
166
|
+
register(
|
|
167
|
+
instructionClass: InstructionClass,
|
|
168
|
+
originExtension?: string
|
|
169
|
+
): void;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Inject a product → originExtension resolver.
|
|
173
|
+
*
|
|
174
|
+
* The kernel is substrate and holds no knowledge of any
|
|
175
|
+
* specific product family. When an instruction class is
|
|
176
|
+
* registered with a `productId` but no explicit
|
|
177
|
+
* `originExtension`, the registry consults this resolver to
|
|
178
|
+
* derive the origin. The product/host layer owns the mapping,
|
|
179
|
+
* keeping product-specific concepts out of `kernel/`
|
|
180
|
+
* (CONSTITUTION §0). Absent resolver = no auto-detection.
|
|
181
|
+
*/
|
|
182
|
+
registerProductOriginResolver(
|
|
183
|
+
resolver: (productId: string) => string | undefined
|
|
184
|
+
): void;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Unregister an instruction class by ID.
|
|
188
|
+
* @param id Instruction class ID to unregister
|
|
189
|
+
*/
|
|
190
|
+
unregister(id: string): void;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Unregister all instruction classes from a specific origin extension.
|
|
194
|
+
* @param originExtension Origin extension ID
|
|
195
|
+
*/
|
|
196
|
+
unregisterByOrigin(originExtension: string): void;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Get an instruction class by ID.
|
|
200
|
+
*/
|
|
201
|
+
get(id: string): InstructionClass | undefined;
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* List all registered instruction classes.
|
|
205
|
+
* @param filterActiveOnly If true, only return classes whose origin extension is currently active
|
|
206
|
+
*/
|
|
207
|
+
list(filterActiveOnly?: boolean): InstructionClass[];
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* List instruction class summaries for introspection/governance.
|
|
211
|
+
* @param filterActiveOnly If true, only return classes whose origin extension is currently active
|
|
212
|
+
*/
|
|
213
|
+
listSummaries(filterActiveOnly?: boolean): InstructionClassSummary[];
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Check if an instruction class is registered.
|
|
217
|
+
*/
|
|
218
|
+
has(id: string): boolean;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Check if an instruction class is available (registered and origin extension is active).
|
|
222
|
+
*/
|
|
223
|
+
isAvailable(id: string): boolean;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* High-level LLM API for kernel layer.
|
|
228
|
+
* Provides instruction class-based invocation and specialized methods.
|
|
229
|
+
*/
|
|
230
|
+
export interface LlmApi {
|
|
231
|
+
/**
|
|
232
|
+
* Instruction class registry.
|
|
233
|
+
*/
|
|
234
|
+
readonly instructionClassRegistry: InstructionClassRegistry;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* List all registered instruction classes (introspection API for governance/debug).
|
|
238
|
+
* Returns summaries with origin extension and product ID metadata.
|
|
239
|
+
*/
|
|
240
|
+
listInstructionClasses(
|
|
241
|
+
filterActiveOnly?: boolean
|
|
242
|
+
): InstructionClassSummary[];
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Invoke LLM using an instruction class.
|
|
246
|
+
*
|
|
247
|
+
* `opts.correlationId` lets the caller bind this invocation to its
|
|
248
|
+
* own session/trace id. When `input.options.stream` is set, the
|
|
249
|
+
* streaming `llm.chunk` deltas are published under this id so the
|
|
250
|
+
* caller can correlate live tokens with the originating turn.
|
|
251
|
+
*/
|
|
252
|
+
invoke(
|
|
253
|
+
input: CapabilityInput,
|
|
254
|
+
opts?: { correlationId?: string }
|
|
255
|
+
): Promise<CapabilityResult>;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Generate FlowBook IR from natural language query.
|
|
259
|
+
*/
|
|
260
|
+
plan(input: {
|
|
261
|
+
query: string;
|
|
262
|
+
capabilities?: Array<{ id: string; definition: unknown }>;
|
|
263
|
+
}): Promise<CapabilityResult>;
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Generate code from requirements.
|
|
267
|
+
*/
|
|
268
|
+
generateCode(input: {
|
|
269
|
+
requirements: string;
|
|
270
|
+
language?: string;
|
|
271
|
+
context?: {
|
|
272
|
+
workspaceId?: string;
|
|
273
|
+
filePath?: string;
|
|
274
|
+
previousOutputs?: Record<string, unknown>;
|
|
275
|
+
};
|
|
276
|
+
}): Promise<CapabilityResult>;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Validate code and identify issues.
|
|
280
|
+
*/
|
|
281
|
+
validator(input: {
|
|
282
|
+
code: string;
|
|
283
|
+
language?: string;
|
|
284
|
+
context?: {
|
|
285
|
+
workspaceId?: string;
|
|
286
|
+
filePath?: string;
|
|
287
|
+
};
|
|
288
|
+
}): Promise<CapabilityResult>;
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Provide code review feedback.
|
|
292
|
+
*/
|
|
293
|
+
reviewer(input: {
|
|
294
|
+
code: string;
|
|
295
|
+
language?: string;
|
|
296
|
+
context?: {
|
|
297
|
+
workspaceId?: string;
|
|
298
|
+
filePath?: string;
|
|
299
|
+
};
|
|
300
|
+
}): Promise<CapabilityResult>;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Edit and optimize FlowBook IR structures.
|
|
304
|
+
*/
|
|
305
|
+
editWorkflow(input: {
|
|
306
|
+
flowBook: ivy.FlowBookDocument;
|
|
307
|
+
requirements?: string;
|
|
308
|
+
context?: {
|
|
309
|
+
workspaceId?: string;
|
|
310
|
+
filePath?: string;
|
|
311
|
+
capabilities?: Array<{ id: string; definition: unknown }>;
|
|
312
|
+
};
|
|
313
|
+
}): Promise<CapabilityResult>;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* LLM manager API for kernel layer.
|
|
318
|
+
*/
|
|
319
|
+
export interface LlmManager {
|
|
320
|
+
readonly api: LlmApi;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* LLM manager instance.
|
|
325
|
+
*/
|
|
326
|
+
export const manager: LlmManager;
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* CodegenBundle IR v0.1 - Multi-file code generation output format
|
|
330
|
+
*/
|
|
331
|
+
export interface CodegenBundleV0_1 {
|
|
332
|
+
specVersion: '0.1';
|
|
333
|
+
summary?: string;
|
|
334
|
+
files: Array<{
|
|
335
|
+
path: string;
|
|
336
|
+
action: 'create' | 'update' | 'delete';
|
|
337
|
+
content?: string;
|
|
338
|
+
encoding?: 'utf-8';
|
|
339
|
+
}>;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
declare module 'punica' {
|
|
2
|
+
export namespace kernel {
|
|
3
|
+
export type NotificationLevel = 'error' | 'warning' | 'info';
|
|
4
|
+
|
|
5
|
+
export interface NotificationItem {
|
|
6
|
+
/** Unique id for this notification. */
|
|
7
|
+
id: string;
|
|
8
|
+
/** Short title shown in UI. */
|
|
9
|
+
title?: string;
|
|
10
|
+
/** Detailed message text. */
|
|
11
|
+
message: string;
|
|
12
|
+
/** Optional logical source (extension id, subsystem, etc.). */
|
|
13
|
+
source?: string;
|
|
14
|
+
/** Level / severity for styling and filtering. */
|
|
15
|
+
level: NotificationLevel;
|
|
16
|
+
/** When the notification was created, as ISO string. */
|
|
17
|
+
timestamp?: string;
|
|
18
|
+
/** Whether the notification has been handled / dismissed. */
|
|
19
|
+
read?: boolean;
|
|
20
|
+
/** Optional command to execute when the user acts on the notification. */
|
|
21
|
+
actionCommandId?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface NotificationsApi {
|
|
25
|
+
/**
|
|
26
|
+
* List all notifications, newest first.
|
|
27
|
+
*/
|
|
28
|
+
list(): Promise<NotificationItem[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Push a new notification into the global notification center.
|
|
31
|
+
*/
|
|
32
|
+
push(item: NotificationItem): void;
|
|
33
|
+
/**
|
|
34
|
+
* Mark a notification as handled / dismissed.
|
|
35
|
+
*/
|
|
36
|
+
markRead(id: string): void;
|
|
37
|
+
/**
|
|
38
|
+
* Clear notifications, optionally filtered by source.
|
|
39
|
+
*/
|
|
40
|
+
clear(source?: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Subscribe to changes in the notification list.
|
|
43
|
+
*/
|
|
44
|
+
onDidChange(listener: () => void): () => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Notifications module façade surfaced under `punica.kernel.Notifications`.
|
|
49
|
+
*
|
|
50
|
+
* Hosts/extensions can use this to access the global notification center.
|
|
51
|
+
*/
|
|
52
|
+
export namespace Notifications {
|
|
53
|
+
/**
|
|
54
|
+
* Default notifications manager instance used across the workbench.
|
|
55
|
+
*/
|
|
56
|
+
const manager: NotificationsApi;
|
|
57
|
+
/**
|
|
58
|
+
* Factory function to create a new NotificationsApi instance.
|
|
59
|
+
* Use `manager` for the global singleton instance.
|
|
60
|
+
*/
|
|
61
|
+
function createNotificationsApi(): NotificationsApi;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|