openmates 0.27.0-alpha.81 → 0.27.0-alpha.82

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.
@@ -6256,6 +6256,68 @@ function parseFocusAuthoringDocument(document) {
6256
6256
  throw new Error("invalid_focus_document");
6257
6257
  }
6258
6258
  }
6259
+ async function collectSelectedCliProjectFocusRoutingCatalog(client2, projectId, options) {
6260
+ const detail = await client2.getProject(projectId, options);
6261
+ if (detail.project.project_id !== projectId || detail.project.archived) throw new Error("Project catalog unavailable.");
6262
+ const key = await client2.decryptProjectKey(detail.project, options);
6263
+ const focuses = [];
6264
+ for (const item of detail.items) {
6265
+ if (!(["embed", "upload"].includes(item.item_type) && item.target_id_hash && !item.deleted_target_state && typeof item.encrypted_metadata === "string")) continue;
6266
+ const decrypted = await decryptWithAesGcmCombined(item.encrypted_metadata, key);
6267
+ if (!decrypted) throw new Error("Project catalog metadata unavailable.");
6268
+ const metadata = JSON.parse(decrypted);
6269
+ const path2 = metadata.display_path;
6270
+ if (typeof path2 !== "string" || !/^\.openmates\/focuses\/[a-zA-Z0-9_-]+\/SKILL\.md$/.test(path2) || typeof metadata.focus_title !== "string" || typeof metadata.focus_description !== "string" || typeof metadata.focus_when_to_use !== "string") continue;
6271
+ focuses.push({
6272
+ item_id: item.project_item_id,
6273
+ revision: createHash9("sha256").update(["updated_at", "encrypted_metadata", "encrypted_note", "target_id_hash", "deleted_target_state"].map((field3) => item[field3] ? String(item[field3]) : "").join("\0")).digest("hex"),
6274
+ title: metadata.focus_title.slice(0, 180),
6275
+ description: metadata.focus_description.slice(0, 640),
6276
+ when_to_use: metadata.focus_when_to_use.slice(0, 640)
6277
+ });
6278
+ if (focuses.length >= 20) break;
6279
+ }
6280
+ return focuses;
6281
+ }
6282
+ function registerCliProjectFocusCatalogResponder(input) {
6283
+ let active = true;
6284
+ const answered = /* @__PURE__ */ new Set();
6285
+ const stopEvent = input.ws.onMessageType("project_focus_catalog_requested", (event) => {
6286
+ if (!active || !input.ws.isOpen() || !input.isCurrent() || event.chat_id !== input.chatId || typeof event.request_id !== "string" || !event.request_id || event.request_id.length > 128 || typeof event.project_id !== "string" || !event.project_id || event.project_id.length > 128 || event.team_id !== input.teamId || !input.isOfferedProject(event.project_id) || answered.has(event.request_id)) return;
6287
+ answered.add(event.request_id);
6288
+ void (async () => {
6289
+ let focuses;
6290
+ try {
6291
+ focuses = await collectSelectedCliProjectFocusRoutingCatalog(
6292
+ input.client,
6293
+ event.project_id,
6294
+ { teamId: input.teamId, personal: !input.teamId }
6295
+ );
6296
+ } catch {
6297
+ focuses = null;
6298
+ }
6299
+ if (!active || !input.ws.isOpen() || !input.isCurrent()) return;
6300
+ await input.ws.sendAsync("project_focus_catalog_result", {
6301
+ chat_id: input.chatId,
6302
+ request_id: event.request_id,
6303
+ project_id: event.project_id,
6304
+ focuses
6305
+ });
6306
+ })().catch((error) => {
6307
+ if (!active || !input.ws.isOpen() || !input.isCurrent()) return;
6308
+ input.onDeliveryFailure(error instanceof Error ? error : new Error("Project catalog delivery failed."));
6309
+ });
6310
+ });
6311
+ const stopClose = input.ws.onClose(() => {
6312
+ active = false;
6313
+ stopEvent();
6314
+ });
6315
+ return () => {
6316
+ active = false;
6317
+ stopEvent();
6318
+ stopClose();
6319
+ };
6320
+ }
6259
6321
  async function discoverCliProjectCandidates(client2, options, requireComplete = false) {
6260
6322
  const records = (await client2.listProjects(options)).filter((record10) => !record10.archived).slice(0, 40);
6261
6323
  const entries = await Promise.all(records.map(async (record10) => {
@@ -16762,9 +16824,12 @@ var OpenMatesClient = class _OpenMatesClient {
16762
16824
  });
16763
16825
  void projectRoutingContext.catch(() => {
16764
16826
  });
16827
+ const catalogEligibleProjectIds = /* @__PURE__ */ new Set();
16765
16828
  const publishProjectRoutingTimed = (context) => {
16766
16829
  projectCandidatesReadyFromSendStartMs ??= Math.round(performance.now() - preWsStartedAt);
16767
- publishProjectRouting(deferredProjectDirectory ? { ...context, project_focus_candidates: context.project_focus_candidates?.filter((candidate) => candidate.auto_selection === true) } : context);
16830
+ const offered = context.project_focus_candidates?.filter((candidate) => candidate.auto_selection === true) ?? [];
16831
+ for (const candidate of offered) catalogEligibleProjectIds.add(candidate.project_id);
16832
+ publishProjectRouting(deferredProjectDirectory ? { ...context, project_focus_candidates: offered } : context);
16768
16833
  };
16769
16834
  let recoveryMs = 0;
16770
16835
  const contextOwnerIsCurrent = () => {
@@ -16793,6 +16858,23 @@ var OpenMatesClient = class _OpenMatesClient {
16793
16858
  throw error;
16794
16859
  }
16795
16860
  const { ws, ownerId: ownerId2 } = opened;
16861
+ let catalogTurnId = null;
16862
+ let rejectCatalogDelivery;
16863
+ const catalogDeliveryFailure = new Promise((_resolve, reject) => {
16864
+ rejectCatalogDelivery = reject;
16865
+ });
16866
+ void catalogDeliveryFailure.catch(() => {
16867
+ });
16868
+ const stopProjectCatalogResponder = !params.incognito ? registerCliProjectFocusCatalogResponder({
16869
+ ws,
16870
+ client: this,
16871
+ chatId,
16872
+ teamId: teamId ?? null,
16873
+ isCurrent: () => contextOwnerIsCurrent() && !!catalogTurnId && this.activeSubmittedChatTurns.get(chatId) === catalogTurnId,
16874
+ isOfferedProject: (projectId) => catalogEligibleProjectIds.has(projectId),
16875
+ onDeliveryFailure: (error) => rejectCatalogDelivery(error)
16876
+ }) : () => {
16877
+ };
16796
16878
  const consumeSocketMemoryReceipt = async () => {
16797
16879
  if (!socketMemoryReceipt) return;
16798
16880
  const receipt = socketMemoryReceipt;
@@ -17237,6 +17319,7 @@ var OpenMatesClient = class _OpenMatesClient {
17237
17319
  const chatKeyVersion = 1;
17238
17320
  const turnId = privacyTurnId;
17239
17321
  savedTurnId = turnId;
17322
+ catalogTurnId = turnId;
17240
17323
  terminalExpectedMessagesV = baselineMessagesV + 1;
17241
17324
  const recoveryKeypairStartedAt = performance.now();
17242
17325
  const recoveryKeypair = independentRecoveryKeypair ? await independentRecoveryKeypair : await deriveChatCompletionRecoveryKeypair(
@@ -17611,7 +17694,7 @@ var OpenMatesClient = class _OpenMatesClient {
17611
17694
  admissionContinuationPhase = "await_details";
17612
17695
  let context;
17613
17696
  try {
17614
- context = await Promise.race([pendingContext, contextAckRejection]);
17697
+ context = await Promise.race([pendingContext, contextAckRejection, catalogDeliveryFailure]);
17615
17698
  } catch (error) {
17616
17699
  try {
17617
17700
  await notifyContextFailure("context_preparation_failed");
@@ -17641,7 +17724,7 @@ var OpenMatesClient = class _OpenMatesClient {
17641
17724
  await consumeSocketMemoryReceipt();
17642
17725
  await ws.sendAsync("chat_message_added", messagePayload);
17643
17726
  }
17644
- confirmedPayload = (await (contextAckRejection ? Promise.race([confirmed, contextAckRejection]) : confirmed)).payload;
17727
+ confirmedPayload = (await Promise.race([confirmed, catalogDeliveryFailure, ...contextAckRejection ? [contextAckRejection] : []])).payload;
17645
17728
  } catch (error) {
17646
17729
  if (process.env.OPENMATES_DEBUG === "1" && admissionPayload) {
17647
17730
  console.error(`[chat admission continuation] phase=${admissionContinuationPhase} ack_observed=${admissionAckObserved} routing_sent=${routingFrameSent} details_sent=${detailsFrameSent} socket_open=${ws.isOpen()} elapsed_ms=${Math.round(performance.now() - admissionContinuationStartedAt)}`);
@@ -17944,6 +18027,7 @@ var OpenMatesClient = class _OpenMatesClient {
17944
18027
  const outcome = await Promise.race([
17945
18028
  responsePromise.then((response) => ({ kind: "response", response })),
17946
18029
  ...contextAckRejection ? [contextAckRejection] : [],
18030
+ catalogDeliveryFailure,
17947
18031
  ...queuedAdmission ? [queuedAdmission.then(
17948
18032
  (frame) => ({ kind: "queued", frame }),
17949
18033
  () => new Promise(() => {
@@ -18335,6 +18419,7 @@ var OpenMatesClient = class _OpenMatesClient {
18335
18419
  promptBudget
18336
18420
  };
18337
18421
  } finally {
18422
+ stopProjectCatalogResponder();
18338
18423
  removeContextAckWatcher?.();
18339
18424
  earlyContextAbort.abort();
18340
18425
  if (!metadataTransportOwned) {
package/dist/cli.js CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  shouldRequireTrustedAccountGuard,
22
22
  waitForSafeE2ETotpWindow,
23
23
  waitForWorkflowRun
24
- } from "./chunk-EGFP6UOU.js";
24
+ } from "./chunk-4TPIRQDS.js";
25
25
  import "./chunk-IWKP55ZB.js";
26
26
  import "./chunk-F2U6KIMR.js";
27
27
  import "./chunk-W5Q6FXNZ.js";
package/dist/index.js CHANGED
@@ -44,7 +44,7 @@ import {
44
44
  selectAssistantMessagesForSpeech,
45
45
  serializeToYaml,
46
46
  summarizeAssistantSpeech
47
- } from "./chunk-EGFP6UOU.js";
47
+ } from "./chunk-4TPIRQDS.js";
48
48
  import "./chunk-IWKP55ZB.js";
49
49
  import "./chunk-F2U6KIMR.js";
50
50
  import "./chunk-W5Q6FXNZ.js";
@@ -17,47 +17,47 @@
17
17
  {
18
18
  "name": "libggml-base.so",
19
19
  "bytes": 1110088,
20
- "sha256": "929dc98685d3d1eb8bd0c15b615dadbbe5d6a0083078500938333de4e5e42668"
20
+ "sha256": "8a6749ade507876bf909237f62fa0577726699bfbca3f341589dc6944d2f755d"
21
21
  },
22
22
  {
23
23
  "name": "libggml-base.so.0",
24
24
  "bytes": 1110088,
25
- "sha256": "929dc98685d3d1eb8bd0c15b615dadbbe5d6a0083078500938333de4e5e42668"
25
+ "sha256": "8a6749ade507876bf909237f62fa0577726699bfbca3f341589dc6944d2f755d"
26
26
  },
27
27
  {
28
28
  "name": "libggml-base.so.0.15.1",
29
29
  "bytes": 1110088,
30
- "sha256": "929dc98685d3d1eb8bd0c15b615dadbbe5d6a0083078500938333de4e5e42668"
30
+ "sha256": "8a6749ade507876bf909237f62fa0577726699bfbca3f341589dc6944d2f755d"
31
31
  },
32
32
  {
33
33
  "name": "libggml-cpu.so",
34
34
  "bytes": 869800,
35
- "sha256": "93abad6bbcaab3650f5cbc309b95311798a39e5a7a2367be0a21dba86d67c59c"
35
+ "sha256": "306bf34b560dcbf3b81a9fb8a3722af6dd180e3025843e9f428319adfb085d79"
36
36
  },
37
37
  {
38
38
  "name": "libggml-cpu.so.0",
39
39
  "bytes": 869800,
40
- "sha256": "93abad6bbcaab3650f5cbc309b95311798a39e5a7a2367be0a21dba86d67c59c"
40
+ "sha256": "306bf34b560dcbf3b81a9fb8a3722af6dd180e3025843e9f428319adfb085d79"
41
41
  },
42
42
  {
43
43
  "name": "libggml-cpu.so.0.15.1",
44
44
  "bytes": 869800,
45
- "sha256": "93abad6bbcaab3650f5cbc309b95311798a39e5a7a2367be0a21dba86d67c59c"
45
+ "sha256": "306bf34b560dcbf3b81a9fb8a3722af6dd180e3025843e9f428319adfb085d79"
46
46
  },
47
47
  {
48
48
  "name": "libggml.so",
49
49
  "bytes": 1899104,
50
- "sha256": "8707b74abcf21714e099e5ee49cf5430b018e4c981a4ca335b8f0ed13e506dce"
50
+ "sha256": "dbb5d4755fd99c2dfe3951dff8e776404c02269181cb699e49831bef6c522197"
51
51
  },
52
52
  {
53
53
  "name": "libggml.so.0",
54
54
  "bytes": 1899104,
55
- "sha256": "8707b74abcf21714e099e5ee49cf5430b018e4c981a4ca335b8f0ed13e506dce"
55
+ "sha256": "dbb5d4755fd99c2dfe3951dff8e776404c02269181cb699e49831bef6c522197"
56
56
  },
57
57
  {
58
58
  "name": "libggml.so.0.15.1",
59
59
  "bytes": 1899104,
60
- "sha256": "8707b74abcf21714e099e5ee49cf5430b018e4c981a4ca335b8f0ed13e506dce"
60
+ "sha256": "dbb5d4755fd99c2dfe3951dff8e776404c02269181cb699e49831bef6c522197"
61
61
  },
62
62
  {
63
63
  "name": "openmates-pii-worker",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openmates",
3
- "version": "0.27.0-alpha.81",
3
+ "version": "0.27.0-alpha.82",
4
4
  "description": "OpenMates CLI and SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",