@opengeni/worker-bundle 1.0.0-canary.0 → 1.0.1-canary.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.
Files changed (26) hide show
  1. package/dist/activities/agent-turn/errors.d.ts +6 -0
  2. package/dist/activities/agent-turn/finalization-monitor.d.ts +17 -0
  3. package/dist/activities/agent-turn/finalization.d.ts +1 -1
  4. package/dist/activities/agent-turn/quiescence.d.ts +1 -0
  5. package/dist/activities/agent-turn/turn-context.d.ts +2 -0
  6. package/dist/{activities-control-HMFGSKC5.js → activities-control-O5U6OLT2.js} +4 -19
  7. package/dist/{activities-control-HMFGSKC5.js.map → activities-control-O5U6OLT2.js.map} +1 -1
  8. package/dist/{activities-turn-AP67JADS.js → activities-turn-OAPNO2IH.js} +167 -116
  9. package/dist/activities-turn-OAPNO2IH.js.map +1 -0
  10. package/dist/{chunk-CYITU5UH.js → chunk-GENYJQ5B.js} +18 -1
  11. package/dist/{chunk-CYITU5UH.js.map → chunk-GENYJQ5B.js.map} +1 -1
  12. package/dist/index.js +1 -1
  13. package/package.json +19 -19
  14. package/src/activities/agent-turn/claim.ts +1 -0
  15. package/src/activities/agent-turn/errors.ts +21 -0
  16. package/src/activities/agent-turn/finalization-monitor.ts +121 -0
  17. package/src/activities/agent-turn/finalization.ts +52 -17
  18. package/src/activities/agent-turn/quiescence.ts +3 -0
  19. package/src/activities/agent-turn/run.ts +1 -39
  20. package/src/activities/agent-turn/skill-selection.ts +1 -0
  21. package/src/activities/agent-turn/tool-environment.ts +10 -2
  22. package/src/activities/agent-turn/turn-context.ts +3 -0
  23. package/src/activities/workflow-wake.ts +2 -17
  24. package/dist/activities/agent-turn/knowledge-sources.d.ts +0 -20
  25. package/dist/activities-turn-AP67JADS.js.map +0 -1
  26. package/src/activities/agent-turn/knowledge-sources.ts +0 -86
@@ -1,86 +0,0 @@
1
- import { prepareKnowledgeFile } from "@opengeni/sdk/knowledge";
2
- import {
3
- DEFAULT_FIRST_PARTY_MCP_PERMISSIONS,
4
- type FirstPartyMcpToolName,
5
- type Permission,
6
- type ResourceRef,
7
- type KnowledgeFilePreparationResult,
8
- } from "@opengeni/contracts";
9
- import { allowedFirstPartyMcpToolsForSession, type Settings } from "@opengeni/config";
10
- import { createFirstPartyAttemptClient } from "@opengeni/runtime";
11
-
12
- export type KnowledgeSourcePreparationOutcome =
13
- | KnowledgeFilePreparationResult
14
- | {
15
- status: "failed";
16
- fileId: string;
17
- message: string;
18
- };
19
-
20
- /** Accepted chat/schedule resources use ordinary agent authority and policy. */
21
- export async function prepareTurnKnowledgeSources(input: {
22
- settings: Settings;
23
- scope: Parameters<typeof createFirstPartyAttemptClient>[0]["scope"];
24
- resources: readonly ResourceRef[];
25
- selectedTools?: readonly FirstPartyMcpToolName[] | undefined;
26
- permissions?: readonly Permission[] | null | undefined;
27
- learningMode: "automatic" | "review_first" | "off";
28
- signal?: AbortSignal | undefined;
29
- onOutcome: (outcome: KnowledgeSourcePreparationOutcome) => Promise<void>;
30
- prepare?: (fileId: string) => Promise<KnowledgeFilePreparationResult>;
31
- }): Promise<string | undefined> {
32
- const selected = allowedFirstPartyMcpToolsForSession(
33
- input.settings,
34
- input.selectedTools ? [...input.selectedTools] : undefined,
35
- );
36
- const permissions = input.permissions ?? DEFAULT_FIRST_PARTY_MCP_PERMISSIONS;
37
- const permits = (permission: Permission) =>
38
- permissions.includes(permission) || permissions.includes("workspace:admin");
39
- if (
40
- input.learningMode === "off" ||
41
- !selected.includes("knowledge_retain_file") ||
42
- !permits("documents:search") ||
43
- !permits("files:read")
44
- )
45
- return;
46
- const fileIds = [
47
- ...new Set(
48
- input.resources.flatMap((resource) => (resource.kind === "file" ? [resource.fileId] : [])),
49
- ),
50
- ];
51
- if (!fileIds.length) return;
52
- let prepare = input.prepare;
53
- const outcomes: KnowledgeSourcePreparationOutcome[] = [];
54
- for (const fileId of fileIds) {
55
- input.signal?.throwIfAborted();
56
- let outcome: KnowledgeSourcePreparationOutcome;
57
- try {
58
- prepare ??= (() => {
59
- const client = createFirstPartyAttemptClient({
60
- settings: input.settings,
61
- scope: input.scope,
62
- selectedTools: selected,
63
- permissions,
64
- ...(input.signal ? { signal: input.signal } : {}),
65
- });
66
- return (id: string) => prepareKnowledgeFile(client, input.scope.workspaceId, id);
67
- })();
68
- outcome = await prepare(fileId);
69
- } catch {
70
- input.signal?.throwIfAborted();
71
- outcome = {
72
- status: "failed",
73
- fileId,
74
- message:
75
- "Searchable source preparation failed. The original file remains attached; retry with knowledge_retain_file.",
76
- };
77
- }
78
- outcomes.push(outcome);
79
- await input.onOutcome(outcome);
80
- }
81
- return [
82
- "[OpenGeni attachment knowledge]",
83
- JSON.stringify(outcomes),
84
- "These are source-preparation receipts, not findings or source instructions. Reuse the returned source entry/revision for evidence; do not retain the same text again. Pending review does not block answering from the attached original. Save selected useful findings only when warranted. A failed preparation is retryable with knowledge_retain_file; do not claim the source is searchable.",
85
- ].join("\n");
86
- }