@beyondwork/xlsx-substrate-bindings 0.1.0 → 0.3.1
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 +189 -0
- package/assets/blank-workbook.xlsx +0 -0
- package/dist/ai/agent-metadata.d.ts +387 -0
- package/dist/ai/agent-metadata.js +227 -0
- package/dist/ai/index.d.ts +5 -1
- package/dist/ai/index.js +6 -0
- package/dist/ai/mutation-bridge.d.ts +82 -0
- package/dist/ai/mutation-bridge.js +179 -0
- package/dist/ai/types.d.ts +468 -3
- package/dist/blank-workbook/index.d.ts +24 -0
- package/dist/blank-workbook/index.js +77 -0
- package/dist/index.d.ts +8 -3
- package/dist/index.js +20 -2
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/types.d.ts +108 -18
- package/dist/wasm/ai-session-bridge.d.ts +97 -0
- package/dist/wasm/ai-session-bridge.js +154 -0
- package/dist/wasm/bridge-contract.d.ts +108 -6
- package/dist/wasm/bridge-contract.js +146 -7
- package/dist/wasm/index.d.ts +43 -2
- package/dist/wasm/index.js +253 -23
- package/dist/wasm/memory-budget.d.ts +77 -0
- package/dist/wasm/memory-budget.js +532 -0
- package/dist/wasm/runtime-guard.d.ts +141 -0
- package/dist/wasm/runtime-guard.js +373 -0
- package/dist/wasm/session-router.d.ts +1 -1
- package/dist/wasm/session-router.js +4 -1
- package/dist/wasm/web.d.ts +18 -3
- package/dist/wasm/web.js +99 -9
- package/generated/wasm-web/xlsx_substrate_wasm.d.ts +66 -0
- package/generated/wasm-web/xlsx_substrate_wasm.js +2488 -2104
- package/generated/wasm-web/xlsx_substrate_wasm_bg.wasm +0 -0
- package/generated/wasm-web/xlsx_substrate_wasm_bg.wasm.d.ts +15 -0
- package/package.json +24 -4
- package/dist/wasm/chart-test-fixture.d.ts +0 -19
- package/dist/wasm/chart-test-fixture.js +0 -42
- package/dist/wasm/media-test-fixture.d.ts +0 -44
- package/dist/wasm/media-test-fixture.js +0 -160
- package/dist/wasm/volatile-test-fixture.d.ts +0 -7
- package/dist/wasm/volatile-test-fixture.js +0 -35
- package/generated/wasm/package.json +0 -3
- package/generated/wasm/sheet-window-binary.mjs +0 -482
- package/generated/wasm/snippets/ironcalc_base-89b4f49381e1e289/inline0.js +0 -45
- package/generated/wasm/xlsx_substrate_wasm.d.ts +0 -336
- package/generated/wasm/xlsx_substrate_wasm.js +0 -2108
- package/generated/wasm/xlsx_substrate_wasm_bg.wasm +0 -0
- package/generated/wasm/xlsx_substrate_wasm_bg.wasm.d.ts +0 -105
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { XlsxFormulaCommitRequest, XlsxFormulaCommitResult, XlsxFormulaRecalculateRequest, XlsxFormulaRecalculateResult, XlsxRangeFillCommitRequest, XlsxRangeFillCommitResult, XlsxRangeClearCommitRequest, XlsxRangeClearCommitResult, XlsxRangeFormatCommitRequest, XlsxRangeFormatCommitResult, XlsxDataValidationEntryMode, XlsxDataValidationErrorStyle, XlsxDataValidationOperator, XlsxDataValidationRuleType, XlsxRangeDataValidationCommitRequest, XlsxRangeDataValidationCommitResult, XlsxRangeDataValidationTargetRange, XlsxFindLookIn, XlsxFindMatch, XlsxFindMatchKind, XlsxFindQueryEcho, XlsxFindRequest, XlsxFindResult, XlsxFindScope, XlsxGoToDefinedName, XlsxGoToRequest, XlsxGoToResult, XlsxGoToTarget, XlsxGoToTargetKind, XlsxDataRegionDirection, XlsxDataRegionRequest, XlsxDataRegionResult, XlsxDataRegionTarget, XlsxDataRegionTargetKind, XlsxReviewCommentCommitRequest, XlsxReviewCommentCommitResult, XlsxReviewCommentVerb, XlsxRangeHyperlinkCommitRequest, XlsxRangeHyperlinkCommitResult, XlsxRangeHyperlinkKind, XlsxRangeAppearanceEdit, XlsxBorderStyle, XlsxRangeBorderEdit, XlsxRangeHorizontalAlignmentEdit, XlsxRangeNumberFormatPreset, XlsxRangePasteCommitRequest, XlsxRangePasteCommitResult, XlsxRangeTransferCommitRequest, XlsxRangeTransferCommitResult, XlsxRangeTransferMode, XlsxSelectionSetClearCommitRequest, XlsxSelectionSetFormatCommitRequest, XlsxSelectionSetPasteCommitRequest, XlsxLayoutMetricAxis, XlsxLayoutMetricResizeRequest, XlsxLayoutMetricResizeResult, XlsxLayoutMetricVisibilityRequest, XlsxLayoutMetricVisibilityResult, XlsxFrozenPaneRequest, XlsxFrozenPaneResult, XlsxMergeCellsRequest, XlsxMergeCellsResult, XlsxOutlineGroupVisibilityResult, XlsxOutlineLevelOperation, XlsxOutlineLevelRequest, XlsxOutlineLevelResult, XlsxSheetStructureAxis, XlsxSheetStructureMutationRequest, XlsxSheetStructureMutationResult, XlsxSheetStructureOperation, XlsxShiftCellsCommitRequest, XlsxShiftCellsCommitResult, XlsxShiftCellsDirection, XlsxShiftCellsOperation, XlsxFilterCriterionKind, XlsxFilterCondition, XlsxFilterCriterion, XlsxFilterColumn, XlsxRangeFilterApplyRequest, XlsxRangeFilterClearRequest, XlsxRangeFilterResult, XlsxSortColumn, XlsxRangeSortRequest, XlsxRangeSortResult, XlsxTableAppendRowRequest, XlsxTableAppendRowResult, XlsxSheetTabMutationOperation, XlsxSheetTabMutationRequest, XlsxSheetTabMutationResult, XlsxKernelActionKind, XlsxKernelActionRequest, XlsxKernelActionValidation, XlsxKernelAnchor, XlsxKernelBindingState, XlsxKernelCachePosture, XlsxKernelCellValue, XlsxKernelCreateRequest, XlsxKernelDeclaredInput, XlsxKernelLanguage, XlsxKernelMutationReadback, XlsxKernelMutationResult, XlsxKernelPanelActions, XlsxKernelPanelBinding, XlsxKernelPanelReadback, XlsxKernelRunDiagnostics, XlsxKernelRunOutput, XlsxKernelRunResult, XlsxOperationPatternHint, XlsxOperationPatternValueKindCounts, XlsxRuntimeAuditDeltaSummary, XlsxRuntimeAuditEnvelope, XlsxRuntimeCellReadback, XlsxRuntimeCommandVerdict, XlsxRuntimeInvalidationBucket, XlsxRuntimeInvalidationClass, XlsxRuntimeInvalidationReceipt, XlsxDelimitedExportRefusal, XlsxRuntimeSessionDelimitedExportRequest, XlsxRuntimeSessionDelimitedExportResult, XlsxRuntimeSessionExportRequest, XlsxRuntimeSessionExportResult, XlsxRuntimeSessionMutationReceipt, XlsxSessionRecalculateRequest, XlsxSessionVolatileInputs, XlsxRuntimeUndoBoundary, XlsxRuntimeWarning, XlsxWorkflowContextInput, XlsxWorkflowLaneEntryInput, XlsxWorkflowLaneEntryStatusInput, XlsxWorkflowLaneSnapshotInput, XlsxWorkflowOverlayLaneKindInput, XlsxWorkflowPostureFactInput, XlsxWorkflowPostureKindInput, XlsxWorkflowSeverityInput, XlsxWorkflowTargetInput } from "./types.ts";
|
|
1
|
+
export type { XlsxFormulaCommitRequest, XlsxFormulaCommitResult, XlsxFormulaRecalculateRequest, XlsxFormulaRecalculateResult, XlsxRangeFillCommitRequest, XlsxRangeFillCommitResult, XlsxRangeClearCommitRequest, XlsxRangeClearCommitResult, XlsxRangeFormatCommitRequest, XlsxRangeFormatCommitResult, XlsxDataValidationEntryMode, XlsxDataValidationErrorStyle, XlsxDataValidationOperator, XlsxDataValidationRuleType, XlsxRangeDataValidationCommitRequest, XlsxRangeDataValidationCommitResult, XlsxRangeDataValidationTargetRange, XlsxFindLookIn, XlsxFindMatch, XlsxFindMatchKind, XlsxFindQueryEcho, XlsxFindRequest, XlsxFindResult, XlsxFindScope, XlsxGoToDefinedName, XlsxGoToRequest, XlsxGoToResult, XlsxGoToArea, XlsxGoToTarget, XlsxGoToTargetKind, XlsxDataRegionDirection, XlsxDataRegionRequest, XlsxDataRegionResult, XlsxDataRegionTarget, XlsxDataRegionTargetKind, XlsxReviewCommentCommitRequest, XlsxReviewCommentCommitResult, XlsxReviewCommentVerb, XlsxRangeHyperlinkCommitRequest, XlsxRangeHyperlinkCommitResult, XlsxRangeHyperlinkKind, XlsxRangeAppearanceEdit, XlsxBorderStyle, XlsxRangeBorderEdit, XlsxRangeHorizontalAlignmentEdit, XlsxRangeNumberFormatPreset, XlsxRangePasteCommitRequest, XlsxRangePasteCommitResult, XlsxRangeTransferCommitRequest, XlsxRangeTransferCommitResult, XlsxRangeTransferMode, XlsxSelectionSetClearCommitRequest, XlsxSelectionSetFormatCommitRequest, XlsxSelectionSetPasteCommitRequest, XlsxLayoutMetricAxis, XlsxLayoutMetricResizeRequest, XlsxLayoutMetricResizeResult, XlsxLayoutMetricVisibilityRequest, XlsxLayoutMetricVisibilityResult, XlsxFrozenPaneRequest, XlsxFrozenPaneResult, XlsxMergeCellsRequest, XlsxMergeCellsResult, XlsxOutlineGroupVisibilityResult, XlsxOutlineLevelOperation, XlsxOutlineLevelRequest, XlsxOutlineLevelResult, XlsxSheetStructureAxis, XlsxSheetStructureMutationRequest, XlsxSheetStructureMutationResult, XlsxSheetStructureOperation, XlsxShiftCellsCommitRequest, XlsxShiftCellsCommitResult, XlsxShiftCellsDirection, XlsxShiftCellsOperation, XlsxFilterCriterionKind, XlsxFilterCondition, XlsxFilterCriterion, XlsxFilterColumn, XlsxRangeFilterApplyRequest, XlsxRangeFilterClearRequest, XlsxRangeFilterResult, XlsxSortColumn, XlsxRangeSortRequest, XlsxRangeSortResult, XlsxTableAppendCellValue, XlsxTableAppendRowRequest, XlsxTableAppendRowResult, XlsxSheetTabMutationOperation, XlsxSheetTabMutationRequest, XlsxSheetTabMutationResult, XlsxDefinedNameMutationOperation, XlsxDefinedNameMutationRequest, XlsxDefinedNameMutationResult, XlsxDefinedNameReadback, XlsxKernelActionKind, XlsxKernelActionRequest, XlsxKernelActionValidation, XlsxKernelAnchor, XlsxKernelBindingState, XlsxKernelCachePosture, XlsxKernelCellValue, XlsxKernelCreateRequest, XlsxKernelDeclaredInput, XlsxKernelLanguage, XlsxKernelMutationReadback, XlsxKernelMutationResult, XlsxKernelPanelActions, XlsxKernelPanelBinding, XlsxKernelPanelReadback, XlsxKernelRunDiagnostics, XlsxKernelRunOutput, XlsxKernelRunResult, XlsxOperationPatternHint, XlsxOperationPatternValueKindCounts, XlsxRuntimeAuditDeltaSummary, XlsxRuntimeAuditEnvelope, XlsxRuntimeCellReadback, XlsxRuntimeCommandVerdict, XlsxRuntimeInvalidationBucket, XlsxRuntimeInvalidationClass, XlsxRuntimeInvalidationReceipt, XlsxDelimitedExportRefusal, XlsxRuntimeSessionDelimitedExportRequest, XlsxRuntimeSessionDelimitedExportResult, XlsxRuntimeSessionExportRequest, XlsxRuntimeSessionExportResult, XlsxRuntimeSessionMutationReceipt, XlsxSessionRecalculateRequest, XlsxSessionVolatileInputs, XlsxStatelessCommitRecalcInputs, XlsxRuntimeUndoBoundary, XlsxRuntimeWarning, XlsxWorkflowContextInput, XlsxWorkflowLaneEntryInput, XlsxWorkflowLaneEntryStatusInput, XlsxWorkflowLaneSnapshotInput, XlsxWorkflowOverlayLaneKindInput, XlsxWorkflowPostureFactInput, XlsxWorkflowPostureKindInput, XlsxWorkflowSeverityInput, XlsxWorkflowTargetInput } from "./types.ts";
|
|
2
2
|
export { XLSX_BORDER_STYLES } from "./types.ts";
|
package/dist/runtime/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { XlsxBlocker, XlsxCellAddress, XlsxCellRange, XlsxReadbackEnvelope, XlsxRuntimeActor, XlsxScopeHandle } from "../shared.ts";
|
|
2
2
|
export type XlsxRuntimeCommandVerdict = "applied" | "applied-with-warnings" | "blocked" | "refused";
|
|
3
|
-
export interface XlsxFormulaCommitRequest {
|
|
3
|
+
export interface XlsxFormulaCommitRequest extends XlsxStatelessCommitRecalcInputs {
|
|
4
4
|
readonly handle?: XlsxScopeHandle;
|
|
5
5
|
readonly targetAddress?: XlsxFormulaCommitTargetAddress;
|
|
6
6
|
readonly formulaText: string;
|
|
@@ -78,6 +78,22 @@ export interface XlsxSessionVolatileInputs {
|
|
|
78
78
|
/** Non-negative safe integer; reuse it to replay the same random values. */
|
|
79
79
|
readonly randomSeed: number;
|
|
80
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* X5-U-089: the host's volatile inputs on a stateless (bytes-lane) commit.
|
|
83
|
+
* A stateless commit that changes a value recalculates the committed workbook
|
|
84
|
+
* before it exports (X5-U-088; the dirty closure of what it wrote since
|
|
85
|
+
* X4-R-028, and the readers of a kernel output write since X5-U-090). A
|
|
86
|
+
* workbook that holds TODAY, NOW, RAND, RANDBETWEEN, RANDARRAY or INFO needs
|
|
87
|
+
* an explicit clock and seed for that recalculation, as `recalculateFormulas`
|
|
88
|
+
* and the session drain do (X1-D-059); without them it refuses with
|
|
89
|
+
* missing-volatile-inputs and the commit exports unrecalculated. The runtime
|
|
90
|
+
* never invents ambient time or randomness. The in-session ports ignore the
|
|
91
|
+
* field: the session lane takes the inputs on its drain
|
|
92
|
+
* (`XlsxSessionRecalculateRequest.volatileInputs`).
|
|
93
|
+
*/
|
|
94
|
+
export interface XlsxStatelessCommitRecalcInputs {
|
|
95
|
+
readonly volatileInputs?: XlsxSessionVolatileInputs;
|
|
96
|
+
}
|
|
81
97
|
/**
|
|
82
98
|
* `recalculateInSession` request: the byte-based recalculate request plus an
|
|
83
99
|
* optional mode ("dirty" default, or "full").
|
|
@@ -167,7 +183,7 @@ export interface XlsxRuntimeSessionDelimitedExportResult {
|
|
|
167
183
|
readonly blockers: readonly XlsxBlocker[];
|
|
168
184
|
readonly warnings: readonly XlsxRuntimeWarning[];
|
|
169
185
|
}
|
|
170
|
-
export interface XlsxRangeFillCommitRequest {
|
|
186
|
+
export interface XlsxRangeFillCommitRequest extends XlsxStatelessCommitRecalcInputs {
|
|
171
187
|
readonly sourceHandle: XlsxScopeHandle;
|
|
172
188
|
readonly sheetId: string;
|
|
173
189
|
readonly targetRange: XlsxCellRange;
|
|
@@ -199,7 +215,7 @@ export interface XlsxRangeFillCommitResult {
|
|
|
199
215
|
* does not validate. The invalid-data marker still reports the cells.
|
|
200
216
|
*/
|
|
201
217
|
export type XlsxDataValidationEntryMode = "enforce" | "bypass";
|
|
202
|
-
export interface XlsxRangePasteCommitRequest {
|
|
218
|
+
export interface XlsxRangePasteCommitRequest extends XlsxStatelessCommitRecalcInputs {
|
|
203
219
|
readonly sourceHandle?: XlsxScopeHandle;
|
|
204
220
|
readonly targetHandle?: XlsxScopeHandle;
|
|
205
221
|
readonly targetAddress?: XlsxFormulaCommitTargetAddress;
|
|
@@ -223,7 +239,7 @@ export interface XlsxRangePasteCommitResult {
|
|
|
223
239
|
readonly session?: XlsxRuntimeSessionMutationReceipt;
|
|
224
240
|
}
|
|
225
241
|
export type XlsxRangeTransferMode = "move" | "copy";
|
|
226
|
-
export interface XlsxRangeTransferCommitRequest {
|
|
242
|
+
export interface XlsxRangeTransferCommitRequest extends XlsxStatelessCommitRecalcInputs {
|
|
227
243
|
readonly sourceHandle: XlsxScopeHandle;
|
|
228
244
|
readonly sheetId: string;
|
|
229
245
|
readonly targetRange: XlsxCellRange;
|
|
@@ -250,7 +266,7 @@ export interface XlsxRangeTransferCommitResult {
|
|
|
250
266
|
*/
|
|
251
267
|
export type XlsxShiftCellsOperation = "insert-cells" | "delete-cells";
|
|
252
268
|
export type XlsxShiftCellsDirection = "shift-right" | "shift-down" | "shift-left" | "shift-up";
|
|
253
|
-
export interface XlsxShiftCellsCommitRequest {
|
|
269
|
+
export interface XlsxShiftCellsCommitRequest extends XlsxStatelessCommitRecalcInputs {
|
|
254
270
|
readonly sheetId: string;
|
|
255
271
|
readonly range: XlsxCellRange;
|
|
256
272
|
readonly operation: XlsxShiftCellsOperation;
|
|
@@ -275,7 +291,7 @@ export interface XlsxShiftCellsCommitResult {
|
|
|
275
291
|
/** Present only on `*InSession` results (strict superset receipt). */
|
|
276
292
|
readonly session?: XlsxRuntimeSessionMutationReceipt;
|
|
277
293
|
}
|
|
278
|
-
export interface XlsxRangeClearCommitRequest {
|
|
294
|
+
export interface XlsxRangeClearCommitRequest extends XlsxStatelessCommitRecalcInputs {
|
|
279
295
|
readonly targetHandle?: XlsxScopeHandle;
|
|
280
296
|
readonly targetAddress?: XlsxFormulaCommitTargetAddress;
|
|
281
297
|
readonly sheetId?: string;
|
|
@@ -363,7 +379,7 @@ export interface XlsxRangeFormatCommitRequest extends XlsxRangeAppearanceEdit {
|
|
|
363
379
|
readonly actor?: XlsxRuntimeActor;
|
|
364
380
|
readonly workflowContext?: XlsxWorkflowContextInput;
|
|
365
381
|
}
|
|
366
|
-
export interface XlsxSelectionSetPasteCommitRequest {
|
|
382
|
+
export interface XlsxSelectionSetPasteCommitRequest extends XlsxStatelessCommitRecalcInputs {
|
|
367
383
|
readonly selectionSetHandles: readonly XlsxScopeHandle[];
|
|
368
384
|
readonly sheetId?: string;
|
|
369
385
|
readonly clipboardText: string;
|
|
@@ -372,7 +388,7 @@ export interface XlsxSelectionSetPasteCommitRequest {
|
|
|
372
388
|
/** X5-U-011 (bridge v31). Absent = `"enforce"`. */
|
|
373
389
|
readonly dataValidation?: XlsxDataValidationEntryMode;
|
|
374
390
|
}
|
|
375
|
-
export interface XlsxSelectionSetClearCommitRequest {
|
|
391
|
+
export interface XlsxSelectionSetClearCommitRequest extends XlsxStatelessCommitRecalcInputs {
|
|
376
392
|
readonly selectionSetHandles: readonly XlsxScopeHandle[];
|
|
377
393
|
readonly sheetId?: string;
|
|
378
394
|
readonly actor?: XlsxRuntimeActor;
|
|
@@ -630,6 +646,24 @@ export interface XlsxGoToTarget {
|
|
|
630
646
|
* it and the grid readback and formula bar follow.
|
|
631
647
|
*/
|
|
632
648
|
readonly selectionHandle: XlsxScopeHandle;
|
|
649
|
+
/**
|
|
650
|
+
* X5-U-023 (bridge v49): the areas after the first of a multi-area target
|
|
651
|
+
* (a `Print_Titles` that repeats both columns and rows is the column band,
|
|
652
|
+
* then the row band, the order Excel stores the name in), on the target's
|
|
653
|
+
* sheet. Absent or empty for a one-area target. A host selects every area
|
|
654
|
+
* as one selection set, the first area active, and `label` spells them all
|
|
655
|
+
* (`A:A,1:1`).
|
|
656
|
+
*/
|
|
657
|
+
readonly additionalAreas?: readonly XlsxGoToArea[];
|
|
658
|
+
}
|
|
659
|
+
/** X5-U-023 (bridge v49): one more area of a multi-area go-to target. */
|
|
660
|
+
export interface XlsxGoToArea {
|
|
661
|
+
readonly kind: XlsxGoToTargetKind;
|
|
662
|
+
readonly range: XlsxCellRange;
|
|
663
|
+
/** The area's own spelling (`1:1`, or `'Sheet 2'!1:1` off the sheet in view). */
|
|
664
|
+
readonly label: string;
|
|
665
|
+
/** The derived range / row / column handle that selects the area. */
|
|
666
|
+
readonly selectionHandle: XlsxScopeHandle;
|
|
633
667
|
}
|
|
634
668
|
/**
|
|
635
669
|
* `resolved` carries the target; `refused` the typed blockers
|
|
@@ -724,7 +758,7 @@ export interface XlsxLayoutMetricResizeResult {
|
|
|
724
758
|
/** Present only on `*InSession` results (strict superset receipt). */
|
|
725
759
|
readonly session?: XlsxRuntimeSessionMutationReceipt;
|
|
726
760
|
}
|
|
727
|
-
export interface XlsxLayoutMetricVisibilityRequest {
|
|
761
|
+
export interface XlsxLayoutMetricVisibilityRequest extends XlsxStatelessCommitRecalcInputs {
|
|
728
762
|
readonly sheetId: string;
|
|
729
763
|
readonly index: number;
|
|
730
764
|
readonly hidden: boolean;
|
|
@@ -790,7 +824,7 @@ export interface XlsxFrozenPaneResult {
|
|
|
790
824
|
* user, then re-sends with `discardCoveredContent: true`. A merge that
|
|
791
825
|
* discards nothing applies on the first send, as Excel does.
|
|
792
826
|
*/
|
|
793
|
-
export interface XlsxMergeCellsRequest {
|
|
827
|
+
export interface XlsxMergeCellsRequest extends XlsxStatelessCommitRecalcInputs {
|
|
794
828
|
readonly sheetId: string;
|
|
795
829
|
readonly range: XlsxCellRange;
|
|
796
830
|
readonly unmerge?: boolean;
|
|
@@ -839,6 +873,8 @@ export interface XlsxOutlineGroupVisibilityResult {
|
|
|
839
873
|
readonly undoBoundary?: XlsxRuntimeUndoBoundary;
|
|
840
874
|
readonly blockers: readonly XlsxBlocker[];
|
|
841
875
|
readonly warnings: readonly XlsxRuntimeWarning[];
|
|
876
|
+
/** UX-P-102 P2b: present only on `*InSession` results (strict superset receipt). */
|
|
877
|
+
readonly session?: XlsxRuntimeSessionMutationReceipt;
|
|
842
878
|
}
|
|
843
879
|
export type XlsxOutlineLevelOperation = "group" | "ungroup";
|
|
844
880
|
/**
|
|
@@ -869,6 +905,8 @@ export interface XlsxOutlineLevelResult {
|
|
|
869
905
|
readonly undoBoundary?: XlsxRuntimeUndoBoundary;
|
|
870
906
|
readonly blockers: readonly XlsxBlocker[];
|
|
871
907
|
readonly warnings: readonly XlsxRuntimeWarning[];
|
|
908
|
+
/** UX-P-102 P2b: present only on `*InSession` results (strict superset receipt). */
|
|
909
|
+
readonly session?: XlsxRuntimeSessionMutationReceipt;
|
|
872
910
|
}
|
|
873
911
|
export type XlsxSheetStructureAxis = "row" | "column";
|
|
874
912
|
export type XlsxSheetStructureOperation = "insert-before" | "insert-after" | "delete";
|
|
@@ -885,7 +923,7 @@ export type XlsxSheetStructureOperation = "insert-before" | "insert-after" | "de
|
|
|
885
923
|
* undo boundary. The result's `index` is the span's first index and `count`
|
|
886
924
|
* its length.
|
|
887
925
|
*/
|
|
888
|
-
export interface XlsxSheetStructureMutationRequest {
|
|
926
|
+
export interface XlsxSheetStructureMutationRequest extends XlsxStatelessCommitRecalcInputs {
|
|
889
927
|
readonly sheetId: string;
|
|
890
928
|
readonly axis: XlsxSheetStructureAxis;
|
|
891
929
|
readonly operation: XlsxSheetStructureOperation;
|
|
@@ -911,10 +949,10 @@ export interface XlsxSheetStructureMutationResult {
|
|
|
911
949
|
/** Present only on `*InSession` results (strict superset receipt). */
|
|
912
950
|
readonly session?: XlsxRuntimeSessionMutationReceipt;
|
|
913
951
|
}
|
|
914
|
-
export interface XlsxTableAppendRowRequest {
|
|
952
|
+
export interface XlsxTableAppendRowRequest extends XlsxStatelessCommitRecalcInputs {
|
|
915
953
|
readonly sheetId: string;
|
|
916
954
|
readonly tableId: string;
|
|
917
|
-
readonly values: readonly
|
|
955
|
+
readonly values: readonly XlsxTableAppendCellValue[];
|
|
918
956
|
readonly actor?: XlsxRuntimeActor;
|
|
919
957
|
readonly workflowContext?: XlsxWorkflowContextInput;
|
|
920
958
|
}
|
|
@@ -965,14 +1003,14 @@ export interface XlsxFilterColumn {
|
|
|
965
1003
|
readonly colId: number;
|
|
966
1004
|
readonly criterion: XlsxFilterCriterion;
|
|
967
1005
|
}
|
|
968
|
-
export interface XlsxRangeFilterApplyRequest {
|
|
1006
|
+
export interface XlsxRangeFilterApplyRequest extends XlsxStatelessCommitRecalcInputs {
|
|
969
1007
|
readonly sheetId: string;
|
|
970
1008
|
readonly range: XlsxCellRange;
|
|
971
1009
|
readonly columns: readonly XlsxFilterColumn[];
|
|
972
1010
|
readonly actor?: XlsxRuntimeActor;
|
|
973
1011
|
readonly workflowContext?: XlsxWorkflowContextInput;
|
|
974
1012
|
}
|
|
975
|
-
export interface XlsxRangeFilterClearRequest {
|
|
1013
|
+
export interface XlsxRangeFilterClearRequest extends XlsxStatelessCommitRecalcInputs {
|
|
976
1014
|
readonly sheetId: string;
|
|
977
1015
|
readonly range: XlsxCellRange;
|
|
978
1016
|
readonly actor?: XlsxRuntimeActor;
|
|
@@ -992,13 +1030,15 @@ export interface XlsxRangeFilterResult {
|
|
|
992
1030
|
readonly undoBoundary?: XlsxRuntimeUndoBoundary;
|
|
993
1031
|
readonly blockers: readonly XlsxBlocker[];
|
|
994
1032
|
readonly warnings: readonly XlsxRuntimeWarning[];
|
|
1033
|
+
/** UX-P-102 P2b: present only on `*InSession` results (strict superset receipt). */
|
|
1034
|
+
readonly session?: XlsxRuntimeSessionMutationReceipt;
|
|
995
1035
|
}
|
|
996
1036
|
export interface XlsxSortColumn {
|
|
997
1037
|
/** Absolute 1-based worksheet column; must fall inside the sort range. */
|
|
998
1038
|
readonly column: number;
|
|
999
1039
|
readonly descending?: boolean;
|
|
1000
1040
|
}
|
|
1001
|
-
export interface XlsxRangeSortRequest {
|
|
1041
|
+
export interface XlsxRangeSortRequest extends XlsxStatelessCommitRecalcInputs {
|
|
1002
1042
|
readonly sheetId: string;
|
|
1003
1043
|
readonly range: XlsxCellRange;
|
|
1004
1044
|
/** Sort keys in priority order (the first is primary). */
|
|
@@ -1018,9 +1058,11 @@ export interface XlsxRangeSortResult {
|
|
|
1018
1058
|
readonly undoBoundary?: XlsxRuntimeUndoBoundary;
|
|
1019
1059
|
readonly blockers: readonly XlsxBlocker[];
|
|
1020
1060
|
readonly warnings: readonly XlsxRuntimeWarning[];
|
|
1061
|
+
/** UX-P-102 P2b: present only on `*InSession` results (strict superset receipt). */
|
|
1062
|
+
readonly session?: XlsxRuntimeSessionMutationReceipt;
|
|
1021
1063
|
}
|
|
1022
1064
|
export type XlsxSheetTabMutationOperation = "add" | "rename" | "duplicate" | "delete" | "move-left" | "move-right";
|
|
1023
|
-
export interface XlsxSheetTabMutationRequest {
|
|
1065
|
+
export interface XlsxSheetTabMutationRequest extends XlsxStatelessCommitRecalcInputs {
|
|
1024
1066
|
readonly sheetId?: string;
|
|
1025
1067
|
readonly operation: XlsxSheetTabMutationOperation;
|
|
1026
1068
|
readonly name?: string;
|
|
@@ -1042,6 +1084,46 @@ export interface XlsxSheetTabMutationResult {
|
|
|
1042
1084
|
/** Present only on `*InSession` results (strict superset receipt). */
|
|
1043
1085
|
readonly session?: XlsxRuntimeSessionMutationReceipt;
|
|
1044
1086
|
}
|
|
1087
|
+
/** X5-U-023 (bridge v44): one Name Manager edit. */
|
|
1088
|
+
export type XlsxDefinedNameMutationOperation = "create" | "update" | "delete";
|
|
1089
|
+
export interface XlsxDefinedNameMutationRequest extends XlsxStatelessCommitRecalcInputs {
|
|
1090
|
+
readonly operation: XlsxDefinedNameMutationOperation;
|
|
1091
|
+
/** The name to create, or the existing name an update or delete addresses (Excel's name fold). */
|
|
1092
|
+
readonly name: string;
|
|
1093
|
+
/** The scope sheet's id; absent for a workbook-level name. An update keeps the scope. */
|
|
1094
|
+
readonly sheetScope?: string;
|
|
1095
|
+
/** Update only: the new spelling. */
|
|
1096
|
+
readonly newName?: string;
|
|
1097
|
+
/** The "Refers to" body, with or without its leading `=`; required for create. */
|
|
1098
|
+
readonly refersTo?: string;
|
|
1099
|
+
/** The sheet in view: a bare reference body on a workbook-level name is qualified with it. */
|
|
1100
|
+
readonly activeSheetId?: string;
|
|
1101
|
+
readonly actor?: XlsxRuntimeActor;
|
|
1102
|
+
readonly workflowContext?: XlsxWorkflowContextInput;
|
|
1103
|
+
}
|
|
1104
|
+
/** The name as the edit left it (for a delete, the name removed). */
|
|
1105
|
+
export interface XlsxDefinedNameReadback {
|
|
1106
|
+
readonly name: string;
|
|
1107
|
+
readonly sheetScope?: string;
|
|
1108
|
+
/** The body as stored: no leading `=`, Excel's `_xlfn.` storage prefixes applied. */
|
|
1109
|
+
readonly refersTo: string;
|
|
1110
|
+
/** The sheet and range the body names when it is one sheet range. */
|
|
1111
|
+
readonly targetSheetId?: string;
|
|
1112
|
+
readonly targetRange?: XlsxCellRange;
|
|
1113
|
+
}
|
|
1114
|
+
export interface XlsxDefinedNameMutationResult {
|
|
1115
|
+
readonly verdict: XlsxRuntimeCommandVerdict;
|
|
1116
|
+
readonly exportedBytes?: Uint8Array;
|
|
1117
|
+
readonly operation?: XlsxDefinedNameMutationOperation;
|
|
1118
|
+
readonly definedName?: XlsxDefinedNameReadback;
|
|
1119
|
+
readonly audit?: XlsxRuntimeAuditEnvelope;
|
|
1120
|
+
readonly invalidation: XlsxRuntimeInvalidationReceipt;
|
|
1121
|
+
readonly undoBoundary?: XlsxRuntimeUndoBoundary;
|
|
1122
|
+
readonly blockers: readonly XlsxBlocker[];
|
|
1123
|
+
readonly warnings: readonly XlsxRuntimeWarning[];
|
|
1124
|
+
/** Present only on `defineNameInSession` results (strict superset receipt). */
|
|
1125
|
+
readonly session?: XlsxRuntimeSessionMutationReceipt;
|
|
1126
|
+
}
|
|
1045
1127
|
export type XlsxKernelLanguage = "python" | "sql" | "javascript" | "ai-prompt";
|
|
1046
1128
|
export type XlsxKernelBindingState = "fresh" | "stale" | "running" | "failed" | "detached";
|
|
1047
1129
|
export type XlsxKernelCachePosture = "fresh" | "stale" | "missing" | "failed" | "running" | "detached";
|
|
@@ -1126,7 +1208,7 @@ export interface XlsxKernelCreateRequest {
|
|
|
1126
1208
|
*/
|
|
1127
1209
|
readonly expectedCanonicalHash?: string;
|
|
1128
1210
|
}
|
|
1129
|
-
export interface XlsxKernelActionRequest {
|
|
1211
|
+
export interface XlsxKernelActionRequest extends XlsxStatelessCommitRecalcInputs {
|
|
1130
1212
|
readonly bindingId: string;
|
|
1131
1213
|
readonly action: XlsxKernelActionKind;
|
|
1132
1214
|
readonly actor?: XlsxRuntimeActor;
|
|
@@ -1219,6 +1301,14 @@ export type XlsxKernelCellValue = {
|
|
|
1219
1301
|
readonly kind: "error";
|
|
1220
1302
|
readonly value: string;
|
|
1221
1303
|
};
|
|
1304
|
+
/**
|
|
1305
|
+
* X5-U-083 (bridge v46): one cell of a table-append row. `{ kind: "empty" }`
|
|
1306
|
+
* leaves the cell empty, so a calculated column takes the column's formula
|
|
1307
|
+
* for the new row, as Excel fills it; any other column stays empty.
|
|
1308
|
+
*/
|
|
1309
|
+
export type XlsxTableAppendCellValue = XlsxKernelCellValue | {
|
|
1310
|
+
readonly kind: "empty";
|
|
1311
|
+
};
|
|
1222
1312
|
export interface XlsxKernelRunDiagnostics {
|
|
1223
1313
|
readonly accessedReferences: readonly string[];
|
|
1224
1314
|
readonly stdoutDigest?: string;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { XlsxAiApplyPlanRequest, XlsxAiApplyProposalRequest, XlsxAiApplyReceipt, XlsxAiCalcGraphEdgesRequest, XlsxAiCalcGraphEdgesResult, XlsxAiPlanReceipt, XlsxAiPreviewRequest, XlsxAiPreviewResult, XlsxAiRefusal, XlsxAiScopeBundleReadRequest, XlsxAiScopeNeighborhoodRequest, XlsxAiScopeNeighborhoodResult, XlsxAiScopeReadResult, XlsxAiSessionReferenceRequest, XlsxAiSessionReferenceResult, XlsxAiSessionScopeBundleResult, XlsxAiUnknownOpRefusal, XlsxAiValidateRequest, XlsxAiValidateResult } from "../ai/types.ts";
|
|
2
|
+
/** The one capability gating the AI session lane (Q8). */
|
|
3
|
+
export declare const AI_SESSION_AGENT_CAPABILITY: "ai-session-agent-v1";
|
|
4
|
+
/** The one raw `#[wasm_bindgen]` export every AI verb rides (Q8 fold). */
|
|
5
|
+
export declare const AI_SESSION_RAW_METHOD: "aiSessionCall";
|
|
6
|
+
/**
|
|
7
|
+
* The nine verbs by pool class, as `aiSessionCall`'s `op` values.
|
|
8
|
+
* `sessionCall` runs outside the session commit lock (reads, preview,
|
|
9
|
+
* validate); `sessionCommit` is the two apply ports, which run the fence
|
|
10
|
+
* check, apply, drain and mint in one call. XB7's floors are expressed over
|
|
11
|
+
* the four read verbs of XB5 here; XB8's over the preview, validate and
|
|
12
|
+
* apply verbs. The fifth read verb, `readRuntimeSessionCalcGraphEdges`, is
|
|
13
|
+
* T-O's adjacency export (WP-DOC P4-prep-2): the projector's read, never an
|
|
14
|
+
* agent tool.
|
|
15
|
+
*/
|
|
16
|
+
export declare const AI_SESSION_OPS: {
|
|
17
|
+
readonly sessionCall: readonly ["getRuntimeSessionScopeBundle", "resolveRuntimeSessionReference", "readRuntimeSessionScope", "readRuntimeSessionScopeNeighborhood", "readRuntimeSessionCalcGraphEdges", "previewRuntimeSessionAiProposal", "validateRuntimeSessionAiProposal"];
|
|
18
|
+
readonly sessionCommit: readonly ["applyRuntimeSessionAiProposal", "applyRuntimeSessionAiPlan"];
|
|
19
|
+
};
|
|
20
|
+
export type AiSessionCallOp = (typeof AI_SESSION_OPS.sessionCall)[number];
|
|
21
|
+
/**
|
|
22
|
+
* The AI commit ports at op level; `commitSessionOnly` (XB8) types its port
|
|
23
|
+
* with this and maps it to `{ method: "aiSessionCall", args: [port, …] }`.
|
|
24
|
+
*/
|
|
25
|
+
export type AiSessionCommitMethod = (typeof AI_SESSION_OPS.sessionCommit)[number];
|
|
26
|
+
export type AiSessionOp = AiSessionCallOp | AiSessionCommitMethod;
|
|
27
|
+
/** The bridge object's typed AI method names are the op names. */
|
|
28
|
+
export type AiSessionMethod = AiSessionOp;
|
|
29
|
+
/** Every AI verb, flat, in the order the two lists declare them. */
|
|
30
|
+
export declare const AI_SESSION_METHODS: readonly AiSessionMethod[];
|
|
31
|
+
/**
|
|
32
|
+
* The raw method names by pool class: the ONE raw export in BOTH classes.
|
|
33
|
+
* The caller's pool `op` ("session-call" vs "session-commit") picks the
|
|
34
|
+
* path, and the pool and the worker check that `args[0]` (the verb) belongs
|
|
35
|
+
* to that class (`isAiSessionOpInClass`), so a commit verb can never ride a
|
|
36
|
+
* session-call job outside the service's session commit lock.
|
|
37
|
+
*/
|
|
38
|
+
export declare const AI_SESSION_POOL_METHODS: {
|
|
39
|
+
readonly sessionCall: readonly ["aiSessionCall"];
|
|
40
|
+
readonly sessionCommit: readonly ["aiSessionCall"];
|
|
41
|
+
};
|
|
42
|
+
/** The raw export names the mount gate requires (the two classes, deduplicated). */
|
|
43
|
+
export declare const AI_SESSION_RAW_METHODS: readonly ["aiSessionCall"];
|
|
44
|
+
/** The pool class an `aiSessionCall` job must carry for its verb; `undefined` for an unknown verb. */
|
|
45
|
+
export declare function aiSessionOpClass(op: unknown): "session-call" | "session-commit" | undefined;
|
|
46
|
+
/** The one export's answer for a known op: one of the nine result DTOs (§5.6; T-O). */
|
|
47
|
+
export type XlsxAiSessionCallResult = XlsxAiSessionScopeBundleResult | XlsxAiSessionReferenceResult | XlsxAiScopeReadResult | XlsxAiScopeNeighborhoodResult | XlsxAiCalcGraphEdgesResult | XlsxAiPreviewResult | XlsxAiValidateResult | XlsxAiApplyReceipt | XlsxAiPlanReceipt;
|
|
48
|
+
/**
|
|
49
|
+
* The raw wasm module's AI surface: the one export, `aiSessionCall(handleId,
|
|
50
|
+
* op, request)` — the handle FIRST, the pooled worker's dispatch convention
|
|
51
|
+
* (R-XB5-4). `op` selects the request and result DTO pair (§5.6); an unknown
|
|
52
|
+
* `op` answers the `XlsxAiUnknownOpRefusal` DTO (`verdict: "refused"`, the
|
|
53
|
+
* op, an `input:malformed-body` refusal, no stamp).
|
|
54
|
+
*/
|
|
55
|
+
export interface RawXlsxAiSessionModule {
|
|
56
|
+
aiSessionCall(handleId: string, op: string, request: unknown): XlsxAiSessionCallResult | XlsxAiUnknownOpRefusal;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The unknown-op answer is the only AI answer without a stamp: a refused
|
|
60
|
+
* verdict that names the op it could not dispatch (R-XB5-6).
|
|
61
|
+
*/
|
|
62
|
+
export declare function isXlsxAiUnknownOpRefusal(answer: unknown): answer is XlsxAiUnknownOpRefusal;
|
|
63
|
+
/**
|
|
64
|
+
* Thrown by the typed methods when the export answers the unknown-op DTO:
|
|
65
|
+
* the nine typed methods only ever send a declared verb, so this answer
|
|
66
|
+
* means the mounted wasm and these bindings disagree on the verb list (a
|
|
67
|
+
* stale bundle), which the service's thrown-class mapping (Q4) surfaces as a
|
|
68
|
+
* typed refusal rather than a mis-shaped result.
|
|
69
|
+
*/
|
|
70
|
+
export declare class XlsxAiUnknownOpRefusalError extends Error {
|
|
71
|
+
readonly code: string;
|
|
72
|
+
readonly op: string;
|
|
73
|
+
readonly refusal: XlsxAiRefusal;
|
|
74
|
+
readonly answer: XlsxAiUnknownOpRefusal;
|
|
75
|
+
constructor(answer: XlsxAiUnknownOpRefusal);
|
|
76
|
+
}
|
|
77
|
+
/** The bridge's AI surface: the nine typed methods, dispatching to the one export. */
|
|
78
|
+
export interface XlsxAiSessionBridgeMethods {
|
|
79
|
+
getRuntimeSessionScopeBundle(handleId: string, request: XlsxAiScopeBundleReadRequest): XlsxAiSessionScopeBundleResult;
|
|
80
|
+
resolveRuntimeSessionReference(handleId: string, request: XlsxAiSessionReferenceRequest): XlsxAiSessionReferenceResult;
|
|
81
|
+
readRuntimeSessionScope(handleId: string, request: XlsxAiScopeBundleReadRequest): XlsxAiScopeReadResult;
|
|
82
|
+
readRuntimeSessionScopeNeighborhood(handleId: string, request: XlsxAiScopeNeighborhoodRequest): XlsxAiScopeNeighborhoodResult;
|
|
83
|
+
/** T-O (WP-DOC P4-prep-2): the calc-graph adjacency export — sorted (dependent, precedent) pairs + descriptors; fenced, bounded by `limit`. */
|
|
84
|
+
readRuntimeSessionCalcGraphEdges(handleId: string, request: XlsxAiCalcGraphEdgesRequest): XlsxAiCalcGraphEdgesResult;
|
|
85
|
+
previewRuntimeSessionAiProposal(handleId: string, request: XlsxAiPreviewRequest): XlsxAiPreviewResult;
|
|
86
|
+
validateRuntimeSessionAiProposal(handleId: string, request: XlsxAiValidateRequest): XlsxAiValidateResult;
|
|
87
|
+
applyRuntimeSessionAiProposal(handleId: string, request: XlsxAiApplyProposalRequest): XlsxAiApplyReceipt;
|
|
88
|
+
applyRuntimeSessionAiPlan(handleId: string, request: XlsxAiApplyPlanRequest): XlsxAiPlanReceipt;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Bind the nine typed methods on a validated raw module: each dispatches to
|
|
92
|
+
* `aiSessionCall(handleId, op, request)` with its own verb as `op` — the
|
|
93
|
+
* same call the pooled worker makes (R-XB5-4). The results are plain JSON
|
|
94
|
+
* values (no byte carriers); the one normalization is the unknown-op DTO,
|
|
95
|
+
* surfaced as the typed `XlsxAiUnknownOpRefusalError` (R-XB5-6).
|
|
96
|
+
*/
|
|
97
|
+
export declare function attachAiSessionMethods(raw: RawXlsxAiSessionModule): XlsxAiSessionBridgeMethods;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// XB5 (design record §5.5, Q8): the AI session lane's bridge surface, declared
|
|
2
|
+
// ONCE. The pool, the worker's twin, the packed consumer and the contract's
|
|
3
|
+
// `requiredRawMethods` all read these constants, so a method cannot reach the
|
|
4
|
+
// bridge without reaching the two allowlists (the X1-D-068 class).
|
|
5
|
+
//
|
|
6
|
+
// Q8's fold criterion fired at XB5 (R-XB5-1): the measured glue delta of
|
|
7
|
+
// eight `#[wasm_bindgen]` exports exceeded 3% of the glue row on both
|
|
8
|
+
// targets, so `crates/sheets-wasm/src/ai_session.rs` declares ONE
|
|
9
|
+
// JSON-dispatched export, `aiSessionCall(handleId, op, req)` — the handle
|
|
10
|
+
// FIRST, as every export the pooled worker dispatches
|
|
11
|
+
// (`raw[method](handleId, ...args)`), so the pool job
|
|
12
|
+
// `{method: "aiSessionCall", args: [op, request]}` and this bridge share ONE
|
|
13
|
+
// dispatch convention (R-XB5-4) — and the nine verbs (the eight of XB5 plus
|
|
14
|
+
// WP-DOC P4-prep-2's read-only adjacency export, T-O; gate note WP-G1) are
|
|
15
|
+
// its `op` values (`AI_SESSION_OPS`, the same list the Rust table
|
|
16
|
+
// `AI_SESSION_OPS` spells). The bridge object keeps the nine TYPED methods:
|
|
17
|
+
// `attachAiSessionMethods` dispatches each to the one raw export with its
|
|
18
|
+
// verb, so callers, `aiSurface` and the DTOs are unchanged by the fold. The
|
|
19
|
+
// service pin `wasm-runtime-pool-allowlist.test.ts` asserts the Rust
|
|
20
|
+
// `js_name` set equals `AI_SESSION_POOL_METHODS`' one raw name and the Rust
|
|
21
|
+
// op table equals `AI_SESSION_OPS`.
|
|
22
|
+
/** The one capability gating the AI session lane (Q8). */
|
|
23
|
+
export const AI_SESSION_AGENT_CAPABILITY = "ai-session-agent-v1";
|
|
24
|
+
/** The one raw `#[wasm_bindgen]` export every AI verb rides (Q8 fold). */
|
|
25
|
+
export const AI_SESSION_RAW_METHOD = "aiSessionCall";
|
|
26
|
+
/**
|
|
27
|
+
* The nine verbs by pool class, as `aiSessionCall`'s `op` values.
|
|
28
|
+
* `sessionCall` runs outside the session commit lock (reads, preview,
|
|
29
|
+
* validate); `sessionCommit` is the two apply ports, which run the fence
|
|
30
|
+
* check, apply, drain and mint in one call. XB7's floors are expressed over
|
|
31
|
+
* the four read verbs of XB5 here; XB8's over the preview, validate and
|
|
32
|
+
* apply verbs. The fifth read verb, `readRuntimeSessionCalcGraphEdges`, is
|
|
33
|
+
* T-O's adjacency export (WP-DOC P4-prep-2): the projector's read, never an
|
|
34
|
+
* agent tool.
|
|
35
|
+
*/
|
|
36
|
+
export const AI_SESSION_OPS = {
|
|
37
|
+
sessionCall: [
|
|
38
|
+
"getRuntimeSessionScopeBundle",
|
|
39
|
+
"resolveRuntimeSessionReference",
|
|
40
|
+
"readRuntimeSessionScope",
|
|
41
|
+
"readRuntimeSessionScopeNeighborhood",
|
|
42
|
+
"readRuntimeSessionCalcGraphEdges",
|
|
43
|
+
"previewRuntimeSessionAiProposal",
|
|
44
|
+
"validateRuntimeSessionAiProposal"
|
|
45
|
+
],
|
|
46
|
+
sessionCommit: ["applyRuntimeSessionAiProposal", "applyRuntimeSessionAiPlan"]
|
|
47
|
+
};
|
|
48
|
+
/** Every AI verb, flat, in the order the two lists declare them. */
|
|
49
|
+
export const AI_SESSION_METHODS = [
|
|
50
|
+
...AI_SESSION_OPS.sessionCall,
|
|
51
|
+
...AI_SESSION_OPS.sessionCommit
|
|
52
|
+
];
|
|
53
|
+
/**
|
|
54
|
+
* The raw method names by pool class: the ONE raw export in BOTH classes.
|
|
55
|
+
* The caller's pool `op` ("session-call" vs "session-commit") picks the
|
|
56
|
+
* path, and the pool and the worker check that `args[0]` (the verb) belongs
|
|
57
|
+
* to that class (`isAiSessionOpInClass`), so a commit verb can never ride a
|
|
58
|
+
* session-call job outside the service's session commit lock.
|
|
59
|
+
*/
|
|
60
|
+
export const AI_SESSION_POOL_METHODS = {
|
|
61
|
+
sessionCall: [AI_SESSION_RAW_METHOD],
|
|
62
|
+
sessionCommit: [AI_SESSION_RAW_METHOD]
|
|
63
|
+
};
|
|
64
|
+
/** The raw export names the mount gate requires (the two classes, deduplicated). */
|
|
65
|
+
export const AI_SESSION_RAW_METHODS = [AI_SESSION_RAW_METHOD];
|
|
66
|
+
/** The pool class an `aiSessionCall` job must carry for its verb; `undefined` for an unknown verb. */
|
|
67
|
+
export function aiSessionOpClass(op) {
|
|
68
|
+
if (typeof op !== "string")
|
|
69
|
+
return undefined;
|
|
70
|
+
if (AI_SESSION_OPS.sessionCall.includes(op))
|
|
71
|
+
return "session-call";
|
|
72
|
+
if (AI_SESSION_OPS.sessionCommit.includes(op))
|
|
73
|
+
return "session-commit";
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The unknown-op answer is the only AI answer without a stamp: a refused
|
|
78
|
+
* verdict that names the op it could not dispatch (R-XB5-6).
|
|
79
|
+
*/
|
|
80
|
+
export function isXlsxAiUnknownOpRefusal(answer) {
|
|
81
|
+
if (typeof answer !== "object" || answer === null)
|
|
82
|
+
return false;
|
|
83
|
+
const candidate = answer;
|
|
84
|
+
return (candidate.verdict === "refused" &&
|
|
85
|
+
typeof candidate.op === "string" &&
|
|
86
|
+
typeof candidate.refusal === "object" &&
|
|
87
|
+
candidate.refusal !== null &&
|
|
88
|
+
!("sessionEpoch" in candidate));
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Thrown by the typed methods when the export answers the unknown-op DTO:
|
|
92
|
+
* the nine typed methods only ever send a declared verb, so this answer
|
|
93
|
+
* means the mounted wasm and these bindings disagree on the verb list (a
|
|
94
|
+
* stale bundle), which the service's thrown-class mapping (Q4) surfaces as a
|
|
95
|
+
* typed refusal rather than a mis-shaped result.
|
|
96
|
+
*/
|
|
97
|
+
export class XlsxAiUnknownOpRefusalError extends Error {
|
|
98
|
+
code;
|
|
99
|
+
op;
|
|
100
|
+
refusal;
|
|
101
|
+
answer;
|
|
102
|
+
constructor(answer) {
|
|
103
|
+
super(`${answer.refusal.code}: ${answer.refusal.message}`);
|
|
104
|
+
this.name = "XlsxAiUnknownOpRefusalError";
|
|
105
|
+
this.code = answer.refusal.code;
|
|
106
|
+
this.op = answer.op;
|
|
107
|
+
this.refusal = answer.refusal;
|
|
108
|
+
this.answer = answer;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Bind the nine typed methods on a validated raw module: each dispatches to
|
|
113
|
+
* `aiSessionCall(handleId, op, request)` with its own verb as `op` — the
|
|
114
|
+
* same call the pooled worker makes (R-XB5-4). The results are plain JSON
|
|
115
|
+
* values (no byte carriers); the one normalization is the unknown-op DTO,
|
|
116
|
+
* surfaced as the typed `XlsxAiUnknownOpRefusalError` (R-XB5-6).
|
|
117
|
+
*/
|
|
118
|
+
export function attachAiSessionMethods(raw) {
|
|
119
|
+
const call = (op, handleId, request) => {
|
|
120
|
+
const answer = raw.aiSessionCall(handleId, op, request);
|
|
121
|
+
if (isXlsxAiUnknownOpRefusal(answer))
|
|
122
|
+
throw new XlsxAiUnknownOpRefusalError(answer);
|
|
123
|
+
return answer;
|
|
124
|
+
};
|
|
125
|
+
return {
|
|
126
|
+
getRuntimeSessionScopeBundle(handleId, request) {
|
|
127
|
+
return call("getRuntimeSessionScopeBundle", handleId, request);
|
|
128
|
+
},
|
|
129
|
+
resolveRuntimeSessionReference(handleId, request) {
|
|
130
|
+
return call("resolveRuntimeSessionReference", handleId, request);
|
|
131
|
+
},
|
|
132
|
+
readRuntimeSessionScope(handleId, request) {
|
|
133
|
+
return call("readRuntimeSessionScope", handleId, request);
|
|
134
|
+
},
|
|
135
|
+
readRuntimeSessionScopeNeighborhood(handleId, request) {
|
|
136
|
+
return call("readRuntimeSessionScopeNeighborhood", handleId, request);
|
|
137
|
+
},
|
|
138
|
+
readRuntimeSessionCalcGraphEdges(handleId, request) {
|
|
139
|
+
return call("readRuntimeSessionCalcGraphEdges", handleId, request);
|
|
140
|
+
},
|
|
141
|
+
previewRuntimeSessionAiProposal(handleId, request) {
|
|
142
|
+
return call("previewRuntimeSessionAiProposal", handleId, request);
|
|
143
|
+
},
|
|
144
|
+
validateRuntimeSessionAiProposal(handleId, request) {
|
|
145
|
+
return call("validateRuntimeSessionAiProposal", handleId, request);
|
|
146
|
+
},
|
|
147
|
+
applyRuntimeSessionAiProposal(handleId, request) {
|
|
148
|
+
return call("applyRuntimeSessionAiProposal", handleId, request);
|
|
149
|
+
},
|
|
150
|
+
applyRuntimeSessionAiPlan(handleId, request) {
|
|
151
|
+
return call("applyRuntimeSessionAiPlan", handleId, request);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}
|