@vertesia/workflow 1.0.0-dev.20260305.083323Z → 1.0.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/lib/cjs/activities/chunkDocument.js +1 -3
- package/lib/cjs/activities/chunkDocument.js.map +1 -1
- package/lib/cjs/activities/executeInteraction.js +18 -0
- package/lib/cjs/activities/executeInteraction.js.map +1 -1
- package/lib/cjs/activities/executeRemoteActivity.js +107 -0
- package/lib/cjs/activities/executeRemoteActivity.js.map +1 -0
- package/lib/cjs/activities/getObjectFromStore.js +12 -1
- package/lib/cjs/activities/getObjectFromStore.js.map +1 -1
- package/lib/cjs/activities/index-dsl.js +5 -3
- package/lib/cjs/activities/index-dsl.js.map +1 -1
- package/lib/cjs/activities/resolveRemoteActivities.js +120 -0
- package/lib/cjs/activities/resolveRemoteActivities.js.map +1 -0
- package/lib/cjs/dsl/dsl-workflow.js +66 -6
- package/lib/cjs/dsl/dsl-workflow.js.map +1 -1
- package/lib/cjs/utils/storage.js +9 -9
- package/lib/cjs/utils/storage.js.map +1 -1
- package/lib/esm/activities/chunkDocument.js +1 -3
- package/lib/esm/activities/chunkDocument.js.map +1 -1
- package/lib/esm/activities/executeInteraction.js +18 -0
- package/lib/esm/activities/executeInteraction.js.map +1 -1
- package/lib/esm/activities/executeRemoteActivity.js +104 -0
- package/lib/esm/activities/executeRemoteActivity.js.map +1 -0
- package/lib/esm/activities/getObjectFromStore.js +12 -1
- package/lib/esm/activities/getObjectFromStore.js.map +1 -1
- package/lib/esm/activities/index-dsl.js +2 -1
- package/lib/esm/activities/index-dsl.js.map +1 -1
- package/lib/esm/activities/resolveRemoteActivities.js +117 -0
- package/lib/esm/activities/resolveRemoteActivities.js.map +1 -0
- package/lib/esm/dsl/dsl-workflow.js +66 -6
- package/lib/esm/dsl/dsl-workflow.js.map +1 -1
- package/lib/esm/utils/storage.js +9 -9
- package/lib/esm/utils/storage.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/activities/chunkDocument.d.ts.map +1 -1
- package/lib/types/activities/executeInteraction.d.ts.map +1 -1
- package/lib/types/activities/executeRemoteActivity.d.ts +31 -0
- package/lib/types/activities/executeRemoteActivity.d.ts.map +1 -0
- package/lib/types/activities/getObjectFromStore.d.ts.map +1 -1
- package/lib/types/activities/index-dsl.d.ts +3 -1
- package/lib/types/activities/index-dsl.d.ts.map +1 -1
- package/lib/types/activities/resolveRemoteActivities.d.ts +32 -0
- package/lib/types/activities/resolveRemoteActivities.d.ts.map +1 -0
- package/lib/types/dsl/dsl-workflow.d.ts.map +1 -1
- package/lib/types/utils/storage.d.ts +2 -2
- package/lib/types/utils/storage.d.ts.map +1 -1
- package/lib/workflows-bundle.js +625 -274
- package/package.json +6 -6
- package/src/activities/chunkDocument.ts +1 -3
- package/src/activities/executeInteraction.ts +17 -0
- package/src/activities/executeRemoteActivity.test.ts +140 -0
- package/src/activities/executeRemoteActivity.ts +133 -0
- package/src/activities/getObjectFromStore.ts +11 -1
- package/src/activities/index-dsl.ts +3 -1
- package/src/activities/resolveRemoteActivities.test.ts +220 -0
- package/src/activities/resolveRemoteActivities.ts +167 -0
- package/src/dsl/dsl-workflow.ts +87 -7
- package/src/utils/storage.ts +9 -8
- package/lib/cjs/activities/copyParentArtifacts.js +0 -127
- package/lib/cjs/activities/copyParentArtifacts.js.map +0 -1
- package/lib/esm/activities/copyParentArtifacts.js +0 -124
- package/lib/esm/activities/copyParentArtifacts.js.map +0 -1
- package/lib/types/activities/copyParentArtifacts.d.ts +0 -19
- package/lib/types/activities/copyParentArtifacts.d.ts.map +0 -1
- package/src/activities/copyParentArtifacts.ts +0 -162
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { log, activityInfo } from "@temporalio/activity";
|
|
2
|
-
import { NodeStreamSource } from "@vertesia/client/node";
|
|
3
|
-
import { DSLActivityExecutionPayload, DSLActivitySpec } from "@vertesia/common";
|
|
4
|
-
import { Readable } from "stream";
|
|
5
|
-
import { setupActivity } from "../dsl/setup/ActivityContext.js";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Directories in the agent workspace to copy from parent to child.
|
|
9
|
-
*/
|
|
10
|
-
const WORKSPACE_DIRECTORIES = ['scripts', 'files', 'skills', 'docs', 'out'];
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Files that should never be copied (child has its own).
|
|
14
|
-
*/
|
|
15
|
-
const EXCLUDED_FILES = ['conversation.json', 'tools.json'];
|
|
16
|
-
|
|
17
|
-
export interface CopyParentArtifactsParams {
|
|
18
|
-
parent_run_id: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface CopyParentArtifacts extends DSLActivitySpec<CopyParentArtifactsParams> {
|
|
22
|
-
name: 'copyParentArtifacts';
|
|
23
|
-
projection?: never;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Copy workspace artifacts from parent workflow's agent space to current workflow's agent space.
|
|
28
|
-
*
|
|
29
|
-
* Copies: scripts/, files/, skills/, docs/, out/
|
|
30
|
-
* Excludes: conversation.json, tools.json
|
|
31
|
-
*/
|
|
32
|
-
export async function copyParentArtifacts(
|
|
33
|
-
payload: DSLActivityExecutionPayload<CopyParentArtifactsParams>
|
|
34
|
-
): Promise<{ copied: number; files: string[] }> {
|
|
35
|
-
const { client, params } = await setupActivity<CopyParentArtifactsParams>(payload);
|
|
36
|
-
const childRunId = activityInfo().workflowExecution.runId;
|
|
37
|
-
const parentRunId = params.parent_run_id;
|
|
38
|
-
|
|
39
|
-
log.info(`Copying artifacts from parent ${parentRunId} to child ${childRunId}`);
|
|
40
|
-
|
|
41
|
-
// List all files in parent's agent space
|
|
42
|
-
const parentFiles = await client.files.listArtifacts(parentRunId);
|
|
43
|
-
|
|
44
|
-
if (parentFiles.length === 0) {
|
|
45
|
-
log.info("No artifacts in parent agent space");
|
|
46
|
-
return { copied: 0, files: [] };
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const copiedFiles: string[] = [];
|
|
50
|
-
|
|
51
|
-
for (const fullPath of parentFiles) {
|
|
52
|
-
const relativePath = extractRelativePath(fullPath, parentRunId);
|
|
53
|
-
if (!relativePath) continue;
|
|
54
|
-
|
|
55
|
-
// Only copy workspace directories
|
|
56
|
-
const dir = relativePath.split('/')[0];
|
|
57
|
-
if (!WORKSPACE_DIRECTORIES.includes(dir)) continue;
|
|
58
|
-
|
|
59
|
-
// Skip excluded files
|
|
60
|
-
const fileName = relativePath.split('/').pop() || '';
|
|
61
|
-
if (EXCLUDED_FILES.includes(fileName)) continue;
|
|
62
|
-
|
|
63
|
-
try {
|
|
64
|
-
await copyArtifact(client, parentRunId, childRunId, relativePath);
|
|
65
|
-
copiedFiles.push(relativePath);
|
|
66
|
-
} catch (err: any) {
|
|
67
|
-
log.warn(`Failed to copy ${relativePath}: ${err.message}`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
log.info(`Copied ${copiedFiles.length} artifacts from parent`);
|
|
72
|
-
return { copied: copiedFiles.length, files: copiedFiles };
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Extract relative path from full artifact storage path.
|
|
77
|
-
* Storage paths can be: "store_xxx/agents/{runId}/..." or "agents/{runId}/..."
|
|
78
|
-
*/
|
|
79
|
-
function extractRelativePath(fullPath: string, runId: string): string | null {
|
|
80
|
-
// Look for the pattern: agents/{runId}/
|
|
81
|
-
const marker = `/agents/${runId}/`;
|
|
82
|
-
const idx = fullPath.lastIndexOf(marker);
|
|
83
|
-
if (idx >= 0) {
|
|
84
|
-
return fullPath.slice(idx + marker.length);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Also try without leading slash
|
|
88
|
-
const legacyPrefix = `agents/${runId}/`;
|
|
89
|
-
if (fullPath.startsWith(legacyPrefix)) {
|
|
90
|
-
return fullPath.slice(legacyPrefix.length);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// If path contains the runId, try to extract after it
|
|
94
|
-
const runIdIdx = fullPath.indexOf(runId);
|
|
95
|
-
if (runIdIdx >= 0) {
|
|
96
|
-
const afterRunId = fullPath.slice(runIdIdx + runId.length);
|
|
97
|
-
if (afterRunId.startsWith('/')) {
|
|
98
|
-
return afterRunId.slice(1);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return null;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Copy a single artifact from parent to child agent space
|
|
107
|
-
*/
|
|
108
|
-
async function copyArtifact(
|
|
109
|
-
client: any,
|
|
110
|
-
parentRunId: string,
|
|
111
|
-
childRunId: string,
|
|
112
|
-
relativePath: string
|
|
113
|
-
): Promise<void> {
|
|
114
|
-
// Download from parent's agent space
|
|
115
|
-
const stream = await client.files.downloadArtifact(parentRunId, relativePath);
|
|
116
|
-
|
|
117
|
-
// Convert web stream to node stream for upload
|
|
118
|
-
const nodeStream = Readable.fromWeb(stream as any);
|
|
119
|
-
|
|
120
|
-
// Determine mime type from extension
|
|
121
|
-
const mimeType = getMimeType(relativePath);
|
|
122
|
-
const fileName = relativePath.split('/').pop() || relativePath;
|
|
123
|
-
|
|
124
|
-
// Upload to child's agent space at the same relative path
|
|
125
|
-
const source = new NodeStreamSource(
|
|
126
|
-
nodeStream,
|
|
127
|
-
fileName,
|
|
128
|
-
mimeType
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
await client.files.uploadArtifact(childRunId, relativePath, source);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Get mime type from file extension
|
|
136
|
-
*/
|
|
137
|
-
function getMimeType(filePath: string): string {
|
|
138
|
-
const ext = filePath.split('.').pop()?.toLowerCase();
|
|
139
|
-
const mimeTypes: Record<string, string> = {
|
|
140
|
-
'json': 'application/json',
|
|
141
|
-
'txt': 'text/plain',
|
|
142
|
-
'md': 'text/markdown',
|
|
143
|
-
'html': 'text/html',
|
|
144
|
-
'csv': 'text/csv',
|
|
145
|
-
'png': 'image/png',
|
|
146
|
-
'jpg': 'image/jpeg',
|
|
147
|
-
'jpeg': 'image/jpeg',
|
|
148
|
-
'gif': 'image/gif',
|
|
149
|
-
'svg': 'image/svg+xml',
|
|
150
|
-
'pdf': 'application/pdf',
|
|
151
|
-
'xml': 'application/xml',
|
|
152
|
-
'zip': 'application/zip',
|
|
153
|
-
'js': 'application/javascript',
|
|
154
|
-
'ts': 'application/typescript',
|
|
155
|
-
'py': 'text/x-python',
|
|
156
|
-
'sh': 'text/x-shellscript',
|
|
157
|
-
'bash': 'text/x-shellscript',
|
|
158
|
-
'yaml': 'text/yaml',
|
|
159
|
-
'yml': 'text/yaml',
|
|
160
|
-
};
|
|
161
|
-
return mimeTypes[ext || ''] || 'application/octet-stream';
|
|
162
|
-
}
|