@opengeni/worker-bundle 1.0.1 → 2.0.0-canary.35585322809001
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/codex.d.ts +1 -1
- package/dist/activities/agent-turn/compaction-prep.d.ts +1 -5
- package/dist/activities/agent-turn/errors.d.ts +31 -5
- package/dist/activities/agent-turn/finalization-monitor.d.ts +17 -0
- package/dist/activities/agent-turn/finalization.d.ts +1 -1
- package/dist/activities/agent-turn/governance-model.d.ts +0 -2
- package/dist/activities/agent-turn/quiescence.d.ts +1 -0
- package/dist/activities/agent-turn/recovery-warning.d.ts +8 -0
- package/dist/activities/agent-turn/run-credentials.d.ts +0 -1
- package/dist/activities/agent-turn/sandbox-establish.d.ts +1 -1
- package/dist/activities/agent-turn/sandbox-route.d.ts +0 -20
- package/dist/activities/agent-turn/sandbox-runtime.d.ts +1 -1
- package/dist/activities/agent-turn/skill-remove.d.ts +14 -0
- package/dist/activities/agent-turn/skill-search.d.ts +1 -1
- package/dist/activities/agent-turn/stream-attempt.d.ts +1 -0
- package/dist/activities/agent-turn/tool-environment.d.ts +0 -4
- package/dist/activities/agent-turn/turn-context.d.ts +2 -0
- package/dist/activities/agent-turn/turn-sandbox-access.d.ts +3 -0
- package/dist/activities/codex-capacity.d.ts +6 -1
- package/dist/activities/codex-rotation.d.ts +1 -1
- package/dist/activities/context-compaction.d.ts +7 -1
- package/dist/activities/mcp-account-routes.d.ts +22 -0
- package/dist/activities/mcp-credentials.d.ts +12 -13
- package/dist/activities/mcp-operation-authority.d.ts +0 -5
- package/dist/activities/rig-verification.d.ts +2 -3
- package/dist/activities/sandbox-images.d.ts +1 -1
- package/dist/activities/sandbox-lease.d.ts +4 -3
- package/dist/activities/session-state.d.ts +57 -2
- package/dist/activities/types.d.ts +12 -3
- package/dist/{activities-control-HMFGSKC5.js → activities-control-BOLIY3H4.js} +366 -187
- package/dist/activities-control-BOLIY3H4.js.map +1 -0
- package/dist/activities-control.d.ts +110 -2
- package/dist/{activities-turn-AP67JADS.js → activities-turn-2B3WMHBB.js} +767 -471
- package/dist/activities-turn-2B3WMHBB.js.map +1 -0
- package/dist/activities.d.ts +110 -2
- package/dist/artifact-materializer-entry.js +5 -2
- package/dist/artifact-materializer-entry.js.map +1 -1
- package/dist/artifact-outbox-entry.js +2 -2
- package/dist/artifact-outbox-entry.js.map +1 -1
- package/dist/{chunk-A4XQWVZK.js → chunk-I7HKKMUJ.js} +77 -1
- package/dist/chunk-I7HKKMUJ.js.map +1 -0
- package/dist/{chunk-CYITU5UH.js → chunk-TVEE2UUC.js} +275 -146
- package/dist/chunk-TVEE2UUC.js.map +1 -0
- package/dist/editable-artifact-materializer-service.d.ts +2 -2
- package/dist/editable-artifact-outbox-service.d.ts +2 -2
- package/dist/index.d.ts +55 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/observability-metrics.d.ts +11 -3
- package/dist/retained-process-diagnostics.d.ts +4 -0
- package/dist/sandbox-resume.d.ts +2 -12
- package/dist/sandbox-routing.d.ts +5 -3
- package/dist/sandbox-snapshot-diagnostics.d.ts +20 -0
- package/dist/warm-capture-holder.d.ts +3 -0
- package/dist/workflow-bundle.js +51 -11
- package/package.json +19 -19
- package/src/activities/agent-turn/agent-build.ts +42 -5
- package/src/activities/agent-turn/claim.ts +12 -0
- package/src/activities/agent-turn/codex-capacity.ts +26 -4
- package/src/activities/agent-turn/codex.ts +6 -2
- package/src/activities/agent-turn/compaction-prep.ts +53 -72
- package/src/activities/agent-turn/errors.ts +98 -10
- package/src/activities/agent-turn/failure-settlement.ts +49 -28
- package/src/activities/agent-turn/finalization-monitor.ts +121 -0
- package/src/activities/agent-turn/finalization.ts +79 -21
- package/src/activities/agent-turn/governance-model.ts +15 -19
- package/src/activities/agent-turn/history.ts +24 -10
- package/src/activities/agent-turn/quiescence.ts +3 -0
- package/src/activities/agent-turn/recovery-warning.ts +18 -0
- package/src/activities/agent-turn/run-credentials.ts +3 -7
- package/src/activities/agent-turn/run.ts +68 -52
- package/src/activities/agent-turn/sandbox-establish.ts +10 -2
- package/src/activities/agent-turn/sandbox-route.ts +0 -20
- package/src/activities/agent-turn/sandbox-runtime.ts +40 -7
- package/src/activities/agent-turn/skill-remove.ts +46 -0
- package/src/activities/agent-turn/skill-save.ts +1 -1
- package/src/activities/agent-turn/skill-search.ts +1 -1
- package/src/activities/agent-turn/skill-selection.ts +2 -0
- package/src/activities/agent-turn/skill-tools.ts +10 -5
- package/src/activities/agent-turn/stream-attempt.ts +38 -15
- package/src/activities/agent-turn/tool-environment.ts +44 -29
- package/src/activities/agent-turn/turn-context.ts +3 -0
- package/src/activities/agent-turn/turn-sandbox-access.ts +7 -1
- package/src/activities/capabilities.ts +17 -2
- package/src/activities/codex-capacity.ts +38 -9
- package/src/activities/codex-rotation.ts +18 -5
- package/src/activities/context-compaction.ts +26 -4
- package/src/activities/goals.ts +1 -0
- package/src/activities/google-drive-publication.ts +1 -3
- package/src/activities/mcp-account-routes.ts +139 -0
- package/src/activities/mcp-credentials.ts +83 -194
- package/src/activities/mcp-operation-authority.ts +16 -41
- package/src/activities/parent-wake.ts +8 -0
- package/src/activities/rig-verification.ts +38 -37
- package/src/activities/run-input.ts +25 -16
- package/src/activities/sandbox-images.ts +0 -1
- package/src/activities/sandbox-lease.ts +177 -44
- package/src/activities/scheduled-tasks.ts +118 -93
- package/src/activities/session-state.ts +83 -3
- package/src/activities/types.ts +18 -2
- package/src/activities/workflow-wake.ts +2 -17
- package/src/editable-artifact-materializer-service.ts +7 -3
- package/src/editable-artifact-outbox-service.ts +4 -4
- package/src/github-rest-mcp.ts +0 -1
- package/src/index.ts +2 -1
- package/src/observability-metrics.ts +105 -2
- package/src/personal-github-git-credentials.ts +0 -1
- package/src/pr-review-credentials.ts +0 -2
- package/src/retained-process-diagnostics.ts +50 -0
- package/src/sandbox-resume.ts +58 -73
- package/src/sandbox-routing.ts +44 -19
- package/src/sandbox-snapshot-diagnostics.ts +112 -0
- package/src/warm-capture-holder.ts +15 -0
- package/src/workflows/session.ts +64 -2
- package/dist/activities/agent-turn/knowledge-sources.d.ts +0 -20
- package/dist/activities/packs.d.ts +0 -55
- package/dist/activities-control-HMFGSKC5.js.map +0 -1
- package/dist/activities-turn-AP67JADS.js.map +0 -1
- package/dist/chunk-A4XQWVZK.js.map +0 -1
- package/dist/chunk-CYITU5UH.js.map +0 -1
- package/src/activities/agent-turn/knowledge-sources.ts +0 -86
- package/src/activities/packs.ts +0 -166
|
@@ -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
|
-
}
|
package/src/activities/packs.ts
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { CapabilityPack } from "@opengeni/contracts";
|
|
2
|
-
import { getWorkspace, listInstalledPortableSkills, type Database } from "@opengeni/db";
|
|
3
|
-
import {
|
|
4
|
-
legacySandboxRuntimeFromPacks,
|
|
5
|
-
packInstallationUsesLegacyRuntime,
|
|
6
|
-
resolveWorkspaceLegacyRuntimePacks,
|
|
7
|
-
} from "@opengeni/core";
|
|
8
|
-
import {
|
|
9
|
-
buildPortableSkillArtifact,
|
|
10
|
-
type InstalledSkillActivation,
|
|
11
|
-
type PackSkillActivation,
|
|
12
|
-
type RuntimeSkillArtifact,
|
|
13
|
-
} from "@opengeni/runtime";
|
|
14
|
-
export {
|
|
15
|
-
resolveRigProviderImageSelection,
|
|
16
|
-
rigProviderImageSourceImage,
|
|
17
|
-
settingsWithPackSandboxImage,
|
|
18
|
-
settingsWithRigImage,
|
|
19
|
-
settingsWithRigProviderImage,
|
|
20
|
-
} from "./sandbox-images";
|
|
21
|
-
export { packInstallationUsesLegacyRuntime };
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Legacy pack-scoped runtime compatibility. V2 Pack installations own ordinary
|
|
25
|
-
* Skill components and select an explicit Rig; they contribute nothing here.
|
|
26
|
-
*/
|
|
27
|
-
export type WorkspacePackRuntime = {
|
|
28
|
-
sandboxImage: string | null;
|
|
29
|
-
sandboxProviderImages: CapabilityPack["sandboxProviderImages"] | null;
|
|
30
|
-
skillActivations: PackSkillActivation[];
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const emptyPackRuntime: WorkspacePackRuntime = {
|
|
34
|
-
sandboxImage: null,
|
|
35
|
-
sandboxProviderImages: null,
|
|
36
|
-
skillActivations: [],
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export type WorkspaceInstalledSkillRuntime = {
|
|
40
|
-
activations: InstalledSkillActivation[];
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Resolves only pre-V2 active Pack installations. A frozen manifest/digest is
|
|
45
|
-
* the protocol marker for V2: inline Skills were migrated into the ordinary
|
|
46
|
-
* Skill ledger and sandboxImage was resolved to selectedRigId during install,
|
|
47
|
-
* so reading either field directly here would duplicate ownership and silently
|
|
48
|
-
* override session compute.
|
|
49
|
-
*/
|
|
50
|
-
export async function resolveWorkspacePackRuntime(
|
|
51
|
-
db: Database,
|
|
52
|
-
workspaceId: string,
|
|
53
|
-
): Promise<WorkspacePackRuntime> {
|
|
54
|
-
const packs = await resolveWorkspaceLegacyRuntimePacks(db, workspaceId);
|
|
55
|
-
if (packs.length === 0) return emptyPackRuntime;
|
|
56
|
-
return workspacePackRuntimeFromPacks(packs);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Resolves every active immutable Skill through the normalized Plugin/Skill-
|
|
61
|
-
* Facet ledger. The data layer has already filtered ineffective owner edges;
|
|
62
|
-
* this boundary independently verifies exact files before runtime activation.
|
|
63
|
-
*/
|
|
64
|
-
export async function resolveWorkspaceInstalledSkillRuntime(
|
|
65
|
-
db: Database,
|
|
66
|
-
workspaceId: string,
|
|
67
|
-
): Promise<WorkspaceInstalledSkillRuntime> {
|
|
68
|
-
const installedSkills = await listInstalledPortableSkills(db, workspaceId);
|
|
69
|
-
const activations: InstalledSkillActivation[] = [];
|
|
70
|
-
for (const installed of installedSkills) {
|
|
71
|
-
const artifact = buildPortableSkillArtifact(installed.files);
|
|
72
|
-
if (
|
|
73
|
-
artifact.name !== installed.name ||
|
|
74
|
-
artifact.description !== installed.description ||
|
|
75
|
-
artifact.contentSha256 !== installed.contentSha256
|
|
76
|
-
) {
|
|
77
|
-
throw new Error(
|
|
78
|
-
`Installed Skill artifact verification failed for ${installed.capabilityId}; reinstall it from the pinned source`,
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
activations.push({
|
|
82
|
-
source: "installation",
|
|
83
|
-
id: installed.capabilityId,
|
|
84
|
-
artifact: {
|
|
85
|
-
name: artifact.name,
|
|
86
|
-
description: artifact.description,
|
|
87
|
-
files: artifact.files.map((file) => ({ path: file.path, content: file.content })),
|
|
88
|
-
},
|
|
89
|
-
version: installed.version,
|
|
90
|
-
contentSha256: artifact.contentSha256,
|
|
91
|
-
reason:
|
|
92
|
-
installed.source === "library"
|
|
93
|
-
? "installed from the curated Skill library"
|
|
94
|
-
: installed.source === "pack"
|
|
95
|
-
? "installed as a Pack-owned Skill"
|
|
96
|
-
: `installed from ${installed.sourceUrl}`,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
return { activations };
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Pure pre-V2 compatibility rule for enabled Pack manifests. At most one
|
|
104
|
-
* legacy Pack may declare a sandbox image, and legacy Skill names must be
|
|
105
|
-
* unique. V2 rows never reach this function through runtime resolution.
|
|
106
|
-
*/
|
|
107
|
-
export function workspacePackRuntimeFromPacks(packs: CapabilityPack[]): WorkspacePackRuntime {
|
|
108
|
-
const sandboxRuntime = legacySandboxRuntimeFromPacks(packs);
|
|
109
|
-
const skillActivations: PackSkillActivation[] = [];
|
|
110
|
-
// Keyed case-insensitively to match the per-pack uniqueness rule in the
|
|
111
|
-
// CapabilityPack contract (and case-insensitive filesystems).
|
|
112
|
-
const skillOwners = new Map<string, string>();
|
|
113
|
-
for (const pack of [...packs].sort((a, b) => a.id.localeCompare(b.id))) {
|
|
114
|
-
for (const skill of pack.skills) {
|
|
115
|
-
const key = skill.name.toLowerCase();
|
|
116
|
-
const existingOwner = skillOwners.get(key);
|
|
117
|
-
if (existingOwner !== undefined && existingOwner !== pack.id) {
|
|
118
|
-
throw new Error(
|
|
119
|
-
`Enabled packs ${existingOwner} and ${pack.id} both declare a skill named "${skill.name}". Pack skill names must be unique across enabled packs; disable one of the packs and retry.`,
|
|
120
|
-
);
|
|
121
|
-
}
|
|
122
|
-
skillOwners.set(key, pack.id);
|
|
123
|
-
const artifact: RuntimeSkillArtifact = {
|
|
124
|
-
name: skill.name,
|
|
125
|
-
description: skill.description ?? null,
|
|
126
|
-
files: skill.files.map((file) => ({ path: file.path, content: file.content })),
|
|
127
|
-
};
|
|
128
|
-
skillActivations.push({
|
|
129
|
-
source: "pack",
|
|
130
|
-
id: `pack:${pack.id}:${skill.name}`,
|
|
131
|
-
artifact,
|
|
132
|
-
reason: `active legacy Pack ${pack.id}`,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return {
|
|
137
|
-
sandboxImage: sandboxRuntime.sandboxImage,
|
|
138
|
-
sandboxProviderImages: sandboxRuntime.sandboxProviderImages,
|
|
139
|
-
skillActivations,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Resolves the per-workspace agent persona override (the white-label surface).
|
|
145
|
-
* Returns the workspace's stored template when set, else null to mean "use the
|
|
146
|
-
* deployment default" (settings.agentInstructionsTemplate). The runtime always
|
|
147
|
-
* injects the non-bypassable CORE regardless, so a null here keeps the
|
|
148
|
-
* byte-identical default and a non-null value only restyles the persona.
|
|
149
|
-
*
|
|
150
|
-
* This is the workspace tier of the session > workspace > deployment-default
|
|
151
|
-
* resolution; per-session overrides do not exist in this slice, so the worker
|
|
152
|
-
* resolves workspace > default and passes the result as instructionsTemplate.
|
|
153
|
-
*/
|
|
154
|
-
export async function resolveWorkspaceAgentInstructions(
|
|
155
|
-
db: Database,
|
|
156
|
-
workspaceId: string,
|
|
157
|
-
): Promise<string | null> {
|
|
158
|
-
const workspace = await getWorkspace(db, workspaceId);
|
|
159
|
-
return workspace?.agentInstructions ?? null;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Applies a pack-declared sandbox image to run settings. With no pack image
|
|
164
|
-
* the settings pass through untouched, so deployments without packs keep the
|
|
165
|
-
* global OPENGENI_DOCKER_IMAGE / OPENGENI_MODAL_IMAGE_REF behavior exactly.
|
|
166
|
-
*/
|