@opengeni/worker-bundle 0.29.0-canary.0 → 0.29.0-canary.2
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/activities/agent-turn/knowledge-source-tools.d.ts +9 -0
- package/dist/activities/agent-turn/knowledge-sources.d.ts +20 -0
- package/dist/activities/agent-turn/stream-attempt.d.ts +1 -0
- package/dist/activities/agent-turn/tool-environment.d.ts +1 -0
- package/dist/activities/knowledge-indexing.d.ts +10 -0
- package/dist/activities/run-input.d.ts +1 -0
- package/dist/activities/types.d.ts +10 -3
- package/dist/{activities-control-MKGEOBXT.js → activities-control-HMFGSKC5.js} +331 -3381
- package/dist/activities-control-HMFGSKC5.js.map +1 -0
- package/dist/activities-control.d.ts +12 -0
- package/dist/{activities-turn-5MZZ6HQA.js → activities-turn-AP67JADS.js} +1296 -1021
- package/dist/activities-turn-AP67JADS.js.map +1 -0
- package/dist/activities.d.ts +12 -0
- package/dist/{chunk-OA5CSY5N.js → chunk-CYITU5UH.js} +3348 -174
- package/dist/chunk-CYITU5UH.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +48 -1
- package/dist/index.js.map +1 -1
- package/dist/workflow-bundle.js +65 -35
- package/dist/workflows/knowledge-indexing.d.ts +2 -0
- package/dist/workflows.d.ts +1 -0
- package/package.json +19 -18
- package/src/activities/agent-turn/knowledge-source-tools.ts +98 -0
- package/src/activities/agent-turn/knowledge-sources.ts +86 -0
- package/src/activities/agent-turn/run.ts +1244 -1112
- package/src/activities/agent-turn/skill-install.ts +1 -1
- package/src/activities/agent-turn/skill-save.ts +1 -1
- package/src/activities/agent-turn/skill-selection.ts +2 -0
- package/src/activities/agent-turn/skill-tools.ts +5 -12
- package/src/activities/agent-turn/stream-attempt.ts +3 -0
- package/src/activities/agent-turn/tool-environment.ts +24 -0
- package/src/activities/codex-image-generation.ts +1 -2
- package/src/activities/documents.ts +17 -52
- package/src/activities/knowledge-indexing.ts +130 -0
- package/src/activities/knowledge-source-sync.ts +120 -16
- package/src/activities/mcp-credentials.ts +2 -0
- package/src/activities/run-input.ts +2 -0
- package/src/activities/scheduled-tasks.ts +25 -62
- package/src/activities/types.ts +8 -2
- package/src/activities/video-generation-reconciliation.ts +8 -1
- package/src/activities-control.ts +2 -0
- package/src/activities.ts +1 -0
- package/src/index.ts +49 -0
- package/src/pr-review-credentials.ts +2 -2
- package/src/workflows/knowledge-indexing.ts +12 -0
- package/src/workflows.ts +1 -0
- package/dist/activities-control-MKGEOBXT.js.map +0 -1
- package/dist/activities-turn-5MZZ6HQA.js.map +0 -1
- package/dist/chunk-OA5CSY5N.js.map +0 -1
package/dist/workflows.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { knowledgeIndexingWorkflow } from "./workflows/knowledge-indexing.js";
|
|
1
2
|
export { documentIndexWorkflow, type DocumentIndexWorkflowInput } from "./workflows/document-index.js";
|
|
2
3
|
export { approvalDecision, codexCapacityChanged, sessionControl, sessionAttemptQuiesced, queueChanged, sessionWorkflow, userMessage, type SessionWorkflowInput, } from "./workflows/session.js";
|
|
3
4
|
export { scheduledTaskFireWorkflow, type ScheduledTaskFireWorkflowInput, } from "./workflows/scheduled-tasks.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeni/worker-bundle",
|
|
3
|
-
"version": "0.29.0-canary.
|
|
3
|
+
"version": "0.29.0-canary.2",
|
|
4
4
|
"description": "OpenGeni worker entry and reusable embedded lifecycle, shipped with a release-coherent pre-bundled Temporal workflow artifact.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -54,23 +54,24 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@llamaindex/liteparse": "2.14.2",
|
|
57
|
-
"@opengeni/agent-proto": "^0.6.0-canary.
|
|
58
|
-
"@opengeni/capabilities": "^0.3.3-canary.
|
|
59
|
-
"@opengeni/codemode": "^0.5.7-canary.
|
|
60
|
-
"@opengeni/codex": "^0.2.22-canary.
|
|
61
|
-
"@opengeni/config": "^1.2.0-canary.
|
|
62
|
-
"@opengeni/contracts": "^3.1.0-canary.
|
|
63
|
-
"@opengeni/core": "^2.10.0-canary.
|
|
64
|
-
"@opengeni/db": "^4.4.0-canary.
|
|
65
|
-
"@opengeni/documents": "^0.8.28-canary.
|
|
66
|
-
"@opengeni/events": "^0.4.26-canary.
|
|
67
|
-
"@opengeni/github": "^0.7.11-canary.
|
|
68
|
-
"@opengeni/network": "^0.3.1-canary.
|
|
69
|
-
"@opengeni/observability": "^0.8.27-canary.
|
|
70
|
-
"@opengeni/runtime": "^2.6.0-canary.
|
|
71
|
-
"@opengeni/
|
|
72
|
-
"@opengeni/
|
|
73
|
-
"@opengeni/
|
|
57
|
+
"@opengeni/agent-proto": "^0.6.0-canary.2",
|
|
58
|
+
"@opengeni/capabilities": "^0.3.3-canary.14",
|
|
59
|
+
"@opengeni/codemode": "^0.5.7-canary.2",
|
|
60
|
+
"@opengeni/codex": "^0.2.22-canary.14",
|
|
61
|
+
"@opengeni/config": "^1.2.0-canary.2",
|
|
62
|
+
"@opengeni/contracts": "^3.1.0-canary.2",
|
|
63
|
+
"@opengeni/core": "^2.10.0-canary.2",
|
|
64
|
+
"@opengeni/db": "^4.4.0-canary.2",
|
|
65
|
+
"@opengeni/documents": "^0.8.28-canary.2",
|
|
66
|
+
"@opengeni/events": "^0.4.26-canary.2",
|
|
67
|
+
"@opengeni/github": "^0.7.11-canary.2",
|
|
68
|
+
"@opengeni/network": "^0.3.1-canary.14",
|
|
69
|
+
"@opengeni/observability": "^0.8.27-canary.2",
|
|
70
|
+
"@opengeni/runtime": "^2.6.0-canary.2",
|
|
71
|
+
"@opengeni/sdk": "^5.1.0-canary.2",
|
|
72
|
+
"@opengeni/storage": "^0.2.128-canary.2",
|
|
73
|
+
"@opengeni/tool-gateway": "^0.1.8-canary.2",
|
|
74
|
+
"@opengeni/xai-subscription": "^0.1.4-canary.14",
|
|
74
75
|
"@temporalio/activity": "^1.17.0",
|
|
75
76
|
"@temporalio/client": "^1.17.0",
|
|
76
77
|
"@temporalio/worker": "^1.17.0",
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { AttemptToolDefinition } from "@opengeni/codemode";
|
|
2
|
+
import {
|
|
3
|
+
freezeAgentLearningPolicy,
|
|
4
|
+
getScheduledTaskRunAcceptedExecution,
|
|
5
|
+
readScheduledKnowledgeSource,
|
|
6
|
+
type Database,
|
|
7
|
+
type KnowledgeContext,
|
|
8
|
+
} from "@opengeni/db";
|
|
9
|
+
import type { RunKnowledgeSourceSyncBatchInput, RunKnowledgeSourceSyncBatchResult } from "../types";
|
|
10
|
+
|
|
11
|
+
/** This tool exists only in an ordinary run with a frozen connector selection. */
|
|
12
|
+
export async function createKnowledgeSourceAttemptTools(input: {
|
|
13
|
+
db: Database;
|
|
14
|
+
context: KnowledgeContext;
|
|
15
|
+
fetch: (input: RunKnowledgeSourceSyncBatchInput) => Promise<RunKnowledgeSourceSyncBatchResult>;
|
|
16
|
+
}): Promise<AttemptToolDefinition[]> {
|
|
17
|
+
if (input.context.actor.kind !== "agent") return [];
|
|
18
|
+
const policy = await freezeAgentLearningPolicy(input.db, input.context);
|
|
19
|
+
if (typeof policy.scheduledTaskRunId !== "string") return [];
|
|
20
|
+
const runId = policy.scheduledTaskRunId;
|
|
21
|
+
const accepted = await getScheduledTaskRunAcceptedExecution(input.db, {
|
|
22
|
+
workspaceId: input.context.workspaceId,
|
|
23
|
+
runId,
|
|
24
|
+
});
|
|
25
|
+
const source = accepted?.task.agentConfig.knowledgeSource;
|
|
26
|
+
if (!accepted || !source || accepted.task.action.kind !== "agent_turn") return [];
|
|
27
|
+
const actor = input.context.actor;
|
|
28
|
+
const authorize = async () => {
|
|
29
|
+
const current = await freezeAgentLearningPolicy(input.db, input.context);
|
|
30
|
+
if (current.scheduledTaskRunId !== runId) throw new Error("Source run authority changed");
|
|
31
|
+
};
|
|
32
|
+
const definition = (
|
|
33
|
+
name: string,
|
|
34
|
+
title: string,
|
|
35
|
+
description: string,
|
|
36
|
+
inputSchema: AttemptToolDefinition["inputSchema"],
|
|
37
|
+
execute: (args: Record<string, unknown>) => Promise<unknown>,
|
|
38
|
+
readOnly: boolean,
|
|
39
|
+
): AttemptToolDefinition => ({
|
|
40
|
+
identity: { serverId: "opengeni", toolName: name },
|
|
41
|
+
modelName: name,
|
|
42
|
+
codemodePath: ["opengeni", name],
|
|
43
|
+
title,
|
|
44
|
+
description,
|
|
45
|
+
inputSchema,
|
|
46
|
+
annotations: {
|
|
47
|
+
title,
|
|
48
|
+
readOnlyHint: readOnly,
|
|
49
|
+
destructiveHint: false,
|
|
50
|
+
idempotentHint: true,
|
|
51
|
+
openWorldHint: !readOnly,
|
|
52
|
+
},
|
|
53
|
+
source: "opengeni",
|
|
54
|
+
approval: "none",
|
|
55
|
+
execute: async (args) => {
|
|
56
|
+
await authorize();
|
|
57
|
+
const output = await execute(args);
|
|
58
|
+
return { isError: false, content: [{ type: "text", text: JSON.stringify(output) }] };
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
return [
|
|
62
|
+
definition(
|
|
63
|
+
"knowledge_source_fetch",
|
|
64
|
+
"Fetch selected source",
|
|
65
|
+
"Fetch a checkpointed batch from this scheduled task's selected source. Retains original files and searchable source content under the run's Knowledge policy. It does not create findings. Use knowledge_source_read to inspect content, then knowledge_save for useful findings with evidence. Call again if action is continue. Review first stages content without interrupting this task; Off keeps Knowledge disabled.",
|
|
66
|
+
{ type: "object", properties: {}, additionalProperties: false },
|
|
67
|
+
async () =>
|
|
68
|
+
(await freezeAgentLearningPolicy(input.db, input.context)).effective.knowledge === "off"
|
|
69
|
+
? { action: "disabled", reason: "Knowledge is Off for this run" }
|
|
70
|
+
: input.fetch({
|
|
71
|
+
accountId: input.context.accountId,
|
|
72
|
+
workspaceId: input.context.workspaceId,
|
|
73
|
+
taskId: accepted.task.id,
|
|
74
|
+
scheduledTaskRunId: runId,
|
|
75
|
+
sourceId: source.sourceId,
|
|
76
|
+
overlapPolicy: accepted.task.overlapPolicy === "skip" ? "skip" : "buffer_one",
|
|
77
|
+
agent: actor,
|
|
78
|
+
}),
|
|
79
|
+
false,
|
|
80
|
+
),
|
|
81
|
+
definition(
|
|
82
|
+
"knowledge_source_read",
|
|
83
|
+
"Read selected source content",
|
|
84
|
+
"List source entries retained or updated in this run. Pass entryId to read up to 16,000 characters, following nextOffset for more. Follow nextCursor with afterId for subsequent list pages. Includes this run's pending source content so you can prepare findings in the same review batch; pending knowledge stays out of ordinary search. Use entryId and revisionId as evidence when saving findings.",
|
|
85
|
+
{
|
|
86
|
+
type: "object",
|
|
87
|
+
properties: {
|
|
88
|
+
entryId: { type: "string", format: "uuid" },
|
|
89
|
+
afterId: { type: "string", format: "uuid" },
|
|
90
|
+
offset: { type: "integer", minimum: 0, maximum: 100000000 },
|
|
91
|
+
},
|
|
92
|
+
additionalProperties: false,
|
|
93
|
+
},
|
|
94
|
+
async (args) => readScheduledKnowledgeSource(input.db, input.context, args),
|
|
95
|
+
true,
|
|
96
|
+
),
|
|
97
|
+
];
|
|
98
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
}
|