@hellolynk-ai/codex-plugin 0.2.105 → 0.2.106

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.
@@ -2,7 +2,7 @@
2
2
  "contract": "hellolynk-client-npm-pack-manifest-v1",
3
3
  "client": "codex",
4
4
  "packageName": "@hellolynk-ai/codex-plugin",
5
- "version": "0.2.105",
5
+ "version": "0.2.106",
6
6
  "workbench": {
7
7
  "path": "plugins/hellolynk-codex/runtime/workbench/hellolynk-workbench-build.json",
8
8
  "contract": "hellolynk-shared-workbench-build-v1",
@@ -33,7 +33,7 @@
33
33
  {
34
34
  "path": "package.json",
35
35
  "bytes": 1713,
36
- "sha256": "dc87461d38712659f1d25a3964cd9ab468ef99d859d038900ac1a277328d103e"
36
+ "sha256": "75f7b55fc72259e623dc90751afc7cc4f936247644a9065a6c6d2bcdbafc3757"
37
37
  },
38
38
  {
39
39
  "path": "plugins/hellolynk-codex/.app.json",
@@ -43,7 +43,7 @@
43
43
  {
44
44
  "path": "plugins/hellolynk-codex/.codex-plugin/plugin.json",
45
45
  "bytes": 1669,
46
- "sha256": "dc33e34ece594590424d3ec1508409e07a02741db5d93d368824e46f12c095a2"
46
+ "sha256": "1c05e06618d2e44cd3f78f8de999db93b434366280f8b78a9aca4d08565607ff"
47
47
  },
48
48
  {
49
49
  "path": "plugins/hellolynk-codex/.mcp.json",
@@ -58,7 +58,7 @@
58
58
  {
59
59
  "path": "plugins/hellolynk-codex/package.json",
60
60
  "bytes": 1030,
61
- "sha256": "be5fc524bab2f659f8f1e851bd1c59c6edf2a5fd4394c1a917a8d5ee9321190e"
61
+ "sha256": "a1167379affa28c595008e826ff854536d75b34d440a11963428d978230170f1"
62
62
  },
63
63
  {
64
64
  "path": "plugins/hellolynk-codex/runtime/bootstrap/core/hellolynk-client-account.mjs",
@@ -322,8 +322,8 @@
322
322
  },
323
323
  {
324
324
  "path": "plugins/hellolynk-codex/runtime/core/hellolynk-neutral-host-assembly.mjs",
325
- "bytes": 46294,
326
- "sha256": "287ad6e077c8da05799b970ffa6607d8c7a0ab54a4837de51516e6af0ef6695b"
325
+ "bytes": 46525,
326
+ "sha256": "b63c3371dfc08d8b15a4fd5ce84c61b40d9e7011424ccb3ff11466adb4f862cc"
327
327
  },
328
328
  {
329
329
  "path": "plugins/hellolynk-codex/runtime/core/hellolynk-neutral-host-installation-store.mjs",
@@ -337,8 +337,8 @@
337
337
  },
338
338
  {
339
339
  "path": "plugins/hellolynk-codex/runtime/core/hellolynk-neutral-host-process.mjs",
340
- "bytes": 225161,
341
- "sha256": "ad6809633f49f7316acf6ce5b8f71a13d7ba20d3b62a2700664421ba671b5369"
340
+ "bytes": 229709,
341
+ "sha256": "34b985f75bc693954eb66bb788fc2814482bb8bf402f14b72ea2faf5f70cf4ea"
342
342
  },
343
343
  {
344
344
  "path": "plugins/hellolynk-codex/runtime/core/hellolynk-neutral-host-store-adapters.mjs",
@@ -398,12 +398,12 @@
398
398
  {
399
399
  "path": "plugins/hellolynk-codex/runtime/neutral-host-release-manifest.json",
400
400
  "bytes": 14038,
401
- "sha256": "e5fcbb78060749b928487d97b59bccb4a2762ddf2f00896637d472818c933564"
401
+ "sha256": "3d5f398ad123ccbcc1a39dcbba88d55fa2a83f620a7bfff3f99a9c87b807bd24"
402
402
  },
403
403
  {
404
404
  "path": "plugins/hellolynk-codex/runtime/neutral-host-release-pin.json",
405
405
  "bytes": 146,
406
- "sha256": "207213795005e40f36d7b238d9f6c689925dc6c1d1ed6fc17449cf7f80777636"
406
+ "sha256": "1c4121aeb65b7437a33ed79a5614bef2bb22a0f94655f5470d4e528c37819c45"
407
407
  },
408
408
  {
409
409
  "path": "plugins/hellolynk-codex/runtime/platform/windows/configure-agent.ps1",
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "contract": "hellolynk-client-npm-pack-pin-v1",
3
- "manifestSha256": "346f4ca1d82c430ac3a49f0182f84836cb7e2c089d5b05b548bd2b3cb13b30ab"
3
+ "manifestSha256": "77fc5c130c05eb84eda346c841b4581e6bfb733021db56924ae6bb36b4133e30"
4
4
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hellolynk-ai/codex-plugin",
3
- "version": "0.2.105",
3
+ "version": "0.2.106",
4
4
  "description": "HelloLynk Messaging for Codex: open conversations and let your AI message other people's AI assistants.",
5
5
  "homepage": "https://hellolynk.com",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hellolynk-codex",
3
- "version": "0.2.105",
3
+ "version": "0.2.106",
4
4
  "description": "HelloLynk 通讯、本地未读提醒与安全文字收发的 Codex 插件。",
5
5
  "author": {
6
6
  "name": "HelloLynk local project"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hellolynk-ai/codex-plugin",
3
- "version": "0.2.105",
3
+ "version": "0.2.106",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "Project-local HelloLynk Messaging, unread notification, and secure messaging plugin for Codex.",
@@ -334,6 +334,9 @@ export async function startHelloLynkNeutralHostAssembly(options = {}, dependenci
334
334
  authorizationVersion: profile.authorizationVersion,
335
335
  identityKeyId: e2ee.identityKeyId,
336
336
  runtimeHeaders: () => runtimeHeaders(sessionProvider),
337
+ // Drops only this instance's cached runtime session, and only for a stale
338
+ // session, so the Host can verify it once more with the device credential.
339
+ clearRuntimeSession: (error) => sessionProvider.clear(error),
337
340
  e2ee,
338
341
  contactE2ee,
339
342
  }));
@@ -1,6 +1,7 @@
1
1
  import { nativeConversationId, nativeConversationQuery, nativeDirectoryResult, queryLocalNativeConversations } from "./hellolynk-native-conversations.mjs";
2
2
  import { DIRECT_TEXT_E2EE_MAX_TTL_MS } from "./hellolynk-direct-text-e2ee.mjs";
3
3
  import { runModelInbox } from "./hellolynk-model-inbox.mjs";
4
+ import { shouldInvalidateDeviceRuntimeSession } from "./hellolynk-client-core.mjs";
4
5
  import crypto from "node:crypto";
5
6
  import fs from "node:fs/promises";
6
7
  import http from "node:http";
@@ -34,7 +35,7 @@ export const HELLOLYNK_NEUTRAL_HOST_PROCESS_CONTRACT = "hellolynk-neutral-host-p
34
35
  export const HELLOLYNK_NEUTRAL_HOST_DISCOVERY_CONTRACT = "hellolynk-neutral-host-discovery-v1";
35
36
  // Raised with every release batch, together with the six client versions. A Host reports it
36
37
  // in its health; the higher release stays and the lower one makes room.
37
- export const HELLOLYNK_HOST_RELEASE_ORDINAL = 17;
38
+ export const HELLOLYNK_HOST_RELEASE_ORDINAL = 18;
38
39
 
39
40
  const INSTALLATION_LOCK_CONTRACT = "hellolynk-neutral-host-installation-lock-v2";
40
41
  const INSTALLATION_LOCK_MAX_BYTES = 4 * 1024;
@@ -97,9 +98,16 @@ const PREKEY_REFILL_RETRY_MIN_MS = 1_000;
97
98
  const PREKEY_REFILL_RETRY_MAX_MS = 60_000;
98
99
  const RELAY_RETRY_MIN_MS = 1_000;
99
100
  const RELAY_RETRY_MAX_MS = 60_000;
100
- const RELAY_AUTHORITY_DENIAL_CODES = new Set([
101
+ // Revocation of this Host or its transport credential fences the whole Host.
102
+ const HOST_AUTHORITY_DENIAL_CODES = new Set([
101
103
  "host_transport_host_revoked", "host_transport_credential_revoked", "host_transport_credential_inactive",
104
+ ]);
105
+ // A refusal of one instance's own device credential or delegate stops only that
106
+ // instance. The Host and its other instances keep receiving and sending. The
107
+ // server reports these when issuing or using that instance's runtime session.
108
+ const ENDPOINT_AUTHORITY_DENIAL_CODES = new Set([
102
109
  "device_credential_invalid", "device_credential_revoked", "delegate_revoked", "delegate_inactive",
110
+ "device_credential_identity_inactive", "device_credential_inactive", "runtime_identity_inactive",
103
111
  ]);
104
112
  const MESSAGE_LOCAL_CAPACITY_CODES = new Set(["local_message_store_too_large"]);
105
113
  const CONTACT_REQUEST_LOCAL_CAPACITY_CODES = new Set([
@@ -247,6 +255,9 @@ export async function startHelloLynkNeutralHostProcess(options = {}) {
247
255
  let receiverState = null;
248
256
  const relayAbortController = new AbortController();
249
257
  const relayProvisionedEndpoints = new Set();
258
+ // Refused instances and their refusal code. Only a later successful registration
259
+ // (the next relay connection or session rotation) readmits one.
260
+ const rejectedEndpoints = new Map();
250
261
  const relayState = { status: "connecting", failureCount: 0, nextAttemptAtMs: 0, errorCode: null };
251
262
  const rejectedInboundTimes = new WeakSet();
252
263
  let lastRejectedInbound = null;
@@ -600,6 +611,20 @@ export async function startHelloLynkNeutralHostProcess(options = {}) {
600
611
  lastRejectedInbound = { errorCode: error.code };
601
612
  continue;
602
613
  }
614
+ // The frame's own instance was refused (for example at ACK). Stop only that
615
+ // instance and skip the frame; the relay expires or redelivers it.
616
+ const refused = ENDPOINT_AUTHORITY_DENIAL_CODES.has(error?.code)
617
+ && endpoints.get(String(item.data?.recipientDelegateId || ""));
618
+ if (refused) {
619
+ rejectedEndpoints.set(refused.delegateId, error.code);
620
+ relayState.errorCode = error.code;
621
+ lastRejectedInbound = { errorCode: error.code };
622
+ continue;
623
+ }
624
+ // A stale runtime session (such as a revocation landing between persist and
625
+ // ACK) is not a local failure. Reconnect: registration verifies that instance
626
+ // again and isolates it if refused. The durable record stays; the relay redelivers.
627
+ if (shouldInvalidateDeviceRuntimeSession(error)) throw error;
603
628
  if (!isInboundLocalCapacityError(error)) {
604
629
  inboundFailed = true;
605
630
  throw error;
@@ -612,7 +637,7 @@ export async function startHelloLynkNeutralHostProcess(options = {}) {
612
637
  } catch (error) {
613
638
  if (lifecycle !== "running") return;
614
639
  // Preserve fail-closed persistence/ACK and other malformed-inbound errors.
615
- if (inboundFailed || RELAY_AUTHORITY_DENIAL_CODES.has(error?.code)) throw error;
640
+ if (inboundFailed || HOST_AUTHORITY_DENIAL_CODES.has(error?.code)) throw error;
616
641
  await stream?.close?.().catch(() => {});
617
642
  stream = null;
618
643
  scheduleRelayRetry(error);
@@ -638,31 +663,63 @@ export async function startHelloLynkNeutralHostProcess(options = {}) {
638
663
  const task = (async () => {
639
664
  let connected = null;
640
665
  try {
641
- const registrations = await Promise.allSettled([...endpoints.values()].map(async (endpoint) => {
642
- if (endpoint.e2ee?.preKeyInventoryStatus?.status === "deferred"
643
- && !relayProvisionedEndpoints.has(endpoint.delegateId)) {
644
- try {
645
- await endpoint.e2ee.ensurePreKeyInventory({ signal });
646
- } catch (error) {
647
- if (error?.code !== "e2ee_local_prekey_capacity_exceeded") throw error;
648
- const state = preKeyRefillState(endpoint.delegateId);
649
- state.failureCount = 1;
650
- state.nextAttemptAtMs = Math.max(nowMs(clock) + PREKEY_REFILL_RETRY_MIN_MS, retryAtTimestamp(error.retryAt) || 0);
651
- state.errorCode = error.code;
666
+ const attempted = [...endpoints.values()];
667
+ const registrations = await Promise.allSettled(attempted.map(async (endpoint) => {
668
+ const register = async () => {
669
+ if (endpoint.e2ee?.preKeyInventoryStatus?.status === "deferred"
670
+ && !relayProvisionedEndpoints.has(endpoint.delegateId)) {
671
+ try {
672
+ await endpoint.e2ee.ensurePreKeyInventory({ signal });
673
+ } catch (error) {
674
+ if (error?.code !== "e2ee_local_prekey_capacity_exceeded") throw error;
675
+ const state = preKeyRefillState(endpoint.delegateId);
676
+ state.failureCount = 1;
677
+ state.nextAttemptAtMs = Math.max(nowMs(clock) + PREKEY_REFILL_RETRY_MIN_MS, retryAtTimestamp(error.retryAt) || 0);
678
+ state.errorCode = error.code;
679
+ }
680
+ relayProvisionedEndpoints.add(endpoint.delegateId);
652
681
  }
653
- relayProvisionedEndpoints.add(endpoint.delegateId);
682
+ if (signal.aborted || lifecycle !== "running") return;
683
+ await options.transport.registerEndpoint({
684
+ delegateId: endpoint.delegateId, identityKeyId: endpoint.identityKeyId,
685
+ runtimeHeaders: endpoint.runtimeHeaders, signal,
686
+ });
687
+ };
688
+ try {
689
+ await register();
690
+ } catch (error) {
691
+ // Revoking an instance also drops its runtime session, so its cached session
692
+ // fails first. Clear only that stale cache and verify once more: a device
693
+ // refusal then isolates the instance; any other failure keeps the usual path.
694
+ const cleared = !shouldInvalidateDeviceRuntimeSession(error) || signal.aborted || lifecycle !== "running"
695
+ || typeof endpoint.clearRuntimeSession !== "function" ? false
696
+ : await Promise.resolve().then(() => endpoint.clearRuntimeSession(error)).catch(() => false);
697
+ if (cleared !== true) throw error;
698
+ await register();
654
699
  }
655
- if (signal.aborted || lifecycle !== "running") return;
656
- await options.transport.registerEndpoint({
657
- delegateId: endpoint.delegateId, identityKeyId: endpoint.identityKeyId,
658
- runtimeHeaders: endpoint.runtimeHeaders, signal,
659
- });
660
700
  }));
661
701
  if (signal.aborted || lifecycle !== "running") return;
662
- const failed = registrations.find((result) => result.status === "rejected"
663
- && RELAY_AUTHORITY_DENIAL_CODES.has(result.reason?.code))
664
- || registrations.find((result) => result.status === "rejected");
702
+ const hostDenial = registrations.find((result) => result.status === "rejected"
703
+ && HOST_AUTHORITY_DENIAL_CODES.has(result.reason?.code));
704
+ if (hostDenial) throw hostDenial.reason;
705
+ // A refused instance stays out of the relay while the others connect. Each
706
+ // later connection, including session rotation, registers it again.
707
+ registrations.forEach((result, index) => {
708
+ if (result.status === "fulfilled") rejectedEndpoints.delete(attempted[index].delegateId);
709
+ else if (ENDPOINT_AUTHORITY_DENIAL_CODES.has(result.reason?.code)) {
710
+ rejectedEndpoints.set(attempted[index].delegateId, result.reason.code);
711
+ }
712
+ });
713
+ // A refused instance whose re-verification fails for another reason (such as
714
+ // its dropped runtime session) stays refused and does not hold back the others.
715
+ const failed = registrations.find((result, index) => result.status === "rejected"
716
+ && !rejectedEndpoints.has(attempted[index].delegateId));
665
717
  if (failed) throw failed.reason;
718
+ // With every instance refused there is nothing to receive: keep the Host and
719
+ // retry with the usual backoff. The session manager bounds cloud rechecks.
720
+ if (rejectedEndpoints.size === endpoints.size) {
721
+ throw registrations.find((result) => result.status === "rejected").reason;
722
+ }
666
723
  connected = await openRelayStream(signal);
667
724
  if (!connected?.events || typeof connected.events[Symbol.asyncIterator] !== "function") {
668
725
  throw failure("neutral_host_transport_stream_invalid");
@@ -672,14 +729,15 @@ export async function startHelloLynkNeutralHostProcess(options = {}) {
672
729
  return;
673
730
  }
674
731
  stream = connected;
675
- Object.assign(relayState, { status: "ready", failureCount: 0, nextAttemptAtMs: 0, errorCode: null });
732
+ Object.assign(relayState, { status: "ready", failureCount: 0, nextAttemptAtMs: 0,
733
+ errorCode: rejectedEndpoints.values().next().value ?? null });
676
734
  startReceiveTask();
677
735
  } catch (error) {
678
736
  await connected?.close?.().catch(() => {});
679
737
  if (signal.aborted || lifecycle !== "running") return;
680
738
  // An explicit revocation of this Host still fences local access. A
681
739
  // timeout/expired cloud session alone is not a local revocation.
682
- if (RELAY_AUTHORITY_DENIAL_CODES.has(error?.code)) {
740
+ if (HOST_AUTHORITY_DENIAL_CODES.has(error?.code)) {
683
741
  // Failure is exposed as host.status/failureCode to the release entry.
684
742
  void beginDrain(error.code).catch(() => {});
685
743
  return;
@@ -733,6 +791,14 @@ export async function startHelloLynkNeutralHostProcess(options = {}) {
733
791
  }
734
792
  const endpoint = endpoints.get(safeId(event.recipientDelegateId, "neutral_host_inbound_delegate_invalid"));
735
793
  if (!endpoint) throw failure("neutral_host_inbound_endpoint_unknown");
794
+ if (rejectedEndpoints.has(endpoint.delegateId)) {
795
+ // A refused instance receives nothing, also not from its Host's siblings.
796
+ // Relay frames are skipped unacknowledged; a local sender sees the failure.
797
+ const refused = failure(item.localDelivery === true
798
+ ? "neutral_host_same_host_recipient_unavailable" : rejectedEndpoints.get(endpoint.delegateId));
799
+ rejectedInboundTimes.add(refused);
800
+ throw refused;
801
+ }
736
802
  const isContactRequest = item.event === "contact_request";
737
803
  if (!isContactRequest && item.event !== "message") throw failure("neutral_host_inbound_kind_invalid");
738
804
  const decryptor = isContactRequest ? endpoint.contactE2ee : endpoint.e2ee;
@@ -1015,7 +1081,14 @@ export async function startHelloLynkNeutralHostProcess(options = {}) {
1015
1081
  return inboundResumeTask;
1016
1082
  }
1017
1083
 
1084
+ // A refused instance does not send, including over local routes that skip the relay.
1085
+ function assertEndpointAccepted(delegateId) {
1086
+ const code = rejectedEndpoints.get(delegateId);
1087
+ if (code) throw hostApplicationFailure(code);
1088
+ }
1089
+
1018
1090
  async function sendOutboundOnce({ endpoint, delegateId, clientMessageId, input }) {
1091
+ assertEndpointAccepted(endpoint.delegateId);
1019
1092
  try {
1020
1093
  const result = await endpoint.outbound.send(input);
1021
1094
  if (result?.message?.lastErrorCode === "reply_target_deleted" || result?.relay?.status === "reply_target_deleted") {
@@ -1529,6 +1602,7 @@ export async function startHelloLynkNeutralHostProcess(options = {}) {
1529
1602
  async function queryPeerNativeDirectory(delegateId, authorization, request) {
1530
1603
  const sender = endpoints.get(delegateId);
1531
1604
  if (!sender?.outbound?.sendDirectory) throw hostApplicationFailure("native_directory_unavailable");
1605
+ assertEndpointAccepted(delegateId);
1532
1606
  const friend = request.kind === "friend_target_request";
1533
1607
  const unavailable = friend ? null : nativeDirectoryResult({ conversations: [], coverage: "unavailable",
1534
1608
  available: false, exactTargetSupported: false, reason: "native_directory_unavailable" });
@@ -2274,6 +2348,7 @@ export async function startHelloLynkNeutralHostProcess(options = {}) {
2274
2348
  || current.senderDelegateId !== context.delegateId) {
2275
2349
  throw hostApplicationFailure("host_app_record_not_found");
2276
2350
  }
2351
+ assertEndpointAccepted(context.delegateId);
2277
2352
  if (!MANUAL_RETRYABLE_STATUSES.has(current.status) || current.lastErrorCode === "reply_target_deleted") {
2278
2353
  throw hostApplicationFailure("host_app_state_conflict");
2279
2354
  }
@@ -3120,7 +3195,8 @@ export async function startHelloLynkNeutralHostProcess(options = {}) {
3120
3195
  return {
3121
3196
  status: inboundPaused
3122
3197
  ? "paused"
3123
- : preKeyInventory.status === "ready" && relayState.status === "ready" && !lastRejectedInbound ? "ready" : "degraded",
3198
+ : preKeyInventory.status === "ready" && relayState.status === "ready" && !lastRejectedInbound
3199
+ && rejectedEndpoints.size === 0 ? "ready" : "degraded",
3124
3200
  ...(lastRejectedInbound ? { lastRejectedInbound } : {}),
3125
3201
  preKeyInventory,
3126
3202
  relay: {
@@ -4,7 +4,7 @@
4
4
  "files": [
5
5
  {
6
6
  "path": "release/package.json",
7
- "sha256": "be5fc524bab2f659f8f1e851bd1c59c6edf2a5fd4394c1a917a8d5ee9321190e"
7
+ "sha256": "a1167379affa28c595008e826ff854536d75b34d440a11963428d978230170f1"
8
8
  },
9
9
  {
10
10
  "path": "neutral-host-bootstrap.mjs",
@@ -184,7 +184,7 @@
184
184
  },
185
185
  {
186
186
  "path": "core/hellolynk-neutral-host-assembly.mjs",
187
- "sha256": "287ad6e077c8da05799b970ffa6607d8c7a0ab54a4837de51516e6af0ef6695b"
187
+ "sha256": "b63c3371dfc08d8b15a4fd5ce84c61b40d9e7011424ccb3ff11466adb4f862cc"
188
188
  },
189
189
  {
190
190
  "path": "core/hellolynk-neutral-host-installation-store.mjs",
@@ -196,7 +196,7 @@
196
196
  },
197
197
  {
198
198
  "path": "core/hellolynk-neutral-host-process.mjs",
199
- "sha256": "ad6809633f49f7316acf6ce5b8f71a13d7ba20d3b62a2700664421ba671b5369"
199
+ "sha256": "34b985f75bc693954eb66bb788fc2814482bb8bf402f14b72ea2faf5f70cf4ea"
200
200
  },
201
201
  {
202
202
  "path": "core/hellolynk-neutral-host-store-adapters.mjs",
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "contract": "hellolynk-neutral-host-release-pin-v1",
3
- "manifestSha256": "e5fcbb78060749b928487d97b59bccb4a2762ddf2f00896637d472818c933564"
3
+ "manifestSha256": "3d5f398ad123ccbcc1a39dcbba88d55fa2a83f620a7bfff3f99a9c87b807bd24"
4
4
  }