openmates 0.14.8-alpha.17 → 0.14.8-alpha.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/{chunk-6M52O6HO.js → chunk-KU5TSXQO.js} +228 -569
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -1214,42 +1214,6 @@ function websocketProtocolError(envelope) {
|
|
|
1214
1214
|
}
|
|
1215
1215
|
return null;
|
|
1216
1216
|
}
|
|
1217
|
-
function errorFrameBelongsToAiResponse(envelope, userMessageId, chatId, recoveryTurnId) {
|
|
1218
|
-
if (envelope.type === "client_update_required") return true;
|
|
1219
|
-
if (envelope.type !== "error") return true;
|
|
1220
|
-
const payload = envelope.payload && typeof envelope.payload === "object" ? envelope.payload : {};
|
|
1221
|
-
let scoped = false;
|
|
1222
|
-
const errorChatId = typeof payload.chat_id === "string" ? payload.chat_id : null;
|
|
1223
|
-
if (errorChatId) {
|
|
1224
|
-
scoped = true;
|
|
1225
|
-
if (errorChatId !== chatId) return false;
|
|
1226
|
-
}
|
|
1227
|
-
const errorMessageId = typeof payload.user_message_id === "string" ? payload.user_message_id : typeof payload.userMessageId === "string" ? payload.userMessageId : typeof payload.message_id === "string" ? payload.message_id : null;
|
|
1228
|
-
if (errorMessageId) {
|
|
1229
|
-
scoped = true;
|
|
1230
|
-
if (errorMessageId !== userMessageId) return false;
|
|
1231
|
-
}
|
|
1232
|
-
const errorTurnId = typeof payload.turn_id === "string" ? payload.turn_id : null;
|
|
1233
|
-
if (errorTurnId) {
|
|
1234
|
-
scoped = true;
|
|
1235
|
-
if (recoveryTurnId !== errorTurnId) return false;
|
|
1236
|
-
}
|
|
1237
|
-
if (typeof payload.job_id === "string") {
|
|
1238
|
-
scoped = true;
|
|
1239
|
-
}
|
|
1240
|
-
return !scoped || Boolean(errorChatId || errorMessageId || errorTurnId);
|
|
1241
|
-
}
|
|
1242
|
-
function scopedErrorMissesPredicate(envelope, predicate) {
|
|
1243
|
-
if (envelope.type !== "error" || !predicate) return false;
|
|
1244
|
-
const payload = envelope.payload && typeof envelope.payload === "object" ? envelope.payload : {};
|
|
1245
|
-
const hasScope = typeof payload.turn_id === "string" || typeof payload.chat_id === "string" || typeof payload.message_id === "string" || typeof payload.user_message_id === "string" || typeof payload.userMessageId === "string" || typeof payload.job_id === "string";
|
|
1246
|
-
if (!hasScope) return false;
|
|
1247
|
-
try {
|
|
1248
|
-
return !predicate(payload);
|
|
1249
|
-
} catch {
|
|
1250
|
-
return false;
|
|
1251
|
-
}
|
|
1252
|
-
}
|
|
1253
1217
|
function parseTaskProposals(value) {
|
|
1254
1218
|
if (!Array.isArray(value)) return [];
|
|
1255
1219
|
return value.flatMap((item) => {
|
|
@@ -1314,21 +1278,6 @@ function parsePendingTaskUpdateJobs(value) {
|
|
|
1314
1278
|
return [job];
|
|
1315
1279
|
});
|
|
1316
1280
|
}
|
|
1317
|
-
function parseAvailableRecoveryJobs(value) {
|
|
1318
|
-
if (!Array.isArray(value)) return [];
|
|
1319
|
-
return value.flatMap((item) => {
|
|
1320
|
-
if (!item || typeof item !== "object" || Array.isArray(item)) return [];
|
|
1321
|
-
const raw = item;
|
|
1322
|
-
if (typeof raw.job_id !== "string" || typeof raw.chat_id !== "string" || typeof raw.turn_id !== "string" || typeof raw.assistant_message_id !== "string" || typeof raw.chat_key_version !== "number") return [];
|
|
1323
|
-
return [{
|
|
1324
|
-
job_id: raw.job_id,
|
|
1325
|
-
chat_id: raw.chat_id,
|
|
1326
|
-
turn_id: raw.turn_id,
|
|
1327
|
-
assistant_message_id: raw.assistant_message_id,
|
|
1328
|
-
chat_key_version: raw.chat_key_version
|
|
1329
|
-
}];
|
|
1330
|
-
});
|
|
1331
|
-
}
|
|
1332
1281
|
var OpenMatesWsClient = class {
|
|
1333
1282
|
socket;
|
|
1334
1283
|
passiveTaskUpdateJobs = /* @__PURE__ */ new Map();
|
|
@@ -1429,7 +1378,6 @@ var OpenMatesWsClient = class {
|
|
|
1429
1378
|
if (typeof parsed.type === "string") seenTypes.add(parsed.type);
|
|
1430
1379
|
const protocolError = websocketProtocolError(parsed);
|
|
1431
1380
|
if (protocolError) {
|
|
1432
|
-
if (scopedErrorMissesPredicate(parsed, predicate)) return;
|
|
1433
1381
|
cleanup();
|
|
1434
1382
|
reject(protocolError);
|
|
1435
1383
|
return;
|
|
@@ -1634,7 +1582,6 @@ var OpenMatesWsClient = class {
|
|
|
1634
1582
|
return;
|
|
1635
1583
|
}
|
|
1636
1584
|
if (!aiResponseDone || !postProcessingDone) return;
|
|
1637
|
-
if (options?.recoveryTurnId && !recoveryJobId) return;
|
|
1638
1585
|
if (pendingSubChatHandlers.size > 0) return;
|
|
1639
1586
|
if (pendingMemoryRequestHandlers.size > 0) return;
|
|
1640
1587
|
if (processingEmbedIds.size > 0 && !asyncEmbedTimer) {
|
|
@@ -1751,9 +1698,6 @@ var OpenMatesWsClient = class {
|
|
|
1751
1698
|
const type = parsed.type;
|
|
1752
1699
|
const protocolError = websocketProtocolError(parsed);
|
|
1753
1700
|
if (protocolError) {
|
|
1754
|
-
if (!errorFrameBelongsToAiResponse(parsed, userMessageId, chatId, options?.recoveryTurnId)) {
|
|
1755
|
-
return;
|
|
1756
|
-
}
|
|
1757
1701
|
cleanup();
|
|
1758
1702
|
reject(protocolError);
|
|
1759
1703
|
return;
|
|
@@ -1796,17 +1740,6 @@ var OpenMatesWsClient = class {
|
|
|
1796
1740
|
maybeResolve();
|
|
1797
1741
|
return;
|
|
1798
1742
|
}
|
|
1799
|
-
if (type === "recovery_jobs_available") {
|
|
1800
|
-
const job = parseAvailableRecoveryJobs(p.jobs).find(
|
|
1801
|
-
(candidate) => candidate.chat_id === chatId && (!options?.recoveryTurnId || candidate.turn_id === options.recoveryTurnId)
|
|
1802
|
-
);
|
|
1803
|
-
if (!job) return;
|
|
1804
|
-
recoveryJobId = job.job_id;
|
|
1805
|
-
messageId = job.assistant_message_id;
|
|
1806
|
-
if (aiResponseDone) maybeResolve();
|
|
1807
|
-
else scheduleResolve(latestContent);
|
|
1808
|
-
return;
|
|
1809
|
-
}
|
|
1810
1743
|
if (type === "ai_message_update") {
|
|
1811
1744
|
const msgId = p.user_message_id ?? p.userMessageId;
|
|
1812
1745
|
if (msgId !== userMessageId && p.chat_id !== chatId) return;
|
|
@@ -1990,9 +1923,6 @@ function extractMentionTokens(message) {
|
|
|
1990
1923
|
function isFilePath(token) {
|
|
1991
1924
|
return token.startsWith("/") || token.startsWith("./") || token.startsWith("~/") || token.startsWith("../");
|
|
1992
1925
|
}
|
|
1993
|
-
function isTaskShortIdMention(token) {
|
|
1994
|
-
return /^TASK-[A-Za-z0-9_-]+[.,;:!?)]?$/.test(token);
|
|
1995
|
-
}
|
|
1996
1926
|
function normalize(name) {
|
|
1997
1927
|
return name.toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9._-]/g, "");
|
|
1998
1928
|
}
|
|
@@ -2172,9 +2102,6 @@ function parseMentions(message, context) {
|
|
|
2172
2102
|
filePaths.push(token);
|
|
2173
2103
|
continue;
|
|
2174
2104
|
}
|
|
2175
|
-
if (isTaskShortIdMention(token)) {
|
|
2176
|
-
continue;
|
|
2177
|
-
}
|
|
2178
2105
|
const resolved_ = resolveToken(token, context);
|
|
2179
2106
|
if (resolved_) {
|
|
2180
2107
|
resolved.push(resolved_);
|
|
@@ -3076,28 +3003,18 @@ async function buildTaskEventSystemMessage(params) {
|
|
|
3076
3003
|
if (params.event.task_update_job_id) message.task_update_job_id = params.event.task_update_job_id;
|
|
3077
3004
|
return message;
|
|
3078
3005
|
}
|
|
3079
|
-
function taskUpdateJobBelongsToActiveTurn(job, activeChatId, taskEvents) {
|
|
3080
|
-
void activeChatId;
|
|
3081
|
-
return taskEvents.some((event) => event.task_update_job_id === job.job_id);
|
|
3082
|
-
}
|
|
3083
3006
|
function buildTaskUpdateJobPersistPayload(params) {
|
|
3084
|
-
|
|
3085
|
-
assertTaskPersistPayloadEncrypted(encryptedTaskPayload);
|
|
3007
|
+
assertTaskPersistPayloadEncrypted(params.encryptedTaskPayload);
|
|
3086
3008
|
return {
|
|
3087
3009
|
protocol_version: 1,
|
|
3088
3010
|
job_id: params.jobId,
|
|
3089
3011
|
lease_token: params.leaseToken,
|
|
3090
3012
|
lease_generation: params.leaseGeneration,
|
|
3091
3013
|
expected_task_version: params.expectedTaskVersion,
|
|
3092
|
-
encrypted_task_payload: encryptedTaskPayload,
|
|
3014
|
+
encrypted_task_payload: { ...params.encryptedTaskPayload },
|
|
3093
3015
|
encrypted_task_event_message: params.encryptedTaskEventMessage ?? null
|
|
3094
3016
|
};
|
|
3095
3017
|
}
|
|
3096
|
-
function pruneAbsentTaskPersistFields(payload) {
|
|
3097
|
-
return Object.fromEntries(
|
|
3098
|
-
Object.entries(payload).filter(([, value]) => value !== void 0 && value !== null)
|
|
3099
|
-
);
|
|
3100
|
-
}
|
|
3101
3018
|
function formatTaskEventSystemContent(event) {
|
|
3102
3019
|
const taskLabel = event.short_id || event.task_id;
|
|
3103
3020
|
const title = event.title ? ` "${event.title}"` : "";
|
|
@@ -3594,8 +3511,7 @@ var CLOUD_API_URL = "https://api.openmates.org";
|
|
|
3594
3511
|
var DEFAULT_API_URL = process.env.OPENMATES_API_URL ?? CLOUD_API_URL;
|
|
3595
3512
|
var SETTINGS_GET_RATE_LIMIT_RETRY_MS = 61e3;
|
|
3596
3513
|
var SKILL_TASK_POLL_INTERVAL_MS = 2e3;
|
|
3597
|
-
var SKILL_TASK_POLL_TIMEOUT_MS =
|
|
3598
|
-
var SKILL_TASK_POLL_TRANSIENT_ERROR_STATUS = 500;
|
|
3514
|
+
var SKILL_TASK_POLL_TIMEOUT_MS = 3e5;
|
|
3599
3515
|
function normalizeOrigin(url) {
|
|
3600
3516
|
url.pathname = "";
|
|
3601
3517
|
url.search = "";
|
|
@@ -5073,7 +4989,7 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
5073
4989
|
if (encryptedEmbeds.length > 0) {
|
|
5074
4990
|
messagePayload.encrypted_embeds = encryptedEmbeds;
|
|
5075
4991
|
}
|
|
5076
|
-
let precollectedResponse = params.precollectResponse && params.incognito ? ws.collectAiResponse(messageId, chatId, { onStream: params.onStream
|
|
4992
|
+
let precollectedResponse = params.precollectResponse && params.incognito ? ws.collectAiResponse(messageId, chatId, { onStream: params.onStream }) : null;
|
|
5077
4993
|
if (!params.incognito && chatKeyBytes && encryptedChatKey) {
|
|
5078
4994
|
const protocolVersion = 1;
|
|
5079
4995
|
const chatKeyVersion = 1;
|
|
@@ -5128,10 +5044,7 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
5128
5044
|
updated_at: createdAt
|
|
5129
5045
|
};
|
|
5130
5046
|
}
|
|
5131
|
-
const preflightAck = ws.waitForMessage(
|
|
5132
|
-
"chat_turn_preflight_ack",
|
|
5133
|
-
(payload) => payload.turn_id === turnId
|
|
5134
|
-
);
|
|
5047
|
+
const preflightAck = ws.waitForMessage("chat_turn_preflight_ack");
|
|
5135
5048
|
let ackPayload;
|
|
5136
5049
|
try {
|
|
5137
5050
|
await ws.sendAsync("chat_turn_preflight", preflightPayload);
|
|
@@ -5154,9 +5067,7 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
5154
5067
|
}
|
|
5155
5068
|
if (params.precollectResponse && !params.incognito) {
|
|
5156
5069
|
precollectedResponse = ws.collectAiResponse(messageId, chatId, {
|
|
5157
|
-
onStream: params.onStream
|
|
5158
|
-
timeoutMs: params.responseTimeoutMs,
|
|
5159
|
-
recoveryTurnId: savedTurnId
|
|
5070
|
+
onStream: params.onStream
|
|
5160
5071
|
});
|
|
5161
5072
|
}
|
|
5162
5073
|
const confirmed = ws.waitForMessage(
|
|
@@ -5168,7 +5079,10 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
5168
5079
|
2e4
|
|
5169
5080
|
);
|
|
5170
5081
|
await ws.sendAsync("chat_message_added", messagePayload);
|
|
5171
|
-
await confirmed;
|
|
5082
|
+
const confirmedPayload = (await confirmed).payload;
|
|
5083
|
+
if (typeof confirmedPayload.new_messages_v === "number" && Number.isSafeInteger(confirmedPayload.new_messages_v)) {
|
|
5084
|
+
terminalExpectedMessagesV = confirmedPayload.new_messages_v + 1;
|
|
5085
|
+
}
|
|
5172
5086
|
let assistant = "";
|
|
5173
5087
|
let assistantMessageId = null;
|
|
5174
5088
|
let category = null;
|
|
@@ -5340,22 +5254,219 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
5340
5254
|
`The assistant requested memories (${event.requestedKeys.join(", ")}). Rerun with --auto-approve-memories to explicitly approve requested memory categories from the CLI, or continue this chat in the web app to approve or reject the request.`
|
|
5341
5255
|
);
|
|
5342
5256
|
};
|
|
5257
|
+
const persistEncryptedSystemMessage = async (systemMessage, targetChatId = chatId) => {
|
|
5258
|
+
await ws.sendAsync("chat_system_message_added", {
|
|
5259
|
+
chat_id: targetChatId,
|
|
5260
|
+
message: systemMessage
|
|
5261
|
+
});
|
|
5262
|
+
await ws.waitForMessage(
|
|
5263
|
+
"system_message_confirmed",
|
|
5264
|
+
(payload) => payload.message_id === systemMessage.message_id,
|
|
5265
|
+
2e4
|
|
5266
|
+
);
|
|
5267
|
+
};
|
|
5343
5268
|
const persistedTaskEventIds = /* @__PURE__ */ new Set();
|
|
5344
5269
|
const persistTaskEventSystemMessages = async (events) => {
|
|
5345
5270
|
if (!chatKeyBytes || events.length === 0) return;
|
|
5346
5271
|
for (const event of events) {
|
|
5347
5272
|
if (persistedTaskEventIds.has(event.event_id)) continue;
|
|
5348
|
-
await
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5273
|
+
await persistEncryptedSystemMessage(await buildTaskEventSystemMessage({
|
|
5274
|
+
chatKey: chatKeyBytes,
|
|
5275
|
+
userMessageId: messageId,
|
|
5276
|
+
event
|
|
5277
|
+
}));
|
|
5278
|
+
persistedTaskEventIds.add(event.event_id);
|
|
5279
|
+
}
|
|
5280
|
+
};
|
|
5281
|
+
const persistPendingTaskUpdateJobs = async (jobs, events) => {
|
|
5282
|
+
const persistedJobIds = /* @__PURE__ */ new Set();
|
|
5283
|
+
if (jobs.length === 0) return persistedJobIds;
|
|
5284
|
+
const masterKey = this.getMasterKeyBytes();
|
|
5285
|
+
let decryptedTasksCache = null;
|
|
5286
|
+
const eventByJobId = new Map(events.map((event) => [event.task_update_job_id, event]));
|
|
5287
|
+
const buildTaskKeyWrappersForChat = async (task, targetChatId, createdAt2) => {
|
|
5288
|
+
const encryptedTaskKey = task.encrypted.encrypted_task_key;
|
|
5289
|
+
if (!encryptedTaskKey) throw new Error(`Task ${task.taskId} is missing encrypted task key.`);
|
|
5290
|
+
const taskKey = await decryptBytesWithAesGcm(encryptedTaskKey, masterKey);
|
|
5291
|
+
if (!taskKey) throw new Error(`Failed to decrypt task key for ${task.taskId}.`);
|
|
5292
|
+
const targetChatKey = await resolveChatKey(targetChatId);
|
|
5293
|
+
const existingProjectWrappers = await listProjectTaskKeyWrappers(task.taskId, createdAt2);
|
|
5294
|
+
const linkedProjectIds = task.linkedProjectIds ?? [];
|
|
5295
|
+
if (linkedProjectIds.length > existingProjectWrappers.length) {
|
|
5296
|
+
throw new Error(`Task ${task.taskId} is missing project key wrappers required for move persistence.`);
|
|
5297
|
+
}
|
|
5298
|
+
return [
|
|
5299
|
+
{
|
|
5300
|
+
key_type: "master",
|
|
5301
|
+
encrypted_task_key: await encryptBytesWithAesGcm(taskKey, masterKey),
|
|
5302
|
+
created_at: createdAt2
|
|
5303
|
+
},
|
|
5304
|
+
{
|
|
5305
|
+
key_type: "chat",
|
|
5306
|
+
hashed_chat_id: computeSHA256(targetChatId),
|
|
5307
|
+
encrypted_task_key: await encryptBytesWithAesGcm(taskKey, targetChatKey),
|
|
5308
|
+
created_at: createdAt2
|
|
5309
|
+
},
|
|
5310
|
+
...existingProjectWrappers
|
|
5311
|
+
];
|
|
5312
|
+
};
|
|
5313
|
+
const listProjectTaskKeyWrappers = async (taskId, createdAt2) => {
|
|
5314
|
+
const response = await this.http.get(
|
|
5315
|
+
`/v1/user-tasks/${encodeURIComponent(taskId)}/key-wrappers`,
|
|
5316
|
+
this.getCliRequestHeaders()
|
|
5317
|
+
);
|
|
5318
|
+
if (!response.ok) {
|
|
5319
|
+
throw new Error(`User task key wrapper list failed with HTTP ${response.status}`);
|
|
5320
|
+
}
|
|
5321
|
+
return (response.data.key_wrappers ?? []).filter((wrapper) => wrapper.key_type === "project").map((wrapper) => ({
|
|
5322
|
+
key_type: "project",
|
|
5323
|
+
hashed_project_id: wrapper.hashed_project_id,
|
|
5324
|
+
encrypted_task_key: wrapper.encrypted_task_key,
|
|
5325
|
+
created_at: typeof wrapper.created_at === "number" ? wrapper.created_at : createdAt2,
|
|
5326
|
+
expires_at: wrapper.expires_at ?? null
|
|
5327
|
+
}));
|
|
5328
|
+
};
|
|
5329
|
+
const resolveChatKey = async (targetChatId) => {
|
|
5330
|
+
if (targetChatId === chatId && chatKeyBytes) return chatKeyBytes;
|
|
5331
|
+
const cache = loadSyncCache() ?? await this.ensureSynced();
|
|
5332
|
+
const targetChat = cache.chats.find((chat) => String(chat.details.id ?? "") === targetChatId);
|
|
5333
|
+
const encryptedTargetChatKey = typeof targetChat?.details.encrypted_chat_key === "string" ? targetChat.details.encrypted_chat_key : null;
|
|
5334
|
+
if (!encryptedTargetChatKey) {
|
|
5335
|
+
throw new Error(`Encrypted chat key not found for task move target '${targetChatId}'. Sync and try again.`);
|
|
5336
|
+
}
|
|
5337
|
+
const targetChatKey = await decryptBytesWithAesGcm(encryptedTargetChatKey, masterKey);
|
|
5338
|
+
if (!targetChatKey) {
|
|
5339
|
+
throw new Error(`Failed to decrypt chat key for task move target '${targetChatId}'.`);
|
|
5340
|
+
}
|
|
5341
|
+
return targetChatKey;
|
|
5342
|
+
};
|
|
5343
|
+
const taskEventTypeForOperation = (operation) => {
|
|
5344
|
+
switch (operation) {
|
|
5345
|
+
case "create":
|
|
5346
|
+
return "created";
|
|
5347
|
+
case "move":
|
|
5348
|
+
return "moved";
|
|
5349
|
+
case "update":
|
|
5350
|
+
return "updated";
|
|
5351
|
+
default:
|
|
5352
|
+
return operation || "updated";
|
|
5353
|
+
}
|
|
5354
|
+
};
|
|
5355
|
+
for (const job of jobs) {
|
|
5356
|
+
const claimPromise = ws.waitForMessage(
|
|
5357
|
+
"task_update_job_claimed",
|
|
5358
|
+
(payload) => payload.job_id === job.job_id,
|
|
5359
|
+
2e4
|
|
5356
5360
|
);
|
|
5361
|
+
await ws.sendAsync("task_update_job_claim", {
|
|
5362
|
+
protocol_version: 1,
|
|
5363
|
+
job_id: job.job_id
|
|
5364
|
+
});
|
|
5365
|
+
const claim = (await claimPromise).payload;
|
|
5366
|
+
const privatePatch = claim.private_patch ?? {};
|
|
5367
|
+
const safeMetadata = claim.safe_metadata ?? {};
|
|
5368
|
+
const sourceChatId = claim.chat_id ?? job.chat_id ?? chatId;
|
|
5369
|
+
const sourceChatKey = await resolveChatKey(sourceChatId);
|
|
5370
|
+
const event = eventByJobId.get(job.job_id) ?? {
|
|
5371
|
+
event_id: `task-event-${job.job_id}`,
|
|
5372
|
+
chat_id: sourceChatId,
|
|
5373
|
+
task_id: claim.task_id,
|
|
5374
|
+
event_type: taskEventTypeForOperation(claim.operation),
|
|
5375
|
+
title: typeof privatePatch.title === "string" ? privatePatch.title : null,
|
|
5376
|
+
status: typeof safeMetadata.status === "string" ? safeMetadata.status : null,
|
|
5377
|
+
created_at: typeof safeMetadata.updated_at === "number" ? safeMetadata.updated_at : Math.floor(Date.now() / 1e3),
|
|
5378
|
+
task_update_job_id: job.job_id
|
|
5379
|
+
};
|
|
5380
|
+
const eventMessage = await buildTaskEventSystemMessage({
|
|
5381
|
+
chatKey: sourceChatKey,
|
|
5382
|
+
userMessageId: claim.message_id ?? messageId,
|
|
5383
|
+
event
|
|
5384
|
+
});
|
|
5385
|
+
const confirmTaskEventPersisted = async () => {
|
|
5386
|
+
const confirmedPromise = ws.waitForMessage(
|
|
5387
|
+
"task_update_job_event_confirmed",
|
|
5388
|
+
(payload) => payload.job_id === job.job_id,
|
|
5389
|
+
2e4
|
|
5390
|
+
);
|
|
5391
|
+
await ws.sendAsync("task_update_job_event_confirmed", {
|
|
5392
|
+
protocol_version: 1,
|
|
5393
|
+
job_id: job.job_id,
|
|
5394
|
+
event_system_message_id: eventMessage.message_id
|
|
5395
|
+
});
|
|
5396
|
+
await confirmedPromise;
|
|
5397
|
+
};
|
|
5398
|
+
if (claim.state === "TASK_PERSISTED") {
|
|
5399
|
+
await persistEncryptedSystemMessage(eventMessage, sourceChatId);
|
|
5400
|
+
persistedTaskEventIds.add(event.event_id);
|
|
5401
|
+
await confirmTaskEventPersisted();
|
|
5402
|
+
persistedJobIds.add(job.job_id);
|
|
5403
|
+
continue;
|
|
5404
|
+
}
|
|
5405
|
+
if (!claim.lease_token || !Number.isSafeInteger(claim.lease_generation)) {
|
|
5406
|
+
throw new Error("Task update job claim returned an invalid lease.");
|
|
5407
|
+
}
|
|
5408
|
+
let encryptedTaskPayload;
|
|
5409
|
+
if (claim.operation === "create") {
|
|
5410
|
+
const input = await buildCreateUserTaskInput(masterKey, {
|
|
5411
|
+
title: typeof privatePatch.title === "string" ? privatePatch.title : "Untitled task",
|
|
5412
|
+
description: typeof privatePatch.description === "string" ? privatePatch.description : "",
|
|
5413
|
+
status: typeof safeMetadata.status === "string" ? safeMetadata.status : "todo",
|
|
5414
|
+
assign: typeof safeMetadata.assignee_type === "string" ? safeMetadata.assignee_type : "user",
|
|
5415
|
+
chatId: typeof safeMetadata.primary_chat_id === "string" ? safeMetadata.primary_chat_id : claim.chat_id ?? chatId
|
|
5416
|
+
});
|
|
5417
|
+
encryptedTaskPayload = {
|
|
5418
|
+
...input,
|
|
5419
|
+
task_id: claim.task_id,
|
|
5420
|
+
position: typeof safeMetadata.position === "number" ? safeMetadata.position : input.position,
|
|
5421
|
+
created_at: typeof safeMetadata.created_at === "number" ? safeMetadata.created_at : input.created_at,
|
|
5422
|
+
updated_at: typeof safeMetadata.updated_at === "number" ? safeMetadata.updated_at : input.updated_at
|
|
5423
|
+
};
|
|
5424
|
+
} else {
|
|
5425
|
+
if (!decryptedTasksCache) {
|
|
5426
|
+
decryptedTasksCache = await decryptUserTasks(await this.listUserTasks(), masterKey);
|
|
5427
|
+
}
|
|
5428
|
+
const task = findTask(decryptedTasksCache, claim.task_id);
|
|
5429
|
+
const patch = await buildUpdateUserTaskInput(task, masterKey, {
|
|
5430
|
+
title: typeof privatePatch.title === "string" ? privatePatch.title : void 0,
|
|
5431
|
+
description: typeof privatePatch.description === "string" ? privatePatch.description : void 0,
|
|
5432
|
+
status: typeof safeMetadata.status === "string" ? safeMetadata.status : void 0,
|
|
5433
|
+
assign: typeof safeMetadata.assignee_type === "string" ? safeMetadata.assignee_type : void 0,
|
|
5434
|
+
chatId: typeof safeMetadata.primary_chat_id === "string" ? safeMetadata.primary_chat_id : void 0
|
|
5435
|
+
});
|
|
5436
|
+
encryptedTaskPayload = {
|
|
5437
|
+
...patch,
|
|
5438
|
+
updated_at: typeof safeMetadata.updated_at === "number" ? safeMetadata.updated_at : patch.updated_at
|
|
5439
|
+
};
|
|
5440
|
+
if (typeof safeMetadata.primary_chat_id === "string") {
|
|
5441
|
+
encryptedTaskPayload.key_wrappers = await buildTaskKeyWrappersForChat(
|
|
5442
|
+
task,
|
|
5443
|
+
safeMetadata.primary_chat_id,
|
|
5444
|
+
typeof safeMetadata.updated_at === "number" ? safeMetadata.updated_at : Math.floor(Date.now() / 1e3)
|
|
5445
|
+
);
|
|
5446
|
+
}
|
|
5447
|
+
}
|
|
5448
|
+
const encryptedEventMessage = eventMessage.encrypted_content;
|
|
5449
|
+
const persistedPromise = ws.waitForMessage(
|
|
5450
|
+
"task_update_job_persisted",
|
|
5451
|
+
(payload) => payload.job_id === job.job_id,
|
|
5452
|
+
2e4
|
|
5453
|
+
);
|
|
5454
|
+
await ws.sendAsync("task_update_job_persist", buildTaskUpdateJobPersistPayload({
|
|
5455
|
+
jobId: job.job_id,
|
|
5456
|
+
leaseToken: claim.lease_token,
|
|
5457
|
+
leaseGeneration: claim.lease_generation,
|
|
5458
|
+
expectedTaskVersion: claim.expected_task_version,
|
|
5459
|
+
encryptedTaskPayload,
|
|
5460
|
+
encryptedTaskEventMessage: encryptedEventMessage
|
|
5461
|
+
}));
|
|
5462
|
+
await persistedPromise;
|
|
5463
|
+
await persistEncryptedSystemMessage(eventMessage, sourceChatId);
|
|
5357
5464
|
persistedTaskEventIds.add(event.event_id);
|
|
5465
|
+
await confirmTaskEventPersisted();
|
|
5466
|
+
persistedJobIds.add(job.job_id);
|
|
5358
5467
|
}
|
|
5468
|
+
clearSyncCache();
|
|
5469
|
+
return persistedJobIds;
|
|
5359
5470
|
};
|
|
5360
5471
|
const streamOpts = {
|
|
5361
5472
|
onStream: params.onStream,
|
|
@@ -5364,11 +5475,7 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
5364
5475
|
};
|
|
5365
5476
|
if (params.incognito) {
|
|
5366
5477
|
try {
|
|
5367
|
-
const resp = await (precollectedResponse ?? ws.collectAiResponse(messageId, chatId,
|
|
5368
|
-
...streamOpts,
|
|
5369
|
-
timeoutMs: params.responseTimeoutMs,
|
|
5370
|
-
recoveryTurnId: savedTurnId
|
|
5371
|
-
}));
|
|
5478
|
+
const resp = await (precollectedResponse ?? ws.collectAiResponse(messageId, chatId, streamOpts));
|
|
5372
5479
|
assistantMessageId = resp.messageId;
|
|
5373
5480
|
assistant = resp.content;
|
|
5374
5481
|
category = resp.category;
|
|
@@ -5399,10 +5506,7 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
5399
5506
|
}
|
|
5400
5507
|
} else {
|
|
5401
5508
|
try {
|
|
5402
|
-
const resp = await (precollectedResponse ?? ws.collectAiResponse(messageId, chatId,
|
|
5403
|
-
...streamOpts,
|
|
5404
|
-
timeoutMs: params.responseTimeoutMs
|
|
5405
|
-
}));
|
|
5509
|
+
const resp = await (precollectedResponse ?? ws.collectAiResponse(messageId, chatId, streamOpts));
|
|
5406
5510
|
assistantMessageId = resp.messageId;
|
|
5407
5511
|
assistant = resp.content;
|
|
5408
5512
|
category = resp.category;
|
|
@@ -5492,15 +5596,12 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
5492
5596
|
"model_name",
|
|
5493
5597
|
"turn_id"
|
|
5494
5598
|
];
|
|
5495
|
-
if (Object.keys(recovered).sort().join(",") !== expectedRecoveryFields.join(",") || recovered.assistant_message_id !== assistantId || recovered.chat_id !== chatId || recovered.turn_id !== savedTurnId || recovered.job_id !== recoveryJobId || recovered.key_version !== keyVersion || typeof recovered.content !== "string" || recovered.category !== null && typeof recovered.category !== "string" || recovered.model_name !== null && typeof recovered.model_name !== "string") {
|
|
5599
|
+
if (Object.keys(recovered).sort().join(",") !== expectedRecoveryFields.join(",") || recovered.assistant_message_id !== assistantId || recovered.chat_id !== chatId || recovered.turn_id !== savedTurnId || recovered.job_id !== recoveryJobId || recovered.key_version !== keyVersion || typeof recovered.content !== "string" || recovered.category !== null && typeof recovered.category !== "string" || recovered.model_name !== null && typeof recovered.model_name !== "string" || recovered.content !== assistant || recovered.category !== category || recovered.model_name !== modelName) {
|
|
5496
5600
|
throw new Error("Recovery job plaintext did not match the terminal completion identity.");
|
|
5497
5601
|
}
|
|
5498
|
-
assistant = recovered.content;
|
|
5499
|
-
category = recovered.category;
|
|
5500
|
-
modelName = recovered.model_name;
|
|
5501
5602
|
const completedAt = Math.floor(Date.now() / 1e3);
|
|
5502
5603
|
const encryptedAssistantContent = await encryptWithAesGcmCombined(
|
|
5503
|
-
|
|
5604
|
+
recovered.content,
|
|
5504
5605
|
chatKeyBytes
|
|
5505
5606
|
);
|
|
5506
5607
|
const encryptedSenderName = await encryptWithAesGcmCombined("Assistant", chatKeyBytes);
|
|
@@ -5547,15 +5648,7 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
5547
5648
|
newChatSuggestions: resp.newChatSuggestions,
|
|
5548
5649
|
encryptedChatKey
|
|
5549
5650
|
});
|
|
5550
|
-
const persistedTaskJobIds = await
|
|
5551
|
-
ws,
|
|
5552
|
-
jobs: pendingTaskUpdateJobs,
|
|
5553
|
-
events: taskEvents,
|
|
5554
|
-
activeChatId: chatId,
|
|
5555
|
-
activeChatKeyBytes: chatKeyBytes,
|
|
5556
|
-
fallbackUserMessageId: messageId,
|
|
5557
|
-
requireActiveTurnEvent: true
|
|
5558
|
-
});
|
|
5651
|
+
const persistedTaskJobIds = await persistPendingTaskUpdateJobs(pendingTaskUpdateJobs, taskEvents);
|
|
5559
5652
|
pendingTaskUpdateJobs = pendingTaskUpdateJobs.filter((job) => !persistedTaskJobIds.has(job.job_id));
|
|
5560
5653
|
await persistTaskEventSystemMessages(taskEvents);
|
|
5561
5654
|
clearSyncCache();
|
|
@@ -5582,224 +5675,6 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
5582
5675
|
appSettingsMemoryRequests
|
|
5583
5676
|
};
|
|
5584
5677
|
}
|
|
5585
|
-
async persistEncryptedSystemMessage(ws, systemMessage, targetChatId) {
|
|
5586
|
-
await ws.sendAsync("chat_system_message_added", {
|
|
5587
|
-
chat_id: targetChatId,
|
|
5588
|
-
message: systemMessage
|
|
5589
|
-
});
|
|
5590
|
-
await ws.waitForMessage(
|
|
5591
|
-
"system_message_confirmed",
|
|
5592
|
-
(payload) => payload.message_id === systemMessage.message_id,
|
|
5593
|
-
2e4
|
|
5594
|
-
);
|
|
5595
|
-
}
|
|
5596
|
-
async persistPendingTaskUpdateJobs(params) {
|
|
5597
|
-
const handledJobIds = /* @__PURE__ */ new Set();
|
|
5598
|
-
if (params.jobs.length === 0) return handledJobIds;
|
|
5599
|
-
const masterKey = this.getMasterKeyBytes();
|
|
5600
|
-
let decryptedTasksCache = null;
|
|
5601
|
-
const eventByJobId = new Map(params.events.map((event) => [event.task_update_job_id, event]));
|
|
5602
|
-
const resolveChatKey = async (targetChatId) => {
|
|
5603
|
-
if (targetChatId === params.activeChatId && params.activeChatKeyBytes) return params.activeChatKeyBytes;
|
|
5604
|
-
const findChat = (chats) => chats?.find((chat) => String(chat.details.id ?? "") === targetChatId);
|
|
5605
|
-
const targetChat = findChat(params.syncedChats) ?? findChat(loadSyncCache()?.chats);
|
|
5606
|
-
const encryptedTargetChatKey = typeof targetChat?.details.encrypted_chat_key === "string" ? targetChat.details.encrypted_chat_key : null;
|
|
5607
|
-
if (!encryptedTargetChatKey) {
|
|
5608
|
-
throw new Error(`Encrypted chat key not found for task update job target '${targetChatId}'. Sync and try again.`);
|
|
5609
|
-
}
|
|
5610
|
-
const targetChatKey = await decryptBytesWithAesGcm(encryptedTargetChatKey, masterKey);
|
|
5611
|
-
if (!targetChatKey) {
|
|
5612
|
-
throw new Error(`Failed to decrypt chat key for task update job target '${targetChatId}'.`);
|
|
5613
|
-
}
|
|
5614
|
-
return targetChatKey;
|
|
5615
|
-
};
|
|
5616
|
-
const listProjectTaskKeyWrappers = async (taskId, createdAt) => {
|
|
5617
|
-
const response = await this.http.get(
|
|
5618
|
-
`/v1/user-tasks/${encodeURIComponent(taskId)}/key-wrappers`,
|
|
5619
|
-
this.getCliRequestHeaders()
|
|
5620
|
-
);
|
|
5621
|
-
if (!response.ok) {
|
|
5622
|
-
throw new Error(`User task key wrapper list failed with HTTP ${response.status}`);
|
|
5623
|
-
}
|
|
5624
|
-
return (response.data.key_wrappers ?? []).filter((wrapper) => wrapper.key_type === "project").map((wrapper) => ({
|
|
5625
|
-
key_type: "project",
|
|
5626
|
-
hashed_project_id: wrapper.hashed_project_id,
|
|
5627
|
-
encrypted_task_key: wrapper.encrypted_task_key,
|
|
5628
|
-
created_at: typeof wrapper.created_at === "number" ? wrapper.created_at : createdAt,
|
|
5629
|
-
expires_at: wrapper.expires_at ?? null
|
|
5630
|
-
}));
|
|
5631
|
-
};
|
|
5632
|
-
const buildTaskKeyWrappersForChat = async (task, targetChatId, createdAt) => {
|
|
5633
|
-
const encryptedTaskKey = task.encrypted.encrypted_task_key;
|
|
5634
|
-
if (!encryptedTaskKey) throw new Error(`Task ${task.taskId} is missing encrypted task key.`);
|
|
5635
|
-
const taskKey = await decryptBytesWithAesGcm(encryptedTaskKey, masterKey);
|
|
5636
|
-
if (!taskKey) throw new Error(`Failed to decrypt task key for ${task.taskId}.`);
|
|
5637
|
-
const targetChatKey = await resolveChatKey(targetChatId);
|
|
5638
|
-
const existingProjectWrappers = await listProjectTaskKeyWrappers(task.taskId, createdAt);
|
|
5639
|
-
const linkedProjectIds = task.linkedProjectIds ?? [];
|
|
5640
|
-
if (linkedProjectIds.length > existingProjectWrappers.length) {
|
|
5641
|
-
throw new Error(`Task ${task.taskId} is missing project key wrappers required for move persistence.`);
|
|
5642
|
-
}
|
|
5643
|
-
return [
|
|
5644
|
-
{
|
|
5645
|
-
key_type: "master",
|
|
5646
|
-
encrypted_task_key: await encryptBytesWithAesGcm(taskKey, masterKey),
|
|
5647
|
-
created_at: createdAt
|
|
5648
|
-
},
|
|
5649
|
-
{
|
|
5650
|
-
key_type: "chat",
|
|
5651
|
-
hashed_chat_id: computeSHA256(targetChatId),
|
|
5652
|
-
encrypted_task_key: await encryptBytesWithAesGcm(taskKey, targetChatKey),
|
|
5653
|
-
created_at: createdAt
|
|
5654
|
-
},
|
|
5655
|
-
...existingProjectWrappers
|
|
5656
|
-
];
|
|
5657
|
-
};
|
|
5658
|
-
const findTaskForUpdateJob = async (claim) => {
|
|
5659
|
-
const chatIds = [claim.source_task_chat_id, claim.chat_id, claim.safe_metadata?.primary_chat_id].filter((value) => typeof value === "string" && value.length > 0);
|
|
5660
|
-
for (const candidateChatId of [...new Set(chatIds)]) {
|
|
5661
|
-
const scopedTasks = await decryptUserTasks(await this.listUserTasks({ chatId: candidateChatId }), masterKey);
|
|
5662
|
-
try {
|
|
5663
|
-
return findTask(scopedTasks, claim.task_id);
|
|
5664
|
-
} catch (error) {
|
|
5665
|
-
if (!(error instanceof Error) || !error.message.includes("was not found")) throw error;
|
|
5666
|
-
}
|
|
5667
|
-
}
|
|
5668
|
-
if (!decryptedTasksCache) {
|
|
5669
|
-
decryptedTasksCache = await decryptUserTasks(await this.listUserTasks({ limit: 1e3 }), masterKey);
|
|
5670
|
-
}
|
|
5671
|
-
return findTask(decryptedTasksCache, claim.task_id);
|
|
5672
|
-
};
|
|
5673
|
-
const taskEventTypeForOperation = (operation) => {
|
|
5674
|
-
switch (operation) {
|
|
5675
|
-
case "create":
|
|
5676
|
-
return "created";
|
|
5677
|
-
case "move":
|
|
5678
|
-
return "moved";
|
|
5679
|
-
case "update":
|
|
5680
|
-
return "updated";
|
|
5681
|
-
default:
|
|
5682
|
-
return operation || "updated";
|
|
5683
|
-
}
|
|
5684
|
-
};
|
|
5685
|
-
for (const job of params.jobs) {
|
|
5686
|
-
if (params.requireActiveTurnEvent && params.activeChatId && !taskUpdateJobBelongsToActiveTurn(job, params.activeChatId, params.events)) {
|
|
5687
|
-
handledJobIds.add(job.job_id);
|
|
5688
|
-
continue;
|
|
5689
|
-
}
|
|
5690
|
-
const claimPromise = params.ws.waitForMessage(
|
|
5691
|
-
"task_update_job_claimed",
|
|
5692
|
-
(payload) => payload.job_id === job.job_id,
|
|
5693
|
-
2e4
|
|
5694
|
-
);
|
|
5695
|
-
await params.ws.sendAsync("task_update_job_claim", {
|
|
5696
|
-
protocol_version: 1,
|
|
5697
|
-
job_id: job.job_id
|
|
5698
|
-
});
|
|
5699
|
-
const claim = (await claimPromise).payload;
|
|
5700
|
-
const privatePatch = claim.private_patch ?? {};
|
|
5701
|
-
const safeMetadata = claim.safe_metadata ?? {};
|
|
5702
|
-
const sourceChatId = claim.chat_id ?? job.chat_id ?? params.activeChatId;
|
|
5703
|
-
if (!sourceChatId) throw new Error(`Task update job ${job.job_id} is missing a source chat id.`);
|
|
5704
|
-
const sourceChatKey = await resolveChatKey(sourceChatId);
|
|
5705
|
-
const event = eventByJobId.get(job.job_id) ?? {
|
|
5706
|
-
event_id: `task-event-${job.job_id}`,
|
|
5707
|
-
chat_id: sourceChatId,
|
|
5708
|
-
task_id: claim.task_id,
|
|
5709
|
-
event_type: taskEventTypeForOperation(claim.operation),
|
|
5710
|
-
title: typeof privatePatch.title === "string" ? privatePatch.title : null,
|
|
5711
|
-
status: typeof safeMetadata.status === "string" ? safeMetadata.status : null,
|
|
5712
|
-
created_at: typeof safeMetadata.updated_at === "number" ? safeMetadata.updated_at : Math.floor(Date.now() / 1e3),
|
|
5713
|
-
task_update_job_id: job.job_id
|
|
5714
|
-
};
|
|
5715
|
-
const userMessageId = claim.message_id ?? params.fallbackUserMessageId;
|
|
5716
|
-
if (!userMessageId) throw new Error(`Task update job ${job.job_id} is missing a user message id.`);
|
|
5717
|
-
const eventMessage = await buildTaskEventSystemMessage({
|
|
5718
|
-
chatKey: sourceChatKey,
|
|
5719
|
-
userMessageId,
|
|
5720
|
-
event
|
|
5721
|
-
});
|
|
5722
|
-
const confirmTaskEventPersisted = async () => {
|
|
5723
|
-
const confirmedPromise = params.ws.waitForMessage(
|
|
5724
|
-
"task_update_job_event_confirmed",
|
|
5725
|
-
(payload) => payload.job_id === job.job_id,
|
|
5726
|
-
2e4
|
|
5727
|
-
);
|
|
5728
|
-
await params.ws.sendAsync("task_update_job_event_confirmed", {
|
|
5729
|
-
protocol_version: 1,
|
|
5730
|
-
job_id: job.job_id,
|
|
5731
|
-
event_system_message_id: eventMessage.message_id
|
|
5732
|
-
});
|
|
5733
|
-
await confirmedPromise;
|
|
5734
|
-
};
|
|
5735
|
-
if (claim.state === "TASK_PERSISTED") {
|
|
5736
|
-
await this.persistEncryptedSystemMessage(params.ws, eventMessage, sourceChatId);
|
|
5737
|
-
await confirmTaskEventPersisted();
|
|
5738
|
-
handledJobIds.add(job.job_id);
|
|
5739
|
-
continue;
|
|
5740
|
-
}
|
|
5741
|
-
if (!claim.lease_token || !Number.isSafeInteger(claim.lease_generation)) {
|
|
5742
|
-
throw new Error("Task update job claim returned an invalid lease.");
|
|
5743
|
-
}
|
|
5744
|
-
let encryptedTaskPayload;
|
|
5745
|
-
if (claim.operation === "create") {
|
|
5746
|
-
const input = await buildCreateUserTaskInput(masterKey, {
|
|
5747
|
-
title: typeof privatePatch.title === "string" ? privatePatch.title : "Untitled task",
|
|
5748
|
-
description: typeof privatePatch.description === "string" ? privatePatch.description : "",
|
|
5749
|
-
status: typeof safeMetadata.status === "string" ? safeMetadata.status : "todo",
|
|
5750
|
-
assign: typeof safeMetadata.assignee_type === "string" ? safeMetadata.assignee_type : "user",
|
|
5751
|
-
chatId: typeof safeMetadata.primary_chat_id === "string" ? safeMetadata.primary_chat_id : claim.chat_id ?? params.activeChatId
|
|
5752
|
-
});
|
|
5753
|
-
encryptedTaskPayload = {
|
|
5754
|
-
...input,
|
|
5755
|
-
task_id: claim.task_id,
|
|
5756
|
-
position: typeof safeMetadata.position === "number" ? safeMetadata.position : input.position,
|
|
5757
|
-
created_at: typeof safeMetadata.created_at === "number" ? safeMetadata.created_at : input.created_at,
|
|
5758
|
-
updated_at: typeof safeMetadata.updated_at === "number" ? safeMetadata.updated_at : input.updated_at
|
|
5759
|
-
};
|
|
5760
|
-
} else {
|
|
5761
|
-
const task = await findTaskForUpdateJob(claim);
|
|
5762
|
-
const patch = await buildUpdateUserTaskInput(task, masterKey, {
|
|
5763
|
-
title: typeof privatePatch.title === "string" ? privatePatch.title : void 0,
|
|
5764
|
-
description: typeof privatePatch.description === "string" ? privatePatch.description : void 0,
|
|
5765
|
-
status: typeof safeMetadata.status === "string" ? safeMetadata.status : void 0,
|
|
5766
|
-
assign: typeof safeMetadata.assignee_type === "string" ? safeMetadata.assignee_type : void 0,
|
|
5767
|
-
chatId: typeof safeMetadata.primary_chat_id === "string" ? safeMetadata.primary_chat_id : void 0
|
|
5768
|
-
});
|
|
5769
|
-
encryptedTaskPayload = {
|
|
5770
|
-
...patch,
|
|
5771
|
-
version: claim.expected_task_version,
|
|
5772
|
-
updated_at: typeof safeMetadata.updated_at === "number" ? safeMetadata.updated_at : patch.updated_at
|
|
5773
|
-
};
|
|
5774
|
-
if (typeof safeMetadata.primary_chat_id === "string") {
|
|
5775
|
-
encryptedTaskPayload.key_wrappers = await buildTaskKeyWrappersForChat(
|
|
5776
|
-
task,
|
|
5777
|
-
safeMetadata.primary_chat_id,
|
|
5778
|
-
typeof safeMetadata.updated_at === "number" ? safeMetadata.updated_at : Math.floor(Date.now() / 1e3)
|
|
5779
|
-
);
|
|
5780
|
-
}
|
|
5781
|
-
}
|
|
5782
|
-
const persistedPromise = params.ws.waitForMessage(
|
|
5783
|
-
"task_update_job_persisted",
|
|
5784
|
-
(payload) => payload.job_id === job.job_id,
|
|
5785
|
-
2e4
|
|
5786
|
-
);
|
|
5787
|
-
await params.ws.sendAsync("task_update_job_persist", buildTaskUpdateJobPersistPayload({
|
|
5788
|
-
jobId: job.job_id,
|
|
5789
|
-
leaseToken: claim.lease_token,
|
|
5790
|
-
leaseGeneration: claim.lease_generation,
|
|
5791
|
-
expectedTaskVersion: claim.expected_task_version,
|
|
5792
|
-
encryptedTaskPayload,
|
|
5793
|
-
encryptedTaskEventMessage: eventMessage.encrypted_content
|
|
5794
|
-
}));
|
|
5795
|
-
await persistedPromise;
|
|
5796
|
-
await this.persistEncryptedSystemMessage(params.ws, eventMessage, sourceChatId);
|
|
5797
|
-
await confirmTaskEventPersisted();
|
|
5798
|
-
handledJobIds.add(job.job_id);
|
|
5799
|
-
}
|
|
5800
|
-
clearSyncCache();
|
|
5801
|
-
return handledJobIds;
|
|
5802
|
-
}
|
|
5803
5678
|
async persistStreamedEmbeds(params) {
|
|
5804
5679
|
const finalized = new Map(
|
|
5805
5680
|
params.embeds.filter((embed) => {
|
|
@@ -6041,28 +5916,14 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
6041
5916
|
}
|
|
6042
5917
|
async pollTaskUntilComplete(taskId, headers) {
|
|
6043
5918
|
const started = Date.now();
|
|
6044
|
-
let lastTransientError = null;
|
|
6045
5919
|
while (Date.now() - started < SKILL_TASK_POLL_TIMEOUT_MS) {
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
headers
|
|
6051
|
-
);
|
|
6052
|
-
} catch (error) {
|
|
6053
|
-
lastTransientError = error instanceof Error ? error.message : String(error);
|
|
6054
|
-
await new Promise((resolve7) => setTimeout(resolve7, SKILL_TASK_POLL_INTERVAL_MS));
|
|
6055
|
-
continue;
|
|
6056
|
-
}
|
|
5920
|
+
const response = await this.http.get(
|
|
5921
|
+
`/v1/tasks/${encodeURIComponent(taskId)}`,
|
|
5922
|
+
headers
|
|
5923
|
+
);
|
|
6057
5924
|
if (!response.ok) {
|
|
6058
|
-
if (response.status >= SKILL_TASK_POLL_TRANSIENT_ERROR_STATUS) {
|
|
6059
|
-
lastTransientError = `HTTP ${response.status}`;
|
|
6060
|
-
await new Promise((resolve7) => setTimeout(resolve7, SKILL_TASK_POLL_INTERVAL_MS));
|
|
6061
|
-
continue;
|
|
6062
|
-
}
|
|
6063
5925
|
throw new Error(`Task polling failed with HTTP ${response.status}`);
|
|
6064
5926
|
}
|
|
6065
|
-
lastTransientError = null;
|
|
6066
5927
|
if (response.data.status === "completed") {
|
|
6067
5928
|
return response.data;
|
|
6068
5929
|
}
|
|
@@ -6071,11 +5932,6 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
6071
5932
|
}
|
|
6072
5933
|
await new Promise((resolve7) => setTimeout(resolve7, SKILL_TASK_POLL_INTERVAL_MS));
|
|
6073
5934
|
}
|
|
6074
|
-
if (lastTransientError) {
|
|
6075
|
-
throw new Error(
|
|
6076
|
-
`Task ${taskId} did not complete within ${SKILL_TASK_POLL_TIMEOUT_MS / 1e3}s; last polling error: ${lastTransientError}`
|
|
6077
|
-
);
|
|
6078
|
-
}
|
|
6079
5935
|
throw new Error(`Task ${taskId} did not complete within ${SKILL_TASK_POLL_TIMEOUT_MS / 1e3}s`);
|
|
6080
5936
|
}
|
|
6081
5937
|
wrapResolvedSkillResult(original, result) {
|
|
@@ -6725,8 +6581,6 @@ var OpenMatesClient = class _OpenMatesClient {
|
|
|
6725
6581
|
if (filters.status) params.set("status", filters.status);
|
|
6726
6582
|
if (filters.chatId) params.set("chat_id", filters.chatId);
|
|
6727
6583
|
if (filters.projectId) params.set("project_id", filters.projectId);
|
|
6728
|
-
const limit = filters.limit;
|
|
6729
|
-
if (Number.isSafeInteger(limit) && limit !== void 0 && limit > 0) params.set("limit", String(limit));
|
|
6730
6584
|
const query = params.toString();
|
|
6731
6585
|
const response = await this.http.get(
|
|
6732
6586
|
`/v1/user-tasks${query ? `?${query}` : ""}`,
|
|
@@ -7639,13 +7493,7 @@ Required: ${schema.required.join(", ")}`
|
|
|
7639
7493
|
* Get the session for file upload authentication.
|
|
7640
7494
|
*/
|
|
7641
7495
|
getSession() {
|
|
7642
|
-
|
|
7643
|
-
const currentCookies = this.http.getCookieMap();
|
|
7644
|
-
if (JSON.stringify(session.cookies) !== JSON.stringify(currentCookies)) {
|
|
7645
|
-
session.cookies = currentCookies;
|
|
7646
|
-
saveSession(session);
|
|
7647
|
-
}
|
|
7648
|
-
return session;
|
|
7496
|
+
return this.requireSession();
|
|
7649
7497
|
}
|
|
7650
7498
|
// ── Share link creation ──────────────────────────────────────────────
|
|
7651
7499
|
/**
|
|
@@ -8149,7 +7997,6 @@ Required: ${schema.required.join(", ")}`
|
|
|
8149
7997
|
let totalChatCount = 0;
|
|
8150
7998
|
let reconciliation = { authoritative: false };
|
|
8151
7999
|
const pendingAIResponses = [];
|
|
8152
|
-
let pendingTaskUpdateJobs = [];
|
|
8153
8000
|
try {
|
|
8154
8001
|
ws.send("phased_sync_request", {
|
|
8155
8002
|
phase: "all",
|
|
@@ -8198,7 +8045,6 @@ Required: ${schema.required.join(", ")}`
|
|
|
8198
8045
|
pendingAIResponses.push(frame.payload);
|
|
8199
8046
|
}
|
|
8200
8047
|
}
|
|
8201
|
-
pendingTaskUpdateJobs = ws.drainPassiveTaskUpdateJobs();
|
|
8202
8048
|
for (const chat of chats) {
|
|
8203
8049
|
const id = typeof chat.details.id === "string" ? chat.details.id : "";
|
|
8204
8050
|
const msgs = messagesByChatId.get(id);
|
|
@@ -8275,26 +8121,11 @@ Required: ${schema.required.join(", ")}`
|
|
|
8275
8121
|
chats.sort(
|
|
8276
8122
|
(a, b) => (typeof b.details.last_edited_overall_timestamp === "number" ? b.details.last_edited_overall_timestamp : 0) - (typeof a.details.last_edited_overall_timestamp === "number" ? a.details.last_edited_overall_timestamp : 0)
|
|
8277
8123
|
);
|
|
8278
|
-
let persistedTaskJobIds = /* @__PURE__ */ new Set();
|
|
8279
8124
|
try {
|
|
8280
8125
|
await this.persistPendingAIResponsesFromSync(ws, chats, pendingAIResponses);
|
|
8281
|
-
persistedTaskJobIds = await this.persistPendingTaskUpdateJobs({
|
|
8282
|
-
ws,
|
|
8283
|
-
jobs: pendingTaskUpdateJobs,
|
|
8284
|
-
events: [],
|
|
8285
|
-
activeChatId: null,
|
|
8286
|
-
activeChatKeyBytes: null,
|
|
8287
|
-
fallbackUserMessageId: null,
|
|
8288
|
-
syncedChats: chats,
|
|
8289
|
-
requireActiveTurnEvent: false
|
|
8290
|
-
});
|
|
8291
8126
|
} finally {
|
|
8292
8127
|
ws.close();
|
|
8293
8128
|
}
|
|
8294
|
-
if (persistedTaskJobIds.size > 0) {
|
|
8295
|
-
clearSyncCache();
|
|
8296
|
-
return this.ensureSynced(true, refreshChatIds);
|
|
8297
|
-
}
|
|
8298
8129
|
const cache = {
|
|
8299
8130
|
syncedAt: Date.now(),
|
|
8300
8131
|
totalChatCount,
|
|
@@ -23681,76 +23512,6 @@ var privateWorkspaceDemoVideoChat = {
|
|
|
23681
23512
|
}
|
|
23682
23513
|
};
|
|
23683
23514
|
|
|
23684
|
-
// ../ui/src/demo_chats/data/example_chats/reference-image-3d-model.ts
|
|
23685
|
-
var MODEL3D_POSTER_DATA_URL = "data:image/webp;base64,UklGRp4PAABXRUJQVlA4IJIPAADQcgCdASqAAYABPpVKoUslpLGqJNKp6jASiWdu3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gbEri8liQ8OozgrV1wZDc5gHk7LtEzjtpAmfKb6NvkTAABLHeYD0W9qQjh00SU22hc1oNNKdVaLvNSQJnApxCCFI8sMyNYmrRonSY/S27GcxzMGyzPmAjt3PKo8Iy9llRXbBd7jmywfMTltDsn46nJvOZZ8Ymw5S8iMjlitYJrUgEvqMWZ4zzQDzar9zRG/MIPZckoquTitTTZ1vP1eaAwvDm35OiMaW9fM4zBRmUvgTgRl7Co3VpucEOYr3KroGlrvb1NrvHt3AQsMse4fQ1U1LA5KAxzudJjQ71hZLR3yTuwcBTaQakNuwLE3fp9InhhFKi4V03m4kKaz86hpQ5mqzCB5uvGv7A5U5JFwfuT6QbS0bGOCdnCFoViox0Pbt1hDyMqFtHp7B1GScPlhtQfFNImbBLA3k2w6dem6vA40I/vretIyXHIPRJc0SKMcW9YNkzQFcxlYuYOmn7IUpcpEe+Gx7XwDYQoa6nARFIZuAb5hXkvrHowFGAeQtobt2xZyIDB/8R6tF4OiXXQYe0WrLzLT7+OdmjClp//98k302Lx8N2JqPWBORhbkR2rq8VP0qtaZwcYCzM58nkB6KbTFqrnqyjsFg7P2sKUWmRaxfkuvOeXT1YK/GP3q5ZsKjJB9KAXyCC7Z/oA6jLKPB1pP9yjc2dn2XxIe4+AlnZTVremr1ZE4pi2Mw2yBPGtcHSAYQ5XucbuCNpU1T28wV2j2qX9RxkNGGnL4nbzuKgfmP4OYpenpXZybdNaD7rSl+ZyWn0sNCsO2NGiTauXZqZh3kwMNCu10bH2J+Ac+nxpB1XenE1XFJWtIvGyF5JehRzAPWCVL/4tep7EvYiUled1jLdZbejtCQQ+BAUGkbRONKQYDlSJfcNCJRMpWaeQXXByc3++UGcjrXbCVYMl1vqX0gAsO0fuddaT8dYXr4CYEJZBFtnUAEmEKBTfmAAAA==";
|
|
23686
|
-
var referenceImage3DModelChat = {
|
|
23687
|
-
chat_id: "example-reference-image-3d-model",
|
|
23688
|
-
slug: "reference-image-3d-model",
|
|
23689
|
-
title: "example_chats.reference_image_3d_model.title",
|
|
23690
|
-
summary: "example_chats.reference_image_3d_model.summary",
|
|
23691
|
-
icon: "3dmodels",
|
|
23692
|
-
category: "design",
|
|
23693
|
-
keywords: ["3D model generation", "image to 3D", "Hi3D", "GLB", "product design"],
|
|
23694
|
-
follow_up_suggestions: [],
|
|
23695
|
-
messages: [
|
|
23696
|
-
{
|
|
23697
|
-
id: "c79b9ff0-7d58-4ed7-b860-4c427cdab6bd",
|
|
23698
|
-
role: "user",
|
|
23699
|
-
content: "example_chats.reference_image_3d_model.message_1",
|
|
23700
|
-
created_at: 1784071246
|
|
23701
|
-
},
|
|
23702
|
-
{
|
|
23703
|
-
id: "fbf595b9-2f71-4a7a-b544-56529bf9a38d",
|
|
23704
|
-
role: "assistant",
|
|
23705
|
-
content: "example_chats.reference_image_3d_model.message_2",
|
|
23706
|
-
created_at: 1784071268,
|
|
23707
|
-
category: "design",
|
|
23708
|
-
model_name: "Gemini 3 Flash"
|
|
23709
|
-
}
|
|
23710
|
-
],
|
|
23711
|
-
embeds: [
|
|
23712
|
-
{
|
|
23713
|
-
embed_id: "85716124-48d5-4c4c-9919-3126b733b41e",
|
|
23714
|
-
type: "app_skill_use",
|
|
23715
|
-
content: `app_id: models3d
|
|
23716
|
-
skill_id: generate
|
|
23717
|
-
type: model3d
|
|
23718
|
-
status: finished
|
|
23719
|
-
input_mode: image
|
|
23720
|
-
prompt: "Create a textured 3D GLB model from the uploaded reference image."
|
|
23721
|
-
provider: Hi3D
|
|
23722
|
-
provider_model: Hi3D
|
|
23723
|
-
poster_url: "${MODEL3D_POSTER_DATA_URL}"
|
|
23724
|
-
files:
|
|
23725
|
-
master:
|
|
23726
|
-
size_bytes: 25847448
|
|
23727
|
-
format: glb
|
|
23728
|
-
mime_type: model/gltf-binary
|
|
23729
|
-
poster:
|
|
23730
|
-
size_bytes: 20690
|
|
23731
|
-
format: webp
|
|
23732
|
-
mime_type: image/webp
|
|
23733
|
-
preview:
|
|
23734
|
-
size_bytes: 25847448
|
|
23735
|
-
format: glb
|
|
23736
|
-
mime_type: model/gltf-binary
|
|
23737
|
-
optimized: false
|
|
23738
|
-
fallback_reason: preview_optimization_failed
|
|
23739
|
-
generated_at: "2026-07-14T23:20:46+00:00"
|
|
23740
|
-
provenance:
|
|
23741
|
-
ai_generated: true
|
|
23742
|
-
labeling: static_public_fixture`,
|
|
23743
|
-
parent_embed_id: null,
|
|
23744
|
-
embed_ids: null
|
|
23745
|
-
}
|
|
23746
|
-
],
|
|
23747
|
-
metadata: {
|
|
23748
|
-
featured: true,
|
|
23749
|
-
order: 38,
|
|
23750
|
-
app_skill_examples: ["models3d.generate"]
|
|
23751
|
-
}
|
|
23752
|
-
};
|
|
23753
|
-
|
|
23754
23515
|
// ../ui/src/demo_chats/data/example_chats/upcoming-reminders-list.ts
|
|
23755
23516
|
var upcomingRemindersListChat = {
|
|
23756
23517
|
chat_id: "example-upcoming-reminders-list",
|
|
@@ -28348,7 +28109,6 @@ var ALL_EXAMPLE_CHATS = [
|
|
|
28348
28109
|
berlinDermatologyAppointmentsChat,
|
|
28349
28110
|
productLaunchSynthLoopChat,
|
|
28350
28111
|
privateWorkspaceDemoVideoChat,
|
|
28351
|
-
referenceImage3DModelChat,
|
|
28352
28112
|
upcomingRemindersListChat,
|
|
28353
28113
|
cancelTestReminderChat,
|
|
28354
28114
|
fediverseActivitypubSocialSearchChat,
|
|
@@ -36988,20 +36748,6 @@ Like [Denis Villeneuve](wiki:Denis_Villeneuve)\u2019s work, *Contact* avoids the
|
|
|
36988
36748
|
text: '```json\n{"type": "app_skill_use", "embed_id": "11ff377e-a0a2-40ed-81c3-9556b68142f3", "app_id": "videos", "skill_id": "search", "query": "retrieval augmented generation explained for beginners", "provider": "Brave"}\n```\n\nI\'ve found some excellent beginner-friendly videos that explain Retrieval-Augmented Generation (RAG). Here is a curated selection to get you started:\n\n[!](embed:youtube.com-OCK)\n[!](embed:youtube.com-20R)\n[!](embed:youtube.com-8SW)\n[!](embed:youtube.com-Fn4)\n[!](embed:youtube.com-rgp)\n\n### Which one should you watch first?\n\nI highly recommend starting with **[What is Retrieval-Augmented Generation (RAG)?](embed:youtube.com-OCK)** by **IBM Technology**.\n\n**Why this one first?**\n* **Conciseness:** At just 6 and a half minutes, it provides the most efficient "conceptual hook" without getting bogged down in implementation details.\n* **High-Level Clarity:** IBM\u2019s explanations are famous for being professional and easy to follow. They focus on the *why* (fixing LLM hallucinations and outdated data) before diving into the *what*.\n* **Authoritative:** It establishes a solid foundation from a reputable industry leader, which helps you better understand the more technical or "hands-on" videos later.\n\n### What to watch next?\n\nOnce you have the concept down, here are two paths depending on your interest:\n\n1. **For a better intuitive understanding:** Watch **[RAG Explained in 12 Minutes](embed:youtube.com-20R)** by **Aishwarya Srinivasan**. She uses a brilliant "Open-Book Exam" analogy that makes the whole process click instantly for most beginners.\n2. **For a technical overview:** If you want to see the "moving parts" (like vector databases and embeddings), check out **[RAG Explained For Beginners](embed:youtube.com-8SW)** by **KodeKloud**. It breaks the process down into a simple 3-step framework: Retrieval, Augmentation, and Generation.\n\nIf you\'re interested in building a RAG system yourself, I can help you find documentation for popular tools like [LangChain](wiki:LangChain) or LlamaIndex. Would you like to see how a simple RAG implementation looks in code?\n\n**Further exploration:**\n* [Check out more AI tutorials](/#settings/apps/videos)\n* [Search for RAG documentation](/#settings/apps/code)'
|
|
36989
36749
|
}
|
|
36990
36750
|
},
|
|
36991
|
-
reference_image_3d_model: {
|
|
36992
|
-
title: {
|
|
36993
|
-
text: "Reference Image to 3D Model"
|
|
36994
|
-
},
|
|
36995
|
-
summary: {
|
|
36996
|
-
text: "A 3D generation example that turns a reference image into a textured GLB model preview."
|
|
36997
|
-
},
|
|
36998
|
-
message_1: {
|
|
36999
|
-
text: "@skill:models3d:generate Turn this reference image into a textured 3D GLB model suitable for a product mockup."
|
|
37000
|
-
},
|
|
37001
|
-
message_2: {
|
|
37002
|
-
text: '```json\n{"type":"app_skill_use","embed_id":"85716124-48d5-4c4c-9919-3126b733b41e","app_id":"models3d","skill_id":"generate"}\n```\n\nI generated a textured GLB model from the reference image and attached the 3D model preview above.'
|
|
37003
|
-
}
|
|
37004
|
-
},
|
|
37005
36751
|
right_to_repair_laws_eu_us: {
|
|
37006
36752
|
title: {
|
|
37007
36753
|
text: "Right-to-Repair Laws in the EU and US"
|
|
@@ -47391,84 +47137,6 @@ As of mid-2026, the severe supply shocks from the 2024\u20132025 avian flu have
|
|
|
47391
47137
|
first_invites: {
|
|
47392
47138
|
text: "First invites in Jan/Feb 2025"
|
|
47393
47139
|
}
|
|
47394
|
-
},
|
|
47395
|
-
workflows: {
|
|
47396
|
-
template_share: {
|
|
47397
|
-
title: {
|
|
47398
|
-
text: "Share as template"
|
|
47399
|
-
},
|
|
47400
|
-
create_link: {
|
|
47401
|
-
text: "Create template link"
|
|
47402
|
-
},
|
|
47403
|
-
import: {
|
|
47404
|
-
text: "Import template"
|
|
47405
|
-
},
|
|
47406
|
-
complete_bindings: {
|
|
47407
|
-
text: "Complete requirements and enable"
|
|
47408
|
-
},
|
|
47409
|
-
revoked: {
|
|
47410
|
-
text: "Template access revoked."
|
|
47411
|
-
}
|
|
47412
|
-
},
|
|
47413
|
-
version_history: {
|
|
47414
|
-
title: {
|
|
47415
|
-
text: "Definition history"
|
|
47416
|
-
},
|
|
47417
|
-
retention: {
|
|
47418
|
-
text: "Keeps up to {max} definitions"
|
|
47419
|
-
},
|
|
47420
|
-
retention_loading: {
|
|
47421
|
-
text: "Loading retention..."
|
|
47422
|
-
},
|
|
47423
|
-
loading: {
|
|
47424
|
-
text: "Loading definition history..."
|
|
47425
|
-
},
|
|
47426
|
-
empty: {
|
|
47427
|
-
text: "No definition history is available yet."
|
|
47428
|
-
},
|
|
47429
|
-
version: {
|
|
47430
|
-
text: "Version {version}"
|
|
47431
|
-
},
|
|
47432
|
-
current: {
|
|
47433
|
-
text: "Current"
|
|
47434
|
-
},
|
|
47435
|
-
restored: {
|
|
47436
|
-
text: "Restored"
|
|
47437
|
-
},
|
|
47438
|
-
inspecting: {
|
|
47439
|
-
text: "Loading definition..."
|
|
47440
|
-
},
|
|
47441
|
-
inspecting_version: {
|
|
47442
|
-
text: "Version {version} graph"
|
|
47443
|
-
},
|
|
47444
|
-
nodes: {
|
|
47445
|
-
text: "nodes"
|
|
47446
|
-
},
|
|
47447
|
-
restore_as_new: {
|
|
47448
|
-
text: "Restore version {version} as new current version"
|
|
47449
|
-
},
|
|
47450
|
-
restore_explanation: {
|
|
47451
|
-
text: "This creates a new current version. The selected and existing versions remain unchanged."
|
|
47452
|
-
},
|
|
47453
|
-
confirm_restore: {
|
|
47454
|
-
text: "Create new current version"
|
|
47455
|
-
},
|
|
47456
|
-
restoring: {
|
|
47457
|
-
text: "Restoring..."
|
|
47458
|
-
},
|
|
47459
|
-
restore_success: {
|
|
47460
|
-
text: "Restored version {version} as a new current version."
|
|
47461
|
-
},
|
|
47462
|
-
load_failed: {
|
|
47463
|
-
text: "Failed to load definition history."
|
|
47464
|
-
},
|
|
47465
|
-
inspect_failed: {
|
|
47466
|
-
text: "Failed to load the selected definition."
|
|
47467
|
-
},
|
|
47468
|
-
restore_failed: {
|
|
47469
|
-
text: "Failed to restore the selected definition."
|
|
47470
|
-
}
|
|
47471
|
-
}
|
|
47472
47140
|
}
|
|
47473
47141
|
};
|
|
47474
47142
|
|
|
@@ -51049,10 +50717,6 @@ function parsePositiveIntegerFlag(value, flagName) {
|
|
|
51049
50717
|
}
|
|
51050
50718
|
return parsed;
|
|
51051
50719
|
}
|
|
51052
|
-
function parseResponseTimeoutMs(flags) {
|
|
51053
|
-
const seconds = parsePositiveIntegerFlag(flags["response-timeout-seconds"], "--response-timeout-seconds");
|
|
51054
|
-
return seconds === void 0 ? void 0 : seconds * 1e3;
|
|
51055
|
-
}
|
|
51056
50720
|
function parseRemoteAccessSourceType(value) {
|
|
51057
50721
|
if (value === void 0) return "local_folder";
|
|
51058
50722
|
if (value === "local_folder" || value === "local_git_repository") {
|
|
@@ -51196,7 +50860,6 @@ async function handleChats(client, subcommand, rest, flags, redactor) {
|
|
|
51196
50860
|
autoApproveMemories: flags["auto-approve-memories"] === true,
|
|
51197
50861
|
acceptTaskProposals: flags["accept-task-proposals"] === true,
|
|
51198
50862
|
piiDetection: flags["no-pii-detection"] !== true,
|
|
51199
|
-
responseTimeoutMs: parseResponseTimeoutMs(flags),
|
|
51200
50863
|
anonymousLearningMode: client.hasSession() ? void 0 : parseAnonymousLearningModeFlags(flags)
|
|
51201
50864
|
},
|
|
51202
50865
|
redactor
|
|
@@ -51272,8 +50935,7 @@ Run 'openmates chats show ` + chatId + "' to check if suggestions have been save
|
|
|
51272
50935
|
autoApproveSubChats: flags["auto-approve"] === true,
|
|
51273
50936
|
autoApproveMemories: flags["auto-approve-memories"] === true,
|
|
51274
50937
|
acceptTaskProposals: flags["accept-task-proposals"] === true,
|
|
51275
|
-
piiDetection: flags["no-pii-detection"] !== true
|
|
51276
|
-
responseTimeoutMs: parseResponseTimeoutMs(flags)
|
|
50938
|
+
piiDetection: flags["no-pii-detection"] !== true
|
|
51277
50939
|
},
|
|
51278
50940
|
redactor
|
|
51279
50941
|
);
|
|
@@ -51302,8 +50964,7 @@ Run 'openmates chats show ` + chatId + "' to check if suggestions have been save
|
|
|
51302
50964
|
autoApproveSubChats: flags["auto-approve"] === true,
|
|
51303
50965
|
autoApproveMemories: flags["auto-approve-memories"] === true,
|
|
51304
50966
|
acceptTaskProposals: flags["accept-task-proposals"] === true,
|
|
51305
|
-
piiDetection: flags["no-pii-detection"] !== true
|
|
51306
|
-
responseTimeoutMs: parseResponseTimeoutMs(flags)
|
|
50967
|
+
piiDetection: flags["no-pii-detection"] !== true
|
|
51307
50968
|
},
|
|
51308
50969
|
redactor
|
|
51309
50970
|
);
|
|
@@ -51324,8 +50985,7 @@ Run 'openmates chats show ` + chatId + "' to check if suggestions have been save
|
|
|
51324
50985
|
json: flags.json === true,
|
|
51325
50986
|
autoApproveSubChats: flags["auto-approve"] === true,
|
|
51326
50987
|
autoApproveMemories: flags["auto-approve-memories"] === true,
|
|
51327
|
-
piiDetection: flags["no-pii-detection"] !== true
|
|
51328
|
-
responseTimeoutMs: parseResponseTimeoutMs(flags)
|
|
50988
|
+
piiDetection: flags["no-pii-detection"] !== true
|
|
51329
50989
|
},
|
|
51330
50990
|
redactor
|
|
51331
50991
|
);
|
|
@@ -54727,7 +54387,6 @@ async function sendMessageStreaming(client, params, redactor) {
|
|
|
54727
54387
|
onSubChatApprovalRequest,
|
|
54728
54388
|
autoApproveSubChats: params.autoApproveSubChats,
|
|
54729
54389
|
autoApproveMemories: params.autoApproveMemories,
|
|
54730
|
-
responseTimeoutMs: params.responseTimeoutMs,
|
|
54731
54390
|
learningMode,
|
|
54732
54391
|
preparedEmbeds: preparedEmbeds.length > 0 ? preparedEmbeds : void 0,
|
|
54733
54392
|
piiMappings: piiResult.mappings.map((mapping) => ({
|
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1205,8 +1205,6 @@ declare class OpenMatesClient {
|
|
|
1205
1205
|
learningMode?: LearningModeContext;
|
|
1206
1206
|
/** Start collecting before send for latency-sensitive benchmark turns. */
|
|
1207
1207
|
precollectResponse?: boolean;
|
|
1208
|
-
/** Override the WebSocket AI response collection timeout for long-running turns. */
|
|
1209
|
-
responseTimeoutMs?: number;
|
|
1210
1208
|
}): Promise<{
|
|
1211
1209
|
status: "completed" | "waiting_for_user";
|
|
1212
1210
|
chatId: string;
|
|
@@ -1235,8 +1233,6 @@ declare class OpenMatesClient {
|
|
|
1235
1233
|
entryCount: number;
|
|
1236
1234
|
}>;
|
|
1237
1235
|
}>;
|
|
1238
|
-
private persistEncryptedSystemMessage;
|
|
1239
|
-
private persistPendingTaskUpdateJobs;
|
|
1240
1236
|
private persistStreamedEmbeds;
|
|
1241
1237
|
private persistPostProcessingMetadata;
|
|
1242
1238
|
/**
|
|
@@ -1368,7 +1364,6 @@ declare class OpenMatesClient {
|
|
|
1368
1364
|
status?: UserTaskStatus;
|
|
1369
1365
|
chatId?: string;
|
|
1370
1366
|
projectId?: string;
|
|
1371
|
-
limit?: number;
|
|
1372
1367
|
}): Promise<UserTaskRecord[]>;
|
|
1373
1368
|
createUserTask(input: UserTaskCreateInput): Promise<UserTaskRecord>;
|
|
1374
1369
|
extractUserTaskProposals(input: {
|
package/dist/index.js
CHANGED