@awiki/dsh-plugin 0.3.10 → 0.3.11-rc.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/README.md +14 -5
- package/README.zh.md +11 -4
- package/lib/client.js +2067 -272
- package/lib/client.js.map +1 -1
- package/lib/index.js +536 -167
- package/lib/model-proxy-contract.js +8 -8
- package/lib/provider.js +32 -2
- package/lib/{sdk-adapter-CYcJH7sM.mjs → sdk-adapter-DpqT2en9.mjs} +17 -7
- package/lib/typert.host.js +181 -117
- package/lib/typert.remote-client.d.ts +3 -1
- package/lib/typert.remote-client.d.ts.map +1 -1
- package/lib/typert.remote-client.js +181 -117
- package/lib/types/base64.d.ts +4 -0
- package/lib/types/base64.d.ts.map +1 -0
- package/lib/types/base64.js +28 -0
- package/lib/types/base64.js.map +1 -0
- package/lib/types/client/AwikiIdentityAccess.d.ts +6 -4
- package/lib/types/client/AwikiIdentityAccess.d.ts.map +1 -1
- package/lib/types/client/AwikiIdentityAccess.js +147 -58
- package/lib/types/client/AwikiIdentityAccess.js.map +1 -1
- package/lib/types/client/AwikiMail.d.ts +1 -1
- package/lib/types/client/AwikiMail.d.ts.map +1 -1
- package/lib/types/client/AwikiMail.js +139 -6
- package/lib/types/client/AwikiMail.js.map +1 -1
- package/lib/types/client/AwikiOverlay.js +2 -2
- package/lib/types/client/AwikiOverlay.js.map +1 -1
- package/lib/types/client/AwikiRecoveryForm.d.ts +1 -0
- package/lib/types/client/AwikiRecoveryForm.d.ts.map +1 -1
- package/lib/types/client/AwikiRecoveryForm.js +3 -2
- package/lib/types/client/AwikiRecoveryForm.js.map +1 -1
- package/lib/types/client/AwikiSettingsSection.d.ts +1 -1
- package/lib/types/client/AwikiSettingsSection.d.ts.map +1 -1
- package/lib/types/client/awiki-client-bridge.d.ts +1 -1
- package/lib/types/client/awiki-client-bridge.d.ts.map +1 -1
- package/lib/types/client/awiki-client-bridge.js +1 -1
- package/lib/types/client/awiki-client-bridge.js.map +1 -1
- package/lib/types/client/controller.d.ts +15 -1
- package/lib/types/client/controller.d.ts.map +1 -1
- package/lib/types/client/controller.js +303 -54
- package/lib/types/client/controller.js.map +1 -1
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js +4 -1
- package/lib/types/client/index.js.map +1 -1
- package/lib/types/client/mail-attachment.d.ts +40 -0
- package/lib/types/client/mail-attachment.d.ts.map +1 -0
- package/lib/types/client/mail-attachment.js +187 -0
- package/lib/types/client/mail-attachment.js.map +1 -0
- package/lib/types/client/otp-cooldown.d.ts +1 -0
- package/lib/types/client/otp-cooldown.d.ts.map +1 -1
- package/lib/types/client/otp-cooldown.js +12 -1
- package/lib/types/client/otp-cooldown.js.map +1 -1
- package/lib/types/client/settings-controller.d.ts +4 -2
- package/lib/types/client/settings-controller.d.ts.map +1 -1
- package/lib/types/client/settings-controller.js +24 -8
- package/lib/types/client/settings-controller.js.map +1 -1
- package/lib/types/client/slots.d.ts +6 -1
- package/lib/types/client/slots.d.ts.map +1 -1
- package/lib/types/client/store.d.ts +1 -1
- package/lib/types/client/store.d.ts.map +1 -1
- package/lib/types/client/store.js +1 -1
- package/lib/types/client/store.js.map +1 -1
- package/lib/types/external-http-auth.d.ts +3 -1
- package/lib/types/external-http-auth.d.ts.map +1 -1
- package/lib/types/external-http-auth.js +2 -2
- package/lib/types/external-http-auth.js.map +1 -1
- package/lib/types/identity-handle.d.ts +5 -0
- package/lib/types/identity-handle.d.ts.map +1 -0
- package/lib/types/identity-handle.js +33 -0
- package/lib/types/identity-handle.js.map +1 -0
- package/lib/types/index.d.ts +11 -2
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +101 -20
- package/lib/types/index.js.map +1 -1
- package/lib/types/listener.d.ts.map +1 -1
- package/lib/types/listener.js +2 -1
- package/lib/types/listener.js.map +1 -1
- package/lib/types/mail-attachment-client.d.ts +14 -0
- package/lib/types/mail-attachment-client.d.ts.map +1 -0
- package/lib/types/mail-attachment-client.js +173 -0
- package/lib/types/mail-attachment-client.js.map +1 -0
- package/lib/types/mail.d.ts +28 -2
- package/lib/types/mail.d.ts.map +1 -1
- package/lib/types/mail.js +79 -2
- package/lib/types/mail.js.map +1 -1
- package/lib/types/model-proxy-contract.d.ts +8 -8
- package/lib/types/model-proxy-contract.d.ts.map +1 -1
- package/lib/types/model-proxy-contract.js +8 -8
- package/lib/types/model-proxy-contract.js.map +1 -1
- package/lib/types/package-version.generated.d.ts +2 -2
- package/lib/types/package-version.generated.d.ts.map +1 -1
- package/lib/types/package-version.generated.js +2 -2
- package/lib/types/package-version.generated.js.map +1 -1
- package/lib/types/provider.d.ts +1 -1
- package/lib/types/provider.d.ts.map +1 -1
- package/lib/types/provider.js +12 -1
- package/lib/types/provider.js.map +1 -1
- package/lib/types/registration-policy.d.ts +5 -0
- package/lib/types/registration-policy.d.ts.map +1 -0
- package/lib/types/registration-policy.js +13 -0
- package/lib/types/registration-policy.js.map +1 -0
- package/lib/types/sdk-adapter.d.ts +2 -1
- package/lib/types/sdk-adapter.d.ts.map +1 -1
- package/lib/types/sdk-adapter.js +13 -4
- package/lib/types/sdk-adapter.js.map +1 -1
- package/lib/types/settings-rpc-contract.d.ts +14 -14
- package/lib/types/settings-rpc-contract.d.ts.map +1 -1
- package/lib/types/settings-rpc-contract.js +14 -14
- package/lib/types/settings-rpc-contract.js.map +1 -1
- package/lib/types/settings-rpc.d.ts.map +1 -1
- package/lib/types/settings-rpc.js +2 -2
- package/lib/types/settings-rpc.js.map +1 -1
- package/lib/types/settings-transport.d.ts +7 -0
- package/lib/types/settings-transport.d.ts.map +1 -0
- package/lib/types/settings-transport.js +52 -0
- package/lib/types/settings-transport.js.map +1 -0
- package/lib/types/tools.d.ts +1 -1
- package/lib/types/tools.d.ts.map +1 -1
- package/lib/types/tools.js +20 -4
- package/lib/types/tools.js.map +1 -1
- package/lib/types/types.d.ts +39 -2
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/types.js.map +1 -1
- package/lib/types/update-policy.d.ts +2 -2
- package/lib/types/update-policy.d.ts.map +1 -1
- package/package.json +84 -75
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
//#region lib/types/model-proxy-contract.js
|
|
2
2
|
/** Browser-safe contracts for the loopback AWiki-hosted DeepSeek proxy channel. */
|
|
3
|
-
const AWIKI_MODEL_PROXY_RPC_CHANNEL = "/
|
|
3
|
+
const AWIKI_MODEL_PROXY_RPC_CHANNEL = "/api";
|
|
4
4
|
const AWIKI_MODEL_PROXY_RPC_ENDPOINTS = {
|
|
5
|
-
capability: "capability",
|
|
6
|
-
status: "status",
|
|
7
|
-
usage: "usage",
|
|
8
|
-
setEnabled: "set-enabled",
|
|
9
|
-
createRecharge: "create-recharge",
|
|
10
|
-
rechargeStatus: "recharge-status",
|
|
11
|
-
closeRecharge: "close-recharge"
|
|
5
|
+
capability: "awiki-model-proxy/capability",
|
|
6
|
+
status: "awiki-model-proxy/status",
|
|
7
|
+
usage: "awiki-model-proxy/usage",
|
|
8
|
+
setEnabled: "awiki-model-proxy/set-enabled",
|
|
9
|
+
createRecharge: "awiki-model-proxy/create-recharge",
|
|
10
|
+
rechargeStatus: "awiki-model-proxy/recharge-status",
|
|
11
|
+
closeRecharge: "awiki-model-proxy/close-recharge"
|
|
12
12
|
};
|
|
13
13
|
function decodeModelProxyCapability(value) {
|
|
14
14
|
return isRecord(value) && value.available === true && value.protocol === 1 ? {
|
package/lib/provider.js
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
|
-
import { n as RustSdkAdapter } from "./sdk-adapter-
|
|
1
|
+
import { n as RustSdkAdapter } from "./sdk-adapter-DpqT2en9.mjs";
|
|
2
2
|
import { setTimeout } from "node:timers/promises";
|
|
3
3
|
import { openImCoreNodeClient } from "@awiki/im-core-node";
|
|
4
|
+
import { AnpIdentityPluginError } from "@agent-network-protocol/dsh-anp-identity";
|
|
5
|
+
//#region lib/types/identity-handle.js
|
|
6
|
+
/** Project Core's registered Handle into the same provider-owned ANP identity. */
|
|
7
|
+
async function syncAnpIdentityHandle(service, identity) {
|
|
8
|
+
if (identity.handle === void 0) return;
|
|
9
|
+
const client = await service.acquireClient({
|
|
10
|
+
consumer: "@awiki/dsh-plugin",
|
|
11
|
+
capabilities: ["identity:read", "identity:handle"],
|
|
12
|
+
ttlSeconds: 60
|
|
13
|
+
});
|
|
14
|
+
try {
|
|
15
|
+
const entries = await client.list();
|
|
16
|
+
const entry = entries.find((item) => item.reference.did === identity.did);
|
|
17
|
+
if (entry === void 0) throw new AnpIdentityPluginError("identity_not_found");
|
|
18
|
+
const handle = identity.handle.toLowerCase();
|
|
19
|
+
if (entry.handle === handle) return;
|
|
20
|
+
for (const previous of entries) if (previous.reference.did !== identity.did && previous.handle === handle) await client.setHandle(previous.reference, null);
|
|
21
|
+
await client.setHandle(entry.reference, identity.handle);
|
|
22
|
+
} finally {
|
|
23
|
+
await client.dispose();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
4
27
|
//#region lib/types/provider.js
|
|
5
28
|
/** Production AWiki provider backed by the versioned Rust IM Core Node bridge. */
|
|
6
29
|
/** Cordis plugin name used by Loader diagnostics. */
|
|
@@ -52,7 +75,14 @@ async function apply(ctx) {
|
|
|
52
75
|
externalHttpAllowInsecureLoopbackForTesting: options.allowInsecureLoopbackForTesting,
|
|
53
76
|
identityProvider: lease
|
|
54
77
|
};
|
|
55
|
-
return new RustSdkAdapter(openImCoreNodeClient(openOptions))
|
|
78
|
+
return new RustSdkAdapter(openImCoreNodeClient(openOptions), async (identity) => {
|
|
79
|
+
try {
|
|
80
|
+
await syncAnpIdentityHandle(ctx.anpIdentity, identity);
|
|
81
|
+
} catch (error) {
|
|
82
|
+
const code = error instanceof AnpIdentityPluginError ? error.code : "unexpected_error";
|
|
83
|
+
ctx.logger.warn("AWiki Handle synchronization failed (code=%s, did=%s, handle=%s); retrying on the next identity read.", code, identity.did, identity.handle);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
56
86
|
});
|
|
57
87
|
return async () => {
|
|
58
88
|
try {
|
|
@@ -115,6 +115,7 @@ const RUST_FAILURE_CODES = {
|
|
|
115
115
|
invalid_otp: "invalid-otp",
|
|
116
116
|
challenge_expired: "challenge-expired",
|
|
117
117
|
handle_unavailable: "handle-unavailable",
|
|
118
|
+
short_handle_invite_required: "short-handle-invite-required",
|
|
118
119
|
not_found: "not-found",
|
|
119
120
|
permission_denied: "forbidden",
|
|
120
121
|
group_not_member: "group-membership-required",
|
|
@@ -123,7 +124,7 @@ const RUST_FAILURE_CODES = {
|
|
|
123
124
|
local_identity_recovery_required: "identity-recovery-required",
|
|
124
125
|
conflict: "conflict",
|
|
125
126
|
join_required: "handle-unavailable",
|
|
126
|
-
state_in_use: "
|
|
127
|
+
state_in_use: "state-in-use",
|
|
127
128
|
rate_limited: "rate-limited",
|
|
128
129
|
timeout: "network",
|
|
129
130
|
transport_unavailable: "network",
|
|
@@ -462,6 +463,7 @@ function externalHttpAttempt(value) {
|
|
|
462
463
|
}
|
|
463
464
|
/** Adapt the Rust Node bridge to the frozen Host provider interface. */
|
|
464
465
|
var RustSdkAdapter = class {
|
|
466
|
+
onIdentity;
|
|
465
467
|
trustedUserPresenceSupported = process.platform === "darwin" && process.arch === "x64";
|
|
466
468
|
client;
|
|
467
469
|
refreshingDisplayPeers = /* @__PURE__ */ new Set();
|
|
@@ -491,7 +493,8 @@ var RustSdkAdapter = class {
|
|
|
491
493
|
realtime;
|
|
492
494
|
agentInbox;
|
|
493
495
|
listener;
|
|
494
|
-
constructor(client) {
|
|
496
|
+
constructor(client, onIdentity) {
|
|
497
|
+
this.onIdentity = onIdentity;
|
|
495
498
|
this.client = Promise.resolve(client);
|
|
496
499
|
this.realtime = {
|
|
497
500
|
syncNow: (reason) => this.listenerSyncNow(reason),
|
|
@@ -775,7 +778,10 @@ var RustSdkAdapter = class {
|
|
|
775
778
|
getIdentity() {
|
|
776
779
|
return this.run(async (client) => {
|
|
777
780
|
const value = await client.getDefaultIdentity();
|
|
778
|
-
|
|
781
|
+
if (value === null) return null;
|
|
782
|
+
const result = identity(value);
|
|
783
|
+
await this.onIdentity?.(result);
|
|
784
|
+
return result;
|
|
779
785
|
});
|
|
780
786
|
}
|
|
781
787
|
sendRegistrationOtp(request) {
|
|
@@ -790,10 +796,14 @@ var RustSdkAdapter = class {
|
|
|
790
796
|
registerIdentity(request) {
|
|
791
797
|
return this.run(async (client) => {
|
|
792
798
|
const value = await client.completeRegistrationWithOutcome(request);
|
|
793
|
-
if (value.status === "registered")
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
799
|
+
if (value.status === "registered") {
|
|
800
|
+
const result = identity(value.identity);
|
|
801
|
+
await this.onIdentity?.(result);
|
|
802
|
+
return {
|
|
803
|
+
status: "registered",
|
|
804
|
+
identity: result
|
|
805
|
+
};
|
|
806
|
+
}
|
|
797
807
|
return {
|
|
798
808
|
status: "join-required",
|
|
799
809
|
continuationId: required(value.existingHandle.continuationId),
|