veryfront 0.1.464 → 0.1.466
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/esm/deno.js +1 -1
- package/esm/src/agent/hosted-agent-service-routes.d.ts +72 -0
- package/esm/src/agent/hosted-agent-service-routes.d.ts.map +1 -0
- package/esm/src/agent/hosted-agent-service-routes.js +202 -0
- package/esm/src/agent/hosted-runtime-state-resolver.d.ts +28 -0
- package/esm/src/agent/hosted-runtime-state-resolver.d.ts.map +1 -0
- package/esm/src/agent/hosted-runtime-state-resolver.js +71 -0
- package/esm/src/agent/index.d.ts +2 -0
- package/esm/src/agent/index.d.ts.map +1 -1
- package/esm/src/agent/index.js +2 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
- package/src/deno.js +1 -1
- package/src/deps/esm.sh/@types/react-dom@19.2.3/client.d.ts +1 -1
- package/src/deps/esm.sh/@types/{react@19.2.14 → react@19.2.3}/global.d.ts +0 -1
- package/src/deps/esm.sh/@types/{react@19.2.14 → react@19.2.3}/index.d.ts +24 -93
- package/src/deps/esm.sh/react-dom@19.2.4/client.d.ts +1 -1
- package/src/src/agent/hosted-agent-service-routes.ts +364 -0
- package/src/src/agent/hosted-runtime-state-resolver.ts +133 -0
- package/src/src/agent/index.ts +20 -0
- package/src/src/utils/version-constant.ts +1 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type DefaultResearchArtifactContext,
|
|
3
|
+
extractLatestUserText,
|
|
4
|
+
updateDefaultResearchArtifacts,
|
|
5
|
+
} from "./default-research-artifact-support.js";
|
|
6
|
+
import {
|
|
7
|
+
addFirstTurnStarterIntentRootOwnershipReminder,
|
|
8
|
+
addSlashCommandArtifactReminder,
|
|
9
|
+
evaluateStarterIntentTurnPolicy,
|
|
10
|
+
FIRST_TURN_STARTER_INTENT_ROOT_OWNERSHIP_CONTEXT_KEY,
|
|
11
|
+
} from "./conversation-delegation-policy.js";
|
|
12
|
+
import { evaluateSlashCommandArtifactPolicy } from "./slash-command-artifact-policy.js";
|
|
13
|
+
import { flattenSystemInstructions } from "./runtime-tool-inventory.js";
|
|
14
|
+
|
|
15
|
+
export type HostedRuntimeStateResolverContext = DefaultResearchArtifactContext & {
|
|
16
|
+
projectId?: string | null;
|
|
17
|
+
branchId?: string | null;
|
|
18
|
+
steeringRevision?: number;
|
|
19
|
+
slashCommandArtifactPathSeen?: boolean;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type HostedRuntimeStateResolverInput = {
|
|
23
|
+
context?: Record<string, unknown>;
|
|
24
|
+
system: string;
|
|
25
|
+
messages: readonly unknown[];
|
|
26
|
+
step: number;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type HostedRuntimeStateResolverResult = {
|
|
30
|
+
system: string;
|
|
31
|
+
context: Record<string, unknown>;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type HostedRuntimeSystemRefreshInput<TContext extends HostedRuntimeStateResolverContext> = {
|
|
35
|
+
taskContext: TContext;
|
|
36
|
+
system: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export type HostedRuntimeSystemRefresh<TContext extends HostedRuntimeStateResolverContext> = (
|
|
40
|
+
input: HostedRuntimeSystemRefreshInput<TContext>,
|
|
41
|
+
) => Promise<string> | string;
|
|
42
|
+
|
|
43
|
+
export type CreateHostedRuntimeStateResolverOptions<
|
|
44
|
+
TContext extends HostedRuntimeStateResolverContext,
|
|
45
|
+
> = {
|
|
46
|
+
taskContext: TContext;
|
|
47
|
+
refreshSystem?: HostedRuntimeSystemRefresh<TContext>;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
function activeProjectId(context: HostedRuntimeStateResolverContext): string | null {
|
|
51
|
+
return context.projectId || null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function activeBranchId(context: HostedRuntimeStateResolverContext): string | null {
|
|
55
|
+
return context.branchId ?? null;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function steeringRevision(context: HostedRuntimeStateResolverContext): number {
|
|
59
|
+
return context.steeringRevision ?? 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function createHostedRuntimeStateResolver<
|
|
63
|
+
TContext extends HostedRuntimeStateResolverContext,
|
|
64
|
+
>(
|
|
65
|
+
options: CreateHostedRuntimeStateResolverOptions<TContext>,
|
|
66
|
+
): (input: HostedRuntimeStateResolverInput) => Promise<HostedRuntimeStateResolverResult> {
|
|
67
|
+
let lastAppliedSteeringRevision = steeringRevision(options.taskContext);
|
|
68
|
+
let lastAppliedProjectId = activeProjectId(options.taskContext);
|
|
69
|
+
let lastAppliedBranchId = activeBranchId(options.taskContext);
|
|
70
|
+
|
|
71
|
+
return async ({ context, system, messages, step }) => {
|
|
72
|
+
const currentSteeringRevision = steeringRevision(options.taskContext);
|
|
73
|
+
const currentProjectId = activeProjectId(options.taskContext);
|
|
74
|
+
const currentBranchId = activeBranchId(options.taskContext);
|
|
75
|
+
const steeringChanged = currentSteeringRevision !== lastAppliedSteeringRevision ||
|
|
76
|
+
currentProjectId !== lastAppliedProjectId ||
|
|
77
|
+
currentBranchId !== lastAppliedBranchId;
|
|
78
|
+
|
|
79
|
+
let nextSystem = system;
|
|
80
|
+
const nextContextRecord = { ...(context ?? {}) };
|
|
81
|
+
|
|
82
|
+
if (steeringChanged && options.refreshSystem) {
|
|
83
|
+
nextSystem = await options.refreshSystem({
|
|
84
|
+
taskContext: options.taskContext,
|
|
85
|
+
system,
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
lastAppliedSteeringRevision = currentSteeringRevision;
|
|
89
|
+
lastAppliedProjectId = currentProjectId;
|
|
90
|
+
lastAppliedBranchId = currentBranchId;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const latestUserText = extractLatestUserText(messages);
|
|
94
|
+
if (latestUserText) {
|
|
95
|
+
const reminded = updateDefaultResearchArtifacts({
|
|
96
|
+
taskContext: options.taskContext,
|
|
97
|
+
latestUserText,
|
|
98
|
+
system: nextSystem,
|
|
99
|
+
});
|
|
100
|
+
nextSystem = typeof reminded === "string" ? reminded : flattenSystemInstructions(reminded);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const starterIntentPolicy = evaluateStarterIntentTurnPolicy({
|
|
104
|
+
messages,
|
|
105
|
+
step,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
if (starterIntentPolicy.shouldAddRootOwnershipReminder) {
|
|
109
|
+
nextSystem = addFirstTurnStarterIntentRootOwnershipReminder(nextSystem);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (starterIntentPolicy.shouldBlockImmediateDelegation) {
|
|
113
|
+
nextContextRecord[FIRST_TURN_STARTER_INTENT_ROOT_OWNERSHIP_CONTEXT_KEY] = true;
|
|
114
|
+
} else {
|
|
115
|
+
delete nextContextRecord[FIRST_TURN_STARTER_INTENT_ROOT_OWNERSHIP_CONTEXT_KEY];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const slashCommandArtifactPolicy = evaluateSlashCommandArtifactPolicy({
|
|
119
|
+
messages,
|
|
120
|
+
slashCommandArtifactPathSeen: options.taskContext.slashCommandArtifactPathSeen,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
if (slashCommandArtifactPolicy.shouldKeepReminder) {
|
|
124
|
+
const reminded = addSlashCommandArtifactReminder(nextSystem);
|
|
125
|
+
nextSystem = typeof reminded === "string" ? reminded : flattenSystemInstructions(reminded);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
system: nextSystem,
|
|
130
|
+
context: nextContextRecord,
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
}
|
package/src/src/agent/index.ts
CHANGED
|
@@ -310,6 +310,26 @@ export type {
|
|
|
310
310
|
HostedChatRuntimeToUiMessageStreamOptions,
|
|
311
311
|
} from "./hosted-chat-runtime-contract.js";
|
|
312
312
|
|
|
313
|
+
export {
|
|
314
|
+
createHostedAgentServiceRouteSet,
|
|
315
|
+
type HostedAgentServiceActiveSpanAttributes,
|
|
316
|
+
type HostedAgentServiceDetachedCleanupInput,
|
|
317
|
+
type HostedAgentServiceDetachedExecutionInput,
|
|
318
|
+
type HostedAgentServiceRouteSet,
|
|
319
|
+
type HostedAgentServiceRouteSetOptions,
|
|
320
|
+
type HostedAgentServiceRoutesLogger,
|
|
321
|
+
type HostedAgentServiceRoutesTrace,
|
|
322
|
+
type HostedAgentServiceStreamExecutionInput,
|
|
323
|
+
} from "./hosted-agent-service-routes.js";
|
|
324
|
+
export {
|
|
325
|
+
createHostedRuntimeStateResolver,
|
|
326
|
+
type CreateHostedRuntimeStateResolverOptions,
|
|
327
|
+
type HostedRuntimeStateResolverContext,
|
|
328
|
+
type HostedRuntimeStateResolverInput,
|
|
329
|
+
type HostedRuntimeStateResolverResult,
|
|
330
|
+
type HostedRuntimeSystemRefresh,
|
|
331
|
+
type HostedRuntimeSystemRefreshInput,
|
|
332
|
+
} from "./hosted-runtime-state-resolver.js";
|
|
313
333
|
export {
|
|
314
334
|
executeHostedDurableChatRun,
|
|
315
335
|
type ExecuteHostedDurableChatRunInput,
|