@ai-gui/core 0.6.1 → 0.7.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/dist/index.cjs +41 -3
- package/dist/index.d.cts +42 -3
- package/dist/index.d.ts +42 -3
- package/dist/index.js +41 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -579,6 +579,38 @@ var CardRegistry = class {
|
|
|
579
579
|
}
|
|
580
580
|
};
|
|
581
581
|
|
|
582
|
+
//#endregion
|
|
583
|
+
//#region src/action-outcome.ts
|
|
584
|
+
const TONES = new Set([
|
|
585
|
+
"positive",
|
|
586
|
+
"warning",
|
|
587
|
+
"negative",
|
|
588
|
+
"neutral"
|
|
589
|
+
]);
|
|
590
|
+
function isTone(value) {
|
|
591
|
+
return typeof value === "string" && TONES.has(value);
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Read an outcome out of whatever a handler returned.
|
|
595
|
+
*
|
|
596
|
+
* A handler answers with its own result type, so the outcome is looked for rather than required:
|
|
597
|
+
* `{ tone: "warning", message: "…" }` on its own, or under an `outcome` key beside the handler's
|
|
598
|
+
* own data. Anything else means the handler did not judge, and the host shows nothing.
|
|
599
|
+
*/
|
|
600
|
+
function actionOutcome(value) {
|
|
601
|
+
const candidate = value;
|
|
602
|
+
const source = candidate?.outcome ?? candidate;
|
|
603
|
+
if (!source || !isTone(source.tone)) return void 0;
|
|
604
|
+
const outcome = { tone: source.tone };
|
|
605
|
+
if (typeof source.message === "string" && source.message.trim() !== "") outcome.message = source.message;
|
|
606
|
+
if (source.fields && typeof source.fields === "object") {
|
|
607
|
+
const fields = {};
|
|
608
|
+
for (const [name, tone] of Object.entries(source.fields)) if (isTone(tone)) fields[name] = tone;
|
|
609
|
+
if (Object.keys(fields).length > 0) outcome.fields = fields;
|
|
610
|
+
}
|
|
611
|
+
return outcome;
|
|
612
|
+
}
|
|
613
|
+
|
|
582
614
|
//#endregion
|
|
583
615
|
//#region src/card-store.ts
|
|
584
616
|
const CARD_ID_MAX_LENGTH = 256;
|
|
@@ -748,8 +780,13 @@ var CardStore = class {
|
|
|
748
780
|
actionId
|
|
749
781
|
}, true);
|
|
750
782
|
}
|
|
751
|
-
succeedAction(id, actionId) {
|
|
752
|
-
|
|
783
|
+
succeedAction(id, actionId, result) {
|
|
784
|
+
const outcome = actionOutcome(result);
|
|
785
|
+
return this.setAction(id, actionId, outcome ? {
|
|
786
|
+
status: "success",
|
|
787
|
+
actionId,
|
|
788
|
+
outcome
|
|
789
|
+
} : {
|
|
753
790
|
status: "success",
|
|
754
791
|
actionId
|
|
755
792
|
});
|
|
@@ -1121,7 +1158,7 @@ var ActionRuntime = class {
|
|
|
1121
1158
|
result
|
|
1122
1159
|
});
|
|
1123
1160
|
}
|
|
1124
|
-
if (request.cardId && this.cardStore && canAffectCard) settleCardAction(() => this.cardStore?.succeedAction(request.cardId, actionId));
|
|
1161
|
+
if (request.cardId && this.cardStore && canAffectCard) settleCardAction(() => this.cardStore?.succeedAction(request.cardId, actionId, result));
|
|
1125
1162
|
resolvePromise(result);
|
|
1126
1163
|
};
|
|
1127
1164
|
function finishError(cause) {
|
|
@@ -2633,6 +2670,7 @@ exports.CardValidationError = CardValidationError
|
|
|
2633
2670
|
exports.DebugEmitter = DebugEmitter
|
|
2634
2671
|
exports.Renderer = Renderer
|
|
2635
2672
|
exports.StreamRouter = StreamRouter
|
|
2673
|
+
exports.actionOutcome = actionOutcome
|
|
2636
2674
|
exports.applyPatches = applyPatches
|
|
2637
2675
|
exports.buildSystemPrompt = buildSystemPrompt
|
|
2638
2676
|
exports.collectNodeRenderers = collectNodeRenderers
|
package/dist/index.d.cts
CHANGED
|
@@ -283,6 +283,40 @@ declare class CardRegistry {
|
|
|
283
283
|
toJSONSchema(): JSONSchema;
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region src/action-outcome.d.ts
|
|
288
|
+
/**
|
|
289
|
+
* How a completed action turned out, as opposed to whether it completed.
|
|
290
|
+
*
|
|
291
|
+
* The lifecycle a card and an action already report — idle, loading, success, error — answers "did
|
|
292
|
+
* the dispatch run". It cannot answer "was the answer right": a student who picks the wrong option
|
|
293
|
+
* submits perfectly well, so the action succeeds and nothing on screen says otherwise. Putting a
|
|
294
|
+
* "warning" beside "error" in that lifecycle would fold a wrong answer in with a failed request,
|
|
295
|
+
* which is the one distinction a host needs to keep.
|
|
296
|
+
*
|
|
297
|
+
* So the outcome travels on its own, returned by the handler that judged it.
|
|
298
|
+
*/
|
|
299
|
+
/** How the result should read to the person looking at it. */
|
|
300
|
+
type OutcomeTone = "positive" | "warning" | "negative" | "neutral";
|
|
301
|
+
interface ActionOutcome {
|
|
302
|
+
tone: OutcomeTone;
|
|
303
|
+
/** A sentence to show beside the control — why it is wrong, or what was expected. */
|
|
304
|
+
message?: string;
|
|
305
|
+
/**
|
|
306
|
+
* Per-field verdicts, so one wrong answer marks the field it came from rather than the whole
|
|
307
|
+
* form. Keyed by field name.
|
|
308
|
+
*/
|
|
309
|
+
fields?: Record<string, OutcomeTone>;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Read an outcome out of whatever a handler returned.
|
|
313
|
+
*
|
|
314
|
+
* A handler answers with its own result type, so the outcome is looked for rather than required:
|
|
315
|
+
* `{ tone: "warning", message: "…" }` on its own, or under an `outcome` key beside the handler's
|
|
316
|
+
* own data. Anything else means the handler did not judge, and the host shows nothing.
|
|
317
|
+
*/
|
|
318
|
+
declare function actionOutcome(value: unknown): ActionOutcome | undefined;
|
|
319
|
+
|
|
286
320
|
//#endregion
|
|
287
321
|
//#region src/card-store.d.ts
|
|
288
322
|
declare const CARD_ID_MAX_LENGTH = 256;
|
|
@@ -294,9 +328,14 @@ type CardAction = {
|
|
|
294
328
|
} | {
|
|
295
329
|
status: "loading";
|
|
296
330
|
actionId: string;
|
|
297
|
-
}
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* The dispatch ran. `outcome` carries how it turned out, when the handler judged it — a student
|
|
334
|
+
* answering wrong submits successfully, so the verdict cannot live in the status.
|
|
335
|
+
*/ | {
|
|
298
336
|
status: "success";
|
|
299
337
|
actionId: string;
|
|
338
|
+
outcome?: ActionOutcome;
|
|
300
339
|
} | {
|
|
301
340
|
status: "error";
|
|
302
341
|
actionId: string;
|
|
@@ -360,7 +399,7 @@ declare class CardStore {
|
|
|
360
399
|
snapshot(): CardSnapshot;
|
|
361
400
|
restore(snapshot: CardSnapshot): void;
|
|
362
401
|
beginAction(id: string, actionId: string): boolean;
|
|
363
|
-
succeedAction(id: string, actionId: string): boolean;
|
|
402
|
+
succeedAction(id: string, actionId: string, result?: unknown): boolean;
|
|
364
403
|
failAction(id: string, actionId: string, error: unknown): boolean;
|
|
365
404
|
cancelAction(id: string, actionId: string): boolean;
|
|
366
405
|
isActionCurrent(id: string, actionId: string): boolean;
|
|
@@ -783,4 +822,4 @@ declare function mockModelStream(events: Iterable<ModelStreamEvent> | AsyncItera
|
|
|
783
822
|
declare function readableBytes(chunks: Iterable<string | Uint8Array> | AsyncIterable<string | Uint8Array>): ReadableStream<Uint8Array>;
|
|
784
823
|
|
|
785
824
|
//#endregion
|
|
786
|
-
export { AIGuiPlugin, ASTNode, ActionAbortedError, ActionAlreadyRegisteredError, ActionContext, ActionDefinition, ActionDestroyedError, ActionDispatchOptions, ActionErrorEvent, ActionEventBase, ActionExecutionError, ActionNotFoundError, ActionRegisterOptions, ActionRegistry, ActionRequest, ActionRuntime, ActionRuntimeError, ActionRuntimeOptions, ActionStartEvent, ActionState, ActionStateListener, ActionStatus, ActionSuccessEvent, ActionTimeoutError, ActionValidationError, BuildSystemPromptOptions, ByteStreamSource, CARD_ID_MAX_LENGTH, CARD_JSON_MAX_DEPTH, CARD_JSON_MAX_NODES, CARD_PATCH_BATCH_MAX_SIZE, CardAction, CardActionError, CardDef, CardJSONError, CardLimitError, CardListener, CardNotFoundError, CardParseResult, CardPatch, CardPatchBatch, CardPatchResult, CardRecord, CardRegistry, CardRevisionConflictError, CardSnapshot, CardSnapshotError, CardStore, CardStoreError, CardStoreListener, CardStoreOptions, CardTypeConflictError, CardValidationError, ChannelSink, Citation, CollectNodeRendererOptions, DebugEmitter, DebugEvent, DebugEventListener, DebugEventTarget, DebugInstrumentationTarget, DebugOptions, DebugRedactContext, DebugSource, ExportImageOptions, ExportedImage, FeedChunk, FeedOptions, FeedSource, JSONSchema, JSONSchemaValidationResult, ModelStreamEvent, MountCardSlotRequest, MountedCardSlot, NodeRenderContext, NodeRenderer, ParseResult, ParserOptions, PartialJSONResult, Patch, PluginCommitContext, RenderMountContext, RenderOutput, Renderer, RendererOptions, SSEEvent, SSEOptions, SafeDebugValueOptions, SanitizeHtmlOptions, SanitizeSetting, SourceBlock, StreamParseOptions, StreamRouter, Usage, applyPatches, buildSystemPrompt, collectNodeRenderers, contentDeltas, createActionRuntime, createParser, createParserWithMetadata, diffAst, downloadImage, exportRenderedImages, exportSVGToImage, getActionKey, getIdleActionState, isCardPatchResult, jsonLines, mockModelStream, ndjson, parsePartialJSON, parseSSE, pluginNodeTypes, readableBytes, repairMarkdown, safeDebugValue, sanitizeHtml, sanitizeRenderedHtml, textLines, validateJSONSchema };
|
|
825
|
+
export { AIGuiPlugin, ASTNode, ActionAbortedError, ActionAlreadyRegisteredError, ActionContext, ActionDefinition, ActionDestroyedError, ActionDispatchOptions, ActionErrorEvent, ActionEventBase, ActionExecutionError, ActionNotFoundError, ActionOutcome, ActionRegisterOptions, ActionRegistry, ActionRequest, ActionRuntime, ActionRuntimeError, ActionRuntimeOptions, ActionStartEvent, ActionState, ActionStateListener, ActionStatus, ActionSuccessEvent, ActionTimeoutError, ActionValidationError, BuildSystemPromptOptions, ByteStreamSource, CARD_ID_MAX_LENGTH, CARD_JSON_MAX_DEPTH, CARD_JSON_MAX_NODES, CARD_PATCH_BATCH_MAX_SIZE, CardAction, CardActionError, CardDef, CardJSONError, CardLimitError, CardListener, CardNotFoundError, CardParseResult, CardPatch, CardPatchBatch, CardPatchResult, CardRecord, CardRegistry, CardRevisionConflictError, CardSnapshot, CardSnapshotError, CardStore, CardStoreError, CardStoreListener, CardStoreOptions, CardTypeConflictError, CardValidationError, ChannelSink, Citation, CollectNodeRendererOptions, DebugEmitter, DebugEvent, DebugEventListener, DebugEventTarget, DebugInstrumentationTarget, DebugOptions, DebugRedactContext, DebugSource, ExportImageOptions, ExportedImage, FeedChunk, FeedOptions, FeedSource, JSONSchema, JSONSchemaValidationResult, ModelStreamEvent, MountCardSlotRequest, MountedCardSlot, NodeRenderContext, NodeRenderer, OutcomeTone, ParseResult, ParserOptions, PartialJSONResult, Patch, PluginCommitContext, RenderMountContext, RenderOutput, Renderer, RendererOptions, SSEEvent, SSEOptions, SafeDebugValueOptions, SanitizeHtmlOptions, SanitizeSetting, SourceBlock, StreamParseOptions, StreamRouter, Usage, actionOutcome, applyPatches, buildSystemPrompt, collectNodeRenderers, contentDeltas, createActionRuntime, createParser, createParserWithMetadata, diffAst, downloadImage, exportRenderedImages, exportSVGToImage, getActionKey, getIdleActionState, isCardPatchResult, jsonLines, mockModelStream, ndjson, parsePartialJSON, parseSSE, pluginNodeTypes, readableBytes, repairMarkdown, safeDebugValue, sanitizeHtml, sanitizeRenderedHtml, textLines, validateJSONSchema };
|
package/dist/index.d.ts
CHANGED
|
@@ -283,6 +283,40 @@ declare class CardRegistry {
|
|
|
283
283
|
toJSONSchema(): JSONSchema;
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
//#endregion
|
|
287
|
+
//#region src/action-outcome.d.ts
|
|
288
|
+
/**
|
|
289
|
+
* How a completed action turned out, as opposed to whether it completed.
|
|
290
|
+
*
|
|
291
|
+
* The lifecycle a card and an action already report — idle, loading, success, error — answers "did
|
|
292
|
+
* the dispatch run". It cannot answer "was the answer right": a student who picks the wrong option
|
|
293
|
+
* submits perfectly well, so the action succeeds and nothing on screen says otherwise. Putting a
|
|
294
|
+
* "warning" beside "error" in that lifecycle would fold a wrong answer in with a failed request,
|
|
295
|
+
* which is the one distinction a host needs to keep.
|
|
296
|
+
*
|
|
297
|
+
* So the outcome travels on its own, returned by the handler that judged it.
|
|
298
|
+
*/
|
|
299
|
+
/** How the result should read to the person looking at it. */
|
|
300
|
+
type OutcomeTone = "positive" | "warning" | "negative" | "neutral";
|
|
301
|
+
interface ActionOutcome {
|
|
302
|
+
tone: OutcomeTone;
|
|
303
|
+
/** A sentence to show beside the control — why it is wrong, or what was expected. */
|
|
304
|
+
message?: string;
|
|
305
|
+
/**
|
|
306
|
+
* Per-field verdicts, so one wrong answer marks the field it came from rather than the whole
|
|
307
|
+
* form. Keyed by field name.
|
|
308
|
+
*/
|
|
309
|
+
fields?: Record<string, OutcomeTone>;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Read an outcome out of whatever a handler returned.
|
|
313
|
+
*
|
|
314
|
+
* A handler answers with its own result type, so the outcome is looked for rather than required:
|
|
315
|
+
* `{ tone: "warning", message: "…" }` on its own, or under an `outcome` key beside the handler's
|
|
316
|
+
* own data. Anything else means the handler did not judge, and the host shows nothing.
|
|
317
|
+
*/
|
|
318
|
+
declare function actionOutcome(value: unknown): ActionOutcome | undefined;
|
|
319
|
+
|
|
286
320
|
//#endregion
|
|
287
321
|
//#region src/card-store.d.ts
|
|
288
322
|
declare const CARD_ID_MAX_LENGTH = 256;
|
|
@@ -294,9 +328,14 @@ type CardAction = {
|
|
|
294
328
|
} | {
|
|
295
329
|
status: "loading";
|
|
296
330
|
actionId: string;
|
|
297
|
-
}
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* The dispatch ran. `outcome` carries how it turned out, when the handler judged it — a student
|
|
334
|
+
* answering wrong submits successfully, so the verdict cannot live in the status.
|
|
335
|
+
*/ | {
|
|
298
336
|
status: "success";
|
|
299
337
|
actionId: string;
|
|
338
|
+
outcome?: ActionOutcome;
|
|
300
339
|
} | {
|
|
301
340
|
status: "error";
|
|
302
341
|
actionId: string;
|
|
@@ -360,7 +399,7 @@ declare class CardStore {
|
|
|
360
399
|
snapshot(): CardSnapshot;
|
|
361
400
|
restore(snapshot: CardSnapshot): void;
|
|
362
401
|
beginAction(id: string, actionId: string): boolean;
|
|
363
|
-
succeedAction(id: string, actionId: string): boolean;
|
|
402
|
+
succeedAction(id: string, actionId: string, result?: unknown): boolean;
|
|
364
403
|
failAction(id: string, actionId: string, error: unknown): boolean;
|
|
365
404
|
cancelAction(id: string, actionId: string): boolean;
|
|
366
405
|
isActionCurrent(id: string, actionId: string): boolean;
|
|
@@ -783,4 +822,4 @@ declare function mockModelStream(events: Iterable<ModelStreamEvent> | AsyncItera
|
|
|
783
822
|
declare function readableBytes(chunks: Iterable<string | Uint8Array> | AsyncIterable<string | Uint8Array>): ReadableStream<Uint8Array>;
|
|
784
823
|
|
|
785
824
|
//#endregion
|
|
786
|
-
export { AIGuiPlugin, ASTNode, ActionAbortedError, ActionAlreadyRegisteredError, ActionContext, ActionDefinition, ActionDestroyedError, ActionDispatchOptions, ActionErrorEvent, ActionEventBase, ActionExecutionError, ActionNotFoundError, ActionRegisterOptions, ActionRegistry, ActionRequest, ActionRuntime, ActionRuntimeError, ActionRuntimeOptions, ActionStartEvent, ActionState, ActionStateListener, ActionStatus, ActionSuccessEvent, ActionTimeoutError, ActionValidationError, BuildSystemPromptOptions, ByteStreamSource, CARD_ID_MAX_LENGTH, CARD_JSON_MAX_DEPTH, CARD_JSON_MAX_NODES, CARD_PATCH_BATCH_MAX_SIZE, CardAction, CardActionError, CardDef, CardJSONError, CardLimitError, CardListener, CardNotFoundError, CardParseResult, CardPatch, CardPatchBatch, CardPatchResult, CardRecord, CardRegistry, CardRevisionConflictError, CardSnapshot, CardSnapshotError, CardStore, CardStoreError, CardStoreListener, CardStoreOptions, CardTypeConflictError, CardValidationError, ChannelSink, Citation, CollectNodeRendererOptions, DebugEmitter, DebugEvent, DebugEventListener, DebugEventTarget, DebugInstrumentationTarget, DebugOptions, DebugRedactContext, DebugSource, ExportImageOptions, ExportedImage, FeedChunk, FeedOptions, FeedSource, JSONSchema, JSONSchemaValidationResult, ModelStreamEvent, MountCardSlotRequest, MountedCardSlot, NodeRenderContext, NodeRenderer, ParseResult, ParserOptions, PartialJSONResult, Patch, PluginCommitContext, RenderMountContext, RenderOutput, Renderer, RendererOptions, SSEEvent, SSEOptions, SafeDebugValueOptions, SanitizeHtmlOptions, SanitizeSetting, SourceBlock, StreamParseOptions, StreamRouter, Usage, applyPatches, buildSystemPrompt, collectNodeRenderers, contentDeltas, createActionRuntime, createParser, createParserWithMetadata, diffAst, downloadImage, exportRenderedImages, exportSVGToImage, getActionKey, getIdleActionState, isCardPatchResult, jsonLines, mockModelStream, ndjson, parsePartialJSON, parseSSE, pluginNodeTypes, readableBytes, repairMarkdown, safeDebugValue, sanitizeHtml, sanitizeRenderedHtml, textLines, validateJSONSchema };
|
|
825
|
+
export { AIGuiPlugin, ASTNode, ActionAbortedError, ActionAlreadyRegisteredError, ActionContext, ActionDefinition, ActionDestroyedError, ActionDispatchOptions, ActionErrorEvent, ActionEventBase, ActionExecutionError, ActionNotFoundError, ActionOutcome, ActionRegisterOptions, ActionRegistry, ActionRequest, ActionRuntime, ActionRuntimeError, ActionRuntimeOptions, ActionStartEvent, ActionState, ActionStateListener, ActionStatus, ActionSuccessEvent, ActionTimeoutError, ActionValidationError, BuildSystemPromptOptions, ByteStreamSource, CARD_ID_MAX_LENGTH, CARD_JSON_MAX_DEPTH, CARD_JSON_MAX_NODES, CARD_PATCH_BATCH_MAX_SIZE, CardAction, CardActionError, CardDef, CardJSONError, CardLimitError, CardListener, CardNotFoundError, CardParseResult, CardPatch, CardPatchBatch, CardPatchResult, CardRecord, CardRegistry, CardRevisionConflictError, CardSnapshot, CardSnapshotError, CardStore, CardStoreError, CardStoreListener, CardStoreOptions, CardTypeConflictError, CardValidationError, ChannelSink, Citation, CollectNodeRendererOptions, DebugEmitter, DebugEvent, DebugEventListener, DebugEventTarget, DebugInstrumentationTarget, DebugOptions, DebugRedactContext, DebugSource, ExportImageOptions, ExportedImage, FeedChunk, FeedOptions, FeedSource, JSONSchema, JSONSchemaValidationResult, ModelStreamEvent, MountCardSlotRequest, MountedCardSlot, NodeRenderContext, NodeRenderer, OutcomeTone, ParseResult, ParserOptions, PartialJSONResult, Patch, PluginCommitContext, RenderMountContext, RenderOutput, Renderer, RendererOptions, SSEEvent, SSEOptions, SafeDebugValueOptions, SanitizeHtmlOptions, SanitizeSetting, SourceBlock, StreamParseOptions, StreamRouter, Usage, actionOutcome, applyPatches, buildSystemPrompt, collectNodeRenderers, contentDeltas, createActionRuntime, createParser, createParserWithMetadata, diffAst, downloadImage, exportRenderedImages, exportSVGToImage, getActionKey, getIdleActionState, isCardPatchResult, jsonLines, mockModelStream, ndjson, parsePartialJSON, parseSSE, pluginNodeTypes, readableBytes, repairMarkdown, safeDebugValue, sanitizeHtml, sanitizeRenderedHtml, textLines, validateJSONSchema };
|
package/dist/index.js
CHANGED
|
@@ -555,6 +555,38 @@ var CardRegistry = class {
|
|
|
555
555
|
}
|
|
556
556
|
};
|
|
557
557
|
|
|
558
|
+
//#endregion
|
|
559
|
+
//#region src/action-outcome.ts
|
|
560
|
+
const TONES = new Set([
|
|
561
|
+
"positive",
|
|
562
|
+
"warning",
|
|
563
|
+
"negative",
|
|
564
|
+
"neutral"
|
|
565
|
+
]);
|
|
566
|
+
function isTone(value) {
|
|
567
|
+
return typeof value === "string" && TONES.has(value);
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Read an outcome out of whatever a handler returned.
|
|
571
|
+
*
|
|
572
|
+
* A handler answers with its own result type, so the outcome is looked for rather than required:
|
|
573
|
+
* `{ tone: "warning", message: "…" }` on its own, or under an `outcome` key beside the handler's
|
|
574
|
+
* own data. Anything else means the handler did not judge, and the host shows nothing.
|
|
575
|
+
*/
|
|
576
|
+
function actionOutcome(value) {
|
|
577
|
+
const candidate = value;
|
|
578
|
+
const source = candidate?.outcome ?? candidate;
|
|
579
|
+
if (!source || !isTone(source.tone)) return void 0;
|
|
580
|
+
const outcome = { tone: source.tone };
|
|
581
|
+
if (typeof source.message === "string" && source.message.trim() !== "") outcome.message = source.message;
|
|
582
|
+
if (source.fields && typeof source.fields === "object") {
|
|
583
|
+
const fields = {};
|
|
584
|
+
for (const [name, tone] of Object.entries(source.fields)) if (isTone(tone)) fields[name] = tone;
|
|
585
|
+
if (Object.keys(fields).length > 0) outcome.fields = fields;
|
|
586
|
+
}
|
|
587
|
+
return outcome;
|
|
588
|
+
}
|
|
589
|
+
|
|
558
590
|
//#endregion
|
|
559
591
|
//#region src/card-store.ts
|
|
560
592
|
const CARD_ID_MAX_LENGTH = 256;
|
|
@@ -724,8 +756,13 @@ var CardStore = class {
|
|
|
724
756
|
actionId
|
|
725
757
|
}, true);
|
|
726
758
|
}
|
|
727
|
-
succeedAction(id, actionId) {
|
|
728
|
-
|
|
759
|
+
succeedAction(id, actionId, result) {
|
|
760
|
+
const outcome = actionOutcome(result);
|
|
761
|
+
return this.setAction(id, actionId, outcome ? {
|
|
762
|
+
status: "success",
|
|
763
|
+
actionId,
|
|
764
|
+
outcome
|
|
765
|
+
} : {
|
|
729
766
|
status: "success",
|
|
730
767
|
actionId
|
|
731
768
|
});
|
|
@@ -1097,7 +1134,7 @@ var ActionRuntime = class {
|
|
|
1097
1134
|
result
|
|
1098
1135
|
});
|
|
1099
1136
|
}
|
|
1100
|
-
if (request.cardId && this.cardStore && canAffectCard) settleCardAction(() => this.cardStore?.succeedAction(request.cardId, actionId));
|
|
1137
|
+
if (request.cardId && this.cardStore && canAffectCard) settleCardAction(() => this.cardStore?.succeedAction(request.cardId, actionId, result));
|
|
1101
1138
|
resolvePromise(result);
|
|
1102
1139
|
};
|
|
1103
1140
|
function finishError(cause) {
|
|
@@ -2582,4 +2619,4 @@ function delay(ms, signal) {
|
|
|
2582
2619
|
}
|
|
2583
2620
|
|
|
2584
2621
|
//#endregion
|
|
2585
|
-
export { ActionAbortedError, ActionAlreadyRegisteredError, ActionDestroyedError, ActionExecutionError, ActionNotFoundError, ActionRegistry, ActionRuntime, ActionRuntimeError, ActionTimeoutError, ActionValidationError, CARD_ID_MAX_LENGTH, CARD_JSON_MAX_DEPTH, CARD_JSON_MAX_NODES, CARD_PATCH_BATCH_MAX_SIZE, CardJSONError, CardLimitError, CardNotFoundError, CardRegistry, CardRevisionConflictError, CardSnapshotError, CardStore, CardStoreError, CardTypeConflictError, CardValidationError, DebugEmitter, Renderer, StreamRouter, applyPatches, buildSystemPrompt, collectNodeRenderers, contentDeltas, createActionRuntime, createParser, createParserWithMetadata, diffAst, downloadImage, exportRenderedImages, exportSVGToImage, getActionKey, getIdleActionState, isCardPatchResult, jsonLines, mockModelStream, ndjson, parsePartialJSON, parseSSE, pluginNodeTypes, readableBytes, repairMarkdown, safeDebugValue, sanitizeHtml, sanitizeRenderedHtml, textLines, validateJSONSchema };
|
|
2622
|
+
export { ActionAbortedError, ActionAlreadyRegisteredError, ActionDestroyedError, ActionExecutionError, ActionNotFoundError, ActionRegistry, ActionRuntime, ActionRuntimeError, ActionTimeoutError, ActionValidationError, CARD_ID_MAX_LENGTH, CARD_JSON_MAX_DEPTH, CARD_JSON_MAX_NODES, CARD_PATCH_BATCH_MAX_SIZE, CardJSONError, CardLimitError, CardNotFoundError, CardRegistry, CardRevisionConflictError, CardSnapshotError, CardStore, CardStoreError, CardTypeConflictError, CardValidationError, DebugEmitter, Renderer, StreamRouter, actionOutcome, applyPatches, buildSystemPrompt, collectNodeRenderers, contentDeltas, createActionRuntime, createParser, createParserWithMetadata, diffAst, downloadImage, exportRenderedImages, exportSVGToImage, getActionKey, getIdleActionState, isCardPatchResult, jsonLines, mockModelStream, ndjson, parsePartialJSON, parseSSE, pluginNodeTypes, readableBytes, repairMarkdown, safeDebugValue, sanitizeHtml, sanitizeRenderedHtml, textLines, validateJSONSchema };
|
package/package.json
CHANGED