@opengeni/worker-bundle 4.3.3-canary.39786771332001 → 4.5.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/dist/activities/agent-turn/owned-sandbox-setup.d.ts +38 -0
- package/dist/activities/agent-turn/stream-attempt.d.ts +3 -0
- package/dist/activities/agent-turn/user-setup-card.d.ts +30 -0
- package/dist/{activities-turn-WVRRHWOU.js → activities-turn-B73PNSEA.js} +550 -437
- package/dist/activities-turn-B73PNSEA.js.map +1 -0
- package/dist/artifact-materializer-entry.js +0 -0
- package/dist/artifact-outbox-entry.js +0 -0
- package/dist/index.js +1 -1
- package/dist/workflow-bundle.js +1 -1
- package/package.json +27 -27
- package/src/activities/agent-turn/owned-sandbox-setup.ts +207 -0
- package/src/activities/agent-turn/run.ts +237 -193
- package/src/activities/agent-turn/stream-attempt.ts +11 -95
- package/src/activities/agent-turn/tool-environment.ts +12 -0
- package/src/activities/agent-turn/user-setup-card.ts +60 -0
- package/dist/activities-turn-WVRRHWOU.js.map +0 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { sessionChatUrl } from "@opengeni/contracts";
|
|
2
|
+
import { CONNECTED_MACHINE_CAPABILITY_ID, userSetupCardPayload } from "@opengeni/core";
|
|
3
|
+
import { appendTurnCapabilityCardOnce } from "@opengeni/db";
|
|
4
|
+
import { publishDurableSessionEvents } from "@opengeni/events";
|
|
5
|
+
import type { UserSetupCardPoster } from "@opengeni/runtime";
|
|
6
|
+
|
|
7
|
+
type AppendCardOnce = typeof appendTurnCapabilityCardOnce;
|
|
8
|
+
type PublishEvents = typeof publishDurableSessionEvents;
|
|
9
|
+
|
|
10
|
+
export type UserSetupCardInput = {
|
|
11
|
+
db: Parameters<AppendCardOnce>[0];
|
|
12
|
+
bus: Parameters<PublishEvents>[0];
|
|
13
|
+
/** Connected Machines are enabled on this deployment; their cards can't help otherwise. */
|
|
14
|
+
connectedMachinesEnabled: boolean;
|
|
15
|
+
/** The web app's base URL, for the chat link the agent can hand out. */
|
|
16
|
+
webBaseUrl: string | null | undefined;
|
|
17
|
+
workspaceId: string;
|
|
18
|
+
sessionId: string;
|
|
19
|
+
turnId: string;
|
|
20
|
+
executionGeneration: number;
|
|
21
|
+
attemptId: string;
|
|
22
|
+
append?: AppendCardOnce;
|
|
23
|
+
publish?: PublishEvents;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Posts the setup card for a tool refusal the person can fix (see
|
|
28
|
+
* USER_SETUP_BLOCKERS) in the calling turn, at most once per turn and card: a
|
|
29
|
+
* later refusal in the same turn reuses the card already shown. The append
|
|
30
|
+
* runs under the attempt fence, so a replaced turn posts nothing. Resolves
|
|
31
|
+
* "unavailable" when the card can't help on this deployment, and null when it
|
|
32
|
+
* was not posted.
|
|
33
|
+
*/
|
|
34
|
+
export function userSetupCardPoster(input: UserSetupCardInput): UserSetupCardPoster {
|
|
35
|
+
const append = input.append ?? appendTurnCapabilityCardOnce;
|
|
36
|
+
const publish = input.publish ?? publishDurableSessionEvents;
|
|
37
|
+
return async (blocker, toolName) => {
|
|
38
|
+
if (
|
|
39
|
+
blocker.capabilityId === CONNECTED_MACHINE_CAPABILITY_ID &&
|
|
40
|
+
!input.connectedMachinesEnabled
|
|
41
|
+
) {
|
|
42
|
+
return "unavailable";
|
|
43
|
+
}
|
|
44
|
+
const payload = userSetupCardPayload(blocker, { toolName });
|
|
45
|
+
if (!payload) return null;
|
|
46
|
+
const appended = await append(
|
|
47
|
+
input.db,
|
|
48
|
+
input.workspaceId,
|
|
49
|
+
input.sessionId,
|
|
50
|
+
input.turnId,
|
|
51
|
+
input.executionGeneration,
|
|
52
|
+
input.attemptId,
|
|
53
|
+
blocker.capabilityId,
|
|
54
|
+
{ type: "tool.auth_needed", payload },
|
|
55
|
+
);
|
|
56
|
+
await publish(input.bus, input.workspaceId, input.sessionId, appended.events);
|
|
57
|
+
if (!appended.accepted) return null;
|
|
58
|
+
return { chatUrl: sessionChatUrl(input.webBaseUrl, input.workspaceId, input.sessionId) };
|
|
59
|
+
};
|
|
60
|
+
}
|