@ultrst-armada/kloks 1.26.2 → 1.26.4
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 +39 -0
- package/index.d.ts +16 -10
- package/index.js +3 -0
- package/package.json +70 -8
- package/packages/audio-midi/dist/{audioClipEngine-BOT33JKI.js → audioClipEngine-LKZRWTJ3.js} +2 -2
- package/packages/audio-midi/dist/{audioInputManager-BLDGGLAR.js → audioInputManager-5BNHLOJM.js} +1 -1
- package/packages/audio-midi/dist/{chunk-N55BWOC6.js → chunk-M4JFGTHE.js} +1 -1
- package/packages/audio-midi/dist/{chunk-3GRGELA4.js → chunk-OUOFTYHY.js} +50 -11
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/Compressor/manifest.json +7 -0
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/Delay/manifest.json +7 -0
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/Equalizer/manifest.json +7 -0
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/Limiter/manifest.json +7 -0
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/MultibandCompressor/manifest.json +7 -0
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/Reverb/manifest.json +7 -0
- package/packages/audio-midi/dist/engine/audio/entities/AudioEffects/functionalities/Saturation/manifest.json +7 -0
- package/packages/audio-midi/dist/index.d.ts +10 -1
- package/packages/audio-midi/dist/index.js +36 -20
- package/packages/audio-midi/package.json +8 -0
- package/packages/backend/dist/ai-models/index.js +2 -2
- package/packages/backend/dist/ai-routing/index.js +3 -3
- package/packages/backend/dist/api/BaseApiRoute.d.ts +1 -1
- package/packages/backend/dist/api/index.js +1 -1
- package/packages/backend/dist/auth/CanonicalAuthClient.d.ts +6 -6
- package/packages/backend/dist/auth/index.js +2 -1
- package/packages/backend/dist/chunk-2Y2EXYDK.js +0 -0
- package/packages/backend/dist/{chunk-3SWMKYCI.js → chunk-3FZSYSJC.js} +18 -9
- package/packages/backend/dist/chunk-5F5V7NAG.js +54 -0
- package/packages/backend/dist/{chunk-KVWBIDZG.js → chunk-BVXGUHLZ.js} +1 -1
- package/packages/backend/dist/chunk-DAG2L4RN.js +0 -0
- package/packages/backend/dist/{chunk-GKXI5V23.js → chunk-G7PPVOFP.js} +17 -51
- package/packages/backend/dist/{chunk-GKQ42CYW.js → chunk-H6ET362U.js} +3 -3
- package/packages/backend/dist/chunk-HUY4272L.js +69 -0
- package/packages/backend/dist/chunk-JQKKMUCT.js +0 -0
- package/packages/backend/dist/{chunk-PT6J6UEU.js → chunk-LMAU62ZG.js} +4 -4
- package/packages/backend/dist/{chunk-4TPSXGG5.js → chunk-MZK362U4.js} +12 -12
- package/packages/backend/dist/{chunk-BQLQTUDD.js → chunk-NGEB3CF5.js} +3 -35
- package/packages/backend/dist/{chunk-3VWBZEMG.js → chunk-NTKUQVCQ.js} +4 -5
- package/packages/backend/dist/chunk-NY2SQOXI.js +34 -0
- package/packages/backend/dist/{chunk-JOTDEFRG.js → chunk-OXEP3AP6.js} +5 -4
- package/packages/backend/dist/chunk-RABSY2JU.js +0 -0
- package/packages/backend/dist/{chunk-M45KQRPR.js → chunk-RFPGUJAZ.js} +11 -11
- package/packages/backend/dist/{chunk-TWCEVES2.js → chunk-WC6EPW3A.js} +1 -1
- package/packages/backend/dist/{chunk-UCCFQCAE.js → chunk-Y5ENDXU2.js} +72 -129
- package/packages/backend/dist/{chunk-EO5VUYYU.js → chunk-Y7ZE6D5H.js} +4 -4
- package/packages/backend/dist/{chunk-RCCQ7IRM.js → chunk-ZBNSK26X.js} +2 -2
- package/packages/backend/dist/control-plane/AuditLogger.d.ts +1 -1
- package/packages/backend/dist/control-plane/ControlPlaneManager.d.ts +1 -1
- package/packages/backend/dist/control-plane/index.js +1 -1
- package/packages/backend/dist/core/dynamicRouteResolver.d.ts +1 -1
- package/packages/backend/dist/core/routesCore.d.ts +1 -1
- package/packages/backend/dist/core/vercelTransformer.d.ts +1 -1
- package/packages/backend/dist/core/workspaceCore.d.ts +2 -2
- package/packages/backend/dist/data/BaseDataProvider.d.ts +1 -1
- package/packages/backend/dist/development/index.js +34 -21
- package/packages/backend/dist/development/playwrightInspectionService.js +1 -2
- package/packages/backend/dist/development/webContainerService.js +1 -2
- package/packages/backend/dist/index.d.ts +4 -24
- package/packages/backend/dist/index.js +14 -4657
- package/packages/backend/dist/krnl-ai-services.d.ts +9 -9
- package/packages/backend/dist/krnl-ai-services.js +5 -6
- package/packages/backend/dist/krnl-services.js +8 -7
- package/packages/backend/dist/node.d.ts +28 -0
- package/packages/backend/dist/node.js +4754 -0
- package/packages/backend/dist/resourceEngine/BaseResourceFetcher.d.ts +3 -3
- package/packages/backend/dist/resourceEngine/CloudflareResourceFetcher.d.ts +3 -3
- package/packages/backend/dist/resourceEngine/ResourceFetcherRegistry.d.ts +5 -5
- package/packages/backend/dist/resourceEngine/VercelResourceFetcher.d.ts +3 -3
- package/packages/backend/dist/resourceEngine/adapters/CloudflareResourceAdapter.d.ts +2 -2
- package/packages/backend/dist/resourceEngine/adapters/VercelResourceAdapter.d.ts +2 -2
- package/packages/backend/dist/resourceEngine/calculator/UniversalResourceCalculator.d.ts +1 -1
- package/packages/backend/dist/resourceEngine/calculator/types.d.ts +1 -1
- package/packages/backend/dist/resourceEngine/index.d.ts +6 -6
- package/packages/backend/dist/resourceEngine/types/depm/entities.d.ts +2 -2
- package/packages/backend/dist/resourceEngine/types.d.ts +1 -1
- package/packages/backend/dist/resourceEngine/weightEngine/helpers.d.ts +1 -1
- package/packages/backend/dist/resourceEngine/weightEngine/index.d.ts +2 -2
- package/packages/backend/dist/resourceEngine/weightEngine/weightEngine.d.ts +1 -1
- package/packages/backend/dist/resourceEngine/weightEngine.d.ts +1 -1
- package/packages/backend/dist/server/services/assetPoolService/assetPoolService.d.ts +3 -3
- package/packages/backend/dist/server/services/projectService/projectService.d.ts +3 -3
- package/packages/backend/dist/services/index.d.ts +2 -10
- package/packages/backend/dist/services/index.js +1 -37
- package/packages/backend/dist/services/node.d.ts +10 -0
- package/packages/backend/dist/services/node.js +38 -0
- package/packages/backend/dist/srkl/index.js +1 -1
- package/packages/backend/dist/storage/BaseStorageAdapter.d.ts +1 -1
- package/packages/backend/dist/storage/GoogleDriveWorkspaceService.d.ts +69 -0
- package/packages/backend/dist/storage/GoogleDriveWorkspaceService.test.d.ts +1 -0
- package/packages/backend/dist/storage/S3Adapter.d.ts +5 -0
- package/packages/backend/dist/storage/googleDriveSdk.d.ts +1 -0
- package/packages/backend/dist/storage/index.d.ts +1 -10
- package/packages/backend/dist/storage/index.js +8 -43
- package/packages/backend/dist/storage/node.d.ts +14 -0
- package/packages/backend/dist/storage/node.js +66 -0
- package/packages/backend/dist/storage-workspace.d.ts +2 -0
- package/packages/backend/dist/storage-workspace.js +339 -0
- package/packages/backend/dist/workspace/WorkspaceCloneSyncEngine.d.ts +1 -1
- package/packages/backend/dist/workspace/index.d.ts +1 -5
- package/packages/backend/dist/workspace/index.js +4 -24
- package/packages/backend/dist/workspace/node.d.ts +8 -0
- package/packages/backend/dist/workspace/node.js +30 -0
- package/packages/backend/package.json +40 -3
- package/packages/functions/dist/base-DDYO-DzM.d.ts +64 -0
- package/packages/functions/dist/base.d.ts +1 -0
- package/packages/functions/dist/base.js +6 -0
- package/packages/functions/dist/chunk-6EHIZHO4.js +555 -0
- package/packages/functions/dist/chunk-Z4LM5TOJ.js +114 -0
- package/packages/functions/dist/index.d.ts +4 -373
- package/packages/functions/dist/index.js +53 -1693
- package/packages/functions/dist/node.d.ts +110 -0
- package/packages/functions/dist/node.js +442 -0
- package/packages/functions/dist/portable.d.ts +207 -0
- package/packages/functions/dist/portable.js +94 -0
- package/packages/functions/package.json +23 -1
- package/packages/{functions/dist/chunk-K6H7T3EP.js → services/dist/chunk-P54QSKOQ.js} +1 -3
- package/packages/{state-graph/dist/dist-es-TLPJYZTE.js → services/dist/dist-es-2P6LFFZL.js} +1 -1
- package/packages/services/dist/{dist-es-5IACWOIO.js → dist-es-OZCE67MW.js} +1 -1
- package/packages/services/dist/{dist-es-3DGJJFOU.js → dist-es-RUJB3ALN.js} +3 -3
- package/packages/{state-graph/dist/dist-es-OECEAUXH.js → services/dist/dist-es-SSJGP5AI.js} +4 -4
- package/packages/services/dist/{loadSso-M3ZIZDGO.js → loadSso-3PZYFUB7.js} +1 -1
- package/packages/{functions/dist/signin-YXALFRYB.js → services/dist/signin-WYPGSXHF.js} +1 -1
- package/packages/{state-graph/dist/sso-oidc-NXFKRL6O.js → services/dist/sso-oidc-PQMIMLJU.js} +1 -1
- package/packages/{state-graph/dist/sts-MICPT37B.js → services/dist/sts-Z7LR3AZH.js} +1 -1
- package/packages/state-graph/dist/browser.d.ts +18 -0
- package/packages/state-graph/dist/browser.js +613 -0
- package/packages/state-graph/dist/browser.test.d.ts +1 -0
- package/packages/state-graph/dist/{chunk-KG6QYS26.js → chunk-5KP74NMF.js} +80 -80
- package/packages/state-graph/dist/{chunk-4UVGXFEM.js → chunk-LVULR5M4.js} +1 -1
- package/packages/state-graph/dist/{chunk-S22PMERU.js → chunk-OXUDG6HE.js} +1 -1
- package/packages/state-graph/dist/chunk-UKTICGGV.js +9523 -0
- package/packages/state-graph/dist/domain/index.js +2 -3
- package/packages/state-graph/dist/engine/AudioConcepts.d.ts +1 -1
- package/packages/state-graph/dist/engine/GraphConcepts.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/archetypes/audioArchetypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/archetypes/effectArchetypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/archetypes/primitiveArchetypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/archetypes/routingArchetypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/archetypes/triggerModuleArchetypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/assets/containerSprites.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/assets/effectSprites.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/assets/primitiveSprites.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/assets/routingSprites.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/canonicalIo/CanonicalAudioInputEndpoint.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/canonicalIo/CanonicalMidiInputEndpoint.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/canonicalIo/topLevelIoRegistry.d.ts +6 -6
- package/packages/state-graph/dist/engine/core/canonicalIo/types.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/graphDataService.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/hierarchy/index.d.ts +11 -11
- package/packages/state-graph/dist/engine/core/hierarchy/nodes/GraphNodeParent.d.ts +3 -3
- package/packages/state-graph/dist/engine/core/hierarchy/nodes/GraphNodeTypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/hierarchy/sockets/GraphSocketParent.d.ts +2 -2
- package/packages/state-graph/dist/engine/core/hierarchy/sockets/GraphSocketTypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/hierarchy/ui/UIElementBase.d.ts +3 -3
- package/packages/state-graph/dist/engine/core/hierarchy/wires/GraphWireParent.d.ts +2 -2
- package/packages/state-graph/dist/engine/core/hierarchy/wires/GraphWireTypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/nodeArchetypeRegistry.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/socketRegistry/containersSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/socketRegistry/customRegistry.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/socketRegistry/landmarksSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/socketRegistry/primitivesSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/socketRegistry/processorsSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/arrangementControlSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/audioSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/folderButtonSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/moduleSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/playbackSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/primitiveSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/routingSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/samplerSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/core/sockets/stripSockets.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/arrangementFactory.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/codeNodeParser/codeNodeParser.d.ts +2 -2
- package/packages/state-graph/dist/engine/functions/codeNodeParser/helpers.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/connection/portMatching.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/connection/signalCompatibility/helpers.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/connection/signalCompatibility/signalCompatibility.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/connection/signalCompatibility.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/connection/wireValidation.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/containerClipSync.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/containerFactory/containerFactory.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/effectLogic.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/graphManager/graphManager.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/graphManager.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/nodeFactory/nodeFactory.d.ts +8 -8
- package/packages/state-graph/dist/engine/functions/nodeFactory.d.ts +2 -2
- package/packages/state-graph/dist/engine/functions/signalTable/audioMidiSignals.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/signalTable/canonicalEffectsTable.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/signalTable/dataSignals.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/socketCompatibilitySpawner/helpers.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/socketCompatibilitySpawner/socketCompatibilitySpawner.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/socketCompatibilitySpawner.d.ts +1 -1
- package/packages/state-graph/dist/engine/functions/spawnNodeFactory.d.ts +1 -1
- package/packages/state-graph/dist/engine/predictive/predictiveGraphEngine/helpers.d.ts +1 -1
- package/packages/state-graph/dist/engine/predictive/predictiveGraphEngine.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/auth.d.ts +1 -1
- package/packages/state-graph/dist/engine/types/hardwareBus.d.ts +1 -1
- package/packages/state-graph/dist/engine/types/legacyTypes.d.ts +1 -1
- package/packages/state-graph/dist/engine/types/nodesArrangement.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/nodesAudio.d.ts +5 -5
- package/packages/state-graph/dist/engine/types/nodesControl.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/nodesPlayback.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/nodesPrimitives.d.ts +6 -6
- package/packages/state-graph/dist/engine/types/nodesRouting.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/sceneData.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/sceneState.d.ts +4 -4
- package/packages/state-graph/dist/engine/types/signals.d.ts +2 -2
- package/packages/state-graph/dist/engine/types/stripsTypes.d.ts +2 -2
- package/packages/state-graph/dist/index.js +262 -9979
- package/packages/state-graph/dist/rules/index.js +0 -1
- package/packages/state-graph/dist/runtime-entrypoint.test.d.ts +1 -0
- package/packages/state-graph/dist/spatial/index.js +0 -1
- package/packages/state-graph/dist/state/index.js +0 -1
- package/packages/state-graph/dist/store/CommandApi.d.ts +2 -2
- package/packages/state-graph/dist/store/index.js +2 -3
- package/packages/state-graph/package.json +8 -2
- package/scripts/normalize-package-declarations.mjs +63 -0
- package/packages/backend/dist/chunk-SXDYW3QA.js +0 -579
- package/packages/functions/dist/bowser-F6LIZBYW.js +0 -2821
- package/packages/functions/dist/chunk-34KJBG4F.js +0 -357
- package/packages/functions/dist/chunk-EAQYK3U2.js +0 -41
- package/packages/functions/dist/chunk-IOAPEUC7.js +0 -3424
- package/packages/functions/dist/chunk-J64ZDIIX.js +0 -2753
- package/packages/functions/dist/chunk-N3MSTUJN.js +0 -4785
- package/packages/functions/dist/chunk-VP26OHBN.js +0 -480
- package/packages/functions/dist/chunk-VRLVLNLG.js +0 -1727
- package/packages/functions/dist/dist-TKZ5TDRN.js +0 -1124
- package/packages/functions/dist/dist-W7ZJS3LZ.js +0 -899
- package/packages/functions/dist/dist-es-3DGJJFOU.js +0 -338
- package/packages/functions/dist/dist-es-5IACWOIO.js +0 -69
- package/packages/functions/dist/dist-es-BWLDIBIA.js +0 -47
- package/packages/functions/dist/dist-es-DO3F4OBN.js +0 -377
- package/packages/functions/dist/dist-es-NN7AKU7P.js +0 -175
- package/packages/functions/dist/dist-es-QZ6GKMM7.js +0 -220
- package/packages/functions/dist/dist-es-R3VEGXOP.js +0 -87
- package/packages/functions/dist/dist-es-TLPJYZTE.js +0 -294
- package/packages/functions/dist/event-streams-DRE6QVD6.js +0 -940
- package/packages/functions/dist/loadSso-M3ZIZDGO.js +0 -586
- package/packages/functions/dist/multipart-parser-YYFFJ4QD.js +0 -371
- package/packages/functions/dist/src-2QCYQXYH.js +0 -1396
- package/packages/functions/dist/sso-oidc-NXFKRL6O.js +0 -847
- package/packages/functions/dist/sts-MICPT37B.js +0 -1253
- package/packages/functions/dist/transformers.node-R6VHTGC2.js +0 -43879
- package/packages/services/dist/chunk-K6H7T3EP.js +0 -1991
- package/packages/services/dist/dist-es-QZ6GKMM7.js +0 -220
- package/packages/services/dist/dist-es-TLPJYZTE.js +0 -294
- package/packages/services/dist/signin-YXALFRYB.js +0 -831
- package/packages/services/dist/sso-oidc-NXFKRL6O.js +0 -847
- package/packages/services/dist/sts-MICPT37B.js +0 -1253
- package/packages/state-graph/dist/bowser-F6LIZBYW.js +0 -2821
- package/packages/state-graph/dist/chunk-34KJBG4F.js +0 -357
- package/packages/state-graph/dist/chunk-EAQYK3U2.js +0 -41
- package/packages/state-graph/dist/chunk-IOAPEUC7.js +0 -3424
- package/packages/state-graph/dist/chunk-J64ZDIIX.js +0 -2753
- package/packages/state-graph/dist/chunk-K6H7T3EP.js +0 -1991
- package/packages/state-graph/dist/chunk-N3MSTUJN.js +0 -4785
- package/packages/state-graph/dist/chunk-VP26OHBN.js +0 -480
- package/packages/state-graph/dist/chunk-VRLVLNLG.js +0 -1727
- package/packages/state-graph/dist/dist-TKZ5TDRN.js +0 -1124
- package/packages/state-graph/dist/dist-W7ZJS3LZ.js +0 -899
- package/packages/state-graph/dist/dist-es-3DGJJFOU.js +0 -338
- package/packages/state-graph/dist/dist-es-5IACWOIO.js +0 -69
- package/packages/state-graph/dist/dist-es-BWLDIBIA.js +0 -47
- package/packages/state-graph/dist/dist-es-DO3F4OBN.js +0 -377
- package/packages/state-graph/dist/dist-es-NN7AKU7P.js +0 -175
- package/packages/state-graph/dist/dist-es-R3VEGXOP.js +0 -87
- package/packages/state-graph/dist/event-streams-DRE6QVD6.js +0 -940
- package/packages/state-graph/dist/loadSso-M3ZIZDGO.js +0 -586
- package/packages/state-graph/dist/multipart-parser-YYFFJ4QD.js +0 -371
- package/packages/state-graph/dist/signin-YXALFRYB.js +0 -831
- package/packages/state-graph/dist/src-2QCYQXYH.js +0 -1396
- package/packages/state-graph/dist/transformers.node-R6VHTGC2.js +0 -43879
- package/packages/backend/dist/{chunk-LMWXONZG.js → chunk-EREYT3WJ.js} +3 -3
|
@@ -1,1668 +1,57 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
defineApi({ id: "gutts.numbers.clamp", name: "clamp", category: "numbers", description: "Restricts a numeric value to an inclusive minimum and maximum range.", parameters: [{ name: "value", description: "The numeric value to constrain.", required: true, schema: { type: "number" } }, { name: "min", description: "The inclusive lower bound.", required: true, schema: { type: "number" } }, { name: "max", description: "The inclusive upper bound.", required: true, schema: { type: "number" } }], output: { type: "number", description: "The value constrained to the inclusive range." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when min exceeds max."] }),
|
|
50
|
-
defineApi({ id: "gutts.numbers.inRange", name: "inRange", category: "numbers", description: "Checks whether a numeric value falls within the configured range.", parameters: [{ name: "value", description: "The numeric value to test.", required: true, schema: { type: "number" } }, { name: "min", description: "The lower range boundary.", required: true, schema: { type: "number" } }, { name: "max", description: "The upper range boundary.", required: true, schema: { type: "number" } }], output: { type: "boolean", description: "Whether the value is inside the range." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when min exceeds max."] }),
|
|
51
|
-
defineApi({ id: "gutts.numbers.roundTo", name: "roundTo", category: "numbers", description: "Rounds a number to a specified non-negative number of decimal places.", parameters: [{ name: "value", description: "The number to round.", required: true, schema: { type: "number" } }, { name: "decimals", description: "The non-negative integer number of decimal places.", required: false, schema: { type: "integer" } }], output: { type: "number", description: "The rounded number." }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when decimals is negative or not an integer."] }),
|
|
52
|
-
defineApi({ id: "gutts.numbers.isFiniteNumber", name: "isFiniteNumber", category: "numbers", description: "Checks whether a value is a JavaScript number and is finite.", parameters: [{ name: "value", description: "The value to test.", required: true, schema: {} }], output: { type: "boolean", description: "True only for finite JavaScript numbers." }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
53
|
-
defineApi({ id: "gutts.numbers.sum", name: "sum", category: "numbers", description: "Adds all numbers in an array and returns their total.", parameters: [{ name: "values", description: "The numeric values to add.", required: true, schema: { type: "array", items: { type: "number" } } }], output: { type: "number", description: "The sum of all input numbers." }, semantics: { deterministic: true, pure: true, sideEffects: false } })
|
|
54
|
-
];
|
|
55
|
-
|
|
56
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/object-apis.js
|
|
57
|
-
var objectApis = [
|
|
58
|
-
defineApi({ id: "gutts.objects.hasOwn", name: "hasOwn", category: "objects", description: "Checks whether an object contains a requested property.", parameters: [{ name: "value", description: "The object to inspect.", required: true, schema: { type: "object" } }, { name: "key", description: "The property key to look for.", required: true, schema: { type: "string" } }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
59
|
-
defineApi({ id: "gutts.objects.pick", name: "pick", category: "objects", description: "Creates an object containing only requested properties.", parameters: [{ name: "value", description: "The source object.", required: true, schema: { type: "object" } }, { name: "keys", description: "The property keys to retain.", required: true, schema: { type: "array", items: { type: "string" } } }], output: { type: "object" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
60
|
-
defineApi({ id: "gutts.objects.omit", name: "omit", category: "objects", description: "Creates an object without requested properties.", parameters: [{ name: "value", description: "The source object.", required: true, schema: { type: "object" } }, { name: "keys", description: "The property keys to remove.", required: true, schema: { type: "array", items: { type: "string" } } }], output: { type: "object" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
61
|
-
defineApi({ id: "gutts.objects.isPlainObject", name: "isPlainObject", category: "objects", description: "Checks whether a value is a plain JavaScript object.", parameters: [{ name: "value", description: "The value to classify.", required: true, schema: {} }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } })
|
|
62
|
-
];
|
|
63
|
-
|
|
64
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/string-apis.js
|
|
65
|
-
var string = { type: "string" };
|
|
66
|
-
var stringApis = [
|
|
67
|
-
defineApi({ id: "gutts.strings.isBlank", name: "isBlank", category: "strings", description: "Checks whether a string contains no non-whitespace characters.", parameters: [{ name: "value", description: "The string to inspect.", required: true, schema: string }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
68
|
-
defineApi({ id: "gutts.strings.isNonBlank", name: "isNonBlank", category: "strings", description: "Checks whether a string contains at least one non-whitespace character.", parameters: [{ name: "value", description: "The string to inspect.", required: true, schema: string }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
69
|
-
defineApi({ id: "gutts.strings.isEmail", name: "isEmail", category: "strings", description: "Checks whether a string conforms to the email-address validation rules used by GutTS.", parameters: [{ name: "value", description: "The string to validate as an email address.", required: true, schema: string }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
70
|
-
defineApi({ id: "gutts.strings.startsWithAny", name: "startsWithAny", category: "strings", description: "Checks whether a string starts with at least one supplied prefix.", parameters: [{ name: "value", description: "The string to inspect.", required: true, schema: string }, { name: "prefixes", description: "The prefixes to test.", required: true, schema: { type: "array", items: string } }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
71
|
-
defineApi({ id: "gutts.strings.endsWithAny", name: "endsWithAny", category: "strings", description: "Checks whether a string ends with at least one supplied suffix.", parameters: [{ name: "value", description: "The string to inspect.", required: true, schema: string }, { name: "suffixes", description: "The suffixes to test.", required: true, schema: { type: "array", items: string } }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
72
|
-
defineApi({ id: "gutts.strings.capitalize", name: "capitalize", category: "strings", description: "Capitalizes a string using the library's existing capitalization behavior.", parameters: [{ name: "value", description: "The string to capitalize.", required: true, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
73
|
-
defineApi({ id: "gutts.strings.camelCase", name: "camelCase", category: "strings", description: "Converts a string into lower camel case.", parameters: [{ name: "value", description: "The string to convert.", required: true, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
74
|
-
defineApi({ id: "gutts.strings.kebabCase", name: "kebabCase", category: "strings", description: "Converts a string into lower kebab case.", parameters: [{ name: "value", description: "The string to convert.", required: true, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
75
|
-
defineApi({ id: "gutts.strings.snakeCase", name: "snakeCase", category: "strings", description: "Converts a string into lower snake case.", parameters: [{ name: "value", description: "The string to convert.", required: true, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
76
|
-
defineApi({ id: "gutts.strings.truncate", name: "truncate", category: "strings", description: "Shortens a string to a maximum length and appends a suffix when truncation is required.", parameters: [{ name: "value", description: "The string to shorten.", required: true, schema: string }, { name: "maxLength", description: "The non-negative maximum output length.", required: true, schema: { type: "number" } }, { name: "suffix", description: "The suffix used when truncation occurs.", required: false, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when maxLength is negative."] }),
|
|
77
|
-
defineApi({ id: "gutts.strings.truncateWords", name: "truncateWords", category: "strings", description: "Shortens a string to a maximum number of words and appends a suffix when truncation is required.", parameters: [{ name: "value", description: "The string to shorten.", required: true, schema: string }, { name: "maxWords", description: "The non-negative maximum number of words.", required: true, schema: { type: "number" } }, { name: "suffix", description: "The suffix used when truncation occurs.", required: false, schema: string }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws RangeError when maxWords is negative."] })
|
|
78
|
-
];
|
|
79
|
-
|
|
80
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/url-apis.js
|
|
81
|
-
var string2 = { type: "string" };
|
|
82
|
-
var urlApis = [
|
|
83
|
-
defineApi({ id: "gutts.urls.isUrl", name: "isUrl", category: "urls", description: "Checks whether a string can be parsed as a URL by the standard URL constructor.", parameters: [{ name: "value", description: "The string to validate.", required: true, schema: string2 }], output: { type: "boolean" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
84
|
-
defineApi({ id: "gutts.urls.joinUrl", name: "joinUrl", category: "urls", description: "Joins a base URL-like string and path segments using single separators.", parameters: [{ name: "base", description: "The base URL or path.", required: true, schema: string2 }, { name: "parts", description: "The path segments to append.", required: true, schema: { type: "array", items: string2 } }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
85
|
-
defineApi({ id: "gutts.urls.getQueryParam", name: "getQueryParam", category: "urls", description: "Reads one query-string parameter from a URL.", parameters: [{ name: "url", description: "The URL to inspect.", required: true, schema: string2 }, { name: "key", description: "The query parameter name.", required: true, schema: string2 }], output: { type: "string", description: "The value, or null when absent." }, semantics: { deterministic: true, pure: true, sideEffects: false } }),
|
|
86
|
-
defineApi({ id: "gutts.urls.setQueryParam", name: "setQueryParam", category: "urls", description: "Returns a URL with one query-string parameter set to the supplied value.", parameters: [{ name: "url", description: "The URL to modify.", required: true, schema: string2 }, { name: "key", description: "The query parameter name.", required: true, schema: string2 }, { name: "value", description: "The query parameter value.", required: true, schema: string2 }], output: { type: "string" }, semantics: { deterministic: true, pure: true, sideEffects: false }, errors: ["Throws when url cannot be parsed as a URL."] })
|
|
87
|
-
];
|
|
88
|
-
|
|
89
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/needle3/index.js
|
|
90
|
-
var needle3Metadata = {
|
|
91
|
-
id: "model.cactus-needle3",
|
|
92
|
-
name: "Needle 3",
|
|
93
|
-
provider: "Cactus Compute",
|
|
94
|
-
version: "3",
|
|
95
|
-
description: "Tiny structured inference model for tool selection, argument extraction, classification, and embeddings.",
|
|
96
|
-
examples: ["select a tool", "extract fields", "classify an intent"],
|
|
97
|
-
avoidWhen: "Avoid for open-ended long-form generation or complex multi-step reasoning.",
|
|
98
|
-
whenToUse: "Use when natural language must be mapped to a small tool set or structured schema.",
|
|
99
|
-
size: { min: 8, max: 29, unit: "MB", qualifier: "range" },
|
|
100
|
-
capabilities: ["tool-selection", "argument-extraction", "classification", "structured-output", "embeddings"],
|
|
101
|
-
input: "Natural-language text with optional tools or extraction schema",
|
|
102
|
-
output: "Structured JSON or embedding vector",
|
|
103
|
-
runtime: "Cactus Needle runtime adapter",
|
|
104
|
-
modelUri: "Cactus-Compute/needle3"
|
|
105
|
-
};
|
|
106
|
-
var needle3CompleteApi = defineApi({
|
|
107
|
-
id: "model.cactus-needle3.complete",
|
|
108
|
-
name: "Needle3.complete",
|
|
109
|
-
category: "models",
|
|
110
|
-
description: "Select tools or extract structured data from natural-language input.",
|
|
111
|
-
parameters: [
|
|
112
|
-
{ name: "prompt", description: "Natural-language input.", required: true, schema: { type: "string" } },
|
|
113
|
-
{ name: "tools", description: "Optional tool definitions.", required: false, schema: { type: "array" } },
|
|
114
|
-
{ name: "schema", description: "Optional extraction schema.", required: false, schema: { type: "object" } }
|
|
115
|
-
],
|
|
116
|
-
output: { type: "object", description: "Structured model result." },
|
|
117
|
-
semantics: { deterministic: false, pure: false, sideEffects: false }
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/runtimes/ettin-head.js
|
|
121
|
-
import fs from "fs";
|
|
122
|
-
import path from "path";
|
|
123
|
-
import os from "os";
|
|
124
|
-
|
|
125
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/smollm2/index.js
|
|
126
|
-
var smolLM2Metadata = {
|
|
127
|
-
id: "model.smollm2-135m-instruct",
|
|
128
|
-
name: "SmolLM2-135M-Instruct",
|
|
129
|
-
provider: "Hugging Face",
|
|
130
|
-
version: "135M",
|
|
131
|
-
description: "Compact instruction-tuned language model for general text generation.",
|
|
132
|
-
examples: ["summarize text", "rewrite text", "draft a short response"],
|
|
133
|
-
avoidWhen: "Avoid for high-stakes reasoning, broad factual knowledge, or tasks requiring large context.",
|
|
134
|
-
whenToUse: "Use for short general-purpose text generation when a local model is preferred.",
|
|
135
|
-
size: { value: 105, unit: "MB", qualifier: "artifact" },
|
|
136
|
-
capabilities: ["text-generation", "instruction-following"],
|
|
137
|
-
input: "Natural-language prompt",
|
|
138
|
-
output: "Generated natural-language text",
|
|
139
|
-
runtime: "ModelRuntime adapter",
|
|
140
|
-
modelUri: "HuggingFaceTB/SmolLM2-135M-Instruct",
|
|
141
|
-
license: "Apache-2.0"
|
|
142
|
-
};
|
|
143
|
-
var smolLM2GenerateApi = defineApi({
|
|
144
|
-
id: "model.smollm2-135m-instruct.generate",
|
|
145
|
-
name: "SmolLM2-135M-Instruct.generate",
|
|
146
|
-
category: "models",
|
|
147
|
-
description: "Generate natural-language text with SmolLM2-135M-Instruct.",
|
|
148
|
-
parameters: [
|
|
149
|
-
{ name: "prompt", description: "Prompt supplied to the model.", required: true, schema: { type: "string" } },
|
|
150
|
-
{ name: "maxNewTokens", description: "Maximum number of new tokens.", required: false, schema: { type: "number" } }
|
|
151
|
-
],
|
|
152
|
-
output: { type: "string", description: "Generated natural-language text." },
|
|
153
|
-
semantics: { deterministic: false, pure: false, sideEffects: false },
|
|
154
|
-
errors: ["Model load failure", "Inference failure"]
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/whistle/index.js
|
|
158
|
-
var whistleMetadata = {
|
|
159
|
-
id: "model.cactus-whistle",
|
|
160
|
-
name: "Whistle",
|
|
161
|
-
provider: "Cactus Compute",
|
|
162
|
-
version: "1",
|
|
163
|
-
description: "Compact CPU speech-recognition model for on-device transcription.",
|
|
164
|
-
examples: ["transcribe a voice note", "transcribe a command"],
|
|
165
|
-
avoidWhen: "Avoid when audio understanding beyond transcription is required.",
|
|
166
|
-
whenToUse: "Use for local speech-to-text when low resource use and privacy matter.",
|
|
167
|
-
size: { value: 16.9, unit: "MB", qualifier: "artifact" },
|
|
168
|
-
capabilities: ["speech-to-text", "on-device", "cpu"],
|
|
169
|
-
input: "Audio bytes",
|
|
170
|
-
output: "Transcribed natural-language text",
|
|
171
|
-
runtime: "Cactus Needle runtime adapter",
|
|
172
|
-
modelUri: "Cactus-Compute/whistle"
|
|
173
|
-
};
|
|
174
|
-
var whistleTranscribeApi = defineApi({
|
|
175
|
-
id: "model.cactus-whistle.transcribe",
|
|
176
|
-
name: "Whistle.transcribe",
|
|
177
|
-
category: "models",
|
|
178
|
-
description: "Transcribe speech audio into natural-language text.",
|
|
179
|
-
parameters: [
|
|
180
|
-
{ name: "audio", description: "Audio bytes supplied to the speech model.", required: true, schema: { type: "string" } },
|
|
181
|
-
{ name: "language", description: "Optional language identifier.", required: false, schema: { type: "string" } }
|
|
182
|
-
],
|
|
183
|
-
output: { type: "string", description: "Transcribed text." },
|
|
184
|
-
semantics: { deterministic: true, pure: false, sideEffects: false }
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/ettin/index.js
|
|
188
|
-
var defineEttin = (id2, name, parameters, description) => ({
|
|
189
|
-
id: id2,
|
|
190
|
-
name,
|
|
191
|
-
provider: "Hugging Face",
|
|
192
|
-
version: String(parameters),
|
|
193
|
-
description,
|
|
194
|
-
examples: ["rank search results", "order retrieved documents by relevance"],
|
|
195
|
-
whenToUse: "Use for cross-encoder reranking when candidate texts must be sorted by semantic relevance.",
|
|
196
|
-
avoidWhen: "Avoid for text generation, embeddings, or transcription.",
|
|
197
|
-
size: { value: parameters * 1e6, unit: "parameters", qualifier: "parameters" },
|
|
198
|
-
capabilities: ["reranking", "relevance-scoring"],
|
|
199
|
-
input: "Query and candidate texts",
|
|
200
|
-
output: "Candidate relevance scores",
|
|
201
|
-
runtime: "ModelRuntime adapter",
|
|
202
|
-
modelUri: `cross-encoder/ettin-reranker-${parameters}m-v1`,
|
|
203
|
-
license: "Apache-2.0"
|
|
204
|
-
});
|
|
205
|
-
var ettinReranker17MMetadata = defineEttin("model.ettin-reranker-17m", "Ettin-Reranker-17M", 17, "Very small relevance model for ranking candidate text.");
|
|
206
|
-
var ettinReranker32MMetadata = defineEttin("model.ettin-reranker-32m", "Ettin-Reranker-32M", 32, "Small relevance model for ranking candidate text.");
|
|
207
|
-
var ettinReranker68MMetadata = defineEttin("model.ettin-reranker-68m", "Ettin-Reranker-68M", 68, "Compact relevance model for higher-quality candidate ranking.");
|
|
208
|
-
var ettinReranker150MMetadata = defineEttin("model.ettin-reranker-150m", "Ettin-Reranker-150M", 150, "Larger compact relevance model for candidate ranking.");
|
|
209
|
-
var ettinRerankApi = defineApi({
|
|
210
|
-
id: "model.ettin-reranker.rerank",
|
|
211
|
-
name: "EttinReranker.rerank",
|
|
212
|
-
category: "models",
|
|
213
|
-
description: "Rank candidate texts by relevance to a query.",
|
|
214
|
-
parameters: [
|
|
215
|
-
{ name: "query", description: "Query text.", required: true, schema: { type: "string" } },
|
|
216
|
-
{ name: "candidates", description: "Candidate texts to rank.", required: true, schema: { type: "array", items: { type: "string" } } }
|
|
217
|
-
],
|
|
218
|
-
output: { type: "array", description: "Relevance scores in candidate order.", items: { type: "number" } },
|
|
219
|
-
semantics: { deterministic: true, pure: false, sideEffects: false }
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/minilm/index.js
|
|
223
|
-
var miniLML6Metadata = {
|
|
224
|
-
id: "model.minilm-l6-v2",
|
|
225
|
-
name: "MiniLM-L6-v2",
|
|
226
|
-
provider: "Sentence Transformers",
|
|
227
|
-
version: "L6-v2",
|
|
228
|
-
description: "Compact sentence embedding model for semantic similarity.",
|
|
229
|
-
examples: ["compare two texts", "match a query to a short description"],
|
|
230
|
-
avoidWhen: "Avoid when generation, extraction, or tool calling is required.",
|
|
231
|
-
whenToUse: "Use for lightweight semantic similarity and embedding-based matching.",
|
|
232
|
-
size: { value: 227e5, unit: "parameters", qualifier: "parameters" },
|
|
233
|
-
capabilities: ["embeddings", "semantic-similarity"],
|
|
234
|
-
input: "Two text strings",
|
|
235
|
-
output: "Similarity score",
|
|
236
|
-
runtime: "ModelRuntime adapter",
|
|
237
|
-
modelUri: "sentence-transformers/all-MiniLM-L6-v2",
|
|
238
|
-
license: "Apache-2.0"
|
|
239
|
-
};
|
|
240
|
-
var miniLMSimilarityApi = defineApi({
|
|
241
|
-
id: "model.minilm-l6-v2.similarity",
|
|
242
|
-
name: "MiniLM-L6-v2.similarity",
|
|
243
|
-
category: "models",
|
|
244
|
-
description: "Compute semantic similarity between two texts.",
|
|
245
|
-
parameters: [
|
|
246
|
-
{ name: "left", description: "First text.", required: true, schema: { type: "string" } },
|
|
247
|
-
{ name: "right", description: "Second text.", required: true, schema: { type: "string" } }
|
|
248
|
-
],
|
|
249
|
-
output: { type: "number", description: "Semantic similarity score." },
|
|
250
|
-
semantics: { deterministic: true, pure: false, sideEffects: false }
|
|
251
|
-
});
|
|
252
|
-
|
|
253
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/api-registry.js
|
|
254
|
-
var guttsApiDefinitions = Object.freeze([
|
|
255
|
-
...arrayApis,
|
|
256
|
-
...jsonApis,
|
|
257
|
-
...numberApis,
|
|
258
|
-
...objectApis,
|
|
259
|
-
...stringApis,
|
|
260
|
-
...urlApis,
|
|
261
|
-
smolLM2GenerateApi,
|
|
262
|
-
needle3CompleteApi,
|
|
263
|
-
whistleTranscribeApi,
|
|
264
|
-
ettinRerankApi,
|
|
265
|
-
miniLMSimilarityApi
|
|
266
|
-
]);
|
|
267
|
-
var guttsApiById = Object.freeze(Object.fromEntries(guttsApiDefinitions.map((api) => [api.id, api])));
|
|
268
|
-
|
|
269
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/api/fod-node-provider.js
|
|
270
|
-
var schemaType = (schema) => String(schema?.type ?? "any");
|
|
271
|
-
function guttsApiToFodNode(api) {
|
|
272
|
-
return {
|
|
273
|
-
type: `gutts/${api.id}`,
|
|
274
|
-
label: api.name,
|
|
275
|
-
description: api.description,
|
|
276
|
-
category: "gutts",
|
|
277
|
-
group: api.category,
|
|
278
|
-
inputs: api.parameters.map((parameter) => ({ id: parameter.name, name: parameter.name, direction: "input", dataType: schemaType(parameter.schema), required: parameter.required, description: parameter.description, schema: parameter.schema })),
|
|
279
|
-
outputs: [{ id: "result", name: "result", direction: "output", dataType: schemaType(api.output), ...api.output.description ? { description: api.output.description } : {}, schema: api.output }],
|
|
280
|
-
metadata: { apiId: api.id, package: "@dinilmusick/gutts", semantics: api.semantics }
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
var guttsFodNodeDefinitions = Object.freeze(guttsApiDefinitions.map(guttsApiToFodNode));
|
|
284
|
-
|
|
285
|
-
// ../../node_modules/.pnpm/@dinilmusick+gutts@1.6.0_@types+node@22.20.5/node_modules/@dinilmusick/gutts/dist/models/model-registry.js
|
|
286
|
-
var guttsModelDefinitions = Object.freeze([
|
|
287
|
-
smolLM2Metadata,
|
|
288
|
-
needle3Metadata,
|
|
289
|
-
whistleMetadata,
|
|
290
|
-
ettinReranker17MMetadata,
|
|
291
|
-
ettinReranker32MMetadata,
|
|
292
|
-
ettinReranker68MMetadata,
|
|
293
|
-
ettinReranker150MMetadata,
|
|
294
|
-
miniLML6Metadata
|
|
295
|
-
]);
|
|
296
|
-
var guttsModelById = Object.freeze(Object.fromEntries(guttsModelDefinitions.map((model) => [model.id, model])));
|
|
297
|
-
|
|
298
|
-
// ../../node_modules/.pnpm/@ultrst-armada+krnl@1.0.9_@types+node@22.20.5/node_modules/@ultrst-armada/krnl/packages/core/dist/index.js
|
|
299
|
-
var ServiceStateStore = class {
|
|
300
|
-
state;
|
|
301
|
-
listeners = /* @__PURE__ */ new Set();
|
|
302
|
-
constructor(initialState) {
|
|
303
|
-
this.state = { ...initialState };
|
|
304
|
-
}
|
|
305
|
-
getState() {
|
|
306
|
-
return Object.freeze({ ...this.state });
|
|
307
|
-
}
|
|
308
|
-
setState(mutation) {
|
|
309
|
-
this.state = { ...this.state, ...mutation };
|
|
310
|
-
const snapshot = this.getState();
|
|
311
|
-
for (const listener of this.listeners) {
|
|
312
|
-
listener(snapshot, mutation);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
subscribe(listener) {
|
|
316
|
-
this.listeners.add(listener);
|
|
317
|
-
return () => {
|
|
318
|
-
this.listeners.delete(listener);
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
reset(newState) {
|
|
322
|
-
this.state = { ...newState || {} };
|
|
323
|
-
}
|
|
324
|
-
};
|
|
325
|
-
var TRANSITIONS = {
|
|
326
|
-
uninitialized: ["initializing"],
|
|
327
|
-
initializing: ["ready", "uninitialized"],
|
|
328
|
-
ready: ["starting"],
|
|
329
|
-
starting: ["running", "ready"],
|
|
330
|
-
running: ["stopping"],
|
|
331
|
-
stopping: ["stopped", "running"],
|
|
332
|
-
stopped: ["starting"]
|
|
333
|
-
};
|
|
334
|
-
var LifecycleManager = class {
|
|
335
|
-
status = "uninitialized";
|
|
336
|
-
getStatus() {
|
|
337
|
-
return this.status;
|
|
338
|
-
}
|
|
339
|
-
canTransitionTo(next) {
|
|
340
|
-
return TRANSITIONS[this.status].includes(next);
|
|
341
|
-
}
|
|
342
|
-
transitionTo(next) {
|
|
343
|
-
if (!this.canTransitionTo(next)) {
|
|
344
|
-
throw new Error("[Lifecycle] Invalid transition '" + this.status + "' -> '" + next + "'.");
|
|
345
|
-
}
|
|
346
|
-
this.status = next;
|
|
347
|
-
}
|
|
348
|
-
setStatus(next) {
|
|
349
|
-
this.transitionTo(next);
|
|
350
|
-
}
|
|
351
|
-
assertRunning(serviceName) {
|
|
352
|
-
if (this.status !== "running") {
|
|
353
|
-
throw new Error(
|
|
354
|
-
"[Service:" + serviceName + "] Cannot invoke operation while status is '" + this.status + "' (expected 'running')."
|
|
355
|
-
);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
var runtimeProcess = typeof globalThis !== "undefined" ? globalThis.process : void 0;
|
|
360
|
-
var runtimePerformance = typeof globalThis !== "undefined" ? globalThis.performance : void 0;
|
|
361
|
-
function telemetryNow() {
|
|
362
|
-
return runtimePerformance?.now ? runtimePerformance.now() : Date.now();
|
|
363
|
-
}
|
|
364
|
-
function sampleResources() {
|
|
365
|
-
const memory = runtimeProcess?.memoryUsage?.();
|
|
366
|
-
const cpu = runtimeProcess?.cpuUsage?.();
|
|
367
|
-
const eventLoop = runtimePerformance?.eventLoopUtilization?.();
|
|
368
|
-
return {
|
|
369
|
-
cpuUserMicros: cpu?.user,
|
|
370
|
-
cpuSystemMicros: cpu?.system,
|
|
371
|
-
heapUsedBytes: memory?.heapUsed,
|
|
372
|
-
heapTotalBytes: memory?.heapTotal,
|
|
373
|
-
rssBytes: memory?.rss,
|
|
374
|
-
externalBytes: memory?.external,
|
|
375
|
-
arrayBuffersBytes: memory?.arrayBuffers,
|
|
376
|
-
eventLoopUtilization: eventLoop?.utilization,
|
|
377
|
-
scope: memory || cpu || eventLoop ? "process" : "runtime"
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
function deltaResources(start, end) {
|
|
381
|
-
const delta = (a, b) => a === void 0 || b === void 0 ? void 0 : b - a;
|
|
382
|
-
return {
|
|
383
|
-
cpuUserMicros: delta(start.cpuUserMicros, end.cpuUserMicros),
|
|
384
|
-
cpuSystemMicros: delta(start.cpuSystemMicros, end.cpuSystemMicros),
|
|
385
|
-
heapUsedBytes: delta(start.heapUsedBytes, end.heapUsedBytes),
|
|
386
|
-
heapTotalBytes: delta(start.heapTotalBytes, end.heapTotalBytes),
|
|
387
|
-
rssBytes: delta(start.rssBytes, end.rssBytes),
|
|
388
|
-
externalBytes: delta(start.externalBytes, end.externalBytes),
|
|
389
|
-
arrayBuffersBytes: delta(start.arrayBuffersBytes, end.arrayBuffersBytes),
|
|
390
|
-
eventLoopUtilization: delta(start.eventLoopUtilization, end.eventLoopUtilization),
|
|
391
|
-
scope: start.scope
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
var id = (prefix) => `${prefix}_${randomUUID()}`;
|
|
395
|
-
function percentiles(values) {
|
|
396
|
-
if (!values.length) return { min: 0, mean: 0, p50: 0, p90: 0, p95: 0, p99: 0, max: 0 };
|
|
397
|
-
const sorted = [...values].sort((a, b) => a - b);
|
|
398
|
-
const pick2 = (p) => sorted[Math.min(sorted.length - 1, Math.floor((sorted.length - 1) * p))];
|
|
399
|
-
return {
|
|
400
|
-
min: sorted[0],
|
|
401
|
-
mean: sorted.reduce((sum2, value) => sum2 + value, 0) / sorted.length,
|
|
402
|
-
p50: pick2(0.5),
|
|
403
|
-
p90: pick2(0.9),
|
|
404
|
-
p95: pick2(0.95),
|
|
405
|
-
p99: pick2(0.99),
|
|
406
|
-
max: sorted[sorted.length - 1]
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
var TelemetryController = class {
|
|
410
|
-
constructor(serviceId, options = {}) {
|
|
411
|
-
this.serviceId = serviceId;
|
|
412
|
-
this.mode = options.mode ?? "off";
|
|
413
|
-
this.maxSamples = Math.max(1, options.maxSamples ?? 2048);
|
|
414
|
-
this.maxRecentInvocations = Math.max(1, options.maxRecentInvocations ?? 100);
|
|
415
|
-
}
|
|
416
|
-
serviceId;
|
|
417
|
-
mode;
|
|
418
|
-
maxSamples;
|
|
419
|
-
maxRecentInvocations;
|
|
420
|
-
samples = [];
|
|
421
|
-
active = /* @__PURE__ */ new Map();
|
|
422
|
-
totalInvocationCount = 0;
|
|
423
|
-
totalSuccessCount = 0;
|
|
424
|
-
totalErrorCount = 0;
|
|
425
|
-
lastInvocationAt;
|
|
426
|
-
enable(mode = "standard") {
|
|
427
|
-
this.mode = mode;
|
|
428
|
-
}
|
|
429
|
-
disable() {
|
|
430
|
-
this.mode = "off";
|
|
431
|
-
this.active.clear();
|
|
432
|
-
}
|
|
433
|
-
setMode(mode) {
|
|
434
|
-
this.mode = mode;
|
|
435
|
-
if (mode === "off") this.active.clear();
|
|
436
|
-
}
|
|
437
|
-
getMode() {
|
|
438
|
-
return this.mode;
|
|
439
|
-
}
|
|
440
|
-
status() {
|
|
441
|
-
return {
|
|
442
|
-
enabled: this.mode !== "off",
|
|
443
|
-
mode: this.mode,
|
|
444
|
-
serviceId: this.serviceId,
|
|
445
|
-
invocationCount: this.totalInvocationCount,
|
|
446
|
-
activeInvocations: this.active.size,
|
|
447
|
-
lastInvocationAt: this.lastInvocationAt
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
begin(target, kind, correlationId, parentSpanId) {
|
|
451
|
-
if (this.mode === "off") {
|
|
452
|
-
return {
|
|
453
|
-
invocationId: "",
|
|
454
|
-
traceId: "",
|
|
455
|
-
spanId: "",
|
|
456
|
-
parentSpanId,
|
|
457
|
-
end: () => void 0
|
|
458
|
-
};
|
|
459
|
-
}
|
|
460
|
-
const invocationId = id("inv");
|
|
461
|
-
const spanId = id("span");
|
|
462
|
-
const traceId = parentSpanId ? this.findTraceId(parentSpanId) ?? id("trace") : id("trace");
|
|
463
|
-
const active = {
|
|
464
|
-
invocationId,
|
|
465
|
-
traceId,
|
|
466
|
-
spanId,
|
|
467
|
-
parentSpanId,
|
|
468
|
-
serviceId: this.serviceId,
|
|
469
|
-
target,
|
|
470
|
-
kind,
|
|
471
|
-
correlationId,
|
|
472
|
-
startedAt: telemetryNow(),
|
|
473
|
-
resourcesStart: this.mode === "standard" ? void 0 : sampleResources()
|
|
474
|
-
};
|
|
475
|
-
this.active.set(invocationId, active);
|
|
476
|
-
return {
|
|
477
|
-
invocationId,
|
|
478
|
-
traceId,
|
|
479
|
-
spanId,
|
|
480
|
-
parentSpanId,
|
|
481
|
-
end: (error) => this.finish(active, error)
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
reset() {
|
|
485
|
-
this.samples.length = 0;
|
|
486
|
-
this.active.clear();
|
|
487
|
-
this.totalInvocationCount = 0;
|
|
488
|
-
this.totalSuccessCount = 0;
|
|
489
|
-
this.totalErrorCount = 0;
|
|
490
|
-
this.lastInvocationAt = void 0;
|
|
491
|
-
}
|
|
492
|
-
snapshot() {
|
|
493
|
-
const invocations = this.samples.slice();
|
|
494
|
-
const durations = invocations.map((item) => item.durationMs);
|
|
495
|
-
const targetMap = /* @__PURE__ */ new Map();
|
|
496
|
-
for (const invocation of invocations) {
|
|
497
|
-
const key = `${invocation.kind}:${invocation.target}`;
|
|
498
|
-
const group = targetMap.get(key) ?? [];
|
|
499
|
-
group.push(invocation);
|
|
500
|
-
targetMap.set(key, group);
|
|
501
|
-
}
|
|
502
|
-
const targets = [...targetMap.values()].map((group) => ({
|
|
503
|
-
target: group[0].target,
|
|
504
|
-
kind: group[0].kind,
|
|
505
|
-
count: group.length,
|
|
506
|
-
successCount: group.filter((item) => item.status === "completed").length,
|
|
507
|
-
errorCount: group.filter((item) => item.status === "failed").length,
|
|
508
|
-
durationMs: percentiles(group.map((item) => item.durationMs)),
|
|
509
|
-
lastInvocationAt: group[group.length - 1]?.completedAt
|
|
510
|
-
}));
|
|
511
|
-
return {
|
|
512
|
-
serviceId: this.serviceId,
|
|
513
|
-
mode: this.mode,
|
|
514
|
-
capturedAt: Date.now(),
|
|
515
|
-
status: this.status(),
|
|
516
|
-
totals: {
|
|
517
|
-
invocationCount: this.totalInvocationCount,
|
|
518
|
-
successCount: this.totalSuccessCount,
|
|
519
|
-
errorCount: this.totalErrorCount,
|
|
520
|
-
durationMs: percentiles(durations)
|
|
521
|
-
},
|
|
522
|
-
targets,
|
|
523
|
-
activeInvocations: this.active.size,
|
|
524
|
-
recentInvocations: invocations.slice(-this.maxRecentInvocations)
|
|
525
|
-
};
|
|
526
|
-
}
|
|
527
|
-
functionality(name) {
|
|
528
|
-
return this.snapshot().targets.find((target) => target.kind === "functionality" && target.target === name);
|
|
529
|
-
}
|
|
530
|
-
functionalities() {
|
|
531
|
-
return this.snapshot().targets.filter((target) => target.kind === "functionality");
|
|
532
|
-
}
|
|
533
|
-
findTraceId(parentSpanId) {
|
|
534
|
-
for (let index = this.samples.length - 1; index >= 0; index -= 1) {
|
|
535
|
-
if (this.samples[index].spanId === parentSpanId) return this.samples[index].traceId;
|
|
536
|
-
}
|
|
537
|
-
for (const active of this.active.values()) {
|
|
538
|
-
if (active.spanId === parentSpanId) return active.traceId;
|
|
539
|
-
}
|
|
540
|
-
return void 0;
|
|
541
|
-
}
|
|
542
|
-
finish(active, error) {
|
|
543
|
-
if (!this.active.delete(active.invocationId)) return;
|
|
544
|
-
const completedAt = telemetryNow();
|
|
545
|
-
const resourcesEnd = this.mode === "standard" ? void 0 : sampleResources();
|
|
546
|
-
const invocation = {
|
|
547
|
-
invocationId: active.invocationId,
|
|
548
|
-
traceId: active.traceId,
|
|
549
|
-
spanId: active.spanId,
|
|
550
|
-
parentSpanId: active.parentSpanId,
|
|
551
|
-
serviceId: active.serviceId,
|
|
552
|
-
target: active.target,
|
|
553
|
-
kind: active.kind,
|
|
554
|
-
correlationId: active.correlationId,
|
|
555
|
-
startedAt: active.startedAt,
|
|
556
|
-
completedAt,
|
|
557
|
-
durationMs: Math.max(0, completedAt - active.startedAt),
|
|
558
|
-
status: error === void 0 ? "completed" : "failed",
|
|
559
|
-
error: error === void 0 ? void 0 : {
|
|
560
|
-
name: error instanceof Error ? error.name : "Error",
|
|
561
|
-
message: error instanceof Error ? error.message : String(error)
|
|
562
|
-
},
|
|
563
|
-
resources: active.resourcesStart && resourcesEnd ? { start: active.resourcesStart, end: resourcesEnd, delta: deltaResources(active.resourcesStart, resourcesEnd) } : void 0
|
|
564
|
-
};
|
|
565
|
-
this.samples.push(invocation);
|
|
566
|
-
this.totalInvocationCount += 1;
|
|
567
|
-
if (invocation.status === "completed") this.totalSuccessCount += 1;
|
|
568
|
-
else this.totalErrorCount += 1;
|
|
569
|
-
if (this.samples.length > this.maxSamples) this.samples.splice(0, this.samples.length - this.maxSamples);
|
|
570
|
-
this.lastInvocationAt = Date.now();
|
|
571
|
-
}
|
|
572
|
-
};
|
|
573
|
-
var ServiceInstance = class {
|
|
574
|
-
constructor(definition) {
|
|
575
|
-
this.definition = definition;
|
|
576
|
-
this.id = definition.id;
|
|
577
|
-
this.name = definition.name;
|
|
578
|
-
this.version = definition.version;
|
|
579
|
-
this.telemetry = new TelemetryController(this.id);
|
|
580
|
-
this.lifecycle = new LifecycleManager();
|
|
581
|
-
if (definition.state) {
|
|
582
|
-
this.stateStore = new ServiceStateStore(definition.state.initial);
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
definition;
|
|
586
|
-
id;
|
|
587
|
-
name;
|
|
588
|
-
version;
|
|
589
|
-
telemetry;
|
|
590
|
-
stateStore;
|
|
591
|
-
lifecycle;
|
|
592
|
-
initialized = false;
|
|
593
|
-
disposed = false;
|
|
594
|
-
getDefinition() {
|
|
595
|
-
return this.definition;
|
|
596
|
-
}
|
|
597
|
-
getStatus() {
|
|
598
|
-
return this.lifecycle.getStatus();
|
|
599
|
-
}
|
|
600
|
-
async start() {
|
|
601
|
-
if (this.disposed) throw new Error("[Service:" + this.name + "] Cannot start a disposed service.");
|
|
602
|
-
const current = this.lifecycle.getStatus();
|
|
603
|
-
if (current === "running") return;
|
|
604
|
-
if (current === "initializing" || current === "starting" || current === "stopping") {
|
|
605
|
-
throw new Error("[Service:" + this.name + "] Cannot start while status is '" + current + "'.");
|
|
606
|
-
}
|
|
607
|
-
if (!this.initialized) {
|
|
608
|
-
this.lifecycle.transitionTo("initializing");
|
|
609
|
-
try {
|
|
610
|
-
await this.definition.lifecycle?.onInit?.();
|
|
611
|
-
this.initialized = true;
|
|
612
|
-
this.lifecycle.transitionTo("ready");
|
|
613
|
-
} catch (error) {
|
|
614
|
-
this.lifecycle.transitionTo("uninitialized");
|
|
615
|
-
throw error;
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
this.lifecycle.transitionTo("starting");
|
|
619
|
-
try {
|
|
620
|
-
await this.definition.lifecycle?.onStart?.();
|
|
621
|
-
this.lifecycle.transitionTo("running");
|
|
622
|
-
} catch (error) {
|
|
623
|
-
this.lifecycle.transitionTo("ready");
|
|
624
|
-
throw error;
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
async stop() {
|
|
628
|
-
const current = this.lifecycle.getStatus();
|
|
629
|
-
if (current === "stopped") return;
|
|
630
|
-
if (current !== "running") {
|
|
631
|
-
throw new Error("[Service:" + this.name + "] Cannot stop while status is '" + current + "'.");
|
|
632
|
-
}
|
|
633
|
-
this.lifecycle.transitionTo("stopping");
|
|
634
|
-
try {
|
|
635
|
-
await this.definition.lifecycle?.onStop?.();
|
|
636
|
-
this.lifecycle.transitionTo("stopped");
|
|
637
|
-
} catch (error) {
|
|
638
|
-
this.lifecycle.transitionTo("running");
|
|
639
|
-
throw error;
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
async dispose() {
|
|
643
|
-
if (this.disposed) return;
|
|
644
|
-
if (this.lifecycle.getStatus() === "running") await this.stop();
|
|
645
|
-
await this.definition.lifecycle?.onDispose?.();
|
|
646
|
-
this.disposed = true;
|
|
647
|
-
}
|
|
648
|
-
async call(op, input, ctx = {}) {
|
|
649
|
-
this.lifecycle.assertRunning(this.name);
|
|
650
|
-
const operation = this.definition.operations[op];
|
|
651
|
-
if (!operation) {
|
|
652
|
-
throw new Error("[Service:" + this.name + "] Operation '" + op + "' not found.");
|
|
653
|
-
}
|
|
654
|
-
if (ctx.metadata?.__krnlTelemetryInternal === true) {
|
|
655
|
-
return await operation.handler(input, ctx);
|
|
656
|
-
}
|
|
657
|
-
const parentSpanId = typeof ctx.metadata?.__krnlTelemetryParentSpanId === "string" ? ctx.metadata.__krnlTelemetryParentSpanId : void 0;
|
|
658
|
-
const handle = this.telemetry.begin(op, "service", ctx.correlationId, parentSpanId);
|
|
659
|
-
try {
|
|
660
|
-
const output = await operation.handler(input, ctx);
|
|
661
|
-
handle.end();
|
|
662
|
-
return output;
|
|
663
|
-
} catch (error) {
|
|
664
|
-
handle.end(error);
|
|
665
|
-
throw error;
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
getState() {
|
|
669
|
-
return this.stateStore?.getState() ?? Object.freeze({});
|
|
670
|
-
}
|
|
671
|
-
setState(mutation) {
|
|
672
|
-
if (!this.stateStore) {
|
|
673
|
-
this.stateStore = new ServiceStateStore({ ...mutation });
|
|
674
|
-
return;
|
|
675
|
-
}
|
|
676
|
-
this.stateStore.setState(mutation);
|
|
677
|
-
}
|
|
678
|
-
};
|
|
679
|
-
function assertRecord(value, field) {
|
|
680
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
681
|
-
throw new Error("[KrnlTS] Invalid service definition: '" + field + "' must be an object.");
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
function assertNonEmptyString(value, field) {
|
|
685
|
-
if (typeof value !== "string" || value.trim().length === 0) {
|
|
686
|
-
throw new Error("[KrnlTS] Invalid service definition: '" + field + "' must be a non-empty string.");
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
function validateServiceDefinition(definition) {
|
|
690
|
-
if (!definition || typeof definition !== "object") {
|
|
691
|
-
throw new Error("[KrnlTS] Invalid service definition: expected an object.");
|
|
692
|
-
}
|
|
693
|
-
assertNonEmptyString(definition.id, "id");
|
|
694
|
-
assertNonEmptyString(definition.name, "name");
|
|
695
|
-
assertNonEmptyString(definition.version, "version");
|
|
696
|
-
if (!definition.operations || typeof definition.operations !== "object") {
|
|
697
|
-
throw new Error("[Service:" + definition.name + "] Invalid operations: expected an object.");
|
|
698
|
-
}
|
|
699
|
-
for (const [key, operation] of Object.entries(definition.operations)) {
|
|
700
|
-
if (!operation || typeof operation !== "object") {
|
|
701
|
-
throw new Error("[Service:" + definition.name + "] Invalid operation '" + key + "'.");
|
|
702
|
-
}
|
|
703
|
-
assertNonEmptyString(operation.id, "operations." + key + ".id");
|
|
704
|
-
assertNonEmptyString(operation.name, "operations." + key + ".name");
|
|
705
|
-
if (operation.inputSchema !== void 0) assertRecord(operation.inputSchema, "operations." + key + ".inputSchema");
|
|
706
|
-
if (operation.outputSchema !== void 0) assertRecord(operation.outputSchema, "operations." + key + ".outputSchema");
|
|
707
|
-
if (typeof operation.handler !== "function") {
|
|
708
|
-
throw new Error("[Service:" + definition.name + "] Operation '" + key + "' must define a handler.");
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
for (const [key, schema] of Object.entries(definition.inputs ?? {})) assertRecord(schema, "inputs." + key);
|
|
712
|
-
for (const [key, schema] of Object.entries(definition.outputs ?? {})) assertRecord(schema, "outputs." + key);
|
|
713
|
-
if (definition.state?.schema !== void 0) assertRecord(definition.state.schema, "state.schema");
|
|
714
|
-
for (const capability of definition.capabilities ?? []) {
|
|
715
|
-
assertNonEmptyString(capability.id, "capability.id");
|
|
716
|
-
assertNonEmptyString(capability.name, "capability.name");
|
|
717
|
-
if (!Array.isArray(capability.protocols)) {
|
|
718
|
-
throw new Error("[Service:" + definition.name + "] Capability '" + capability.name + "' protocols must be an array.");
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
for (const dependency of definition.dependencies ?? []) {
|
|
722
|
-
assertNonEmptyString(dependency.serviceId, "dependency.serviceId");
|
|
723
|
-
}
|
|
724
|
-
return definition;
|
|
725
|
-
}
|
|
726
|
-
function createServiceDefinition(definition) {
|
|
727
|
-
return validateServiceDefinition(definition);
|
|
728
|
-
}
|
|
729
|
-
function createService(definition) {
|
|
730
|
-
return new ServiceInstance(validateServiceDefinition(definition));
|
|
731
|
-
}
|
|
732
|
-
var asyncHooks = globalThis.process?.getBuiltinModule?.("node:async_hooks");
|
|
733
|
-
|
|
734
|
-
// src/string.ts
|
|
735
|
-
function toCamelCase(str) {
|
|
736
|
-
return str.replace(/[-_]+/g, " ").replace(/[^\w\s]/g, "").replace(
|
|
737
|
-
/(?:^\w|[A-Z]|\b\w)/g,
|
|
738
|
-
(word, index) => index === 0 ? word.toLowerCase() : word.toUpperCase()
|
|
739
|
-
).replace(/\s+/g, "");
|
|
740
|
-
}
|
|
741
|
-
function toPascalCase(str) {
|
|
742
|
-
const camel = toCamelCase(str);
|
|
743
|
-
return camel.charAt(0).toUpperCase() + camel.slice(1);
|
|
744
|
-
}
|
|
745
|
-
function toSnakeCase(str) {
|
|
746
|
-
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`).replace(/[-_\s]+/g, "_").replace(/^[_\s]+|[_\s]+$/g, "").toLowerCase();
|
|
747
|
-
}
|
|
748
|
-
function toKebabCase(str) {
|
|
749
|
-
return str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`).replace(/[-_\s]+/g, "-").replace(/^[-_\s]+|[-_\s]+$/g, "").toLowerCase();
|
|
750
|
-
}
|
|
751
|
-
function toScreamingSnake(str) {
|
|
752
|
-
return toSnakeCase(str).toUpperCase();
|
|
753
|
-
}
|
|
754
|
-
function toSlug(str) {
|
|
755
|
-
return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9\s-_]/g, "").replace(/[\s-_]+/g, "-").replace(/^-+|-+$/g, "");
|
|
756
|
-
}
|
|
757
|
-
function uuid() {
|
|
758
|
-
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
|
|
759
|
-
return crypto.randomUUID();
|
|
760
|
-
}
|
|
761
|
-
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
762
|
-
const r = Math.random() * 16 | 0;
|
|
763
|
-
const v = c === "x" ? r : r & 3 | 8;
|
|
764
|
-
return v.toString(16);
|
|
765
|
-
});
|
|
766
|
-
}
|
|
767
|
-
function shortId(length = 8) {
|
|
768
|
-
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
|
769
|
-
let result = "";
|
|
770
|
-
for (let i = 0; i < length; i++) {
|
|
771
|
-
result += chars.charAt(Math.random() * chars.length | 0);
|
|
772
|
-
}
|
|
773
|
-
return result;
|
|
774
|
-
}
|
|
775
|
-
function prefixedId(prefix, length = 8) {
|
|
776
|
-
return `${prefix}-${shortId(length)}`;
|
|
777
|
-
}
|
|
778
|
-
function interpolate(tmpl, data) {
|
|
779
|
-
return tmpl.replace(/\{\{\s*(\w+)\s*\}\}/g, (_, key) => {
|
|
780
|
-
return data[key] !== void 0 ? String(data[key]) : `{{${key}}}`;
|
|
781
|
-
});
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
// src/base.ts
|
|
785
|
-
var SkipoBase = class {
|
|
786
|
-
/** Unique instance identifier */
|
|
787
|
-
instanceId;
|
|
788
|
-
/** Human-readable component name */
|
|
789
|
-
name;
|
|
790
|
-
/** Logger instance */
|
|
791
|
-
logger;
|
|
792
|
-
/** Whether this component has been initialized */
|
|
793
|
-
initialized = false;
|
|
794
|
-
/** Whether this component has been disposed */
|
|
795
|
-
disposed = false;
|
|
796
|
-
constructor(config = { name: "SkipoComponent" }) {
|
|
797
|
-
this.instanceId = shortId();
|
|
798
|
-
this.name = config?.name ?? "SkipoComponent";
|
|
799
|
-
this.logger = config?.logger ?? console;
|
|
800
|
-
}
|
|
801
|
-
/** Initialize the component. Call before use. */
|
|
802
|
-
async initialize() {
|
|
803
|
-
if (this.initialized) return;
|
|
804
|
-
this.logger.log(`[${this.name}:${this.instanceId}] Initializing`);
|
|
805
|
-
await this.onInitialize();
|
|
806
|
-
this.initialized = true;
|
|
807
|
-
}
|
|
808
|
-
/** Override to add custom initialization logic */
|
|
809
|
-
async onInitialize() {
|
|
810
|
-
}
|
|
811
|
-
/** Dispose the component and release resources */
|
|
812
|
-
async dispose() {
|
|
813
|
-
if (this.disposed) return;
|
|
814
|
-
this.logger.log(`[${this.name}:${this.instanceId}] Disposing`);
|
|
815
|
-
await this.onDispose();
|
|
816
|
-
this.disposed = true;
|
|
817
|
-
}
|
|
818
|
-
/** Override to add custom cleanup logic */
|
|
819
|
-
async onDispose() {
|
|
820
|
-
}
|
|
821
|
-
/** Guard: throws if not initialized */
|
|
822
|
-
ensureInitialized() {
|
|
823
|
-
if (!this.initialized) {
|
|
824
|
-
throw new Error(`${this.name} has not been initialized. Call initialize() first.`);
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
/** Guard: throws if already disposed */
|
|
828
|
-
ensureNotDisposed() {
|
|
829
|
-
if (this.disposed) {
|
|
830
|
-
throw new Error(`${this.name} has been disposed and cannot be used.`);
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
};
|
|
834
|
-
|
|
835
|
-
// src/async.ts
|
|
836
|
-
function sleep(ms) {
|
|
837
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
838
|
-
}
|
|
839
|
-
function withTimeout(promise, ms, label = "Operation") {
|
|
840
|
-
let timer;
|
|
841
|
-
const timeoutPromise = new Promise((_, reject) => {
|
|
842
|
-
timer = setTimeout(() => {
|
|
843
|
-
reject(new Error(`[SkipoTimeoutError] ${label} timed out after ${ms}ms`));
|
|
844
|
-
}, ms);
|
|
845
|
-
});
|
|
846
|
-
return Promise.race([
|
|
847
|
-
promise.then((val) => {
|
|
848
|
-
clearTimeout(timer);
|
|
849
|
-
return val;
|
|
850
|
-
}),
|
|
851
|
-
timeoutPromise
|
|
852
|
-
]);
|
|
853
|
-
}
|
|
854
|
-
async function retry(fn, maxAttempts, delayMs = 1e3) {
|
|
855
|
-
let attempts = 0;
|
|
856
|
-
while (attempts < maxAttempts) {
|
|
857
|
-
try {
|
|
858
|
-
return await fn();
|
|
859
|
-
} catch (err) {
|
|
860
|
-
attempts++;
|
|
861
|
-
if (attempts >= maxAttempts) {
|
|
862
|
-
throw err;
|
|
863
|
-
}
|
|
864
|
-
await sleep(delayMs);
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
throw new Error("Retry failed");
|
|
868
|
-
}
|
|
869
|
-
async function pLimit(tasks, concurrency) {
|
|
870
|
-
const results = [];
|
|
871
|
-
let index = 0;
|
|
872
|
-
const worker = async () => {
|
|
873
|
-
while (index < tasks.length) {
|
|
874
|
-
const i = index++;
|
|
875
|
-
results[i] = await tasks[i]();
|
|
876
|
-
}
|
|
877
|
-
};
|
|
878
|
-
const workers = [];
|
|
879
|
-
for (let i = 0; i < concurrency && i < tasks.length; i++) {
|
|
880
|
-
workers.push(worker());
|
|
881
|
-
}
|
|
882
|
-
await Promise.all(workers);
|
|
883
|
-
return results;
|
|
884
|
-
}
|
|
885
|
-
function debounce(fn, ms) {
|
|
886
|
-
let timer = null;
|
|
887
|
-
return (...args) => {
|
|
888
|
-
if (timer) clearTimeout(timer);
|
|
889
|
-
timer = setTimeout(() => fn(...args), ms);
|
|
890
|
-
};
|
|
891
|
-
}
|
|
892
|
-
function throttle(fn, ms) {
|
|
893
|
-
let lastCall = 0;
|
|
894
|
-
return (...args) => {
|
|
895
|
-
const now = Date.now();
|
|
896
|
-
if (now - lastCall >= ms) {
|
|
897
|
-
lastCall = now;
|
|
898
|
-
fn(...args);
|
|
899
|
-
}
|
|
900
|
-
};
|
|
901
|
-
}
|
|
902
|
-
function once(fn) {
|
|
903
|
-
let run = false;
|
|
904
|
-
let result;
|
|
905
|
-
return (...args) => {
|
|
906
|
-
if (!run) {
|
|
907
|
-
run = true;
|
|
908
|
-
result = fn(...args);
|
|
909
|
-
}
|
|
910
|
-
return result;
|
|
911
|
-
};
|
|
912
|
-
}
|
|
913
|
-
function memoize(fn, keyFn) {
|
|
914
|
-
const cache = /* @__PURE__ */ new Map();
|
|
915
|
-
return (...args) => {
|
|
916
|
-
const key = keyFn ? keyFn(...args) : JSON.stringify(args);
|
|
917
|
-
if (cache.has(key)) {
|
|
918
|
-
return cache.get(key);
|
|
919
|
-
}
|
|
920
|
-
const val = fn(...args);
|
|
921
|
-
cache.set(key, val);
|
|
922
|
-
return val;
|
|
923
|
-
};
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
// src/object.ts
|
|
927
|
-
function deepClone(obj, seen = /* @__PURE__ */ new Map()) {
|
|
928
|
-
if (obj === null || typeof obj !== "object") {
|
|
929
|
-
return obj;
|
|
930
|
-
}
|
|
931
|
-
if (seen.has(obj)) {
|
|
932
|
-
return seen.get(obj);
|
|
933
|
-
}
|
|
934
|
-
if (obj instanceof Date) {
|
|
935
|
-
return new Date(obj.getTime());
|
|
936
|
-
}
|
|
937
|
-
if (obj instanceof RegExp) {
|
|
938
|
-
return new RegExp(obj.source, obj.flags);
|
|
939
|
-
}
|
|
940
|
-
if (Array.isArray(obj)) {
|
|
941
|
-
const cloneArr = [];
|
|
942
|
-
seen.set(obj, cloneArr);
|
|
943
|
-
for (const item of obj) {
|
|
944
|
-
cloneArr.push(deepClone(item, seen));
|
|
945
|
-
}
|
|
946
|
-
return cloneArr;
|
|
947
|
-
}
|
|
948
|
-
const cloneObj = Object.create(Object.getPrototypeOf(obj));
|
|
949
|
-
seen.set(obj, cloneObj);
|
|
950
|
-
for (const key of Reflect.ownKeys(obj)) {
|
|
951
|
-
const descriptor = Reflect.getOwnPropertyDescriptor(obj, key);
|
|
952
|
-
if (descriptor) {
|
|
953
|
-
descriptor.value = deepClone(descriptor.value, seen);
|
|
954
|
-
Object.defineProperty(cloneObj, key, descriptor);
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
return cloneObj;
|
|
958
|
-
}
|
|
959
|
-
function deepMerge(base, ...overrides) {
|
|
960
|
-
let result = deepClone(base);
|
|
961
|
-
for (const override of overrides) {
|
|
962
|
-
if (override === null || typeof override !== "object") {
|
|
963
|
-
continue;
|
|
964
|
-
}
|
|
965
|
-
for (const key of Object.keys(override)) {
|
|
966
|
-
const val = override[key];
|
|
967
|
-
if (val === void 0) {
|
|
968
|
-
delete result[key];
|
|
969
|
-
} else if (val && typeof val === "object" && !Array.isArray(val)) {
|
|
970
|
-
if (result[key] && typeof result[key] === "object" && !Array.isArray(result[key])) {
|
|
971
|
-
result[key] = deepMerge(result[key], val);
|
|
972
|
-
} else {
|
|
973
|
-
result[key] = deepClone(val);
|
|
974
|
-
}
|
|
975
|
-
} else {
|
|
976
|
-
result[key] = deepClone(val);
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
return result;
|
|
981
|
-
}
|
|
982
|
-
function deepEqual(a, b) {
|
|
983
|
-
if (Object.is(a, b)) return true;
|
|
984
|
-
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) {
|
|
985
|
-
return false;
|
|
986
|
-
}
|
|
987
|
-
if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) {
|
|
988
|
-
return false;
|
|
989
|
-
}
|
|
990
|
-
if (a instanceof Date && b instanceof Date) {
|
|
991
|
-
return a.getTime() === b.getTime();
|
|
992
|
-
}
|
|
993
|
-
if (a instanceof RegExp && b instanceof RegExp) {
|
|
994
|
-
return a.toString() === b.toString();
|
|
995
|
-
}
|
|
996
|
-
const keysA = Reflect.ownKeys(a);
|
|
997
|
-
const keysB = Reflect.ownKeys(b);
|
|
998
|
-
if (keysA.length !== keysB.length) return false;
|
|
999
|
-
const setB = new Set(keysB);
|
|
1000
|
-
for (const key of keysA) {
|
|
1001
|
-
if (!setB.has(key)) return false;
|
|
1002
|
-
if (!deepEqual(a[key], b[key])) return false;
|
|
1003
|
-
}
|
|
1004
|
-
return true;
|
|
1005
|
-
}
|
|
1006
|
-
function objectDiff(before, after) {
|
|
1007
|
-
const added = {};
|
|
1008
|
-
const removed = {};
|
|
1009
|
-
const changed = {};
|
|
1010
|
-
if (before === null || typeof before !== "object" || after === null || typeof after !== "object") {
|
|
1011
|
-
return { added, removed, changed };
|
|
1012
|
-
}
|
|
1013
|
-
const keysBefore = Object.keys(before);
|
|
1014
|
-
const keysAfter = Object.keys(after);
|
|
1015
|
-
for (const key of keysAfter) {
|
|
1016
|
-
if (!(key in before)) {
|
|
1017
|
-
added[key] = deepClone(after[key]);
|
|
1018
|
-
} else if (!deepEqual(before[key], after[key])) {
|
|
1019
|
-
if (before[key] && typeof before[key] === "object" && after[key] && typeof after[key] === "object" && !Array.isArray(before[key]) && !Array.isArray(after[key])) {
|
|
1020
|
-
const nested = objectDiff(before[key], after[key]);
|
|
1021
|
-
if (Object.keys(nested.added).length > 0 || Object.keys(nested.removed).length > 0 || Object.keys(nested.changed).length > 0) {
|
|
1022
|
-
changed[key] = nested;
|
|
1023
|
-
}
|
|
1024
|
-
} else {
|
|
1025
|
-
changed[key] = { from: deepClone(before[key]), to: deepClone(after[key]) };
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
for (const key of keysBefore) {
|
|
1030
|
-
if (!(key in after)) {
|
|
1031
|
-
removed[key] = deepClone(before[key]);
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
return { added, removed, changed };
|
|
1035
|
-
}
|
|
1036
|
-
function getPath(obj, path7, defaultValue) {
|
|
1037
|
-
if (!path7) return obj;
|
|
1038
|
-
const parts = path7.split(".");
|
|
1039
|
-
let current = obj;
|
|
1040
|
-
for (const part of parts) {
|
|
1041
|
-
if (current === null || current === void 0) {
|
|
1042
|
-
return defaultValue;
|
|
1043
|
-
}
|
|
1044
|
-
current = current[part];
|
|
1045
|
-
}
|
|
1046
|
-
return current !== void 0 ? current : defaultValue;
|
|
1047
|
-
}
|
|
1048
|
-
function setPath(obj, path7, value) {
|
|
1049
|
-
if (!path7) return obj;
|
|
1050
|
-
const parts = path7.split(".");
|
|
1051
|
-
let current = obj;
|
|
1052
|
-
for (let i = 0; i < parts.length - 1; i++) {
|
|
1053
|
-
const part = parts[i];
|
|
1054
|
-
if (current[part] === void 0 || current[part] === null) {
|
|
1055
|
-
current[part] = {};
|
|
1056
|
-
}
|
|
1057
|
-
current = current[part];
|
|
1058
|
-
}
|
|
1059
|
-
current[parts[parts.length - 1]] = value;
|
|
1060
|
-
return obj;
|
|
1061
|
-
}
|
|
1062
|
-
|
|
1063
|
-
// src/cache.ts
|
|
1064
|
-
import fs2 from "fs";
|
|
1065
|
-
import path2 from "path";
|
|
1066
|
-
var LRUCache = class {
|
|
1067
|
-
maxSize;
|
|
1068
|
-
cache;
|
|
1069
|
-
constructor(maxSize) {
|
|
1070
|
-
this.maxSize = maxSize;
|
|
1071
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
1072
|
-
}
|
|
1073
|
-
get(key) {
|
|
1074
|
-
if (!this.cache.has(key)) return void 0;
|
|
1075
|
-
const val = this.cache.get(key);
|
|
1076
|
-
this.cache.delete(key);
|
|
1077
|
-
this.cache.set(key, val);
|
|
1078
|
-
return val;
|
|
1079
|
-
}
|
|
1080
|
-
set(key, value) {
|
|
1081
|
-
if (this.cache.has(key)) {
|
|
1082
|
-
this.cache.delete(key);
|
|
1083
|
-
} else if (this.cache.size >= this.maxSize) {
|
|
1084
|
-
const firstKey = this.cache.keys().next().value;
|
|
1085
|
-
if (firstKey !== void 0) this.cache.delete(firstKey);
|
|
1086
|
-
}
|
|
1087
|
-
this.cache.set(key, value);
|
|
1088
|
-
}
|
|
1089
|
-
delete(key) {
|
|
1090
|
-
return this.cache.delete(key);
|
|
1091
|
-
}
|
|
1092
|
-
clear() {
|
|
1093
|
-
this.cache.clear();
|
|
1094
|
-
}
|
|
1095
|
-
size() {
|
|
1096
|
-
return this.cache.size;
|
|
1097
|
-
}
|
|
1098
|
-
};
|
|
1099
|
-
var TTLCache = class {
|
|
1100
|
-
ttlMs;
|
|
1101
|
-
cache;
|
|
1102
|
-
constructor(ttlMs) {
|
|
1103
|
-
this.ttlMs = ttlMs;
|
|
1104
|
-
this.cache = /* @__PURE__ */ new Map();
|
|
1105
|
-
}
|
|
1106
|
-
get(key) {
|
|
1107
|
-
const entry = this.cache.get(key);
|
|
1108
|
-
if (!entry) return null;
|
|
1109
|
-
if (Date.now() > entry.expires) {
|
|
1110
|
-
this.cache.delete(key);
|
|
1111
|
-
return null;
|
|
1112
|
-
}
|
|
1113
|
-
return entry.value;
|
|
1114
|
-
}
|
|
1115
|
-
set(key, value) {
|
|
1116
|
-
this.cache.set(key, {
|
|
1117
|
-
value,
|
|
1118
|
-
expires: Date.now() + this.ttlMs
|
|
1119
|
-
});
|
|
1120
|
-
}
|
|
1121
|
-
delete(key) {
|
|
1122
|
-
return this.cache.delete(key);
|
|
1123
|
-
}
|
|
1124
|
-
clear() {
|
|
1125
|
-
this.cache.clear();
|
|
1126
|
-
}
|
|
1127
|
-
};
|
|
1128
|
-
function swr(cache, key, fetchFn) {
|
|
1129
|
-
const cached = cache.get(key);
|
|
1130
|
-
if (cached !== null) {
|
|
1131
|
-
setTimeout(() => {
|
|
1132
|
-
fetchFn().then((fresh) => cache.set(key, fresh)).catch(() => {
|
|
1133
|
-
});
|
|
1134
|
-
}, 0);
|
|
1135
|
-
return Promise.resolve(cached);
|
|
1136
|
-
}
|
|
1137
|
-
return fetchFn().then((fresh) => {
|
|
1138
|
-
cache.set(key, fresh);
|
|
1139
|
-
return fresh;
|
|
1140
|
-
});
|
|
1141
|
-
}
|
|
1142
|
-
var FileCache = class {
|
|
1143
|
-
cacheDir;
|
|
1144
|
-
constructor(cacheDir) {
|
|
1145
|
-
this.cacheDir = cacheDir;
|
|
1146
|
-
try {
|
|
1147
|
-
if (!fs2.existsSync(cacheDir)) {
|
|
1148
|
-
fs2.mkdirSync(cacheDir, { recursive: true });
|
|
1149
|
-
}
|
|
1150
|
-
} catch (e) {
|
|
1151
|
-
}
|
|
1152
|
-
}
|
|
1153
|
-
getFilePath(key) {
|
|
1154
|
-
return path2.join(this.cacheDir, `${encodeURIComponent(key)}.json`);
|
|
1155
|
-
}
|
|
1156
|
-
get(key) {
|
|
1157
|
-
const file = this.getFilePath(key);
|
|
1158
|
-
if (!fs2.existsSync(file)) return null;
|
|
1159
|
-
try {
|
|
1160
|
-
const content = fs2.readFileSync(file, "utf8");
|
|
1161
|
-
return JSON.parse(content);
|
|
1162
|
-
} catch (e) {
|
|
1163
|
-
return null;
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
set(key, value) {
|
|
1167
|
-
const file = this.getFilePath(key);
|
|
1168
|
-
try {
|
|
1169
|
-
fs2.writeFileSync(file, JSON.stringify(value, null, 2), "utf8");
|
|
1170
|
-
} catch (e) {
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
delete(key) {
|
|
1174
|
-
const file = this.getFilePath(key);
|
|
1175
|
-
if (fs2.existsSync(file)) {
|
|
1176
|
-
try {
|
|
1177
|
-
fs2.unlinkSync(file);
|
|
1178
|
-
} catch (e) {
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
clear() {
|
|
1183
|
-
try {
|
|
1184
|
-
const files = fs2.readdirSync(this.cacheDir);
|
|
1185
|
-
for (const file of files) {
|
|
1186
|
-
fs2.unlinkSync(path2.join(this.cacheDir, file));
|
|
1187
|
-
}
|
|
1188
|
-
} catch (e) {
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
};
|
|
1192
|
-
|
|
1193
|
-
// src/env.ts
|
|
1194
|
-
import fs3 from "fs";
|
|
1195
|
-
import path3 from "path";
|
|
1196
|
-
function getEnv(key, defaultValue) {
|
|
1197
|
-
const val = process.env[key];
|
|
1198
|
-
if (val === void 0) {
|
|
1199
|
-
if (defaultValue !== void 0) return defaultValue;
|
|
1200
|
-
throw new Error(`[SkipoEnvError] Missing required environment variable: ${key}`);
|
|
1201
|
-
}
|
|
1202
|
-
if (typeof defaultValue === "number") {
|
|
1203
|
-
const num = Number(val);
|
|
1204
|
-
if (isNaN(num)) {
|
|
1205
|
-
throw new Error(`[SkipoEnvError] Expected number for ${key}, received: ${val}`);
|
|
1206
|
-
}
|
|
1207
|
-
return num;
|
|
1208
|
-
}
|
|
1209
|
-
if (typeof defaultValue === "boolean") {
|
|
1210
|
-
return val === "true" || val === "1";
|
|
1211
|
-
}
|
|
1212
|
-
try {
|
|
1213
|
-
if (defaultValue && typeof defaultValue === "object") {
|
|
1214
|
-
return JSON.parse(val);
|
|
1215
|
-
}
|
|
1216
|
-
} catch (e) {
|
|
1217
|
-
}
|
|
1218
|
-
return val;
|
|
1219
|
-
}
|
|
1220
|
-
function requireEnv(key) {
|
|
1221
|
-
const val = process.env[key];
|
|
1222
|
-
if (val === void 0) {
|
|
1223
|
-
throw new Error(`[SkipoEnvError] Missing required environment variable: ${key}`);
|
|
1224
|
-
}
|
|
1225
|
-
return val;
|
|
1226
|
-
}
|
|
1227
|
-
function loadEnv(filePath) {
|
|
1228
|
-
const file = filePath || path3.join(process.cwd(), ".env");
|
|
1229
|
-
if (!fs3.existsSync(file)) return;
|
|
1230
|
-
try {
|
|
1231
|
-
const content = fs3.readFileSync(file, "utf8");
|
|
1232
|
-
const lines = content.split(/\r?\n/);
|
|
1233
|
-
for (const line of lines) {
|
|
1234
|
-
const trimmed = line.trim();
|
|
1235
|
-
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
1236
|
-
const equalsIndex = trimmed.indexOf("=");
|
|
1237
|
-
if (equalsIndex === -1) continue;
|
|
1238
|
-
const key = trimmed.slice(0, equalsIndex).trim();
|
|
1239
|
-
let value = trimmed.slice(equalsIndex + 1).trim();
|
|
1240
|
-
if (value.startsWith('"') && value.endsWith('"')) {
|
|
1241
|
-
value = value.slice(1, -1);
|
|
1242
|
-
} else if (value.startsWith("'") && value.endsWith("'")) {
|
|
1243
|
-
value = value.slice(1, -1);
|
|
1244
|
-
}
|
|
1245
|
-
if (process.env[key] === void 0) {
|
|
1246
|
-
process.env[key] = value;
|
|
1247
|
-
}
|
|
1248
|
-
}
|
|
1249
|
-
} catch (e) {
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
function validateEnvSchema(zodSchema) {
|
|
1253
|
-
try {
|
|
1254
|
-
return zodSchema.parse(process.env);
|
|
1255
|
-
} catch (err) {
|
|
1256
|
-
throw new Error(`[SkipoEnvError] Environment validation failed: ${err.message || String(err)}`);
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
function isPlaceholderConnection(url) {
|
|
1260
|
-
if (!url || typeof url !== "string") return true;
|
|
1261
|
-
const trimmed = url.trim().toLowerCase();
|
|
1262
|
-
const placeholders = [
|
|
1263
|
-
"ep-sample",
|
|
1264
|
-
"example.com",
|
|
1265
|
-
"placeholder",
|
|
1266
|
-
"user:password@",
|
|
1267
|
-
"my_database",
|
|
1268
|
-
"your_password",
|
|
1269
|
-
"xxx.neon.tech",
|
|
1270
|
-
"username:password"
|
|
1271
|
-
];
|
|
1272
|
-
return placeholders.some((p) => trimmed.includes(p));
|
|
1273
|
-
}
|
|
1274
|
-
function sanitizeDatabaseUrl(url) {
|
|
1275
|
-
if (!url || isPlaceholderConnection(url)) return void 0;
|
|
1276
|
-
return url.trim();
|
|
1277
|
-
}
|
|
1278
|
-
|
|
1279
|
-
// src/http.ts
|
|
1280
|
-
async function requestRaw(url, opts = {}) {
|
|
1281
|
-
const timeout = opts.timeout || 6e4;
|
|
1282
|
-
const retries = opts.retries || 0;
|
|
1283
|
-
const perform = async () => {
|
|
1284
|
-
const controller = new AbortController();
|
|
1285
|
-
const id2 = setTimeout(() => controller.abort(), timeout);
|
|
1286
|
-
try {
|
|
1287
|
-
const response = await fetch(url, {
|
|
1288
|
-
...opts,
|
|
1289
|
-
signal: controller.signal
|
|
1290
|
-
});
|
|
1291
|
-
clearTimeout(id2);
|
|
1292
|
-
return response;
|
|
1293
|
-
} catch (e) {
|
|
1294
|
-
clearTimeout(id2);
|
|
1295
|
-
throw e;
|
|
1296
|
-
}
|
|
1297
|
-
};
|
|
1298
|
-
return await retry(perform, retries + 1, 1e3);
|
|
1299
|
-
}
|
|
1300
|
-
async function request(url, opts = {}) {
|
|
1301
|
-
try {
|
|
1302
|
-
const res = await requestRaw(url, opts);
|
|
1303
|
-
const contentType = res.headers.get("content-type") || "";
|
|
1304
|
-
const isJson = contentType.toLowerCase().includes("application/json");
|
|
1305
|
-
if (!res.ok) {
|
|
1306
|
-
let errorMessage = `HTTP Error ${res.status}: ${res.statusText}`;
|
|
1307
|
-
try {
|
|
1308
|
-
if (isJson) {
|
|
1309
|
-
const errData = await res.json();
|
|
1310
|
-
errorMessage = errData?.message || errData?.error || errorMessage;
|
|
1311
|
-
} else {
|
|
1312
|
-
const rawText = await res.text();
|
|
1313
|
-
if (rawText.trim()) {
|
|
1314
|
-
errorMessage = rawText.length > 200 ? `${rawText.slice(0, 200)}...` : rawText;
|
|
1315
|
-
}
|
|
1316
|
-
}
|
|
1317
|
-
} catch {
|
|
1318
|
-
}
|
|
1319
|
-
return { status: "error", message: errorMessage, code: res.status };
|
|
1320
|
-
}
|
|
1321
|
-
if (!isJson) {
|
|
1322
|
-
const text = await res.text();
|
|
1323
|
-
return {
|
|
1324
|
-
status: "error",
|
|
1325
|
-
message: `Expected JSON response but received "${contentType || "text/plain"}": ${text.slice(0, 100)}`,
|
|
1326
|
-
code: res.status
|
|
1327
|
-
};
|
|
1328
|
-
}
|
|
1329
|
-
const data = await res.json();
|
|
1330
|
-
return { status: "success", data };
|
|
1331
|
-
} catch (e) {
|
|
1332
|
-
return { status: "error", message: e.message || String(e) };
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
async function get(url, opts = {}) {
|
|
1336
|
-
return await request(url, { ...opts, method: "GET" });
|
|
1337
|
-
}
|
|
1338
|
-
async function post(url, body, opts = {}) {
|
|
1339
|
-
return await request(url, {
|
|
1340
|
-
...opts,
|
|
1341
|
-
method: "POST",
|
|
1342
|
-
headers: { "Content-Type": "application/json", ...opts.headers },
|
|
1343
|
-
body: JSON.stringify(body)
|
|
1344
|
-
});
|
|
1345
|
-
}
|
|
1346
|
-
async function put(url, body, opts = {}) {
|
|
1347
|
-
return await request(url, {
|
|
1348
|
-
...opts,
|
|
1349
|
-
method: "PUT",
|
|
1350
|
-
headers: { "Content-Type": "application/json", ...opts.headers },
|
|
1351
|
-
body: JSON.stringify(body)
|
|
1352
|
-
});
|
|
1353
|
-
}
|
|
1354
|
-
async function del(url, opts = {}) {
|
|
1355
|
-
return await request(url, { ...opts, method: "DELETE" });
|
|
1356
|
-
}
|
|
1357
|
-
function createClient(baseUrl, defaultHeaders = {}) {
|
|
1358
|
-
return {
|
|
1359
|
-
get: (path7, opts = {}) => get(`${baseUrl}${path7}`, { ...opts, headers: { ...defaultHeaders, ...opts.headers } }),
|
|
1360
|
-
post: (path7, body, opts = {}) => post(`${baseUrl}${path7}`, body, { ...opts, headers: { ...defaultHeaders, ...opts.headers } }),
|
|
1361
|
-
put: (path7, body, opts = {}) => put(`${baseUrl}${path7}`, body, { ...opts, headers: { ...defaultHeaders, ...opts.headers } }),
|
|
1362
|
-
del: (path7, opts = {}) => del(`${baseUrl}${path7}`, { ...opts, headers: { ...defaultHeaders, ...opts.headers } })
|
|
1363
|
-
};
|
|
1364
|
-
}
|
|
1365
|
-
async function* streamResponse(url, opts = {}) {
|
|
1366
|
-
const res = await requestRaw(url, opts);
|
|
1367
|
-
if (!res.ok || !res.body) {
|
|
1368
|
-
throw new Error(`Failed to initialize stream: HTTP ${res.status}`);
|
|
1369
|
-
}
|
|
1370
|
-
const reader = res.body.getReader();
|
|
1371
|
-
const decoder = new TextDecoder();
|
|
1372
|
-
try {
|
|
1373
|
-
while (true) {
|
|
1374
|
-
const { done, value } = await reader.read();
|
|
1375
|
-
if (done) break;
|
|
1376
|
-
yield decoder.decode(value, { stream: true });
|
|
1377
|
-
}
|
|
1378
|
-
} finally {
|
|
1379
|
-
reader.releaseLock();
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
|
|
1383
|
-
// src/shell.ts
|
|
1384
|
-
import childProcess from "child_process";
|
|
1385
|
-
import path4 from "path";
|
|
1386
|
-
import fs4 from "fs";
|
|
1387
|
-
function execCmd(cmd, opts = {}) {
|
|
1388
|
-
const timeout = opts.timeout || 3e4;
|
|
1389
|
-
return new Promise((resolve, reject) => {
|
|
1390
|
-
childProcess.exec(cmd, { ...opts, timeout }, (error, stdout, stderr) => {
|
|
1391
|
-
if (error) {
|
|
1392
|
-
reject(new Error(`[SkipoShellError] Command failed: ${cmd}
|
|
1393
|
-
Exit Code: ${error.code}
|
|
1394
|
-
Stderr: ${String(stderr)}`));
|
|
1395
|
-
} else {
|
|
1396
|
-
resolve({ stdout: String(stdout), stderr: String(stderr) });
|
|
1397
|
-
}
|
|
1398
|
-
});
|
|
1399
|
-
});
|
|
1400
|
-
}
|
|
1401
|
-
function spawnCmd(cmd, args, opts = {}) {
|
|
1402
|
-
const child = childProcess.spawn(cmd, args, opts);
|
|
1403
|
-
const promise = new Promise((resolve, reject) => {
|
|
1404
|
-
child.on("close", (code, signal) => {
|
|
1405
|
-
resolve({ code, signal });
|
|
1406
|
-
});
|
|
1407
|
-
child.on("error", (err) => {
|
|
1408
|
-
reject(err);
|
|
1409
|
-
});
|
|
1410
|
-
});
|
|
1411
|
-
return {
|
|
1412
|
-
pid: child.pid,
|
|
1413
|
-
kill: (signal) => child.kill(signal),
|
|
1414
|
-
promise
|
|
1415
|
-
};
|
|
1416
|
-
}
|
|
1417
|
-
function platform(routing) {
|
|
1418
|
-
return process.platform === "win32" ? routing.win32 : routing.posix;
|
|
1419
|
-
}
|
|
1420
|
-
function which(cmd) {
|
|
1421
|
-
const envPath = process.env.PATH || "";
|
|
1422
|
-
const paths = envPath.split(path4.delimiter);
|
|
1423
|
-
const extensions = process.platform === "win32" ? [".exe", ".cmd", ".bat", ""] : [""];
|
|
1424
|
-
for (const p of paths) {
|
|
1425
|
-
for (const ext of extensions) {
|
|
1426
|
-
const fullPath = path4.join(p, `${cmd}${ext}`);
|
|
1427
|
-
try {
|
|
1428
|
-
if (fs4.existsSync(fullPath) && fs4.statSync(fullPath).isFile()) {
|
|
1429
|
-
return fullPath;
|
|
1430
|
-
}
|
|
1431
|
-
} catch (e) {
|
|
1432
|
-
}
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
|
-
return null;
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1438
|
-
// src/fs-lock.ts
|
|
1439
|
-
import path5 from "path";
|
|
1440
|
-
var FileLock = class _FileLock {
|
|
1441
|
-
static locks = /* @__PURE__ */ new Map();
|
|
1442
|
-
static async acquire(filePath) {
|
|
1443
|
-
const resolvedPath = path5.resolve(filePath);
|
|
1444
|
-
const existing = _FileLock.locks.get(resolvedPath) || Promise.resolve();
|
|
1445
|
-
let release = () => {
|
|
1446
|
-
};
|
|
1447
|
-
const nextLock = new Promise((resolve) => {
|
|
1448
|
-
release = () => {
|
|
1449
|
-
_FileLock.locks.delete(resolvedPath);
|
|
1450
|
-
resolve();
|
|
1451
|
-
};
|
|
1452
|
-
});
|
|
1453
|
-
_FileLock.locks.set(resolvedPath, nextLock);
|
|
1454
|
-
await existing;
|
|
1455
|
-
return release;
|
|
1456
|
-
}
|
|
1457
|
-
};
|
|
1458
|
-
|
|
1459
|
-
// src/fs.ts
|
|
1460
|
-
import fs5 from "fs";
|
|
1461
|
-
import fsp from "fs/promises";
|
|
1462
|
-
import path6 from "path";
|
|
1463
|
-
import os2 from "os";
|
|
1464
|
-
async function readFile(filePath, encoding = "utf8") {
|
|
1465
|
-
return await fsp.readFile(filePath, encoding);
|
|
1466
|
-
}
|
|
1467
|
-
async function writeFile(filePath, content) {
|
|
1468
|
-
await fsp.writeFile(filePath, content);
|
|
1469
|
-
}
|
|
1470
|
-
async function writeFileAtomic(filePath, content) {
|
|
1471
|
-
const dir = path6.dirname(filePath);
|
|
1472
|
-
await ensureDir(dir);
|
|
1473
|
-
const tempFile = path6.join(dir, `.${path6.basename(filePath)}.tmp_${Date.now()}_${Math.random().toString(36).substring(7)}`);
|
|
1474
|
-
try {
|
|
1475
|
-
await fsp.writeFile(tempFile, content);
|
|
1476
|
-
await fsp.rename(tempFile, filePath);
|
|
1477
|
-
} catch (e) {
|
|
1478
|
-
if (fs5.existsSync(tempFile)) {
|
|
1479
|
-
await fsp.unlink(tempFile).catch(() => {
|
|
1480
|
-
});
|
|
1481
|
-
}
|
|
1482
|
-
throw e;
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
async function appendFile(filePath, content) {
|
|
1486
|
-
await fsp.appendFile(filePath, content);
|
|
1487
|
-
}
|
|
1488
|
-
async function deleteFile(filePath) {
|
|
1489
|
-
await fsp.unlink(filePath);
|
|
1490
|
-
}
|
|
1491
|
-
async function fileExists(filePath) {
|
|
1492
|
-
try {
|
|
1493
|
-
const stat = await fsp.stat(filePath);
|
|
1494
|
-
return stat.isFile();
|
|
1495
|
-
} catch (e) {
|
|
1496
|
-
return false;
|
|
1497
|
-
}
|
|
1498
|
-
}
|
|
1499
|
-
async function getFileStat(filePath) {
|
|
1500
|
-
const stat = await fsp.stat(filePath);
|
|
1501
|
-
return {
|
|
1502
|
-
size: stat.size,
|
|
1503
|
-
createdAt: stat.birthtime,
|
|
1504
|
-
modifiedAt: stat.mtime,
|
|
1505
|
-
isDir: stat.isDirectory()
|
|
1506
|
-
};
|
|
1507
|
-
}
|
|
1508
|
-
async function readJSON(filePath) {
|
|
1509
|
-
try {
|
|
1510
|
-
const content = await readFile(filePath, "utf8");
|
|
1511
|
-
return JSON.parse(content);
|
|
1512
|
-
} catch (e) {
|
|
1513
|
-
return null;
|
|
1514
|
-
}
|
|
1515
|
-
}
|
|
1516
|
-
async function writeJSON(filePath, data, indent = 2) {
|
|
1517
|
-
const content = JSON.stringify(data, null, indent);
|
|
1518
|
-
await writeFileAtomic(filePath, content);
|
|
1519
|
-
}
|
|
1520
|
-
async function updateJSON(filePath, patch) {
|
|
1521
|
-
const release = await FileLock.acquire(filePath);
|
|
1522
|
-
try {
|
|
1523
|
-
let existing = await readJSON(filePath);
|
|
1524
|
-
if (!existing) {
|
|
1525
|
-
existing = {};
|
|
1526
|
-
}
|
|
1527
|
-
const updated = deepMerge(existing, patch);
|
|
1528
|
-
await writeJSON(filePath, updated);
|
|
1529
|
-
return updated;
|
|
1530
|
-
} finally {
|
|
1531
|
-
release();
|
|
1532
|
-
}
|
|
1533
|
-
}
|
|
1534
|
-
async function ensureDir(dirPath) {
|
|
1535
|
-
await fsp.mkdir(dirPath, { recursive: true });
|
|
1536
|
-
}
|
|
1537
|
-
async function deleteDir(dirPath, recursive = true) {
|
|
1538
|
-
await fsp.rm(dirPath, { recursive, force: true });
|
|
1539
|
-
}
|
|
1540
|
-
async function listDir(dirPath) {
|
|
1541
|
-
return await fsp.readdir(dirPath);
|
|
1542
|
-
}
|
|
1543
|
-
async function* walkDir(dirPath, filter) {
|
|
1544
|
-
const list = await listDir(dirPath);
|
|
1545
|
-
for (const item of list) {
|
|
1546
|
-
const full = path6.join(dirPath, item);
|
|
1547
|
-
const stat = await getFileStat(full);
|
|
1548
|
-
if (stat.isDir) {
|
|
1549
|
-
yield* walkDir(full, filter);
|
|
1550
|
-
} else {
|
|
1551
|
-
if (!filter || filter(full)) {
|
|
1552
|
-
yield full;
|
|
1553
|
-
}
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
async function dirExists(dirPath) {
|
|
1558
|
-
try {
|
|
1559
|
-
const stat = await fsp.stat(dirPath);
|
|
1560
|
-
return stat.isDirectory();
|
|
1561
|
-
} catch (e) {
|
|
1562
|
-
return false;
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
async function copyDir(src, dest) {
|
|
1566
|
-
await ensureDir(dest);
|
|
1567
|
-
const list = await listDir(src);
|
|
1568
|
-
for (const item of list) {
|
|
1569
|
-
const srcItem = path6.join(src, item);
|
|
1570
|
-
const destItem = path6.join(dest, item);
|
|
1571
|
-
const stat = await getFileStat(srcItem);
|
|
1572
|
-
if (stat.isDir) {
|
|
1573
|
-
await copyDir(srcItem, destItem);
|
|
1574
|
-
} else {
|
|
1575
|
-
await fsp.copyFile(srcItem, destItem);
|
|
1576
|
-
}
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
|
-
async function firstExisting(candidates) {
|
|
1580
|
-
for (const cand of candidates) {
|
|
1581
|
-
if (await fileExists(cand)) {
|
|
1582
|
-
return cand;
|
|
1583
|
-
}
|
|
1584
|
-
}
|
|
1585
|
-
return null;
|
|
1586
|
-
}
|
|
1587
|
-
function watchFile(filePath, handler, debounceMs = 100) {
|
|
1588
|
-
let timer = null;
|
|
1589
|
-
return fs5.watch(filePath, (event) => {
|
|
1590
|
-
if (timer) clearTimeout(timer);
|
|
1591
|
-
timer = setTimeout(() => handler(event), debounceMs);
|
|
1592
|
-
});
|
|
1593
|
-
}
|
|
1594
|
-
function watchDir(dirPath, handler, debounceMs = 100) {
|
|
1595
|
-
let timer = null;
|
|
1596
|
-
return fs5.watch(dirPath, (event, filename) => {
|
|
1597
|
-
if (timer) clearTimeout(timer);
|
|
1598
|
-
timer = setTimeout(() => handler(event, filename), debounceMs);
|
|
1599
|
-
});
|
|
1600
|
-
}
|
|
1601
|
-
function createTempFile(prefix = "tmp-") {
|
|
1602
|
-
return path6.join(os2.tmpdir(), `${prefix}${Math.random().toString(36).substring(7)}.tmp`);
|
|
1603
|
-
}
|
|
1604
|
-
function createTempDir(prefix = "tmp-dir-") {
|
|
1605
|
-
const dir = path6.join(os2.tmpdir(), `${prefix}${Math.random().toString(36).substring(7)}`);
|
|
1606
|
-
fs5.mkdirSync(dir, { recursive: true });
|
|
1607
|
-
return dir;
|
|
1608
|
-
}
|
|
1609
|
-
async function withTempDir(fn, prefix = "tmp-") {
|
|
1610
|
-
const tempDir = createTempDir(prefix);
|
|
1611
|
-
try {
|
|
1612
|
-
return await fn(tempDir);
|
|
1613
|
-
} finally {
|
|
1614
|
-
await deleteDir(tempDir, true).catch(() => {
|
|
1615
|
-
});
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
1618
|
-
|
|
1619
|
-
// src/events.ts
|
|
1620
|
-
var globalStore = globalThis;
|
|
1621
|
-
if (!globalStore.__skipo_realtime_store) {
|
|
1622
|
-
globalStore.__skipo_realtime_store = {
|
|
1623
|
-
buffer: [],
|
|
1624
|
-
listeners: /* @__PURE__ */ new Set()
|
|
1625
|
-
};
|
|
1626
|
-
}
|
|
1627
|
-
var store = globalStore.__skipo_realtime_store;
|
|
1628
|
-
var MAX_BUFFER_SIZE = 200;
|
|
1629
|
-
function publishRealtimeEvent(eventInput) {
|
|
1630
|
-
const event = {
|
|
1631
|
-
...eventInput,
|
|
1632
|
-
id: eventInput.id || `ev-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`,
|
|
1633
|
-
timestamp: eventInput.timestamp || Date.now(),
|
|
1634
|
-
source: eventInput.source || "api"
|
|
1635
|
-
};
|
|
1636
|
-
store.buffer.push(event);
|
|
1637
|
-
if (store.buffer.length > MAX_BUFFER_SIZE) {
|
|
1638
|
-
store.buffer.splice(0, store.buffer.length - MAX_BUFFER_SIZE);
|
|
1639
|
-
}
|
|
1640
|
-
for (const listener of store.listeners) {
|
|
1641
|
-
try {
|
|
1642
|
-
listener(event);
|
|
1643
|
-
} catch (err) {
|
|
1644
|
-
console.error("[RealtimeBus] Listener invocation error:", err);
|
|
1645
|
-
}
|
|
1646
|
-
}
|
|
1647
|
-
return event;
|
|
1648
|
-
}
|
|
1649
|
-
function subscribeRealtimeEvents(listener) {
|
|
1650
|
-
store.listeners.add(listener);
|
|
1651
|
-
return () => {
|
|
1652
|
-
store.listeners.delete(listener);
|
|
1653
|
-
};
|
|
1654
|
-
}
|
|
1655
|
-
function getRecentEvents(sinceTimestamp, workspaceId, userId) {
|
|
1656
|
-
const since = typeof sinceTimestamp === "number" && !isNaN(sinceTimestamp) ? sinceTimestamp : 0;
|
|
1657
|
-
return store.buffer.filter((e) => {
|
|
1658
|
-
if (e.timestamp <= since) return false;
|
|
1659
|
-
if (workspaceId && e.workspaceId && e.workspaceId !== workspaceId) return false;
|
|
1660
|
-
if (userId && e.userId && e.userId !== userId) return false;
|
|
1661
|
-
return true;
|
|
1662
|
-
});
|
|
1663
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
LRUCache,
|
|
3
|
+
TTLCache,
|
|
4
|
+
createClient,
|
|
5
|
+
debounce,
|
|
6
|
+
deepClone,
|
|
7
|
+
deepEqual,
|
|
8
|
+
deepMerge,
|
|
9
|
+
del,
|
|
10
|
+
get,
|
|
11
|
+
getEnv,
|
|
12
|
+
getPath,
|
|
13
|
+
getRecentEvents,
|
|
14
|
+
isPlaceholderConnection,
|
|
15
|
+
memoize,
|
|
16
|
+
objectDiff,
|
|
17
|
+
once,
|
|
18
|
+
pLimit,
|
|
19
|
+
post,
|
|
20
|
+
publishRealtimeEvent,
|
|
21
|
+
put,
|
|
22
|
+
request,
|
|
23
|
+
requestRaw,
|
|
24
|
+
requireEnv,
|
|
25
|
+
retry,
|
|
26
|
+
sanitizeDatabaseUrl,
|
|
27
|
+
setPath,
|
|
28
|
+
sleep,
|
|
29
|
+
streamResponse,
|
|
30
|
+
subscribeRealtimeEvents,
|
|
31
|
+
swr,
|
|
32
|
+
throttle,
|
|
33
|
+
validateEnvSchema,
|
|
34
|
+
withTimeout
|
|
35
|
+
} from "./chunk-6EHIZHO4.js";
|
|
36
|
+
import {
|
|
37
|
+
SkipoBase,
|
|
38
|
+
interpolate,
|
|
39
|
+
prefixedId,
|
|
40
|
+
shortId,
|
|
41
|
+
toCamelCase,
|
|
42
|
+
toKebabCase,
|
|
43
|
+
toPascalCase,
|
|
44
|
+
toScreamingSnake,
|
|
45
|
+
toSlug,
|
|
46
|
+
toSnakeCase,
|
|
47
|
+
uuid
|
|
48
|
+
} from "./chunk-Z4LM5TOJ.js";
|
|
1664
49
|
|
|
1665
50
|
// src/index.ts
|
|
51
|
+
import {
|
|
52
|
+
createService,
|
|
53
|
+
createServiceDefinition
|
|
54
|
+
} from "@ultrst-armada/krnl";
|
|
1666
55
|
var FunctionsServiceDefinition = createServiceDefinition({
|
|
1667
56
|
id: "kloks.functions.core",
|
|
1668
57
|
name: "FunctionsService",
|
|
@@ -1715,52 +104,33 @@ var FunctionsServiceFacade = {
|
|
|
1715
104
|
var krnlFunctionsServiceDefinition = FunctionsServiceDefinition;
|
|
1716
105
|
var krnlFunctionsServiceFacade = FunctionsServiceFacade;
|
|
1717
106
|
export {
|
|
1718
|
-
FileCache,
|
|
1719
|
-
FileLock,
|
|
1720
107
|
FunctionsServiceDefinition,
|
|
1721
108
|
FunctionsServiceFacade,
|
|
1722
109
|
LRUCache,
|
|
1723
110
|
SkipoBase,
|
|
1724
111
|
TTLCache,
|
|
1725
|
-
appendFile,
|
|
1726
|
-
copyDir,
|
|
1727
112
|
createClient,
|
|
1728
|
-
createTempDir,
|
|
1729
|
-
createTempFile,
|
|
1730
113
|
debounce,
|
|
1731
114
|
deepClone,
|
|
1732
115
|
deepEqual,
|
|
1733
116
|
deepMerge,
|
|
1734
117
|
del,
|
|
1735
|
-
deleteDir,
|
|
1736
|
-
deleteFile,
|
|
1737
|
-
dirExists,
|
|
1738
|
-
ensureDir,
|
|
1739
|
-
execCmd,
|
|
1740
|
-
fileExists,
|
|
1741
|
-
firstExisting,
|
|
1742
118
|
get,
|
|
1743
119
|
getEnv,
|
|
1744
|
-
getFileStat,
|
|
1745
120
|
getPath,
|
|
1746
121
|
getRecentEvents,
|
|
1747
122
|
interpolate,
|
|
1748
123
|
isPlaceholderConnection,
|
|
1749
124
|
krnlFunctionsServiceDefinition,
|
|
1750
125
|
krnlFunctionsServiceFacade,
|
|
1751
|
-
listDir,
|
|
1752
|
-
loadEnv,
|
|
1753
126
|
memoize,
|
|
1754
127
|
objectDiff,
|
|
1755
128
|
once,
|
|
1756
129
|
pLimit,
|
|
1757
|
-
platform,
|
|
1758
130
|
post,
|
|
1759
131
|
prefixedId,
|
|
1760
132
|
publishRealtimeEvent,
|
|
1761
133
|
put,
|
|
1762
|
-
readFile,
|
|
1763
|
-
readJSON,
|
|
1764
134
|
request,
|
|
1765
135
|
requestRaw,
|
|
1766
136
|
requireEnv,
|
|
@@ -1769,7 +139,6 @@ export {
|
|
|
1769
139
|
setPath,
|
|
1770
140
|
shortId,
|
|
1771
141
|
sleep,
|
|
1772
|
-
spawnCmd,
|
|
1773
142
|
streamResponse,
|
|
1774
143
|
subscribeRealtimeEvents,
|
|
1775
144
|
swr,
|
|
@@ -1780,16 +149,7 @@ export {
|
|
|
1780
149
|
toScreamingSnake,
|
|
1781
150
|
toSlug,
|
|
1782
151
|
toSnakeCase,
|
|
1783
|
-
updateJSON,
|
|
1784
152
|
uuid,
|
|
1785
153
|
validateEnvSchema,
|
|
1786
|
-
|
|
1787
|
-
watchDir,
|
|
1788
|
-
watchFile,
|
|
1789
|
-
which,
|
|
1790
|
-
withTempDir,
|
|
1791
|
-
withTimeout,
|
|
1792
|
-
writeFile,
|
|
1793
|
-
writeFileAtomic,
|
|
1794
|
-
writeJSON
|
|
154
|
+
withTimeout
|
|
1795
155
|
};
|