@memberjunction/ai-agents 6.2.2 → 6.3.0-edge.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 +29 -6
- package/dist/AgentContextAssembler.d.ts +127 -0
- package/dist/AgentContextAssembler.d.ts.map +1 -0
- package/dist/AgentContextAssembler.js +482 -0
- package/dist/AgentContextAssembler.js.map +1 -0
- package/dist/AgentDataPreloader.d.ts +14 -3
- package/dist/AgentDataPreloader.d.ts.map +1 -1
- package/dist/AgentDataPreloader.js +147 -22
- package/dist/AgentDataPreloader.js.map +1 -1
- package/dist/AgentDecisionService.d.ts +10 -1
- package/dist/AgentDecisionService.d.ts.map +1 -1
- package/dist/AgentDecisionService.js +28 -13
- package/dist/AgentDecisionService.js.map +1 -1
- package/dist/AgentFeedbackCoordinator.d.ts +169 -0
- package/dist/AgentFeedbackCoordinator.d.ts.map +1 -0
- package/dist/AgentFeedbackCoordinator.js +593 -0
- package/dist/AgentFeedbackCoordinator.js.map +1 -0
- package/dist/AgentRunner.d.ts +57 -15
- package/dist/AgentRunner.d.ts.map +1 -1
- package/dist/AgentRunner.js +692 -101
- package/dist/AgentRunner.js.map +1 -1
- package/dist/AgentStepDispatcher.d.ts +211 -0
- package/dist/AgentStepDispatcher.d.ts.map +1 -0
- package/dist/AgentStepDispatcher.js +729 -0
- package/dist/AgentStepDispatcher.js.map +1 -0
- package/dist/AgentTreeBudgetTracker.d.ts +163 -0
- package/dist/AgentTreeBudgetTracker.d.ts.map +1 -0
- package/dist/AgentTreeBudgetTracker.js +415 -0
- package/dist/AgentTreeBudgetTracker.js.map +1 -0
- package/dist/AgentWakeTriggerService.d.ts +41 -1
- package/dist/AgentWakeTriggerService.d.ts.map +1 -1
- package/dist/AgentWakeTriggerService.js +154 -8
- package/dist/AgentWakeTriggerService.js.map +1 -1
- package/dist/ArtifactToolManager.d.ts +134 -39
- package/dist/ArtifactToolManager.d.ts.map +1 -1
- package/dist/ArtifactToolManager.js +2761 -321
- package/dist/ArtifactToolManager.js.map +1 -1
- package/dist/GovernedArtifactService.d.ts +367 -0
- package/dist/GovernedArtifactService.d.ts.map +1 -0
- package/dist/GovernedArtifactService.js +2569 -0
- package/dist/GovernedArtifactService.js.map +1 -0
- package/dist/MJAIAgentRequestEntityServer.d.ts +32 -1
- package/dist/MJAIAgentRequestEntityServer.d.ts.map +1 -1
- package/dist/MJAIAgentRequestEntityServer.js +105 -3
- package/dist/MJAIAgentRequestEntityServer.js.map +1 -1
- package/dist/SkillMarkdownConverter.d.ts +1 -1
- package/dist/SkillMarkdownConverter.d.ts.map +1 -1
- package/dist/SkillMarkdownConverter.js +8 -6
- package/dist/SkillMarkdownConverter.js.map +1 -1
- package/dist/agent-context-injector.d.ts +2 -25
- package/dist/agent-context-injector.d.ts.map +1 -1
- package/dist/agent-context-injector.js +38 -153
- package/dist/agent-context-injector.js.map +1 -1
- package/dist/agent-instance.d.ts +28 -0
- package/dist/agent-instance.d.ts.map +1 -0
- package/dist/agent-instance.js +39 -0
- package/dist/agent-instance.js.map +1 -0
- package/dist/agent-memory-context-builder.d.ts.map +1 -1
- package/dist/agent-memory-context-builder.js +46 -42
- package/dist/agent-memory-context-builder.js.map +1 -1
- package/dist/agent-pre-execution-rag.d.ts +5 -0
- package/dist/agent-pre-execution-rag.d.ts.map +1 -1
- package/dist/agent-pre-execution-rag.js +10 -0
- package/dist/agent-pre-execution-rag.js.map +1 -1
- package/dist/agent-run-watchdog.d.ts +38 -6
- package/dist/agent-run-watchdog.d.ts.map +1 -1
- package/dist/agent-run-watchdog.js +75 -13
- package/dist/agent-run-watchdog.js.map +1 -1
- package/dist/agent-types/flow-agent-type.d.ts +6 -1
- package/dist/agent-types/flow-agent-type.d.ts.map +1 -1
- package/dist/agent-types/flow-agent-type.js +30 -7
- package/dist/agent-types/flow-agent-type.js.map +1 -1
- package/dist/agent-types/loop-agent-prompt-params.d.ts +18 -0
- package/dist/agent-types/loop-agent-prompt-params.d.ts.map +1 -1
- package/dist/agent-types/loop-agent-prompt-params.js +2 -0
- package/dist/agent-types/loop-agent-prompt-params.js.map +1 -1
- package/dist/agent-types/loop-agent-type.d.ts +4 -0
- package/dist/agent-types/loop-agent-type.d.ts.map +1 -1
- package/dist/agent-types/loop-agent-type.js +29 -0
- package/dist/agent-types/loop-agent-type.js.map +1 -1
- package/dist/artifact-presence-locator.d.ts +132 -0
- package/dist/artifact-presence-locator.d.ts.map +1 -0
- package/dist/artifact-presence-locator.js +472 -0
- package/dist/artifact-presence-locator.js.map +1 -0
- package/dist/artifact-tools/CSVToolLibrary.d.ts +2 -2
- package/dist/artifact-tools/CSVToolLibrary.d.ts.map +1 -1
- package/dist/artifact-tools/CSVToolLibrary.js +41 -14
- package/dist/artifact-tools/CSVToolLibrary.js.map +1 -1
- package/dist/artifact-tools/DataSnapshotToolLibrary.d.ts +2 -2
- package/dist/artifact-tools/DataSnapshotToolLibrary.d.ts.map +1 -1
- package/dist/artifact-tools/DataSnapshotToolLibrary.js +53 -21
- package/dist/artifact-tools/DataSnapshotToolLibrary.js.map +1 -1
- package/dist/artifact-tools/DocumentToolLibrary.d.ts +101 -0
- package/dist/artifact-tools/DocumentToolLibrary.d.ts.map +1 -0
- package/dist/artifact-tools/DocumentToolLibrary.js +1846 -0
- package/dist/artifact-tools/DocumentToolLibrary.js.map +1 -0
- package/dist/artifact-tools/DocxToolLibrary.d.ts +2 -4
- package/dist/artifact-tools/DocxToolLibrary.d.ts.map +1 -1
- package/dist/artifact-tools/DocxToolLibrary.js +42 -30
- package/dist/artifact-tools/DocxToolLibrary.js.map +1 -1
- package/dist/artifact-tools/ExcelToolLibrary.d.ts +2 -3
- package/dist/artifact-tools/ExcelToolLibrary.d.ts.map +1 -1
- package/dist/artifact-tools/ExcelToolLibrary.js +105 -49
- package/dist/artifact-tools/ExcelToolLibrary.js.map +1 -1
- package/dist/artifact-tools/GenericBinaryToolLibrary.d.ts +2 -2
- package/dist/artifact-tools/GenericBinaryToolLibrary.d.ts.map +1 -1
- package/dist/artifact-tools/GenericBinaryToolLibrary.js +3 -2
- package/dist/artifact-tools/GenericBinaryToolLibrary.js.map +1 -1
- package/dist/artifact-tools/JSONToolLibrary.d.ts +4 -4
- package/dist/artifact-tools/JSONToolLibrary.d.ts.map +1 -1
- package/dist/artifact-tools/JSONToolLibrary.js +32 -11
- package/dist/artifact-tools/JSONToolLibrary.js.map +1 -1
- package/dist/artifact-tools/PDFToolLibrary.d.ts +27 -3
- package/dist/artifact-tools/PDFToolLibrary.d.ts.map +1 -1
- package/dist/artifact-tools/PDFToolLibrary.js +36 -21
- package/dist/artifact-tools/PDFToolLibrary.js.map +1 -1
- package/dist/artifact-tools/SearchResultSetToolLibrary.d.ts +2 -2
- package/dist/artifact-tools/SearchResultSetToolLibrary.d.ts.map +1 -1
- package/dist/artifact-tools/SearchResultSetToolLibrary.js +83 -24
- package/dist/artifact-tools/SearchResultSetToolLibrary.js.map +1 -1
- package/dist/artifact-tools/SlideDeckToolLibrary.d.ts +50 -0
- package/dist/artifact-tools/SlideDeckToolLibrary.d.ts.map +1 -0
- package/dist/artifact-tools/SlideDeckToolLibrary.js +1617 -0
- package/dist/artifact-tools/SlideDeckToolLibrary.js.map +1 -0
- package/dist/artifact-tools/SpreadsheetToolLibrary.d.ts +87 -0
- package/dist/artifact-tools/SpreadsheetToolLibrary.d.ts.map +1 -0
- package/dist/artifact-tools/SpreadsheetToolLibrary.js +3351 -0
- package/dist/artifact-tools/SpreadsheetToolLibrary.js.map +1 -0
- package/dist/artifact-tools/TextToolLibrary.d.ts +3 -3
- package/dist/artifact-tools/TextToolLibrary.d.ts.map +1 -1
- package/dist/artifact-tools/TextToolLibrary.js +34 -24
- package/dist/artifact-tools/TextToolLibrary.js.map +1 -1
- package/dist/artifact-tools/WhiteboardToolLibrary.d.ts +69 -0
- package/dist/artifact-tools/WhiteboardToolLibrary.d.ts.map +1 -0
- package/dist/artifact-tools/WhiteboardToolLibrary.js +555 -0
- package/dist/artifact-tools/WhiteboardToolLibrary.js.map +1 -0
- package/dist/artifact-tools/artifact-comment-suggestion-helper.d.ts +98 -0
- package/dist/artifact-tools/artifact-comment-suggestion-helper.d.ts.map +1 -0
- package/dist/artifact-tools/artifact-comment-suggestion-helper.js +851 -0
- package/dist/artifact-tools/artifact-comment-suggestion-helper.js.map +1 -0
- package/dist/artifact-tools/artifact-tool-helpers.d.ts +21 -0
- package/dist/artifact-tools/artifact-tool-helpers.d.ts.map +1 -0
- package/dist/artifact-tools/artifact-tool-helpers.js +74 -0
- package/dist/artifact-tools/artifact-tool-helpers.js.map +1 -0
- package/dist/artifact-tools/grepHelper.d.ts +27 -0
- package/dist/artifact-tools/grepHelper.d.ts.map +1 -0
- package/dist/artifact-tools/grepHelper.js +229 -0
- package/dist/artifact-tools/grepHelper.js.map +1 -0
- package/dist/artifact-tools/node-vm-safe-regex.d.ts +10 -0
- package/dist/artifact-tools/node-vm-safe-regex.d.ts.map +1 -0
- package/dist/artifact-tools/node-vm-safe-regex.js +148 -0
- package/dist/artifact-tools/node-vm-safe-regex.js.map +1 -0
- package/dist/base-agent.d.ts +151 -137
- package/dist/base-agent.d.ts.map +1 -1
- package/dist/base-agent.js +727 -1550
- package/dist/base-agent.js.map +1 -1
- package/dist/catalog-narrowing.d.ts +112 -5
- package/dist/catalog-narrowing.d.ts.map +1 -1
- package/dist/catalog-narrowing.js +181 -6
- package/dist/catalog-narrowing.js.map +1 -1
- package/dist/decision-discovery.d.ts +42 -15
- package/dist/decision-discovery.d.ts.map +1 -1
- package/dist/decision-discovery.js +90 -20
- package/dist/decision-discovery.js.map +1 -1
- package/dist/index.d.ts +17 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -3
- package/dist/index.js.map +1 -1
- package/dist/memory-decision-uses.d.ts +206 -0
- package/dist/memory-decision-uses.d.ts.map +1 -0
- package/dist/memory-decision-uses.js +259 -0
- package/dist/memory-decision-uses.js.map +1 -0
- package/dist/memory-manager-agent.d.ts +66 -6
- package/dist/memory-manager-agent.d.ts.map +1 -1
- package/dist/memory-manager-agent.js +184 -31
- package/dist/memory-manager-agent.js.map +1 -1
- package/dist/memory-note-gate.d.ts +12 -9
- package/dist/memory-note-gate.d.ts.map +1 -1
- package/dist/memory-note-gate.js +16 -11
- package/dist/memory-note-gate.js.map +1 -1
- package/dist/native-tools/control-tools.d.ts +8 -1
- package/dist/native-tools/control-tools.d.ts.map +1 -1
- package/dist/native-tools/control-tools.js +38 -5
- package/dist/native-tools/control-tools.js.map +1 -1
- package/dist/native-tools/framework-tools.d.ts +3 -3
- package/dist/native-tools/framework-tools.d.ts.map +1 -1
- package/dist/native-tools/framework-tools.js +20 -8
- package/dist/native-tools/framework-tools.js.map +1 -1
- package/dist/pipeline/operators.d.ts.map +1 -1
- package/dist/pipeline/operators.js +1 -1
- package/dist/pipeline/operators.js.map +1 -1
- package/dist/pipeline/pipeline-executor.d.ts +29 -1
- package/dist/pipeline/pipeline-executor.d.ts.map +1 -1
- package/dist/pipeline/pipeline-executor.js +159 -2
- package/dist/pipeline/pipeline-executor.js.map +1 -1
- package/dist/pipeline/pipeline.types.d.ts +19 -1
- package/dist/pipeline/pipeline.types.d.ts.map +1 -1
- package/dist/pipeline/template.d.ts +16 -0
- package/dist/pipeline/template.d.ts.map +1 -1
- package/dist/pipeline/template.js +55 -6
- package/dist/pipeline/template.js.map +1 -1
- package/dist/realtime/artifact-workspace-channel-server.d.ts +27 -0
- package/dist/realtime/artifact-workspace-channel-server.d.ts.map +1 -0
- package/dist/realtime/artifact-workspace-channel-server.js +43 -0
- package/dist/realtime/artifact-workspace-channel-server.js.map +1 -0
- package/dist/realtime/bridge-realtime-session-factory.d.ts +2 -2
- package/dist/realtime/bridge-realtime-session-factory.d.ts.map +1 -1
- package/dist/realtime/bridge-realtime-session-factory.js +7 -56
- package/dist/realtime/bridge-realtime-session-factory.js.map +1 -1
- package/dist/realtime/bridge-room-transcript-sink.d.ts.map +1 -1
- package/dist/realtime/bridge-room-transcript-sink.js +28 -1
- package/dist/realtime/bridge-room-transcript-sink.js.map +1 -1
- package/dist/realtime/media-channel-server.js +1 -1
- package/dist/realtime/media-channel-server.js.map +1 -1
- package/dist/realtime/realtime-artifact-helpers.d.ts +37 -0
- package/dist/realtime/realtime-artifact-helpers.d.ts.map +1 -0
- package/dist/realtime/realtime-artifact-helpers.js +150 -0
- package/dist/realtime/realtime-artifact-helpers.js.map +1 -0
- package/dist/realtime/realtime-client-session-service.d.ts +209 -19
- package/dist/realtime/realtime-client-session-service.d.ts.map +1 -1
- package/dist/realtime/realtime-client-session-service.js +670 -41
- package/dist/realtime/realtime-client-session-service.js.map +1 -1
- package/dist/realtime/realtime-coagent-config.d.ts +26 -9
- package/dist/realtime/realtime-coagent-config.d.ts.map +1 -1
- package/dist/realtime/realtime-coagent-config.js +47 -60
- package/dist/realtime/realtime-coagent-config.js.map +1 -1
- package/dist/realtime/realtime-delegation-narrator.js +1 -1
- package/dist/realtime/realtime-delegation-narrator.js.map +1 -1
- package/dist/realtime/realtime-moderator-decision.d.ts +86 -0
- package/dist/realtime/realtime-moderator-decision.d.ts.map +1 -0
- package/dist/realtime/realtime-moderator-decision.js +131 -0
- package/dist/realtime/realtime-moderator-decision.js.map +1 -0
- package/dist/realtime/realtime-session-runner.d.ts +2 -0
- package/dist/realtime/realtime-session-runner.d.ts.map +1 -1
- package/dist/realtime/realtime-session-runner.js +24 -3
- package/dist/realtime/realtime-session-runner.js.map +1 -1
- package/dist/realtime/realtime-tool-broker.d.ts +6 -0
- package/dist/realtime/realtime-tool-broker.d.ts.map +1 -1
- package/dist/realtime/realtime-tool-broker.js +4 -2
- package/dist/realtime/realtime-tool-broker.js.map +1 -1
- package/dist/realtime/realtime-turn-moderator.d.ts +20 -0
- package/dist/realtime/realtime-turn-moderator.d.ts.map +1 -1
- package/dist/realtime/realtime-turn-moderator.js +63 -8
- package/dist/realtime/realtime-turn-moderator.js.map +1 -1
- package/dist/repeated-failing-step.d.ts +50 -0
- package/dist/repeated-failing-step.d.ts.map +1 -0
- package/dist/repeated-failing-step.js +130 -0
- package/dist/repeated-failing-step.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +20 -20
|
@@ -0,0 +1,1617 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
8
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
9
|
+
import { BaseArtifactToolLibrary, ResolveEmbeddedArtifactId, ResolveEmbeddedVersionId } from '@memberjunction/ai-core-plus';
|
|
10
|
+
import { DocumentLiveBlockEngine, SlideDeckEngine } from '@memberjunction/core-entities';
|
|
11
|
+
import { ExecuteArtifactCommentTool, ExecuteListSuggestionsTool, ExecuteProposeSuggestionTool, ExecuteReviewSuggestionTool, GetSharedCommentAndSuggestionToolDefinitions, ParseSuggestionAnchor, ValidateEmbeddedArtifactAccess } from './artifact-comment-suggestion-helper.js';
|
|
12
|
+
/**
|
|
13
|
+
* Server-side and agent tool library for `Presentation` (`Slide Deck`) artifacts (`MJ Slides`, § 3.6 & § 5).
|
|
14
|
+
*
|
|
15
|
+
* Registered under `'SlideDeckToolLibrary'` via `@RegisterClass(BaseArtifactToolLibrary, 'SlideDeckToolLibrary')`
|
|
16
|
+
* to match `metadata/artifact-types/.artifact-types.json`.
|
|
17
|
+
*
|
|
18
|
+
* Supports:
|
|
19
|
+
* - Deck & slide inspection (`read_deck`, `get_deck_outline`, `get_slide`),
|
|
20
|
+
* - Targeted slide & region mutations (`add_slide`, `update_slide`, `delete_slide`, `reorder_slides`,
|
|
21
|
+
* `upsert_slide_element`, `update_slide_region`, `delete_slide_element`, `update_speaker_notes`),
|
|
22
|
+
* - Brand theme & seed application (`apply_theme`, `Accept #4`), and
|
|
23
|
+
* - Document-to-Deck synthesis (`generate_deck_from_markdown`, *"make a deck from this doc"*, `§ 5.2`).
|
|
24
|
+
*/
|
|
25
|
+
let SlideDeckToolLibrary = class SlideDeckToolLibrary extends BaseArtifactToolLibrary {
|
|
26
|
+
getSubclassToolList() {
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
name: 'read_deck',
|
|
30
|
+
description: 'Returns the full structured slide deck outline, active theme, master slide configuration, and per-slide metadata (slideId, slideNumber, layout, title, regionIds, embeddedBlockIds).',
|
|
31
|
+
inputSchema: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
properties: {
|
|
34
|
+
includeFullSlides: {
|
|
35
|
+
type: 'boolean',
|
|
36
|
+
description: 'When true, includes the full regions and speakerNotes for every slide.'
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'get_deck_outline',
|
|
43
|
+
description: 'Alias for read_deck: returns the slide deck outline summary, theme metadata, and slide list.',
|
|
44
|
+
inputSchema: {
|
|
45
|
+
type: 'object',
|
|
46
|
+
properties: {}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'get_slide',
|
|
51
|
+
description: 'Returns the full SlideSpec (layout, title, subtitle, regions, embedded MJ blocks, and speakerNotes) for a specific slide by slideId or 1-based slideNumber.',
|
|
52
|
+
inputSchema: {
|
|
53
|
+
type: 'object',
|
|
54
|
+
properties: {
|
|
55
|
+
slideId: { type: 'string', description: 'Stable SlideID of the slide to inspect.' },
|
|
56
|
+
slideNumber: { type: 'number', description: '1-based slide number if slideId is not provided.' }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'add_slide',
|
|
62
|
+
description: 'Adds a new slide to the presentation with a canonical layout (Title, SectionHeader, TitleAndBody, TwoColumn, Comparison, LiveDataSlide, ChartAndText, BigNumber, Quote, FullBleedImage, Blank).',
|
|
63
|
+
inputSchema: {
|
|
64
|
+
type: 'object',
|
|
65
|
+
properties: {
|
|
66
|
+
slideId: { type: 'string', description: 'Optional explicit SlideID.' },
|
|
67
|
+
layout: {
|
|
68
|
+
type: 'string',
|
|
69
|
+
description: 'Canonical slide layout (Title, SectionHeader, TitleAndBody, TwoColumn, Comparison, LiveDataSlide, ChartAndText, BigNumber, Quote, FullBleedImage, Blank).'
|
|
70
|
+
},
|
|
71
|
+
title: { type: 'string', description: 'Slide title.' },
|
|
72
|
+
subtitle: { type: 'string', description: 'Optional slide subtitle.' },
|
|
73
|
+
markdownContent: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
description: 'Optional initial Markdown body for the primary region.'
|
|
76
|
+
},
|
|
77
|
+
speakerNotes: { type: 'string', description: 'Optional speaker notes for the slide.' },
|
|
78
|
+
insertAtIndex: {
|
|
79
|
+
type: 'number',
|
|
80
|
+
description: 'Optional 0-based index where the slide should be inserted.'
|
|
81
|
+
},
|
|
82
|
+
expectedRevisionHash: {
|
|
83
|
+
type: 'string',
|
|
84
|
+
description: 'Optional SHA-256 revision hash for optimistic concurrency protection.'
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
required: ['title']
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'update_slide',
|
|
92
|
+
description: 'Updates a single slide (title, subtitle, layout, speakerNotes, transition, hidden, or primary body) by slideId without touching any other slide in the deck (Accept #3).',
|
|
93
|
+
inputSchema: {
|
|
94
|
+
type: 'object',
|
|
95
|
+
properties: {
|
|
96
|
+
slideId: { type: 'string', description: 'Target SlideID to update.' },
|
|
97
|
+
title: { type: 'string', description: 'New slide title.' },
|
|
98
|
+
subtitle: { type: 'string', description: 'New slide subtitle.' },
|
|
99
|
+
layout: { type: 'string', description: 'New canonical layout.' },
|
|
100
|
+
markdownContent: {
|
|
101
|
+
type: 'string',
|
|
102
|
+
description: 'Optional updated Markdown content for the primary region of this slide.'
|
|
103
|
+
},
|
|
104
|
+
speakerNotes: { type: 'string', description: 'Updated speaker notes.' },
|
|
105
|
+
transition: { type: 'string', description: 'Slide transition (none, fade, slide).' },
|
|
106
|
+
hidden: { type: 'boolean', description: 'Whether the slide is hidden during presentation.' },
|
|
107
|
+
expectedRevisionHash: {
|
|
108
|
+
type: 'string',
|
|
109
|
+
description: 'Optional SHA-256 revision hash for optimistic concurrency protection.'
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
required: ['slideId']
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: 'delete_slide',
|
|
117
|
+
description: 'Deletes a slide by slideId (preserving at least 1 slide in the presentation).',
|
|
118
|
+
inputSchema: {
|
|
119
|
+
type: 'object',
|
|
120
|
+
properties: {
|
|
121
|
+
slideId: { type: 'string', description: 'Target SlideID to delete.' },
|
|
122
|
+
expectedRevisionHash: {
|
|
123
|
+
type: 'string',
|
|
124
|
+
description: 'Optional SHA-256 revision hash for optimistic concurrency protection.'
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
required: ['slideId']
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: 'duplicate_slide',
|
|
132
|
+
description: 'Duplicates an existing slide by slideId (generating unique slide and block IDs) and inserts it right after the source slide.',
|
|
133
|
+
inputSchema: {
|
|
134
|
+
type: 'object',
|
|
135
|
+
properties: {
|
|
136
|
+
slideId: { type: 'string', description: 'Source SlideID to duplicate.' },
|
|
137
|
+
title: { type: 'string', description: 'Optional override title for the duplicated slide.' },
|
|
138
|
+
expectedRevisionHash: {
|
|
139
|
+
type: 'string',
|
|
140
|
+
description: 'Optional SHA-256 revision hash for optimistic concurrency protection.'
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
required: ['slideId']
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: 'reorder_slides',
|
|
148
|
+
description: 'Reorders the presentation slides according to an ordered array of slideIds without losing any unmentioned slides (Accept #1).',
|
|
149
|
+
inputSchema: {
|
|
150
|
+
type: 'object',
|
|
151
|
+
properties: {
|
|
152
|
+
slideIds: {
|
|
153
|
+
type: 'array',
|
|
154
|
+
items: { type: 'string' },
|
|
155
|
+
description: 'Ordered list of SlideIDs.'
|
|
156
|
+
},
|
|
157
|
+
expectedRevisionHash: {
|
|
158
|
+
type: 'string',
|
|
159
|
+
description: 'Optional SHA-256 revision hash for optimistic concurrency protection.'
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
required: ['slideIds']
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: 'upsert_slide_element',
|
|
167
|
+
description: 'Updates or inserts a structured region/element on a specific slide (rich-text, table, callout, image, big-number, quote, or mj-block including Live EntityView/SavedQuery and inline OLE Whiteboard Artifact blocks) without modifying any other slide.',
|
|
168
|
+
inputSchema: {
|
|
169
|
+
type: 'object',
|
|
170
|
+
properties: {
|
|
171
|
+
slideId: { type: 'string', description: 'Target SlideID.' },
|
|
172
|
+
regionId: {
|
|
173
|
+
type: 'string',
|
|
174
|
+
description: 'Target RegionID within the slide (e.g., "main", "left", "right", "data", "narrative").'
|
|
175
|
+
},
|
|
176
|
+
label: { type: 'string', description: 'Optional region label.' },
|
|
177
|
+
kind: {
|
|
178
|
+
type: 'string',
|
|
179
|
+
description: 'Region kind (rich-text, mj-block, callout, table, image, big-number, quote).'
|
|
180
|
+
},
|
|
181
|
+
markdownContent: { type: 'string', description: 'Markdown content for this region.' },
|
|
182
|
+
imageUrl: { type: 'string', description: 'Image URL or data URI when kind is image.' },
|
|
183
|
+
imageAlt: { type: 'string', description: 'Accessible alt text / caption when kind is image.' },
|
|
184
|
+
bigNumberValue: { type: 'string', description: 'Headline metric value when kind is big-number.' },
|
|
185
|
+
bigNumberLabel: { type: 'string', description: 'Metric label when kind is big-number.' },
|
|
186
|
+
bigNumberDelta: { type: 'string', description: 'Metric delta when kind is big-number.' },
|
|
187
|
+
quoteAttribution: { type: 'string', description: 'Attribution when kind is quote.' },
|
|
188
|
+
calloutTone: {
|
|
189
|
+
type: 'string',
|
|
190
|
+
description: 'Callout tone (NOTE, TIP, IMPORTANT, WARNING, CAUTION).'
|
|
191
|
+
},
|
|
192
|
+
mjBlock: {
|
|
193
|
+
type: 'object',
|
|
194
|
+
description: 'Optional MJ block descriptor (Kind, Mode, Title, EntityName, ViewID, ViewName, ExtraFilter, Fields, DisplayMode, ChartType, MaxRows, QueryID, QueryName, Parameters, DashboardID, ComponentID, ArtifactID, ArtifactType, VersionID, EmbedMode, SheetID, SheetName, SheetRange/Range, SheetChartID/ChartID).'
|
|
195
|
+
},
|
|
196
|
+
expectedRevisionHash: {
|
|
197
|
+
type: 'string',
|
|
198
|
+
description: 'Optional SHA-256 revision hash for optimistic concurrency protection.'
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
required: ['slideId', 'regionId']
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: 'update_slide_region',
|
|
206
|
+
description: 'Alias for upsert_slide_element: updates a single region on a target slide by slideId and regionId.',
|
|
207
|
+
inputSchema: {
|
|
208
|
+
type: 'object',
|
|
209
|
+
properties: {
|
|
210
|
+
slideId: { type: 'string', description: 'Target SlideID.' },
|
|
211
|
+
regionId: { type: 'string', description: 'Target RegionID.' },
|
|
212
|
+
label: { type: 'string', description: 'Optional region label.' },
|
|
213
|
+
kind: { type: 'string', description: 'Region kind (rich-text, mj-block, callout, table, image, big-number, quote).' },
|
|
214
|
+
markdownContent: { type: 'string', description: 'Replacement Markdown content.' },
|
|
215
|
+
imageUrl: { type: 'string', description: 'Image URL or data URI when kind is image.' },
|
|
216
|
+
imageAlt: { type: 'string', description: 'Accessible alt text / caption when kind is image.' },
|
|
217
|
+
bigNumberValue: { type: 'string', description: 'Headline metric value when kind is big-number.' },
|
|
218
|
+
bigNumberLabel: { type: 'string', description: 'Metric label when kind is big-number.' },
|
|
219
|
+
bigNumberDelta: { type: 'string', description: 'Metric delta when kind is big-number.' },
|
|
220
|
+
quoteAttribution: { type: 'string', description: 'Attribution when kind is quote.' },
|
|
221
|
+
calloutTone: { type: 'string', description: 'Callout tone (NOTE, TIP, IMPORTANT, WARNING, CAUTION).' },
|
|
222
|
+
mjBlock: { type: 'object', description: 'Optional MJ block descriptor.' },
|
|
223
|
+
expectedRevisionHash: {
|
|
224
|
+
type: 'string',
|
|
225
|
+
description: 'Optional SHA-256 revision hash for optimistic concurrency protection.'
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
required: ['slideId', 'regionId']
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: 'delete_slide_element',
|
|
233
|
+
description: 'Removes a secondary region/element from a slide or clears its content if it is the sole region.',
|
|
234
|
+
inputSchema: {
|
|
235
|
+
type: 'object',
|
|
236
|
+
properties: {
|
|
237
|
+
slideId: { type: 'string', description: 'Target SlideID.' },
|
|
238
|
+
regionId: { type: 'string', description: 'Target RegionID to remove or clear.' },
|
|
239
|
+
expectedRevisionHash: {
|
|
240
|
+
type: 'string',
|
|
241
|
+
description: 'Optional SHA-256 revision hash for optimistic concurrency protection.'
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
required: ['slideId', 'regionId']
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: 'update_speaker_notes',
|
|
249
|
+
description: 'Updates the presenter speaker notes on a target slide by slideId.',
|
|
250
|
+
inputSchema: {
|
|
251
|
+
type: 'object',
|
|
252
|
+
properties: {
|
|
253
|
+
slideId: { type: 'string', description: 'Target SlideID.' },
|
|
254
|
+
speakerNotes: { type: 'string', description: 'Updated speaker notes text.' },
|
|
255
|
+
expectedRevisionHash: {
|
|
256
|
+
type: 'string',
|
|
257
|
+
description: 'Optional SHA-256 revision hash for optimistic concurrency protection.'
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
required: ['slideId', 'speakerNotes']
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: 'update_deck_metadata',
|
|
265
|
+
description: 'Updates top-level presentation metadata (title, subtitle, aspectRatio) and master slide chrome settings.',
|
|
266
|
+
inputSchema: {
|
|
267
|
+
type: 'object',
|
|
268
|
+
properties: {
|
|
269
|
+
title: { type: 'string', description: 'Presentation title.' },
|
|
270
|
+
subtitle: { type: 'string', description: 'Presentation subtitle.' },
|
|
271
|
+
aspectRatio: {
|
|
272
|
+
type: 'string',
|
|
273
|
+
enum: ['16:9', '4:3'],
|
|
274
|
+
description: 'Presentation canvas aspect ratio.'
|
|
275
|
+
},
|
|
276
|
+
headerText: { type: 'string', description: 'Master header text.' },
|
|
277
|
+
footerText: { type: 'string', description: 'Master footer text.' },
|
|
278
|
+
showSlideNumbers: { type: 'boolean', description: 'Whether slide numbers appear in the footer.' },
|
|
279
|
+
showDate: { type: 'boolean', description: 'Whether the date appears in the footer.' },
|
|
280
|
+
organizationName: { type: 'string', description: 'Organization or presenter name in master chrome.' },
|
|
281
|
+
logoUrl: { type: 'string', description: 'Optional brand logo URL.' },
|
|
282
|
+
expectedRevisionHash: {
|
|
283
|
+
type: 'string',
|
|
284
|
+
description: 'Optional SHA-256 revision hash for optimistic concurrency protection.'
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
name: 'apply_theme',
|
|
291
|
+
description: 'Applies a preset theme (mj-default, executive-slate, emerald-growth, crimson-bold) or derives a new theme from organization brand color seeds (Accept #4).',
|
|
292
|
+
inputSchema: {
|
|
293
|
+
type: 'object',
|
|
294
|
+
properties: {
|
|
295
|
+
themeId: {
|
|
296
|
+
type: 'string',
|
|
297
|
+
description: 'Preset ThemeID (mj-default, executive-slate, emerald-growth, crimson-bold).'
|
|
298
|
+
},
|
|
299
|
+
organizationName: { type: 'string', description: 'Optional organization name for brand seeds.' },
|
|
300
|
+
primaryColor: { type: 'string', description: 'Organization brand primary hex color.' },
|
|
301
|
+
accentColor: { type: 'string', description: 'Organization brand accent hex color.' },
|
|
302
|
+
backgroundColor: { type: 'string', description: 'Slide stage background hex color.' },
|
|
303
|
+
surfaceColor: { type: 'string', description: 'Card/region surface hex color.' },
|
|
304
|
+
textColor: { type: 'string', description: 'Primary text hex color.' },
|
|
305
|
+
expectedRevisionHash: {
|
|
306
|
+
type: 'string',
|
|
307
|
+
description: 'Optional SHA-256 revision hash for optimistic concurrency protection.'
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
name: 'generate_deck_from_markdown',
|
|
314
|
+
description: 'Converts a Markdown document (headings, lists, tables, callouts, and embedded :::mj-block directives including Live MJ Blocks and OLE Whiteboards) into a structured SlideDeckSpec ("make a deck from this doc", § 5.2).',
|
|
315
|
+
inputSchema: {
|
|
316
|
+
type: 'object',
|
|
317
|
+
properties: {
|
|
318
|
+
markdown: { type: 'string', description: 'Source Markdown document text.' },
|
|
319
|
+
deckTitle: { type: 'string', description: 'Optional title for the generated presentation.' },
|
|
320
|
+
themeId: { type: 'string', description: 'Optional theme preset ID.' },
|
|
321
|
+
expectedRevisionHash: {
|
|
322
|
+
type: 'string',
|
|
323
|
+
description: 'Optional SHA-256 revision hash for optimistic concurrency protection.'
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
required: ['markdown']
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
name: 'duplicate_region',
|
|
331
|
+
description: 'Duplicates an existing region on a slide with a new unique regionId.',
|
|
332
|
+
inputSchema: {
|
|
333
|
+
type: 'object',
|
|
334
|
+
properties: {
|
|
335
|
+
slideId: { type: 'string', description: 'Target SlideID.' },
|
|
336
|
+
regionId: { type: 'string', description: 'Source RegionID to duplicate.' },
|
|
337
|
+
newRegionId: { type: 'string', description: 'Optional explicit ID for the duplicated region.' },
|
|
338
|
+
expectedRevisionHash: { type: 'string', description: 'Optional SHA-256 revision hash for optimistic concurrency protection.' }
|
|
339
|
+
},
|
|
340
|
+
required: ['slideId', 'regionId']
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
name: 'align_distribute_regions',
|
|
345
|
+
description: 'Reorders or redistributes regions within a slide cleanly while respecting lock permissions.',
|
|
346
|
+
inputSchema: {
|
|
347
|
+
type: 'object',
|
|
348
|
+
properties: {
|
|
349
|
+
slideId: { type: 'string', description: 'Target SlideID.' },
|
|
350
|
+
orderedRegionIds: {
|
|
351
|
+
type: 'array',
|
|
352
|
+
items: { type: 'string' },
|
|
353
|
+
description: 'Desired RegionID order; unmentioned regions stay appended in relative order.'
|
|
354
|
+
},
|
|
355
|
+
expectedRevisionHash: { type: 'string', description: 'Optional SHA-256 revision hash for optimistic concurrency protection.' }
|
|
356
|
+
},
|
|
357
|
+
required: ['slideId', 'orderedRegionIds']
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
{
|
|
361
|
+
name: 'upsert_speaker_notes',
|
|
362
|
+
description: 'Sets or appends presenter speaker notes on a slide.',
|
|
363
|
+
inputSchema: {
|
|
364
|
+
type: 'object',
|
|
365
|
+
properties: {
|
|
366
|
+
slideId: { type: 'string', description: 'Target SlideID.' },
|
|
367
|
+
speakerNotes: { type: 'string', description: 'Speaker notes text to set or append.' },
|
|
368
|
+
append: { type: 'boolean', description: 'When true, appends to existing speaker notes instead of replacing them.' },
|
|
369
|
+
expectedRevisionHash: { type: 'string', description: 'Optional SHA-256 revision hash for optimistic concurrency protection.' }
|
|
370
|
+
},
|
|
371
|
+
required: ['slideId', 'speakerNotes']
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
name: 'batch_mutate_slides',
|
|
376
|
+
description: 'Atomically updates multiple slides (title, subtitle, layout, speakerNotes, hidden) after checking all slide locks upfront.',
|
|
377
|
+
inputSchema: {
|
|
378
|
+
type: 'object',
|
|
379
|
+
properties: {
|
|
380
|
+
operations: {
|
|
381
|
+
type: 'array',
|
|
382
|
+
items: { type: 'object' },
|
|
383
|
+
description: 'Array of { slideId, title?, subtitle?, layout?, speakerNotes?, hidden? } updates.'
|
|
384
|
+
},
|
|
385
|
+
expectedRevisionHash: { type: 'string', description: 'Optional SHA-256 revision hash for optimistic concurrency protection.' }
|
|
386
|
+
},
|
|
387
|
+
required: ['operations']
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
name: 'set_lock',
|
|
392
|
+
description: 'Locks a slide (or specific region when regionId is supplied) to owner/locker.',
|
|
393
|
+
inputSchema: {
|
|
394
|
+
type: 'object',
|
|
395
|
+
properties: {
|
|
396
|
+
slideId: { type: 'string', description: 'Target SlideID to lock.' },
|
|
397
|
+
regionId: { type: 'string', description: 'Optional RegionID to lock instead of the whole slide.' },
|
|
398
|
+
allowEditors: { type: 'boolean', description: 'When true, artifact editors may still edit the locked target (default false).' },
|
|
399
|
+
expectedRevisionHash: { type: 'string', description: 'Optional SHA-256 revision hash for optimistic concurrency protection.' }
|
|
400
|
+
},
|
|
401
|
+
required: ['slideId']
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
name: 'release_lock',
|
|
406
|
+
description: 'Unlocks a locked slide or region if the actor is the locker or artifact owner.',
|
|
407
|
+
inputSchema: {
|
|
408
|
+
type: 'object',
|
|
409
|
+
properties: {
|
|
410
|
+
slideId: { type: 'string', description: 'Target SlideID to unlock.' },
|
|
411
|
+
regionId: { type: 'string', description: 'Optional RegionID to unlock.' },
|
|
412
|
+
expectedRevisionHash: { type: 'string', description: 'Optional SHA-256 revision hash for optimistic concurrency protection.' }
|
|
413
|
+
},
|
|
414
|
+
required: ['slideId']
|
|
415
|
+
}
|
|
416
|
+
},
|
|
417
|
+
...GetSharedCommentAndSuggestionToolDefinitions('slides')
|
|
418
|
+
];
|
|
419
|
+
}
|
|
420
|
+
async invokeSubclassTool(toolName, input, artifactContent, context) {
|
|
421
|
+
const contentStr = typeof artifactContent === 'string' ? artifactContent : artifactContent.toString('utf-8');
|
|
422
|
+
switch (toolName) {
|
|
423
|
+
case 'read_deck':
|
|
424
|
+
case 'get_deck_outline':
|
|
425
|
+
return this.handleReadDeck(contentStr, input);
|
|
426
|
+
case 'get_slide':
|
|
427
|
+
return this.handleGetSlide(contentStr, input);
|
|
428
|
+
case 'add_slide':
|
|
429
|
+
return await this.handleAddSlide(contentStr, input, context);
|
|
430
|
+
case 'update_slide':
|
|
431
|
+
return await this.handleUpdateSlide(contentStr, input, context);
|
|
432
|
+
case 'delete_slide':
|
|
433
|
+
return this.handleDeleteSlide(contentStr, input, context);
|
|
434
|
+
case 'duplicate_slide':
|
|
435
|
+
return this.handleDuplicateSlide(contentStr, input, context);
|
|
436
|
+
case 'reorder_slides':
|
|
437
|
+
return this.handleReorderSlides(contentStr, input, context);
|
|
438
|
+
case 'upsert_slide_element':
|
|
439
|
+
case 'update_slide_region':
|
|
440
|
+
return this.handleUpsertSlideElement(contentStr, input, context);
|
|
441
|
+
case 'delete_slide_element':
|
|
442
|
+
return this.handleDeleteSlideElement(contentStr, input, context);
|
|
443
|
+
case 'duplicate_region':
|
|
444
|
+
return this.handleDuplicateRegion(contentStr, input, context);
|
|
445
|
+
case 'align_distribute_regions':
|
|
446
|
+
return this.handleAlignDistributeRegions(contentStr, input, context);
|
|
447
|
+
case 'update_speaker_notes':
|
|
448
|
+
return this.handleUpdateSpeakerNotes(contentStr, input, context);
|
|
449
|
+
case 'upsert_speaker_notes':
|
|
450
|
+
return this.handleUpsertSpeakerNotes(contentStr, input, context);
|
|
451
|
+
case 'batch_mutate_slides':
|
|
452
|
+
return this.handleBatchMutateSlides(contentStr, input, context);
|
|
453
|
+
case 'update_deck_metadata':
|
|
454
|
+
return this.handleUpdateDeckMetadata(contentStr, input, context);
|
|
455
|
+
case 'apply_theme':
|
|
456
|
+
return this.handleApplyTheme(contentStr, input, context);
|
|
457
|
+
case 'generate_deck_from_markdown':
|
|
458
|
+
return this.handleGenerateDeckFromMarkdown(contentStr, input, context);
|
|
459
|
+
case 'set_lock':
|
|
460
|
+
return this.handleToggleSlideLock(contentStr, input, true, context);
|
|
461
|
+
case 'release_lock':
|
|
462
|
+
return this.handleToggleSlideLock(contentStr, input, false, context);
|
|
463
|
+
case 'list_comments':
|
|
464
|
+
case 'add_comment':
|
|
465
|
+
case 'reply_comment':
|
|
466
|
+
case 'resolve_comment':
|
|
467
|
+
return ExecuteArtifactCommentTool({
|
|
468
|
+
toolName,
|
|
469
|
+
input,
|
|
470
|
+
context,
|
|
471
|
+
domain: 'slides'
|
|
472
|
+
});
|
|
473
|
+
case 'list_suggestions':
|
|
474
|
+
return ExecuteListSuggestionsTool({
|
|
475
|
+
domain: 'slides',
|
|
476
|
+
artifactContent: contentStr,
|
|
477
|
+
input,
|
|
478
|
+
context
|
|
479
|
+
});
|
|
480
|
+
case 'propose_suggestion':
|
|
481
|
+
return this.handleProposeSuggestion(contentStr, input, context);
|
|
482
|
+
case 'review_suggestion':
|
|
483
|
+
return this.handleReviewSuggestion(contentStr, input, context);
|
|
484
|
+
default:
|
|
485
|
+
return { success: false, data: null, errorMessage: `Unknown SlideDeckToolLibrary tool: "${toolName}"` };
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
async normalizeArtifactBlocksInMarkdown(markdown, context) {
|
|
489
|
+
const parsedSegs = DocumentLiveBlockEngine.Instance.ParseMarkdownDirectives(markdown);
|
|
490
|
+
let updated = markdown;
|
|
491
|
+
for (const seg of parsedSegs) {
|
|
492
|
+
if (seg.Type !== 'mj-block' || !seg.BlockSpec || seg.BlockSpec.Kind !== 'Artifact') {
|
|
493
|
+
continue;
|
|
494
|
+
}
|
|
495
|
+
const rawArtifactId = String(seg.BlockSpec.ArtifactID ?? '').trim();
|
|
496
|
+
if (!rawArtifactId) {
|
|
497
|
+
return { ok: false, errorMessage: 'Embedded Artifact block requires a valid ArtifactID.' };
|
|
498
|
+
}
|
|
499
|
+
const resolved = ResolveEmbeddedArtifactId(rawArtifactId, context);
|
|
500
|
+
if (!resolved.ok) {
|
|
501
|
+
return { ok: false, errorMessage: resolved.errorMessage };
|
|
502
|
+
}
|
|
503
|
+
const rawVersionId = typeof seg.BlockSpec.VersionID === 'string' ? seg.BlockSpec.VersionID.trim() : '';
|
|
504
|
+
let resolvedVersionId = seg.BlockSpec.VersionID;
|
|
505
|
+
if (rawVersionId) {
|
|
506
|
+
const verResult = ResolveEmbeddedVersionId(rawVersionId, context);
|
|
507
|
+
if (!verResult.ok) {
|
|
508
|
+
return { ok: false, errorMessage: verResult.errorMessage };
|
|
509
|
+
}
|
|
510
|
+
resolvedVersionId = verResult.versionId;
|
|
511
|
+
}
|
|
512
|
+
const access = await ValidateEmbeddedArtifactAccess({
|
|
513
|
+
targetArtifactId: resolved.artifactId,
|
|
514
|
+
targetVersionId: resolvedVersionId ?? null,
|
|
515
|
+
context
|
|
516
|
+
});
|
|
517
|
+
if (!access.Ok) {
|
|
518
|
+
return { ok: false, errorMessage: access.ErrorMessage || `Cannot embed artifact '${resolved.artifactId}'.` };
|
|
519
|
+
}
|
|
520
|
+
if (resolved.artifactId !== seg.BlockSpec.ArtifactID ||
|
|
521
|
+
resolvedVersionId !== seg.BlockSpec.VersionID ||
|
|
522
|
+
(!seg.BlockSpec.ArtifactType && access.ArtifactTypeName)) {
|
|
523
|
+
const normalizedDirective = DocumentLiveBlockEngine.Instance.SerializeBlockToMarkdownDirective({
|
|
524
|
+
...seg.BlockSpec,
|
|
525
|
+
ArtifactID: resolved.artifactId,
|
|
526
|
+
ArtifactType: seg.BlockSpec.ArtifactType ?? access.ArtifactTypeName,
|
|
527
|
+
VersionID: resolvedVersionId
|
|
528
|
+
});
|
|
529
|
+
updated = updated.replace(seg.RawText, () => normalizedDirective);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
return { ok: true, markdown: updated };
|
|
533
|
+
}
|
|
534
|
+
checkRevision(contentStr, expectedRevisionHash) {
|
|
535
|
+
if (typeof expectedRevisionHash !== 'string' || !expectedRevisionHash.trim()) {
|
|
536
|
+
return null;
|
|
537
|
+
}
|
|
538
|
+
const current = this.ComputeRevisionHash(contentStr);
|
|
539
|
+
if (current !== expectedRevisionHash.trim()) {
|
|
540
|
+
return 'Stale revision hash: the presentation was modified concurrently. Re-read the deck before applying updates.';
|
|
541
|
+
}
|
|
542
|
+
return null;
|
|
543
|
+
}
|
|
544
|
+
assertDeckUnlockedForGlobalEdit(deck, lockContext) {
|
|
545
|
+
for (const slide of deck.Slides) {
|
|
546
|
+
const slidePerm = SlideDeckEngine.Instance.CanActorEditSlide(slide, lockContext.ActorUserID, lockContext.OwnerUserID, lockContext.IsEditor);
|
|
547
|
+
if (!slidePerm.Allowed) {
|
|
548
|
+
return slidePerm.Reason ?? `Slide '${slide.SlideID}' is locked (owner-only protection).`;
|
|
549
|
+
}
|
|
550
|
+
for (const region of slide.Regions) {
|
|
551
|
+
const regionPerm = SlideDeckEngine.Instance.CanActorEditRegion(slide, region, lockContext.ActorUserID, lockContext.OwnerUserID, lockContext.IsEditor);
|
|
552
|
+
if (!regionPerm.Allowed) {
|
|
553
|
+
return regionPerm.Reason ?? `Region '${region.RegionID}' on slide '${slide.SlideID}' is locked (owner-only protection).`;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
return null;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Computes a deterministic SHA-256 revision hash for optimistic concurrency checking.
|
|
561
|
+
*/
|
|
562
|
+
ComputeRevisionHash(content) {
|
|
563
|
+
return createHash('sha256').update(content ?? '', 'utf8').digest('hex');
|
|
564
|
+
}
|
|
565
|
+
handleReadDeck(contentStr, input) {
|
|
566
|
+
const deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
567
|
+
const outline = SlideDeckEngine.Instance.BuildDeckOutline(deck);
|
|
568
|
+
const includeFull = Boolean(input.includeFullSlides);
|
|
569
|
+
return {
|
|
570
|
+
success: true,
|
|
571
|
+
data: {
|
|
572
|
+
revisionHash: this.ComputeRevisionHash(contentStr),
|
|
573
|
+
outline,
|
|
574
|
+
theme: deck.Theme,
|
|
575
|
+
master: deck.Master,
|
|
576
|
+
slides: includeFull ? deck.Slides : undefined
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
handleGetSlide(contentStr, input) {
|
|
581
|
+
const deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
582
|
+
const slideId = typeof input.slideId === 'string' ? input.slideId.trim() : '';
|
|
583
|
+
const slideNumber = typeof input.slideNumber === 'number' ? input.slideNumber : undefined;
|
|
584
|
+
const found = deck.Slides.find((s) => (slideId && s.SlideID === slideId) || (slideNumber !== undefined && s.SlideNumber === slideNumber));
|
|
585
|
+
if (!found) {
|
|
586
|
+
return {
|
|
587
|
+
success: false,
|
|
588
|
+
data: null,
|
|
589
|
+
errorMessage: `Slide not found for slideId="${slideId}" / slideNumber=${slideNumber ?? 'none'}.`
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
return {
|
|
593
|
+
success: true,
|
|
594
|
+
data: {
|
|
595
|
+
revisionHash: this.ComputeRevisionHash(contentStr),
|
|
596
|
+
slide: found
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
async handleAddSlide(contentStr, input, context) {
|
|
601
|
+
const revError = this.checkRevision(contentStr, input.expectedRevisionHash);
|
|
602
|
+
if (revError) {
|
|
603
|
+
return { success: false, data: null, errorMessage: revError };
|
|
604
|
+
}
|
|
605
|
+
const deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
606
|
+
const title = typeof input.title === 'string' && input.title.trim() ? input.title.trim() : 'New Slide';
|
|
607
|
+
const subtitle = typeof input.subtitle === 'string' ? input.subtitle : undefined;
|
|
608
|
+
const layout = (typeof input.layout === 'string' ? input.layout : 'TitleAndBody');
|
|
609
|
+
const speakerNotes = typeof input.speakerNotes === 'string' ? input.speakerNotes : '';
|
|
610
|
+
const slideId = typeof input.slideId === 'string' && input.slideId.trim() ? input.slideId.trim() : undefined;
|
|
611
|
+
const insertAtIndex = typeof input.insertAtIndex === 'number' ? Math.trunc(input.insertAtIndex) : undefined;
|
|
612
|
+
if (insertAtIndex !== undefined && insertAtIndex >= 0 && insertAtIndex < deck.Slides.length) {
|
|
613
|
+
const lockContext = this.extractLockContext(context);
|
|
614
|
+
for (const shiftedSlide of deck.Slides.slice(insertAtIndex)) {
|
|
615
|
+
const perm = SlideDeckEngine.Instance.CanActorEditSlide(shiftedSlide, lockContext.ActorUserID, lockContext.OwnerUserID, lockContext.IsEditor);
|
|
616
|
+
if (!perm.Allowed) {
|
|
617
|
+
return {
|
|
618
|
+
success: false,
|
|
619
|
+
data: null,
|
|
620
|
+
errorMessage: perm.Reason ||
|
|
621
|
+
`Cannot insert slide at index ${insertAtIndex} because locked slide '${shiftedSlide.SlideID}' would be renumbered.`
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
let initialRegions;
|
|
627
|
+
if (typeof input.markdownContent === 'string' && input.markdownContent.trim()) {
|
|
628
|
+
const normalized = await this.normalizeArtifactBlocksInMarkdown(input.markdownContent, context);
|
|
629
|
+
if (!normalized.ok) {
|
|
630
|
+
return { success: false, data: null, errorMessage: normalized.errorMessage };
|
|
631
|
+
}
|
|
632
|
+
const defaultRegions = SlideDeckEngine.Instance.BuildRegionsForLayout(layout);
|
|
633
|
+
defaultRegions[0] = {
|
|
634
|
+
...defaultRegions[0],
|
|
635
|
+
MarkdownContent: normalized.markdown
|
|
636
|
+
};
|
|
637
|
+
initialRegions = defaultRegions;
|
|
638
|
+
}
|
|
639
|
+
const { Deck: updatedDeck, AddedSlide } = SlideDeckEngine.Instance.AddSlide(deck, {
|
|
640
|
+
SlideID: slideId,
|
|
641
|
+
Layout: layout,
|
|
642
|
+
Title: title,
|
|
643
|
+
Subtitle: subtitle,
|
|
644
|
+
Regions: initialRegions,
|
|
645
|
+
SpeakerNotes: speakerNotes,
|
|
646
|
+
InsertAtIndex: insertAtIndex
|
|
647
|
+
});
|
|
648
|
+
const updatedContent = SlideDeckEngine.Instance.SerializeDeckSpec(updatedDeck);
|
|
649
|
+
return {
|
|
650
|
+
success: true,
|
|
651
|
+
data: {
|
|
652
|
+
addedSlide: AddedSlide,
|
|
653
|
+
slideCount: updatedDeck.Slides.length,
|
|
654
|
+
revisionHash: this.ComputeRevisionHash(updatedContent),
|
|
655
|
+
updatedContent
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
}
|
|
659
|
+
async handleUpdateSlide(contentStr, input, context) {
|
|
660
|
+
const revError = this.checkRevision(contentStr, input.expectedRevisionHash);
|
|
661
|
+
if (revError) {
|
|
662
|
+
return { success: false, data: null, errorMessage: revError };
|
|
663
|
+
}
|
|
664
|
+
const slideId = typeof input.slideId === 'string' ? input.slideId.trim() : '';
|
|
665
|
+
if (!slideId) {
|
|
666
|
+
return { success: false, data: null, errorMessage: 'update_slide requires a non-empty slideId.' };
|
|
667
|
+
}
|
|
668
|
+
const deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
669
|
+
const lockContext = this.extractLockContext(context);
|
|
670
|
+
let afterMeta;
|
|
671
|
+
let UpdatedSlide;
|
|
672
|
+
try {
|
|
673
|
+
const metaRes = SlideDeckEngine.Instance.UpdateSlideMetadata(deck, slideId, {
|
|
674
|
+
Title: typeof input.title === 'string' ? input.title : undefined,
|
|
675
|
+
Subtitle: typeof input.subtitle === 'string' ? input.subtitle : undefined,
|
|
676
|
+
Layout: typeof input.layout === 'string' ? input.layout : undefined,
|
|
677
|
+
SpeakerNotes: typeof input.speakerNotes === 'string' ? input.speakerNotes : undefined,
|
|
678
|
+
Transition: typeof input.transition === 'string'
|
|
679
|
+
? input.transition
|
|
680
|
+
: undefined,
|
|
681
|
+
Hidden: typeof input.hidden === 'boolean' ? input.hidden : undefined
|
|
682
|
+
}, lockContext);
|
|
683
|
+
afterMeta = metaRes.Deck;
|
|
684
|
+
UpdatedSlide = metaRes.UpdatedSlide;
|
|
685
|
+
}
|
|
686
|
+
catch (err) {
|
|
687
|
+
return { success: false, data: null, errorMessage: err instanceof Error ? err.message : String(err) };
|
|
688
|
+
}
|
|
689
|
+
if (!UpdatedSlide) {
|
|
690
|
+
return {
|
|
691
|
+
success: false,
|
|
692
|
+
data: null,
|
|
693
|
+
errorMessage: `Slide "${slideId}" was not found in the presentation.`
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
let finalDeck = afterMeta;
|
|
697
|
+
if (typeof input.markdownContent === 'string') {
|
|
698
|
+
const normalized = await this.normalizeArtifactBlocksInMarkdown(input.markdownContent, context);
|
|
699
|
+
if (!normalized.ok) {
|
|
700
|
+
return { success: false, data: null, errorMessage: normalized.errorMessage };
|
|
701
|
+
}
|
|
702
|
+
const targetRegionId = UpdatedSlide.Regions[0]?.RegionID || 'main';
|
|
703
|
+
try {
|
|
704
|
+
const regionRes = SlideDeckEngine.Instance.UpsertSlideRegion(finalDeck, slideId, {
|
|
705
|
+
RegionID: targetRegionId,
|
|
706
|
+
MarkdownContent: normalized.markdown
|
|
707
|
+
}, lockContext);
|
|
708
|
+
finalDeck = regionRes.Deck;
|
|
709
|
+
}
|
|
710
|
+
catch (err) {
|
|
711
|
+
return { success: false, data: null, errorMessage: err instanceof Error ? err.message : String(err) };
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
const updatedSlideFinal = finalDeck.Slides.find((s) => s.SlideID === slideId) ?? UpdatedSlide;
|
|
715
|
+
const updatedContent = SlideDeckEngine.Instance.SerializeDeckSpec(finalDeck);
|
|
716
|
+
return {
|
|
717
|
+
success: true,
|
|
718
|
+
data: {
|
|
719
|
+
updatedSlide: updatedSlideFinal,
|
|
720
|
+
revisionHash: this.ComputeRevisionHash(updatedContent),
|
|
721
|
+
updatedContent
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
handleDeleteSlide(contentStr, input, context) {
|
|
726
|
+
const revError = this.checkRevision(contentStr, input.expectedRevisionHash);
|
|
727
|
+
if (revError) {
|
|
728
|
+
return { success: false, data: null, errorMessage: revError };
|
|
729
|
+
}
|
|
730
|
+
const slideId = typeof input.slideId === 'string' ? input.slideId.trim() : '';
|
|
731
|
+
if (!slideId) {
|
|
732
|
+
return { success: false, data: null, errorMessage: 'delete_slide requires slideId.' };
|
|
733
|
+
}
|
|
734
|
+
const deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
735
|
+
const lockContext = this.extractLockContext(context);
|
|
736
|
+
let updatedDeck;
|
|
737
|
+
let Deleted;
|
|
738
|
+
try {
|
|
739
|
+
const delRes = SlideDeckEngine.Instance.DeleteSlide(deck, slideId, lockContext);
|
|
740
|
+
updatedDeck = delRes.Deck;
|
|
741
|
+
Deleted = delRes.Deleted;
|
|
742
|
+
}
|
|
743
|
+
catch (err) {
|
|
744
|
+
return { success: false, data: null, errorMessage: err instanceof Error ? err.message : String(err) };
|
|
745
|
+
}
|
|
746
|
+
if (!Deleted) {
|
|
747
|
+
return {
|
|
748
|
+
success: false,
|
|
749
|
+
data: null,
|
|
750
|
+
errorMessage: `Could not delete slide "${slideId}" (slide not found or deck has only 1 slide).`
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
const updatedContent = SlideDeckEngine.Instance.SerializeDeckSpec(updatedDeck);
|
|
754
|
+
return {
|
|
755
|
+
success: true,
|
|
756
|
+
data: {
|
|
757
|
+
deletedSlideId: slideId,
|
|
758
|
+
slideCount: updatedDeck.Slides.length,
|
|
759
|
+
revisionHash: this.ComputeRevisionHash(updatedContent),
|
|
760
|
+
updatedContent
|
|
761
|
+
}
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
handleDuplicateSlide(contentStr, input, context) {
|
|
765
|
+
const revError = this.checkRevision(contentStr, input.expectedRevisionHash);
|
|
766
|
+
if (revError) {
|
|
767
|
+
return { success: false, data: null, errorMessage: revError };
|
|
768
|
+
}
|
|
769
|
+
const slideId = typeof input.slideId === 'string' ? input.slideId.trim() : '';
|
|
770
|
+
if (!slideId) {
|
|
771
|
+
return { success: false, data: null, errorMessage: 'duplicate_slide requires slideId.' };
|
|
772
|
+
}
|
|
773
|
+
const deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
774
|
+
const sourceSlide = deck.Slides.find((s) => s.SlideID === slideId);
|
|
775
|
+
if (!sourceSlide) {
|
|
776
|
+
return { success: false, data: null, errorMessage: `Slide "${slideId}" was not found.` };
|
|
777
|
+
}
|
|
778
|
+
const lockContext = this.extractLockContext(context);
|
|
779
|
+
const slidePerm = SlideDeckEngine.Instance.CanActorEditSlide(sourceSlide, lockContext.ActorUserID, lockContext.OwnerUserID, lockContext.IsEditor);
|
|
780
|
+
if (!slidePerm.Allowed) {
|
|
781
|
+
return { success: false, data: null, errorMessage: slidePerm.Reason };
|
|
782
|
+
}
|
|
783
|
+
const dupRes = SlideDeckEngine.Instance.DuplicateSlide(deck, slideId);
|
|
784
|
+
if (!dupRes.DuplicatedSlide) {
|
|
785
|
+
return { success: false, data: null, errorMessage: `Could not duplicate slide "${slideId}".` };
|
|
786
|
+
}
|
|
787
|
+
if (typeof input.title === 'string' && input.title.trim()) {
|
|
788
|
+
dupRes.DuplicatedSlide.Title = input.title.trim();
|
|
789
|
+
}
|
|
790
|
+
const updatedContent = SlideDeckEngine.Instance.SerializeDeckSpec(dupRes.Deck);
|
|
791
|
+
return {
|
|
792
|
+
success: true,
|
|
793
|
+
data: {
|
|
794
|
+
sourceSlideId: slideId,
|
|
795
|
+
duplicatedSlide: dupRes.DuplicatedSlide,
|
|
796
|
+
slideCount: dupRes.Deck.Slides.length,
|
|
797
|
+
revisionHash: this.ComputeRevisionHash(updatedContent),
|
|
798
|
+
updatedContent
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
handleReorderSlides(contentStr, input, context) {
|
|
803
|
+
const revError = this.checkRevision(contentStr, input.expectedRevisionHash);
|
|
804
|
+
if (revError) {
|
|
805
|
+
return { success: false, data: null, errorMessage: revError };
|
|
806
|
+
}
|
|
807
|
+
const rawIds = Array.isArray(input.slideIds) ? input.slideIds : [];
|
|
808
|
+
const slideIds = rawIds.filter((id) => typeof id === 'string' && id.trim().length > 0);
|
|
809
|
+
if (slideIds.length === 0) {
|
|
810
|
+
return { success: false, data: null, errorMessage: 'reorder_slides requires a non-empty slideIds array.' };
|
|
811
|
+
}
|
|
812
|
+
const deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
813
|
+
const lockContext = this.extractLockContext(context);
|
|
814
|
+
const originalIndexBySlideId = new Map();
|
|
815
|
+
deck.Slides.forEach((s, idx) => originalIndexBySlideId.set(s.SlideID, idx));
|
|
816
|
+
const updatedDeck = SlideDeckEngine.Instance.ReorderSlides(deck, slideIds);
|
|
817
|
+
for (let newIdx = 0; newIdx < updatedDeck.Slides.length; newIdx++) {
|
|
818
|
+
const slide = updatedDeck.Slides[newIdx];
|
|
819
|
+
const prevIdx = originalIndexBySlideId.get(slide.SlideID);
|
|
820
|
+
if (prevIdx !== newIdx) {
|
|
821
|
+
const slidePerm = SlideDeckEngine.Instance.CanActorEditSlide(slide, lockContext.ActorUserID, lockContext.OwnerUserID, lockContext.IsEditor);
|
|
822
|
+
if (!slidePerm.Allowed) {
|
|
823
|
+
return { success: false, data: null, errorMessage: slidePerm.Reason };
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
const updatedContent = SlideDeckEngine.Instance.SerializeDeckSpec(updatedDeck);
|
|
828
|
+
return {
|
|
829
|
+
success: true,
|
|
830
|
+
data: {
|
|
831
|
+
orderedSlideIds: updatedDeck.Slides.map((s) => s.SlideID),
|
|
832
|
+
revisionHash: this.ComputeRevisionHash(updatedContent),
|
|
833
|
+
updatedContent
|
|
834
|
+
}
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
async handleUpsertSlideElement(contentStr, input, context) {
|
|
838
|
+
const revError = this.checkRevision(contentStr, input.expectedRevisionHash);
|
|
839
|
+
if (revError) {
|
|
840
|
+
return { success: false, data: null, errorMessage: revError };
|
|
841
|
+
}
|
|
842
|
+
const slideId = typeof input.slideId === 'string' ? input.slideId.trim() : '';
|
|
843
|
+
const regionId = typeof input.regionId === 'string' ? input.regionId.trim() : '';
|
|
844
|
+
if (!slideId || !regionId) {
|
|
845
|
+
return {
|
|
846
|
+
success: false,
|
|
847
|
+
data: null,
|
|
848
|
+
errorMessage: 'upsert_slide_element requires both slideId and regionId.'
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
const deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
852
|
+
let blockSpec;
|
|
853
|
+
let markdownContent = typeof input.markdownContent === 'string' ? input.markdownContent : undefined;
|
|
854
|
+
let kind = (typeof input.kind === 'string' ? input.kind : undefined);
|
|
855
|
+
if (input.mjBlock && typeof input.mjBlock === 'object' && !Array.isArray(input.mjBlock)) {
|
|
856
|
+
const rawBlock = input.mjBlock;
|
|
857
|
+
const blockKind = (typeof rawBlock.Kind === 'string' ? rawBlock.Kind : 'EntityView');
|
|
858
|
+
let resolvedArtifactId = typeof rawBlock.ArtifactID === 'string' ? rawBlock.ArtifactID : undefined;
|
|
859
|
+
if (blockKind === 'Artifact' || resolvedArtifactId) {
|
|
860
|
+
const resolved = ResolveEmbeddedArtifactId(resolvedArtifactId ?? '', context);
|
|
861
|
+
if (!resolved.ok) {
|
|
862
|
+
return { success: false, data: null, errorMessage: resolved.errorMessage };
|
|
863
|
+
}
|
|
864
|
+
resolvedArtifactId = resolved.artifactId;
|
|
865
|
+
}
|
|
866
|
+
let resolvedVersionId;
|
|
867
|
+
if (typeof rawBlock.VersionID === 'string' && rawBlock.VersionID.trim()) {
|
|
868
|
+
const verResult = ResolveEmbeddedVersionId(rawBlock.VersionID, context);
|
|
869
|
+
if (!verResult.ok) {
|
|
870
|
+
return { success: false, data: null, errorMessage: verResult.errorMessage };
|
|
871
|
+
}
|
|
872
|
+
resolvedVersionId = verResult.versionId;
|
|
873
|
+
}
|
|
874
|
+
else if (rawBlock.VersionID === null) {
|
|
875
|
+
resolvedVersionId = null;
|
|
876
|
+
}
|
|
877
|
+
let resolvedArtifactType = typeof rawBlock.ArtifactType === 'string' ? rawBlock.ArtifactType : undefined;
|
|
878
|
+
if ((blockKind === 'Artifact' || resolvedArtifactId) && resolvedArtifactId) {
|
|
879
|
+
const access = await ValidateEmbeddedArtifactAccess({
|
|
880
|
+
targetArtifactId: resolvedArtifactId,
|
|
881
|
+
targetVersionId: resolvedVersionId ?? null,
|
|
882
|
+
context
|
|
883
|
+
});
|
|
884
|
+
if (!access.Ok) {
|
|
885
|
+
return { success: false, data: null, errorMessage: access.ErrorMessage || `Cannot embed artifact '${resolvedArtifactId}'.` };
|
|
886
|
+
}
|
|
887
|
+
if (!resolvedArtifactType && access.ArtifactTypeName) {
|
|
888
|
+
resolvedArtifactType = access.ArtifactTypeName;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
const rawFields = Array.isArray(rawBlock.Fields)
|
|
892
|
+
? rawBlock.Fields.filter((f) => typeof f === 'string' && f.trim().length > 0)
|
|
893
|
+
: undefined;
|
|
894
|
+
const rawParameters = rawBlock.Parameters && typeof rawBlock.Parameters === 'object' && !Array.isArray(rawBlock.Parameters)
|
|
895
|
+
? rawBlock.Parameters
|
|
896
|
+
: undefined;
|
|
897
|
+
const rawComponentSpec = rawBlock.ComponentSpec && typeof rawBlock.ComponentSpec === 'object' && !Array.isArray(rawBlock.ComponentSpec)
|
|
898
|
+
? rawBlock.ComponentSpec
|
|
899
|
+
: undefined;
|
|
900
|
+
const sheetId = typeof rawBlock.SheetID === 'string' && rawBlock.SheetID.trim()
|
|
901
|
+
? rawBlock.SheetID.trim()
|
|
902
|
+
: typeof rawBlock.SheetName === 'string' && rawBlock.SheetName.trim()
|
|
903
|
+
? rawBlock.SheetName.trim()
|
|
904
|
+
: undefined;
|
|
905
|
+
const sheetRange = typeof rawBlock.SheetRange === 'string' && rawBlock.SheetRange.trim()
|
|
906
|
+
? rawBlock.SheetRange.trim()
|
|
907
|
+
: typeof rawBlock.Range === 'string' && rawBlock.Range.trim()
|
|
908
|
+
? rawBlock.Range.trim()
|
|
909
|
+
: undefined;
|
|
910
|
+
const sheetChartId = typeof rawBlock.SheetChartID === 'string' && rawBlock.SheetChartID.trim()
|
|
911
|
+
? rawBlock.SheetChartID.trim()
|
|
912
|
+
: typeof rawBlock.ChartID === 'string' && rawBlock.ChartID.trim()
|
|
913
|
+
? rawBlock.ChartID.trim()
|
|
914
|
+
: undefined;
|
|
915
|
+
blockSpec = {
|
|
916
|
+
BlockID: typeof rawBlock.BlockID === 'string' && rawBlock.BlockID.trim()
|
|
917
|
+
? rawBlock.BlockID.trim()
|
|
918
|
+
: `slide-blk-${slideId}-${regionId}`,
|
|
919
|
+
Kind: blockKind,
|
|
920
|
+
Mode: (typeof rawBlock.Mode === 'string' ? rawBlock.Mode : 'Live'),
|
|
921
|
+
Title: typeof rawBlock.Title === 'string' ? rawBlock.Title : undefined,
|
|
922
|
+
EntityName: typeof rawBlock.EntityName === 'string' ? rawBlock.EntityName : undefined,
|
|
923
|
+
ViewID: typeof rawBlock.ViewID === 'string' ? rawBlock.ViewID : undefined,
|
|
924
|
+
ViewName: typeof rawBlock.ViewName === 'string' ? rawBlock.ViewName : undefined,
|
|
925
|
+
ExtraFilter: typeof rawBlock.ExtraFilter === 'string' ? rawBlock.ExtraFilter : undefined,
|
|
926
|
+
OrderBy: typeof rawBlock.OrderBy === 'string' ? rawBlock.OrderBy : undefined,
|
|
927
|
+
Fields: rawFields && rawFields.length > 0 ? rawFields : undefined,
|
|
928
|
+
DisplayMode: typeof rawBlock.DisplayMode === 'string'
|
|
929
|
+
? rawBlock.DisplayMode
|
|
930
|
+
: undefined,
|
|
931
|
+
ChartType: typeof rawBlock.ChartType === 'string'
|
|
932
|
+
? rawBlock.ChartType
|
|
933
|
+
: undefined,
|
|
934
|
+
QueryID: typeof rawBlock.QueryID === 'string' ? rawBlock.QueryID : undefined,
|
|
935
|
+
QueryName: typeof rawBlock.QueryName === 'string' ? rawBlock.QueryName : undefined,
|
|
936
|
+
CategoryPath: typeof rawBlock.CategoryPath === 'string' ? rawBlock.CategoryPath : undefined,
|
|
937
|
+
Parameters: rawParameters,
|
|
938
|
+
DashboardID: typeof rawBlock.DashboardID === 'string' ? rawBlock.DashboardID : undefined,
|
|
939
|
+
DashboardPartID: typeof rawBlock.DashboardPartID === 'string' ? rawBlock.DashboardPartID : undefined,
|
|
940
|
+
DashboardName: typeof rawBlock.DashboardName === 'string' ? rawBlock.DashboardName : undefined,
|
|
941
|
+
ComponentID: typeof rawBlock.ComponentID === 'string' ? rawBlock.ComponentID : undefined,
|
|
942
|
+
ComponentName: typeof rawBlock.ComponentName === 'string' ? rawBlock.ComponentName : undefined,
|
|
943
|
+
ComponentSpec: rawComponentSpec,
|
|
944
|
+
ArtifactID: resolvedArtifactId,
|
|
945
|
+
ArtifactType: resolvedArtifactType,
|
|
946
|
+
VersionID: resolvedVersionId,
|
|
947
|
+
EmbedMode: (typeof rawBlock.EmbedMode === 'string' ? rawBlock.EmbedMode : 'Inline'),
|
|
948
|
+
HeightPx: typeof rawBlock.HeightPx === 'number' && Number.isFinite(rawBlock.HeightPx)
|
|
949
|
+
? rawBlock.HeightPx
|
|
950
|
+
: undefined,
|
|
951
|
+
SheetID: sheetId,
|
|
952
|
+
SheetRange: sheetRange,
|
|
953
|
+
SheetChartID: sheetChartId,
|
|
954
|
+
MaxRows: typeof rawBlock.MaxRows === 'number' && Number.isFinite(rawBlock.MaxRows) && rawBlock.MaxRows > 0
|
|
955
|
+
? Math.floor(rawBlock.MaxRows)
|
|
956
|
+
: undefined,
|
|
957
|
+
PageSize: typeof rawBlock.PageSize === 'number' && Number.isFinite(rawBlock.PageSize) && rawBlock.PageSize > 0
|
|
958
|
+
? Math.floor(rawBlock.PageSize)
|
|
959
|
+
: undefined,
|
|
960
|
+
Collapsed: typeof rawBlock.Collapsed === 'boolean' ? rawBlock.Collapsed : undefined
|
|
961
|
+
};
|
|
962
|
+
kind = 'mj-block';
|
|
963
|
+
markdownContent = DocumentLiveBlockEngine.Instance.SerializeBlockToMarkdownDirective(blockSpec);
|
|
964
|
+
}
|
|
965
|
+
else if (typeof markdownContent === 'string' && markdownContent.includes(':::mj-block')) {
|
|
966
|
+
const normalized = await this.normalizeArtifactBlocksInMarkdown(markdownContent, context);
|
|
967
|
+
if (!normalized.ok) {
|
|
968
|
+
return { success: false, data: null, errorMessage: normalized.errorMessage };
|
|
969
|
+
}
|
|
970
|
+
markdownContent = normalized.markdown;
|
|
971
|
+
}
|
|
972
|
+
const lockContext = this.extractLockContext(context);
|
|
973
|
+
let updatedDeck;
|
|
974
|
+
let UpdatedRegion;
|
|
975
|
+
try {
|
|
976
|
+
const upsertRes = SlideDeckEngine.Instance.UpsertSlideRegion(deck, slideId, {
|
|
977
|
+
RegionID: regionId,
|
|
978
|
+
Label: typeof input.label === 'string' ? input.label : undefined,
|
|
979
|
+
Kind: kind,
|
|
980
|
+
MarkdownContent: markdownContent,
|
|
981
|
+
BlockSpec: blockSpec,
|
|
982
|
+
ImageUrl: typeof input.imageUrl === 'string' ? input.imageUrl : undefined,
|
|
983
|
+
ImageAlt: typeof input.imageAlt === 'string' ? input.imageAlt : undefined,
|
|
984
|
+
BigNumberValue: typeof input.bigNumberValue === 'string' ? input.bigNumberValue : undefined,
|
|
985
|
+
BigNumberLabel: typeof input.bigNumberLabel === 'string' ? input.bigNumberLabel : undefined,
|
|
986
|
+
BigNumberDelta: typeof input.bigNumberDelta === 'string' ? input.bigNumberDelta : undefined,
|
|
987
|
+
QuoteAttribution: typeof input.quoteAttribution === 'string' ? input.quoteAttribution : undefined,
|
|
988
|
+
CalloutTone: typeof input.calloutTone === 'string'
|
|
989
|
+
? input.calloutTone
|
|
990
|
+
: undefined
|
|
991
|
+
}, lockContext);
|
|
992
|
+
updatedDeck = upsertRes.Deck;
|
|
993
|
+
UpdatedRegion = upsertRes.UpdatedRegion;
|
|
994
|
+
}
|
|
995
|
+
catch (err) {
|
|
996
|
+
return { success: false, data: null, errorMessage: err instanceof Error ? err.message : String(err) };
|
|
997
|
+
}
|
|
998
|
+
if (!UpdatedRegion) {
|
|
999
|
+
return {
|
|
1000
|
+
success: false,
|
|
1001
|
+
data: null,
|
|
1002
|
+
errorMessage: `Slide "${slideId}" was not found.`
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
1005
|
+
const updatedContent = SlideDeckEngine.Instance.SerializeDeckSpec(updatedDeck);
|
|
1006
|
+
return {
|
|
1007
|
+
success: true,
|
|
1008
|
+
data: {
|
|
1009
|
+
slideId,
|
|
1010
|
+
updatedRegion: UpdatedRegion,
|
|
1011
|
+
revisionHash: this.ComputeRevisionHash(updatedContent),
|
|
1012
|
+
updatedContent
|
|
1013
|
+
}
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
handleDeleteSlideElement(contentStr, input, context) {
|
|
1017
|
+
const revError = this.checkRevision(contentStr, input.expectedRevisionHash);
|
|
1018
|
+
if (revError) {
|
|
1019
|
+
return { success: false, data: null, errorMessage: revError };
|
|
1020
|
+
}
|
|
1021
|
+
const slideId = typeof input.slideId === 'string' ? input.slideId.trim() : '';
|
|
1022
|
+
const regionId = typeof input.regionId === 'string' ? input.regionId.trim() : '';
|
|
1023
|
+
if (!slideId || !regionId) {
|
|
1024
|
+
return {
|
|
1025
|
+
success: false,
|
|
1026
|
+
data: null,
|
|
1027
|
+
errorMessage: 'delete_slide_element requires both slideId and regionId.'
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
const deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
1031
|
+
const slide = deck.Slides.find((s) => s.SlideID === slideId);
|
|
1032
|
+
if (!slide) {
|
|
1033
|
+
return { success: false, data: null, errorMessage: `Slide "${slideId}" was not found.` };
|
|
1034
|
+
}
|
|
1035
|
+
const lockContext = this.extractLockContext(context);
|
|
1036
|
+
const slidePerm = SlideDeckEngine.Instance.CanActorEditSlide(slide, lockContext.ActorUserID, lockContext.OwnerUserID, lockContext.IsEditor);
|
|
1037
|
+
if (!slidePerm.Allowed) {
|
|
1038
|
+
return { success: false, data: null, errorMessage: slidePerm.Reason };
|
|
1039
|
+
}
|
|
1040
|
+
const targetRegion = slide.Regions.find((r) => r.RegionID === regionId);
|
|
1041
|
+
const regionForLockCheck = targetRegion ?? (slide.Regions.length === 1 ? slide.Regions[0] : undefined);
|
|
1042
|
+
if (regionForLockCheck) {
|
|
1043
|
+
const regionPerm = SlideDeckEngine.Instance.CanActorEditRegion(slide, regionForLockCheck, lockContext.ActorUserID, lockContext.OwnerUserID, lockContext.IsEditor);
|
|
1044
|
+
if (!regionPerm.Allowed) {
|
|
1045
|
+
return { success: false, data: null, errorMessage: regionPerm.Reason };
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
if (!targetRegion) {
|
|
1049
|
+
return {
|
|
1050
|
+
success: false,
|
|
1051
|
+
data: null,
|
|
1052
|
+
errorMessage: `Region "${regionId}" was not found on slide "${slideId}".`
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1055
|
+
if (slide.Regions.length > 1) {
|
|
1056
|
+
slide.Regions = slide.Regions.filter((r) => r.RegionID !== regionId);
|
|
1057
|
+
}
|
|
1058
|
+
else if (slide.Regions[0]) {
|
|
1059
|
+
slide.Regions[0] = {
|
|
1060
|
+
...slide.Regions[0],
|
|
1061
|
+
Kind: 'rich-text',
|
|
1062
|
+
MarkdownContent: '',
|
|
1063
|
+
BlockSpec: undefined,
|
|
1064
|
+
ImageUrl: undefined,
|
|
1065
|
+
ImageAlt: undefined,
|
|
1066
|
+
BigNumberValue: undefined,
|
|
1067
|
+
BigNumberLabel: undefined,
|
|
1068
|
+
BigNumberDelta: undefined,
|
|
1069
|
+
QuoteAttribution: undefined,
|
|
1070
|
+
CalloutTone: undefined
|
|
1071
|
+
};
|
|
1072
|
+
}
|
|
1073
|
+
const updatedContent = SlideDeckEngine.Instance.SerializeDeckSpec(deck);
|
|
1074
|
+
return {
|
|
1075
|
+
success: true,
|
|
1076
|
+
data: {
|
|
1077
|
+
slideId,
|
|
1078
|
+
deletedRegionId: regionId,
|
|
1079
|
+
revisionHash: this.ComputeRevisionHash(updatedContent),
|
|
1080
|
+
updatedContent
|
|
1081
|
+
}
|
|
1082
|
+
};
|
|
1083
|
+
}
|
|
1084
|
+
handleUpdateSpeakerNotes(contentStr, input, context) {
|
|
1085
|
+
const revError = this.checkRevision(contentStr, input.expectedRevisionHash);
|
|
1086
|
+
if (revError) {
|
|
1087
|
+
return { success: false, data: null, errorMessage: revError };
|
|
1088
|
+
}
|
|
1089
|
+
const slideId = typeof input.slideId === 'string' ? input.slideId.trim() : '';
|
|
1090
|
+
const speakerNotes = typeof input.speakerNotes === 'string' ? input.speakerNotes : '';
|
|
1091
|
+
if (!slideId) {
|
|
1092
|
+
return { success: false, data: null, errorMessage: 'update_speaker_notes requires slideId.' };
|
|
1093
|
+
}
|
|
1094
|
+
const deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
1095
|
+
const lockContext = this.extractLockContext(context);
|
|
1096
|
+
let updatedDeck;
|
|
1097
|
+
let UpdatedSlide;
|
|
1098
|
+
try {
|
|
1099
|
+
const metaRes = SlideDeckEngine.Instance.UpdateSlideMetadata(deck, slideId, { SpeakerNotes: speakerNotes }, lockContext);
|
|
1100
|
+
updatedDeck = metaRes.Deck;
|
|
1101
|
+
UpdatedSlide = metaRes.UpdatedSlide;
|
|
1102
|
+
}
|
|
1103
|
+
catch (err) {
|
|
1104
|
+
return { success: false, data: null, errorMessage: err instanceof Error ? err.message : String(err) };
|
|
1105
|
+
}
|
|
1106
|
+
if (!UpdatedSlide) {
|
|
1107
|
+
return { success: false, data: null, errorMessage: `Slide "${slideId}" was not found.` };
|
|
1108
|
+
}
|
|
1109
|
+
const updatedContent = SlideDeckEngine.Instance.SerializeDeckSpec(updatedDeck);
|
|
1110
|
+
return {
|
|
1111
|
+
success: true,
|
|
1112
|
+
data: {
|
|
1113
|
+
slideId,
|
|
1114
|
+
speakerNotes: UpdatedSlide.SpeakerNotes,
|
|
1115
|
+
revisionHash: this.ComputeRevisionHash(updatedContent),
|
|
1116
|
+
updatedContent
|
|
1117
|
+
}
|
|
1118
|
+
};
|
|
1119
|
+
}
|
|
1120
|
+
handleUpdateDeckMetadata(contentStr, input, context) {
|
|
1121
|
+
const revError = this.checkRevision(contentStr, input.expectedRevisionHash);
|
|
1122
|
+
if (revError) {
|
|
1123
|
+
return { success: false, data: null, errorMessage: revError };
|
|
1124
|
+
}
|
|
1125
|
+
const deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
1126
|
+
const lockContext = this.extractLockContext(context);
|
|
1127
|
+
const lockErr = this.assertDeckUnlockedForGlobalEdit(deck, lockContext);
|
|
1128
|
+
if (lockErr) {
|
|
1129
|
+
return { success: false, data: null, errorMessage: lockErr };
|
|
1130
|
+
}
|
|
1131
|
+
if (typeof input.title === 'string' && input.title.trim()) {
|
|
1132
|
+
deck.Title = input.title.trim();
|
|
1133
|
+
}
|
|
1134
|
+
if (typeof input.subtitle === 'string') {
|
|
1135
|
+
deck.Subtitle = input.subtitle;
|
|
1136
|
+
}
|
|
1137
|
+
if (input.aspectRatio === '16:9' || input.aspectRatio === '4:3') {
|
|
1138
|
+
deck.AspectRatio = input.aspectRatio;
|
|
1139
|
+
}
|
|
1140
|
+
if (typeof input.headerText === 'string') {
|
|
1141
|
+
deck.Master.HeaderText = input.headerText;
|
|
1142
|
+
}
|
|
1143
|
+
if (typeof input.footerText === 'string') {
|
|
1144
|
+
deck.Master.FooterText = input.footerText;
|
|
1145
|
+
}
|
|
1146
|
+
if (typeof input.showSlideNumbers === 'boolean') {
|
|
1147
|
+
deck.Master.ShowSlideNumbers = input.showSlideNumbers;
|
|
1148
|
+
}
|
|
1149
|
+
if (typeof input.showDate === 'boolean') {
|
|
1150
|
+
deck.Master.ShowDate = input.showDate;
|
|
1151
|
+
}
|
|
1152
|
+
if (typeof input.organizationName === 'string') {
|
|
1153
|
+
deck.Master.OrganizationName = input.organizationName;
|
|
1154
|
+
}
|
|
1155
|
+
if (typeof input.logoUrl === 'string') {
|
|
1156
|
+
deck.Master.LogoUrl = input.logoUrl;
|
|
1157
|
+
}
|
|
1158
|
+
deck.UpdatedAt = new Date().toISOString();
|
|
1159
|
+
const updatedContent = SlideDeckEngine.Instance.SerializeDeckSpec(deck);
|
|
1160
|
+
return {
|
|
1161
|
+
success: true,
|
|
1162
|
+
data: {
|
|
1163
|
+
title: deck.Title,
|
|
1164
|
+
subtitle: deck.Subtitle,
|
|
1165
|
+
aspectRatio: deck.AspectRatio,
|
|
1166
|
+
master: deck.Master,
|
|
1167
|
+
revisionHash: this.ComputeRevisionHash(updatedContent),
|
|
1168
|
+
updatedContent
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1172
|
+
extractLockContext(context) {
|
|
1173
|
+
return {
|
|
1174
|
+
ActorUserID: context?.actorUserId ?? context?.contextUser?.ID ?? null,
|
|
1175
|
+
OwnerUserID: context?.ownerUserId ?? null,
|
|
1176
|
+
IsEditor: Boolean(context?.isEditor)
|
|
1177
|
+
};
|
|
1178
|
+
}
|
|
1179
|
+
handleApplyTheme(contentStr, input, context) {
|
|
1180
|
+
const revError = this.checkRevision(contentStr, input.expectedRevisionHash);
|
|
1181
|
+
if (revError) {
|
|
1182
|
+
return { success: false, data: null, errorMessage: revError };
|
|
1183
|
+
}
|
|
1184
|
+
const deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
1185
|
+
const lockContext = this.extractLockContext(context);
|
|
1186
|
+
const lockErr = this.assertDeckUnlockedForGlobalEdit(deck, lockContext);
|
|
1187
|
+
if (lockErr) {
|
|
1188
|
+
return { success: false, data: null, errorMessage: lockErr };
|
|
1189
|
+
}
|
|
1190
|
+
let updatedDeck;
|
|
1191
|
+
if (typeof input.primaryColor === 'string' && input.primaryColor.trim()) {
|
|
1192
|
+
updatedDeck = SlideDeckEngine.Instance.ApplyTheme(deck, {
|
|
1193
|
+
OrganizationName: typeof input.organizationName === 'string' ? input.organizationName : undefined,
|
|
1194
|
+
PrimaryColor: input.primaryColor.trim(),
|
|
1195
|
+
AccentColor: typeof input.accentColor === 'string' ? input.accentColor : undefined,
|
|
1196
|
+
BackgroundColor: typeof input.backgroundColor === 'string' ? input.backgroundColor : undefined,
|
|
1197
|
+
SurfaceColor: typeof input.surfaceColor === 'string' ? input.surfaceColor : undefined,
|
|
1198
|
+
TextColor: typeof input.textColor === 'string' ? input.textColor : undefined
|
|
1199
|
+
});
|
|
1200
|
+
}
|
|
1201
|
+
else {
|
|
1202
|
+
const themeId = typeof input.themeId === 'string' ? input.themeId : 'mj-default';
|
|
1203
|
+
updatedDeck = SlideDeckEngine.Instance.ApplyTheme(deck, themeId);
|
|
1204
|
+
}
|
|
1205
|
+
const updatedContent = SlideDeckEngine.Instance.SerializeDeckSpec(updatedDeck);
|
|
1206
|
+
return {
|
|
1207
|
+
success: true,
|
|
1208
|
+
data: {
|
|
1209
|
+
theme: updatedDeck.Theme,
|
|
1210
|
+
revisionHash: this.ComputeRevisionHash(updatedContent),
|
|
1211
|
+
updatedContent
|
|
1212
|
+
}
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
async handleGenerateDeckFromMarkdown(contentStr, input, context) {
|
|
1216
|
+
const revError = this.checkRevision(contentStr, input.expectedRevisionHash);
|
|
1217
|
+
if (revError) {
|
|
1218
|
+
return { success: false, data: null, errorMessage: revError };
|
|
1219
|
+
}
|
|
1220
|
+
const lockContext = this.extractLockContext(context);
|
|
1221
|
+
const existingDeck = contentStr.trim().startsWith('{')
|
|
1222
|
+
? SlideDeckEngine.Instance.ParseDeckSpec(contentStr)
|
|
1223
|
+
: undefined;
|
|
1224
|
+
if (existingDeck) {
|
|
1225
|
+
const lockErr = this.assertDeckUnlockedForGlobalEdit(existingDeck, lockContext);
|
|
1226
|
+
if (lockErr) {
|
|
1227
|
+
return { success: false, data: null, errorMessage: lockErr };
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
else {
|
|
1231
|
+
const mdLocks = DocumentLiveBlockEngine.Instance.ParseDocumentLocks(contentStr);
|
|
1232
|
+
for (const lock of mdLocks) {
|
|
1233
|
+
if (!DocumentLiveBlockEngine.Instance.CanActorEditLockedRange(lock, lockContext.ActorUserID, lockContext.OwnerUserID, lockContext.IsEditor)) {
|
|
1234
|
+
return {
|
|
1235
|
+
success: false,
|
|
1236
|
+
data: null,
|
|
1237
|
+
errorMessage: `Cannot regenerate deck over locked region '${lock.Label}' (${lock.Scope}).`
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
const rawMarkdown = typeof input.markdown === 'string' ? input.markdown : contentStr;
|
|
1243
|
+
const normalized = await this.normalizeArtifactBlocksInMarkdown(rawMarkdown, context);
|
|
1244
|
+
if (!normalized.ok) {
|
|
1245
|
+
return { success: false, data: null, errorMessage: normalized.errorMessage };
|
|
1246
|
+
}
|
|
1247
|
+
const deckTitle = typeof input.deckTitle === 'string' ? input.deckTitle : undefined;
|
|
1248
|
+
let generated = SlideDeckEngine.Instance.ConvertMarkdownToSlideDeck(normalized.markdown, deckTitle || existingDeck?.Title, existingDeck?.Theme, existingDeck?.DeckID);
|
|
1249
|
+
if (typeof input.themeId === 'string' && input.themeId.trim()) {
|
|
1250
|
+
generated = SlideDeckEngine.Instance.ApplyTheme(generated, input.themeId.trim());
|
|
1251
|
+
}
|
|
1252
|
+
const updatedContent = SlideDeckEngine.Instance.SerializeDeckSpec(generated);
|
|
1253
|
+
return {
|
|
1254
|
+
success: true,
|
|
1255
|
+
data: {
|
|
1256
|
+
outline: SlideDeckEngine.Instance.BuildDeckOutline(generated),
|
|
1257
|
+
slideCount: generated.Slides.length,
|
|
1258
|
+
revisionHash: this.ComputeRevisionHash(updatedContent),
|
|
1259
|
+
updatedContent
|
|
1260
|
+
}
|
|
1261
|
+
};
|
|
1262
|
+
}
|
|
1263
|
+
handleDuplicateRegion(contentStr, input, context) {
|
|
1264
|
+
const revError = this.checkRevision(contentStr, input.expectedRevisionHash);
|
|
1265
|
+
if (revError) {
|
|
1266
|
+
return { success: false, data: null, errorMessage: revError };
|
|
1267
|
+
}
|
|
1268
|
+
const slideId = typeof input.slideId === 'string' ? input.slideId.trim() : '';
|
|
1269
|
+
const regionId = typeof input.regionId === 'string' ? input.regionId.trim() : '';
|
|
1270
|
+
if (!slideId || !regionId) {
|
|
1271
|
+
return { success: false, data: null, errorMessage: 'duplicate_region requires slideId and regionId.' };
|
|
1272
|
+
}
|
|
1273
|
+
const deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
1274
|
+
const slide = deck.Slides.find((s) => s.SlideID === slideId);
|
|
1275
|
+
if (!slide) {
|
|
1276
|
+
return { success: false, data: null, errorMessage: `Slide "${slideId}" was not found.` };
|
|
1277
|
+
}
|
|
1278
|
+
const sourceIdx = slide.Regions.findIndex((r) => r.RegionID === regionId);
|
|
1279
|
+
if (sourceIdx < 0) {
|
|
1280
|
+
return { success: false, data: null, errorMessage: `Region "${regionId}" was not found on slide "${slideId}".` };
|
|
1281
|
+
}
|
|
1282
|
+
const lockContext = this.extractLockContext(context);
|
|
1283
|
+
const slidePerm = SlideDeckEngine.Instance.CanActorEditSlide(slide, lockContext.ActorUserID, lockContext.OwnerUserID, lockContext.IsEditor);
|
|
1284
|
+
if (!slidePerm.Allowed) {
|
|
1285
|
+
return { success: false, data: null, errorMessage: slidePerm.Reason };
|
|
1286
|
+
}
|
|
1287
|
+
const existingIds = new Set(slide.Regions.map((r) => r.RegionID));
|
|
1288
|
+
const requestedId = typeof input.newRegionId === 'string' ? input.newRegionId.trim() : '';
|
|
1289
|
+
let mintedId = requestedId || `${regionId}-copy-${randomUUID().slice(0, 6)}`;
|
|
1290
|
+
if (existingIds.has(mintedId)) {
|
|
1291
|
+
if (requestedId) {
|
|
1292
|
+
return { success: false, data: null, errorMessage: `RegionID '${requestedId}' already exists on slide '${slideId}'.` };
|
|
1293
|
+
}
|
|
1294
|
+
while (existingIds.has(mintedId)) {
|
|
1295
|
+
mintedId = `${regionId}-copy-${randomUUID().slice(0, 6)}`;
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
const source = slide.Regions[sourceIdx];
|
|
1299
|
+
const cloned = {
|
|
1300
|
+
...source,
|
|
1301
|
+
RegionID: mintedId,
|
|
1302
|
+
Locked: false,
|
|
1303
|
+
LockedByUserID: undefined,
|
|
1304
|
+
BlockSpec: source.BlockSpec ? { ...source.BlockSpec, BlockID: `${source.BlockSpec.BlockID}-${randomUUID().slice(0, 4)}` } : undefined
|
|
1305
|
+
};
|
|
1306
|
+
slide.Regions.splice(sourceIdx + 1, 0, cloned);
|
|
1307
|
+
const updatedContent = SlideDeckEngine.Instance.SerializeDeckSpec(deck);
|
|
1308
|
+
return {
|
|
1309
|
+
success: true,
|
|
1310
|
+
data: {
|
|
1311
|
+
slideId,
|
|
1312
|
+
sourceRegionId: regionId,
|
|
1313
|
+
regionId: mintedId,
|
|
1314
|
+
duplicatedRegion: cloned,
|
|
1315
|
+
revisionHash: this.ComputeRevisionHash(updatedContent),
|
|
1316
|
+
updatedContent
|
|
1317
|
+
}
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
handleAlignDistributeRegions(contentStr, input, context) {
|
|
1321
|
+
const revError = this.checkRevision(contentStr, input.expectedRevisionHash);
|
|
1322
|
+
if (revError) {
|
|
1323
|
+
return { success: false, data: null, errorMessage: revError };
|
|
1324
|
+
}
|
|
1325
|
+
const slideId = typeof input.slideId === 'string' ? input.slideId.trim() : '';
|
|
1326
|
+
const orderedRaw = Array.isArray(input.orderedRegionIds)
|
|
1327
|
+
? input.orderedRegionIds.filter((r) => typeof r === 'string' && r.trim().length > 0).map((r) => r.trim())
|
|
1328
|
+
: [];
|
|
1329
|
+
if (!slideId || orderedRaw.length === 0) {
|
|
1330
|
+
return { success: false, data: null, errorMessage: 'align_distribute_regions requires slideId and orderedRegionIds.' };
|
|
1331
|
+
}
|
|
1332
|
+
const deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
1333
|
+
const slide = deck.Slides.find((s) => s.SlideID === slideId);
|
|
1334
|
+
if (!slide) {
|
|
1335
|
+
return { success: false, data: null, errorMessage: `Slide "${slideId}" was not found.` };
|
|
1336
|
+
}
|
|
1337
|
+
const lockContext = this.extractLockContext(context);
|
|
1338
|
+
const slidePerm = SlideDeckEngine.Instance.CanActorEditSlide(slide, lockContext.ActorUserID, lockContext.OwnerUserID, lockContext.IsEditor);
|
|
1339
|
+
if (!slidePerm.Allowed) {
|
|
1340
|
+
return { success: false, data: null, errorMessage: slidePerm.Reason };
|
|
1341
|
+
}
|
|
1342
|
+
for (const r of slide.Regions) {
|
|
1343
|
+
const regPerm = SlideDeckEngine.Instance.CanActorEditRegion(slide, r, lockContext.ActorUserID, lockContext.OwnerUserID, lockContext.IsEditor);
|
|
1344
|
+
if (!regPerm.Allowed) {
|
|
1345
|
+
return { success: false, data: null, errorMessage: regPerm.Reason };
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
const byId = new Map(slide.Regions.map((r) => [r.RegionID, r]));
|
|
1349
|
+
const reordered = [];
|
|
1350
|
+
const seen = new Set();
|
|
1351
|
+
for (const rid of orderedRaw) {
|
|
1352
|
+
const match = byId.get(rid);
|
|
1353
|
+
if (!match) {
|
|
1354
|
+
return { success: false, data: null, errorMessage: `Region '${rid}' was not found on slide '${slideId}'.` };
|
|
1355
|
+
}
|
|
1356
|
+
if (!seen.has(rid)) {
|
|
1357
|
+
seen.add(rid);
|
|
1358
|
+
reordered.push(match);
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
for (const r of slide.Regions) {
|
|
1362
|
+
if (!seen.has(r.RegionID)) {
|
|
1363
|
+
reordered.push(r);
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
slide.Regions = reordered;
|
|
1367
|
+
const updatedContent = SlideDeckEngine.Instance.SerializeDeckSpec(deck);
|
|
1368
|
+
return {
|
|
1369
|
+
success: true,
|
|
1370
|
+
data: {
|
|
1371
|
+
slideId,
|
|
1372
|
+
regionOrder: reordered.map((r) => r.RegionID),
|
|
1373
|
+
revisionHash: this.ComputeRevisionHash(updatedContent),
|
|
1374
|
+
updatedContent
|
|
1375
|
+
}
|
|
1376
|
+
};
|
|
1377
|
+
}
|
|
1378
|
+
handleUpsertSpeakerNotes(contentStr, input, context) {
|
|
1379
|
+
if (input.append !== true) {
|
|
1380
|
+
return this.handleUpdateSpeakerNotes(contentStr, input, context);
|
|
1381
|
+
}
|
|
1382
|
+
const slideId = typeof input.slideId === 'string' ? input.slideId.trim() : '';
|
|
1383
|
+
const addition = typeof input.speakerNotes === 'string' ? input.speakerNotes : '';
|
|
1384
|
+
if (!slideId) {
|
|
1385
|
+
return { success: false, data: null, errorMessage: 'upsert_speaker_notes requires slideId.' };
|
|
1386
|
+
}
|
|
1387
|
+
const deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
1388
|
+
const slide = deck.Slides.find((s) => s.SlideID === slideId);
|
|
1389
|
+
if (!slide) {
|
|
1390
|
+
return { success: false, data: null, errorMessage: `Slide "${slideId}" was not found.` };
|
|
1391
|
+
}
|
|
1392
|
+
const combined = slide.SpeakerNotes?.trim() ? `${slide.SpeakerNotes.trimEnd()}\n\n${addition}` : addition;
|
|
1393
|
+
return this.handleUpdateSpeakerNotes(contentStr, { ...input, speakerNotes: combined }, context);
|
|
1394
|
+
}
|
|
1395
|
+
handleBatchMutateSlides(contentStr, input, context) {
|
|
1396
|
+
const revError = this.checkRevision(contentStr, input.expectedRevisionHash);
|
|
1397
|
+
if (revError) {
|
|
1398
|
+
return { success: false, data: null, errorMessage: revError };
|
|
1399
|
+
}
|
|
1400
|
+
const rawOps = Array.isArray(input.operations) ? input.operations : [];
|
|
1401
|
+
if (rawOps.length === 0) {
|
|
1402
|
+
return { success: false, data: null, errorMessage: 'batch_mutate_slides requires a non-empty operations array.' };
|
|
1403
|
+
}
|
|
1404
|
+
let deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
1405
|
+
const lockContext = this.extractLockContext(context);
|
|
1406
|
+
const validatedOps = [];
|
|
1407
|
+
for (const item of rawOps) {
|
|
1408
|
+
if (!item || typeof item !== 'object' || Array.isArray(item))
|
|
1409
|
+
continue;
|
|
1410
|
+
const op = item;
|
|
1411
|
+
const slideId = typeof op.slideId === 'string' ? op.slideId.trim() : '';
|
|
1412
|
+
if (!slideId) {
|
|
1413
|
+
return { success: false, data: null, errorMessage: 'Each operation in batch_mutate_slides requires slideId.' };
|
|
1414
|
+
}
|
|
1415
|
+
const slide = deck.Slides.find((s) => s.SlideID === slideId);
|
|
1416
|
+
if (!slide) {
|
|
1417
|
+
return { success: false, data: null, errorMessage: `Slide "${slideId}" was not found.` };
|
|
1418
|
+
}
|
|
1419
|
+
const perm = SlideDeckEngine.Instance.CanActorEditSlide(slide, lockContext.ActorUserID, lockContext.OwnerUserID, lockContext.IsEditor);
|
|
1420
|
+
if (!perm.Allowed) {
|
|
1421
|
+
return { success: false, data: null, errorMessage: perm.Reason };
|
|
1422
|
+
}
|
|
1423
|
+
validatedOps.push({
|
|
1424
|
+
slideId,
|
|
1425
|
+
patch: {
|
|
1426
|
+
Title: typeof op.title === 'string' ? op.title : undefined,
|
|
1427
|
+
Subtitle: typeof op.subtitle === 'string' ? op.subtitle : undefined,
|
|
1428
|
+
Layout: typeof op.layout === 'string' ? op.layout : undefined,
|
|
1429
|
+
SpeakerNotes: typeof op.speakerNotes === 'string' ? op.speakerNotes : undefined,
|
|
1430
|
+
Hidden: typeof op.hidden === 'boolean' ? op.hidden : undefined
|
|
1431
|
+
}
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
for (const op of validatedOps) {
|
|
1435
|
+
const res = SlideDeckEngine.Instance.UpdateSlideMetadata(deck, op.slideId, op.patch, lockContext);
|
|
1436
|
+
deck = res.Deck;
|
|
1437
|
+
}
|
|
1438
|
+
const updatedContent = SlideDeckEngine.Instance.SerializeDeckSpec(deck);
|
|
1439
|
+
return {
|
|
1440
|
+
success: true,
|
|
1441
|
+
data: {
|
|
1442
|
+
updatedSlideIds: validatedOps.map((o) => o.slideId),
|
|
1443
|
+
updatedCount: validatedOps.length,
|
|
1444
|
+
revisionHash: this.ComputeRevisionHash(updatedContent),
|
|
1445
|
+
updatedContent
|
|
1446
|
+
}
|
|
1447
|
+
};
|
|
1448
|
+
}
|
|
1449
|
+
handleToggleSlideLock(contentStr, input, locked, context) {
|
|
1450
|
+
const revError = this.checkRevision(contentStr, input.expectedRevisionHash);
|
|
1451
|
+
if (revError) {
|
|
1452
|
+
return { success: false, data: null, errorMessage: revError };
|
|
1453
|
+
}
|
|
1454
|
+
const slideId = typeof input.slideId === 'string' ? input.slideId.trim() : '';
|
|
1455
|
+
if (!slideId) {
|
|
1456
|
+
return { success: false, data: null, errorMessage: 'set_lock / release_lock requires slideId.' };
|
|
1457
|
+
}
|
|
1458
|
+
const regionId = typeof input.regionId === 'string' && input.regionId.trim() ? input.regionId.trim() : undefined;
|
|
1459
|
+
const allowEditors = input.allowEditors === true;
|
|
1460
|
+
const lockContext = this.extractLockContext(context);
|
|
1461
|
+
const actorUserId = lockContext.ActorUserID ?? lockContext.OwnerUserID ?? 'system';
|
|
1462
|
+
const deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
1463
|
+
try {
|
|
1464
|
+
if (regionId) {
|
|
1465
|
+
const { Deck: updatedDeck, UpdatedRegion } = SlideDeckEngine.Instance.SetRegionLock(deck, slideId, regionId, locked, actorUserId, allowEditors, lockContext.OwnerUserID);
|
|
1466
|
+
if (!UpdatedRegion) {
|
|
1467
|
+
return { success: false, data: null, errorMessage: `Slide '${slideId}' or region '${regionId}' not found.` };
|
|
1468
|
+
}
|
|
1469
|
+
const updatedContent = SlideDeckEngine.Instance.SerializeDeckSpec(updatedDeck);
|
|
1470
|
+
return {
|
|
1471
|
+
success: true,
|
|
1472
|
+
data: {
|
|
1473
|
+
slideId,
|
|
1474
|
+
regionId,
|
|
1475
|
+
locked: UpdatedRegion.Locked,
|
|
1476
|
+
revisionHash: this.ComputeRevisionHash(updatedContent),
|
|
1477
|
+
updatedContent
|
|
1478
|
+
}
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1481
|
+
const { Deck: updatedDeck, UpdatedSlide } = SlideDeckEngine.Instance.SetSlideLock(deck, slideId, locked, actorUserId, allowEditors, lockContext.OwnerUserID);
|
|
1482
|
+
if (!UpdatedSlide) {
|
|
1483
|
+
return { success: false, data: null, errorMessage: `Slide '${slideId}' not found.` };
|
|
1484
|
+
}
|
|
1485
|
+
const updatedContent = SlideDeckEngine.Instance.SerializeDeckSpec(updatedDeck);
|
|
1486
|
+
return {
|
|
1487
|
+
success: true,
|
|
1488
|
+
data: {
|
|
1489
|
+
slideId,
|
|
1490
|
+
locked: UpdatedSlide.Locked,
|
|
1491
|
+
revisionHash: this.ComputeRevisionHash(updatedContent),
|
|
1492
|
+
updatedContent
|
|
1493
|
+
}
|
|
1494
|
+
};
|
|
1495
|
+
}
|
|
1496
|
+
catch (err) {
|
|
1497
|
+
return { success: false, data: null, errorMessage: err instanceof Error ? err.message : String(err) };
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
resolveTargetSlideFromAnchor(deck, slideId, slideNumber) {
|
|
1501
|
+
if (slideId) {
|
|
1502
|
+
const byId = deck.Slides.find((s) => s.SlideID === slideId);
|
|
1503
|
+
if (byId)
|
|
1504
|
+
return byId;
|
|
1505
|
+
}
|
|
1506
|
+
if (typeof slideNumber === 'number' && Number.isFinite(slideNumber)) {
|
|
1507
|
+
return deck.Slides.find((s) => s.SlideNumber === slideNumber) ?? deck.Slides[slideNumber - 1];
|
|
1508
|
+
}
|
|
1509
|
+
return undefined;
|
|
1510
|
+
}
|
|
1511
|
+
async handleProposeSuggestion(contentStr, input, context) {
|
|
1512
|
+
const deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
1513
|
+
return ExecuteProposeSuggestionTool({
|
|
1514
|
+
domain: 'slides',
|
|
1515
|
+
artifactContent: contentStr,
|
|
1516
|
+
input,
|
|
1517
|
+
context,
|
|
1518
|
+
validateTarget: (anchor, originalSlice) => {
|
|
1519
|
+
const targetRegionId = anchor.RegionId ?? anchor.ElementId;
|
|
1520
|
+
const slide = this.resolveTargetSlideFromAnchor(deck, anchor.SlideId, anchor.SlideNumber) ??
|
|
1521
|
+
(targetRegionId
|
|
1522
|
+
? deck.Slides.find((s) => s.Regions.some((r) => r.RegionID === targetRegionId))
|
|
1523
|
+
: undefined);
|
|
1524
|
+
if (!slide) {
|
|
1525
|
+
return {
|
|
1526
|
+
ok: false,
|
|
1527
|
+
errorMessage: `Target slide '${anchor.SlideId ?? String(anchor.SlideNumber ?? targetRegionId ?? '')}' was not found.`
|
|
1528
|
+
};
|
|
1529
|
+
}
|
|
1530
|
+
if (targetRegionId) {
|
|
1531
|
+
const region = slide.Regions.find((r) => r.RegionID === targetRegionId);
|
|
1532
|
+
if (!region) {
|
|
1533
|
+
return { ok: false, errorMessage: `Target region '${targetRegionId}' was not found on slide '${slide.SlideID}'.` };
|
|
1534
|
+
}
|
|
1535
|
+
if (originalSlice && !region.MarkdownContent.includes(originalSlice)) {
|
|
1536
|
+
return {
|
|
1537
|
+
ok: false,
|
|
1538
|
+
errorMessage: `originalSlice was not found inside region '${targetRegionId}' on slide '${slide.SlideID}'.`
|
|
1539
|
+
};
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
return {
|
|
1543
|
+
ok: true,
|
|
1544
|
+
resolvedAnchor: {
|
|
1545
|
+
...anchor,
|
|
1546
|
+
SlideId: slide.SlideID,
|
|
1547
|
+
SlideNumber: slide.SlideNumber,
|
|
1548
|
+
...(targetRegionId && !anchor.RegionId ? { RegionId: targetRegionId } : {})
|
|
1549
|
+
}
|
|
1550
|
+
};
|
|
1551
|
+
}
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
async handleReviewSuggestion(contentStr, input, context) {
|
|
1555
|
+
const deck = SlideDeckEngine.Instance.ParseDeckSpec(contentStr);
|
|
1556
|
+
return ExecuteReviewSuggestionTool({
|
|
1557
|
+
domain: 'slides',
|
|
1558
|
+
artifactContent: contentStr,
|
|
1559
|
+
input,
|
|
1560
|
+
context,
|
|
1561
|
+
applyAcceptedSuggestion: async (suggestion) => {
|
|
1562
|
+
const targetAnchor = ParseSuggestionAnchor(suggestion.Anchor, 'slides');
|
|
1563
|
+
const slide = this.resolveTargetSlideFromAnchor(deck, targetAnchor.SlideId, targetAnchor.SlideNumber);
|
|
1564
|
+
if (!slide) {
|
|
1565
|
+
return { ok: false, errorMessage: 'Suggestion target slide was not found.' };
|
|
1566
|
+
}
|
|
1567
|
+
const lockContext = this.extractLockContext(context);
|
|
1568
|
+
const targetRegionId = targetAnchor.RegionId ?? targetAnchor.ElementId;
|
|
1569
|
+
try {
|
|
1570
|
+
if (targetRegionId) {
|
|
1571
|
+
const region = slide.Regions.find((r) => r.RegionID === targetRegionId);
|
|
1572
|
+
if (!region) {
|
|
1573
|
+
return { ok: false, errorMessage: `Suggestion target region '${targetRegionId}' was not found.` };
|
|
1574
|
+
}
|
|
1575
|
+
if (suggestion.OriginalSlice && !region.MarkdownContent.includes(suggestion.OriginalSlice)) {
|
|
1576
|
+
return { ok: false, errorMessage: `originalSlice is stale for region '${targetRegionId}'.` };
|
|
1577
|
+
}
|
|
1578
|
+
const nextMarkdown = suggestion.OriginalSlice
|
|
1579
|
+
? region.MarkdownContent.replace(suggestion.OriginalSlice, () => suggestion.ProposedReplacement)
|
|
1580
|
+
: suggestion.ProposedReplacement;
|
|
1581
|
+
const { Deck: updatedDeck } = SlideDeckEngine.Instance.UpsertSlideRegion(deck, slide.SlideID, { RegionID: targetRegionId, MarkdownContent: nextMarkdown }, lockContext);
|
|
1582
|
+
const updatedContent = SlideDeckEngine.Instance.SerializeDeckSpec(updatedDeck);
|
|
1583
|
+
return {
|
|
1584
|
+
ok: true,
|
|
1585
|
+
updatedContent,
|
|
1586
|
+
revisionHash: this.ComputeRevisionHash(updatedContent),
|
|
1587
|
+
extra: { slideId: slide.SlideID, regionId: targetRegionId }
|
|
1588
|
+
};
|
|
1589
|
+
}
|
|
1590
|
+
const nextTitle = suggestion.OriginalSlice && slide.Title.includes(suggestion.OriginalSlice)
|
|
1591
|
+
? slide.Title.replace(suggestion.OriginalSlice, () => suggestion.ProposedReplacement)
|
|
1592
|
+
: suggestion.ProposedReplacement;
|
|
1593
|
+
const { Deck: updatedDeck } = SlideDeckEngine.Instance.UpdateSlideMetadata(deck, slide.SlideID, { Title: nextTitle }, lockContext);
|
|
1594
|
+
const updatedContent = SlideDeckEngine.Instance.SerializeDeckSpec(updatedDeck);
|
|
1595
|
+
return {
|
|
1596
|
+
ok: true,
|
|
1597
|
+
updatedContent,
|
|
1598
|
+
revisionHash: this.ComputeRevisionHash(updatedContent),
|
|
1599
|
+
extra: { slideId: slide.SlideID }
|
|
1600
|
+
};
|
|
1601
|
+
}
|
|
1602
|
+
catch (err) {
|
|
1603
|
+
return { ok: false, errorMessage: err instanceof Error ? err.message : String(err) };
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
});
|
|
1607
|
+
}
|
|
1608
|
+
};
|
|
1609
|
+
SlideDeckToolLibrary = __decorate([
|
|
1610
|
+
RegisterClass(BaseArtifactToolLibrary, 'SlideDeckToolLibrary')
|
|
1611
|
+
], SlideDeckToolLibrary);
|
|
1612
|
+
export { SlideDeckToolLibrary };
|
|
1613
|
+
/** Tree-shaking prevention loader for {@link SlideDeckToolLibrary}. */
|
|
1614
|
+
export function LoadSlideDeckToolLibrary() {
|
|
1615
|
+
// Ensures @RegisterClass decorator executes when imported.
|
|
1616
|
+
}
|
|
1617
|
+
//# sourceMappingURL=SlideDeckToolLibrary.js.map
|