ultravisor 1.0.3 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/launch.json +11 -0
- package/.claude/ultravisor-dev-config.json +3 -0
- package/card-audit.json +1545 -0
- package/docs/_sidebar.md +17 -0
- package/docs/css/docuserve.css +73 -0
- package/docs/features/beacon-authentication.md +209 -0
- package/docs/features/beacon-providers.md +1299 -0
- package/docs/features/beacons.md +530 -0
- package/docs/features/capabilities.md +193 -0
- package/docs/features/llm-model-setup.md +505 -0
- package/docs/features/llm.md +262 -0
- package/docs/features/tasks-content-system.md +110 -0
- package/docs/features/tasks-data-transform.md +233 -0
- package/docs/features/tasks-extension.md +36 -0
- package/docs/features/tasks-file-system.md +203 -0
- package/docs/features/tasks-flow-control.md +125 -0
- package/docs/features/tasks-http-client.md +119 -0
- package/docs/features/tasks-llm.md +118 -0
- package/docs/features/tasks-meadow-api.md +163 -0
- package/docs/features/tasks-user-interaction.md +49 -0
- package/docs/features/tasks.md +14 -0
- package/docs/index.html +1 -1
- package/docs/retold-catalog.json +1 -1
- package/docs/retold-keyword-index.json +17374 -5
- package/operation-library/api-data-pipeline.json +143 -0
- package/operation-library/beacon-remote-command.json +72 -0
- package/operation-library/conditional-file-backup.json +143 -0
- package/operation-library/config-processor.json +136 -0
- package/operation-library/csv-data-analysis.json +228 -0
- package/operation-library/csv-to-json.json +160 -0
- package/operation-library/directory-inventory.json +128 -0
- package/operation-library/expression-calculator.json +114 -0
- package/operation-library/file-search-replace.json +175 -0
- package/operation-library/git-status-report.json +368 -0
- package/operation-library/health-check-ping.json +329 -0
- package/operation-library/json-config-merge.json +313 -0
- package/operation-library/llm-embedding-tool-use.json +314 -0
- package/operation-library/llm-multi-turn-analysis.json +322 -0
- package/operation-library/llm-summarize.json +264 -0
- package/operation-library/log-line-counter.json +185 -0
- package/operation-library/meadow-crud-lifecycle.json +264 -0
- package/operation-library/npm-project-validator.json +193 -0
- package/operation-library/rest-api-orchestrator.json +218 -0
- package/operation-library/shell-system-info.json +137 -0
- package/operation-library/simple-echo.json +95 -0
- package/operation-library/template-processor.json +299 -0
- package/operation-library/text-sanitizer.json +176 -0
- package/package.json +12 -8
- package/source/Ultravisor.cjs +30 -3
- package/source/beacon/Ultravisor-Beacon-CLI.cjs +143 -0
- package/source/beacon/Ultravisor-Beacon-CapabilityProvider.cjs +129 -0
- package/source/beacon/Ultravisor-Beacon-Client.cjs +568 -0
- package/source/beacon/Ultravisor-Beacon-Executor.cjs +500 -0
- package/source/beacon/Ultravisor-Beacon-ProviderRegistry.cjs +330 -0
- package/source/beacon/providers/Ultravisor-Beacon-Provider-FileSystem.cjs +331 -0
- package/source/beacon/providers/Ultravisor-Beacon-Provider-LLM.cjs +966 -0
- package/source/beacon/providers/Ultravisor-Beacon-Provider-Shell.cjs +95 -0
- package/source/cli/Ultravisor-CLIProgram.cjs +44 -22
- package/source/cli/commands/Ultravisor-Command-SingleOperation.cjs +29 -18
- package/source/cli/commands/Ultravisor-Command-SingleTask.cjs +62 -19
- package/source/cli/commands/Ultravisor-Command-UpdateTask.cjs +27 -15
- package/source/config/Ultravisor-Default-Command-Configuration.cjs +12 -3
- package/source/services/Ultravisor-Beacon-Coordinator.cjs +966 -0
- package/source/services/Ultravisor-ExecutionEngine.cjs +1093 -0
- package/source/services/Ultravisor-ExecutionManifest.cjs +629 -0
- package/source/services/Ultravisor-Hypervisor-State.cjs +270 -97
- package/source/services/Ultravisor-Hypervisor.cjs +185 -75
- package/source/services/Ultravisor-Schedule-Persistence-Base.cjs +45 -0
- package/source/services/Ultravisor-StateManager.cjs +253 -0
- package/source/services/Ultravisor-TaskTypeRegistry.cjs +213 -0
- package/source/services/persistence/Ultravisor-Schedule-Persistence-JSONFile.cjs +140 -0
- package/source/services/tasks/Ultravisor-BuiltIn-TaskConfigs.cjs +19 -0
- package/source/services/tasks/Ultravisor-TaskHelper-BeaconDispatch.cjs +107 -0
- package/source/services/tasks/Ultravisor-TaskType-Base.cjs +125 -0
- package/source/services/tasks/content-system/Ultravisor-TaskConfigs-ContentSystem.cjs +90 -0
- package/source/services/tasks/content-system/definitions/content-create-folder.json +24 -0
- package/source/services/tasks/content-system/definitions/content-list-files.json +27 -0
- package/source/services/tasks/content-system/definitions/content-read-file.json +26 -0
- package/source/services/tasks/content-system/definitions/content-save-file.json +26 -0
- package/source/services/tasks/data-transform/Ultravisor-TaskConfigs-DataTransform.cjs +577 -0
- package/source/services/tasks/data-transform/Ultravisor-TaskType-ReplaceString.cjs +80 -0
- package/source/services/tasks/data-transform/Ultravisor-TaskType-SetValues.cjs +74 -0
- package/source/services/tasks/data-transform/Ultravisor-TaskType-StringAppender.cjs +90 -0
- package/source/services/tasks/data-transform/definitions/comprehension-intersect.json +24 -0
- package/source/services/tasks/data-transform/definitions/csv-transform.json +24 -0
- package/source/services/tasks/data-transform/definitions/expression-solver.json +20 -0
- package/source/services/tasks/data-transform/definitions/histogram.json +23 -0
- package/source/services/tasks/data-transform/definitions/parse-csv.json +27 -0
- package/source/services/tasks/data-transform/definitions/replace-string.json +27 -0
- package/source/services/tasks/data-transform/definitions/set-values.json +17 -0
- package/source/services/tasks/data-transform/definitions/string-appender.json +22 -0
- package/source/services/tasks/data-transform/definitions/template-string.json +20 -0
- package/source/services/tasks/extension/Ultravisor-TaskConfigs-Extension.cjs +87 -0
- package/source/services/tasks/extension/definitions/beacon-dispatch.json +32 -0
- package/source/services/tasks/file-system/Ultravisor-TaskConfigs-FileSystem.cjs +509 -0
- package/source/services/tasks/file-system/Ultravisor-TaskType-ReadFile.cjs +96 -0
- package/source/services/tasks/file-system/Ultravisor-TaskType-ReadFileBuffered.cjs +123 -0
- package/source/services/tasks/file-system/Ultravisor-TaskType-WriteFile.cjs +106 -0
- package/source/services/tasks/file-system/definitions/copy-file.json +27 -0
- package/source/services/tasks/file-system/definitions/list-files.json +27 -0
- package/source/services/tasks/file-system/definitions/read-file-buffered.json +31 -0
- package/source/services/tasks/file-system/definitions/read-file.json +26 -0
- package/source/services/tasks/file-system/definitions/read-json.json +23 -0
- package/source/services/tasks/file-system/definitions/write-file.json +29 -0
- package/source/services/tasks/file-system/definitions/write-json.json +30 -0
- package/source/services/tasks/flow-control/Ultravisor-TaskConfigs-FlowControl.cjs +353 -0
- package/source/services/tasks/flow-control/Ultravisor-TaskType-IfConditional.cjs +125 -0
- package/source/services/tasks/flow-control/Ultravisor-TaskType-LaunchOperation.cjs +186 -0
- package/source/services/tasks/flow-control/Ultravisor-TaskType-SplitExecute.cjs +164 -0
- package/source/services/tasks/flow-control/definitions/if-conditional.json +25 -0
- package/source/services/tasks/flow-control/definitions/launch-operation.json +27 -0
- package/source/services/tasks/flow-control/definitions/split-execute.json +32 -0
- package/source/services/tasks/http-client/Ultravisor-TaskConfigs-HttpClient.cjs +281 -0
- package/source/services/tasks/http-client/definitions/get-json.json +26 -0
- package/source/services/tasks/http-client/definitions/get-text.json +26 -0
- package/source/services/tasks/http-client/definitions/rest-request.json +32 -0
- package/source/services/tasks/http-client/definitions/send-json.json +28 -0
- package/source/services/tasks/llm/Ultravisor-TaskConfigs-LLM.cjs +605 -0
- package/source/services/tasks/llm/definitions/llm-chat-completion.json +46 -0
- package/source/services/tasks/llm/definitions/llm-embedding.json +31 -0
- package/source/services/tasks/llm/definitions/llm-tool-use.json +42 -0
- package/source/services/tasks/meadow-api/Ultravisor-TaskConfigs-MeadowApi.cjs +341 -0
- package/source/services/tasks/meadow-api/definitions/meadow-count.json +26 -0
- package/source/services/tasks/meadow-api/definitions/meadow-create.json +26 -0
- package/source/services/tasks/meadow-api/definitions/meadow-delete.json +23 -0
- package/source/services/tasks/meadow-api/definitions/meadow-read.json +26 -0
- package/source/services/tasks/meadow-api/definitions/meadow-reads.json +29 -0
- package/source/services/tasks/meadow-api/definitions/meadow-update.json +26 -0
- package/source/services/tasks/shell/Ultravisor-TaskConfigs-Shell.cjs +63 -0
- package/source/services/tasks/shell/definitions/command.json +29 -0
- package/source/services/tasks/user-interaction/Ultravisor-TaskConfigs-UserInteraction.cjs +64 -0
- package/source/services/tasks/user-interaction/Ultravisor-TaskType-ErrorMessage.cjs +55 -0
- package/source/services/tasks/user-interaction/Ultravisor-TaskType-ValueInput.cjs +47 -0
- package/source/services/tasks/user-interaction/definitions/error-message.json +18 -0
- package/source/services/tasks/user-interaction/definitions/value-input.json +23 -0
- package/source/web_server/Ultravisor-API-Server.cjs +849 -124
- package/test/Ultravisor_browser_tests.js +2226 -0
- package/test/Ultravisor_operation_library_tests.js +894 -0
- package/test/Ultravisor_tests.js +4946 -5044
- package/test/workflows/test-content-concatenate-all.json +339 -0
- package/test/workflows/test-content-full-pipeline.json +159 -0
- package/test/workflows/test-content-list-files.json +76 -0
- package/test/workflows/test-content-save-and-read.json +106 -0
- package/webinterface/css/ultravisor-themes.css +668 -0
- package/webinterface/css/ultravisor.css +37 -14
- package/webinterface/docs/card-help/beacon-dispatch.md +30 -0
- package/webinterface/docs/card-help/command.md +27 -0
- package/webinterface/docs/card-help/comprehension-intersect.md +24 -0
- package/webinterface/docs/card-help/content-create-folder.md +22 -0
- package/webinterface/docs/card-help/content-list-files.md +25 -0
- package/webinterface/docs/card-help/content-read-file.md +24 -0
- package/webinterface/docs/card-help/content-save-file.md +24 -0
- package/webinterface/docs/card-help/copy-file.md +25 -0
- package/webinterface/docs/card-help/csv-transform.md +24 -0
- package/webinterface/docs/card-help/end.md +11 -0
- package/webinterface/docs/card-help/error-message.md +16 -0
- package/webinterface/docs/card-help/expression-solver.md +21 -0
- package/webinterface/docs/card-help/get-json.md +24 -0
- package/webinterface/docs/card-help/get-text.md +24 -0
- package/webinterface/docs/card-help/histogram.md +23 -0
- package/webinterface/docs/card-help/if-conditional.md +23 -0
- package/webinterface/docs/card-help/launch-operation.md +25 -0
- package/webinterface/docs/card-help/list-files.md +25 -0
- package/webinterface/docs/card-help/llm-chat-completion.md +43 -0
- package/webinterface/docs/card-help/llm-embedding.md +24 -0
- package/webinterface/docs/card-help/llm-tool-use.md +39 -0
- package/webinterface/docs/card-help/meadow-count.md +24 -0
- package/webinterface/docs/card-help/meadow-create.md +24 -0
- package/webinterface/docs/card-help/meadow-delete.md +19 -0
- package/webinterface/docs/card-help/meadow-read.md +24 -0
- package/webinterface/docs/card-help/meadow-reads.md +27 -0
- package/webinterface/docs/card-help/meadow-update.md +24 -0
- package/webinterface/docs/card-help/parse-csv.md +27 -0
- package/webinterface/docs/card-help/read-file-buffered.md +29 -0
- package/webinterface/docs/card-help/read-file.md +24 -0
- package/webinterface/docs/card-help/read-json.md +21 -0
- package/webinterface/docs/card-help/replace-string.md +25 -0
- package/webinterface/docs/card-help/rest-request.md +30 -0
- package/webinterface/docs/card-help/send-json.md +26 -0
- package/webinterface/docs/card-help/set-values.md +16 -0
- package/webinterface/docs/card-help/split-execute.md +35 -0
- package/webinterface/docs/card-help/start.md +11 -0
- package/webinterface/docs/card-help/string-appender.md +22 -0
- package/webinterface/docs/card-help/template-string.md +21 -0
- package/webinterface/docs/card-help/value-input.md +24 -0
- package/webinterface/docs/card-help/write-file.md +27 -0
- package/webinterface/docs/card-help/write-json.md +28 -0
- package/webinterface/html/index.html +5 -0
- package/webinterface/package.json +13 -4
- package/webinterface/source/Pict-Application-Ultravisor.js +564 -70
- package/webinterface/source/Ultravisor-TimingUtils.js +99 -0
- package/webinterface/source/card-help-content.js +46 -0
- package/webinterface/source/cards/Ultravisor-BuiltIn-CardConfigs.js +174 -0
- package/webinterface/source/cards/Ultravisor-CardConfigGenerator.js +431 -0
- package/webinterface/source/data/ExampleFlow-CSVPipeline.js +231 -0
- package/webinterface/source/data/ExampleFlow-FileProcessor.js +315 -0
- package/webinterface/source/data/ExampleFlow-MeadowPipeline.js +328 -0
- package/webinterface/source/panels/Ultravisor-CardSettingsPanel.js +902 -0
- package/webinterface/source/providers/PictRouter-Ultravisor-Configuration.json +20 -8
- package/webinterface/source/views/PictView-Ultravisor-BeaconList.js +817 -0
- package/webinterface/source/views/PictView-Ultravisor-BottomBar.js +5 -5
- package/webinterface/source/views/PictView-Ultravisor-Dashboard.js +25 -25
- package/webinterface/source/views/PictView-Ultravisor-Documentation.js +856 -0
- package/webinterface/source/views/PictView-Ultravisor-FlowEditor.js +777 -0
- package/webinterface/source/views/PictView-Ultravisor-ManifestList.js +321 -58
- package/webinterface/source/views/PictView-Ultravisor-OperationEdit.js +36 -91
- package/webinterface/source/views/PictView-Ultravisor-OperationList.js +388 -16
- package/webinterface/source/views/PictView-Ultravisor-PendingInput.js +314 -0
- package/webinterface/source/views/PictView-Ultravisor-Schedule.js +521 -65
- package/webinterface/source/views/PictView-Ultravisor-TimingView.js +333 -71
- package/webinterface/source/views/PictView-Ultravisor-TopBar.js +257 -21
- package/webinterface/theme-sampler.html +645 -0
- package/debug/Harness.js +0 -6
- package/source/services/Ultravisor-Operation-Manifest.cjs +0 -160
- package/source/services/Ultravisor-Operation.cjs +0 -200
- package/source/services/Ultravisor-Task.cjs +0 -349
- package/source/services/events/Ultravisor-Hypervisor-Event-Solver.cjs +0 -11
- package/source/services/tasks/Ultravisor-Task-Base.cjs +0 -264
- package/source/services/tasks/Ultravisor-Task-CollectValues.cjs +0 -188
- package/source/services/tasks/Ultravisor-Task-Command.cjs +0 -65
- package/source/services/tasks/Ultravisor-Task-CommandEach.cjs +0 -190
- package/source/services/tasks/Ultravisor-Task-Conditional.cjs +0 -104
- package/source/services/tasks/Ultravisor-Task-DateWindow.cjs +0 -72
- package/source/services/tasks/Ultravisor-Task-GeneratePagedOperation.cjs +0 -336
- package/source/services/tasks/Ultravisor-Task-LaunchOperation.cjs +0 -143
- package/source/services/tasks/Ultravisor-Task-LaunchTask.cjs +0 -146
- package/source/services/tasks/Ultravisor-Task-LineMatch.cjs +0 -158
- package/source/services/tasks/Ultravisor-Task-Request.cjs +0 -56
- package/source/services/tasks/Ultravisor-Task-Solver.cjs +0 -89
- package/source/services/tasks/Ultravisor-Task-TemplateString.cjs +0 -93
- package/source/services/tasks/rest/Ultravisor-Task-GetBinary.cjs +0 -127
- package/source/services/tasks/rest/Ultravisor-Task-GetJSON.cjs +0 -119
- package/source/services/tasks/rest/Ultravisor-Task-GetText.cjs +0 -109
- package/source/services/tasks/rest/Ultravisor-Task-GetXML.cjs +0 -112
- package/source/services/tasks/rest/Ultravisor-Task-RestRequest.cjs +0 -499
- package/source/services/tasks/rest/Ultravisor-Task-SendJSON.cjs +0 -150
- package/source/services/tasks/stagingfiles/Ultravisor-Task-CopyFile.cjs +0 -110
- package/source/services/tasks/stagingfiles/Ultravisor-Task-ListFiles.cjs +0 -89
- package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadBinary.cjs +0 -87
- package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadJSON.cjs +0 -67
- package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadText.cjs +0 -66
- package/source/services/tasks/stagingfiles/Ultravisor-Task-ReadXML.cjs +0 -69
- package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteBinary.cjs +0 -95
- package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteJSON.cjs +0 -96
- package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteText.cjs +0 -99
- package/source/services/tasks/stagingfiles/Ultravisor-Task-WriteXML.cjs +0 -102
- package/webinterface/source/views/PictView-Ultravisor-TaskEdit.js +0 -220
- package/webinterface/source/views/PictView-Ultravisor-TaskList.js +0 -248
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
const libPictService = require('pict-serviceproviderbase');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Registry of all available task type classes and configs.
|
|
5
|
+
*
|
|
6
|
+
* Task types can be registered either as classes (via registerTaskType) or
|
|
7
|
+
* as config objects (via registerTaskTypeFromConfig). Both paths produce
|
|
8
|
+
* instances that the ExecutionEngine can execute.
|
|
9
|
+
*/
|
|
10
|
+
class UltravisorTaskTypeRegistry extends libPictService
|
|
11
|
+
{
|
|
12
|
+
constructor(pPict, pOptions, pServiceHash)
|
|
13
|
+
{
|
|
14
|
+
super(pPict, pOptions, pServiceHash);
|
|
15
|
+
|
|
16
|
+
this.serviceType = 'UltravisorTaskTypeRegistry';
|
|
17
|
+
|
|
18
|
+
// Map of task type hash -> task type class (class-based registration)
|
|
19
|
+
this._TaskTypes = {};
|
|
20
|
+
|
|
21
|
+
// Map of task type hash -> config object (config-based registration)
|
|
22
|
+
this._TaskTypeConfigs = {};
|
|
23
|
+
|
|
24
|
+
// Map of task type hash -> definition (cached from either path)
|
|
25
|
+
this._Definitions = {};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Register a task type class.
|
|
30
|
+
*
|
|
31
|
+
* @param {Function} pTaskTypeClass - A class extending UltravisorTaskType.
|
|
32
|
+
* @returns {object|false} The task type definition, or false on failure.
|
|
33
|
+
*/
|
|
34
|
+
registerTaskType(pTaskTypeClass)
|
|
35
|
+
{
|
|
36
|
+
if (typeof(pTaskTypeClass) !== 'function')
|
|
37
|
+
{
|
|
38
|
+
this.log.error('UltravisorTaskTypeRegistry: registerTaskType requires a constructor function.');
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Instantiate temporarily to read the definition
|
|
43
|
+
let tmpInstance = new pTaskTypeClass(this.fable, {}, `TaskType-Probe-${Date.now()}`);
|
|
44
|
+
let tmpDefinition = tmpInstance.definition;
|
|
45
|
+
|
|
46
|
+
if (!tmpDefinition || !tmpDefinition.Hash)
|
|
47
|
+
{
|
|
48
|
+
this.log.error('UltravisorTaskTypeRegistry: task type class must have a definition with a Hash.');
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
this._TaskTypes[tmpDefinition.Hash] = pTaskTypeClass;
|
|
53
|
+
this._Definitions[tmpDefinition.Hash] = tmpDefinition;
|
|
54
|
+
|
|
55
|
+
this.log.info(`UltravisorTaskTypeRegistry: registered task type [${tmpDefinition.Hash}] "${tmpDefinition.Name}"`);
|
|
56
|
+
|
|
57
|
+
return tmpDefinition;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Register a task type from a config object.
|
|
62
|
+
*
|
|
63
|
+
* @param {object} pConfig - Config object with:
|
|
64
|
+
* Definition {object} - Task type definition (Hash, Name, EventInputs, etc.)
|
|
65
|
+
* Execute {function} - Optional. function(pTaskInstance, pResolvedSettings, pExecutionContext, fCallback, fFireIntermediateEvent)
|
|
66
|
+
* @returns {object|false} The task type definition, or false on failure.
|
|
67
|
+
*/
|
|
68
|
+
registerTaskTypeFromConfig(pConfig)
|
|
69
|
+
{
|
|
70
|
+
if (!pConfig || typeof(pConfig) !== 'object')
|
|
71
|
+
{
|
|
72
|
+
this.log.error('UltravisorTaskTypeRegistry: registerTaskTypeFromConfig requires a config object.');
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let tmpDefinition = pConfig.Definition;
|
|
77
|
+
|
|
78
|
+
if (!tmpDefinition || !tmpDefinition.Hash)
|
|
79
|
+
{
|
|
80
|
+
this.log.error('UltravisorTaskTypeRegistry: config must have a Definition with a Hash.');
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
this._TaskTypeConfigs[tmpDefinition.Hash] = pConfig;
|
|
85
|
+
this._Definitions[tmpDefinition.Hash] = tmpDefinition;
|
|
86
|
+
|
|
87
|
+
this.log.info(`UltravisorTaskTypeRegistry: registered config-driven task type [${tmpDefinition.Hash}] "${tmpDefinition.Name}"`);
|
|
88
|
+
|
|
89
|
+
return tmpDefinition;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Register multiple task types from an array of config objects.
|
|
94
|
+
*
|
|
95
|
+
* @param {Array} pConfigs - Array of config objects.
|
|
96
|
+
* @returns {number} Number of successfully registered task types.
|
|
97
|
+
*/
|
|
98
|
+
registerTaskTypesFromConfigArray(pConfigs)
|
|
99
|
+
{
|
|
100
|
+
if (!Array.isArray(pConfigs))
|
|
101
|
+
{
|
|
102
|
+
this.log.error('UltravisorTaskTypeRegistry: registerTaskTypesFromConfigArray requires an array.');
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
let tmpCount = 0;
|
|
107
|
+
|
|
108
|
+
for (let i = 0; i < pConfigs.length; i++)
|
|
109
|
+
{
|
|
110
|
+
if (this.registerTaskTypeFromConfig(pConfigs[i]))
|
|
111
|
+
{
|
|
112
|
+
tmpCount++;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return tmpCount;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Create a new instance of a task type by hash.
|
|
121
|
+
*
|
|
122
|
+
* Checks config-driven tasks first, then falls back to class-based tasks.
|
|
123
|
+
*
|
|
124
|
+
* @param {string} pHash - The task type hash (e.g. 'read-file').
|
|
125
|
+
* @returns {object|null} A new instance of the task type, or null if not found.
|
|
126
|
+
*/
|
|
127
|
+
instantiateTaskType(pHash)
|
|
128
|
+
{
|
|
129
|
+
// Check config-driven tasks first
|
|
130
|
+
let tmpConfig = this._TaskTypeConfigs[pHash];
|
|
131
|
+
|
|
132
|
+
if (tmpConfig)
|
|
133
|
+
{
|
|
134
|
+
let tmpBaseClass = require('./tasks/Ultravisor-TaskType-Base.cjs');
|
|
135
|
+
let tmpOptions =
|
|
136
|
+
{
|
|
137
|
+
Definition: tmpConfig.Definition
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
if (typeof(tmpConfig.Execute) === 'function')
|
|
141
|
+
{
|
|
142
|
+
tmpOptions.Execute = tmpConfig.Execute;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return new tmpBaseClass(this.fable, tmpOptions, `TaskType-${pHash}-${Date.now()}`);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Fall back to class-based tasks
|
|
149
|
+
let tmpTaskTypeClass = this._TaskTypes[pHash];
|
|
150
|
+
|
|
151
|
+
if (!tmpTaskTypeClass)
|
|
152
|
+
{
|
|
153
|
+
this.log.error(`UltravisorTaskTypeRegistry: unknown task type hash [${pHash}]`);
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return new tmpTaskTypeClass(this.fable, {}, `TaskType-${pHash}-${Date.now()}`);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Get the definition for a task type by hash.
|
|
162
|
+
*
|
|
163
|
+
* @param {string} pHash - The task type hash.
|
|
164
|
+
* @returns {object|null} The definition, or null if not found.
|
|
165
|
+
*/
|
|
166
|
+
getDefinition(pHash)
|
|
167
|
+
{
|
|
168
|
+
return this._Definitions[pHash] || null;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Get all registered task type definitions.
|
|
173
|
+
*
|
|
174
|
+
* @returns {Array} Array of definition objects.
|
|
175
|
+
*/
|
|
176
|
+
listDefinitions()
|
|
177
|
+
{
|
|
178
|
+
let tmpDefinitions = [];
|
|
179
|
+
let tmpKeys = Object.keys(this._Definitions);
|
|
180
|
+
|
|
181
|
+
for (let i = 0; i < tmpKeys.length; i++)
|
|
182
|
+
{
|
|
183
|
+
tmpDefinitions.push(this._Definitions[tmpKeys[i]]);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return tmpDefinitions;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Check if a task type hash is registered.
|
|
191
|
+
*
|
|
192
|
+
* @param {string} pHash - The task type hash.
|
|
193
|
+
* @returns {boolean}
|
|
194
|
+
*/
|
|
195
|
+
hasTaskType(pHash)
|
|
196
|
+
{
|
|
197
|
+
return this._TaskTypes.hasOwnProperty(pHash) || this._TaskTypeConfigs.hasOwnProperty(pHash);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Register all built-in task types.
|
|
202
|
+
* Called during application initialization.
|
|
203
|
+
*/
|
|
204
|
+
registerBuiltInTaskTypes()
|
|
205
|
+
{
|
|
206
|
+
let tmpBuiltInConfigs = require('./tasks/Ultravisor-BuiltIn-TaskConfigs.cjs');
|
|
207
|
+
this.registerTaskTypesFromConfigArray(tmpBuiltInConfigs);
|
|
208
|
+
|
|
209
|
+
this.log.info(`UltravisorTaskTypeRegistry: ${Object.keys(this._Definitions).length} built-in task types registered.`);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
module.exports = UltravisorTaskTypeRegistry;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
const libSchedulePersistenceBase = require('../Ultravisor-Schedule-Persistence-Base.cjs');
|
|
2
|
+
|
|
3
|
+
const libFS = require('fs');
|
|
4
|
+
const libPath = require('path');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* JSON file–backed schedule persistence provider.
|
|
8
|
+
*
|
|
9
|
+
* Stores the schedule array in the same `.ultravisor.json` config file
|
|
10
|
+
* used by HypervisorState, under the `Schedule` key. Reads and writes
|
|
11
|
+
* are synchronous to stay consistent with HypervisorState's approach.
|
|
12
|
+
*
|
|
13
|
+
* To use a remote API instead, create a new provider that extends
|
|
14
|
+
* UltravisorSchedulePersistenceBase and register it under the service
|
|
15
|
+
* type 'UltravisorSchedulePersistence'.
|
|
16
|
+
*/
|
|
17
|
+
class UltravisorSchedulePersistenceJSONFile extends libSchedulePersistenceBase
|
|
18
|
+
{
|
|
19
|
+
constructor(pPict, pOptions, pServiceHash)
|
|
20
|
+
{
|
|
21
|
+
super(pPict, pOptions, pServiceHash);
|
|
22
|
+
|
|
23
|
+
this.serviceType = 'UltravisorSchedulePersistence';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Resolve the config file path.
|
|
28
|
+
*
|
|
29
|
+
* Uses the same logic as HypervisorState.persistState():
|
|
30
|
+
* walk the gather-phase list for a non-default path, then fall
|
|
31
|
+
* back to ProgramConfigurationFileName relative to cwd.
|
|
32
|
+
*
|
|
33
|
+
* @returns {string|false} Resolved path, or false if none available.
|
|
34
|
+
*/
|
|
35
|
+
_getConfigPath()
|
|
36
|
+
{
|
|
37
|
+
let tmpFinalPath = false;
|
|
38
|
+
|
|
39
|
+
// Check gathered configuration phases (if available)
|
|
40
|
+
let tmpOutcome = this.fable._ConfigurationOutcome;
|
|
41
|
+
if (tmpOutcome && Array.isArray(tmpOutcome.GatherPhases))
|
|
42
|
+
{
|
|
43
|
+
for (let i = 0; i < tmpOutcome.GatherPhases.length; i++)
|
|
44
|
+
{
|
|
45
|
+
let tmpPhase = tmpOutcome.GatherPhases[i];
|
|
46
|
+
if ((tmpPhase.Phase !== 'Default Program Configuration') && (tmpPhase.Path))
|
|
47
|
+
{
|
|
48
|
+
tmpFinalPath = tmpPhase.Path;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (!tmpFinalPath && this.fable.settings && this.fable.settings.ProgramConfigurationFileName)
|
|
54
|
+
{
|
|
55
|
+
tmpFinalPath = libPath.resolve(process.cwd(), this.fable.settings.ProgramConfigurationFileName);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return tmpFinalPath;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Load the schedule from the JSON config file.
|
|
63
|
+
*
|
|
64
|
+
* @param {function} fCallback - fCallback(pError, pScheduleArray)
|
|
65
|
+
*/
|
|
66
|
+
loadSchedule(fCallback)
|
|
67
|
+
{
|
|
68
|
+
let tmpPath = this._getConfigPath();
|
|
69
|
+
|
|
70
|
+
if (!tmpPath)
|
|
71
|
+
{
|
|
72
|
+
this.log.warn('UltravisorSchedulePersistenceJSONFile: no config path available; returning empty schedule.');
|
|
73
|
+
return fCallback(null, []);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
try
|
|
77
|
+
{
|
|
78
|
+
if (!libFS.existsSync(tmpPath))
|
|
79
|
+
{
|
|
80
|
+
return fCallback(null, []);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
let tmpContent = libFS.readFileSync(tmpPath, 'utf8');
|
|
84
|
+
let tmpConfig = JSON.parse(tmpContent);
|
|
85
|
+
let tmpSchedule = Array.isArray(tmpConfig.Schedule) ? tmpConfig.Schedule : [];
|
|
86
|
+
|
|
87
|
+
return fCallback(null, tmpSchedule);
|
|
88
|
+
}
|
|
89
|
+
catch (pError)
|
|
90
|
+
{
|
|
91
|
+
this.log.error(`UltravisorSchedulePersistenceJSONFile: load error: ${pError.message}`);
|
|
92
|
+
return fCallback(null, []);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Save the schedule to the JSON config file.
|
|
98
|
+
*
|
|
99
|
+
* Reads the existing file first so other keys (Operations, Templates,
|
|
100
|
+
* GlobalState, etc.) are preserved.
|
|
101
|
+
*
|
|
102
|
+
* @param {Array} pSchedule - The schedule array to persist.
|
|
103
|
+
* @param {function} fCallback - fCallback(pError)
|
|
104
|
+
*/
|
|
105
|
+
saveSchedule(pSchedule, fCallback)
|
|
106
|
+
{
|
|
107
|
+
let tmpPath = this._getConfigPath();
|
|
108
|
+
|
|
109
|
+
if (!tmpPath)
|
|
110
|
+
{
|
|
111
|
+
this.log.error('UltravisorSchedulePersistenceJSONFile: no config path available; schedule will not be saved.');
|
|
112
|
+
return fCallback(new Error('No config path available.'));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
try
|
|
116
|
+
{
|
|
117
|
+
// Read existing config so we don't clobber other keys
|
|
118
|
+
let tmpConfig = {};
|
|
119
|
+
if (libFS.existsSync(tmpPath))
|
|
120
|
+
{
|
|
121
|
+
let tmpContent = libFS.readFileSync(tmpPath, 'utf8');
|
|
122
|
+
tmpConfig = JSON.parse(tmpContent);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
tmpConfig.Schedule = pSchedule;
|
|
126
|
+
|
|
127
|
+
libFS.writeFileSync(tmpPath, JSON.stringify(tmpConfig, null, '\t'), 'utf8');
|
|
128
|
+
this.log.info(`UltravisorSchedulePersistenceJSONFile: persisted ${pSchedule.length} schedule entries to ${tmpPath}`);
|
|
129
|
+
|
|
130
|
+
return fCallback(null);
|
|
131
|
+
}
|
|
132
|
+
catch (pError)
|
|
133
|
+
{
|
|
134
|
+
this.log.error(`UltravisorSchedulePersistenceJSONFile: save error: ${pError.message}`);
|
|
135
|
+
return fCallback(pError);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
module.exports = UltravisorSchedulePersistenceJSONFile;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in task type configurations for Ultravisor.
|
|
3
|
+
*
|
|
4
|
+
* Aggregates per-capability config files into a single array.
|
|
5
|
+
* Each capability folder contains its own config file exporting
|
|
6
|
+
* an array of task type definitions.
|
|
7
|
+
*/
|
|
8
|
+
module.exports = [].concat(
|
|
9
|
+
require('./data-transform/Ultravisor-TaskConfigs-DataTransform.cjs'),
|
|
10
|
+
require('./flow-control/Ultravisor-TaskConfigs-FlowControl.cjs'),
|
|
11
|
+
require('./file-system/Ultravisor-TaskConfigs-FileSystem.cjs'),
|
|
12
|
+
require('./shell/Ultravisor-TaskConfigs-Shell.cjs'),
|
|
13
|
+
require('./http-client/Ultravisor-TaskConfigs-HttpClient.cjs'),
|
|
14
|
+
require('./user-interaction/Ultravisor-TaskConfigs-UserInteraction.cjs'),
|
|
15
|
+
require('./meadow-api/Ultravisor-TaskConfigs-MeadowApi.cjs'),
|
|
16
|
+
require('./extension/Ultravisor-TaskConfigs-Extension.cjs'),
|
|
17
|
+
require('./llm/Ultravisor-TaskConfigs-LLM.cjs'),
|
|
18
|
+
require('./content-system/Ultravisor-TaskConfigs-ContentSystem.cjs')
|
|
19
|
+
);
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ultravisor Task Helper — Beacon Dispatch
|
|
3
|
+
*
|
|
4
|
+
* Shared helper function for system-specific task types that dispatch
|
|
5
|
+
* work to beacon workers. Encapsulates the "enqueue to Beacon
|
|
6
|
+
* Coordinator + return WaitingForInput" pattern.
|
|
7
|
+
*
|
|
8
|
+
* Usage (from a task config Execute function):
|
|
9
|
+
*
|
|
10
|
+
* const beaconDispatch = require('../Ultravisor-TaskHelper-BeaconDispatch.cjs');
|
|
11
|
+
*
|
|
12
|
+
* Execute: function(pTask, pResolvedSettings, pExecutionContext, fCallback)
|
|
13
|
+
* {
|
|
14
|
+
* beaconDispatch(pTask, {
|
|
15
|
+
* Capability: 'ContentSystem',
|
|
16
|
+
* Action: 'ReadFile',
|
|
17
|
+
* Settings: { FilePath: pResolvedSettings.FilePath },
|
|
18
|
+
* AffinityKey: pResolvedSettings.AffinityKey,
|
|
19
|
+
* TimeoutMs: pResolvedSettings.TimeoutMs
|
|
20
|
+
* }, pExecutionContext, fCallback);
|
|
21
|
+
* }
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Get a named service from the Fable services map.
|
|
27
|
+
*/
|
|
28
|
+
function _getService(pTask, pTypeName)
|
|
29
|
+
{
|
|
30
|
+
return pTask.fable.servicesMap[pTypeName]
|
|
31
|
+
? Object.values(pTask.fable.servicesMap[pTypeName])[0]
|
|
32
|
+
: null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Dispatch work to a beacon via the BeaconCoordinator.
|
|
38
|
+
*
|
|
39
|
+
* @param {object} pTask - The task instance (has pTask.fable, pTask.log)
|
|
40
|
+
* @param {object} pWorkInfo - Work item description:
|
|
41
|
+
* {
|
|
42
|
+
* Capability: 'ContentSystem',
|
|
43
|
+
* Action: 'ReadFile',
|
|
44
|
+
* Settings: { FilePath: '/docs/README.md' },
|
|
45
|
+
* AffinityKey: '', // optional
|
|
46
|
+
* TimeoutMs: 300000 // optional
|
|
47
|
+
* }
|
|
48
|
+
* @param {object} pExecutionContext - Has RunHash, NodeHash, OperationHash
|
|
49
|
+
* @param {function} fCallback - Standard task callback
|
|
50
|
+
*/
|
|
51
|
+
function beaconDispatch(pTask, pWorkInfo, pExecutionContext, fCallback)
|
|
52
|
+
{
|
|
53
|
+
let tmpCoordinator = _getService(pTask, 'UltravisorBeaconCoordinator');
|
|
54
|
+
|
|
55
|
+
if (!tmpCoordinator)
|
|
56
|
+
{
|
|
57
|
+
return fCallback(null, {
|
|
58
|
+
EventToFire: 'Error',
|
|
59
|
+
Outputs: { StdOut: 'BeaconCoordinator service not available.', Result: '', BeaconID: '' },
|
|
60
|
+
Log: ['Beacon dispatch: BeaconCoordinator service not found.']
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Check if any beacons are registered
|
|
65
|
+
let tmpBeacons = tmpCoordinator.listBeacons();
|
|
66
|
+
if (tmpBeacons.length === 0)
|
|
67
|
+
{
|
|
68
|
+
return fCallback(null, {
|
|
69
|
+
EventToFire: 'Error',
|
|
70
|
+
Outputs: { StdOut: 'No Beacon workers are registered.', Result: '', BeaconID: '' },
|
|
71
|
+
Log: ['Beacon dispatch: no Beacon workers registered. Cannot dispatch work.']
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Build work item
|
|
76
|
+
let tmpWorkItemInfo = {
|
|
77
|
+
RunHash: pExecutionContext.RunHash,
|
|
78
|
+
NodeHash: pExecutionContext.NodeHash,
|
|
79
|
+
OperationHash: pExecutionContext.OperationHash,
|
|
80
|
+
Capability: pWorkInfo.Capability || 'Unknown',
|
|
81
|
+
Action: pWorkInfo.Action || '',
|
|
82
|
+
Settings: pWorkInfo.Settings || {},
|
|
83
|
+
AffinityKey: pWorkInfo.AffinityKey || '',
|
|
84
|
+
TimeoutMs: pWorkInfo.TimeoutMs || 300000
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
// Enqueue the work item
|
|
88
|
+
let tmpWorkItem = tmpCoordinator.enqueueWorkItem(tmpWorkItemInfo);
|
|
89
|
+
|
|
90
|
+
pTask.log.info(`Beacon dispatch [${pWorkInfo.Capability}/${pWorkInfo.Action}]: enqueued [${tmpWorkItem.WorkItemHash}]` +
|
|
91
|
+
(tmpWorkItemInfo.AffinityKey ? ` with affinity [${tmpWorkItemInfo.AffinityKey}]` : ''));
|
|
92
|
+
|
|
93
|
+
// Pause execution — the BeaconCoordinator will call resumeOperation when the beacon reports back
|
|
94
|
+
return fCallback(null, {
|
|
95
|
+
WaitingForInput: true,
|
|
96
|
+
ResumeEventName: 'Complete',
|
|
97
|
+
PromptMessage: `Waiting for Beacon (${pWorkInfo.Capability}/${pWorkInfo.Action})`,
|
|
98
|
+
OutputAddress: '',
|
|
99
|
+
Outputs: {},
|
|
100
|
+
Log: [
|
|
101
|
+
`Beacon dispatch: dispatched as [${tmpWorkItem.WorkItemHash}].`,
|
|
102
|
+
`Capability: ${tmpWorkItemInfo.Capability}, Action: ${tmpWorkItemInfo.Action}`
|
|
103
|
+
]
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
module.exports = beaconDispatch;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
const libFableServiceProviderBase = require('fable-serviceproviderbase');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Base class for all Ultravisor task types.
|
|
5
|
+
*
|
|
6
|
+
* Subclasses override `definition` to declare their port schema
|
|
7
|
+
* (EventInputs, EventOutputs, SettingsInputs, StateOutputs)
|
|
8
|
+
* and `execute` to implement the task logic.
|
|
9
|
+
*/
|
|
10
|
+
class UltravisorTaskType extends libFableServiceProviderBase
|
|
11
|
+
{
|
|
12
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
13
|
+
{
|
|
14
|
+
super(pFable, pOptions, pServiceHash);
|
|
15
|
+
|
|
16
|
+
this.serviceType = 'UltravisorTaskType';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Port schema and metadata for this task type.
|
|
21
|
+
* Subclasses MUST override this getter.
|
|
22
|
+
*
|
|
23
|
+
* @returns {object} Task type definition with:
|
|
24
|
+
* Hash {string} - unique type identifier (e.g. 'read-file')
|
|
25
|
+
* Name {string} - display name
|
|
26
|
+
* Description {string} - what the task does
|
|
27
|
+
* Category {string} - grouping key (file-io, data, control, interaction)
|
|
28
|
+
* Capability {string} - capability grouping for worker dispatch (e.g. 'File System', 'Data Transform')
|
|
29
|
+
* Action {string} - verb within the capability (e.g. 'Read', 'Write')
|
|
30
|
+
* Tier {string} - capability tier: 'Engine' | 'Platform' | 'Service' | 'Extension'
|
|
31
|
+
* EventInputs {Array} - [{ Name, Description? }]
|
|
32
|
+
* EventOutputs {Array} - [{ Name, Description?, IsError? }]
|
|
33
|
+
* SettingsInputs {Array} - [{ Name, DataType, Required?, Default?, Description? }]
|
|
34
|
+
* StateOutputs {Array} - [{ Name, DataType?, Description? }]
|
|
35
|
+
* DefaultSettings {object} - default values for SettingsInputs
|
|
36
|
+
*/
|
|
37
|
+
get definition()
|
|
38
|
+
{
|
|
39
|
+
// Config-driven: if Definition was provided in options, use it
|
|
40
|
+
if (this.options.Definition && typeof(this.options.Definition) === 'object'
|
|
41
|
+
&& this.options.Definition.Hash)
|
|
42
|
+
{
|
|
43
|
+
return this.options.Definition;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Default fallback (overridden by subclasses)
|
|
47
|
+
return {
|
|
48
|
+
Hash: 'base',
|
|
49
|
+
Name: 'Base Task',
|
|
50
|
+
Description: 'Override this in subclasses.',
|
|
51
|
+
Category: 'internal',
|
|
52
|
+
Capability: 'Internal',
|
|
53
|
+
Action: 'Base',
|
|
54
|
+
Tier: 'Engine',
|
|
55
|
+
EventInputs: [],
|
|
56
|
+
EventOutputs: [],
|
|
57
|
+
SettingsInputs: [],
|
|
58
|
+
StateOutputs: [],
|
|
59
|
+
DefaultSettings: {}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Execute the task.
|
|
65
|
+
*
|
|
66
|
+
* @param {object} pResolvedSettings - The task's Settings with incoming
|
|
67
|
+
* State connections already resolved by the engine.
|
|
68
|
+
* @param {object} pExecutionContext - Runtime context:
|
|
69
|
+
* GlobalState {object} - state shared across all operations
|
|
70
|
+
* OperationState {object} - state shared across tasks in this run
|
|
71
|
+
* TaskOutputs {object} - keyed by NodeHash, per-task output state
|
|
72
|
+
* StagingPath {string} - path to the operation's staging folder
|
|
73
|
+
* OperationHash {string} - the operation being executed
|
|
74
|
+
* NodeHash {string} - this task node's hash in the graph
|
|
75
|
+
* RunHash {string} - the execution run hash
|
|
76
|
+
* RunMode {string} - 'production' | 'standard' | 'debug'
|
|
77
|
+
* StateManager {object} - reference to the StateManager service
|
|
78
|
+
* TriggeringEventName {string} - the event that triggered this execution
|
|
79
|
+
* (e.g. 'PerformSplit', 'StepComplete') — lets state-machine tasks
|
|
80
|
+
* distinguish which input event caused the current invocation.
|
|
81
|
+
* @param {function} fCallback - function(pError, pResult) where pResult is:
|
|
82
|
+
* EventToFire {string} - which output event to fire (e.g. 'ReadComplete')
|
|
83
|
+
* Outputs {object} - key/value pairs written to TaskOutputs[NodeHash]
|
|
84
|
+
* Log {Array} - array of log message strings
|
|
85
|
+
* @param {function} [fFireIntermediateEvent] - Optional. For re-entrant
|
|
86
|
+
* tasks (like split-execute) that fire events multiple times.
|
|
87
|
+
* Signature: fFireIntermediateEvent(pEventName, pOutputs, fResumeCallback)
|
|
88
|
+
*/
|
|
89
|
+
execute(pResolvedSettings, pExecutionContext, fCallback, fFireIntermediateEvent)
|
|
90
|
+
{
|
|
91
|
+
// Config-driven: if Execute function was provided in options, call it
|
|
92
|
+
if (typeof(this.options.Execute) === 'function')
|
|
93
|
+
{
|
|
94
|
+
return this.options.Execute(this, pResolvedSettings, pExecutionContext, fCallback, fFireIntermediateEvent);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return fCallback(new Error(`Task type "${this.definition.Hash}" has not implemented execute().`));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Resolve a file path relative to the staging folder if it is not absolute.
|
|
102
|
+
*
|
|
103
|
+
* @param {string} pFilePath - The file path from settings.
|
|
104
|
+
* @param {string} pStagingPath - The operation's staging folder.
|
|
105
|
+
* @returns {string} Resolved absolute path.
|
|
106
|
+
*/
|
|
107
|
+
resolveFilePath(pFilePath, pStagingPath)
|
|
108
|
+
{
|
|
109
|
+
if (!pFilePath || typeof(pFilePath) !== 'string')
|
|
110
|
+
{
|
|
111
|
+
return pStagingPath || '';
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const libPath = require('path');
|
|
115
|
+
|
|
116
|
+
if (libPath.isAbsolute(pFilePath))
|
|
117
|
+
{
|
|
118
|
+
return pFilePath;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return libPath.resolve(pStagingPath || process.cwd(), pFilePath);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
module.exports = UltravisorTaskType;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task configurations for the "ContentSystem" capability.
|
|
3
|
+
*
|
|
4
|
+
* Provides dedicated cards for remote-controlling a retold-content-system
|
|
5
|
+
* beacon. Each task dispatches to a beacon advertising the ContentSystem
|
|
6
|
+
* capability, using the shared beacon dispatch helper.
|
|
7
|
+
*
|
|
8
|
+
* Cards:
|
|
9
|
+
* - content-read-file — Read a markdown/content file
|
|
10
|
+
* - content-save-file — Save content to a file
|
|
11
|
+
* - content-list-files — List files in a content directory
|
|
12
|
+
* - content-create-folder — Create a folder in the content directory
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const beaconDispatch = require('../Ultravisor-TaskHelper-BeaconDispatch.cjs');
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
module.exports =
|
|
19
|
+
[
|
|
20
|
+
// ── content-read-file ─────────────────────────────────────────
|
|
21
|
+
{
|
|
22
|
+
Definition: require('./definitions/content-read-file.json'),
|
|
23
|
+
Execute: function (pTask, pResolvedSettings, pExecutionContext, fCallback)
|
|
24
|
+
{
|
|
25
|
+
beaconDispatch(pTask, {
|
|
26
|
+
Capability: 'ContentSystem',
|
|
27
|
+
Action: 'ReadFile',
|
|
28
|
+
Settings: {
|
|
29
|
+
FilePath: pResolvedSettings.FilePath || ''
|
|
30
|
+
},
|
|
31
|
+
AffinityKey: pResolvedSettings.AffinityKey,
|
|
32
|
+
TimeoutMs: pResolvedSettings.TimeoutMs
|
|
33
|
+
}, pExecutionContext, fCallback);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
// ── content-save-file ─────────────────────────────────────────
|
|
38
|
+
{
|
|
39
|
+
Definition: require('./definitions/content-save-file.json'),
|
|
40
|
+
Execute: function (pTask, pResolvedSettings, pExecutionContext, fCallback)
|
|
41
|
+
{
|
|
42
|
+
beaconDispatch(pTask, {
|
|
43
|
+
Capability: 'ContentSystem',
|
|
44
|
+
Action: 'SaveFile',
|
|
45
|
+
Settings: {
|
|
46
|
+
FilePath: pResolvedSettings.FilePath || '',
|
|
47
|
+
Content: pResolvedSettings.Content || ''
|
|
48
|
+
},
|
|
49
|
+
AffinityKey: pResolvedSettings.AffinityKey,
|
|
50
|
+
TimeoutMs: pResolvedSettings.TimeoutMs
|
|
51
|
+
}, pExecutionContext, fCallback);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
// ── content-list-files ────────────────────────────────────────
|
|
56
|
+
{
|
|
57
|
+
Definition: require('./definitions/content-list-files.json'),
|
|
58
|
+
Execute: function (pTask, pResolvedSettings, pExecutionContext, fCallback)
|
|
59
|
+
{
|
|
60
|
+
beaconDispatch(pTask, {
|
|
61
|
+
Capability: 'ContentSystem',
|
|
62
|
+
Action: 'ListFiles',
|
|
63
|
+
Settings: {
|
|
64
|
+
Path: pResolvedSettings.Path || '',
|
|
65
|
+
Pattern: pResolvedSettings.Pattern || '',
|
|
66
|
+
Recursive: pResolvedSettings.Recursive || false
|
|
67
|
+
},
|
|
68
|
+
AffinityKey: pResolvedSettings.AffinityKey,
|
|
69
|
+
TimeoutMs: pResolvedSettings.TimeoutMs
|
|
70
|
+
}, pExecutionContext, fCallback);
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
// ── content-create-folder ─────────────────────────────────────
|
|
75
|
+
{
|
|
76
|
+
Definition: require('./definitions/content-create-folder.json'),
|
|
77
|
+
Execute: function (pTask, pResolvedSettings, pExecutionContext, fCallback)
|
|
78
|
+
{
|
|
79
|
+
beaconDispatch(pTask, {
|
|
80
|
+
Capability: 'ContentSystem',
|
|
81
|
+
Action: 'CreateFolder',
|
|
82
|
+
Settings: {
|
|
83
|
+
Path: pResolvedSettings.Path || ''
|
|
84
|
+
},
|
|
85
|
+
AffinityKey: pResolvedSettings.AffinityKey,
|
|
86
|
+
TimeoutMs: pResolvedSettings.TimeoutMs
|
|
87
|
+
}, pExecutionContext, fCallback);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
];
|