@sentry/junior 0.140.0 → 0.141.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/{agent-hooks-BFTDRFUO.js → agent-hooks-HIRVKUQJ.js} +10 -10
- package/dist/api/conversations/detail.d.ts +1 -0
- package/dist/api/conversations/event-list.d.ts +1 -0
- package/dist/api/schema/conversation.d.ts +4 -0
- package/dist/api.js +19 -19
- package/dist/app.js +31 -31
- package/dist/{catalog-runtime-RK664S5T.js → catalog-runtime-XVLED5UH.js} +5 -5
- package/dist/chat/agent/repository-context.d.ts +1 -0
- package/dist/chat/conversations/history.d.ts +2 -0
- package/dist/chat/conversations/projection.d.ts +8 -0
- package/dist/chat/conversations/store.d.ts +5 -0
- package/dist/chat/conversations/structured-events.d.ts +11 -0
- package/dist/chat/runtime/thread-state.d.ts +3 -1
- package/dist/chat/services/guardian-action-policy.d.ts +1 -1
- package/dist/chat/state/turn-session.d.ts +3 -4
- package/dist/{chunk-3B7O3GNU.js → chunk-2DOVDDZJ.js} +3 -3
- package/dist/{chunk-557HLSNH.js → chunk-3H42HMA2.js} +1 -1
- package/dist/{chunk-CPPTBHQN.js → chunk-43OPSFUY.js} +1 -1
- package/dist/{chunk-TKTZ4L4Z.js → chunk-44NWPKY3.js} +1 -1
- package/dist/{chunk-XX2QNQN4.js → chunk-5LPWHC7Q.js} +5 -5
- package/dist/{chunk-WSWM6A3R.js → chunk-5MFCEKR6.js} +19 -3
- package/dist/{chunk-D3X2PI3D.js → chunk-6FRAWWGR.js} +2 -2
- package/dist/{chunk-J5H65GY2.js → chunk-6U44QGXL.js} +1 -1
- package/dist/{chunk-4PIT6O7A.js → chunk-7ULXCNOZ.js} +6 -6
- package/dist/{chunk-5YAWB2AX.js → chunk-A2O7SGK5.js} +15 -17
- package/dist/{chunk-S3FAOKQU.js → chunk-BBLO66XT.js} +29 -29
- package/dist/{chunk-VRDHAITB.js → chunk-DBKS7JR2.js} +3 -3
- package/dist/{chunk-5KAZMR5U.js → chunk-DK3GQWJK.js} +6 -6
- package/dist/{chunk-A6BI25J3.js → chunk-DKH4WGZU.js} +8 -8
- package/dist/{chunk-HEFBGCCU.js → chunk-DVIJ6DP6.js} +2 -2
- package/dist/{chunk-N2I7W2VS.js → chunk-EYD523BV.js} +1 -1
- package/dist/{chunk-XROWZSOY.js → chunk-FWXSPJRN.js} +1 -1
- package/dist/{chunk-OGNL2QY7.js → chunk-FZFJZZR3.js} +4 -4
- package/dist/{chunk-DMDOKRPC.js → chunk-H4WNQFBH.js} +5 -5
- package/dist/{chunk-CDQ4YIZM.js → chunk-HLXXQI5Q.js} +55 -1
- package/dist/{chunk-TGIKZJ3Y.js → chunk-HN4UZTG7.js} +2 -2
- package/dist/{chunk-WTGLUX4K.js → chunk-HQAFIN6O.js} +1 -1
- package/dist/{chunk-Z2A7BDHT.js → chunk-LIVSCWI5.js} +15 -15
- package/dist/{chunk-I3OZR3HG.js → chunk-LMGKSDO4.js} +1 -1
- package/dist/{chunk-AA2EPMUF.js → chunk-NFL4FRIU.js} +4 -4
- package/dist/{chunk-YB363QGA.js → chunk-OFQBDHVG.js} +1 -1
- package/dist/{chunk-MYVCHWDG.js → chunk-OHO46E7F.js} +36 -18
- package/dist/{chunk-UXMRN2ZX.js → chunk-PGJUJCOQ.js} +1 -1
- package/dist/{chunk-BMFRFSTM.js → chunk-PIQKV7IR.js} +159 -88
- package/dist/{chunk-NPL66ZWL.js → chunk-UFEU4UX6.js} +1 -1
- package/dist/{chunk-3CUBAGA3.js → chunk-UONUDOJP.js} +7 -7
- package/dist/cli/chat.js +31 -31
- package/dist/cli/check.js +6 -6
- package/dist/cli/plugins.js +13 -13
- package/dist/cli/snapshot-create.js +9 -9
- package/dist/cli/upgrade.js +7 -7
- package/dist/{db-QOGYDDQM.js → db-PSMQZR4P.js} +7 -7
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-CT4RMGCP.js → oauth-callback-server-XZUK2AT6.js} +22 -22
- package/dist/{runner-PHMLHNLX.js → runner-5EKJCQWP.js} +14 -14
- package/dist/{skills-AYRM4QGF.js → skills-2PRM42SE.js} +6 -6
- package/dist/spawn-UGTLRTFP.js +38 -0
- package/dist/{validation-M5JNGRGL.js → validation-XLXAIRTR.js} +6 -6
- package/dist/version.js +1 -1
- package/dist/{work-LZWE6HK4.js → work-CNTNEQ2Q.js} +17 -17
- package/dist/{worker-KOGPXFYK.js → worker-BGW7CKZ7.js} +10 -10
- package/package.json +5 -5
- package/dist/spawn-OGRQFUNK.js +0 -38
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
JUNIOR_NATIVE_EVENT_NAMESPACE,
|
|
6
6
|
ToolInputError,
|
|
7
7
|
addAgentTurnUsage,
|
|
8
|
-
|
|
8
|
+
agentsInstructionsUpdatedEvent,
|
|
9
9
|
authenticationLinkedEvent,
|
|
10
10
|
authenticationUnlinkedEvent
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-HLXXQI5Q.js";
|
|
12
12
|
import {
|
|
13
13
|
agentHistoryItemSchema,
|
|
14
14
|
bindProviderConversation,
|
|
@@ -21,20 +21,20 @@ import {
|
|
|
21
21
|
instructionProvenanceFor,
|
|
22
22
|
sanitizePostgresJson,
|
|
23
23
|
withConversationEventLock
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-5MFCEKR6.js";
|
|
25
25
|
import {
|
|
26
26
|
SANDBOX_WORKSPACE_ROOT,
|
|
27
27
|
sleep
|
|
28
28
|
} from "./chunk-EM225ITJ.js";
|
|
29
29
|
import {
|
|
30
30
|
getStateAdapter
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-6U44QGXL.js";
|
|
32
32
|
import {
|
|
33
33
|
botConfig,
|
|
34
34
|
escapeXml,
|
|
35
35
|
resolveGatewayModel,
|
|
36
36
|
unwrapCurrentInstruction
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-BBLO66XT.js";
|
|
38
38
|
import {
|
|
39
39
|
toStoredSlackActor
|
|
40
40
|
} from "./chunk-HZF5P5UN.js";
|
|
@@ -49,7 +49,7 @@ import {
|
|
|
49
49
|
setSpanAttributes,
|
|
50
50
|
toOptionalNumber,
|
|
51
51
|
toOptionalString
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-UFEU4UX6.js";
|
|
53
53
|
|
|
54
54
|
// src/chat/turn-context-tag.ts
|
|
55
55
|
var TURN_CONTEXT_TAG = "runtime-turn-context";
|
|
@@ -1214,6 +1214,59 @@ async function recordAuthenticationAccountChange(action, args) {
|
|
|
1214
1214
|
async function recordAuthenticationLinked(args) {
|
|
1215
1215
|
await recordAuthenticationAccountChange("linked", args);
|
|
1216
1216
|
}
|
|
1217
|
+
async function loadAgentsEvent(conversationId) {
|
|
1218
|
+
const event = await getConversationEventStore().loadLatestStructuredEvent(
|
|
1219
|
+
conversationId,
|
|
1220
|
+
JUNIOR_NATIVE_EVENT_NAMESPACE,
|
|
1221
|
+
agentsInstructionsUpdatedEvent.eventName
|
|
1222
|
+
);
|
|
1223
|
+
if (!event || event.data.type !== "structured_event") return void 0;
|
|
1224
|
+
return {
|
|
1225
|
+
content: agentsInstructionsUpdatedEvent.parse(
|
|
1226
|
+
event.data.content
|
|
1227
|
+
),
|
|
1228
|
+
seq: event.seq
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
function agentsInstructionsIdempotencyKey(args) {
|
|
1232
|
+
const previous = args.previousSeq ?? "none";
|
|
1233
|
+
return `native:${JUNIOR_NATIVE_EVENT_NAMESPACE}:agents_instructions_updated:${args.turnId}:${args.action}:${previous}->${args.fingerprint}`;
|
|
1234
|
+
}
|
|
1235
|
+
async function recordAgentsInstructionsUpdated(args) {
|
|
1236
|
+
const previous = await loadAgentsEvent(args.conversationId);
|
|
1237
|
+
const instructions = args.instructions;
|
|
1238
|
+
if (previous && (!instructions && previous.content.action === "cleared" || instructions && previous.content.action !== "cleared" && previous.content.fingerprint === instructions.fingerprint && previous.content.directory === instructions.directory)) {
|
|
1239
|
+
return;
|
|
1240
|
+
}
|
|
1241
|
+
const action = !instructions ? "cleared" : previous && previous.content.action !== "cleared" ? "replaced" : "loaded";
|
|
1242
|
+
const fingerprint = instructions?.fingerprint ?? "cleared";
|
|
1243
|
+
const content = agentsInstructionsUpdatedEvent.parse({
|
|
1244
|
+
action,
|
|
1245
|
+
fingerprint,
|
|
1246
|
+
sources: instructions?.sources ?? [],
|
|
1247
|
+
...instructions ? { directory: instructions.directory } : {},
|
|
1248
|
+
...instructions ? { textBytes: Buffer.byteLength(instructions.text, "utf8") } : {}
|
|
1249
|
+
});
|
|
1250
|
+
await getConversationEventStore().append(args.conversationId, [
|
|
1251
|
+
{
|
|
1252
|
+
createdAtMs: Date.now(),
|
|
1253
|
+
idempotencyKey: agentsInstructionsIdempotencyKey({
|
|
1254
|
+
action,
|
|
1255
|
+
fingerprint,
|
|
1256
|
+
previousSeq: previous?.seq,
|
|
1257
|
+
turnId: args.turnId
|
|
1258
|
+
}),
|
|
1259
|
+
data: {
|
|
1260
|
+
type: "structured_event",
|
|
1261
|
+
namespace: JUNIOR_NATIVE_EVENT_NAMESPACE,
|
|
1262
|
+
name: agentsInstructionsUpdatedEvent.eventName,
|
|
1263
|
+
version: agentsInstructionsUpdatedEvent.version,
|
|
1264
|
+
turnId: args.turnId,
|
|
1265
|
+
content
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
]);
|
|
1269
|
+
}
|
|
1217
1270
|
async function loadTurnRoute(args) {
|
|
1218
1271
|
const event = await getConversationEventStore().loadByIdempotencyKey(
|
|
1219
1272
|
args.conversationId,
|
|
@@ -1402,9 +1455,6 @@ function getAssistantReplyText(message) {
|
|
|
1402
1455
|
}
|
|
1403
1456
|
|
|
1404
1457
|
// src/chat/state/turn-session.ts
|
|
1405
|
-
import {
|
|
1406
|
-
actorSchema
|
|
1407
|
-
} from "@sentry/junior-plugin-api";
|
|
1408
1458
|
import { z as z2 } from "zod";
|
|
1409
1459
|
|
|
1410
1460
|
// src/chat/repository-instructions.ts
|
|
@@ -1767,6 +1817,9 @@ function agentTurnSessionConversationIndexKey(conversationId) {
|
|
|
1767
1817
|
// src/chat/state/turn-session.ts
|
|
1768
1818
|
var AGENT_TURN_SESSION_RESUME_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
1769
1819
|
var AGENT_TURN_SESSION_TERMINAL_TTL_MS = 60 * 60 * 1e3;
|
|
1820
|
+
function executionMetricsForSession(conversation, sessionId) {
|
|
1821
|
+
return conversation?.executionMetrics?.runId === sessionId ? conversation.executionMetrics : void 0;
|
|
1822
|
+
}
|
|
1770
1823
|
function definedProps(values) {
|
|
1771
1824
|
return Object.fromEntries(
|
|
1772
1825
|
Object.entries(values).filter(([, value]) => value !== void 0)
|
|
@@ -1807,18 +1860,12 @@ var agentTurnSessionSummarySchema = z2.object({
|
|
|
1807
1860
|
updatedAtMs: nonNegativeNumberSchema
|
|
1808
1861
|
}).strip();
|
|
1809
1862
|
var storedAgentTurnSessionRecordSchema = z2.object({
|
|
1810
|
-
channelName: z2.string().min(1).optional(),
|
|
1811
1863
|
version: z2.number().int().nonnegative(),
|
|
1812
1864
|
conversationId: z2.string().min(1),
|
|
1813
|
-
cumulativeDurationMs: nonNegativeNumberSchema,
|
|
1814
|
-
cumulativeUsage: agentTurnUsageSchema.optional(),
|
|
1815
1865
|
dispatchId: z2.string().min(1).optional(),
|
|
1816
1866
|
dispatchOutcome: z2.enum(["blocked", "completed", "failed"]).optional(),
|
|
1817
1867
|
resultMessageId: z2.string().min(1).optional(),
|
|
1818
1868
|
lastProgressAtMs: nonNegativeNumberSchema,
|
|
1819
|
-
loadedSkillNames: z2.array(z2.string()).optional(),
|
|
1820
|
-
modelId: z2.string().min(1).optional(),
|
|
1821
|
-
reasoningLevel: z2.string().min(1).optional(),
|
|
1822
1869
|
resumeReason: agentTurnResumeReasonSchema.optional(),
|
|
1823
1870
|
resumedFromSliceId: z2.number().int().nonnegative().optional(),
|
|
1824
1871
|
sessionId: z2.string().min(1),
|
|
@@ -1828,7 +1875,6 @@ var storedAgentTurnSessionRecordSchema = z2.object({
|
|
|
1828
1875
|
surface: agentTurnSurfaceSchema.optional(),
|
|
1829
1876
|
traceId: z2.string().optional(),
|
|
1830
1877
|
updatedAtMs: nonNegativeNumberSchema,
|
|
1831
|
-
actors: z2.array(actorSchema).optional(),
|
|
1832
1878
|
committedSeq: seqCursorSchema,
|
|
1833
1879
|
historyVersion: z2.number().int().nonnegative().optional(),
|
|
1834
1880
|
errorMessage: z2.string().optional(),
|
|
@@ -1908,7 +1954,7 @@ async function recordConversationActivityMetadata(args) {
|
|
|
1908
1954
|
visibility: isChild ? void 0 : args.destinationVisibility
|
|
1909
1955
|
});
|
|
1910
1956
|
}
|
|
1911
|
-
function materializeAgentTurnSessionRecord(stored, piProjection, turnStartMessageIndex, restoreVolatileContext = true) {
|
|
1957
|
+
function materializeAgentTurnSessionRecord(stored, piProjection, turnStartMessageIndex, restoreVolatileContext = true, runtimeMetadata) {
|
|
1912
1958
|
const restoredProjection = restoreVolatileContext && (stored.state === "running" || stored.state === "awaiting_resume") ? restoreRuntimeContext(piProjection, stored.runtimeContext) : piProjection;
|
|
1913
1959
|
return {
|
|
1914
1960
|
version: stored.version,
|
|
@@ -1921,17 +1967,17 @@ function materializeAgentTurnSessionRecord(stored, piProjection, turnStartMessag
|
|
|
1921
1967
|
updatedAtMs: stored.updatedAtMs,
|
|
1922
1968
|
piMessages: restoredProjection.messages,
|
|
1923
1969
|
piMessageProvenance: restoredProjection.provenance,
|
|
1924
|
-
actors:
|
|
1925
|
-
cumulativeDurationMs:
|
|
1970
|
+
actors: instructionActors(piProjection.provenance),
|
|
1971
|
+
cumulativeDurationMs: runtimeMetadata?.cumulativeDurationMs ?? 0,
|
|
1926
1972
|
...definedProps({
|
|
1927
|
-
channelName:
|
|
1928
|
-
cumulativeUsage:
|
|
1973
|
+
channelName: runtimeMetadata?.channelName,
|
|
1974
|
+
cumulativeUsage: runtimeMetadata?.cumulativeUsage,
|
|
1975
|
+
loadedSkillNames: runtimeMetadata?.loadedSkillNames,
|
|
1976
|
+
modelId: runtimeMetadata?.modelId,
|
|
1977
|
+
reasoningLevel: runtimeMetadata?.reasoningLevel,
|
|
1929
1978
|
dispatchId: stored.dispatchId,
|
|
1930
1979
|
dispatchOutcome: stored.dispatchOutcome,
|
|
1931
1980
|
errorMessage: stored.errorMessage,
|
|
1932
|
-
loadedSkillNames: stored.loadedSkillNames,
|
|
1933
|
-
modelId: stored.modelId,
|
|
1934
|
-
reasoningLevel: stored.reasoningLevel,
|
|
1935
1981
|
resumeReason: stored.resumeReason,
|
|
1936
1982
|
resultMessageId: stored.resultMessageId,
|
|
1937
1983
|
resumedFromSliceId: stored.resumedFromSliceId,
|
|
@@ -2008,11 +2054,18 @@ async function materializeStoredAgentTurnSessionRecord(conversationId, sessionId
|
|
|
2008
2054
|
const followsReplacement = followCurrentReplacement && (parsed.state === "running" || parsed.state === "awaiting_resume") && parsed.historyVersion !== void 0 && parsed.historyVersion !== currentHistoryVersion;
|
|
2009
2055
|
const piProjection = followsReplacement ? projectConversationEvents(currentHistory) : pinnedProjection;
|
|
2010
2056
|
const turnStartMessageIndex = followsReplacement ? 0 : parsed.turnStartSeq === void 0 ? void 0 : piProjection.seqs.filter((seq) => seq <= parsed.turnStartSeq).length;
|
|
2057
|
+
const conversation = await getConversationStore().get({ conversationId });
|
|
2058
|
+
const executionMetrics = executionMetricsForSession(conversation, sessionId);
|
|
2011
2059
|
return materializeAgentTurnSessionRecord(
|
|
2012
2060
|
parsed,
|
|
2013
2061
|
piProjection,
|
|
2014
2062
|
turnStartMessageIndex,
|
|
2015
|
-
!followsReplacement && (parsed.historyVersion === void 0 || parsed.historyVersion === currentHistoryVersion)
|
|
2063
|
+
!followsReplacement && (parsed.historyVersion === void 0 || parsed.historyVersion === currentHistoryVersion),
|
|
2064
|
+
{
|
|
2065
|
+
channelName: conversation?.channelName,
|
|
2066
|
+
cumulativeDurationMs: executionMetrics?.durationMs,
|
|
2067
|
+
cumulativeUsage: executionMetrics?.usage
|
|
2068
|
+
}
|
|
2016
2069
|
);
|
|
2017
2070
|
}
|
|
2018
2071
|
async function getAgentTurnSessionRecord(conversationId, sessionId) {
|
|
@@ -2041,18 +2094,11 @@ function buildStoredRecord(args) {
|
|
|
2041
2094
|
lastProgressAtMs: args.lastProgressAtMs ?? nowMs,
|
|
2042
2095
|
updatedAtMs: nowMs,
|
|
2043
2096
|
committedSeq: args.committedSeq,
|
|
2044
|
-
cumulativeDurationMs: args.cumulativeDurationMs,
|
|
2045
2097
|
...definedProps({
|
|
2046
|
-
actors: args.actors,
|
|
2047
|
-
channelName: args.channelName,
|
|
2048
|
-
cumulativeUsage: args.cumulativeUsage,
|
|
2049
2098
|
dispatchId: args.dispatchId,
|
|
2050
2099
|
dispatchOutcome: args.dispatchOutcome,
|
|
2051
2100
|
errorMessage: args.errorMessage,
|
|
2052
2101
|
historyVersion: args.historyVersion,
|
|
2053
|
-
loadedSkillNames: args.loadedSkillNames,
|
|
2054
|
-
modelId: args.modelId,
|
|
2055
|
-
reasoningLevel: args.reasoningLevel,
|
|
2056
2102
|
resumeReason: args.resumeReason,
|
|
2057
2103
|
resultMessageId: args.resultMessageId,
|
|
2058
2104
|
resumedFromSliceId: args.resumedFromSliceId,
|
|
@@ -2074,7 +2120,7 @@ async function setStoredRecord(args) {
|
|
|
2074
2120
|
destinationVisibility: args.destinationVisibility,
|
|
2075
2121
|
nowMs: Date.now(),
|
|
2076
2122
|
source: args.source,
|
|
2077
|
-
summary: storedRecord
|
|
2123
|
+
summary: { ...storedRecord, ...args.runtimeMetadata }
|
|
2078
2124
|
});
|
|
2079
2125
|
await stateAdapter.set(
|
|
2080
2126
|
agentTurnSessionKey(storedRecord.conversationId, storedRecord.sessionId),
|
|
@@ -2091,7 +2137,9 @@ async function setStoredRecord(args) {
|
|
|
2091
2137
|
messages: [...args.piMessages],
|
|
2092
2138
|
provenance: [...args.piMessageProvenance]
|
|
2093
2139
|
},
|
|
2094
|
-
args.turnStartMessageIndex
|
|
2140
|
+
args.turnStartMessageIndex,
|
|
2141
|
+
true,
|
|
2142
|
+
args.runtimeMetadata
|
|
2095
2143
|
);
|
|
2096
2144
|
}
|
|
2097
2145
|
async function updateAgentTurnSessionState(args) {
|
|
@@ -2106,6 +2154,16 @@ async function updateAgentTurnSessionState(args) {
|
|
|
2106
2154
|
piMessages: args.existing.piMessages,
|
|
2107
2155
|
piMessageProvenance: args.existing.piMessageProvenance,
|
|
2108
2156
|
ttlMs: agentTurnSessionRecordTtlMs(args.state),
|
|
2157
|
+
runtimeMetadata: {
|
|
2158
|
+
cumulativeDurationMs: args.existing.cumulativeDurationMs,
|
|
2159
|
+
...definedProps({
|
|
2160
|
+
channelName: args.existing.channelName,
|
|
2161
|
+
cumulativeUsage: args.existing.cumulativeUsage,
|
|
2162
|
+
loadedSkillNames: args.existing.loadedSkillNames,
|
|
2163
|
+
modelId: args.existing.modelId,
|
|
2164
|
+
reasoningLevel: args.existing.reasoningLevel
|
|
2165
|
+
})
|
|
2166
|
+
},
|
|
2109
2167
|
...definedProps({
|
|
2110
2168
|
turnStartMessageIndex: args.existing.turnStartMessageIndex
|
|
2111
2169
|
}),
|
|
@@ -2118,18 +2176,11 @@ async function updateAgentTurnSessionState(args) {
|
|
|
2118
2176
|
startedAtMs: parsed.startedAtMs,
|
|
2119
2177
|
lastProgressAtMs: parsed.lastProgressAtMs,
|
|
2120
2178
|
previousVersion: parsed.version,
|
|
2121
|
-
cumulativeDurationMs: args.existing.cumulativeDurationMs,
|
|
2122
|
-
actors: args.existing.actors,
|
|
2123
2179
|
...definedProps({
|
|
2124
|
-
channelName: parsed.channelName,
|
|
2125
|
-
cumulativeUsage: args.existing.cumulativeUsage,
|
|
2126
2180
|
dispatchId: args.existing.dispatchId,
|
|
2127
2181
|
dispatchOutcome: args.existing.dispatchOutcome,
|
|
2128
2182
|
errorMessage: args.errorMessage ?? args.existing.errorMessage,
|
|
2129
2183
|
historyVersion: parsed.historyVersion,
|
|
2130
|
-
loadedSkillNames: args.existing.loadedSkillNames,
|
|
2131
|
-
modelId: args.existing.modelId,
|
|
2132
|
-
reasoningLevel: args.existing.reasoningLevel,
|
|
2133
2184
|
resumeReason: args.existing.resumeReason,
|
|
2134
2185
|
resultMessageId: args.existing.resultMessageId,
|
|
2135
2186
|
resumedFromSliceId: args.existing.resumedFromSliceId,
|
|
@@ -2145,6 +2196,13 @@ async function upsertAgentTurnSessionRecord(args) {
|
|
|
2145
2196
|
args.conversationId,
|
|
2146
2197
|
args.sessionId
|
|
2147
2198
|
);
|
|
2199
|
+
const conversation = await (args.conversationStore ?? getConversationStore()).get({
|
|
2200
|
+
conversationId: args.conversationId
|
|
2201
|
+
});
|
|
2202
|
+
const executionMetrics = executionMetricsForSession(
|
|
2203
|
+
conversation,
|
|
2204
|
+
args.sessionId
|
|
2205
|
+
);
|
|
2148
2206
|
const existingDispatchId = existingRecord?.dispatchId ?? (await listAgentTurnSessionSummariesForConversation(args.conversationId)).find((summary) => summary.sessionId === args.sessionId)?.dispatchId;
|
|
2149
2207
|
if (existingDispatchId && args.dispatchId && existingDispatchId !== args.dispatchId) {
|
|
2150
2208
|
throw new Error(
|
|
@@ -2181,6 +2239,16 @@ async function upsertAgentTurnSessionRecord(args) {
|
|
|
2181
2239
|
piMessages: commit.messages,
|
|
2182
2240
|
piMessageProvenance: commit.provenance,
|
|
2183
2241
|
ttlMs,
|
|
2242
|
+
// TODO(#1267): remove the temporary caller-to-SQL metadata write once the
|
|
2243
|
+
// SQL-only turn-session readers have completed rollout.
|
|
2244
|
+
runtimeMetadata: {
|
|
2245
|
+
channelName: args.channelName ?? conversation?.channelName,
|
|
2246
|
+
cumulativeDurationMs: args.cumulativeDurationMs ?? executionMetrics?.durationMs ?? 0,
|
|
2247
|
+
cumulativeUsage: args.cumulativeUsage ?? executionMetrics?.usage,
|
|
2248
|
+
loadedSkillNames: args.loadedSkillNames,
|
|
2249
|
+
modelId: args.modelId,
|
|
2250
|
+
reasoningLevel: args.reasoningLevel
|
|
2251
|
+
},
|
|
2184
2252
|
// Pass through only an explicit override so indexes stay on the resume window
|
|
2185
2253
|
// by default even when the record takes a short terminal TTL.
|
|
2186
2254
|
...definedProps({ indexTtlMs: args.ttlMs }),
|
|
@@ -2193,22 +2261,11 @@ async function upsertAgentTurnSessionRecord(args) {
|
|
|
2193
2261
|
committedSeq: commit.committedSeq,
|
|
2194
2262
|
historyVersion: commit.historyVersion,
|
|
2195
2263
|
previousVersion: existingRecord?.version,
|
|
2196
|
-
cumulativeDurationMs: args.cumulativeDurationMs ?? existingRecord?.cumulativeDurationMs ?? 0,
|
|
2197
|
-
modelId: args.modelId,
|
|
2198
|
-
actors: instructionActors([
|
|
2199
|
-
...(existingRecord?.actors ?? []).map(instructionProvenanceFor),
|
|
2200
|
-
...(args.actors ?? []).map(instructionProvenanceFor),
|
|
2201
|
-
...commit.provenance
|
|
2202
|
-
]),
|
|
2203
2264
|
...definedProps({
|
|
2204
|
-
channelName: args.channelName ?? existingRecord?.channelName,
|
|
2205
|
-
cumulativeUsage: args.cumulativeUsage,
|
|
2206
2265
|
dispatchId: args.dispatchId ?? existingRecord?.dispatchId,
|
|
2207
2266
|
dispatchOutcome: args.dispatchOutcome ?? existingRecord?.dispatchOutcome,
|
|
2208
2267
|
errorMessage: args.errorMessage,
|
|
2209
2268
|
lastProgressAtMs: args.lastProgressAtMs,
|
|
2210
|
-
loadedSkillNames: args.loadedSkillNames,
|
|
2211
|
-
reasoningLevel: args.reasoningLevel ?? existingRecord?.reasoningLevel,
|
|
2212
2269
|
resumeReason: args.resumeReason,
|
|
2213
2270
|
resultMessageId: args.resultMessageId ?? existingRecord?.resultMessageId,
|
|
2214
2271
|
resumedFromSliceId: args.resumedFromSliceId,
|
|
@@ -2226,6 +2283,14 @@ async function recordAgentTurnSessionSummary(args) {
|
|
|
2226
2283
|
args.conversationId,
|
|
2227
2284
|
args.sessionId
|
|
2228
2285
|
);
|
|
2286
|
+
const conversationStore = args.conversationStore ?? getConversationStore();
|
|
2287
|
+
const conversation = await conversationStore.get({
|
|
2288
|
+
conversationId: args.conversationId
|
|
2289
|
+
});
|
|
2290
|
+
const executionMetrics = executionMetricsForSession(
|
|
2291
|
+
conversation,
|
|
2292
|
+
args.sessionId
|
|
2293
|
+
);
|
|
2229
2294
|
const priorSummary = (await listAgentTurnSessionSummariesForConversation(args.conversationId)).find((summary2) => summary2.sessionId === args.sessionId);
|
|
2230
2295
|
const existing = stored ?? priorSummary;
|
|
2231
2296
|
const existingDispatchId = existing?.dispatchId;
|
|
@@ -2255,16 +2320,16 @@ async function recordAgentTurnSessionSummary(args) {
|
|
|
2255
2320
|
};
|
|
2256
2321
|
await recordConversationActivityMetadata({
|
|
2257
2322
|
actor: args.actor,
|
|
2258
|
-
conversationStore
|
|
2323
|
+
conversationStore,
|
|
2259
2324
|
destination: args.destination,
|
|
2260
2325
|
destinationVisibility: args.destinationVisibility,
|
|
2261
2326
|
nowMs,
|
|
2262
2327
|
source: args.source,
|
|
2263
2328
|
summary: {
|
|
2264
2329
|
...summary,
|
|
2265
|
-
channelName: args.channelName ??
|
|
2266
|
-
cumulativeDurationMs: args.cumulativeDurationMs ??
|
|
2267
|
-
cumulativeUsage: args.cumulativeUsage ??
|
|
2330
|
+
channelName: args.channelName ?? conversation?.channelName,
|
|
2331
|
+
cumulativeDurationMs: args.cumulativeDurationMs ?? executionMetrics?.durationMs ?? 0,
|
|
2332
|
+
cumulativeUsage: args.cumulativeUsage ?? executionMetrics?.usage,
|
|
2268
2333
|
startedAtMs: stored?.startedAtMs ?? args.startedAtMs ?? nowMs
|
|
2269
2334
|
}
|
|
2270
2335
|
});
|
|
@@ -2493,9 +2558,9 @@ async function persistCompletedSessionRecord(args) {
|
|
|
2493
2558
|
destination: args.destination,
|
|
2494
2559
|
destinationVisibility: args.destinationVisibility,
|
|
2495
2560
|
dispatchId: args.dispatchId,
|
|
2496
|
-
loadedSkillNames: args.loadedSkillNames
|
|
2561
|
+
loadedSkillNames: args.loadedSkillNames,
|
|
2497
2562
|
modelId: args.modelId,
|
|
2498
|
-
reasoningLevel: args.reasoningLevel
|
|
2563
|
+
reasoningLevel: args.reasoningLevel,
|
|
2499
2564
|
sessionId: args.sessionId,
|
|
2500
2565
|
source: args.source,
|
|
2501
2566
|
surface: args.surface,
|
|
@@ -2574,7 +2639,7 @@ async function persistAuthPauseSessionRecord(args) {
|
|
|
2574
2639
|
// Auth-pause keeps caller-owned skill names only.
|
|
2575
2640
|
loadedSkillNames: args.loadedSkillNames,
|
|
2576
2641
|
modelId: args.modelId,
|
|
2577
|
-
reasoningLevel: args.reasoningLevel
|
|
2642
|
+
reasoningLevel: args.reasoningLevel,
|
|
2578
2643
|
sessionId: args.sessionId,
|
|
2579
2644
|
source: args.source,
|
|
2580
2645
|
surface: args.surface
|
|
@@ -2645,7 +2710,7 @@ async function persistContinuationSessionRecord(args) {
|
|
|
2645
2710
|
// Continuation keeps caller-owned skill names only.
|
|
2646
2711
|
loadedSkillNames: args.loadedSkillNames,
|
|
2647
2712
|
modelId: args.modelId,
|
|
2648
|
-
reasoningLevel: args.reasoningLevel
|
|
2713
|
+
reasoningLevel: args.reasoningLevel,
|
|
2649
2714
|
sessionId: args.sessionId,
|
|
2650
2715
|
source: args.source,
|
|
2651
2716
|
surface: args.surface
|
|
@@ -2713,7 +2778,7 @@ async function persistYieldSessionRecord(args) {
|
|
|
2713
2778
|
// Yield keeps caller-owned skill names only.
|
|
2714
2779
|
loadedSkillNames: args.loadedSkillNames,
|
|
2715
2780
|
modelId: args.modelId,
|
|
2716
|
-
reasoningLevel: args.reasoningLevel
|
|
2781
|
+
reasoningLevel: args.reasoningLevel,
|
|
2717
2782
|
sessionId: args.sessionId,
|
|
2718
2783
|
source: args.source,
|
|
2719
2784
|
surface: args.surface
|
|
@@ -3136,6 +3201,19 @@ function buildThreadStatePayload(patch) {
|
|
|
3136
3201
|
}
|
|
3137
3202
|
return payload;
|
|
3138
3203
|
}
|
|
3204
|
+
async function mergePersistedState(key, payload) {
|
|
3205
|
+
if (Object.keys(payload).length === 0) {
|
|
3206
|
+
return;
|
|
3207
|
+
}
|
|
3208
|
+
const stateAdapter = getStateAdapter();
|
|
3209
|
+
await stateAdapter.connect();
|
|
3210
|
+
const existing = await stateAdapter.get(key) ?? {};
|
|
3211
|
+
await stateAdapter.set(
|
|
3212
|
+
key,
|
|
3213
|
+
{ ...existing, ...payload },
|
|
3214
|
+
JUNIOR_THREAD_STATE_TTL_MS
|
|
3215
|
+
);
|
|
3216
|
+
}
|
|
3139
3217
|
function mergeArtifactsState(artifacts, patch) {
|
|
3140
3218
|
if (!patch) {
|
|
3141
3219
|
return artifacts;
|
|
@@ -3172,11 +3250,14 @@ async function persistThreadState(thread, patch) {
|
|
|
3172
3250
|
await persistThreadRuntimeState(thread, patch);
|
|
3173
3251
|
}
|
|
3174
3252
|
async function persistThreadRuntimeState(thread, patch) {
|
|
3175
|
-
const
|
|
3176
|
-
if (
|
|
3177
|
-
|
|
3253
|
+
const threadId = toOptionalString(thread.id) ?? toOptionalString(thread.runId);
|
|
3254
|
+
if (!threadId) {
|
|
3255
|
+
throw new Error("thread id is required to persist runtime scratch");
|
|
3178
3256
|
}
|
|
3179
|
-
await
|
|
3257
|
+
await mergePersistedState(
|
|
3258
|
+
threadStateKey(threadId),
|
|
3259
|
+
buildThreadStatePayload(patch)
|
|
3260
|
+
);
|
|
3180
3261
|
}
|
|
3181
3262
|
async function getPersistedThreadState(threadId) {
|
|
3182
3263
|
const stateAdapter = getStateAdapter();
|
|
@@ -3199,26 +3280,21 @@ async function persistThreadStateById(threadId, patch) {
|
|
|
3199
3280
|
conversationId: threadId
|
|
3200
3281
|
});
|
|
3201
3282
|
}
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
}
|
|
3206
|
-
const stateAdapter = getStateAdapter();
|
|
3207
|
-
await stateAdapter.connect();
|
|
3208
|
-
const key = threadStateKey(threadId);
|
|
3209
|
-
const existing = await stateAdapter.get(key) ?? {};
|
|
3210
|
-
await stateAdapter.set(
|
|
3211
|
-
key,
|
|
3212
|
-
{ ...existing, ...payload },
|
|
3213
|
-
JUNIOR_THREAD_STATE_TTL_MS
|
|
3283
|
+
await mergePersistedState(
|
|
3284
|
+
threadStateKey(threadId),
|
|
3285
|
+
buildThreadStatePayload(patch)
|
|
3214
3286
|
);
|
|
3215
3287
|
}
|
|
3216
3288
|
function getChannelConfigurationService(thread) {
|
|
3217
3289
|
const channel = thread.channel;
|
|
3290
|
+
const channelId = toOptionalString(thread.channelId) ?? toOptionalString(channel.id);
|
|
3291
|
+
if (!channelId) {
|
|
3292
|
+
throw new Error("channel id is required to load channel configuration");
|
|
3293
|
+
}
|
|
3218
3294
|
return createChannelConfigurationService({
|
|
3219
|
-
load: async () => channel.state,
|
|
3295
|
+
load: async () => await channel.state,
|
|
3220
3296
|
save: async (state) => {
|
|
3221
|
-
await
|
|
3297
|
+
await mergePersistedState(channelStateKey(channelId), {
|
|
3222
3298
|
configuration: state
|
|
3223
3299
|
});
|
|
3224
3300
|
}
|
|
@@ -3228,15 +3304,9 @@ function getChannelConfigurationServiceById(channelId) {
|
|
|
3228
3304
|
return createChannelConfigurationService({
|
|
3229
3305
|
load: async () => await getPersistedChannelState(channelId),
|
|
3230
3306
|
save: async (state) => {
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
const existing = await stateAdapter.get(key) ?? {};
|
|
3235
|
-
await stateAdapter.set(
|
|
3236
|
-
key,
|
|
3237
|
-
{ ...existing, configuration: state },
|
|
3238
|
-
JUNIOR_THREAD_STATE_TTL_MS
|
|
3239
|
-
);
|
|
3307
|
+
await mergePersistedState(channelStateKey(channelId), {
|
|
3308
|
+
configuration: state
|
|
3309
|
+
});
|
|
3240
3310
|
}
|
|
3241
3311
|
});
|
|
3242
3312
|
}
|
|
@@ -3349,6 +3419,7 @@ export {
|
|
|
3349
3419
|
recordAuthorizationRequested,
|
|
3350
3420
|
recordAuthorizationCompleted,
|
|
3351
3421
|
recordAuthenticationLinked,
|
|
3422
|
+
recordAgentsInstructionsUpdated,
|
|
3352
3423
|
loadTurnRoute,
|
|
3353
3424
|
recordTurnRoute,
|
|
3354
3425
|
recordToolExecutionStarted,
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveBaseUrl
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DK3GQWJK.js";
|
|
4
4
|
import {
|
|
5
5
|
createPluginLogger,
|
|
6
6
|
getPlugins
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-7ULXCNOZ.js";
|
|
8
8
|
import {
|
|
9
9
|
getDb,
|
|
10
10
|
parseDestination
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-5MFCEKR6.js";
|
|
12
12
|
import {
|
|
13
13
|
sleep
|
|
14
14
|
} from "./chunk-EM225ITJ.js";
|
|
15
15
|
import {
|
|
16
16
|
acquireActiveLock,
|
|
17
17
|
getStateAdapter
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-6U44QGXL.js";
|
|
19
19
|
import {
|
|
20
20
|
pluginCatalogRuntime
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-EYD523BV.js";
|
|
22
22
|
import {
|
|
23
23
|
fetchWithBoundedOAuthErrorBodies
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-LMGKSDO4.js";
|
|
25
25
|
import {
|
|
26
26
|
isRecord
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-UFEU4UX6.js";
|
|
28
28
|
|
|
29
29
|
// src/chat/capabilities/router.ts
|
|
30
30
|
var ProviderCredentialRouter = class {
|
package/dist/cli/chat.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAgentRunner,
|
|
3
3
|
executeAgentRun
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-OHO46E7F.js";
|
|
5
|
+
import "../chunk-H4WNQFBH.js";
|
|
6
6
|
import "../chunk-DIB4GX3G.js";
|
|
7
|
-
import "../chunk-
|
|
7
|
+
import "../chunk-UONUDOJP.js";
|
|
8
8
|
import "../chunk-R776HKPK.js";
|
|
9
|
-
import "../chunk-
|
|
10
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-DK3GQWJK.js";
|
|
10
|
+
import "../chunk-PIQKV7IR.js";
|
|
11
11
|
import "../chunk-3Y47VMHV.js";
|
|
12
12
|
import "../chunk-HUO3UTAQ.js";
|
|
13
13
|
import "../chunk-5IDFPCON.js";
|
|
14
|
-
import "../chunk-
|
|
15
|
-
import "../chunk-
|
|
16
|
-
import "../chunk-
|
|
17
|
-
import "../chunk-
|
|
14
|
+
import "../chunk-FZFJZZR3.js";
|
|
15
|
+
import "../chunk-5LPWHC7Q.js";
|
|
16
|
+
import "../chunk-HQAFIN6O.js";
|
|
17
|
+
import "../chunk-HLXXQI5Q.js";
|
|
18
18
|
import "../chunk-PDO5BLNM.js";
|
|
19
19
|
import "../chunk-UIE3R5XU.js";
|
|
20
20
|
import {
|
|
21
21
|
loadAppPluginSet
|
|
22
22
|
} from "../chunk-Y2CM7HXH.js";
|
|
23
|
-
import "../chunk-
|
|
24
|
-
import "../chunk-
|
|
25
|
-
import "../chunk-
|
|
26
|
-
import "../chunk-
|
|
23
|
+
import "../chunk-7ULXCNOZ.js";
|
|
24
|
+
import "../chunk-DVIJ6DP6.js";
|
|
25
|
+
import "../chunk-5MFCEKR6.js";
|
|
26
|
+
import "../chunk-3H42HMA2.js";
|
|
27
27
|
import "../chunk-EM225ITJ.js";
|
|
28
|
-
import "../chunk-
|
|
29
|
-
import "../chunk-
|
|
28
|
+
import "../chunk-6U44QGXL.js";
|
|
29
|
+
import "../chunk-BBLO66XT.js";
|
|
30
30
|
import "../chunk-VFUK3X5B.js";
|
|
31
|
-
import "../chunk-
|
|
32
|
-
import "../chunk-
|
|
33
|
-
import "../chunk-
|
|
34
|
-
import "../chunk-
|
|
31
|
+
import "../chunk-PGJUJCOQ.js";
|
|
32
|
+
import "../chunk-6FRAWWGR.js";
|
|
33
|
+
import "../chunk-EYD523BV.js";
|
|
34
|
+
import "../chunk-LMGKSDO4.js";
|
|
35
35
|
import "../chunk-RUIXF3YQ.js";
|
|
36
36
|
import "../chunk-HZF5P5UN.js";
|
|
37
37
|
import "../chunk-F3B2YJ76.js";
|
|
38
|
-
import "../chunk-
|
|
38
|
+
import "../chunk-UFEU4UX6.js";
|
|
39
39
|
import "../chunk-6GWA276C.js";
|
|
40
40
|
import "../chunk-OOUNJNMR.js";
|
|
41
41
|
import "../chunk-H4HBKISO.js";
|
|
42
|
-
import "../chunk-
|
|
43
|
-
import "../chunk-
|
|
42
|
+
import "../chunk-OFQBDHVG.js";
|
|
43
|
+
import "../chunk-43OPSFUY.js";
|
|
44
44
|
import "../chunk-MLKGABMK.js";
|
|
45
45
|
|
|
46
46
|
// src/cli/chat.ts
|
|
@@ -163,10 +163,10 @@ async function configureLocalChatPlugins(pluginSet) {
|
|
|
163
163
|
databaseModule
|
|
164
164
|
] = await Promise.all([
|
|
165
165
|
import("../plugins-HW4VWW6G.js"),
|
|
166
|
-
import("../agent-hooks-
|
|
167
|
-
import("../catalog-runtime-
|
|
168
|
-
import("../validation-
|
|
169
|
-
import("../db-
|
|
166
|
+
import("../agent-hooks-HIRVKUQJ.js"),
|
|
167
|
+
import("../catalog-runtime-XVLED5UH.js"),
|
|
168
|
+
import("../validation-XLXAIRTR.js"),
|
|
169
|
+
import("../db-PSMQZR4P.js")
|
|
170
170
|
]);
|
|
171
171
|
const resolvedPluginSet = pluginSet === void 0 ? await loadLocalPluginSet() : pluginSet ?? void 0;
|
|
172
172
|
const plugins = pluginsModule.pluginRuntimeRegistrationsFromPluginSet(resolvedPluginSet);
|
|
@@ -232,14 +232,14 @@ async function prepareLocalChatRun(io, pluginSet) {
|
|
|
232
232
|
await configureLocalChatPlugins(pluginSet);
|
|
233
233
|
const { setExperimentalFeatures } = await import("../experimental-HH6OM6UH.js");
|
|
234
234
|
setExperimentalFeatures({ subagents: true });
|
|
235
|
-
const { runLocalAgentTurn } = await import("../runner-
|
|
236
|
-
const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-
|
|
235
|
+
const { runLocalAgentTurn } = await import("../runner-5EKJCQWP.js");
|
|
236
|
+
const { startLocalOAuthCallbackServer } = await import("../oauth-callback-server-XZUK2AT6.js");
|
|
237
237
|
const { createLocalOAuthState } = await import("../oauth-relay-3ZU72UGL.js");
|
|
238
238
|
const { createLocalSandboxEgressSignalTransport } = await import("../sandbox-egress-signals-EKPAVWQL.js");
|
|
239
|
-
const { bindSpawnAgent } = await import("../spawn-
|
|
240
|
-
const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-
|
|
239
|
+
const { bindSpawnAgent } = await import("../spawn-UGTLRTFP.js");
|
|
240
|
+
const { createAgentInvocationWorker, routeAgentInvocationWork } = await import("../work-CNTNEQ2Q.js");
|
|
241
241
|
const { createLocalConversationWork } = await import("../conversation-work-KATFHLG3.js");
|
|
242
|
-
const { processConversationWork } = await import("../worker-
|
|
242
|
+
const { processConversationWork } = await import("../worker-BGW7CKZ7.js");
|
|
243
243
|
let agentRunner;
|
|
244
244
|
const localConversationWork = createLocalConversationWork(async (message) => {
|
|
245
245
|
if (!agentRunner) {
|