@ultrst-armada/kloks 1.18.0 → 1.21.0
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/.krusbl-release-attestation.json +3 -3
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +11 -1
- package/packages/aiko/dist/index.d.ts +105 -0
- package/packages/aiko/dist/index.js +84 -0
- package/packages/aiko/kloks.manifest.json +32 -0
- package/packages/aiko/package.json +14 -0
- package/packages/backend/dist/ai-keys/index.d.ts +1 -1
- package/packages/backend/dist/index.d.ts +1 -1
- package/packages/backend/dist/index.js +62 -62
- package/packages/backend/dist/krnl-ai-services.d.ts +1 -1
- package/packages/backend/dist/krnl-services.js +5 -5
- package/packages/backend/dist/services/index.js +1 -1
- package/packages/backend/dist/storage/index.js +7 -7
- package/packages/backend/dist/{types-B0aSwTAt.d.ts → types-NITEaxAh.d.ts} +1 -0
- package/packages/backend/dist/workspace/index.js +2 -2
- package/packages/fod/dist/index.d.ts +155 -0
- package/packages/fod/dist/index.js +261 -0
- package/packages/fod/kloks.manifest.json +17 -0
- package/packages/fod/package.json +26 -0
- package/packages/state-graph/dist/index.js +15 -15
- package/packages/backend/dist/{chunk-6DNGLKAV.js → chunk-2XTHJI4I.js} +3 -3
- package/packages/backend/dist/{chunk-LCRK2QSY.js → chunk-4ONX56XS.js} +13 -13
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"packageName": "@ultrst-armada/kloks",
|
|
4
|
-
"version": "1.
|
|
5
|
-
"sourceCommit": "
|
|
4
|
+
"version": "1.21.0",
|
|
5
|
+
"sourceCommit": "16094cb698ff64e642910be6d921d0209de43151",
|
|
6
6
|
"releaseWorkflow": "npm Release",
|
|
7
|
-
"workflowRunId": "
|
|
7
|
+
"workflowRunId": "41025580233"
|
|
8
8
|
}
|
package/index.d.ts
CHANGED
|
@@ -5,3 +5,5 @@ export * from './packages/services/dist/index.d.ts';
|
|
|
5
5
|
export * from './packages/backend/dist/index.d.ts';
|
|
6
6
|
export * from './packages/orchestrations/dist/index.d.ts';
|
|
7
7
|
export * from './packages/contracts/dist/index.d.ts';
|
|
8
|
+
export * from './packages/fod/dist/index.d.ts';
|
|
9
|
+
export * from './packages/aiko/dist/index.d.ts';
|
package/index.js
CHANGED
|
@@ -5,3 +5,5 @@ export * from './packages/services/dist/index.js';
|
|
|
5
5
|
export * from './packages/backend/dist/index.js';
|
|
6
6
|
export * from './packages/orchestrations/dist/index.js';
|
|
7
7
|
export * from './packages/contracts/dist/index.js';
|
|
8
|
+
export * from './packages/fod/dist/index.js';
|
|
9
|
+
export * from './packages/aiko/dist/index.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ultrst-armada/kloks",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -144,6 +144,16 @@
|
|
|
144
144
|
"types": "./packages/backend/dist/krnl-ai-services.d.ts",
|
|
145
145
|
"import": "./packages/backend/dist/krnl-ai-services.js",
|
|
146
146
|
"default": "./packages/backend/dist/krnl-ai-services.js"
|
|
147
|
+
},
|
|
148
|
+
"./fod": {
|
|
149
|
+
"types": "./packages/fod/dist/index.d.ts",
|
|
150
|
+
"import": "./packages/fod/dist/index.js",
|
|
151
|
+
"default": "./packages/fod/dist/index.js"
|
|
152
|
+
},
|
|
153
|
+
"./aiko": {
|
|
154
|
+
"types": "./packages/aiko/dist/index.d.ts",
|
|
155
|
+
"import": "./packages/aiko/dist/index.js",
|
|
156
|
+
"default": "./packages/aiko/dist/index.js"
|
|
147
157
|
}
|
|
148
158
|
},
|
|
149
159
|
"scripts": {
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
type AikoSourceKind = 'endpoint' | 'fod-flow' | 'gutts-api' | 'custom';
|
|
2
|
+
interface AikoIntelligenceSpec {
|
|
3
|
+
[key: string]: unknown;
|
|
4
|
+
}
|
|
5
|
+
interface AikoTool {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
inputSchema?: unknown;
|
|
10
|
+
execute: (input: unknown) => Promise<unknown>;
|
|
11
|
+
sourceKind: AikoSourceKind;
|
|
12
|
+
sourceId: string;
|
|
13
|
+
}
|
|
14
|
+
interface AikoAgentDefinition {
|
|
15
|
+
schemaVersion: '1.0.0';
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
agentType: 'TOOL' | 'ENDPOINT' | 'AIKO';
|
|
20
|
+
tool: AikoTool;
|
|
21
|
+
intelligenceSpec: AikoIntelligenceSpec;
|
|
22
|
+
intelligenceSpecId?: string;
|
|
23
|
+
sourceKind: AikoSourceKind;
|
|
24
|
+
sourceId: string;
|
|
25
|
+
allowedToolIds?: string[];
|
|
26
|
+
custom?: boolean;
|
|
27
|
+
}
|
|
28
|
+
interface AikoCapability {
|
|
29
|
+
id: string;
|
|
30
|
+
name: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
sourceKind: AikoSourceKind;
|
|
33
|
+
sourceId: string;
|
|
34
|
+
inputSchema?: unknown;
|
|
35
|
+
execute: (input: unknown) => Promise<unknown>;
|
|
36
|
+
}
|
|
37
|
+
interface AikoKey {
|
|
38
|
+
id: string;
|
|
39
|
+
providerId: string;
|
|
40
|
+
label: string;
|
|
41
|
+
status?: string;
|
|
42
|
+
isActive?: boolean;
|
|
43
|
+
emailGroup?: string;
|
|
44
|
+
expiresAt?: string | null;
|
|
45
|
+
}
|
|
46
|
+
interface AikoIntelligenceResolver {
|
|
47
|
+
resolve(specId?: string, context?: {
|
|
48
|
+
agent?: AikoAgentDefinition;
|
|
49
|
+
tool?: AikoTool;
|
|
50
|
+
}): Promise<{
|
|
51
|
+
spec: AikoIntelligenceSpec;
|
|
52
|
+
specId?: string;
|
|
53
|
+
}> | {
|
|
54
|
+
spec: AikoIntelligenceSpec;
|
|
55
|
+
specId?: string;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
interface AikoKeyRuntime {
|
|
59
|
+
listKeys(): Promise<AikoKey[]>;
|
|
60
|
+
getActiveKey(providerId: string): Promise<AikoKey | null>;
|
|
61
|
+
rotateKey(providerId: string): Promise<AikoKey | null>;
|
|
62
|
+
addKey?(input: {
|
|
63
|
+
providerId: string;
|
|
64
|
+
label: string;
|
|
65
|
+
key: string;
|
|
66
|
+
emailGroup?: string;
|
|
67
|
+
}): Promise<AikoKey>;
|
|
68
|
+
syncFromAikoEngine(): Promise<{
|
|
69
|
+
synced: number;
|
|
70
|
+
message?: string;
|
|
71
|
+
}>;
|
|
72
|
+
}
|
|
73
|
+
interface AikoRuntimeOptions {
|
|
74
|
+
customAgents?: AikoAgentDefinition[];
|
|
75
|
+
capabilities: (() => Promise<AikoCapability[]> | AikoCapability[]) | AikoCapability[];
|
|
76
|
+
resolver: AikoIntelligenceResolver;
|
|
77
|
+
resolveNaturalLanguage?: (agent: AikoAgentDefinition, input: string) => Promise<unknown>;
|
|
78
|
+
keys: AikoKeyRuntime;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
declare class AikoRuntime {
|
|
82
|
+
private readonly options;
|
|
83
|
+
private readonly agents;
|
|
84
|
+
constructor(options: AikoRuntimeOptions);
|
|
85
|
+
listCapabilities(): Promise<AikoCapability[]>;
|
|
86
|
+
refreshAgents(): Promise<AikoAgentDefinition[]>;
|
|
87
|
+
listAgents(): Promise<AikoAgentDefinition[]>;
|
|
88
|
+
executeAgent(agentId: string, input: unknown): Promise<unknown>;
|
|
89
|
+
createCustomAgent(name: string, capabilityIds: string[], specId?: string): Promise<AikoAgentDefinition>;
|
|
90
|
+
listKeys(): Promise<AikoKey[]>;
|
|
91
|
+
getActiveKey(providerId: string): Promise<AikoKey | null>;
|
|
92
|
+
rotateKey(providerId: string): Promise<AikoKey | null>;
|
|
93
|
+
syncFromAikoEngine(): Promise<{
|
|
94
|
+
synced: number;
|
|
95
|
+
message?: string;
|
|
96
|
+
}>;
|
|
97
|
+
addKey(input: {
|
|
98
|
+
providerId: string;
|
|
99
|
+
label: string;
|
|
100
|
+
key: string;
|
|
101
|
+
emailGroup?: string;
|
|
102
|
+
}): Promise<AikoKey>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export { type AikoAgentDefinition, type AikoCapability, type AikoIntelligenceResolver, type AikoIntelligenceSpec, type AikoKey, type AikoKeyRuntime, AikoRuntime, type AikoRuntimeOptions, type AikoSourceKind, type AikoTool };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// src/runtime.ts
|
|
2
|
+
var AikoRuntime = class {
|
|
3
|
+
options;
|
|
4
|
+
agents = /* @__PURE__ */ new Map();
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.options = options;
|
|
7
|
+
for (const agent of options.customAgents ?? []) this.agents.set(agent.id, agent);
|
|
8
|
+
}
|
|
9
|
+
async listCapabilities() {
|
|
10
|
+
const caps = this.options.capabilities;
|
|
11
|
+
return typeof caps === "function" ? await caps() : caps;
|
|
12
|
+
}
|
|
13
|
+
async refreshAgents() {
|
|
14
|
+
const capabilities = await this.listCapabilities();
|
|
15
|
+
const next = /* @__PURE__ */ new Map();
|
|
16
|
+
for (const agent of this.agents.values()) {
|
|
17
|
+
if (agent.custom || agent.sourceKind === "custom") next.set(agent.id, agent);
|
|
18
|
+
}
|
|
19
|
+
for (const capability of capabilities) {
|
|
20
|
+
const tool = { id: capability.id, name: capability.name, description: capability.description, inputSchema: capability.inputSchema, execute: capability.execute, sourceKind: capability.sourceKind, sourceId: capability.sourceId };
|
|
21
|
+
const resolved = await this.options.resolver.resolve(void 0, { tool });
|
|
22
|
+
const agent = {
|
|
23
|
+
schemaVersion: "1.0.0",
|
|
24
|
+
id: "aiko-" + capability.sourceKind + "-" + capability.sourceId,
|
|
25
|
+
name: capability.name + " Agent",
|
|
26
|
+
description: capability.description ?? "Aiko agent for " + capability.name,
|
|
27
|
+
agentType: capability.sourceKind === "endpoint" ? "ENDPOINT" : "TOOL",
|
|
28
|
+
tool,
|
|
29
|
+
intelligenceSpec: resolved.spec,
|
|
30
|
+
intelligenceSpecId: resolved.specId,
|
|
31
|
+
sourceKind: capability.sourceKind,
|
|
32
|
+
sourceId: capability.sourceId
|
|
33
|
+
};
|
|
34
|
+
next.set(agent.id, agent);
|
|
35
|
+
}
|
|
36
|
+
this.agents.clear();
|
|
37
|
+
for (const agent of next.values()) this.agents.set(agent.id, agent);
|
|
38
|
+
return [...this.agents.values()];
|
|
39
|
+
}
|
|
40
|
+
async listAgents() {
|
|
41
|
+
return this.agents.size ? [...this.agents.values()] : this.refreshAgents();
|
|
42
|
+
}
|
|
43
|
+
async executeAgent(agentId, input) {
|
|
44
|
+
const agent = this.agents.get(agentId) ?? (await this.refreshAgents()).find((item) => item.id === agentId);
|
|
45
|
+
if (!agent) throw new Error("Aiko agent not found: " + agentId);
|
|
46
|
+
const resolvedInput = typeof input === "string" && this.options.resolveNaturalLanguage ? await this.options.resolveNaturalLanguage(agent, input) : input;
|
|
47
|
+
return agent.tool.execute(resolvedInput);
|
|
48
|
+
}
|
|
49
|
+
async createCustomAgent(name, capabilityIds, specId) {
|
|
50
|
+
const capabilities = await this.listCapabilities();
|
|
51
|
+
const allowed = capabilities.filter((item) => capabilityIds.includes(item.id));
|
|
52
|
+
if (allowed.length === 0) throw new Error("A custom Aiko agent requires at least one permitted capability.");
|
|
53
|
+
const resolved = await this.options.resolver.resolve(specId, {});
|
|
54
|
+
const tool = { id: "custom-" + name, name, description: "Custom Aiko capability set", execute: async (input) => {
|
|
55
|
+
const request = input;
|
|
56
|
+
if (!request?.toolId || !capabilityIds.includes(request.toolId)) throw new Error("Capability is not permitted for this custom agent.");
|
|
57
|
+
const capability = allowed.find((item) => item.id === request.toolId);
|
|
58
|
+
if (!capability) throw new Error("Capability not found.");
|
|
59
|
+
return capability.execute(request.input);
|
|
60
|
+
}, sourceKind: "custom", sourceId: name };
|
|
61
|
+
const agent = { schemaVersion: "1.0.0", id: "aiko-custom-" + name.toLowerCase().replace(/\s+/g, "-"), name, description: "Custom Aiko agent", agentType: "AIKO", tool, intelligenceSpec: resolved.spec, intelligenceSpecId: resolved.specId, sourceKind: "custom", sourceId: name, allowedToolIds: capabilityIds, custom: true };
|
|
62
|
+
this.agents.set(agent.id, agent);
|
|
63
|
+
return agent;
|
|
64
|
+
}
|
|
65
|
+
listKeys() {
|
|
66
|
+
return this.options.keys.listKeys();
|
|
67
|
+
}
|
|
68
|
+
getActiveKey(providerId) {
|
|
69
|
+
return this.options.keys.getActiveKey(providerId);
|
|
70
|
+
}
|
|
71
|
+
rotateKey(providerId) {
|
|
72
|
+
return this.options.keys.rotateKey(providerId);
|
|
73
|
+
}
|
|
74
|
+
syncFromAikoEngine() {
|
|
75
|
+
return this.options.keys.syncFromAikoEngine();
|
|
76
|
+
}
|
|
77
|
+
addKey(input) {
|
|
78
|
+
if (!this.options.keys.addKey) throw new Error("Local Aiko key storage is unavailable.");
|
|
79
|
+
return this.options.keys.addKey(input);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
export {
|
|
83
|
+
AikoRuntime
|
|
84
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://skipo.dev/schemas/kloks-manifest.v1.json",
|
|
3
|
+
"package": "@kloks/aiko",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"services": [
|
|
6
|
+
{
|
|
7
|
+
"id": "aiko",
|
|
8
|
+
"name": "Aiko Application Module",
|
|
9
|
+
"version": "1.0.0",
|
|
10
|
+
"description": "Embedded Aiko agent runtime, intelligence resolution, and API key synchronization module for Skipo applications.",
|
|
11
|
+
"backend": {
|
|
12
|
+
"package": "@ultrst-armada/kloks",
|
|
13
|
+
"subpath": "aiko",
|
|
14
|
+
"export": "AikoRuntime",
|
|
15
|
+
"facade": "AikoRuntime"
|
|
16
|
+
},
|
|
17
|
+
"modes": [
|
|
18
|
+
"backend",
|
|
19
|
+
"fullstack"
|
|
20
|
+
],
|
|
21
|
+
"targets": {
|
|
22
|
+
"backend": [
|
|
23
|
+
"BackendFacade.services"
|
|
24
|
+
],
|
|
25
|
+
"frontend": [
|
|
26
|
+
"Main.tabs.aiko"
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
"dependencies": []
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name":"@kloks/aiko",
|
|
3
|
+
"version":"1.0.0",
|
|
4
|
+
"description":"Embedded Aiko application module runtime for Skipo applications.",
|
|
5
|
+
"type":"module",
|
|
6
|
+
"private":false,
|
|
7
|
+
"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},
|
|
8
|
+
"main":"./dist/index.js",
|
|
9
|
+
"types":"./dist/index.d.ts",
|
|
10
|
+
"module":"./dist/index.js",
|
|
11
|
+
"exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts","default":"./dist/index.js"}},
|
|
12
|
+
"scripts":{"build":"tsup src/index.ts --format esm --dts --clean","typecheck":"tsc --noEmit","test":"vitest run","clean":"rm -rf dist"},
|
|
13
|
+
"devDependencies":{"tsup":"^8.4.0","typescript":"^5.7.3","vitest":"^3.1.0"}
|
|
14
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as KeyValidationResult, A as ApiKeyEntry, R as RotationStrategy, K as KeyModelUsageStats } from '../types-
|
|
1
|
+
import { a as KeyValidationResult, A as ApiKeyEntry, R as RotationStrategy, K as KeyModelUsageStats } from '../types-NITEaxAh.js';
|
|
2
2
|
import { P as ProviderId } from '../types-Di4ZAQYA.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -21,7 +21,7 @@ export { DeterministicEndpointExecutor, EndpointExecutionParams, EndpointExecuti
|
|
|
21
21
|
export { M as ModelCatalogEntry, a as ModelHealthStatus } from './types-fYUdf9oB.js';
|
|
22
22
|
export { EndpointRefresher, ModelCatalogService, ModelHealthService, STATIC_MODELS_CATALOG, endpointRefresher, modelCatalog, modelHealthService } from './ai-models/index.js';
|
|
23
23
|
export { AIMetricRecord, AIRoutingStrategy, FailoverExecutionEngine, HealthCheckService, MetricsLogger, RetryPolicy, RouteCandidate, RouteExecutionResult, failoverExecutionEngine, healthCheckService, metricsLogger } from './ai-routing/index.js';
|
|
24
|
-
export { A as ApiKeyEntry, K as KeyModelUsageStats, a as KeyValidationResult, R as RotationStrategy } from './types-
|
|
24
|
+
export { A as ApiKeyEntry, K as KeyModelUsageStats, a as KeyValidationResult, R as RotationStrategy } from './types-NITEaxAh.js';
|
|
25
25
|
export { KeyStoreService, KeysStorage, keyStore, keysStorage, validateApiKey } from './ai-keys/index.js';
|
|
26
26
|
export { MCPEngine, MCPServerConfig, MCPTool, MCPToolParameter, ToolExecutionResult, ToolInputValidationResult, ToolManagerService, mcpEngine, toolManagerService, validateToolInput } from './ai-tools/index.js';
|
|
27
27
|
export { AIInferenceServiceDefinition, AIInferenceServiceFacade, AIKeyServiceDefinition, AIKeyServiceFacade, AIModelCatalogServiceDefinition, AIModelCatalogServiceFacade, AIProviderServiceDefinition, AIProviderServiceFacade, AIRoutingServiceDefinition, AIRoutingServiceFacade, AIToolServiceDefinition, AIToolServiceFacade } from './krnl-ai-services.js';
|
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CANONICAL_SRKL_URL,
|
|
3
|
-
SrklClient,
|
|
4
|
-
SrklCredentialRegistry,
|
|
5
|
-
SrklVaultAccessClient,
|
|
6
|
-
createSrklClient,
|
|
7
|
-
decryptVaultBufferInBrowser,
|
|
8
|
-
getPrimarySrklDeploymentUrl as getPrimarySrklDeploymentUrl2,
|
|
9
|
-
getSrklAccounts as getSrklAccounts2,
|
|
10
|
-
getSrklStatus,
|
|
11
|
-
globalCredentialRegistry,
|
|
12
|
-
hexToBytes,
|
|
13
|
-
listBackblazeBuckets,
|
|
14
|
-
srklListBackblazeBuckets as srklListBackblazeBuckets2,
|
|
15
|
-
srklService,
|
|
16
|
-
syncSrklAccounts,
|
|
17
|
-
useSrklServices
|
|
18
|
-
} from "./chunk-3IUA66RS.js";
|
|
19
1
|
import {
|
|
20
2
|
S3Adapter
|
|
21
3
|
} from "./chunk-RBQ4CW3T.js";
|
|
@@ -34,16 +16,30 @@ import {
|
|
|
34
16
|
setWorkingWorkspaceConfig,
|
|
35
17
|
syncWorkspace,
|
|
36
18
|
workingWorkspaceService
|
|
37
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-2XTHJI4I.js";
|
|
38
20
|
import {
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
CompositeBackend,
|
|
22
|
+
EndpointGenerator,
|
|
23
|
+
LOCAL_STORAGE_GRAPHS_PREFIX,
|
|
24
|
+
NodeGraphPersistenceService,
|
|
25
|
+
createBackend,
|
|
26
|
+
createCompositeService,
|
|
27
|
+
createLocalService,
|
|
28
|
+
createRemoteService,
|
|
29
|
+
exportGraphAsJsonFile,
|
|
30
|
+
nodeGraphPersistence,
|
|
31
|
+
parseGraphJsonFile,
|
|
32
|
+
validateGraphDocument
|
|
33
|
+
} from "./chunk-RBF2OGMC.js";
|
|
41
34
|
import {
|
|
42
35
|
BaseApiRoute,
|
|
43
36
|
createSSEResponse,
|
|
44
37
|
withAuth,
|
|
45
38
|
withCors
|
|
46
39
|
} from "./chunk-TWCEVES2.js";
|
|
40
|
+
import {
|
|
41
|
+
validateToolInput
|
|
42
|
+
} from "./chunk-6GQNYRD6.js";
|
|
47
43
|
import {
|
|
48
44
|
AdminGuard,
|
|
49
45
|
BaseAccountProvider,
|
|
@@ -112,19 +108,23 @@ import {
|
|
|
112
108
|
resolveDevelopmentCommand
|
|
113
109
|
} from "./chunk-OYVHKYJW.js";
|
|
114
110
|
import {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
111
|
+
CANONICAL_SRKL_URL,
|
|
112
|
+
SrklClient,
|
|
113
|
+
SrklCredentialRegistry,
|
|
114
|
+
SrklVaultAccessClient,
|
|
115
|
+
createSrklClient,
|
|
116
|
+
decryptVaultBufferInBrowser,
|
|
117
|
+
getPrimarySrklDeploymentUrl as getPrimarySrklDeploymentUrl2,
|
|
118
|
+
getSrklAccounts as getSrklAccounts2,
|
|
119
|
+
getSrklStatus,
|
|
120
|
+
globalCredentialRegistry,
|
|
121
|
+
hexToBytes,
|
|
122
|
+
listBackblazeBuckets,
|
|
123
|
+
srklListBackblazeBuckets as srklListBackblazeBuckets2,
|
|
124
|
+
srklService,
|
|
125
|
+
syncSrklAccounts,
|
|
126
|
+
useSrklServices
|
|
127
|
+
} from "./chunk-3IUA66RS.js";
|
|
128
128
|
import {
|
|
129
129
|
AIInferenceServiceDefinition,
|
|
130
130
|
AIInferenceServiceFacade,
|
|
@@ -178,31 +178,11 @@ import {
|
|
|
178
178
|
krnlWorkspaceGraphServiceFacade,
|
|
179
179
|
krnlWorkspaceServiceDefinition,
|
|
180
180
|
krnlWorkspaceServiceFacade
|
|
181
|
-
} from "./chunk-
|
|
182
|
-
import {
|
|
183
|
-
getPrimarySrklDeploymentUrl,
|
|
184
|
-
getSrklAccounts,
|
|
185
|
-
srklListBackblazeBuckets
|
|
186
|
-
} from "./chunk-XHADDA75.js";
|
|
187
|
-
import {
|
|
188
|
-
authorizeB2,
|
|
189
|
-
b2DownloadFile,
|
|
190
|
-
b2ListBuckets,
|
|
191
|
-
b2ListFileNames,
|
|
192
|
-
b2UploadFile
|
|
193
|
-
} from "./chunk-4QEMALXF.js";
|
|
181
|
+
} from "./chunk-4ONX56XS.js";
|
|
194
182
|
import {
|
|
195
183
|
formatCanonicalWorkspaceFolderName,
|
|
196
184
|
sanitizeWorkspaceName
|
|
197
185
|
} from "./chunk-FZKBTF34.js";
|
|
198
|
-
import {
|
|
199
|
-
CanonicalAuthClient,
|
|
200
|
-
RateLimiter,
|
|
201
|
-
SessionManager,
|
|
202
|
-
createCanonicalAuthClient,
|
|
203
|
-
loginSystemUser,
|
|
204
|
-
resolveUserFromToken
|
|
205
|
-
} from "./chunk-WTBAG4AV.js";
|
|
206
186
|
import {
|
|
207
187
|
workspaceGraphService
|
|
208
188
|
} from "./chunk-47IVAXPJ.js";
|
|
@@ -241,6 +221,33 @@ import {
|
|
|
241
221
|
updateWorkspace,
|
|
242
222
|
writeWorkspaceFile
|
|
243
223
|
} from "./chunk-VN2YMZJO.js";
|
|
224
|
+
import {
|
|
225
|
+
BaseStorageAdapter,
|
|
226
|
+
GoogleDriveAdapter,
|
|
227
|
+
createGoogleDriveAuthorizationUrl,
|
|
228
|
+
exchangeGoogleDriveCode,
|
|
229
|
+
refreshGoogleDriveAccessToken
|
|
230
|
+
} from "./chunk-KKRWZDMN.js";
|
|
231
|
+
import {
|
|
232
|
+
CanonicalAuthClient,
|
|
233
|
+
RateLimiter,
|
|
234
|
+
SessionManager,
|
|
235
|
+
createCanonicalAuthClient,
|
|
236
|
+
loginSystemUser,
|
|
237
|
+
resolveUserFromToken
|
|
238
|
+
} from "./chunk-WTBAG4AV.js";
|
|
239
|
+
import {
|
|
240
|
+
getPrimarySrklDeploymentUrl,
|
|
241
|
+
getSrklAccounts,
|
|
242
|
+
srklListBackblazeBuckets
|
|
243
|
+
} from "./chunk-XHADDA75.js";
|
|
244
|
+
import {
|
|
245
|
+
authorizeB2,
|
|
246
|
+
b2DownloadFile,
|
|
247
|
+
b2ListBuckets,
|
|
248
|
+
b2ListFileNames,
|
|
249
|
+
b2UploadFile
|
|
250
|
+
} from "./chunk-4QEMALXF.js";
|
|
244
251
|
import {
|
|
245
252
|
b2DeleteFileVersion,
|
|
246
253
|
b2DeleteFolder,
|
|
@@ -249,13 +256,6 @@ import {
|
|
|
249
256
|
getUnifiedDbUrl,
|
|
250
257
|
queryUnifiedDb
|
|
251
258
|
} from "./chunk-VAFCR2MS.js";
|
|
252
|
-
import {
|
|
253
|
-
BaseStorageAdapter,
|
|
254
|
-
GoogleDriveAdapter,
|
|
255
|
-
createGoogleDriveAuthorizationUrl,
|
|
256
|
-
exchangeGoogleDriveCode,
|
|
257
|
-
refreshGoogleDriveAccessToken
|
|
258
|
-
} from "./chunk-KKRWZDMN.js";
|
|
259
259
|
import "./chunk-TY32TUNI.js";
|
|
260
260
|
import {
|
|
261
261
|
DeterministicEndpointExecutor,
|
|
@@ -2,7 +2,7 @@ import * as _ultrst_armada_krnl from '@ultrst-armada/krnl';
|
|
|
2
2
|
import { ServiceDefinition } from '@ultrst-armada/krnl';
|
|
3
3
|
import { P as ProviderId } from './types-Di4ZAQYA.js';
|
|
4
4
|
import { M as ModelCatalogEntry } from './types-fYUdf9oB.js';
|
|
5
|
-
import { A as ApiKeyEntry, R as RotationStrategy, K as KeyModelUsageStats } from './types-
|
|
5
|
+
import { A as ApiKeyEntry, R as RotationStrategy, K as KeyModelUsageStats } from './types-NITEaxAh.js';
|
|
6
6
|
|
|
7
7
|
declare const AIProviderServiceDefinition: ServiceDefinition;
|
|
8
8
|
declare const AIProviderServiceFacade: {
|
|
@@ -31,16 +31,16 @@ import {
|
|
|
31
31
|
krnlWorkspaceGraphServiceFacade,
|
|
32
32
|
krnlWorkspaceServiceDefinition,
|
|
33
33
|
krnlWorkspaceServiceFacade
|
|
34
|
-
} from "./chunk-
|
|
35
|
-
import "./chunk-XHADDA75.js";
|
|
36
|
-
import "./chunk-4QEMALXF.js";
|
|
34
|
+
} from "./chunk-4ONX56XS.js";
|
|
37
35
|
import "./chunk-FZKBTF34.js";
|
|
38
|
-
import "./chunk-WTBAG4AV.js";
|
|
39
36
|
import "./chunk-47IVAXPJ.js";
|
|
40
37
|
import "./chunk-SHZAQTIT.js";
|
|
41
38
|
import "./chunk-VN2YMZJO.js";
|
|
42
|
-
import "./chunk-VAFCR2MS.js";
|
|
43
39
|
import "./chunk-KKRWZDMN.js";
|
|
40
|
+
import "./chunk-WTBAG4AV.js";
|
|
41
|
+
import "./chunk-XHADDA75.js";
|
|
42
|
+
import "./chunk-4QEMALXF.js";
|
|
43
|
+
import "./chunk-VAFCR2MS.js";
|
|
44
44
|
import "./chunk-TY32TUNI.js";
|
|
45
45
|
export {
|
|
46
46
|
AuthServiceDefinition,
|
|
@@ -17,8 +17,8 @@ import {
|
|
|
17
17
|
} from "../chunk-47IVAXPJ.js";
|
|
18
18
|
import "../chunk-SHZAQTIT.js";
|
|
19
19
|
import "../chunk-VN2YMZJO.js";
|
|
20
|
-
import "../chunk-VAFCR2MS.js";
|
|
21
20
|
import "../chunk-KKRWZDMN.js";
|
|
21
|
+
import "../chunk-VAFCR2MS.js";
|
|
22
22
|
import "../chunk-TY32TUNI.js";
|
|
23
23
|
export {
|
|
24
24
|
CompositeBackend,
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
S3Adapter
|
|
3
3
|
} from "../chunk-RBQ4CW3T.js";
|
|
4
|
-
import {
|
|
5
|
-
authorizeB2,
|
|
6
|
-
b2DownloadFile,
|
|
7
|
-
b2ListBuckets,
|
|
8
|
-
b2ListFileNames,
|
|
9
|
-
b2UploadFile
|
|
10
|
-
} from "../chunk-4QEMALXF.js";
|
|
11
4
|
import {
|
|
12
5
|
BackblazeB2Adapter,
|
|
13
6
|
LocalFSAdapter,
|
|
@@ -28,6 +21,13 @@ import {
|
|
|
28
21
|
exchangeGoogleDriveCode,
|
|
29
22
|
refreshGoogleDriveAccessToken
|
|
30
23
|
} from "../chunk-KKRWZDMN.js";
|
|
24
|
+
import {
|
|
25
|
+
authorizeB2,
|
|
26
|
+
b2DownloadFile,
|
|
27
|
+
b2ListBuckets,
|
|
28
|
+
b2ListFileNames,
|
|
29
|
+
b2UploadFile
|
|
30
|
+
} from "../chunk-4QEMALXF.js";
|
|
31
31
|
export {
|
|
32
32
|
BackblazeB2Adapter,
|
|
33
33
|
BaseStorageAdapter,
|
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
WorkspaceFS,
|
|
7
7
|
remoteWorkspaceService,
|
|
8
8
|
workingWorkspaceService
|
|
9
|
-
} from "../chunk-
|
|
9
|
+
} from "../chunk-2XTHJI4I.js";
|
|
10
10
|
import {
|
|
11
11
|
formatCanonicalWorkspaceFolderName,
|
|
12
12
|
sanitizeWorkspaceName
|
|
13
13
|
} from "../chunk-FZKBTF34.js";
|
|
14
14
|
import "../chunk-VN2YMZJO.js";
|
|
15
|
-
import "../chunk-VAFCR2MS.js";
|
|
16
15
|
import "../chunk-KKRWZDMN.js";
|
|
16
|
+
import "../chunk-VAFCR2MS.js";
|
|
17
17
|
export {
|
|
18
18
|
RemoteWorkspaceService,
|
|
19
19
|
SyncEngine,
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import * as _ultrst_armada_krnl from '@ultrst-armada/krnl';
|
|
2
|
+
import { ServiceDefinition } from '@ultrst-armada/krnl';
|
|
3
|
+
|
|
4
|
+
type FodPortDirection = 'input' | 'output';
|
|
5
|
+
type FodNodeCategory = 'host-app' | 'gutts' | 'flow' | 'system';
|
|
6
|
+
interface FodPort {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
direction: FodPortDirection;
|
|
10
|
+
dataType: string;
|
|
11
|
+
required?: boolean;
|
|
12
|
+
description?: string;
|
|
13
|
+
schema?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
interface FodNodeDefinition {
|
|
16
|
+
type: string;
|
|
17
|
+
label: string;
|
|
18
|
+
description: string;
|
|
19
|
+
category: FodNodeCategory;
|
|
20
|
+
group: string;
|
|
21
|
+
inputs: FodPort[];
|
|
22
|
+
outputs: FodPort[];
|
|
23
|
+
metadata?: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
interface FodEndpointDescriptor {
|
|
26
|
+
id: string;
|
|
27
|
+
serviceId: string;
|
|
28
|
+
serviceName: string;
|
|
29
|
+
operationId: string;
|
|
30
|
+
operationName: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
runtime?: string;
|
|
33
|
+
deployment?: string;
|
|
34
|
+
inputSchema?: Record<string, unknown>;
|
|
35
|
+
outputSchema?: Record<string, unknown>;
|
|
36
|
+
invoke: (input: unknown) => Promise<unknown>;
|
|
37
|
+
}
|
|
38
|
+
interface FodFlowNode {
|
|
39
|
+
id: string;
|
|
40
|
+
type: string;
|
|
41
|
+
position: {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
};
|
|
45
|
+
data: Record<string, unknown>;
|
|
46
|
+
}
|
|
47
|
+
interface FodFlowEdge {
|
|
48
|
+
id: string;
|
|
49
|
+
source: string;
|
|
50
|
+
sourceHandle?: string;
|
|
51
|
+
target: string;
|
|
52
|
+
targetHandle?: string;
|
|
53
|
+
}
|
|
54
|
+
interface FodFlow {
|
|
55
|
+
id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
version: number;
|
|
59
|
+
createdAt: string;
|
|
60
|
+
updatedAt: string;
|
|
61
|
+
nodes: FodFlowNode[];
|
|
62
|
+
edges: FodFlowEdge[];
|
|
63
|
+
viewport?: {
|
|
64
|
+
x: number;
|
|
65
|
+
y: number;
|
|
66
|
+
zoom: number;
|
|
67
|
+
};
|
|
68
|
+
metadata?: Record<string, unknown>;
|
|
69
|
+
}
|
|
70
|
+
interface FodExecutionEvent {
|
|
71
|
+
type: 'flow-started' | 'node-started' | 'node-completed' | 'node-failed' | 'flow-completed';
|
|
72
|
+
timestamp: number;
|
|
73
|
+
flowId: string;
|
|
74
|
+
nodeId?: string;
|
|
75
|
+
data?: unknown;
|
|
76
|
+
}
|
|
77
|
+
interface FodExecutionResult {
|
|
78
|
+
success: boolean;
|
|
79
|
+
flowId: string;
|
|
80
|
+
output: unknown;
|
|
81
|
+
outputs: Record<string, unknown>;
|
|
82
|
+
errors: Array<{
|
|
83
|
+
nodeId?: string;
|
|
84
|
+
message: string;
|
|
85
|
+
}>;
|
|
86
|
+
events: FodExecutionEvent[];
|
|
87
|
+
}
|
|
88
|
+
interface FodRuntimeOptions {
|
|
89
|
+
workspaceId: string;
|
|
90
|
+
workspaceService: any;
|
|
91
|
+
endpoints?: FodEndpointDescriptor[];
|
|
92
|
+
nodes?: FodNodeDefinition[];
|
|
93
|
+
onEvent?: (event: FodExecutionEvent) => void;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
declare function scanBackendFacade(facade: Record<string, unknown>): FodEndpointDescriptor[];
|
|
97
|
+
declare function endpointToNode(endpoint: FodEndpointDescriptor): FodNodeDefinition;
|
|
98
|
+
declare function scanBackendFacadeToNodes(facade: Record<string, unknown>): {
|
|
99
|
+
endpoints: FodEndpointDescriptor[];
|
|
100
|
+
nodes: FodNodeDefinition[];
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
declare class FodFlowStore {
|
|
104
|
+
private readonly workspaceService;
|
|
105
|
+
constructor(workspaceService: any);
|
|
106
|
+
list(workspaceId: string): Promise<FodFlow[]>;
|
|
107
|
+
get(workspaceId: string, flowId: string): Promise<FodFlow | null>;
|
|
108
|
+
save(workspaceId: string, flow: FodFlow): Promise<FodFlow>;
|
|
109
|
+
delete(workspaceId: string, flowId: string): Promise<boolean>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
declare function executeFodFlow(flow: FodFlow, endpoints: Map<string, FodEndpointDescriptor>, onEvent?: (event: FodExecutionEvent) => void, initialInput?: unknown): Promise<FodExecutionResult>;
|
|
113
|
+
|
|
114
|
+
declare class FodRuntime {
|
|
115
|
+
private readonly options;
|
|
116
|
+
readonly flowStore: FodFlowStore;
|
|
117
|
+
private endpoints;
|
|
118
|
+
private nodes;
|
|
119
|
+
constructor(options: {
|
|
120
|
+
workspaceId: string;
|
|
121
|
+
workspaceService: any;
|
|
122
|
+
onEvent?: (event: any) => void;
|
|
123
|
+
});
|
|
124
|
+
setEndpoints(endpoints: FodEndpointDescriptor[], nodes?: FodNodeDefinition[]): void;
|
|
125
|
+
getNodeDefinitions(): FodNodeDefinition[];
|
|
126
|
+
getEndpoints(): FodEndpointDescriptor[];
|
|
127
|
+
listFlows(): Promise<FodFlow[]>;
|
|
128
|
+
getFlow(flowId: string): Promise<FodFlow | null>;
|
|
129
|
+
saveFlow(flow: FodFlow): Promise<FodFlow>;
|
|
130
|
+
deleteFlow(flowId: string): Promise<boolean>;
|
|
131
|
+
executeFlow(flowId: string, input?: unknown): Promise<FodExecutionResult>;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
declare function createFodServiceFacade(runtime: FodRuntime): {
|
|
135
|
+
id: string;
|
|
136
|
+
name: string;
|
|
137
|
+
version: string;
|
|
138
|
+
runtime: "server";
|
|
139
|
+
deployment: "local";
|
|
140
|
+
definition: ServiceDefinition<Record<string, unknown>, Record<string, unknown>>;
|
|
141
|
+
createInstance: () => _ultrst_armada_krnl.ServiceInstance<Record<string, unknown>, Record<string, unknown>>;
|
|
142
|
+
execute: <TIn = unknown, TOut = unknown>(op: string, input?: TIn) => Promise<TOut>;
|
|
143
|
+
};
|
|
144
|
+
declare function createFodServiceFacadeForWorkspace(buildRuntime: (workspaceId: string) => FodRuntime): {
|
|
145
|
+
id: string;
|
|
146
|
+
name: string;
|
|
147
|
+
version: string;
|
|
148
|
+
runtime: "server";
|
|
149
|
+
deployment: "local";
|
|
150
|
+
definition: ServiceDefinition<Record<string, unknown>, Record<string, unknown>>;
|
|
151
|
+
createInstance: () => _ultrst_armada_krnl.ServiceInstance<Record<string, unknown>, Record<string, unknown>>;
|
|
152
|
+
execute: <TIn = unknown, TOut = unknown>(op: string, input?: TIn) => Promise<TOut>;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export { type FodEndpointDescriptor, type FodExecutionEvent, type FodExecutionResult, type FodFlow, type FodFlowEdge, type FodFlowNode, FodFlowStore, type FodNodeCategory, type FodNodeDefinition, type FodPort, type FodPortDirection, FodRuntime, type FodRuntimeOptions, createFodServiceFacade, createFodServiceFacadeForWorkspace, endpointToNode, executeFodFlow, scanBackendFacade, scanBackendFacadeToNodes };
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
// src/endpointNodeProvider.ts
|
|
2
|
+
function portsFromSchema(schema, direction) {
|
|
3
|
+
if (!schema || schema.type !== "object") {
|
|
4
|
+
return [{ id: direction === "input" ? "input" : "result", name: direction === "input" ? "input" : "result", direction, dataType: String(schema?.type ?? "any") }];
|
|
5
|
+
}
|
|
6
|
+
const properties = schema.properties ?? {};
|
|
7
|
+
const required = new Set(Array.isArray(schema.required) ? schema.required.map(String) : []);
|
|
8
|
+
return Object.entries(properties).map(([id, value]) => ({
|
|
9
|
+
id,
|
|
10
|
+
name: id,
|
|
11
|
+
direction,
|
|
12
|
+
dataType: String(value?.type ?? "any"),
|
|
13
|
+
required: required.has(id),
|
|
14
|
+
description: typeof value?.description === "string" ? value.description : void 0,
|
|
15
|
+
schema: value
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
function scanBackendFacade(facade) {
|
|
19
|
+
const endpoints = [];
|
|
20
|
+
const services = facade.services ?? {};
|
|
21
|
+
for (const [serviceKey, service] of Object.entries(services)) {
|
|
22
|
+
const definition = service?.definition;
|
|
23
|
+
if (!definition?.operations) continue;
|
|
24
|
+
for (const [operationKey, operation] of Object.entries(definition.operations)) {
|
|
25
|
+
if (typeof service.execute !== "function") continue;
|
|
26
|
+
endpoints.push({
|
|
27
|
+
id: String(operation.id ?? `${service.id ?? serviceKey}.${operationKey}`),
|
|
28
|
+
serviceId: String(service.id ?? serviceKey),
|
|
29
|
+
serviceName: String(service.name ?? serviceKey),
|
|
30
|
+
operationId: String(operation.id ?? operationKey),
|
|
31
|
+
operationName: String(operation.name ?? operationKey),
|
|
32
|
+
description: typeof operation.description === "string" ? operation.description : void 0,
|
|
33
|
+
runtime: typeof service.runtime === "string" ? service.runtime : void 0,
|
|
34
|
+
deployment: typeof service.deployment === "string" ? service.deployment : void 0,
|
|
35
|
+
inputSchema: operation.inputSchema,
|
|
36
|
+
outputSchema: operation.outputSchema,
|
|
37
|
+
invoke: (input) => service.execute(operationKey, input)
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return endpoints;
|
|
42
|
+
}
|
|
43
|
+
function endpointToNode(endpoint) {
|
|
44
|
+
return {
|
|
45
|
+
type: `host/${endpoint.id}`,
|
|
46
|
+
label: endpoint.operationName,
|
|
47
|
+
description: endpoint.description ?? endpoint.operationId,
|
|
48
|
+
category: "host-app",
|
|
49
|
+
group: endpoint.serviceName,
|
|
50
|
+
inputs: portsFromSchema(endpoint.inputSchema, "input"),
|
|
51
|
+
outputs: portsFromSchema(endpoint.outputSchema, "output"),
|
|
52
|
+
metadata: {
|
|
53
|
+
endpointId: endpoint.id,
|
|
54
|
+
serviceId: endpoint.serviceId,
|
|
55
|
+
operationId: endpoint.operationId,
|
|
56
|
+
runtime: endpoint.runtime,
|
|
57
|
+
deployment: endpoint.deployment
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function scanBackendFacadeToNodes(facade) {
|
|
62
|
+
const endpoints = scanBackendFacade(facade);
|
|
63
|
+
return { endpoints, nodes: endpoints.map(endpointToNode) };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/flowStore.ts
|
|
67
|
+
var ROOT = "FOD";
|
|
68
|
+
function pathFor(flowId) {
|
|
69
|
+
const safe = flowId.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
70
|
+
return `${ROOT}/${safe}.json`;
|
|
71
|
+
}
|
|
72
|
+
var FodFlowStore = class {
|
|
73
|
+
constructor(workspaceService) {
|
|
74
|
+
this.workspaceService = workspaceService;
|
|
75
|
+
}
|
|
76
|
+
workspaceService;
|
|
77
|
+
async list(workspaceId) {
|
|
78
|
+
const entries = await this.workspaceService.listFiles(workspaceId, ROOT);
|
|
79
|
+
const flows = [];
|
|
80
|
+
for (const entry of entries) {
|
|
81
|
+
if (entry.isFolder || !entry.name.endsWith(".json")) continue;
|
|
82
|
+
try {
|
|
83
|
+
const raw = await this.workspaceService.readFile(workspaceId, entry.path);
|
|
84
|
+
flows.push(JSON.parse(typeof raw === "string" ? raw : Buffer.from(raw).toString("utf8")));
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return flows.sort((a, b) => a.name.localeCompare(b.name));
|
|
89
|
+
}
|
|
90
|
+
async get(workspaceId, flowId) {
|
|
91
|
+
try {
|
|
92
|
+
const raw = await this.workspaceService.readFile(workspaceId, pathFor(flowId));
|
|
93
|
+
return JSON.parse(typeof raw === "string" ? raw : Buffer.from(raw).toString("utf8"));
|
|
94
|
+
} catch {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async save(workspaceId, flow) {
|
|
99
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
100
|
+
const next = { ...flow, updatedAt: now, version: Math.max(1, flow.version ?? 1) };
|
|
101
|
+
await this.workspaceService.writeFile(workspaceId, pathFor(flow.id), JSON.stringify(next, null, 2));
|
|
102
|
+
return next;
|
|
103
|
+
}
|
|
104
|
+
async delete(workspaceId, flowId) {
|
|
105
|
+
const result = await this.workspaceService.deleteFile(workspaceId, pathFor(flowId));
|
|
106
|
+
return Boolean(result?.success);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// src/executor.ts
|
|
111
|
+
async function executeFodFlow(flow, endpoints, onEvent, initialInput) {
|
|
112
|
+
const events = [];
|
|
113
|
+
const errors = [];
|
|
114
|
+
const emit = (event) => {
|
|
115
|
+
events.push(event);
|
|
116
|
+
onEvent?.(event);
|
|
117
|
+
};
|
|
118
|
+
emit({ type: "flow-started", timestamp: Date.now(), flowId: flow.id });
|
|
119
|
+
const outputs = {};
|
|
120
|
+
const incoming = (nodeId) => flow.edges.filter((edge) => edge.target === nodeId);
|
|
121
|
+
const remaining = new Set(flow.nodes.map((node) => node.id));
|
|
122
|
+
const values = /* @__PURE__ */ new Map();
|
|
123
|
+
while (remaining.size) {
|
|
124
|
+
const ready = flow.nodes.filter((node) => remaining.has(node.id) && incoming(node.id).every((edge) => values.has(`${edge.source}:${edge.sourceHandle ?? "result"}`)));
|
|
125
|
+
if (!ready.length) {
|
|
126
|
+
const unresolved = [...remaining].join(", ");
|
|
127
|
+
const message = `Flow contains an unresolved dependency or cycle: ${unresolved}`;
|
|
128
|
+
errors.push({ message });
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
for (const node of ready) {
|
|
132
|
+
remaining.delete(node.id);
|
|
133
|
+
emit({ type: "node-started", timestamp: Date.now(), flowId: flow.id, nodeId: node.id });
|
|
134
|
+
try {
|
|
135
|
+
const endpointId = String(node.data.endpointId ?? node.data.apiId ?? node.type.replace(/^(host|gutts)\//, ""));
|
|
136
|
+
const endpoint = endpoints.get(endpointId);
|
|
137
|
+
if (!endpoint) throw new Error(`No executable endpoint registered for node '${node.type}'.`);
|
|
138
|
+
const input = {};
|
|
139
|
+
if (incoming(node.id).length === 0 && initialInput !== void 0) {
|
|
140
|
+
if (typeof initialInput === "object" && initialInput !== null) {
|
|
141
|
+
Object.assign(input, initialInput);
|
|
142
|
+
} else {
|
|
143
|
+
input.input = initialInput;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
for (const edge of incoming(node.id)) {
|
|
147
|
+
input[String(edge.targetHandle ?? "input")] = values.get(`${edge.source}:${edge.sourceHandle ?? "result"}`);
|
|
148
|
+
}
|
|
149
|
+
const configured = node.data.inputs ?? {};
|
|
150
|
+
Object.assign(input, configured);
|
|
151
|
+
const result = await endpoint.invoke(input);
|
|
152
|
+
outputs[node.id] = result;
|
|
153
|
+
values.set(`${node.id}:result`, result);
|
|
154
|
+
if (result && typeof result === "object") {
|
|
155
|
+
for (const [key, value] of Object.entries(result)) values.set(`${node.id}:${key}`, value);
|
|
156
|
+
}
|
|
157
|
+
emit({ type: "node-completed", timestamp: Date.now(), flowId: flow.id, nodeId: node.id, data: result });
|
|
158
|
+
} catch (error) {
|
|
159
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
160
|
+
errors.push({ nodeId: node.id, message });
|
|
161
|
+
emit({ type: "node-failed", timestamp: Date.now(), flowId: flow.id, nodeId: node.id, data: message });
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (errors.length) break;
|
|
166
|
+
}
|
|
167
|
+
const success = errors.length === 0 && remaining.size === 0;
|
|
168
|
+
const last = flow.nodes.at(-1);
|
|
169
|
+
emit({ type: "flow-completed", timestamp: Date.now(), flowId: flow.id, data: { success } });
|
|
170
|
+
return { success, flowId: flow.id, output: last ? outputs[last.id] : void 0, outputs, errors, events };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// src/runtime.ts
|
|
174
|
+
var FodRuntime = class {
|
|
175
|
+
constructor(options) {
|
|
176
|
+
this.options = options;
|
|
177
|
+
this.flowStore = new FodFlowStore(options.workspaceService);
|
|
178
|
+
}
|
|
179
|
+
options;
|
|
180
|
+
flowStore;
|
|
181
|
+
endpoints = /* @__PURE__ */ new Map();
|
|
182
|
+
nodes = [];
|
|
183
|
+
setEndpoints(endpoints, nodes = []) {
|
|
184
|
+
this.endpoints = new Map(endpoints.map((endpoint) => [endpoint.id, endpoint]));
|
|
185
|
+
this.nodes = nodes;
|
|
186
|
+
}
|
|
187
|
+
getNodeDefinitions() {
|
|
188
|
+
return [...this.nodes];
|
|
189
|
+
}
|
|
190
|
+
getEndpoints() {
|
|
191
|
+
return [...this.endpoints.values()];
|
|
192
|
+
}
|
|
193
|
+
async listFlows() {
|
|
194
|
+
return this.flowStore.list(this.options.workspaceId);
|
|
195
|
+
}
|
|
196
|
+
async getFlow(flowId) {
|
|
197
|
+
return this.flowStore.get(this.options.workspaceId, flowId);
|
|
198
|
+
}
|
|
199
|
+
async saveFlow(flow) {
|
|
200
|
+
return this.flowStore.save(this.options.workspaceId, flow);
|
|
201
|
+
}
|
|
202
|
+
async deleteFlow(flowId) {
|
|
203
|
+
return this.flowStore.delete(this.options.workspaceId, flowId);
|
|
204
|
+
}
|
|
205
|
+
async executeFlow(flowId, input) {
|
|
206
|
+
const flow = await this.getFlow(flowId);
|
|
207
|
+
if (!flow) throw new Error(`FOD flow '${flowId}' not found.`);
|
|
208
|
+
return executeFodFlow(flow, this.endpoints, this.options.onEvent, input);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// src/index.ts
|
|
213
|
+
import { createService } from "@ultrst-armada/krnl";
|
|
214
|
+
function createFodServiceFacade(runtime) {
|
|
215
|
+
const definition = {
|
|
216
|
+
id: "kloks.fod",
|
|
217
|
+
name: "FodService",
|
|
218
|
+
version: "1.0.0",
|
|
219
|
+
operations: {
|
|
220
|
+
listFlows: { id: "FodService.listFlows", name: "listFlows", inputSchema: { type: "object", properties: {} }, outputSchema: { type: "array" }, handler: async () => runtime.listFlows() },
|
|
221
|
+
getFlow: { id: "FodService.getFlow", name: "getFlow", inputSchema: { type: "object", properties: { flowId: { type: "string" } }, required: ["flowId"] }, outputSchema: { type: "object" }, handler: async (input) => runtime.getFlow(String(input.flowId)) },
|
|
222
|
+
saveFlow: { id: "FodService.saveFlow", name: "saveFlow", inputSchema: { type: "object" }, outputSchema: { type: "object" }, handler: async (input) => runtime.saveFlow(input.flow) },
|
|
223
|
+
deleteFlow: { id: "FodService.deleteFlow", name: "deleteFlow", inputSchema: { type: "object", properties: { flowId: { type: "string" } }, required: ["flowId"] }, outputSchema: { type: "object" }, handler: async (input) => ({ success: await runtime.deleteFlow(String(input.flowId)) }) },
|
|
224
|
+
executeFlow: { id: "FodService.executeFlow", name: "executeFlow", inputSchema: { type: "object", properties: { flowId: { type: "string" }, input: { type: "object" } }, required: ["flowId"] }, outputSchema: { type: "object" }, handler: async (input) => runtime.executeFlow(String(input.flowId), input.input) }
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
const service = createService(definition);
|
|
228
|
+
return { id: definition.id, name: definition.name, version: definition.version, runtime: "server", deployment: "local", definition, createInstance: () => createService(definition), execute: async (op, input) => {
|
|
229
|
+
await service.start();
|
|
230
|
+
return service.call(op, input);
|
|
231
|
+
} };
|
|
232
|
+
}
|
|
233
|
+
function createFodServiceFacadeForWorkspace(buildRuntime) {
|
|
234
|
+
const definition = {
|
|
235
|
+
id: "kloks.fod",
|
|
236
|
+
name: "FodService",
|
|
237
|
+
version: "1.0.0",
|
|
238
|
+
operations: {
|
|
239
|
+
listFlows: { id: "FodService.listFlows", name: "listFlows", inputSchema: { type: "object", properties: { workspaceId: { type: "string" } }, required: ["workspaceId"] }, outputSchema: { type: "array" }, handler: async (input) => buildRuntime(String(input.workspaceId)).listFlows() },
|
|
240
|
+
getFlow: { id: "FodService.getFlow", name: "getFlow", inputSchema: { type: "object", properties: { workspaceId: { type: "string" }, flowId: { type: "string" } }, required: ["workspaceId", "flowId"] }, outputSchema: { type: "object" }, handler: async (input) => buildRuntime(String(input.workspaceId)).getFlow(String(input.flowId)) },
|
|
241
|
+
saveFlow: { id: "FodService.saveFlow", name: "saveFlow", inputSchema: { type: "object", properties: { workspaceId: { type: "string" }, flow: { type: "object" } }, required: ["workspaceId", "flow"] }, outputSchema: { type: "object" }, handler: async (input) => buildRuntime(String(input.workspaceId)).saveFlow(input.flow) },
|
|
242
|
+
deleteFlow: { id: "FodService.deleteFlow", name: "deleteFlow", inputSchema: { type: "object", properties: { workspaceId: { type: "string" }, flowId: { type: "string" } }, required: ["workspaceId", "flowId"] }, outputSchema: { type: "object" }, handler: async (input) => ({ success: await buildRuntime(String(input.workspaceId)).deleteFlow(String(input.flowId)) }) },
|
|
243
|
+
executeFlow: { id: "FodService.executeFlow", name: "executeFlow", inputSchema: { type: "object", properties: { workspaceId: { type: "string" }, flowId: { type: "string" }, input: { type: "object" } }, required: ["workspaceId", "flowId"] }, outputSchema: { type: "object" }, handler: async (input) => buildRuntime(String(input.workspaceId)).executeFlow(String(input.flowId), input.input) }
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
const service = createService(definition);
|
|
247
|
+
return { id: definition.id, name: definition.name, version: definition.version, runtime: "server", deployment: "local", definition, createInstance: () => createService(definition), execute: async (op, input) => {
|
|
248
|
+
await service.start();
|
|
249
|
+
return service.call(op, input);
|
|
250
|
+
} };
|
|
251
|
+
}
|
|
252
|
+
export {
|
|
253
|
+
FodFlowStore,
|
|
254
|
+
FodRuntime,
|
|
255
|
+
createFodServiceFacade,
|
|
256
|
+
createFodServiceFacadeForWorkspace,
|
|
257
|
+
endpointToNode,
|
|
258
|
+
executeFodFlow,
|
|
259
|
+
scanBackendFacade,
|
|
260
|
+
scanBackendFacadeToNodes
|
|
261
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema":"https://skipo.dev/schemas/kloks-manifest.v1.json",
|
|
3
|
+
"package":"@kloks/fod",
|
|
4
|
+
"version":"1.0.0",
|
|
5
|
+
"services":[
|
|
6
|
+
{
|
|
7
|
+
"id":"fod",
|
|
8
|
+
"name":"FOD Workflow Module",
|
|
9
|
+
"version":"1.0.0",
|
|
10
|
+
"description":"Embedded workflow discovery, persistence, validation and execution capability for Skipo applications.",
|
|
11
|
+
"backend":{"package":"@ultrst-armada/kloks","subpath":"fod","export":"FodServiceFacade","facade":"FodServiceFacade"},
|
|
12
|
+
"modes":["backend","fullstack"],
|
|
13
|
+
"targets":{"backend":["BackendFacade.services"],"frontend":["Main.tabs.fod"]},
|
|
14
|
+
"dependencies":[]
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kloks/fod",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Embedded FOD workflow orchestration module for Skipo applications.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"private": false,
|
|
7
|
+
"publishConfig": {"access":"public","registry":"https://registry.npmjs.org/"},
|
|
8
|
+
"main":"./dist/index.js","types":"./dist/index.d.ts","module":"./dist/index.js",
|
|
9
|
+
"exports": {".":{"import":"./dist/index.js","types":"./dist/index.d.ts","default":"./dist/index.js"}},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build":"tsup src/index.ts --format esm --dts --clean --external @ultrst-armada/krnl",
|
|
12
|
+
"typecheck":"tsc --noEmit",
|
|
13
|
+
"test":"vitest run",
|
|
14
|
+
"clean":"rm -rf dist"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@kloks/backend":"workspace:*",
|
|
18
|
+
"@kloks/state-graph":"workspace:*"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@ultrst-armada/krnl":"^1.0.3",
|
|
22
|
+
"tsup":"^8.4.0",
|
|
23
|
+
"typescript":"^5.7.3",
|
|
24
|
+
"vitest":"^3.1.0"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -7,6 +7,21 @@ import {
|
|
|
7
7
|
instantiateSubgraph
|
|
8
8
|
} from "./chunk-S22PMERU.js";
|
|
9
9
|
import "./chunk-RHRXPY2U.js";
|
|
10
|
+
import {
|
|
11
|
+
AttractionEngine,
|
|
12
|
+
GhostInferenceEngine,
|
|
13
|
+
GhostLayoutResolver,
|
|
14
|
+
GhostTracePathBuilder,
|
|
15
|
+
calculateSocketCoordinates,
|
|
16
|
+
getBeamPoints,
|
|
17
|
+
useMagneticTraces
|
|
18
|
+
} from "./chunk-JXDJZSFW.js";
|
|
19
|
+
import {
|
|
20
|
+
ConnectionRuleStore,
|
|
21
|
+
HandleTypeRegistry,
|
|
22
|
+
WireTypeRegistry,
|
|
23
|
+
initializeDefaultGraphRules
|
|
24
|
+
} from "./chunk-TZOL3RN7.js";
|
|
10
25
|
import {
|
|
11
26
|
LifecycleCycleError,
|
|
12
27
|
LifecycleGraph,
|
|
@@ -30,21 +45,6 @@ import {
|
|
|
30
45
|
CustomViewWindow,
|
|
31
46
|
DEFAULT_GRAPH_SETTINGS
|
|
32
47
|
} from "./chunk-KG6QYS26.js";
|
|
33
|
-
import {
|
|
34
|
-
AttractionEngine,
|
|
35
|
-
GhostInferenceEngine,
|
|
36
|
-
GhostLayoutResolver,
|
|
37
|
-
GhostTracePathBuilder,
|
|
38
|
-
calculateSocketCoordinates,
|
|
39
|
-
getBeamPoints,
|
|
40
|
-
useMagneticTraces
|
|
41
|
-
} from "./chunk-JXDJZSFW.js";
|
|
42
|
-
import {
|
|
43
|
-
ConnectionRuleStore,
|
|
44
|
-
HandleTypeRegistry,
|
|
45
|
-
WireTypeRegistry,
|
|
46
|
-
initializeDefaultGraphRules
|
|
47
|
-
} from "./chunk-TZOL3RN7.js";
|
|
48
48
|
import {
|
|
49
49
|
AutoSolidify,
|
|
50
50
|
SpatialEngine,
|
|
@@ -5,15 +5,15 @@ import {
|
|
|
5
5
|
getWorkspaces,
|
|
6
6
|
updateWorkspace
|
|
7
7
|
} from "./chunk-VN2YMZJO.js";
|
|
8
|
+
import {
|
|
9
|
+
GoogleDriveAdapter
|
|
10
|
+
} from "./chunk-KKRWZDMN.js";
|
|
8
11
|
import {
|
|
9
12
|
b2DownloadFile,
|
|
10
13
|
b2ListFileNames,
|
|
11
14
|
b2UploadFile,
|
|
12
15
|
queryUnifiedDb
|
|
13
16
|
} from "./chunk-VAFCR2MS.js";
|
|
14
|
-
import {
|
|
15
|
-
GoogleDriveAdapter
|
|
16
|
-
} from "./chunk-KKRWZDMN.js";
|
|
17
17
|
|
|
18
18
|
// src/workspace/WorkspaceFS.ts
|
|
19
19
|
import { SkipoBase } from "@ultrst-armada/kloks/functions";
|
|
@@ -1,20 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getSrklAccounts,
|
|
3
|
-
srklListBackblazeBuckets
|
|
4
|
-
} from "./chunk-XHADDA75.js";
|
|
5
|
-
import {
|
|
6
|
-
b2ListBuckets
|
|
7
|
-
} from "./chunk-4QEMALXF.js";
|
|
8
1
|
import {
|
|
9
2
|
formatCanonicalWorkspaceFolderName,
|
|
10
3
|
sanitizeWorkspaceName
|
|
11
4
|
} from "./chunk-FZKBTF34.js";
|
|
12
|
-
import {
|
|
13
|
-
RateLimiter,
|
|
14
|
-
SessionManager,
|
|
15
|
-
loginSystemUser,
|
|
16
|
-
resolveUserFromToken
|
|
17
|
-
} from "./chunk-WTBAG4AV.js";
|
|
18
5
|
import {
|
|
19
6
|
workspaceGraphService
|
|
20
7
|
} from "./chunk-47IVAXPJ.js";
|
|
@@ -28,6 +15,19 @@ import {
|
|
|
28
15
|
getWorkspaces,
|
|
29
16
|
updateWorkspace
|
|
30
17
|
} from "./chunk-VN2YMZJO.js";
|
|
18
|
+
import {
|
|
19
|
+
RateLimiter,
|
|
20
|
+
SessionManager,
|
|
21
|
+
loginSystemUser,
|
|
22
|
+
resolveUserFromToken
|
|
23
|
+
} from "./chunk-WTBAG4AV.js";
|
|
24
|
+
import {
|
|
25
|
+
getSrklAccounts,
|
|
26
|
+
srklListBackblazeBuckets
|
|
27
|
+
} from "./chunk-XHADDA75.js";
|
|
28
|
+
import {
|
|
29
|
+
b2ListBuckets
|
|
30
|
+
} from "./chunk-4QEMALXF.js";
|
|
31
31
|
import {
|
|
32
32
|
queryUnifiedDb
|
|
33
33
|
} from "./chunk-VAFCR2MS.js";
|