arcane-os 0.1.0-dev.5
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/CHANGELOG.md +154 -0
- package/COMMERCIAL-LICENSE.md +13 -0
- package/LICENSE +661 -0
- package/NOTICE +70 -0
- package/README.md +448 -0
- package/bin/arcane-test.mjs +741 -0
- package/bin/arcane.mjs +5 -0
- package/docs/architecture.md +234 -0
- package/docs/compatibility.md +36 -0
- package/docs/event-manager.md +166 -0
- package/docs/platform-targets.md +108 -0
- package/docs/publishing.md +203 -0
- package/docs/reference/README.md +117 -0
- package/docs/reference/arcane-ollama.md +288 -0
- package/docs/reference/availability-and-normalization.md +123 -0
- package/docs/reference/behavioral-testing.md +86 -0
- package/docs/reference/cli.md +569 -0
- package/docs/reference/core/README.md +62 -0
- package/docs/reference/core/arcane-ai-contracts.md +873 -0
- package/docs/reference/core/arcane-api.md +601 -0
- package/docs/reference/core/arcane-entities.md +65 -0
- package/docs/reference/core/arcane-events.md +134 -0
- package/docs/reference/core/ollama-module.md +181 -0
- package/docs/reference/core/reference/arcane-api/ai-and-ollama.md +1909 -0
- package/docs/reference/core/reference/arcane-api/applications-terminal-capabilities.md +1057 -0
- package/docs/reference/core/reference/arcane-api/core-and-events.md +320 -0
- package/docs/reference/core/reference/arcane-api/filesystem-storage-preferences-appearance.md +610 -0
- package/docs/reference/core/reference/arcane-api/namespaces.md +1157 -0
- package/docs/reference/core/reference/arcane-api/platform-installation-users-system.md +1423 -0
- package/docs/reference/core/reference/arcane-api/session-provisioning-diagnostics-development.md +315 -0
- package/docs/reference/event-manager.md +957 -0
- package/docs/reference/inventory/package-api.json +2632 -0
- package/docs/reference/inventory/runtime-components.json +934 -0
- package/docs/reference/inventory/runtime-entities.json +26 -0
- package/docs/reference/inventory/runtime-modules.json +1249 -0
- package/docs/reference/protocols.md +242 -0
- package/docs/reference/runtime-components.md +1098 -0
- package/docs/reference/runtime-entities.md +303 -0
- package/docs/reference/runtime-modules.md +2010 -0
- package/docs/reference/sdk-api.md +4901 -0
- package/docs/roadmap.md +79 -0
- package/docs/work-amplification.md +124 -0
- package/node_modules/event-pubsub/CHANGELOG.md +55 -0
- package/node_modules/event-pubsub/MIGRATION.md +70 -0
- package/node_modules/event-pubsub/README.md +363 -0
- package/node_modules/event-pubsub/SECURITY.md +37 -0
- package/node_modules/event-pubsub/index.js +141 -0
- package/node_modules/event-pubsub/licence +21 -0
- package/node_modules/event-pubsub/package.json +59 -0
- package/node_modules/strong-type/README.md +408 -0
- package/node_modules/strong-type/assets/strong-type-header.png +0 -0
- package/node_modules/strong-type/index.js +1151 -0
- package/node_modules/strong-type/licence +21 -0
- package/node_modules/strong-type/node.js +125 -0
- package/node_modules/strong-type/package.json +61 -0
- package/package.json +95 -0
- package/runtime/ARCANE_RUNTIME_RELEASE.json +791 -0
- package/runtime/arcane/components/app-bar.html +468 -0
- package/runtime/arcane/components/assistant-panel.html +715 -0
- package/runtime/arcane/components/calculator.html +8 -0
- package/runtime/arcane/components/chart.html +655 -0
- package/runtime/arcane/components/chat.html +1225 -0
- package/runtime/arcane/components/conversation-view.html +13 -0
- package/runtime/arcane/components/dashboard-config.html +341 -0
- package/runtime/arcane/components/data-maintenance.html +112 -0
- package/runtime/arcane/components/data-view.html +92 -0
- package/runtime/arcane/components/directory-picker.html +197 -0
- package/runtime/arcane/components/document-inspector.html +252 -0
- package/runtime/arcane/components/file-drop.html +264 -0
- package/runtime/arcane/components/file-inspector.html +293 -0
- package/runtime/arcane/components/file-manager.html +1715 -0
- package/runtime/arcane/components/header.html +142 -0
- package/runtime/arcane/components/integration-settings.html +14 -0
- package/runtime/arcane/components/local-ai-status.html +360 -0
- package/runtime/arcane/components/markdown-document.html +1048 -0
- package/runtime/arcane/components/markdown-editor.html +360 -0
- package/runtime/arcane/components/media-embed.html +8 -0
- package/runtime/arcane/components/modal.html +402 -0
- package/runtime/arcane/components/output-panel.html +259 -0
- package/runtime/arcane/components/preferences-form.html +135 -0
- package/runtime/arcane/components/record-timeline.html +105 -0
- package/runtime/arcane/components/relationship-board.html +116 -0
- package/runtime/arcane/components/screen-capture.html +8 -0
- package/runtime/arcane/components/source-code-viewer.html +441 -0
- package/runtime/arcane/components/source-explanation.html +124 -0
- package/runtime/arcane/components/speech.html +365 -0
- package/runtime/arcane/components/summary-strip.html +177 -0
- package/runtime/arcane/components/table.html +77 -0
- package/runtime/arcane/components/task-progress.html +282 -0
- package/runtime/arcane/components/terminal-workspace.html +65 -0
- package/runtime/arcane/components/theme-editor.html +41 -0
- package/runtime/arcane/components/theme-switcher.html +46 -0
- package/runtime/arcane/components/unified-inbox.html +20 -0
- package/runtime/arcane/components/voice-transcription.html +476 -0
- package/runtime/arcane/components/weather-widget.html +8 -0
- package/runtime/arcane/components/web-navigator.html +239 -0
- package/runtime/arcane/css/communications.css +1 -0
- package/runtime/arcane/css/dashboard-config.css +45 -0
- package/runtime/arcane/css/document-site.css +981 -0
- package/runtime/arcane/css/layout.css +438 -0
- package/runtime/arcane/css/primitives.css +321 -0
- package/runtime/arcane/css/theme.css +112 -0
- package/runtime/arcane/css/utility-workspace.css +1 -0
- package/runtime/arcane/entities/ApiModelRecord.js +20 -0
- package/runtime/arcane/entities/Calculation.js +13 -0
- package/runtime/arcane/entities/Chat.js +581 -0
- package/runtime/arcane/entities/CommunicationMessage.js +29 -0
- package/runtime/arcane/entities/CommunicationThread.js +21 -0
- package/runtime/arcane/entities/Document.js +10 -0
- package/runtime/arcane/entities/File.js +143 -0
- package/runtime/arcane/entities/Image.js +135 -0
- package/runtime/arcane/entities/IntentEnvelope.js +834 -0
- package/runtime/arcane/entities/Preference.js +83 -0
- package/runtime/arcane/entities/TWiNPolicyDecision.js +1092 -0
- package/runtime/arcane/entities/TerminalSession.js +46 -0
- package/runtime/arcane/entities/Theme.js +107 -0
- package/runtime/arcane/entities/User.js +1046 -0
- package/runtime/arcane/entities/Weather.js +23 -0
- package/runtime/arcane/img/arcane-os-everywhere.png +0 -0
- package/runtime/arcane/img/arrow-left.png +0 -0
- package/runtime/arcane/img/arrow-right.png +0 -0
- package/runtime/arcane/img/doc.svg +5 -0
- package/runtime/arcane/img/folder.svg +4 -0
- package/runtime/arcane/img/image.svg +5 -0
- package/runtime/arcane/img/refresh.png +0 -0
- package/runtime/arcane/img/send.svg +9 -0
- package/runtime/arcane/img/trash.svg +5 -0
- package/runtime/arcane/img/upload.svg +5 -0
- package/runtime/arcane/modules/AI.js +2048 -0
- package/runtime/arcane/modules/AIPreferenceRuntime.js +32 -0
- package/runtime/arcane/modules/AIPreferenceTuple.js +92 -0
- package/runtime/arcane/modules/AIResponseLength.js +42 -0
- package/runtime/arcane/modules/AIResponseURLPolicy.js +626 -0
- package/runtime/arcane/modules/AnsiText.js +53 -0
- package/runtime/arcane/modules/ApiModelDatabase.js +25 -0
- package/runtime/arcane/modules/AppDataScope.js +245 -0
- package/runtime/arcane/modules/AppearancePreferences.js +28 -0
- package/runtime/arcane/modules/ArcaneCommunicationBridge.js +22 -0
- package/runtime/arcane/modules/ArcaneNavigationPolicy.js +135 -0
- package/runtime/arcane/modules/ArcaneNetworkPolicy.js +255 -0
- package/runtime/arcane/modules/AsyncBoundary.js +161 -0
- package/runtime/arcane/modules/BrowserTestSuite.js +326 -0
- package/runtime/arcane/modules/CalculatorEngine.js +20 -0
- package/runtime/arcane/modules/CaseEvidenceIndexer.js +134 -0
- package/runtime/arcane/modules/ChartLibrary.js +35 -0
- package/runtime/arcane/modules/ChatRecords.js +13 -0
- package/runtime/arcane/modules/CommunicationAppController.js +43 -0
- package/runtime/arcane/modules/CommunicationHub.js +16 -0
- package/runtime/arcane/modules/CommunicationPreferences.js +13 -0
- package/runtime/arcane/modules/CommunicationProviderRegistry.js +16 -0
- package/runtime/arcane/modules/ComponentContracts.js +586 -0
- package/runtime/arcane/modules/ConfiguredAIChatSession.js +288 -0
- package/runtime/arcane/modules/ConversationActionItems.js +488 -0
- package/runtime/arcane/modules/ConversationClosingReport.js +274 -0
- package/runtime/arcane/modules/ConversationTimebox.js +527 -0
- package/runtime/arcane/modules/CoreLocalModelCatalog.js +255 -0
- package/runtime/arcane/modules/DBLS.js +171 -0
- package/runtime/arcane/modules/DBOPFS.js +1154 -0
- package/runtime/arcane/modules/DBOPFSWorker.js +116 -0
- package/runtime/arcane/modules/DataMaintenance.js +91 -0
- package/runtime/arcane/modules/DevelopmentWorkspace.js +74 -0
- package/runtime/arcane/modules/DirectoryPicker.js +109 -0
- package/runtime/arcane/modules/DocumentNavigation.js +223 -0
- package/runtime/arcane/modules/Errors.js +1025 -0
- package/runtime/arcane/modules/GifEncoder.js +29 -0
- package/runtime/arcane/modules/HTMLImport.js +114 -0
- package/runtime/arcane/modules/InMemoryCommunicationProvider.js +14 -0
- package/runtime/arcane/modules/IsolatedModelQuestionRunner.js +275 -0
- package/runtime/arcane/modules/LocalAIReadiness.js +870 -0
- package/runtime/arcane/modules/LocalAIReadinessController.js +156 -0
- package/runtime/arcane/modules/MD.js +111 -0
- package/runtime/arcane/modules/Mail.js +352 -0
- package/runtime/arcane/modules/MailTransport.mjs +180 -0
- package/runtime/arcane/modules/Marked.min.js +71 -0
- package/runtime/arcane/modules/MemoryRecords.js +44 -0
- package/runtime/arcane/modules/MessageAdvisory.js +38 -0
- package/runtime/arcane/modules/ModelDefinition.js +189 -0
- package/runtime/arcane/modules/Ollama.js +74 -0
- package/runtime/arcane/modules/OllamaModelIdentifier.js +21 -0
- package/runtime/arcane/modules/OllamaSettings.js +24 -0
- package/runtime/arcane/modules/OpenMeteoWeatherProvider.js +14 -0
- package/runtime/arcane/modules/PreferenceStore.js +109 -0
- package/runtime/arcane/modules/QRCode.min.js +1 -0
- package/runtime/arcane/modules/Questionnaire.js +61 -0
- package/runtime/arcane/modules/RecordLinkIndex.js +24 -0
- package/runtime/arcane/modules/RecordPassageIndex.js +222 -0
- package/runtime/arcane/modules/RecordReviewStore.js +94 -0
- package/runtime/arcane/modules/RevocableProjectionLedger.js +1623 -0
- package/runtime/arcane/modules/RiskSignalAnalyzer.js +37 -0
- package/runtime/arcane/modules/ScamRiskPolicy.js +62 -0
- package/runtime/arcane/modules/ScopedOPFSCache.js +183 -0
- package/runtime/arcane/modules/ScreenCapture.js +20 -0
- package/runtime/arcane/modules/SpeechPlayback.js +581 -0
- package/runtime/arcane/modules/StaticDocumentCatalog.js +1248 -0
- package/runtime/arcane/modules/SystemAppearance.js +20 -0
- package/runtime/arcane/modules/SystemPlatformPresentation.js +51 -0
- package/runtime/arcane/modules/SystemToolRegistry.js +28 -0
- package/runtime/arcane/modules/TerminalClient.js +52 -0
- package/runtime/arcane/modules/TerminalCommandRegistry.js +50 -0
- package/runtime/arcane/modules/ThemeBootstrap.js +26 -0
- package/runtime/arcane/modules/ThemeManager.js +131 -0
- package/runtime/arcane/modules/TimeGuard.js +149 -0
- package/runtime/arcane/modules/ToolCallRouter.js +83 -0
- package/runtime/arcane/modules/WaitForComponent.js +102 -0
- package/runtime/arcane/modules/YouTubeMedia.js +16 -0
- package/runtime/arcane/modules/uPlot.LICENSE.txt +21 -0
- package/runtime/arcane/modules/uPlot.iife.min.js +2 -0
- package/runtime/arcane/modules/uPlot.min.css +1 -0
- package/runtime/arcane/security/arcane-network-policy.json +6 -0
- package/runtime/strong-type/index.js +352 -0
- package/runtime/strong-type/licence +21 -0
- package/runtime/strong-type/package.json +45 -0
- package/schemas/arcane-app-bundle.schema.json +125 -0
- package/schemas/arcane-app.schema.json +329 -0
- package/schemas/arcane-lock.schema.json +86 -0
- package/schemas/arcane-package.schema.json +224 -0
- package/schemas/cli-event.schema.json +122 -0
- package/schemas/event-stack.schema.json +152 -0
- package/schemas/native-build-plan.schema.json +176 -0
- package/schemas/target-adapter.schema.json +117 -0
- package/src/app-descriptor.mjs +500 -0
- package/src/cli/main.mjs +561 -0
- package/src/constants.mjs +31 -0
- package/src/dev-server.mjs +718 -0
- package/src/doctor.mjs +315 -0
- package/src/dom-event-instrumentation.mjs +594 -0
- package/src/errors.mjs +75 -0
- package/src/event-manager.mjs +1342 -0
- package/src/event-queue.mjs +138 -0
- package/src/events.mjs +219 -0
- package/src/index.mjs +177 -0
- package/src/integrated-provider-loader.mjs +432 -0
- package/src/native-plan.mjs +698 -0
- package/src/native-provider-loader.mjs +1126 -0
- package/src/packager/core.mjs +2691 -0
- package/src/process.mjs +353 -0
- package/src/release-bundle.mjs +2523 -0
- package/src/repository.mjs +90 -0
- package/src/runtime.mjs +452 -0
- package/src/scaffold.mjs +380 -0
- package/src/targets/index.mjs +436 -0
- package/src/templates/assets/app-icon.png +0 -0
- package/src/templates/workspace-template.mjs +388 -0
- package/src/testing-loader.mjs +9 -0
- package/src/testing.mjs +427 -0
- package/src/toolchain.mjs +1335 -0
- package/src/update-check.mjs +307 -0
- package/src/workspace.mjs +449 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import {AsyncLocalStorage} from 'node:async_hooks';
|
|
2
|
+
import {arcaneEvents} from './event-manager.mjs';
|
|
3
|
+
|
|
4
|
+
const deliveryStorage=new AsyncLocalStorage();
|
|
5
|
+
|
|
6
|
+
function deliveryOccurrence(event){
|
|
7
|
+
const active=deliveryStorage.getStore();
|
|
8
|
+
if(active&&!active.closed&&Object.is(active.event,event)){
|
|
9
|
+
return active;
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
event,
|
|
13
|
+
managers:new Set(),
|
|
14
|
+
pending:0,
|
|
15
|
+
closed:false
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function mirror(manager,event,eventMetadata,occurrence){
|
|
20
|
+
if(!manager||!event||typeof event!=='object'||occurrence.managers.has(manager)){
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
occurrence.managers.add(manager);
|
|
24
|
+
try{
|
|
25
|
+
const result=manager.forward(event,eventMetadata);
|
|
26
|
+
if(result&&typeof result.then==='function'){
|
|
27
|
+
void Promise.resolve(result).catch(()=>{});
|
|
28
|
+
}
|
|
29
|
+
}catch{
|
|
30
|
+
// Central instrumentation is observational. Its subscribers must not
|
|
31
|
+
// replace the queue callback's backpressure or failure semantics.
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function callbackError(value){
|
|
36
|
+
if(value instanceof Error){
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
return new Error(`The event callback failed: ${String(value)}`,{cause:value});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function createEventQueue(onEvent,{
|
|
43
|
+
onFailure,
|
|
44
|
+
eventManager=arcaneEvents,
|
|
45
|
+
eventMetadata={source:'sdk',category:'operation'}
|
|
46
|
+
}={}){
|
|
47
|
+
const callback=typeof onEvent==='function'?onEvent:null;
|
|
48
|
+
const manager=eventManager===null?null:eventManager;
|
|
49
|
+
if(manager&&typeof manager.forward!=='function'){
|
|
50
|
+
throw new TypeError('The central event manager must provide forward(event, metadata).');
|
|
51
|
+
}
|
|
52
|
+
let firstError=null;
|
|
53
|
+
let tail=Promise.resolve();
|
|
54
|
+
const pendingKeys=new Set();
|
|
55
|
+
let resolveFailure;
|
|
56
|
+
const failure=new Promise(resolve=>{
|
|
57
|
+
resolveFailure=resolve;
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const capture=error=>{
|
|
61
|
+
if(firstError){
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
firstError=callbackError(error);
|
|
65
|
+
resolveFailure(firstError);
|
|
66
|
+
try{
|
|
67
|
+
const result=onFailure?.(firstError);
|
|
68
|
+
if(result&&typeof result.then==='function'){
|
|
69
|
+
void Promise.resolve(result).catch(()=>{});
|
|
70
|
+
}
|
|
71
|
+
}catch{
|
|
72
|
+
// The callback failure remains authoritative. Failure cleanup must
|
|
73
|
+
// never create a second unhandled error.
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const enqueue=(event,{coalesce}={})=>{
|
|
78
|
+
if((!callback&&!manager)||firstError){
|
|
79
|
+
return tail;
|
|
80
|
+
}
|
|
81
|
+
if(coalesce&&pendingKeys.has(coalesce)){
|
|
82
|
+
return tail;
|
|
83
|
+
}
|
|
84
|
+
if(coalesce){
|
|
85
|
+
pendingKeys.add(coalesce);
|
|
86
|
+
}
|
|
87
|
+
const occurrence=deliveryOccurrence(event);
|
|
88
|
+
occurrence.pending+=1;
|
|
89
|
+
const task=tail.then(()=>deliveryStorage.run(occurrence,async()=>{
|
|
90
|
+
if(firstError){
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const current=Object.freeze(event);
|
|
94
|
+
mirror(manager,current,eventMetadata,occurrence);
|
|
95
|
+
try{
|
|
96
|
+
await callback?.(current);
|
|
97
|
+
}catch(error){
|
|
98
|
+
capture(error);
|
|
99
|
+
}
|
|
100
|
+
}));
|
|
101
|
+
tail=task.finally(()=>{
|
|
102
|
+
occurrence.pending-=1;
|
|
103
|
+
if(occurrence.pending===0){
|
|
104
|
+
occurrence.closed=true;
|
|
105
|
+
}
|
|
106
|
+
if(coalesce){
|
|
107
|
+
pendingKeys.delete(coalesce);
|
|
108
|
+
}
|
|
109
|
+
}).catch(capture);
|
|
110
|
+
return tail;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const send=async event=>{
|
|
114
|
+
await enqueue(event);
|
|
115
|
+
if(firstError){
|
|
116
|
+
throw firstError;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const drain=async()=>{
|
|
121
|
+
let observed;
|
|
122
|
+
do{
|
|
123
|
+
observed=tail;
|
|
124
|
+
await observed;
|
|
125
|
+
}while(observed!==tail);
|
|
126
|
+
if(firstError){
|
|
127
|
+
throw firstError;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return Object.freeze({
|
|
132
|
+
drain,
|
|
133
|
+
enqueue,
|
|
134
|
+
failure,
|
|
135
|
+
send,
|
|
136
|
+
get error(){return firstError;}
|
|
137
|
+
});
|
|
138
|
+
}
|
package/src/events.mjs
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import {randomUUID} from 'node:crypto';
|
|
2
|
+
import {CLI_EVENT_PROTOCOL,OUTPUT_MODES} from './constants.mjs';
|
|
3
|
+
import {ArcaneError,ERROR_CODES,errorRecord} from './errors.mjs';
|
|
4
|
+
|
|
5
|
+
function write(stream,value){
|
|
6
|
+
stream.write(`${value}\n`);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function jsonSafe(value,seen=new WeakSet()){
|
|
10
|
+
if(value===undefined||value===null||typeof value==='string'
|
|
11
|
+
||typeof value==='number'||typeof value==='boolean'){
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if(typeof value==='bigint'){
|
|
16
|
+
return value.toString();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if(typeof value==='function'||typeof value==='symbol'){
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if(value instanceof Error){
|
|
24
|
+
return errorRecord(value);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if(Array.isArray(value)){
|
|
28
|
+
if(seen.has(value)){
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
seen.add(value);
|
|
33
|
+
const result=value.map(item=>jsonSafe(item,seen)).filter(item=>item!==undefined);
|
|
34
|
+
seen.delete(value);
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if(typeof value==='object'){
|
|
39
|
+
if(seen.has(value)){
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
seen.add(value);
|
|
44
|
+
const result={};
|
|
45
|
+
for(const [key,item] of Object.entries(value)){
|
|
46
|
+
const safe=jsonSafe(item,seen);
|
|
47
|
+
if(safe!==undefined){
|
|
48
|
+
result[key]=safe;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
seen.delete(value);
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return String(value);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function humanEvent(event){
|
|
59
|
+
const label=event.message||event.type;
|
|
60
|
+
return `[${event.sequence}] ${label}`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function createReporter({
|
|
64
|
+
command,
|
|
65
|
+
output='human',
|
|
66
|
+
stdout=process.stdout,
|
|
67
|
+
stderr=process.stderr,
|
|
68
|
+
operationId=randomUUID(),
|
|
69
|
+
clock=()=>new Date()
|
|
70
|
+
}={}){
|
|
71
|
+
if(!OUTPUT_MODES.includes(output)){
|
|
72
|
+
throw new ArcaneError(
|
|
73
|
+
ERROR_CODES.usage,
|
|
74
|
+
`Unsupported output mode: ${String(output)}. Expected human, json, or ndjson.`
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let sequence=0;
|
|
79
|
+
let accepted=false;
|
|
80
|
+
let terminal=false;
|
|
81
|
+
|
|
82
|
+
function event(type,{message,data,status}={}){
|
|
83
|
+
return {
|
|
84
|
+
protocol:CLI_EVENT_PROTOCOL,
|
|
85
|
+
operationId,
|
|
86
|
+
sequence:++sequence,
|
|
87
|
+
timestamp:clock().toISOString(),
|
|
88
|
+
command,
|
|
89
|
+
type,
|
|
90
|
+
...(status?{status}:{}),
|
|
91
|
+
...(message?{message}:{}),
|
|
92
|
+
...(data===undefined?{}:{data:jsonSafe(data)})
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function streamEvent(current){
|
|
97
|
+
if(output==='ndjson'){
|
|
98
|
+
write(stdout,JSON.stringify(current));
|
|
99
|
+
}else if(output==='json'){
|
|
100
|
+
write(stderr,JSON.stringify(current));
|
|
101
|
+
}else{
|
|
102
|
+
write(stderr,humanEvent(current));
|
|
103
|
+
}
|
|
104
|
+
return current;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function accept(data){
|
|
108
|
+
if(accepted){
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
accepted=true;
|
|
112
|
+
return streamEvent(event('operation.accepted',{
|
|
113
|
+
status:'accepted',
|
|
114
|
+
message:`Accepted ${command}.`,
|
|
115
|
+
data
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function emit(type,data,message){
|
|
120
|
+
if(!accepted){
|
|
121
|
+
throw new ArcaneError(
|
|
122
|
+
ERROR_CODES.operationFailed,
|
|
123
|
+
'The operation must be accepted before work events are emitted.'
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
if(terminal){
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
return streamEvent(event(type,{message,data,status:'running'}));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function complete(result){
|
|
133
|
+
if(terminal){
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
terminal=true;
|
|
137
|
+
const current=event('operation.completed',{
|
|
138
|
+
status:'completed',
|
|
139
|
+
message:`Completed ${command}.`,
|
|
140
|
+
data:{result}
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
if(output==='ndjson'){
|
|
144
|
+
write(stdout,JSON.stringify(current));
|
|
145
|
+
}else if(output==='json'){
|
|
146
|
+
write(stdout,JSON.stringify({
|
|
147
|
+
protocol:CLI_EVENT_PROTOCOL,
|
|
148
|
+
ok:true,
|
|
149
|
+
operationId,
|
|
150
|
+
command,
|
|
151
|
+
result:jsonSafe(result)
|
|
152
|
+
}));
|
|
153
|
+
}else{
|
|
154
|
+
if(result!==undefined){
|
|
155
|
+
if(typeof result==='string'){
|
|
156
|
+
write(stdout,result);
|
|
157
|
+
}else{
|
|
158
|
+
write(stdout,JSON.stringify(jsonSafe(result),null,2));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
write(stderr,humanEvent(current));
|
|
162
|
+
}
|
|
163
|
+
return current;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function reject(error){
|
|
167
|
+
if(terminal){
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
terminal=true;
|
|
171
|
+
const normalized=errorRecord(error);
|
|
172
|
+
const current=event(
|
|
173
|
+
normalized.code===ERROR_CODES.cancelled?'operation.cancelled':'operation.failed',
|
|
174
|
+
{
|
|
175
|
+
status:normalized.code===ERROR_CODES.cancelled?'cancelled':'failed',
|
|
176
|
+
message:normalized.message,
|
|
177
|
+
data:{error:normalized}
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
if(output==='ndjson'){
|
|
182
|
+
write(stdout,JSON.stringify(current));
|
|
183
|
+
}else if(output==='json'){
|
|
184
|
+
write(stdout,JSON.stringify({
|
|
185
|
+
protocol:CLI_EVENT_PROTOCOL,
|
|
186
|
+
ok:false,
|
|
187
|
+
operationId,
|
|
188
|
+
command,
|
|
189
|
+
error:normalized
|
|
190
|
+
}));
|
|
191
|
+
}else{
|
|
192
|
+
write(stderr,`${normalized.code}: ${normalized.message}`);
|
|
193
|
+
}
|
|
194
|
+
return current;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function forward(value,data){
|
|
198
|
+
if(typeof value==='string'){
|
|
199
|
+
return emit(value,data);
|
|
200
|
+
}
|
|
201
|
+
if(value&&typeof value==='object'){
|
|
202
|
+
const {type='operation.progress',message,...rest}=value;
|
|
203
|
+
return emit(type,rest.data??rest,message);
|
|
204
|
+
}
|
|
205
|
+
return emit('operation.progress',data);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
return {
|
|
209
|
+
operationId,
|
|
210
|
+
output,
|
|
211
|
+
accept,
|
|
212
|
+
emit,
|
|
213
|
+
forward,
|
|
214
|
+
complete,
|
|
215
|
+
reject,
|
|
216
|
+
get accepted(){return accepted;},
|
|
217
|
+
get terminal(){return terminal;}
|
|
218
|
+
};
|
|
219
|
+
}
|
package/src/index.mjs
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
export {
|
|
2
|
+
ARCANE_MACHINE_BUNDLE_VERSION,
|
|
3
|
+
ARCANE_PROTOCOL,
|
|
4
|
+
ARCANE_UPSTREAM_COMMIT,
|
|
5
|
+
ARCANE_UPSTREAM_REPOSITORY,
|
|
6
|
+
CLI_EVENT_PROTOCOL,
|
|
7
|
+
CLI_NAME,
|
|
8
|
+
OUTPUT_MODES,
|
|
9
|
+
RUNTIME_ROOT,
|
|
10
|
+
SDK_NAME,
|
|
11
|
+
SDK_ROOT,
|
|
12
|
+
SDK_VERSION,
|
|
13
|
+
TARGET_ADAPTER_PROTOCOL,
|
|
14
|
+
TARGET_IDS
|
|
15
|
+
} from './constants.mjs';
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
ArcaneError,
|
|
19
|
+
ERROR_CODES,
|
|
20
|
+
errorRecord,
|
|
21
|
+
fail,
|
|
22
|
+
normalizeError,
|
|
23
|
+
throwIfAborted
|
|
24
|
+
} from './errors.mjs';
|
|
25
|
+
|
|
26
|
+
export {createReporter} from './events.mjs';
|
|
27
|
+
export {
|
|
28
|
+
SDK_UPDATE_REGISTRY,
|
|
29
|
+
SDK_UPDATE_TIMEOUT_MS,
|
|
30
|
+
checkForSdkUpdate,
|
|
31
|
+
compareSdkVersions,
|
|
32
|
+
updateTagForVersion,
|
|
33
|
+
validateUpdateRegistry
|
|
34
|
+
} from './update-check.mjs';
|
|
35
|
+
export {
|
|
36
|
+
ARCANE_EVENT_STACK_PROTOCOL,
|
|
37
|
+
arcaneEvents,
|
|
38
|
+
createDOMInstrumentation,
|
|
39
|
+
createEventManager,
|
|
40
|
+
DEFAULT_DOM_EVENT_TYPES,
|
|
41
|
+
describeDOMTarget,
|
|
42
|
+
DOM_INTERACTION_EVENT,
|
|
43
|
+
DOM_MUTATION_EVENT,
|
|
44
|
+
DOM_OBSERVATION_STARTED_EVENT,
|
|
45
|
+
DOM_OBSERVATION_STOPPED_EVENT,
|
|
46
|
+
domSelector,
|
|
47
|
+
EventManager,
|
|
48
|
+
parseEventStack,
|
|
49
|
+
PLAYBACK_CANCELLED_EVENT,
|
|
50
|
+
PLAYBACK_COMPLETED_EVENT,
|
|
51
|
+
PLAYBACK_FAILED_EVENT,
|
|
52
|
+
PLAYBACK_RECORD_EVENT,
|
|
53
|
+
PLAYBACK_STARTED_EVENT,
|
|
54
|
+
TIME_TRAVEL_OVERFLOW_EVENT,
|
|
55
|
+
TIME_TRAVEL_SEEK_EVENT
|
|
56
|
+
} from './event-manager.mjs';
|
|
57
|
+
export {runProcess} from './process.mjs';
|
|
58
|
+
export {
|
|
59
|
+
DEFAULT_TEST_TIMEOUT_MS,
|
|
60
|
+
registeredTestCount,
|
|
61
|
+
runRegisteredTests,
|
|
62
|
+
test
|
|
63
|
+
} from './testing.mjs';
|
|
64
|
+
export {runDoctor,assessArcaneOllama} from './doctor.mjs';
|
|
65
|
+
export {
|
|
66
|
+
ARCANE_NATIVE_PROVIDER_PATHS,
|
|
67
|
+
ARCANE_PORTABLE_PROVIDER_PATH,
|
|
68
|
+
loadArcaneNativeProvider,
|
|
69
|
+
loadArcanePortableProvider
|
|
70
|
+
} from './native-provider-loader.mjs';
|
|
71
|
+
export {
|
|
72
|
+
ARCANE_INTEGRATED_PROVIDER_RELATIVE_PATH,
|
|
73
|
+
INTEGRATED_TOOLCHAIN_PROTOCOL,
|
|
74
|
+
loadArcaneIntegratedProvider
|
|
75
|
+
} from './integrated-provider-loader.mjs';
|
|
76
|
+
export {
|
|
77
|
+
repositoryPull,
|
|
78
|
+
repositoryPush,
|
|
79
|
+
repositoryStatus,
|
|
80
|
+
runRepositoryAction
|
|
81
|
+
} from './repository.mjs';
|
|
82
|
+
export {
|
|
83
|
+
buildTarget,
|
|
84
|
+
createNativeTargetAdapter,
|
|
85
|
+
getTargetAdapter,
|
|
86
|
+
listTargets,
|
|
87
|
+
runTarget,
|
|
88
|
+
verifyTarget
|
|
89
|
+
} from './targets/index.mjs';
|
|
90
|
+
export {
|
|
91
|
+
assertIntegratedNativeToolchain,
|
|
92
|
+
assertIntegratedPortableToolchain,
|
|
93
|
+
assertNativeApplicationToolchainCompatibility,
|
|
94
|
+
assertPortableToolchainCompatibility,
|
|
95
|
+
buildApplication,
|
|
96
|
+
bundleApplication,
|
|
97
|
+
checkApplication,
|
|
98
|
+
checkSdkUpdate,
|
|
99
|
+
createApplication,
|
|
100
|
+
createToolchain,
|
|
101
|
+
describeTargets,
|
|
102
|
+
developApplication,
|
|
103
|
+
doctorApplication,
|
|
104
|
+
doctorNativeTarget,
|
|
105
|
+
executeOperation,
|
|
106
|
+
initializeApplication,
|
|
107
|
+
packageApplication,
|
|
108
|
+
planApplication,
|
|
109
|
+
prepareNativeTarget,
|
|
110
|
+
resolveNativeBuildOutputRoot,
|
|
111
|
+
resolvePortableBuildOutputRoot,
|
|
112
|
+
repositoryApplication,
|
|
113
|
+
runApplication,
|
|
114
|
+
testApplication,
|
|
115
|
+
verifyApplication,
|
|
116
|
+
verifyBundleApplication,
|
|
117
|
+
verifyNativeArtifact
|
|
118
|
+
} from './toolchain.mjs';
|
|
119
|
+
export {createWorkspace,initWorkspace} from './scaffold.mjs';
|
|
120
|
+
export {
|
|
121
|
+
authenticateRuntimeReceipt,
|
|
122
|
+
getSdkRoot,
|
|
123
|
+
loadRuntimeRelease,
|
|
124
|
+
readVerifiedRuntimeFile,
|
|
125
|
+
verifyRuntime
|
|
126
|
+
} from './runtime.mjs';
|
|
127
|
+
export {
|
|
128
|
+
discoverApps,
|
|
129
|
+
inspectWorkspaceProfile,
|
|
130
|
+
resolveWorkspace,
|
|
131
|
+
selectApp,
|
|
132
|
+
validateWorkspace
|
|
133
|
+
} from './workspace.mjs';
|
|
134
|
+
export {startDevServer} from './dev-server.mjs';
|
|
135
|
+
export {
|
|
136
|
+
NATIVE_BUILD_PLAN_PROTOCOL,
|
|
137
|
+
NATIVE_BUILDER_PROTOCOL,
|
|
138
|
+
assertNativeToolchainCompatibility,
|
|
139
|
+
authenticateNativeBuildPlan,
|
|
140
|
+
createNativeBuildPlan,
|
|
141
|
+
executeNativeBuildPlan,
|
|
142
|
+
validateNativeBuilder
|
|
143
|
+
} from './native-plan.mjs';
|
|
144
|
+
export {
|
|
145
|
+
APP_DESCRIPTOR_NAME,
|
|
146
|
+
APP_DESCRIPTOR_SCHEMA_VERSION,
|
|
147
|
+
appDescriptorSha256,
|
|
148
|
+
loadAppDescriptor,
|
|
149
|
+
projectNativeDescriptor,
|
|
150
|
+
projectPackageManifest,
|
|
151
|
+
validateAppDescriptor
|
|
152
|
+
} from './app-descriptor.mjs';
|
|
153
|
+
export {
|
|
154
|
+
authenticateAppReleaseAuthority,
|
|
155
|
+
authenticateAppReleaseReceipt,
|
|
156
|
+
authenticateSharedPayloadSnapshot,
|
|
157
|
+
discoverApps as discoverPackagerApps,
|
|
158
|
+
inspectApp,
|
|
159
|
+
packageApp,
|
|
160
|
+
prepareSharedPayloadSnapshot,
|
|
161
|
+
readVerifiedAppReleaseFile,
|
|
162
|
+
verifyApp
|
|
163
|
+
} from './packager/core.mjs';
|
|
164
|
+
export {
|
|
165
|
+
APP_BUNDLE_DESCRIPTOR_NAME,
|
|
166
|
+
APP_BUNDLE_EXTENSION,
|
|
167
|
+
APP_BUNDLE_FORMAT,
|
|
168
|
+
APP_BUNDLE_KIND,
|
|
169
|
+
APP_BUNDLE_LIMITS,
|
|
170
|
+
APP_BUNDLE_MANIFEST_NAME,
|
|
171
|
+
APP_BUNDLE_RELEASE_PATH,
|
|
172
|
+
APP_BUNDLE_SCHEMA_VERSION,
|
|
173
|
+
createAppReleaseBundle,
|
|
174
|
+
createCanonicalUstarHeader,
|
|
175
|
+
validateAppBundlePath,
|
|
176
|
+
verifyAppReleaseBundle
|
|
177
|
+
} from './release-bundle.mjs';
|