@lace-cloud/chat-core 0.16.2 → 0.18.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/README.md +11 -8
- package/dist/index.cjs +23 -172
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +13 -49
- package/dist/index.d.ts +13 -49
- package/dist/index.mjs +22 -169
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CanvasView as CanvasView$1 } from '@lace-cloud/proto';
|
|
1
|
+
import { ChatEngineEvent, FactsSource } from '@lace-cloud/host';
|
|
3
2
|
|
|
4
3
|
type TextPart = {
|
|
5
4
|
kind: 'text';
|
|
@@ -186,7 +185,11 @@ type AgentControllerOptions = {
|
|
|
186
185
|
toolRegistry: ToolRegistry;
|
|
187
186
|
buildSystemPrompt: (availableSystems: string[]) => string;
|
|
188
187
|
getAvailableSystems: () => string[];
|
|
189
|
-
|
|
188
|
+
/** Host-supplied counts of the current canvas; null before a state has loaded. */
|
|
189
|
+
getCanvasFacts: () => {
|
|
190
|
+
nodeCount: number;
|
|
191
|
+
diagnosticCount: number;
|
|
192
|
+
} | null;
|
|
190
193
|
historyKey: string;
|
|
191
194
|
maxToolRounds?: number;
|
|
192
195
|
completedTurnCap?: number;
|
|
@@ -224,44 +227,17 @@ declare class AgentController {
|
|
|
224
227
|
*/
|
|
225
228
|
declare function capRecentMessages(messages: ChatMessage[], turnCap?: number): ChatMessage[];
|
|
226
229
|
|
|
227
|
-
type StateUpdatedLike = {
|
|
228
|
-
view: CanvasView$1 | undefined;
|
|
229
|
-
};
|
|
230
|
-
type GenerateProgressLike = {
|
|
231
|
-
stage: string;
|
|
232
|
-
message: string;
|
|
233
|
-
};
|
|
234
|
-
type GenerateSuccessLike = {
|
|
235
|
-
files_written: string[];
|
|
236
|
-
files: Record<string, string>;
|
|
237
|
-
};
|
|
238
|
-
type GenerateErrorLike = {
|
|
239
|
-
message: string;
|
|
240
|
-
diagnostics: Array<{
|
|
241
|
-
message: string;
|
|
242
|
-
instance_id?: string;
|
|
243
|
-
address?: string;
|
|
244
|
-
}>;
|
|
245
|
-
};
|
|
246
|
-
type EngineEventLike = {
|
|
247
|
-
state_updated?: StateUpdatedLike;
|
|
248
|
-
generate_progress?: GenerateProgressLike;
|
|
249
|
-
generate_success?: GenerateSuccessLike;
|
|
250
|
-
generate_error?: GenerateErrorLike;
|
|
251
|
-
};
|
|
252
230
|
type RuleState = {
|
|
253
|
-
|
|
254
|
-
prevNodeIds: Set<string>;
|
|
231
|
+
prevDiagnosticErrorCount: number;
|
|
255
232
|
};
|
|
256
233
|
declare function initialRuleState(): RuleState;
|
|
257
|
-
declare function
|
|
258
|
-
declare function
|
|
259
|
-
declare function
|
|
260
|
-
declare function
|
|
261
|
-
declare function advanceState(event: EngineEventLike, state: RuleState): RuleState;
|
|
234
|
+
declare function matchGenerateError(event: ChatEngineEvent): ProactiveSuggestion | null;
|
|
235
|
+
declare function matchErrorsAppeared(event: ChatEngineEvent, state: RuleState): ProactiveSuggestion | null;
|
|
236
|
+
declare function matchAll(event: ChatEngineEvent, state: RuleState): ProactiveSuggestion | null;
|
|
237
|
+
declare function advanceState(event: ChatEngineEvent, state: RuleState): RuleState;
|
|
262
238
|
|
|
263
239
|
type ProactivityWatcherOptions = {
|
|
264
|
-
|
|
240
|
+
facts: FactsSource;
|
|
265
241
|
sessionId: string;
|
|
266
242
|
adapter: Pick<ChatHostAdapter, 'getConfig' | 'log'>;
|
|
267
243
|
onSuggestion: (suggestion: ProactiveSuggestion) => void;
|
|
@@ -306,16 +282,4 @@ type Telemetry = {
|
|
|
306
282
|
};
|
|
307
283
|
declare function createTelemetry(log: (message: string) => void): Telemetry;
|
|
308
284
|
|
|
309
|
-
type
|
|
310
|
-
/** Compact: single-line lists. Detailed (default): markdown headers and bullets. */
|
|
311
|
-
compact?: boolean;
|
|
312
|
-
};
|
|
313
|
-
/**
|
|
314
|
-
* Format a CanvasView as a text summary.
|
|
315
|
-
*
|
|
316
|
-
* - compact mode: terse one-liner lists (used for chat context injection)
|
|
317
|
-
* - detailed mode: markdown with headers (used for describe_graph tool output)
|
|
318
|
-
*/
|
|
319
|
-
declare function formatCanvasState(view: CanvasView | undefined, opts?: FormatOptions): string;
|
|
320
|
-
|
|
321
|
-
export { AgentController, type AgentControllerOptions, type ChatHostAdapter, type ChatMessage, type ChatMessageRole, type ChatModel, type ChatStreamEvent, type CompletedTurn, type ContextSummary, type Disposable, type EngineEventLike, type HostToWebview, type Part, type ProactiveSuggestion, ProactivityWatcher, type ProactivityWatcherOptions, type RuleState, type SessionMetadata, type Telemetry, type TextPart, type ToolCallPart, type ToolHandler, type ToolInvocationRecord, type ToolRegistration, type ToolRegistry, type ToolResult, type ToolResultPart, type ToolSchema, type WebviewToHost, type WebviewTransport, advanceState, buildSystemPrompt, capRecentMessages, createTelemetry, createToolRegistry, formatCanvasState, initialRuleState, matchAll, matchErrorsAppeared, matchGenerateError, matchUnwiredRequiredInput };
|
|
285
|
+
export { AgentController, type AgentControllerOptions, type ChatHostAdapter, type ChatMessage, type ChatMessageRole, type ChatModel, type ChatStreamEvent, type CompletedTurn, type ContextSummary, type Disposable, type HostToWebview, type Part, type ProactiveSuggestion, ProactivityWatcher, type ProactivityWatcherOptions, type RuleState, type SessionMetadata, type Telemetry, type TextPart, type ToolCallPart, type ToolHandler, type ToolInvocationRecord, type ToolRegistration, type ToolRegistry, type ToolResult, type ToolResultPart, type ToolSchema, type WebviewToHost, type WebviewTransport, advanceState, buildSystemPrompt, capRecentMessages, createTelemetry, createToolRegistry, initialRuleState, matchAll, matchErrorsAppeared, matchGenerateError };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CanvasView as CanvasView$1 } from '@lace-cloud/proto';
|
|
1
|
+
import { ChatEngineEvent, FactsSource } from '@lace-cloud/host';
|
|
3
2
|
|
|
4
3
|
type TextPart = {
|
|
5
4
|
kind: 'text';
|
|
@@ -186,7 +185,11 @@ type AgentControllerOptions = {
|
|
|
186
185
|
toolRegistry: ToolRegistry;
|
|
187
186
|
buildSystemPrompt: (availableSystems: string[]) => string;
|
|
188
187
|
getAvailableSystems: () => string[];
|
|
189
|
-
|
|
188
|
+
/** Host-supplied counts of the current canvas; null before a state has loaded. */
|
|
189
|
+
getCanvasFacts: () => {
|
|
190
|
+
nodeCount: number;
|
|
191
|
+
diagnosticCount: number;
|
|
192
|
+
} | null;
|
|
190
193
|
historyKey: string;
|
|
191
194
|
maxToolRounds?: number;
|
|
192
195
|
completedTurnCap?: number;
|
|
@@ -224,44 +227,17 @@ declare class AgentController {
|
|
|
224
227
|
*/
|
|
225
228
|
declare function capRecentMessages(messages: ChatMessage[], turnCap?: number): ChatMessage[];
|
|
226
229
|
|
|
227
|
-
type StateUpdatedLike = {
|
|
228
|
-
view: CanvasView$1 | undefined;
|
|
229
|
-
};
|
|
230
|
-
type GenerateProgressLike = {
|
|
231
|
-
stage: string;
|
|
232
|
-
message: string;
|
|
233
|
-
};
|
|
234
|
-
type GenerateSuccessLike = {
|
|
235
|
-
files_written: string[];
|
|
236
|
-
files: Record<string, string>;
|
|
237
|
-
};
|
|
238
|
-
type GenerateErrorLike = {
|
|
239
|
-
message: string;
|
|
240
|
-
diagnostics: Array<{
|
|
241
|
-
message: string;
|
|
242
|
-
instance_id?: string;
|
|
243
|
-
address?: string;
|
|
244
|
-
}>;
|
|
245
|
-
};
|
|
246
|
-
type EngineEventLike = {
|
|
247
|
-
state_updated?: StateUpdatedLike;
|
|
248
|
-
generate_progress?: GenerateProgressLike;
|
|
249
|
-
generate_success?: GenerateSuccessLike;
|
|
250
|
-
generate_error?: GenerateErrorLike;
|
|
251
|
-
};
|
|
252
230
|
type RuleState = {
|
|
253
|
-
|
|
254
|
-
prevNodeIds: Set<string>;
|
|
231
|
+
prevDiagnosticErrorCount: number;
|
|
255
232
|
};
|
|
256
233
|
declare function initialRuleState(): RuleState;
|
|
257
|
-
declare function
|
|
258
|
-
declare function
|
|
259
|
-
declare function
|
|
260
|
-
declare function
|
|
261
|
-
declare function advanceState(event: EngineEventLike, state: RuleState): RuleState;
|
|
234
|
+
declare function matchGenerateError(event: ChatEngineEvent): ProactiveSuggestion | null;
|
|
235
|
+
declare function matchErrorsAppeared(event: ChatEngineEvent, state: RuleState): ProactiveSuggestion | null;
|
|
236
|
+
declare function matchAll(event: ChatEngineEvent, state: RuleState): ProactiveSuggestion | null;
|
|
237
|
+
declare function advanceState(event: ChatEngineEvent, state: RuleState): RuleState;
|
|
262
238
|
|
|
263
239
|
type ProactivityWatcherOptions = {
|
|
264
|
-
|
|
240
|
+
facts: FactsSource;
|
|
265
241
|
sessionId: string;
|
|
266
242
|
adapter: Pick<ChatHostAdapter, 'getConfig' | 'log'>;
|
|
267
243
|
onSuggestion: (suggestion: ProactiveSuggestion) => void;
|
|
@@ -306,16 +282,4 @@ type Telemetry = {
|
|
|
306
282
|
};
|
|
307
283
|
declare function createTelemetry(log: (message: string) => void): Telemetry;
|
|
308
284
|
|
|
309
|
-
type
|
|
310
|
-
/** Compact: single-line lists. Detailed (default): markdown headers and bullets. */
|
|
311
|
-
compact?: boolean;
|
|
312
|
-
};
|
|
313
|
-
/**
|
|
314
|
-
* Format a CanvasView as a text summary.
|
|
315
|
-
*
|
|
316
|
-
* - compact mode: terse one-liner lists (used for chat context injection)
|
|
317
|
-
* - detailed mode: markdown with headers (used for describe_graph tool output)
|
|
318
|
-
*/
|
|
319
|
-
declare function formatCanvasState(view: CanvasView | undefined, opts?: FormatOptions): string;
|
|
320
|
-
|
|
321
|
-
export { AgentController, type AgentControllerOptions, type ChatHostAdapter, type ChatMessage, type ChatMessageRole, type ChatModel, type ChatStreamEvent, type CompletedTurn, type ContextSummary, type Disposable, type EngineEventLike, type HostToWebview, type Part, type ProactiveSuggestion, ProactivityWatcher, type ProactivityWatcherOptions, type RuleState, type SessionMetadata, type Telemetry, type TextPart, type ToolCallPart, type ToolHandler, type ToolInvocationRecord, type ToolRegistration, type ToolRegistry, type ToolResult, type ToolResultPart, type ToolSchema, type WebviewToHost, type WebviewTransport, advanceState, buildSystemPrompt, capRecentMessages, createTelemetry, createToolRegistry, formatCanvasState, initialRuleState, matchAll, matchErrorsAppeared, matchGenerateError, matchUnwiredRequiredInput };
|
|
285
|
+
export { AgentController, type AgentControllerOptions, type ChatHostAdapter, type ChatMessage, type ChatMessageRole, type ChatModel, type ChatStreamEvent, type CompletedTurn, type ContextSummary, type Disposable, type HostToWebview, type Part, type ProactiveSuggestion, ProactivityWatcher, type ProactivityWatcherOptions, type RuleState, type SessionMetadata, type Telemetry, type TextPart, type ToolCallPart, type ToolHandler, type ToolInvocationRecord, type ToolRegistration, type ToolRegistry, type ToolResult, type ToolResultPart, type ToolSchema, type WebviewToHost, type WebviewTransport, advanceState, buildSystemPrompt, capRecentMessages, createTelemetry, createToolRegistry, initialRuleState, matchAll, matchErrorsAppeared, matchGenerateError };
|
package/dist/index.mjs
CHANGED
|
@@ -165,8 +165,8 @@ var AgentController = class {
|
|
|
165
165
|
const signal = this.activeTurn.signal;
|
|
166
166
|
const session = this.telemetry.startSession(userText);
|
|
167
167
|
const systemPrompt = this.opts.buildSystemPrompt(this.opts.getAvailableSystems());
|
|
168
|
-
const
|
|
169
|
-
const canvasContext =
|
|
168
|
+
const canvasFacts = this.opts.getCanvasFacts();
|
|
169
|
+
const canvasContext = canvasFacts ? `Canvas: ${canvasFacts.nodeCount} node(s), ${canvasFacts.diagnosticCount} diagnostic(s).` : "Canvas: (state not yet loaded)";
|
|
170
170
|
const messages = [
|
|
171
171
|
{ role: "user", content: [{ kind: "text", value: systemPrompt }] },
|
|
172
172
|
{
|
|
@@ -346,46 +346,12 @@ function signatureFor(tc) {
|
|
|
346
346
|
return `${tc.name}:${JSON.stringify(tc.input)}`;
|
|
347
347
|
}
|
|
348
348
|
|
|
349
|
-
// src/proactivity/index.ts
|
|
350
|
-
import { parseModuleKey, projectCanvasView } from "@lace-cloud/proto";
|
|
351
|
-
|
|
352
349
|
// src/proactivity/rules.ts
|
|
353
350
|
function initialRuleState() {
|
|
354
|
-
return {
|
|
351
|
+
return { prevDiagnosticErrorCount: 0 };
|
|
355
352
|
}
|
|
356
|
-
function
|
|
357
|
-
|
|
358
|
-
if (!view) return null;
|
|
359
|
-
const newNodes = view.nodes.filter((n) => !state.prevNodeIds.has(n.id));
|
|
360
|
-
if (newNodes.length === 0) return null;
|
|
361
|
-
const newNode = newNodes[0];
|
|
362
|
-
const unwiredRequiredInput = findUnwiredRequiredInput(newNode);
|
|
363
|
-
if (!unwiredRequiredInput) return null;
|
|
364
|
-
const candidate = findSiblingOutputMatch(view, newNode, unwiredRequiredInput);
|
|
365
|
-
if (!candidate) return null;
|
|
366
|
-
return {
|
|
367
|
-
id: `unwired-${newNode.id}-${unwiredRequiredInput.name}`,
|
|
368
|
-
text: `The new \`${newNode.id}\` has an unwired required input \`${unwiredRequiredInput.name}\`. Want me to wire it to \`${candidate.instanceId}.${candidate.outputName}\`?`
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
function findUnwiredRequiredInput(node) {
|
|
372
|
-
for (const pin of node.inputs) {
|
|
373
|
-
if (pin.required && !pin.wired) return pin;
|
|
374
|
-
}
|
|
375
|
-
return null;
|
|
376
|
-
}
|
|
377
|
-
function findSiblingOutputMatch(view, target, targetInput) {
|
|
378
|
-
const family = targetInput.type_family;
|
|
379
|
-
if (!family) return null;
|
|
380
|
-
for (const node of view.nodes) {
|
|
381
|
-
if (node.id === target.id) continue;
|
|
382
|
-
for (const output of node.outputs) {
|
|
383
|
-
if (output.type_family === family) {
|
|
384
|
-
return { instanceId: node.id, outputName: output.name };
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
return null;
|
|
353
|
+
function errorsOf(diagnostics) {
|
|
354
|
+
return diagnostics.filter((d) => d.severity === "error");
|
|
389
355
|
}
|
|
390
356
|
function matchGenerateError(event) {
|
|
391
357
|
const err = event.generate_error;
|
|
@@ -399,27 +365,22 @@ function matchGenerateError(event) {
|
|
|
399
365
|
};
|
|
400
366
|
}
|
|
401
367
|
function matchErrorsAppeared(event, state) {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
const curr =
|
|
405
|
-
if (state.
|
|
406
|
-
const
|
|
407
|
-
const summary = first.message + (view.errors.length > 1 ? ` (+${view.errors.length - 1} more)` : "");
|
|
368
|
+
if (!event.diagnostics) return null;
|
|
369
|
+
const errors = errorsOf(event.diagnostics);
|
|
370
|
+
const curr = errors.length;
|
|
371
|
+
if (state.prevDiagnosticErrorCount !== 0 || curr === 0) return null;
|
|
372
|
+
const summary = errors[0].message + (curr > 1 ? ` (+${curr - 1} more)` : "");
|
|
408
373
|
return {
|
|
409
374
|
id: `errors-appeared-${Date.now()}`,
|
|
410
375
|
text: `${curr} validation error${curr === 1 ? "" : "s"} appeared \u2014 ${summary}. Investigate?`
|
|
411
376
|
};
|
|
412
377
|
}
|
|
413
378
|
function matchAll(event, state) {
|
|
414
|
-
return
|
|
379
|
+
return matchGenerateError(event) ?? matchErrorsAppeared(event, state);
|
|
415
380
|
}
|
|
416
381
|
function advanceState(event, state) {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
return {
|
|
420
|
-
prevErrorCount: view.errors.length,
|
|
421
|
-
prevNodeIds: new Set(view.nodes.map((n) => n.id))
|
|
422
|
-
};
|
|
382
|
+
if (!event.diagnostics) return state;
|
|
383
|
+
return { prevDiagnosticErrorCount: errorsOf(event.diagnostics).length };
|
|
423
384
|
}
|
|
424
385
|
|
|
425
386
|
// src/proactivity/index.ts
|
|
@@ -436,7 +397,7 @@ var ProactivityWatcher = class {
|
|
|
436
397
|
}
|
|
437
398
|
start() {
|
|
438
399
|
if (this.stopped) return;
|
|
439
|
-
this.stream = this.opts.
|
|
400
|
+
this.stream = this.opts.facts.subscribeFacts(this.opts.sessionId);
|
|
440
401
|
this.stream.on("data", (event) => this.handleEvent(event));
|
|
441
402
|
this.stream.on("end", () => {
|
|
442
403
|
this.opts.adapter.log("[Proactivity] stream ended");
|
|
@@ -459,47 +420,14 @@ var ProactivityWatcher = class {
|
|
|
459
420
|
this.stream = null;
|
|
460
421
|
}
|
|
461
422
|
handleEvent(event) {
|
|
462
|
-
const converted = toEngineEventLike(event);
|
|
463
423
|
const enabled = this.opts.adapter.getConfig(CONFIG_KEY, CONFIG_ENABLED_VALUE) === CONFIG_ENABLED_VALUE;
|
|
464
424
|
if (enabled) {
|
|
465
|
-
const suggestion = matchAll(
|
|
425
|
+
const suggestion = matchAll(event, this.ruleState);
|
|
466
426
|
if (suggestion) this.opts.onSuggestion(suggestion);
|
|
467
427
|
}
|
|
468
|
-
this.ruleState = advanceState(
|
|
428
|
+
this.ruleState = advanceState(event, this.ruleState);
|
|
469
429
|
}
|
|
470
430
|
};
|
|
471
|
-
function toEngineEventLike(event) {
|
|
472
|
-
const result = {};
|
|
473
|
-
if (event.state?.bundle) {
|
|
474
|
-
const { id: moduleName } = parseModuleKey(event.state.bundle.entry);
|
|
475
|
-
const view = projectCanvasView(event.state.bundle, void 0, {
|
|
476
|
-
moduleName,
|
|
477
|
-
canUndo: event.state.can_undo,
|
|
478
|
-
canRedo: event.state.can_redo,
|
|
479
|
-
isDirty: event.state.is_dirty
|
|
480
|
-
});
|
|
481
|
-
result.state_updated = { view };
|
|
482
|
-
}
|
|
483
|
-
if (event.generate_progress) {
|
|
484
|
-
result.generate_progress = {
|
|
485
|
-
stage: event.generate_progress.stage,
|
|
486
|
-
message: event.generate_progress.message
|
|
487
|
-
};
|
|
488
|
-
}
|
|
489
|
-
if (event.generate_success) {
|
|
490
|
-
result.generate_success = {
|
|
491
|
-
files_written: event.generate_success.files_written,
|
|
492
|
-
files: event.generate_success.files
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
if (event.generate_error) {
|
|
496
|
-
result.generate_error = {
|
|
497
|
-
message: event.generate_error.message,
|
|
498
|
-
diagnostics: event.generate_error.diagnostics.map((d) => ({ message: d.message }))
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
return result;
|
|
502
|
-
}
|
|
503
431
|
|
|
504
432
|
// src/system-prompt.ts
|
|
505
433
|
function buildSystemPrompt(systems = ["aws", "azure", "google"]) {
|
|
@@ -539,7 +467,7 @@ Tell the user to open one with **Lace: Open Canvas** from the Command Palette. D
|
|
|
539
467
|
- lace_describe_graph: Get the current canvas state \u2014 instances, connections, errors.
|
|
540
468
|
- lace_validate_graph: Run validation \u2014 returns auto-resolvable vs. user-required errors.
|
|
541
469
|
- lace_inspect_node: Get the live input bindings and outputs of a placed instance.
|
|
542
|
-
- lace_get_settings: Read terraform block, providers,
|
|
470
|
+
- lace_get_settings: Read terraform block, providers, and locals.
|
|
543
471
|
- lace_workspace_context: Analyze project files \u2014 returns a structured ProjectProfile + raw content.
|
|
544
472
|
|
|
545
473
|
**Write tools** (modify the canvas):
|
|
@@ -552,7 +480,6 @@ Tell the user to open one with **Lace: Open Canvas** from the Command Palette. D
|
|
|
552
480
|
- lace_rename_instance: Rename an instance (cascades to all references).
|
|
553
481
|
- lace_set_variable: Add or update a canvas-level variable (var.NAME).
|
|
554
482
|
- lace_set_local: Add or update a local value (literal or expression).
|
|
555
|
-
- lace_set_environment: Set environment-specific variable overrides.
|
|
556
483
|
- lace_create_group: Group instances visually on the canvas.
|
|
557
484
|
- lace_ungroup: Remove a visual group (instances stay on canvas).
|
|
558
485
|
- lace_undo: Undo the last canvas change.
|
|
@@ -609,12 +536,12 @@ When setting inputs, use these heuristics for common types:
|
|
|
609
536
|
- **Instance types**: Suggest cost-effective defaults (t3.medium, Standard_B2ms) but note the user can change them.
|
|
610
537
|
- **Names, IDs, ARNs, passwords, secrets**: NEVER guess. Always ask.
|
|
611
538
|
|
|
612
|
-
## Using Locals and Environment
|
|
539
|
+
## Using Locals and Per-Environment Values
|
|
613
540
|
|
|
614
|
-
- Call lace_get_settings to see existing locals
|
|
615
|
-
- Use lace_set_local to create reusable values (e.g., local.region
|
|
616
|
-
- Use lace_set_environment to define per-environment overrides (staging vs production).
|
|
541
|
+
- Call lace_get_settings to see existing locals.
|
|
542
|
+
- Use lace_set_local to create reusable values (e.g., local.region).
|
|
617
543
|
- Reference locals in module inputs via expression: "local.NAME".
|
|
544
|
+
- Per-environment values (staging vs production) are not part of the canvas \u2014 tell the user to pass them at plan time with \`lace stack preview|apply|destroy --var-file <file>\` or \`--var name=value\`. Values passed this way are baked into the plan, so they are not secret-safe; point the user to a provider data source for secrets instead.
|
|
618
545
|
|
|
619
546
|
## Canvas Organization
|
|
620
547
|
|
|
@@ -674,78 +601,6 @@ function createToolRegistry() {
|
|
|
674
601
|
}
|
|
675
602
|
};
|
|
676
603
|
}
|
|
677
|
-
|
|
678
|
-
// src/utils/canvas-summary.ts
|
|
679
|
-
function formatCanvasState(view, opts = {}) {
|
|
680
|
-
if (!view) {
|
|
681
|
-
return "No canvas is open. Tell the user to open one with **Lace: Open Canvas** from the Command Palette before making any canvas changes.";
|
|
682
|
-
}
|
|
683
|
-
if (view.nodes.length === 0) {
|
|
684
|
-
return "Canvas is open but empty \u2014 no modules added yet.";
|
|
685
|
-
}
|
|
686
|
-
if (opts.compact) return formatCompact(view);
|
|
687
|
-
return formatDetailed(view);
|
|
688
|
-
}
|
|
689
|
-
function formatCompact(view) {
|
|
690
|
-
const groupCount = view.groups.length ?? 0;
|
|
691
|
-
const groupSuffix = groupCount > 0 ? `, ${groupCount} group(s)` : "";
|
|
692
|
-
const parts = [
|
|
693
|
-
`Canvas snapshot: ${view.nodes.length} instance(s), ${view.edges.length} connection(s)${groupSuffix}.`
|
|
694
|
-
];
|
|
695
|
-
if (groupCount > 0) {
|
|
696
|
-
const groupList = view.groups.map((g) => {
|
|
697
|
-
const collapsed = g.collapsed ? " (collapsed)" : "";
|
|
698
|
-
return `${g.label} [${g.node_ids.join(", ")}]${collapsed}`;
|
|
699
|
-
}).join(", ");
|
|
700
|
-
parts.push(`Groups: ${groupList}`);
|
|
701
|
-
}
|
|
702
|
-
const nodeList = view.nodes.map((n) => `${n.id} (${n.label})${n.has_errors ? " \u26A0" : ""}`).join(", ");
|
|
703
|
-
parts.push(`Instances: ${nodeList}`);
|
|
704
|
-
if (view.edges.length > 0) {
|
|
705
|
-
const edgeList = view.edges.map((e) => `${e.source}.${e.source_output}\u2192${e.target}.${e.target_input}`).join(", ");
|
|
706
|
-
parts.push(`Connections: ${edgeList}`);
|
|
707
|
-
}
|
|
708
|
-
if (view.errors.length > 0) {
|
|
709
|
-
parts.push(`Errors: ${view.errors.length} validation error(s) present.`);
|
|
710
|
-
}
|
|
711
|
-
return parts.join("\n");
|
|
712
|
-
}
|
|
713
|
-
function formatDetailed(view) {
|
|
714
|
-
const lines = [];
|
|
715
|
-
lines.push(`**Canvas: ${view.nodes.length} instance(s), ${view.edges.length} connection(s)**`);
|
|
716
|
-
if (view.groups.length > 0) {
|
|
717
|
-
lines.push("");
|
|
718
|
-
lines.push("### Groups");
|
|
719
|
-
for (const g of view.groups) {
|
|
720
|
-
const collapsed = g.collapsed ? " (collapsed)" : "";
|
|
721
|
-
lines.push(`- **${g.label}** \u2014 ${g.node_ids.join(", ")}${collapsed}`);
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
lines.push("");
|
|
725
|
-
lines.push("### Instances");
|
|
726
|
-
for (const node of view.nodes) {
|
|
727
|
-
const errFlag = node.has_errors ? " \u26A0 has errors" : "";
|
|
728
|
-
lines.push(`- **${node.id}** (${node.label})${errFlag}`);
|
|
729
|
-
}
|
|
730
|
-
if (view.edges.length > 0) {
|
|
731
|
-
lines.push("");
|
|
732
|
-
lines.push("### Connections");
|
|
733
|
-
for (const edge of view.edges) {
|
|
734
|
-
lines.push(
|
|
735
|
-
`- ${edge.source}.${edge.source_output} \u2192 ${edge.target}.${edge.target_input}`
|
|
736
|
-
);
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
if (view.errors.length > 0) {
|
|
740
|
-
lines.push("");
|
|
741
|
-
lines.push("### Errors");
|
|
742
|
-
for (const err of view.errors) {
|
|
743
|
-
const loc = [err.instance_id, err.input_name].filter(Boolean).join(".");
|
|
744
|
-
lines.push(`- ${loc ? `[${loc}] ` : ""}${err.message}`);
|
|
745
|
-
}
|
|
746
|
-
}
|
|
747
|
-
return lines.join("\n");
|
|
748
|
-
}
|
|
749
604
|
export {
|
|
750
605
|
AgentController,
|
|
751
606
|
ProactivityWatcher,
|
|
@@ -754,11 +609,9 @@ export {
|
|
|
754
609
|
capRecentMessages,
|
|
755
610
|
createTelemetry,
|
|
756
611
|
createToolRegistry,
|
|
757
|
-
formatCanvasState,
|
|
758
612
|
initialRuleState,
|
|
759
613
|
matchAll,
|
|
760
614
|
matchErrorsAppeared,
|
|
761
|
-
matchGenerateError
|
|
762
|
-
matchUnwiredRequiredInput
|
|
615
|
+
matchGenerateError
|
|
763
616
|
};
|
|
764
617
|
//# sourceMappingURL=index.mjs.map
|