@senguoyun/dsh-arkme 0.1.85 → 0.1.86

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.
Files changed (52) hide show
  1. package/docs/self-role-avatar-cache.md +59 -0
  2. package/lib/client.js +460 -116
  3. package/lib/client.js.map +1 -1
  4. package/lib/harness-model-client.js +14 -0
  5. package/lib/harness-native-selection-client.js +14 -0
  6. package/lib/harness-sidebar-client.js +14 -0
  7. package/lib/index.js +22 -9
  8. package/lib/persistent-extension.js +1 -1
  9. package/lib/{persistent-runtime-adGFmkIa.js → persistent-runtime-DfmCJcxH.js} +412 -121
  10. package/lib/sdk.js +14 -0
  11. package/lib/types/arkme-service.d.ts +1 -0
  12. package/lib/types/arkme-service.d.ts.map +1 -1
  13. package/lib/types/client/ArkmeSelfRolePicker.d.ts.map +1 -1
  14. package/lib/types/client/ArkmeSidebar.d.ts.map +1 -1
  15. package/lib/types/client/avatar-image-runtime.d.ts.map +1 -1
  16. package/lib/types/client/avatar-image-store.d.ts +10 -0
  17. package/lib/types/client/avatar-image-store.d.ts.map +1 -1
  18. package/lib/types/client/avatar-persistent-cache.d.ts +16 -0
  19. package/lib/types/client/avatar-persistent-cache.d.ts.map +1 -0
  20. package/lib/types/client/reaction-notifications.d.ts.map +1 -1
  21. package/lib/types/client/reaction-preview-store.d.ts +4 -1
  22. package/lib/types/client/reaction-preview-store.d.ts.map +1 -1
  23. package/lib/types/client/reaction-transport.d.ts +4 -0
  24. package/lib/types/client/reaction-transport.d.ts.map +1 -0
  25. package/lib/types/client/realtime-client-events.d.ts.map +1 -1
  26. package/lib/types/host-api.d.ts.map +1 -1
  27. package/lib/types/local-database.d.ts +1 -0
  28. package/lib/types/local-database.d.ts.map +1 -1
  29. package/lib/types/reaction-contract.d.ts +4 -0
  30. package/lib/types/reaction-contract.d.ts.map +1 -1
  31. package/lib/types/reaction-diagnostics.d.ts +4 -0
  32. package/lib/types/reaction-diagnostics.d.ts.map +1 -0
  33. package/lib/types/reaction-host-diagnostics.d.ts +6 -0
  34. package/lib/types/reaction-host-diagnostics.d.ts.map +1 -0
  35. package/lib/types/request-coordinator.d.ts +2 -0
  36. package/lib/types/request-coordinator.d.ts.map +1 -1
  37. package/lib/types/sdk/index.d.ts +2 -0
  38. package/lib/types/sdk/index.d.ts.map +1 -1
  39. package/lib/types/services/chat-service.d.ts +1 -0
  40. package/lib/types/services/chat-service.d.ts.map +1 -1
  41. package/lib/types/services/media-service.d.ts +14 -0
  42. package/lib/types/services/media-service.d.ts.map +1 -1
  43. package/lib/types/services/profile-service.d.ts.map +1 -1
  44. package/lib/types/services/reaction-service.d.ts.map +1 -1
  45. package/lib/types/services/service.d.ts +1 -0
  46. package/lib/types/services/service.d.ts.map +1 -1
  47. package/lib/types/tools/business/media/read-image.d.ts.map +1 -1
  48. package/lib/types/tools/ports/media.d.ts +1 -0
  49. package/lib/types/tools/ports/media.d.ts.map +1 -1
  50. package/lib/types/types.d.ts +1 -0
  51. package/lib/types/types.d.ts.map +1 -1
  52. package/package.json +5 -5
@@ -2808,6 +2808,20 @@ AI 额度充值流程|AI point purchase
2808
2808
  if (imageRef.trim() === "") throw new TypeError("Arkme image reference must not be empty");
2809
2809
  return await this.call("image.read", { imageRef }, signal);
2810
2810
  }
