@workglow/cactus 0.3.2 → 0.3.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/dist/ai/CactusProvider.browser.d.ts +23 -0
- package/dist/ai/CactusProvider.browser.d.ts.map +1 -0
- package/dist/ai/CactusQueuedProvider.browser.d.ts +23 -0
- package/dist/ai/CactusQueuedProvider.browser.d.ts.map +1 -0
- package/dist/ai/common/Cactus_Download.browser.d.ts +9 -0
- package/dist/ai/common/Cactus_Download.browser.d.ts.map +1 -0
- package/dist/ai/common/Cactus_DownloadRemove.browser.d.ts +9 -0
- package/dist/ai/common/Cactus_DownloadRemove.browser.d.ts.map +1 -0
- package/dist/ai/common/Cactus_JobRunFns.browser.d.ts +12 -0
- package/dist/ai/common/Cactus_JobRunFns.browser.d.ts.map +1 -0
- package/dist/ai/common/Cactus_ModelInfo.browser.d.ts +9 -0
- package/dist/ai/common/Cactus_ModelInfo.browser.d.ts.map +1 -0
- package/dist/ai/common/Cactus_Runtime.d.ts.map +1 -1
- package/dist/ai/common/Cactus_ToolCalling.browser.d.ts +9 -0
- package/dist/ai/common/Cactus_ToolCalling.browser.d.ts.map +1 -0
- package/dist/ai/registerCactus.browser.d.ts +10 -0
- package/dist/ai/registerCactus.browser.d.ts.map +1 -0
- package/dist/ai/registerCactusInline.browser.d.ts +8 -0
- package/dist/ai/registerCactusInline.browser.d.ts.map +1 -0
- package/dist/ai/registerCactusWorker.browser.d.ts +7 -0
- package/dist/ai/registerCactusWorker.browser.d.ts.map +1 -0
- package/dist/ai-runtime.browser.d.ts +3 -1
- package/dist/ai-runtime.browser.d.ts.map +1 -1
- package/dist/ai-runtime.browser.js +21 -185
- package/dist/ai-runtime.browser.js.map +12 -13
- package/dist/ai-runtime.d.ts +3 -1
- package/dist/ai-runtime.d.ts.map +1 -1
- package/dist/ai-runtime.js +7 -14
- package/dist/ai-runtime.js.map +4 -4
- package/dist/{ai/index.d.ts → ai.browser.d.ts} +9 -9
- package/dist/ai.browser.d.ts.map +1 -0
- package/dist/ai.browser.js +485 -0
- package/dist/ai.browser.js.map +25 -0
- package/dist/ai.d.ts +39 -1
- package/dist/ai.d.ts.map +1 -1
- package/dist/ai.js +6 -13
- package/dist/ai.js.map +5 -5
- package/package.json +19 -15
- package/dist/ai/index.d.ts.map +0 -1
- package/dist/ai/runtime.browser.d.ts +0 -9
- package/dist/ai/runtime.browser.d.ts.map +0 -1
- package/dist/ai/runtime.d.ts +0 -9
- package/dist/ai/runtime.d.ts.map +0 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { AiProviderPreviewRunFn, AiProviderRunFnRegistration, Capability, ModelConfig, ModelRecord } from "@workglow/ai/worker";
|
|
7
|
+
import { AiProvider } from "@workglow/ai/worker";
|
|
8
|
+
import type { CactusModelConfig } from "./common/Cactus_ModelSchema";
|
|
9
|
+
/** Browser worker-server registration for Cactus. */
|
|
10
|
+
export declare class CactusProvider extends AiProvider<CactusModelConfig> {
|
|
11
|
+
readonly name = "LOCAL_CACTUS";
|
|
12
|
+
readonly displayName = "Cactus (Needle)";
|
|
13
|
+
readonly isLocal = true;
|
|
14
|
+
readonly supportsBrowser = true;
|
|
15
|
+
constructor(promiseRunFns?: readonly AiProviderRunFnRegistration<any, any, CactusModelConfig>[], previewTasks?: Record<string, AiProviderPreviewRunFn<any, any, CactusModelConfig>>);
|
|
16
|
+
inferCapabilities(model: ModelRecord): readonly Capability[];
|
|
17
|
+
protected workerRunFnSpecs(): readonly {
|
|
18
|
+
serves: readonly Capability[];
|
|
19
|
+
}[];
|
|
20
|
+
createSession(_model: ModelConfig): string;
|
|
21
|
+
disposeSession(sessionId: string): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=CactusProvider.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CactusProvider.browser.d.ts","sourceRoot":"","sources":["../../src/ai/CactusProvider.browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,sBAAsB,EACtB,2BAA2B,EAC3B,UAAU,EACV,WAAW,EACX,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGrE,qDAAqD;AACrD,qBAAa,cAAe,SAAQ,UAAU,CAAC,iBAAiB,CAAC;IAC/D,QAAQ,CAAC,IAAI,kBAAgB;IAC7B,QAAQ,CAAC,WAAW,qBAAqB;IACzC,QAAQ,CAAC,OAAO,QAAQ;IACxB,QAAQ,CAAC,eAAe,QAAQ;IAEhC,YACE,aAAa,CAAC,EAAE,SAAS,2BAA2B,CAElD,GAAG,EAEH,GAAG,EACH,iBAAiB,CAClB,EAAE,EACH,YAAY,CAAC,EAAE,MAAM,CACnB,MAAM,EAEN,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,iBAAiB,CAAC,CACpD,EAGF;IAEQ,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,UAAU,EAAE,CAEpE;IAED,UAAmB,gBAAgB,IAAI,SAAS;QAAE,MAAM,EAAE,SAAS,UAAU,EAAE,CAAA;KAAE,EAAE,CAElF;IAEQ,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAElD;IAEc,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9D;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { AiProviderPreviewRunFn, AiProviderRunFnRegistration, Capability, ModelConfig, ModelRecord } from "@workglow/ai";
|
|
7
|
+
import { QueuedAiProvider } from "@workglow/ai";
|
|
8
|
+
import type { CactusModelConfig } from "./common/Cactus_ModelSchema";
|
|
9
|
+
/** Browser main-thread registration (inline or worker-backed); creates the default job queue. */
|
|
10
|
+
export declare class CactusQueuedProvider extends QueuedAiProvider<CactusModelConfig> {
|
|
11
|
+
readonly name = "LOCAL_CACTUS";
|
|
12
|
+
readonly displayName = "Cactus (Needle)";
|
|
13
|
+
readonly isLocal = true;
|
|
14
|
+
readonly supportsBrowser = true;
|
|
15
|
+
constructor(promiseRunFns?: readonly AiProviderRunFnRegistration<any, any, CactusModelConfig>[], previewTasks?: Record<string, AiProviderPreviewRunFn<any, any, CactusModelConfig>>);
|
|
16
|
+
inferCapabilities(model: ModelRecord): readonly Capability[];
|
|
17
|
+
protected workerRunFnSpecs(): readonly {
|
|
18
|
+
serves: readonly Capability[];
|
|
19
|
+
}[];
|
|
20
|
+
createSession(_model: ModelConfig): string;
|
|
21
|
+
disposeSession(sessionId: string): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=CactusQueuedProvider.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CactusQueuedProvider.browser.d.ts","sourceRoot":"","sources":["../../src/ai/CactusQueuedProvider.browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,sBAAsB,EACtB,2BAA2B,EAC3B,UAAU,EACV,WAAW,EACX,WAAW,EACZ,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGrE,iGAAiG;AACjG,qBAAa,oBAAqB,SAAQ,gBAAgB,CAAC,iBAAiB,CAAC;IAC3E,QAAQ,CAAC,IAAI,kBAAgB;IAC7B,QAAQ,CAAC,WAAW,qBAAqB;IACzC,QAAQ,CAAC,OAAO,QAAQ;IACxB,QAAQ,CAAC,eAAe,QAAQ;IAEhC,YACE,aAAa,CAAC,EAAE,SAAS,2BAA2B,CAElD,GAAG,EAEH,GAAG,EACH,iBAAiB,CAClB,EAAE,EACH,YAAY,CAAC,EAAE,MAAM,CACnB,MAAM,EAEN,sBAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,iBAAiB,CAAC,CACpD,EAGF;IAEQ,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,UAAU,EAAE,CAEpE;IAED,UAAmB,gBAAgB,IAAI,SAAS;QAAE,MAAM,EAAE,SAAS,UAAU,EAAE,CAAA;KAAE,EAAE,CAElF;IAEQ,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAElD;IAEc,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE9D;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { AiProviderRunFn, ModelDownloadTaskRunInput, ModelDownloadTaskRunOutput } from "@workglow/ai";
|
|
7
|
+
import type { CactusModelConfig } from "./Cactus_ModelSchema";
|
|
8
|
+
export declare const Cactus_Download: AiProviderRunFn<ModelDownloadTaskRunInput, ModelDownloadTaskRunOutput, CactusModelConfig>;
|
|
9
|
+
//# sourceMappingURL=Cactus_Download.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cactus_Download.browser.d.ts","sourceRoot":"","sources":["../../../src/ai/common/Cactus_Download.browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,yBAAyB,EACzB,0BAA0B,EAC3B,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,eAAO,MAAM,eAAe,EAAE,eAAe,CAC3C,yBAAyB,EACzB,0BAA0B,EAC1B,iBAAiB,CAkBlB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { AiProviderRunFn, ModelDownloadRemoveTaskRunInput, ModelDownloadRemoveTaskRunOutput } from "@workglow/ai";
|
|
7
|
+
import type { CactusModelConfig } from "./Cactus_ModelSchema";
|
|
8
|
+
export declare const Cactus_DownloadRemove: AiProviderRunFn<ModelDownloadRemoveTaskRunInput, ModelDownloadRemoveTaskRunOutput, CactusModelConfig>;
|
|
9
|
+
//# sourceMappingURL=Cactus_DownloadRemove.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cactus_DownloadRemove.browser.d.ts","sourceRoot":"","sources":["../../../src/ai/common/Cactus_DownloadRemove.browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,+BAA+B,EAC/B,gCAAgC,EACjC,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,eAAO,MAAM,qBAAqB,EAAE,eAAe,CACjD,+BAA+B,EAC/B,gCAAgC,EAChC,iBAAiB,CAKlB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { AiProviderRunFnRegistration } from "@workglow/ai";
|
|
7
|
+
import type { CactusModelConfig } from "./Cactus_ModelSchema";
|
|
8
|
+
export { cactusConfigJson, cactusEngines, deleteCactusSession, disposeCactusResources, getOrLoadEngine, loadSdk, removeCachedAssets, } from "./Cactus_Runtime.browser";
|
|
9
|
+
export declare const CACTUS_RUN_FNS: readonly AiProviderRunFnRegistration<any, any, CactusModelConfig>[];
|
|
10
|
+
/** No preview-only tasks for Cactus today. */
|
|
11
|
+
export declare const CACTUS_PREVIEW_TASKS: {};
|
|
12
|
+
//# sourceMappingURL=Cactus_JobRunFns.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cactus_JobRunFns.browser.d.ts","sourceRoot":"","sources":["../../../src/ai/common/Cactus_JobRunFns.browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAWhE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAI9D,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,OAAO,EACP,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAElC,eAAO,MAAM,cAAc,EAAE,SAAS,2BAA2B,CAE/D,GAAG,EAEH,GAAG,EACH,iBAAiB,CAClB,EAMA,CAAC;AAEF,8CAA8C;AAC9C,eAAO,MAAM,oBAAoB,IAAc,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { AiProviderRunFn, ModelInfoTaskInput, ModelInfoTaskOutput } from "@workglow/ai";
|
|
7
|
+
import type { CactusModelConfig } from "./Cactus_ModelSchema";
|
|
8
|
+
export declare const Cactus_ModelInfo: AiProviderRunFn<ModelInfoTaskInput, ModelInfoTaskOutput, CactusModelConfig>;
|
|
9
|
+
//# sourceMappingURL=Cactus_ModelInfo.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cactus_ModelInfo.browser.d.ts","sourceRoot":"","sources":["../../../src/ai/common/Cactus_ModelInfo.browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAE7F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,eAAO,MAAM,gBAAgB,EAAE,eAAe,CAC5C,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,CAuBlB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cactus_Runtime.d.ts","sourceRoot":"","sources":["../../../src/ai/common/Cactus_Runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"Cactus_Runtime.d.ts","sourceRoot":"","sources":["../../../src/ai/common/Cactus_Runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,KAAK,eAAe,GAAG,cAAc,WAAW,CAAC,CAAC;AAGlD,KAAK,YAAY,GAAG,WAAW,CAAC,UAAU,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAKnF,oEAAoE;AACpE,wBAAsB,OAAO,IAAI,OAAO,CAAC,eAAe,CAAC,CAkBxD;AAED,wBAAgB,YAAY,IAAI,eAAe,CAG9C;AA0DD,wBAAsB,eAAe,CACnC,KAAK,EAAE,iBAAiB,EACxB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,UAAU,CAAC,CASrB;AAMD,oCAAoC;AACpC,eAAO,MAAM,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAa,CAAC;AAClE,oCAAoC;AACpC,eAAO,MAAM,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAa,CAAC;AAMhE,wBAAsB,eAAe,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,YAAY,CAAC,CAwCrF;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED,iFAAiF;AACjF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAEtD;AAED,iGAAiG;AACjG,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEvD;AAMD,oCAAoC;AACpC,eAAO,MAAM,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAa,CAAC;AAE5E,wBAAsB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAEtE;AA2CD,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhF;AAED,uCAAuC;AACvC,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC,CAQ5D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { AiProviderRunFn, ToolCallingTaskInput, ToolCallingTaskOutput } from "@workglow/ai";
|
|
7
|
+
import type { CactusModelConfig } from "./Cactus_ModelSchema";
|
|
8
|
+
export declare const Cactus_ToolCalling: AiProviderRunFn<ToolCallingTaskInput, ToolCallingTaskOutput, CactusModelConfig>;
|
|
9
|
+
//# sourceMappingURL=Cactus_ToolCalling.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cactus_ToolCalling.browser.d.ts","sourceRoot":"","sources":["../../../src/ai/common/Cactus_ToolCalling.browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EAGtB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAiD9D,eAAO,MAAM,kBAAkB,EAAE,eAAe,CAC9C,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,CA8BlB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { AiProviderRegisterOptions } from "@workglow/ai";
|
|
7
|
+
export declare function registerCactus(options: AiProviderRegisterOptions & {
|
|
8
|
+
worker: Worker | (() => Worker);
|
|
9
|
+
}): Promise<void>;
|
|
10
|
+
//# sourceMappingURL=registerCactus.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerCactus.browser.d.ts","sourceRoot":"","sources":["../../src/ai/registerCactus.browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAI9D,wBAAsB,cAAc,CAClC,OAAO,EAAE,yBAAyB,GAAG;IACnC,MAAM,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;CACjC,GACA,OAAO,CAAC,IAAI,CAAC,CAEf"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { AiProviderRegisterOptions } from "@workglow/ai";
|
|
7
|
+
export declare function registerCactusInline(options?: AiProviderRegisterOptions): Promise<void>;
|
|
8
|
+
//# sourceMappingURL=registerCactusInline.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerCactusInline.browser.d.ts","sourceRoot":"","sources":["../../src/ai/registerCactusInline.browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAK9D,wBAAsB,oBAAoB,CAAC,OAAO,CAAC,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAM7F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerCactusWorker.browser.d.ts","sourceRoot":"","sources":["../../src/ai/registerCactusWorker.browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAK1D"}
|
|
@@ -3,5 +3,7 @@
|
|
|
3
3
|
* Copyright 2026 Steven Roussey <sroussey@gmail.com>
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
export * from "./ai/
|
|
6
|
+
export * from "./ai/common/Cactus_Runtime.browser";
|
|
7
|
+
export * from "./ai/registerCactusInline.browser";
|
|
8
|
+
export * from "./ai/registerCactusWorker.browser";
|
|
7
9
|
//# sourceMappingURL=ai-runtime.browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-runtime.browser.d.ts","sourceRoot":"","sources":["../src/ai-runtime.browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,cAAc,
|
|
1
|
+
{"version":3,"file":"ai-runtime.browser.d.ts","sourceRoot":"","sources":["../src/ai-runtime.browser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC"}
|
|
@@ -173,11 +173,10 @@ async function disposeCactusResources() {
|
|
|
173
173
|
cactusCachedModelIds.clear();
|
|
174
174
|
cactusSessions.clear();
|
|
175
175
|
}
|
|
176
|
-
|
|
177
|
-
// src/ai/registerCactusInline.ts
|
|
176
|
+
// src/ai/registerCactusInline.browser.ts
|
|
178
177
|
import { registerProviderInline } from "@workglow/ai/provider-utils";
|
|
179
178
|
|
|
180
|
-
// src/ai/CactusQueuedProvider.ts
|
|
179
|
+
// src/ai/CactusQueuedProvider.browser.ts
|
|
181
180
|
import { QueuedAiProvider } from "@workglow/ai";
|
|
182
181
|
|
|
183
182
|
// src/ai/common/Cactus_CapabilitySets.ts
|
|
@@ -205,169 +204,7 @@ function inferCactusCapabilities(_model) {
|
|
|
205
204
|
return ["tool-use", "model.download", "model.download-remove", "model.search", "model.info"];
|
|
206
205
|
}
|
|
207
206
|
|
|
208
|
-
// src/ai/
|
|
209
|
-
var _sdk2;
|
|
210
|
-
var _sdkInitPromise2;
|
|
211
|
-
async function loadSdk2() {
|
|
212
|
-
_sdkInitPromise2 ??= import("needle-rs").then(async (mod) => {
|
|
213
|
-
const init = mod.default;
|
|
214
|
-
if (typeof init === "function") {
|
|
215
|
-
await init();
|
|
216
|
-
}
|
|
217
|
-
_sdk2 = mod;
|
|
218
|
-
return mod;
|
|
219
|
-
}).catch((err) => {
|
|
220
|
-
_sdkInitPromise2 = undefined;
|
|
221
|
-
_sdk2 = undefined;
|
|
222
|
-
throw new Error(`needle-rs is required for LOCAL_CACTUS tasks. Install it with: bun add needle-rs (cause: ${String(err)})`);
|
|
223
|
-
});
|
|
224
|
-
return _sdkInitPromise2;
|
|
225
|
-
}
|
|
226
|
-
function hasBrowserCacheStorage() {
|
|
227
|
-
return typeof globalThis !== "undefined" && "caches" in globalThis && typeof globalThis.caches?.open === "function";
|
|
228
|
-
}
|
|
229
|
-
function modelsDirOf(model) {
|
|
230
|
-
return model.provider_config.models_dir ?? CACTUS_DEFAULT_MODELS_DIR;
|
|
231
|
-
}
|
|
232
|
-
async function fetchAssetBytesBrowser2(url) {
|
|
233
|
-
const cachesApi = globalThis.caches;
|
|
234
|
-
const cache = await cachesApi.open(CACTUS_CACHE_NAME);
|
|
235
|
-
const hit = await cache.match(url);
|
|
236
|
-
if (hit) {
|
|
237
|
-
return new Uint8Array(await hit.arrayBuffer());
|
|
238
|
-
}
|
|
239
|
-
const resp = await fetch(url);
|
|
240
|
-
if (!resp.ok)
|
|
241
|
-
throw new Error(`Cactus asset fetch failed (${resp.status}) for ${url}`);
|
|
242
|
-
await cache.put(url, resp.clone());
|
|
243
|
-
return new Uint8Array(await resp.arrayBuffer());
|
|
244
|
-
}
|
|
245
|
-
async function fetchAssetBytesNode(url, models_dir, model_id, filename) {
|
|
246
|
-
const fs = await import("node:fs/promises");
|
|
247
|
-
const path = await import("node:path");
|
|
248
|
-
const resolvedDir = models_dir.startsWith("~/") ? path.join(process.env.HOME ?? process.env.USERPROFILE ?? ".", models_dir.slice(2), model_id) : path.resolve(models_dir, model_id);
|
|
249
|
-
const filePath = path.join(resolvedDir, filename);
|
|
250
|
-
try {
|
|
251
|
-
const buf = await fs.readFile(filePath);
|
|
252
|
-
return new Uint8Array(buf);
|
|
253
|
-
} catch {}
|
|
254
|
-
const resp = await fetch(url);
|
|
255
|
-
if (!resp.ok)
|
|
256
|
-
throw new Error(`Cactus asset fetch failed (${resp.status}) for ${url}`);
|
|
257
|
-
const bytes = new Uint8Array(await resp.arrayBuffer());
|
|
258
|
-
await fs.mkdir(resolvedDir, { recursive: true });
|
|
259
|
-
const tmpPath = `${filePath}.tmp`;
|
|
260
|
-
await fs.writeFile(tmpPath, bytes);
|
|
261
|
-
await fs.rename(tmpPath, filePath);
|
|
262
|
-
return bytes;
|
|
263
|
-
}
|
|
264
|
-
async function fetchAssetBytes2(model, filename) {
|
|
265
|
-
const model_id = model.provider_config.model_id;
|
|
266
|
-
const entry = getCactusCatalogEntry(model_id);
|
|
267
|
-
if (!entry)
|
|
268
|
-
throw new Error(`Unknown Cactus model_id: ${model_id}`);
|
|
269
|
-
const url = cactusAssetUrl(entry, filename);
|
|
270
|
-
if (hasBrowserCacheStorage()) {
|
|
271
|
-
return fetchAssetBytesBrowser2(url);
|
|
272
|
-
}
|
|
273
|
-
return fetchAssetBytesNode(url, modelsDirOf(model), model_id, filename);
|
|
274
|
-
}
|
|
275
|
-
var cactusEngines2 = new Map;
|
|
276
|
-
var cactusConfigJson2 = new Map;
|
|
277
|
-
var cactusCachedModelIds2 = new Set;
|
|
278
|
-
var cactusEngineLoadsInFlight2 = new Map;
|
|
279
|
-
async function getOrLoadEngine2(model) {
|
|
280
|
-
const model_id = model.provider_config.model_id;
|
|
281
|
-
const cached = cactusEngines2.get(model_id);
|
|
282
|
-
if (cached)
|
|
283
|
-
return cached;
|
|
284
|
-
const inFlight = cactusEngineLoadsInFlight2.get(model_id);
|
|
285
|
-
if (inFlight)
|
|
286
|
-
return inFlight;
|
|
287
|
-
const loadPromise = (async () => {
|
|
288
|
-
const sdk = await loadSdk2();
|
|
289
|
-
const entry = getCactusCatalogEntry(model_id);
|
|
290
|
-
if (!entry)
|
|
291
|
-
throw new Error(`Unknown Cactus model_id: ${model_id}`);
|
|
292
|
-
const [weightsBytes, vocabBytes, configBytes] = await Promise.all([
|
|
293
|
-
fetchAssetBytes2(model, entry.assets.weights),
|
|
294
|
-
fetchAssetBytes2(model, entry.assets.vocab),
|
|
295
|
-
fetchAssetBytes2(model, entry.assets.config)
|
|
296
|
-
]);
|
|
297
|
-
try {
|
|
298
|
-
const text = new TextDecoder().decode(configBytes);
|
|
299
|
-
cactusConfigJson2.set(model_id, JSON.parse(text));
|
|
300
|
-
} catch {
|
|
301
|
-
cactusConfigJson2.set(model_id, null);
|
|
302
|
-
}
|
|
303
|
-
const vocabText = new TextDecoder().decode(vocabBytes);
|
|
304
|
-
const engine = sdk.NeedleWasm.load(weightsBytes, vocabText);
|
|
305
|
-
if (!engine) {
|
|
306
|
-
throw new Error(`needle-rs NeedleWasm.load returned undefined for model ${model_id}`);
|
|
307
|
-
}
|
|
308
|
-
cactusEngines2.set(model_id, engine);
|
|
309
|
-
return engine;
|
|
310
|
-
})().finally(() => {
|
|
311
|
-
cactusEngineLoadsInFlight2.delete(model_id);
|
|
312
|
-
});
|
|
313
|
-
cactusEngineLoadsInFlight2.set(model_id, loadPromise);
|
|
314
|
-
return loadPromise;
|
|
315
|
-
}
|
|
316
|
-
function isModelLoaded2(model_id) {
|
|
317
|
-
return cactusEngines2.has(model_id);
|
|
318
|
-
}
|
|
319
|
-
function markModelCached2(model_id) {
|
|
320
|
-
cactusCachedModelIds2.add(model_id);
|
|
321
|
-
}
|
|
322
|
-
function isModelCached2(model_id) {
|
|
323
|
-
return cactusEngines2.has(model_id) || cactusCachedModelIds2.has(model_id);
|
|
324
|
-
}
|
|
325
|
-
var cactusSessions2 = new Map;
|
|
326
|
-
async function deleteCactusSession2(id) {
|
|
327
|
-
return cactusSessions2.delete(id);
|
|
328
|
-
}
|
|
329
|
-
async function removeBrowserCacheEntries2(entry) {
|
|
330
|
-
if (!hasBrowserCacheStorage())
|
|
331
|
-
return;
|
|
332
|
-
const cachesApi = globalThis.caches;
|
|
333
|
-
const cache = await cachesApi.open(CACTUS_CACHE_NAME);
|
|
334
|
-
for (const filename of [entry.assets.weights, entry.assets.vocab, entry.assets.config]) {
|
|
335
|
-
const url = cactusAssetUrl(entry, filename);
|
|
336
|
-
try {
|
|
337
|
-
await cache.delete(url);
|
|
338
|
-
} catch {}
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
async function removeNodeCacheDir(model, model_id) {
|
|
342
|
-
if (hasBrowserCacheStorage())
|
|
343
|
-
return;
|
|
344
|
-
const fs = await import("node:fs/promises");
|
|
345
|
-
const path = await import("node:path");
|
|
346
|
-
const models_dir = modelsDirOf(model);
|
|
347
|
-
const resolvedDir = models_dir.startsWith("~/") ? path.join(process.env.HOME ?? process.env.USERPROFILE ?? ".", models_dir.slice(2), model_id) : path.resolve(models_dir, model_id);
|
|
348
|
-
await fs.rm(resolvedDir, { recursive: true, force: true });
|
|
349
|
-
}
|
|
350
|
-
function disposeCactusEngine2(model_id) {
|
|
351
|
-
const engine = cactusEngines2.get(model_id);
|
|
352
|
-
if (engine) {
|
|
353
|
-
try {
|
|
354
|
-
engine.free?.();
|
|
355
|
-
} catch {}
|
|
356
|
-
}
|
|
357
|
-
cactusEngines2.delete(model_id);
|
|
358
|
-
cactusConfigJson2.delete(model_id);
|
|
359
|
-
cactusCachedModelIds2.delete(model_id);
|
|
360
|
-
}
|
|
361
|
-
async function removeCachedAssets2(model) {
|
|
362
|
-
const model_id = model.provider_config.model_id;
|
|
363
|
-
const entry = getCactusCatalogEntry(model_id);
|
|
364
|
-
if (!entry)
|
|
365
|
-
return;
|
|
366
|
-
await Promise.all([removeBrowserCacheEntries2(entry), removeNodeCacheDir(model, model_id)]);
|
|
367
|
-
disposeCactusEngine2(model_id);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// src/ai/CactusQueuedProvider.ts
|
|
207
|
+
// src/ai/CactusQueuedProvider.browser.ts
|
|
371
208
|
class CactusQueuedProvider extends QueuedAiProvider {
|
|
372
209
|
name = LOCAL_CACTUS;
|
|
373
210
|
displayName = "Cactus (Needle)";
|
|
@@ -386,11 +223,11 @@ class CactusQueuedProvider extends QueuedAiProvider {
|
|
|
386
223
|
return crypto.randomUUID();
|
|
387
224
|
}
|
|
388
225
|
async disposeSession(sessionId) {
|
|
389
|
-
await
|
|
226
|
+
await deleteCactusSession(sessionId);
|
|
390
227
|
}
|
|
391
228
|
}
|
|
392
229
|
|
|
393
|
-
// src/ai/common/Cactus_Download.ts
|
|
230
|
+
// src/ai/common/Cactus_Download.browser.ts
|
|
394
231
|
var Cactus_Download = async (input, model, _signal, emit) => {
|
|
395
232
|
if (!model)
|
|
396
233
|
throw new Error("Model config is required for ModelDownloadTask.");
|
|
@@ -405,21 +242,21 @@ var Cactus_Download = async (input, model, _signal, emit) => {
|
|
|
405
242
|
message: `Downloading ${assets[i]}`,
|
|
406
243
|
progress: Math.round((i + 0.5) / assets.length * 99)
|
|
407
244
|
});
|
|
408
|
-
await
|
|
245
|
+
await fetchAssetBytes(model, assets[i]);
|
|
409
246
|
}
|
|
410
|
-
|
|
247
|
+
markModelCached(model_id);
|
|
411
248
|
emit({ type: "finish", data: { model: input.model } });
|
|
412
249
|
};
|
|
413
250
|
|
|
414
|
-
// src/ai/common/Cactus_DownloadRemove.ts
|
|
251
|
+
// src/ai/common/Cactus_DownloadRemove.browser.ts
|
|
415
252
|
var Cactus_DownloadRemove = async (input, model, _signal, emit) => {
|
|
416
253
|
if (!model)
|
|
417
254
|
throw new Error("Model config is required for ModelDownloadRemoveTask.");
|
|
418
|
-
await
|
|
255
|
+
await removeCachedAssets(model);
|
|
419
256
|
emit({ type: "finish", data: { model: input.model } });
|
|
420
257
|
};
|
|
421
258
|
|
|
422
|
-
// src/ai/common/Cactus_ModelInfo.ts
|
|
259
|
+
// src/ai/common/Cactus_ModelInfo.browser.ts
|
|
423
260
|
var Cactus_ModelInfo = async (input, model, _signal, emit) => {
|
|
424
261
|
if (!model)
|
|
425
262
|
throw new Error("Model config is required for ModelInfoTask.");
|
|
@@ -427,8 +264,8 @@ var Cactus_ModelInfo = async (input, model, _signal, emit) => {
|
|
|
427
264
|
const entry = getCactusCatalogEntry(model_id);
|
|
428
265
|
if (!entry)
|
|
429
266
|
throw new Error(`Unknown Cactus model_id: ${model_id}`);
|
|
430
|
-
const is_loaded =
|
|
431
|
-
const is_cached =
|
|
267
|
+
const is_loaded = isModelLoaded(model_id);
|
|
268
|
+
const is_cached = isModelCached(model_id);
|
|
432
269
|
emit({
|
|
433
270
|
type: "finish",
|
|
434
271
|
data: {
|
|
@@ -465,7 +302,7 @@ var Cactus_ModelSearch = async (input, _model, _signal, emit) => {
|
|
|
465
302
|
emit({ type: "finish", data: { results } });
|
|
466
303
|
};
|
|
467
304
|
|
|
468
|
-
// src/ai/common/Cactus_ToolCalling.ts
|
|
305
|
+
// src/ai/common/Cactus_ToolCalling.browser.ts
|
|
469
306
|
import { extractMessageText } from "@workglow/ai/provider-utils";
|
|
470
307
|
import { filterValidToolCalls } from "@workglow/ai/worker";
|
|
471
308
|
function buildToolsJson(tools) {
|
|
@@ -515,7 +352,7 @@ var Cactus_ToolCalling = async (input, model, signal, emit) => {
|
|
|
515
352
|
throw new Error("Model config is required for ToolCallingTask.");
|
|
516
353
|
if (signal.aborted)
|
|
517
354
|
throw signal.reason ?? new Error("The operation was aborted");
|
|
518
|
-
const engine = await
|
|
355
|
+
const engine = await getOrLoadEngine(model);
|
|
519
356
|
const query = promptText(input);
|
|
520
357
|
const toolsJson = buildToolsJson(input.tools);
|
|
521
358
|
let raw = "";
|
|
@@ -536,7 +373,7 @@ var Cactus_ToolCalling = async (input, model, signal, emit) => {
|
|
|
536
373
|
emit({ type: "finish", data: { text: raw, toolCalls: validToolCalls } });
|
|
537
374
|
};
|
|
538
375
|
|
|
539
|
-
// src/ai/common/Cactus_JobRunFns.ts
|
|
376
|
+
// src/ai/common/Cactus_JobRunFns.browser.ts
|
|
540
377
|
var CACTUS_RUN_FNS = [
|
|
541
378
|
{ serves: CACTUS_TOOL_USE, runFn: Cactus_ToolCalling },
|
|
542
379
|
{ serves: CACTUS_MODEL_DOWNLOAD, runFn: Cactus_Download },
|
|
@@ -546,15 +383,14 @@ var CACTUS_RUN_FNS = [
|
|
|
546
383
|
];
|
|
547
384
|
var CACTUS_PREVIEW_TASKS = {};
|
|
548
385
|
|
|
549
|
-
// src/ai/registerCactusInline.ts
|
|
386
|
+
// src/ai/registerCactusInline.browser.ts
|
|
550
387
|
async function registerCactusInline(options) {
|
|
551
388
|
await registerProviderInline(new CactusQueuedProvider(CACTUS_RUN_FNS, CACTUS_PREVIEW_TASKS), "Cactus", options);
|
|
552
389
|
}
|
|
553
|
-
|
|
554
|
-
// src/ai/registerCactusWorker.ts
|
|
390
|
+
// src/ai/registerCactusWorker.browser.ts
|
|
555
391
|
import { registerProviderWorker } from "@workglow/ai/provider-utils";
|
|
556
392
|
|
|
557
|
-
// src/ai/CactusProvider.ts
|
|
393
|
+
// src/ai/CactusProvider.browser.ts
|
|
558
394
|
import { AiProvider } from "@workglow/ai/worker";
|
|
559
395
|
class CactusProvider extends AiProvider {
|
|
560
396
|
name = LOCAL_CACTUS;
|
|
@@ -574,11 +410,11 @@ class CactusProvider extends AiProvider {
|
|
|
574
410
|
return crypto.randomUUID();
|
|
575
411
|
}
|
|
576
412
|
async disposeSession(sessionId) {
|
|
577
|
-
await
|
|
413
|
+
await deleteCactusSession(sessionId);
|
|
578
414
|
}
|
|
579
415
|
}
|
|
580
416
|
|
|
581
|
-
// src/ai/registerCactusWorker.ts
|
|
417
|
+
// src/ai/registerCactusWorker.browser.ts
|
|
582
418
|
async function registerCactusWorker() {
|
|
583
419
|
await registerProviderWorker((ws) => new CactusProvider(CACTUS_RUN_FNS, CACTUS_PREVIEW_TASKS).registerOnWorkerServer(ws), "Cactus");
|
|
584
420
|
}
|
|
@@ -600,4 +436,4 @@ export {
|
|
|
600
436
|
cactusConfigJson
|
|
601
437
|
};
|
|
602
438
|
|
|
603
|
-
//# debugId=
|
|
439
|
+
//# debugId=67D13FB5B6D17CB364756E2164756E21
|