@peers-app/peers-device 0.15.4 → 0.16.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.
@@ -0,0 +1,411 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setDecryptData = setDecryptData;
4
+ exports.setUserHomeDirectory = setUserHomeDirectory;
5
+ exports.setSimilarToolsFn = setSimilarToolsFn;
6
+ exports.initializeWorkflowProcessor = initializeWorkflowProcessor;
7
+ exports.checkForWorkflowsToProcess = checkForWorkflowsToProcess;
8
+ exports.tryProcessingWorkflowRun = tryProcessingWorkflowRun;
9
+ const peers_sdk_1 = require("@peers-app/peers-sdk");
10
+ const lodash_1 = require("lodash");
11
+ const machine_stats_1 = require("./machine-stats");
12
+ const tool_loader_1 = require("./tool-loader");
13
+ // ---------------------------------------------------------------------------
14
+ // Injectable platform functions
15
+ // ---------------------------------------------------------------------------
16
+ let decryptData = async () => {
17
+ throw new Error("decryptData fn not set, call `setDecryptData` first");
18
+ };
19
+ /**
20
+ * Injects the decryption function used by {@link getVariable} when a
21
+ * persistent variable is marked as a secret. Must be called once during
22
+ * app initialisation before any workflow or tool accesses secret variables.
23
+ */
24
+ function setDecryptData(fn) {
25
+ decryptData = fn;
26
+ }
27
+ // TODO this returns Promise<string> but it should be a type of Promise<T>
28
+ async function getVariable(groupId, variableName, _requestingToolId) {
29
+ // TODO - add security for this. Show user a UI to approve this tool to access this variable
30
+ const userContext = await (0, peers_sdk_1.getUserContext)();
31
+ const dataContext = userContext.getDataContext(groupId);
32
+ const pvar = await (0, peers_sdk_1.getPersistentVar)(variableName, dataContext);
33
+ if (pvar?.isSecret && pvar?.value) {
34
+ const val = await decryptData(pvar.value.value, groupId);
35
+ return val;
36
+ }
37
+ return pvar?.value?.value || "";
38
+ }
39
+ let _getUserHomeDirectory;
40
+ /**
41
+ * Injects the function that returns the current user's home directory.
42
+ * Used as the default `currentWorkingDirectory` for new workflow runs.
43
+ * Must be called once during app initialisation.
44
+ */
45
+ function setUserHomeDirectory(fn) {
46
+ _getUserHomeDirectory = fn;
47
+ }
48
+ let _getSimilarTools;
49
+ /**
50
+ * Injects the embedding-based tool similarity function used when an
51
+ * assistant's {@link ToolInclusionStrategy} is `Relevant`. This is
52
+ * optional -- when unset, the "Relevant" strategy simply skips the
53
+ * similarity search.
54
+ */
55
+ function setSimilarToolsFn(fn) {
56
+ _getSimilarTools = fn;
57
+ }
58
+ // ---------------------------------------------------------------------------
59
+ // Processor state
60
+ // ---------------------------------------------------------------------------
61
+ let resolvedUserContext;
62
+ /**
63
+ * Sets up the WorkflowRuns change subscription and the 60-second polling
64
+ * interval. Pass a `UserContext` directly (e.g. in tests) or omit it to
65
+ * fall back to `getUserContext()`.
66
+ */
67
+ function initializeWorkflowProcessor(userContext) {
68
+ const ready = userContext ? Promise.resolve(userContext) : (0, peers_sdk_1.getUserContext)();
69
+ ready.then((uc) => {
70
+ resolvedUserContext = uc;
71
+ const dataContext = uc.defaultDataContext();
72
+ // TODO this whole subscription might be able to be removed
73
+ // rely on explicit calls to tryProcessingWorkflowRun and fallback to the interval check
74
+ uc.subscribeToDataChangedAcrossAllGroups((0, peers_sdk_1.WorkflowRuns)(dataContext), (evt) => {
75
+ if (evt.data.source === "local") {
76
+ tryProcessingWorkflowRun(evt.dataContext, evt.data.dataObject.workflowRunId);
77
+ }
78
+ });
79
+ setInterval(() => {
80
+ checkForWorkflowsToProcess();
81
+ }, 60000);
82
+ });
83
+ }
84
+ /** Scans for incomplete workflow runs and schedules them for processing. */
85
+ async function checkForWorkflowsToProcess() {
86
+ if (!resolvedUserContext)
87
+ return;
88
+ // TODO this should check across all groups, not just the currently active group
89
+ const dataContext = resolvedUserContext.defaultDataContext();
90
+ const workflowRuns = await (0, peers_sdk_1.WorkflowRuns)(dataContext).cursor({
91
+ completedAt: { $exists: false },
92
+ $and: [
93
+ {
94
+ $or: [{ inErrorState: { $exists: false } }, { inErrorState: false }],
95
+ },
96
+ ],
97
+ }, { pageSize: 1 });
98
+ for await (const workflowRun of workflowRuns) {
99
+ setTimeout(() => tryProcessingWorkflowRun(dataContext, workflowRun.workflowRunId), 0);
100
+ }
101
+ }
102
+ /** In-process exclusive processing per workflowRunId (no cross-device lock). */
103
+ const activeWorkflowRuns = new Set();
104
+ async function saveAndReleaseWorkflow(dataContext, workflowRun) {
105
+ await (0, peers_sdk_1.WorkflowRuns)(dataContext).save(workflowRun);
106
+ activeWorkflowRuns.delete(workflowRun.workflowRunId);
107
+ }
108
+ /**
109
+ * Attempts to process the next instruction for a workflow run. Applies
110
+ * CPU-based throttling, schedule gating, sub-workflow checks, and an
111
+ * in-process per-run lock before delegating to {@link processNextInstruction}.
112
+ */
113
+ async function tryProcessingWorkflowRun(dataContext, workflowRunId) {
114
+ const workflowRun = await (0, peers_sdk_1.WorkflowRuns)(dataContext).get(workflowRunId);
115
+ if (!workflowRun || workflowRun.inErrorState) {
116
+ return;
117
+ }
118
+ if (workflowRun.scheduleDT && workflowRun.scheduleDT > new Date()) {
119
+ const oneMinuteFromNow = new Date(Date.now() + 60000);
120
+ if (workflowRun.scheduleDT <= oneMinuteFromNow) {
121
+ const msUntilScheduled = workflowRun.scheduleDT.getTime() - Date.now();
122
+ setTimeout(() => tryProcessingWorkflowRun(dataContext, workflowRunId), msUntilScheduled);
123
+ }
124
+ return;
125
+ }
126
+ const _machineStats = (0, machine_stats_1.machineStats)();
127
+ if (workflowRun.completedAt || workflowRun.inErrorState) {
128
+ return;
129
+ }
130
+ const workflowRunsInProgress = activeWorkflowRuns.size;
131
+ // TODO Make this configurable
132
+ if ((_machineStats.cpu.average > 30 || _machineStats.cpu.max > 70) &&
133
+ workflowRunsInProgress > 2) {
134
+ return;
135
+ }
136
+ // TODO make this configurable
137
+ if (workflowRunsInProgress >= _machineStats.cpu.cpuCount) {
138
+ return;
139
+ }
140
+ if (activeWorkflowRuns.has(workflowRun.workflowRunId)) {
141
+ return;
142
+ }
143
+ activeWorkflowRuns.add(workflowRun.workflowRunId);
144
+ try {
145
+ const subWorkflowsPendingCnt = await (0, peers_sdk_1.WorkflowRuns)(dataContext).count({
146
+ parentWorkflowRunId: workflowRun.workflowRunId,
147
+ completedAt: { $exists: false },
148
+ });
149
+ if (subWorkflowsPendingCnt) {
150
+ return;
151
+ }
152
+ await processNextInstruction(dataContext, workflowRun);
153
+ }
154
+ catch (err) {
155
+ console.error(`Error processing workflow run: ${workflowRun.workflowRunId}`, err);
156
+ try {
157
+ workflowRun.inErrorState = true;
158
+ await (0, peers_sdk_1.WorkflowRuns)(dataContext).save(workflowRun);
159
+ }
160
+ catch (_) {
161
+ /* best-effort: lock releases in finally regardless */
162
+ }
163
+ }
164
+ finally {
165
+ activeWorkflowRuns.delete(workflowRun.workflowRunId);
166
+ }
167
+ }
168
+ async function processNextInstruction(dataContext, workflowRun) {
169
+ console.log("processNextInstruction", workflowRun.workflowRunId);
170
+ const nextInstruction = workflowRun.instructions[workflowRun.currentInstructionIndex];
171
+ workflowRun.instructionResults ??= [];
172
+ const contextId = (0, peers_sdk_1.newid)();
173
+ const logger = await (0, peers_sdk_1.getLogger)(workflowRun.workflowRunId, contextId);
174
+ if (!workflowRun.startedAt) {
175
+ workflowRun.startedAt = new Date();
176
+ }
177
+ if (!nextInstruction) {
178
+ workflowRun.completedAt = new Date();
179
+ await saveAndReleaseWorkflow(dataContext, workflowRun);
180
+ return checkForWorkflowsToProcess();
181
+ }
182
+ if (!_getUserHomeDirectory) {
183
+ throw new Error("setUserHomeDirectory must be called before processing workflows");
184
+ }
185
+ workflowRun.vars.currentWorkingDirectory ??= _getUserHomeDirectory();
186
+ if (nextInstruction.directCallToolId) {
187
+ let result = null;
188
+ let isError = false;
189
+ let tool;
190
+ try {
191
+ tool = await (0, peers_sdk_1.Tools)(dataContext).get(nextInstruction.directCallToolId);
192
+ if (!tool) {
193
+ throw new Error(`Tool not found: ${nextInstruction.directCallToolId}`);
194
+ }
195
+ const defaultToolId = tool.toolId;
196
+ const args = gatherArgs(dataContext, workflowRun, tool.inputSchema);
197
+ const context = {
198
+ contextId,
199
+ dataContextId: dataContext.dataContextId,
200
+ workflowRun,
201
+ logger,
202
+ getAssistantRunnerArgs: async (assistantId) => getAssistantRunnerArgs(dataContext, assistantId, workflowRun),
203
+ getAvailableTools: async (args, similarityText) => getAvailableTools(args, context, similarityText),
204
+ getVariable: async (variableName, toolId) => {
205
+ const groupId = dataContext.groupId || dataContext.userContext.userId;
206
+ // TODO rethink how this works - the idea is to make it so the user knows and has control over what code is accessing what variables
207
+ return getVariable(groupId, variableName, toolId || defaultToolId);
208
+ },
209
+ };
210
+ const toolInstance = await (0, tool_loader_1.initWrappedTool)(tool, context);
211
+ result = await toolInstance.toolFn(args);
212
+ workflowRun.currentInstructionIndex++;
213
+ }
214
+ catch (err) {
215
+ isError = true;
216
+ const toolMention = (0, peers_sdk_1.formatMention)({
217
+ kind: "tool",
218
+ id: nextInstruction.directCallToolId,
219
+ name: tool?.name ?? nextInstruction.directCallToolId,
220
+ });
221
+ result = `Error running tool: ${toolMention}: ${err}`;
222
+ await logger({ logText: result, isError: true, instruction: nextInstruction });
223
+ }
224
+ workflowRun.instructionResults.push(result);
225
+ if (isError) {
226
+ workflowRun.inErrorState = true;
227
+ }
228
+ }
229
+ else {
230
+ const markdown = nextInstruction.markdown ?? "";
231
+ if (markdown) {
232
+ const assistantsMentioned = await (0, peers_sdk_1.getAllAssistantIdsMentioned)(markdown);
233
+ let assistantToUse;
234
+ while (!assistantToUse && assistantsMentioned.length) {
235
+ const assistantId = assistantsMentioned.shift();
236
+ if (!assistantId)
237
+ break;
238
+ assistantToUse = await (0, peers_sdk_1.Assistants)(dataContext).get(assistantId);
239
+ }
240
+ if (!assistantToUse) {
241
+ const assistantId = getWorkflowVarValue(workflowRun, "assistantId");
242
+ assistantToUse = await (0, peers_sdk_1.Assistants)(dataContext).get(assistantId);
243
+ }
244
+ if (!assistantToUse) {
245
+ workflowRun.inErrorState = true;
246
+ workflowRun.instructionResults.push(`no assistant found to process next instruction`);
247
+ }
248
+ else {
249
+ const assistantMention = (0, peers_sdk_1.formatMention)({
250
+ kind: "assistant",
251
+ id: assistantToUse.assistantId,
252
+ name: assistantToUse.name,
253
+ });
254
+ workflowRun.instructionResults.push(`instruction sent to assistant: ${assistantMention}`);
255
+ workflowRun.currentInstructionIndex++;
256
+ workflowRun.instructions.splice(workflowRun.currentInstructionIndex, 0, {
257
+ directCallToolId: assistantToUse.assistantRunnerToolId,
258
+ markdown: markdown,
259
+ });
260
+ workflowRun.vars.assistantId = assistantToUse.assistantId;
261
+ }
262
+ }
263
+ }
264
+ if (workflowRun.inErrorState) {
265
+ await saveAndReleaseWorkflow(dataContext, workflowRun);
266
+ // TODO const mentionRun = formatMention({ kind: 'workflowrun', id: workflowRun.workflowRunId, name: `Workflow Run` });
267
+ const mentionRun = `<todo:link-to-workflow-run:${workflowRun.workflowRunId}>`;
268
+ const error = workflowRun.instructionResults[workflowRun.instructionResults.length - 1];
269
+ await (0, peers_sdk_1.sendMessage)({
270
+ channelOrThreadIdOrWorkflowRunId: workflowRun.parentMessageId,
271
+ messageContent: `Workflow run ${mentionRun} is in error state: ${error}`,
272
+ assistantId: workflowRun.defaultAssistantId,
273
+ });
274
+ return checkForWorkflowsToProcess();
275
+ }
276
+ else if (workflowRun.currentInstructionIndex < workflowRun.instructions.length) {
277
+ await (0, peers_sdk_1.WorkflowRuns)(dataContext).save(workflowRun);
278
+ setTimeout(() => tryProcessingWorkflowRun(dataContext, workflowRun.workflowRunId), 0);
279
+ }
280
+ else {
281
+ workflowRun.completedAt = new Date();
282
+ await saveAndReleaseWorkflow(dataContext, workflowRun);
283
+ if (!workflowRun.parentWorkflowRunId) {
284
+ const assistantId = getWorkflowVarValue(workflowRun, "assistantId");
285
+ let messageContent = (0, lodash_1.last)(workflowRun.instructionResults);
286
+ if (typeof messageContent !== "string") {
287
+ if ((0, lodash_1.isObject)(messageContent)) {
288
+ messageContent = `\`\`\`\n${JSON.stringify(messageContent, null, 2)}\n\`\`\``;
289
+ }
290
+ else {
291
+ messageContent = String(messageContent);
292
+ }
293
+ }
294
+ const parentMessage = await (0, peers_sdk_1.Messages)(dataContext).get(workflowRun.parentMessageId);
295
+ if (parentMessage) {
296
+ const oldVars = await (0, peers_sdk_1.getThreadVars)(parentMessage);
297
+ const newVars = { ...oldVars, ...workflowRun.vars };
298
+ if (!(0, lodash_1.isEqual)(oldVars, newVars)) {
299
+ parentMessage.vars = newVars;
300
+ await (0, peers_sdk_1.Messages)(dataContext).save(parentMessage);
301
+ }
302
+ }
303
+ // TODO don't send a message if the last tool call was to send a message
304
+ await (0, peers_sdk_1.sendMessage)({
305
+ channelOrThreadIdOrWorkflowRunId: workflowRun.parentMessageId,
306
+ assistantId,
307
+ messageContent,
308
+ });
309
+ }
310
+ return checkForWorkflowsToProcess();
311
+ }
312
+ }
313
+ function gatherArgs(dataContext, workflowRun, ioSchema) {
314
+ const args = {};
315
+ for (const field of ioSchema.fields) {
316
+ args[field.name] = getWorkflowVarValue(workflowRun, field.name, dataContext);
317
+ }
318
+ const zodSchema = (0, peers_sdk_1.fieldsToSchema)(ioSchema.fields);
319
+ // TODO deal with errors from this (start sub workflow to gather args from user?)
320
+ return zodSchema.parse(args);
321
+ }
322
+ function getWorkflowVarValue(workflowRun, name, dataContext) {
323
+ const instruction = workflowRun.instructions[workflowRun.currentInstructionIndex];
324
+ let value;
325
+ let _var = workflowRun.vars[name];
326
+ if (_var === undefined) {
327
+ if (name === "workflowRunId")
328
+ _var = workflowRun.workflowRunId;
329
+ if (name === "dataContextId")
330
+ _var = dataContext?.dataContextId;
331
+ if (name === "assistantId")
332
+ _var = workflowRun.defaultAssistantId;
333
+ if (name === "messageContent")
334
+ _var = instruction?.markdown;
335
+ }
336
+ if (_var !== undefined) {
337
+ if (_var?.instructionVariableType === "reference") {
338
+ if (_var.source === "lastOutput") {
339
+ value = workflowRun.instructionResults[workflowRun.instructionResults.length - 1];
340
+ }
341
+ else {
342
+ throw new Error(`Unknown instructionVariableType: ${_var.instructionVariableType}`);
343
+ }
344
+ }
345
+ else {
346
+ value = _var;
347
+ }
348
+ }
349
+ return value;
350
+ }
351
+ async function getAssistantRunnerArgs(dataContext, assistantId, workflowRun) {
352
+ const assistant = await (0, peers_sdk_1.Assistants)(dataContext).get(assistantId);
353
+ const messageId = workflowRun.parentMessageId;
354
+ const message = await (0, peers_sdk_1.Messages)(dataContext).get(messageId);
355
+ if (!assistant) {
356
+ throw new Error(`Assistant with id ${assistantId} not found`);
357
+ }
358
+ if (!message) {
359
+ throw new Error(`Message with id ${messageId} not found`);
360
+ }
361
+ let threadHistory = [];
362
+ if (message.messageParentId) {
363
+ threadHistory = await (0, peers_sdk_1.Messages)(dataContext).list({
364
+ messageParentId: message.messageParentId,
365
+ messageId: { $ne: message.messageId },
366
+ }, {
367
+ sortBy: ["createdAt"],
368
+ });
369
+ const parent = await (0, peers_sdk_1.Messages)(dataContext).get(message.messageParentId);
370
+ if (parent) {
371
+ threadHistory.unshift(parent);
372
+ }
373
+ }
374
+ const messageLogs = await (0, peers_sdk_1.WorkflowLogs)(dataContext).list({
375
+ workflowRunId: workflowRun.workflowRunId,
376
+ });
377
+ const args = {
378
+ assistant,
379
+ message,
380
+ threadHistory: Object.freeze(threadHistory),
381
+ messageLogs: Object.freeze(messageLogs),
382
+ };
383
+ return args;
384
+ }
385
+ async function getAvailableTools(args, context, similarityText = "") {
386
+ const { assistant, threadHistory } = args;
387
+ // TODO - it might be better to reverse this and have the newest messages first. Should be looked into.
388
+ const messageHistoryStr = threadHistory.map((m) => m.message).join("\n\n\n");
389
+ const logsStr = args.messageLogs.map((log) => log.logText).join("\n\n\n");
390
+ let toolContextStr = `${messageHistoryStr}\n\n\n${logsStr}\n\n\n${similarityText}`;
391
+ toolContextStr = toolContextStr.trim();
392
+ /* Fixed */
393
+ let toolsToLoad = await (0, tool_loader_1.getLinkedTools)(assistant.toolsToInclude);
394
+ /* Linked */
395
+ if (assistant.toolInclusionStrategy !== peers_sdk_1.ToolInclusionStrategy.Fixed) {
396
+ const linkedTools = await (0, tool_loader_1.getLinkedTools)(toolContextStr);
397
+ toolsToLoad.push(...linkedTools);
398
+ }
399
+ /* Relevant */
400
+ if (assistant.toolInclusionStrategy === peers_sdk_1.ToolInclusionStrategy.Relevant && _getSimilarTools) {
401
+ const similarTools = await _getSimilarTools({
402
+ context,
403
+ text: toolContextStr,
404
+ });
405
+ toolsToLoad.push(...similarTools);
406
+ }
407
+ toolsToLoad = (0, lodash_1.uniqBy)(toolsToLoad, "toolId");
408
+ const agentTools = await Promise.all(toolsToLoad.map((tool) => (0, tool_loader_1.initWrappedTool)(tool, context)));
409
+ return agentTools;
410
+ }
411
+ //# sourceMappingURL=workflow-processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-processor.js","sourceRoot":"","sources":["../src/workflow-processor.ts"],"names":[],"mappings":";;AA4CA,wCAEC;AA0BD,oDAEC;AAiBD,8CAEC;AAaD,kEAkBC;AAGD,gEAkBC;AAeD,4DA8DC;AA9ND,oDA0B8B;AAC9B,mCAAyD;AACzD,mDAA+C;AAC/C,+CAAgE;AAEhE,8EAA8E;AAC9E,gCAAgC;AAChC,8EAA8E;AAE9E,IAAI,WAAW,GAAqD,KAAK,IAAI,EAAE;IAC7E,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;AACzE,CAAC,CAAC;AAEF;;;;GAIG;AACH,SAAgB,cAAc,CAAC,EAAoD;IACjF,WAAW,GAAG,EAAE,CAAC;AACnB,CAAC;AAED,0EAA0E;AAC1E,KAAK,UAAU,WAAW,CACxB,OAAe,EACf,YAAoB,EACpB,iBAAyB;IAEzB,6FAA6F;IAC7F,MAAM,WAAW,GAAG,MAAM,IAAA,0BAAc,GAAE,CAAC;IAC3C,MAAM,WAAW,GAAG,WAAW,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACxD,MAAM,IAAI,GAAG,MAAM,IAAA,4BAAgB,EAAC,YAAY,EAAE,WAAW,CAA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AC;IAED,WAAW,GAAG,IAAA,eAAM,EAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAE5C,MAAM,UAAU,GAAoB,MAAM,OAAO,CAAC,GAAG,CACnD,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,6BAAe,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAC1D,CAAC;IAEF,OAAO,UAAU,CAAC;AACpB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Integration + unit tests for workflow-processor.ts
3
+ *
4
+ * Uses in-memory SQLite (via peers-device DBLocal) for real WorkflowRuns table
5
+ * operations. Heavy external dependencies (tool-loader, machineStats, etc.) are
6
+ * mocked so tests exercise the lock, gating, continuation, and error logic in
7
+ * isolation.
8
+ *
9
+ * The module no longer has a side effect on import — initializeWorkflowProcessor()
10
+ * is never called in tests. Tests call tryProcessingWorkflowRun directly with an
11
+ * explicit DataContext backed by in-memory SQLite.
12
+ */
13
+ export {};