2811
+ /** Probe immutable image bytes without starting an upstream request. */
2812
+ async readCachedImage(imageRef, signal) {
2813
+ if (imageRef.trim() === "") throw new TypeError("Arkme image reference must not be empty");
2814
+ if ((await this.capabilities(signal)).features.imageCacheRead !== true) throw new Error("当前 Arkme Provider 不支持本地头像探测,请升级");
2815
+ try {
2816
+ return await this.call("image.read", {
2817
+ imageRef,
2818
+ cacheOnly: true
2819
+ }, signal);
2820
+ } catch (error) {
2821
+ if (error instanceof ArkmeClientError && error.body.code === "image-cache-miss") return void 0;
2822
+ throw error;
2823
+ }
2824
+ }
2811
2825
  /** Convert a Provider image payload into a browser-renderable data URL. */
2812
2826
  imageDataUrl(image) {
2813
2827
  return `data:${image.mediaType};base64,${image.dataBase64}`;
@@ -825,6 +825,20 @@ window.__ModuleLoader__.load({
825
825
  if (imageRef.trim() === "") throw new TypeError("Arkme image reference must not be empty");
826
826
  return await this.call("image.read", { imageRef }, signal);
827
827
  }
828
+ /** Probe immutable image bytes without starting an upstream request. */
829
+ async readCachedImage(imageRef, signal) {
830
+ if (imageRef.trim() === "") throw new TypeError("Arkme image reference must not be empty");
831
+ if ((await this.capabilities(signal)).features.imageCacheRead !== true) throw new Error("当前 Arkme Provider 不支持本地头像探测,请升级");
832
+ try {
833
+ return await this.call("image.read", {
834
+ imageRef,
835
+ cacheOnly: true
836
+ }, signal);
837
+ } catch (error) {
838
+ if (error instanceof ArkmeClientError && error.body.code === "image-cache-miss") return void 0;
839
+ throw error;
840
+ }
841
+ }
828
842
  /** Convert a Provider image payload into a browser-renderable data URL. */
829
843
  imageDataUrl(image) {
830
844
  return `data:${image.mediaType};base64,${image.dataBase64}`;
@@ -767,6 +767,20 @@ window.__ModuleLoader__.load({
767
767
  if (imageRef.trim() === "") throw new TypeError("Arkme image reference must not be empty");
768
768
  return await this.call("image.read", { imageRef }, signal);
769
769
  }
770
+ /** Probe immutable image bytes without starting an upstream request. */
771
+ async readCachedImage(imageRef, signal) {
772
+ if (imageRef.trim() === "") throw new TypeError("Arkme image reference must not be empty");
773
+ if ((await this.capabilities(signal)).features.imageCacheRead !== true) throw new Error("当前 Arkme Provider 不支持本地头像探测,请升级");
774
+ try {
775
+ return await this.call("image.read", {
776
+ imageRef,
777
+ cacheOnly: true
778
+ }, signal);
779
+ } catch (error) {
780
+ if (error instanceof ArkmeClientError && error.body.code === "image-cache-miss") return void 0;
781
+ throw error;
782
+ }
783
+ }
770
784
  /** Convert a Provider image payload into a browser-renderable data URL. */
771
785
  imageDataUrl(image) {
772
786
  return `data:${image.mediaType};base64,${image.dataBase64}`;
package/lib/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as inspectNativeBundleArtifactV3, At as recordOwnerId, Bt as __exportAll, Ct as recordingImportFileNameKey, D as bundleSha256, E as arkmeSandboxEntryId, Et as registerManagedAiProvider, F as assertExtensionArtifactSize, Ft as parseArrangementBoardCachePages, G as validateVoiceprintPcm16Wav, Ht as __toCommonJS, I as canonicalExtensionJson, It as registerDSHAgentInputRecordSync, J as arkmeRequiredLinkMetadataFallback, K as arkmeExtensionShareRefFromLink, L as sha256Hex, Lt as createDesktopLifecycleReader, M as packLocalNativeBundleDirectoryV3, Mt as parseArkmeRecordReeditAttachments, N as readNativeBundleTarballV3, Nt as parseArkmeRecordReeditMentions, O as canonicalBundleJson, Ot as ArkmePluginError, P as renderArkmeSandboxHostEntry, Q as ARKME_PROVIDER_CONTRACT_VERSION, R as unpackArkmeExtension, Rt as __commonJSMin, S as ARKME_BUNDLE_ARTIFACT_KIND, T as ArkmeBundleArtifactError, Tt as normalizeRecentEmojiIds, U as ARKME_EXTENSION_RUNTIME_UNAVAILABLE_MESSAGE, Vt as __require, W as ArkmeService, X as arkmeRichBackgroundSound, Y as arkmeFileBackgroundSound, Z as ARKME_DEFAULT_SHARE_WEBSITE, _ as arkmeClientContentDigest, _t as ArkmeDirectMessageAdmissionError, at as cachedMemberItem, b as verifyExtensionResolutionSignature, bt as recordingImportFileKind, c as persistentExtensionBundleDirectory, ct as SelfRoleSyncStore, d as readPersistentExtensionActivation, dt as arkmeCanInlineLocalFile, f as refreshPersistentClientWrapper, ft as arkmeNormalizedFileMimeType, g as activeProfileExtensionOwnerConflicts, gt as SecretValue, h as renderArkmeBundleClientBundle, ht as ArkmeOutgoingCallError, i as invokePersistentArkmeExtension, it as applyMemberUpdate, j as packBundleFiles, jt as ArkmeRecordReeditDraftConflict, k as inspectBundleArtifact, kt as retryAfterMillis, l as persistentExtensionPackageIdentity, lt as ARKME_RUNTIME_INSTANCE_ID, m as writePersistentExtensionActivation, mt as isArkmeBotAvatarRef, nt as ARKME_WORLD_PUBLISH_MAX_IMAGES, o as persistentArkmeExtensionRuntimeState, ot as mergeMemberJoinEvents, p as repairPersistentExtensionInstallation, pt as arkmePickedFileKind, q as arkmeIsGenericLinkMetadataTitle, r as deactivatePersistentArkmeExtension, rt as ARKME_WORLD_PUBLISH_MAX_IMAGE_BYTES, s as materializePersistentExtensionBundle, st as validateMemberUpdate, t as activatePersistentArkmeExtension, u as quarantinePersistentExtension, ut as ARKME_TOOL_FILE_MAX_BYTES, v as arkmeClientContentDigestFromSource, vt as isRecordingInstantOnOrAfterUnixEpoch, w as ARKME_NATIVE_BUNDLE_ARTIFACT_KIND, wt as isRecentEmojiId, x as verifyNativeBundleResolutionSignature, xt as sameRecordingImportIdentity, y as verifyBundleResolutionSignature, yt as isUnresolvedRecordingImportJob, z as ARKME_EXTENSION_FORMAT, zt as __esmMin } from "./persistent-runtime-adGFmkIa.js";
1
+ import { A as inspectNativeBundleArtifactV3, At as recordOwnerId, Bt as __exportAll, Ct as recordingImportFileNameKey, D as bundleSha256, E as arkmeSandboxEntryId, Et as registerManagedAiProvider, F as assertExtensionArtifactSize, Ft as parseArrangementBoardCachePages, G as validateVoiceprintPcm16Wav, Ht as __toCommonJS, I as canonicalExtensionJson, It as registerDSHAgentInputRecordSync, J as arkmeRequiredLinkMetadataFallback, K as arkmeExtensionShareRefFromLink, L as sha256Hex, Lt as createDesktopLifecycleReader, M as packLocalNativeBundleDirectoryV3, Mt as parseArkmeRecordReeditAttachments, N as readNativeBundleTarballV3, Nt as parseArkmeRecordReeditMentions, O as canonicalBundleJson, Ot as ArkmePluginError, P as renderArkmeSandboxHostEntry, Q as ARKME_PROVIDER_CONTRACT_VERSION, R as unpackArkmeExtension, Rt as __commonJSMin, S as ARKME_BUNDLE_ARTIFACT_KIND, T as ArkmeBundleArtifactError, Tt as normalizeRecentEmojiIds, U as ARKME_EXTENSION_RUNTIME_UNAVAILABLE_MESSAGE, Vt as __require, W as ArkmeService, X as arkmeRichBackgroundSound, Y as arkmeFileBackgroundSound, Z as ARKME_DEFAULT_SHARE_WEBSITE, _ as arkmeClientContentDigest, _t as ArkmeDirectMessageAdmissionError, at as cachedMemberItem, b as verifyExtensionResolutionSignature, bt as recordingImportFileKind, c as persistentExtensionBundleDirectory, ct as SelfRoleSyncStore, d as readPersistentExtensionActivation, dt as arkmeCanInlineLocalFile, f as refreshPersistentClientWrapper, ft as arkmeNormalizedFileMimeType, g as activeProfileExtensionOwnerConflicts, gt as SecretValue, h as renderArkmeBundleClientBundle, ht as ArkmeOutgoingCallError, i as invokePersistentArkmeExtension, it as applyMemberUpdate, j as packBundleFiles, jt as ArkmeRecordReeditDraftConflict, k as inspectBundleArtifact, kt as retryAfterMillis, l as persistentExtensionPackageIdentity, lt as ARKME_RUNTIME_INSTANCE_ID, m as writePersistentExtensionActivation, mt as isArkmeBotAvatarRef, nt as ARKME_WORLD_PUBLISH_MAX_IMAGES, o as persistentArkmeExtensionRuntimeState, ot as mergeMemberJoinEvents, p as repairPersistentExtensionInstallation, pt as arkmePickedFileKind, q as arkmeIsGenericLinkMetadataTitle, r as deactivatePersistentArkmeExtension, rt as ARKME_WORLD_PUBLISH_MAX_IMAGE_BYTES, s as materializePersistentExtensionBundle, st as validateMemberUpdate, t as activatePersistentArkmeExtension, u as quarantinePersistentExtension, ut as ARKME_TOOL_FILE_MAX_BYTES, v as arkmeClientContentDigestFromSource, vt as isRecordingInstantOnOrAfterUnixEpoch, w as ARKME_NATIVE_BUNDLE_ARTIFACT_KIND, wt as isRecentEmojiId, x as verifyNativeBundleResolutionSignature, xt as sameRecordingImportIdentity, y as verifyBundleResolutionSignature, yt as isUnresolvedRecordingImportJob, z as ARKME_EXTENSION_FORMAT, zt as __esmMin } from "./persistent-runtime-DfmCJcxH.js";
2
2
  import { i as securePrivateFileSync, n as securePrivateDirectorySync, r as securePrivateFile, t as securePrivateDirectory } from "./private-filesystem-CGh4FtyA.js";
3
3
  import { _ as parsePluginUpdateManifest, b as validatePluginUpdateServiceOrigin, d as writePluginUpdateLifecycleLog, f as PluginUpdateInstallStateStore, g as existingCachedPluginArtifactPath, h as downloadAndCachePluginArtifact, m as PluginUpdateArtifactError, n as buildTargetInstallArgs, o as reconcilePluginUpdaterProfilePolicy, p as ARKME_PLUGIN_PACKAGE_NAME$1, t as assertTargetArtifactIntegrity, u as detachManagedProfilePluginLink, v as pluginUpdateEndpointUrl, y as validatePluginUpdateArtifactOrigin } from "./plugin-updater-helper-dNxHpiVg.js";
4
4
  import { i as prepareProfilePackageManager, n as isArkmeProfilePackageName, r as localExtensionPnpmArgs, t as applyArkmeProfileBundlePolicy } from "./profile-bundle-policy-8_y3QfHe.js";
@@ -14833,7 +14833,7 @@ async function dispatchArkmeHostOperation(service, operation, params, updateMana
14833
14833
  case "user.arkme-id.check": return await service.checkArkmeIdAvailability(stringParam(params, "arkmeId"));
14834
14834
  case "user.arkme-id.set": return await service.setArkmeIdOnce(stringParam(params, "arkmeId"));
14835
14835
  case "image.read": {
14836
- const image = await service.readImage(stringParam(params, "imageRef"));
14836
+ const image = params.cacheOnly === true ? await service.readImage(stringParam(params, "imageRef"), { cacheOnly: true }) : await service.readImage(stringParam(params, "imageRef"));
14837
14837
  return {
14838
14838
  mediaType: image.mediaType,
14839
14839
  bytes: image.bytes,
@@ -19964,6 +19964,9 @@ var ArkmeLocalDatabase = class {
19964
19964
  });
19965
19965
  this.secureDatabaseFiles();
19966
19966
  }
19967
+ async selfRoleAvatarLocalRef(userId, fileAssetUid) {
19968
+ return this.database.prepare("SELECT local_ref FROM self_role_avatar_asset WHERE user_id=? AND asset_uid=? LIMIT 1").get(userId, fileAssetUid)?.local_ref;
19969
+ }
19967
19970
  async readAvatarCache(userId, imageRef) {
19968
19971
  const row = this.database.prepare("SELECT media_type, data FROM avatar_cache WHERE user_id=? AND image_ref=?").get(userId, imageRef);
19969
19972
  if (row === void 0) return void 0;
@@ -27707,7 +27710,7 @@ const readReactionsToolModule = defineArkmeCoreToolModule({
27707
27710
  parameters: { request_json: {
27708
27711
  type: "string",
27709
27712
  required: true,
27710
- description: "ReactionRequest JSON: accountKey and action; notifications after_id/limit (max50); query targets (max50); actors target/key/after_user_id/limit; history start_at/end_at/before_at/before_id/limit (UTC ms, max32 days); groups target/after_key/limit; received world_only/limit/before_at/before_id; history-policy-query and library-query no extra fields."
27713
+ description: "ReactionRequest JSON: accountKey and action; notifications after_id/limit (max50); query targets (max50), optional actorPresentation:\"deferred\" returns authorized actor IDs/memberRefs immediately with presentationPending:true for caller-side cached names; omit it for complete names; actors target/key/after_user_id/limit; history start_at/end_at/before_at/before_id/limit (UTC ms, max32 days); groups target/after_key/limit; received world_only/limit/before_at/before_id; history-policy-query and library-query no extra fields."
27711
27714
  } },
27712
27715
  output: TEXT_OUTPUT$3,
27713
27716
  async execute(args, exec) {
@@ -30144,11 +30147,17 @@ function createArkmeImageToolDefinition(ctx, service) {
30144
30147
  return defineTool({
30145
30148
  name: "arkme_image_read",
30146
30149
  description: "Read an image reference returned by the Arkme Provider and return the image itself. This includes image-library items, the signed-in profile avatar, and authorized private/group chat avatars. The Provider refreshes Arkme authorization without exposing signed OSS URLs and rejects guessed or cross-account references. Requires the current model to accept image input.",
30147
- parameters: { image_ref: {
30148
- type: "string",
30149
- required: true,
30150
- description: "An image reference returned by arkme_images_list, arkme_user_profile, or arkme_sources_list. Never construct, parse, or guess this value."
30151
- } },
30150
+ parameters: {
30151
+ cache_only: {
30152
+ type: "boolean",
30153
+ description: "Only read locally cached immutable file-asset bytes; never query or download upstream. A miss returns image-cache-miss."
30154
+ },
30155
+ image_ref: {
30156
+ type: "string",
30157
+ required: true,
30158
+ description: "An image reference returned by arkme_images_list, arkme_user_profile, or arkme_sources_list. Never construct, parse, or guess this value."
30159
+ }
30160
+ },
30152
30161
  output: {
30153
30162
  schema: {
30154
30163
  type: "object",
@@ -30207,7 +30216,11 @@ function createArkmeImageToolDefinition(ctx, service) {
30207
30216
  const byteCap = Math.min(attachments.imageLimits.maxImageBytes, attachments.imageLimits.maxMessageImageBytes);
30208
30217
  const resolved = await service.readImage(imageRef, {
30209
30218
  maxBytes: byteCap,
30210
- signal: exec.signal
30219
+ signal: exec.signal,
30220
+ ...args.cache_only === true ? { cacheOnly: true } : {}
30221
+ }).catch((error) => {
30222
+ if (args.cache_only === true && error instanceof ArkmePluginError && error.code === "image-cache-miss") throw new Error(`[image-cache-miss] ${error.message}`, { cause: error });
30223
+ throw error;
30211
30224
  });
30212
30225
  if (!attachments.imageLimits.mediaTypes.includes(resolved.mediaType)) throw new Error(`cannot read the Arkme image: ${resolved.mediaType} is not accepted by this deployment`);
30213
30226
  let ref;
@@ -1,2 +1,2 @@
1
- import { a as persistentArkmeExtensionActive, i as invokePersistentArkmeExtension, n as applyPersistentArkmeHostExtension, o as persistentArkmeExtensionRuntimeState, r as deactivatePersistentArkmeExtension, t as activatePersistentArkmeExtension } from "./persistent-runtime-adGFmkIa.js";
1
+ import { a as persistentArkmeExtensionActive, i as invokePersistentArkmeExtension, n as applyPersistentArkmeHostExtension, o as persistentArkmeExtensionRuntimeState, r as deactivatePersistentArkmeExtension, t as activatePersistentArkmeExtension } from "./persistent-runtime-DfmCJcxH.js";
2
2
  export { activatePersistentArkmeExtension, applyPersistentArkmeHostExtension, deactivatePersistentArkmeExtension, invokePersistentArkmeExtension, persistentArkmeExtensionActive, persistentArkmeExtensionRuntimeState };