@ours.network/sdk 0.1.1

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 (121) hide show
  1. package/LICENSE +98 -0
  2. package/README.md +41 -0
  3. package/dist/api/contacts.d.ts +31 -0
  4. package/dist/api/contacts.js +2 -0
  5. package/dist/api/files.d.ts +10 -0
  6. package/dist/api/files.js +2 -0
  7. package/dist/api/identity.d.ts +44 -0
  8. package/dist/api/identity.js +2 -0
  9. package/dist/api/messaging.d.ts +23 -0
  10. package/dist/api/messaging.js +2 -0
  11. package/dist/api/profile.d.ts +9 -0
  12. package/dist/api/profile.js +2 -0
  13. package/dist/api/types.d.ts +177 -0
  14. package/dist/api/types.js +1 -0
  15. package/dist/book.d.ts +22 -0
  16. package/dist/book.js +2 -0
  17. package/dist/boot.d.ts +1 -0
  18. package/dist/boot.js +2 -0
  19. package/dist/chunk-37D5PCFY.js +2 -0
  20. package/dist/chunk-3DQSMLVZ.js +2 -0
  21. package/dist/chunk-5EWCIQH6.js +2 -0
  22. package/dist/chunk-7UUFYO6G.js +2 -0
  23. package/dist/chunk-A3SXVUOC.js +2 -0
  24. package/dist/chunk-AJQIWYXG.js +2 -0
  25. package/dist/chunk-DIRW7I4S.js +2 -0
  26. package/dist/chunk-HCIVLHKC.js +2 -0
  27. package/dist/chunk-HSVIKO4D.js +3 -0
  28. package/dist/chunk-IB2U7K6Y.js +5 -0
  29. package/dist/chunk-KZMPGVQM.js +2 -0
  30. package/dist/chunk-LKFYUCN7.js +2 -0
  31. package/dist/chunk-NMYSFQBL.js +2 -0
  32. package/dist/chunk-NQQ4GSVI.js +5 -0
  33. package/dist/chunk-NSPYN5TT.js +2 -0
  34. package/dist/chunk-P55RJGZU.js +2 -0
  35. package/dist/chunk-PCHN744Y.js +2 -0
  36. package/dist/chunk-Q3UVLSCX.js +2 -0
  37. package/dist/chunk-RAGUBE4Y.js +2 -0
  38. package/dist/chunk-T25JIPX5.js +2 -0
  39. package/dist/chunk-TZBRSDND.js +2 -0
  40. package/dist/chunk-UELGY557.js +2 -0
  41. package/dist/chunk-UJGRFV4J.js +2 -0
  42. package/dist/chunk-UM73BGFH.js +2 -0
  43. package/dist/chunk-V64IUVSS.js +4 -0
  44. package/dist/chunk-VOYMK2OO.js +2 -0
  45. package/dist/chunk-VW2KWXSJ.js +2 -0
  46. package/dist/chunk-X4RVJ5VL.js +6 -0
  47. package/dist/chunk-YRPUM6JG.js +2 -0
  48. package/dist/chunk-ZAXRB5MO.js +2 -0
  49. package/dist/chunk-ZHH3PWEW.js +4 -0
  50. package/dist/client/http.d.ts +178 -0
  51. package/dist/client/http.js +2 -0
  52. package/dist/cluster/control.d.ts +5 -0
  53. package/dist/cluster/control.js +2 -0
  54. package/dist/cluster/manifest.d.ts +12 -0
  55. package/dist/cluster/manifest.js +2 -0
  56. package/dist/config.d.ts +37 -0
  57. package/dist/config.js +2 -0
  58. package/dist/connector.d.ts +68 -0
  59. package/dist/connector.js +5 -0
  60. package/dist/daemon.d.ts +5 -0
  61. package/dist/daemon.js +2 -0
  62. package/dist/errors.d.ts +40 -0
  63. package/dist/errors.js +2 -0
  64. package/dist/events.d.ts +144 -0
  65. package/dist/events.js +2 -0
  66. package/dist/files.d.ts +2 -0
  67. package/dist/files.js +2 -0
  68. package/dist/gc.d.ts +2 -0
  69. package/dist/gc.js +2 -0
  70. package/dist/http/api-routes.d.ts +63 -0
  71. package/dist/http/api-routes.js +2 -0
  72. package/dist/http/server.d.ts +120 -0
  73. package/dist/http/server.js +2 -0
  74. package/dist/identity/hierarchy.d.ts +20 -0
  75. package/dist/identity/hierarchy.js +2 -0
  76. package/dist/identity/lease.d.ts +29 -0
  77. package/dist/identity/lease.js +2 -0
  78. package/dist/identity/lifecycle.d.ts +5 -0
  79. package/dist/identity/lifecycle.js +2 -0
  80. package/dist/identity/model.d.ts +67 -0
  81. package/dist/identity/model.js +2 -0
  82. package/dist/identity/provision.d.ts +12 -0
  83. package/dist/identity/provision.js +2 -0
  84. package/dist/inbox.d.ts +38 -0
  85. package/dist/inbox.js +2 -0
  86. package/dist/index.d.ts +11 -0
  87. package/dist/index.js +2 -0
  88. package/dist/messaging/send.d.ts +28 -0
  89. package/dist/messaging/send.js +2 -0
  90. package/dist/mufl/handlers.d.ts +5 -0
  91. package/dist/mufl/handlers.js +2 -0
  92. package/dist/mufl/tx.d.ts +9 -0
  93. package/dist/mufl/tx.js +2 -0
  94. package/dist/mufl_code/8ED6356B41CC689C75DA3302AD7856058131661A6ABBAC961E71BA838D8C97A3.muflo +0 -0
  95. package/dist/notify.d.ts +24 -0
  96. package/dist/notify.js +2 -0
  97. package/dist/process-state.d.ts +2 -0
  98. package/dist/process-state.js +2 -0
  99. package/dist/protocol.d.ts +1 -0
  100. package/dist/protocol.js +2 -0
  101. package/dist/render/adapt-to-json.d.ts +83 -0
  102. package/dist/render/adapt-to-json.js +2 -0
  103. package/dist/runtime/env.d.ts +18 -0
  104. package/dist/runtime/env.js +2 -0
  105. package/dist/runtime/unit.d.ts +15 -0
  106. package/dist/runtime/unit.js +2 -0
  107. package/dist/sse-keepalive.d.ts +18 -0
  108. package/dist/sse-keepalive.js +2 -0
  109. package/dist/startup-progress.d.ts +54 -0
  110. package/dist/startup-progress.js +2 -0
  111. package/dist/state.d.ts +5 -0
  112. package/dist/state.js +2 -0
  113. package/dist/sweeps.d.ts +18 -0
  114. package/dist/sweeps.js +2 -0
  115. package/dist/transcribe.d.ts +113 -0
  116. package/dist/transcribe.js +2 -0
  117. package/dist/version-advisory.d.ts +4 -0
  118. package/dist/version-advisory.js +2 -0
  119. package/dist/voice-setup.d.ts +44 -0
  120. package/dist/voice-setup.js +28 -0
  121. package/package.json +49 -0
package/LICENSE ADDED
@@ -0,0 +1,98 @@
1
+ # Functional Source License, Version 1.1, Apache 2.0 Future License
2
+
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-Apache-2.0
6
+
7
+ ## Notice
8
+
9
+ Copyright 2026 Adapt Framework Solutions Ltd
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to use,
27
+ copy, modify, create derivative works, publicly perform, publicly display and
28
+ redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or service
34
+ that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software that
39
+ exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee using
52
+ the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to the
59
+ infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software, you
68
+ must include a copy of or a link to these Terms and Conditions and not remove any
69
+ copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, INCLUDING
74
+ WITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
75
+ PURPOSE, NON-INFRINGEMENT, OR THAT THE SOFTWARE IS FREE OF DEFECTS. IN NO EVENT
76
+ WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE SOFTWARE,
77
+ INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN IF WE HAVE
78
+ BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
79
+
80
+ ### Grant of Future License
81
+
82
+ We hereby irrevocably grant you an additional license to use the Software under
83
+ the Apache License, Version 2.0 that is effective on the second anniversary of
84
+ the date we make the Software available. On or after that date, you may use the
85
+ Software under the Apache License, Version 2.0, in which case the following will
86
+ apply:
87
+
88
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
89
+ this file except in compliance with the License.
90
+
91
+ You may obtain a copy of the License at
92
+
93
+ http://www.apache.org/licenses/LICENSE-2.0
94
+
95
+ Unless required by applicable law or agreed to in writing, software distributed
96
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
97
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
98
+ specific language governing permissions and limitations under the License.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # @ours.network/sdk
2
+
3
+ The ADAPT/MUFL engine, the typed API over it, and the connector client for the
4
+ [ours](https://ours.network) network — extracted from `@ours.network/mcp` 0.16.0.
5
+
6
+ This package holds everything that is not an MCP tool definition: the MUFL
7
+ packet and its wrapper, identities and leases, the local contact book, the
8
+ cluster control plane, messaging and files, the HTTP daemon, and the stdio↔HTTP
9
+ connector. `@ours.network/mcp` builds on it and contributes only tool
10
+ definitions, result formatting and CLI text.
11
+
12
+ ## Exports
13
+
14
+ | Entry point | What it gives you |
15
+ |---|---|
16
+ | `@ours.network/sdk` | `OursClient` — a typed HTTP client for a running daemon — plus `OursError` and every exported type |
17
+ | `@ours.network/sdk/daemon` | `startDaemon(opts)` — the engine, identities, leases, HTTP routing and SSE, with an injectable MCP handler |
18
+ | `@ours.network/sdk/connector` | `runProxy(opts)` — the stdio↔HTTP connector client |
19
+
20
+ ## Requirements
21
+
22
+ Node ≥ 20. The MUFL packet is compiled from `mufl_code/`, which pins the
23
+ `ours-mufl-core` submodule — clone with `--recurse-submodules`.
24
+
25
+ ## Build and test
26
+
27
+ ```bash
28
+ npm ci
29
+ npm run build
30
+ npm test
31
+ ```
32
+
33
+ ## Errors
34
+
35
+ Every operation rejects with `OursError`, carrying a stable `code` and a
36
+ message that is byte-identical to the text `@ours.network/mcp` has always
37
+ shown for that condition.
38
+
39
+ ## License
40
+
41
+ See [LICENSE](LICENSE).
@@ -0,0 +1,31 @@
1
+ import type { AddContactResult, ContactsView, IntroductionResult, InviteResult, InviteRow, LocalBookPolicyResult, LocalBookRow, RemoveContactResult, RenameContactResult, RevokeResult, SessionContext } from './types.js';
2
+ export type * from './types.js';
3
+ export declare function generateInvite(ctx: SessionContext, a?: {
4
+ name?: string;
5
+ mode?: 'one_time' | 'public';
6
+ }): Promise<InviteResult>;
7
+ export declare function listInvites(ctx: SessionContext): Promise<InviteRow[]>;
8
+ export declare function revokeInvite(ctx: SessionContext, a: {
9
+ invite_id: string;
10
+ }): Promise<RevokeResult>;
11
+ export declare function addContact(ctx: SessionContext, a: {
12
+ invite: string;
13
+ name?: string;
14
+ }): Promise<AddContactResult>;
15
+ export declare function listContacts(ctx: SessionContext): Promise<ContactsView>;
16
+ export declare function listLocalContactBook(ctx: SessionContext): Promise<LocalBookRow[]>;
17
+ export declare function setLocalBookPolicy(ctx: SessionContext, a: {
18
+ expose?: boolean;
19
+ auto_accept?: boolean;
20
+ }): Promise<LocalBookPolicyResult>;
21
+ export declare function removeContact(ctx: SessionContext, a: {
22
+ contact: string;
23
+ }): Promise<RemoveContactResult>;
24
+ export declare function renameContact(ctx: SessionContext, a: {
25
+ contact: string;
26
+ name: string;
27
+ }): Promise<RenameContactResult>;
28
+ export declare function respondToIntroduction(ctx: SessionContext, a: {
29
+ contact: string;
30
+ action: 'approve' | 'reject';
31
+ }): Promise<IntroductionResult>;
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import{a,b,c,d,e,f,g,h,i,j}from"../chunk-KZMPGVQM.js";import"../chunk-7UUFYO6G.js";import"../chunk-UM73BGFH.js";import"../chunk-NMYSFQBL.js";import"../chunk-VOYMK2OO.js";import"../chunk-T25JIPX5.js";import"../chunk-HCIVLHKC.js";import"../chunk-NQQ4GSVI.js";import"../chunk-X4RVJ5VL.js";import"../chunk-DIRW7I4S.js";import"../chunk-YRPUM6JG.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-RAGUBE4Y.js";import"../chunk-Q3UVLSCX.js";import"../chunk-HSVIKO4D.js";import"../chunk-ZHH3PWEW.js";import"../chunk-IB2U7K6Y.js";import"../chunk-UJGRFV4J.js";export{d as addContact,a as generateInvite,e as listContacts,b as listInvites,f as listLocalContactBook,h as removeContact,i as renameContact,j as respondToIntroduction,c as revokeInvite,g as setLocalBookPolicy};
@@ -0,0 +1,10 @@
1
+ import { type IncomingFileMeta } from '../render/adapt-to-json.js';
2
+ import type { GetFilesResult, SaveFileNotice, SessionContext } from './types.js';
3
+ export type * from './types.js';
4
+ export declare function listIncomingFiles(ctx: SessionContext): Promise<IncomingFileMeta[]>;
5
+ export declare function getFiles(ctx: SessionContext, a?: {
6
+ wire_ids?: string[];
7
+ }): Promise<GetFilesResult>;
8
+ export declare function saveFileFallbackNotice(ctx: SessionContext, a: {
9
+ wire_id: string;
10
+ }): SaveFileNotice;
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import{a,b,c}from"../chunk-AJQIWYXG.js";import"../chunk-7UUFYO6G.js";import"../chunk-UM73BGFH.js";import"../chunk-NMYSFQBL.js";import"../chunk-VOYMK2OO.js";import"../chunk-T25JIPX5.js";import"../chunk-HCIVLHKC.js";import"../chunk-NQQ4GSVI.js";import"../chunk-X4RVJ5VL.js";import"../chunk-DIRW7I4S.js";import"../chunk-YRPUM6JG.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-RAGUBE4Y.js";import"../chunk-Q3UVLSCX.js";import"../chunk-HSVIKO4D.js";import"../chunk-ZHH3PWEW.js";import"../chunk-IB2U7K6Y.js";import"../chunk-UJGRFV4J.js";export{b as getFiles,a as listIncomingFiles,c as saveFileFallbackNotice};
@@ -0,0 +1,44 @@
1
+ import { type Identity } from '../identity/model.js';
2
+ import type { BindResult, CloseTempResult, CreateIdentityResult, CreateTempResult, CurrentIdentityResult, IdentityFileResult, IdentityTreeRow, RemoveResult, SessionContext, ReleaseLeaseResult } from './types.js';
3
+ export type * from './types.js';
4
+ export declare function requireBound(ctx: SessionContext): Identity;
5
+ export declare function createIdentity(ctx: SessionContext, a: {
6
+ name: string;
7
+ bio: string;
8
+ exposeLocal: boolean;
9
+ localAutoAccept: boolean;
10
+ }): Promise<CreateIdentityResult>;
11
+ export declare function createTemporaryIdentity(ctx: SessionContext, a: {
12
+ name?: string;
13
+ bio: string;
14
+ exposeLocal: boolean;
15
+ localAutoAccept: boolean;
16
+ }): Promise<CreateTempResult>;
17
+ export declare function closeTemporaryIdentityOp(ctx: SessionContext, a: {
18
+ name?: string;
19
+ }): Promise<CloseTempResult>;
20
+ export declare function createRootIdentity(ctx: SessionContext, a: {
21
+ name: string;
22
+ bio: string;
23
+ exposeLocal: boolean;
24
+ localAutoAccept: boolean;
25
+ skipIfRootExists: boolean;
26
+ }): Promise<CreateIdentityResult>;
27
+ export declare function defineLocalIdentityFile(a: {
28
+ name: string;
29
+ path: string;
30
+ force: boolean;
31
+ exposeLocal: boolean;
32
+ localAutoAccept: boolean;
33
+ overwrite: boolean;
34
+ }): Promise<IdentityFileResult>;
35
+ export declare function chooseIdentity(ctx: SessionContext, a: {
36
+ name: string;
37
+ force: boolean;
38
+ }): Promise<BindResult>;
39
+ export declare function listIdentities(ctx: SessionContext): Promise<IdentityTreeRow[]>;
40
+ export declare function currentIdentity(ctx: SessionContext): Promise<CurrentIdentityResult>;
41
+ export declare function removeIdentity(ctx: SessionContext, a: {
42
+ name: string;
43
+ }): Promise<RemoveResult>;
44
+ export declare function releaseLease(ctx: SessionContext): Promise<ReleaseLeaseResult>;
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import{a,b,c,d,e,f,g,h,i,j,k}from"../chunk-7UUFYO6G.js";import"../chunk-UM73BGFH.js";import"../chunk-NMYSFQBL.js";import"../chunk-VOYMK2OO.js";import"../chunk-T25JIPX5.js";import"../chunk-HCIVLHKC.js";import"../chunk-NQQ4GSVI.js";import"../chunk-X4RVJ5VL.js";import"../chunk-DIRW7I4S.js";import"../chunk-YRPUM6JG.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-RAGUBE4Y.js";import"../chunk-Q3UVLSCX.js";import"../chunk-HSVIKO4D.js";import"../chunk-ZHH3PWEW.js";import"../chunk-IB2U7K6Y.js";import"../chunk-UJGRFV4J.js";export{g as chooseIdentity,d as closeTemporaryIdentityOp,b as createIdentity,e as createRootIdentity,c as createTemporaryIdentity,i as currentIdentity,f as defineLocalIdentityFile,h as listIdentities,k as releaseLease,j as removeIdentity,a as requireBound};
@@ -0,0 +1,23 @@
1
+ import { type InboxMsg } from '../render/adapt-to-json.js';
2
+ import type { DeferResult, FileSendOutcome, MessagesPayload, SendOutcome, SessionContext } from './types.js';
3
+ export type * from './types.js';
4
+ export declare function sendMessage(ctx: SessionContext, a: {
5
+ contact: string;
6
+ text: string;
7
+ reply_to_wire_id?: string;
8
+ reply_to_sentence?: number;
9
+ }): Promise<SendOutcome>;
10
+ export declare function sendFile(ctx: SessionContext, a: {
11
+ contact: string;
12
+ path?: string;
13
+ data_base64?: string;
14
+ filename?: string;
15
+ mime?: string;
16
+ reply_to_wire_id?: string;
17
+ reply_to_sentence?: number;
18
+ }): Promise<FileSendOutcome>;
19
+ export declare function listIncomingMessages(ctx: SessionContext): Promise<InboxMsg[]>;
20
+ export declare function getMessages(ctx: SessionContext): Promise<MessagesPayload>;
21
+ export declare function deferMessages(ctx: SessionContext, a: {
22
+ msg_ids: number[];
23
+ }): Promise<DeferResult>;
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import{a,b,c,d,e}from"../chunk-NSPYN5TT.js";import"../chunk-VW2KWXSJ.js";import"../chunk-7UUFYO6G.js";import"../chunk-UM73BGFH.js";import"../chunk-NMYSFQBL.js";import"../chunk-VOYMK2OO.js";import"../chunk-T25JIPX5.js";import"../chunk-HCIVLHKC.js";import"../chunk-NQQ4GSVI.js";import"../chunk-X4RVJ5VL.js";import"../chunk-DIRW7I4S.js";import"../chunk-YRPUM6JG.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-RAGUBE4Y.js";import"../chunk-Q3UVLSCX.js";import"../chunk-HSVIKO4D.js";import"../chunk-ZHH3PWEW.js";import"../chunk-IB2U7K6Y.js";import"../chunk-UJGRFV4J.js";export{e as deferMessages,d as getMessages,c as listIncomingMessages,b as sendFile,a as sendMessage};
@@ -0,0 +1,9 @@
1
+ import type { AdvertiseMigrateResult, SessionContext, SetBioResult, SetPersonaResult } from './types.js';
2
+ export type * from './types.js';
3
+ export declare function setBio(ctx: SessionContext, a: {
4
+ bio: string;
5
+ }): Promise<SetBioResult>;
6
+ export declare function advertiseMigrate(ctx: SessionContext): Promise<AdvertiseMigrateResult>;
7
+ export declare function setPersona(ctx: SessionContext, a: {
8
+ persona: string;
9
+ }): Promise<SetPersonaResult>;
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import{a,b,c}from"../chunk-3DQSMLVZ.js";import"../chunk-7UUFYO6G.js";import"../chunk-UM73BGFH.js";import"../chunk-NMYSFQBL.js";import"../chunk-VOYMK2OO.js";import"../chunk-T25JIPX5.js";import"../chunk-HCIVLHKC.js";import"../chunk-NQQ4GSVI.js";import"../chunk-X4RVJ5VL.js";import"../chunk-DIRW7I4S.js";import"../chunk-YRPUM6JG.js";import"../chunk-LKFYUCN7.js";import"../chunk-P55RJGZU.js";import"../chunk-RAGUBE4Y.js";import"../chunk-Q3UVLSCX.js";import"../chunk-HSVIKO4D.js";import"../chunk-ZHH3PWEW.js";import"../chunk-IB2U7K6Y.js";import"../chunk-UJGRFV4J.js";export{b as advertiseMigrate,a as setBio,c as setPersona};
@@ -0,0 +1,177 @@
1
+ import type { TempCloseResult } from '../identity/model.js';
2
+ import type { MessageJson } from '../inbox.js';
3
+ import type { SendVerdict } from '../messaging/send.js';
4
+ import type { ContactRoot, IncomingFileMeta, InboxMsg, ReceivedFileMeta } from '../render/adapt-to-json.js';
5
+ export type { ContactRoot, IncomingFileMeta, InboxMsg, MessageJson, ReceivedFileMeta };
6
+ export interface SessionContext {
7
+ sessionId(): string;
8
+ leaseToken(): string | undefined;
9
+ clientPid(): number | undefined;
10
+ }
11
+ export interface IdentityInfo {
12
+ name: string;
13
+ cid: string;
14
+ bio: string;
15
+ persona: string;
16
+ roleId: string;
17
+ rootCid: string;
18
+ rootName: string;
19
+ }
20
+ export interface CreateIdentityResult {
21
+ info: IdentityInfo;
22
+ hierarchy: 'role' | 'root';
23
+ underRoot: string | null;
24
+ adopted: string[];
25
+ failed: string[];
26
+ exposedLocal: boolean;
27
+ localAutoAccept: boolean;
28
+ }
29
+ export interface CreateTempResult {
30
+ info: IdentityInfo;
31
+ ownerPid: number;
32
+ exposedLocal: boolean;
33
+ localAutoAccept: boolean;
34
+ }
35
+ export interface BindResult {
36
+ name: string;
37
+ cid: string;
38
+ switchedFrom: string | null;
39
+ }
40
+ export interface IdentityTreeRow {
41
+ name: string;
42
+ cid: string;
43
+ kind: 'root' | 'role' | 'flat';
44
+ temp: null | {
45
+ state: 'mine' | 'other-live' | 'stale' | 'closing';
46
+ ownerPid: number;
47
+ };
48
+ session: 'mine' | 'other-live' | null;
49
+ }
50
+ export interface RemoveResult {
51
+ name: string;
52
+ kind: 'permanent' | 'temporary';
53
+ close?: TempCloseResult;
54
+ }
55
+ export interface CloseTempResult {
56
+ name: string;
57
+ result: TempCloseResult | null;
58
+ }
59
+ export interface CurrentIdentityResult extends IdentityInfo {
60
+ temporary: boolean;
61
+ isRoot: boolean;
62
+ described: boolean;
63
+ }
64
+ export interface IdentityFileResult {
65
+ written: string;
66
+ json: Record<string, unknown>;
67
+ }
68
+ export interface InviteResult {
69
+ blob: string;
70
+ inviteId: string;
71
+ mode: 'one_time' | 'public';
72
+ }
73
+ export interface InviteRow {
74
+ invite_id: string;
75
+ mode: string;
76
+ assigned: string;
77
+ created: string;
78
+ }
79
+ export interface RevokeResult {
80
+ revoked: boolean;
81
+ wasPublic: boolean;
82
+ }
83
+ export interface AddContactResult {
84
+ display: string;
85
+ cid: string;
86
+ }
87
+ export interface ContactRow {
88
+ name: string;
89
+ container_id: string;
90
+ }
91
+ export interface PendingRow {
92
+ container_id: string;
93
+ name: string;
94
+ queued: number;
95
+ }
96
+ export interface DegradedRow {
97
+ cid: string;
98
+ name: string;
99
+ attempts: number;
100
+ queued: number;
101
+ }
102
+ export interface ContactsView {
103
+ contacts: ContactRow[];
104
+ pending: PendingRow[];
105
+ roots: Record<string, ContactRoot>;
106
+ degraded: DegradedRow[];
107
+ renames: Record<string, string>;
108
+ }
109
+ export interface LocalBookRow {
110
+ name: string;
111
+ container_id: string;
112
+ published_at: string;
113
+ isMine: boolean;
114
+ }
115
+ export interface LocalBookPolicyResult {
116
+ identity: string;
117
+ changes: string[];
118
+ }
119
+ export interface RemoveContactResult {
120
+ name: string;
121
+ cid: string;
122
+ notified: boolean | undefined;
123
+ }
124
+ export interface RenameContactResult {
125
+ from: string;
126
+ cid: string;
127
+ }
128
+ export type IntroductionResult = {
129
+ action: 'approve';
130
+ name: string;
131
+ cid: string;
132
+ flushed: string;
133
+ } | {
134
+ action: 'reject';
135
+ name: string;
136
+ dropped: string;
137
+ };
138
+ export interface SetBioResult {
139
+ identity: string;
140
+ rolesRefreshed: number;
141
+ }
142
+ export interface SetPersonaResult {
143
+ identity: string;
144
+ }
145
+ export interface AdvertiseMigrateResult {
146
+ wasAdvertising: boolean;
147
+ advertising: boolean;
148
+ offers: number;
149
+ }
150
+ export type SendOutcome = SendVerdict | {
151
+ kind: 'introduced';
152
+ text: string;
153
+ };
154
+ export type FileSendOutcome = SendOutcome & {
155
+ filename: string;
156
+ bytes: number;
157
+ mime: string;
158
+ };
159
+ export interface MessagesPayload {
160
+ count: number;
161
+ messages: MessageJson[];
162
+ }
163
+ export interface DeferResult {
164
+ deferred: string;
165
+ }
166
+ export interface GetFilesResult {
167
+ files: ReceivedFileMeta[];
168
+ text: string;
169
+ mode: 'all_unread' | 'selected';
170
+ requested: string[] | null;
171
+ }
172
+ export interface ReleaseLeaseResult {
173
+ released: string[];
174
+ }
175
+ export interface SaveFileNotice {
176
+ existsOnDisk: boolean;
177
+ }
@@ -0,0 +1 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
package/dist/book.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { type Identity } from './identity/model.js';
2
+ export declare const bookDir: () => string;
3
+ export declare const registrarKeyPath: () => string;
4
+ export declare const bookPath: () => string;
5
+ export interface BookEntry {
6
+ v: 1;
7
+ name: string;
8
+ container_id: string;
9
+ address_document: string;
10
+ published_at: string;
11
+ registrar_sig: string;
12
+ }
13
+ export declare function readBook(): Record<string, BookEntry>;
14
+ export declare function writeBook(entries: Record<string, BookEntry>): void;
15
+ export declare function exportAdBlob(id: Identity): Buffer;
16
+ export declare function exportSigningSecret(id: Identity): string;
17
+ export declare function publishToBook(id: Identity): Promise<void>;
18
+ export declare function unpublishFromBook(id: {
19
+ name: string;
20
+ cid: string;
21
+ }): void;
22
+ export declare function pinRegistrar(id: Identity): Promise<void>;
package/dist/book.js ADDED
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import{K as a,L as b,M as c,N as d,O as e,P as f,Q as g,R as h,S as i,T as j}from"./chunk-NQQ4GSVI.js";import"./chunk-X4RVJ5VL.js";import"./chunk-DIRW7I4S.js";import"./chunk-YRPUM6JG.js";import"./chunk-LKFYUCN7.js";import"./chunk-P55RJGZU.js";import"./chunk-RAGUBE4Y.js";import"./chunk-Q3UVLSCX.js";import"./chunk-HSVIKO4D.js";import"./chunk-ZHH3PWEW.js";import"./chunk-IB2U7K6Y.js";import"./chunk-UJGRFV4J.js";export{a as bookDir,c as bookPath,f as exportAdBlob,g as exportSigningSecret,j as pinRegistrar,h as publishToBook,d as readBook,b as registrarKeyPath,i as unpublishFromBook,e as writeBook};
package/dist/boot.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function bootWrapper(): Promise<void>;
package/dist/boot.js ADDED
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import{a}from"./chunk-A3SXVUOC.js";import"./chunk-NMYSFQBL.js";import"./chunk-VOYMK2OO.js";import"./chunk-T25JIPX5.js";import"./chunk-HCIVLHKC.js";import"./chunk-NQQ4GSVI.js";import"./chunk-X4RVJ5VL.js";import"./chunk-DIRW7I4S.js";import"./chunk-YRPUM6JG.js";import"./chunk-LKFYUCN7.js";import"./chunk-P55RJGZU.js";import"./chunk-RAGUBE4Y.js";import"./chunk-Q3UVLSCX.js";import"./chunk-HSVIKO4D.js";import"./chunk-ZHH3PWEW.js";import"./chunk-IB2U7K6Y.js";import"./chunk-UJGRFV4J.js";export{a as bootWrapper};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ var O=1;export{O as a};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import{a as m}from"./chunk-7UUFYO6G.js";import{J as c}from"./chunk-UM73BGFH.js";import{b as f,e as g,f as p}from"./chunk-HCIVLHKC.js";import{F as n,J as a}from"./chunk-NQQ4GSVI.js";import{c as u}from"./chunk-Q3UVLSCX.js";import{i as d}from"./chunk-HSVIKO4D.js";async function v(o,s){let e=m(o),{bio:i}=s;try{await n(async r=>{await a(e,"::a2a_messaging::set_my_bio",{bio:i},r)});let t=0;if(e.name===f){for(let r of u.values())if(r.name!==e.name&&g(r).rootCid===e.cid)try{await p(e,r),t+=1}catch(y){d(`failed to refresh root profile in role "${r.name}":`,String(y))}}return{identity:e.name,rolesRefreshed:t}}catch(t){throw c("set_bio",String(t))}}async function x(o){let s=m(o);try{return await n(async e=>{let i=await a(s,"::a2a_messaging::advertise_migrate",{},e);return{wasAdvertising:i.Reduce("was_advertising").Visualize()==="true",advertising:i.Reduce("advertising").Visualize()==="true",offers:parseInt(i.Reduce("offers_initiated").Visualize(),10)||0}})}catch(e){throw c("advertise_migrate",String(e))}}async function P(o,s){let e=m(o),{persona:i}=s;try{return await n(async t=>{await a(e,"::a2a_messaging::set_my_persona",{persona:i},t)}),{identity:e.name}}catch(t){throw c("set_persona",String(t))}}export{v as a,x as b,P as c};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ function i(s){let{selfVersion:n,daemonVersion:e}=s;return!e||e===n?null:`ours: version mismatch \u2014 this plugin/connector is v${n}, the running daemon is v${e}. Everything still works; for the best experience run matching versions. The daemon is a shared singleton and is never restarted automatically, so when no other session is mid-task run \`ours-mcp stop\` (the next session starts the daemon at the new version) \u2014 or update the lagging side to match. No action is required; this is advisory.`}export{i as a};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import{J as p,a as T,f as k,g as q,h as W,i as z,j as U,k as Y,l as G,m as J,n as K,o as Q,p as S,q as X,r as Z,s as ee,t as te,u as oe,v as ne,w as re,x as ie}from"./chunk-UM73BGFH.js";import{a as se,b as A}from"./chunk-NMYSFQBL.js";import{a as ae,c as de}from"./chunk-VOYMK2OO.js";import{b as f,e as b,f as N,g as E}from"./chunk-HCIVLHKC.js";import{F as M,J as j,x as L,y as _}from"./chunk-NQQ4GSVI.js";import{a as h,b as v,e as I,f as B,g as H,h as V,i as g}from"./chunk-RAGUBE4Y.js";import{c,o as w,p as $}from"./chunk-Q3UVLSCX.js";import{i as R,p as x}from"./chunk-HSVIKO4D.js";import{k as D,m as F}from"./chunk-IB2U7K6Y.js";import{randomBytes as ce}from"node:crypto";import{isAbsolute as me}from"node:path";function le(r){try{return b(r)}catch{return null}}function C(r){let o=le(r);return{name:r.name,cid:r.cid,bio:o?.bio??"",persona:o?.persona??"",roleId:o?.roleId??"",rootCid:o?.rootCid??"",rootName:o?.rootName??""}}async function P(r,o){o&&await M(async e=>{await j(r,"::a2a_messaging::set_my_bio",{bio:o},e)})}function pe(r){let o=V(r.sessionId());if(!("error"in o))return o.id;throw new T(o.code,o.error)}async function ke(r,o){let{name:e,bio:i,exposeLocal:d,localAutoAccept:s}=o,n=x(e);if(n)throw p("create_identity",n,"NAME_INVALID");if(c.has(e))throw k("create_identity",e);try{let t=await _(e,{exposeLocal:d,localAutoAccept:s});await P(t,i);let a,l=null,m=[],u=[],y=f?c.get(f):void 0;if(y)await N(y,t),a="role",l=y.name,ae()&&de(y);else{a="root";let O=await E(t);m=O.adopted,u=O.failed}return g(r.sessionId(),e),{info:C(t),hierarchy:a,underRoot:l,adopted:m,failed:u,exposedLocal:d,localAutoAccept:s}}catch(t){throw p("create_identity",String(t),"PROVISION_FAILED")}}async function Ae(r,o){let{bio:e,exposeLocal:i,localAutoAccept:d}=o,s=r.leaseToken(),n=r.clientPid();if(!s||!n)throw q();let t=o.name;if(t!==void 0){let l=x(t);if(l)throw p("create_temporary_identity",l,"NAME_INVALID");if(c.has(t)||L.has(t))throw k("create_temporary_identity",t)}else{for(let l=0;l<5&&t===void 0;l++){let m=`tmp-${ce(5).toString("hex")}`;!c.has(m)&&!L.has(m)&&(t=m)}if(t===void 0)throw W()}let a=t;try{let l=await _(a,{exposeLocal:i,localAutoAccept:d,temp:{tokenHash:w(s),pid:n}});return await P(l,e),g(r.sessionId(),a),{info:C(l),ownerPid:n,exposedLocal:i,localAutoAccept:d}}catch(l){throw p("create_temporary_identity",String(l),"PROVISION_FAILED")}}async function Ce(r,o){let e=r.leaseToken(),i;if(o.name!==void 0){if(i=c.get(o.name),!i)return{name:o.name,result:null}}else{let n=e?B(e):void 0;if(i=n?c.get(n.identity):void 0,!i)throw U()}if(!i.temp)throw Y(i.name);let d=i.temp.owner,s=e!==void 0&&d.tokenHash===w(e);if(!s&&!i.temp.closing&&I(d.pid))throw G(i.name,d.pid);try{let n=await A(i,s?"explicit close by owner":"stale reclaim via close_temporary_identity");if(n.deleteError){let t=n.attempted===0?"It had no contacts, so no remove-me notices were needed.":`Remove-me notices: ${n.notified}/${n.attempted} queued, ${n.failed} not sent (best effort \u2014 delivery and remote contact deletion are not guaranteed).`;throw J(i.name,n.deleteError,t)}return{name:i.name,result:n}}catch(n){throw n instanceof T?n:p("close_temporary_identity",String(n),"CLOSE_FAILED")}}async function ve(r,o){let{name:e,bio:i,exposeLocal:d,localAutoAccept:s,skipIfRootExists:n}=o,t=x(e);if(t)throw p("create_root_identity",t,"NAME_INVALID");let a=f;if(n&&a&&c.has(a))throw z(a);if(c.has(e))throw k("create_root_identity",e);try{let l=await _(e,{exposeLocal:d,localAutoAccept:s});await P(l,i);let m=f?c.get(f):void 0;if(m&&m.name!==e)return await N(m,l),g(r.sessionId(),e),{info:C(l),hierarchy:"role",underRoot:m.name,adopted:[],failed:[],exposedLocal:d,localAutoAccept:s};let{adopted:u,failed:y}=await E(l);return g(r.sessionId(),e),{info:C(l),hierarchy:"root",underRoot:null,adopted:u,failed:y,exposedLocal:d,localAutoAccept:s}}catch(l){throw p("create_root_identity",String(l),"PROVISION_FAILED")}}async function Le(r){if(!me(r.path))throw K(r.path);let o={name:r.name,force:r.force,exposeLocal:r.exposeLocal,localAutoAccept:r.localAutoAccept};try{return{written:F(r.path,o,r.overwrite),json:D(o)}}catch(e){throw p("define_local_identity_file",String(e),"WRITE_FAILED")}}async function Se(r,o){let{name:e,force:i}=o;if(!c.has(e))throw Q(e);let d=r.sessionId(),s=r.leaseToken();if(!s)throw S();let n=c.get(e);if(n.temp){if(n.temp.closing)throw X(e);let m=n.temp.owner;if(m.tokenHash!==w(s))throw I(m.pid)?Z(e,m.pid):ee(e,m.pid);let u=r.clientPid();if(u&&u!==m.pid){m.pid=u;try{$(n.dir,n.temp)}catch(y){R(`[${e}] temp marker refresh failed:`,String(y))}}}let t=h.get(e);if(t&&t.token!==s)if(!I(t.pid))R(`auto-reclaiming "${e}" from dead client pid ${t.pid}`),h.delete(e);else if(i)v.add(t.token),h.delete(e);else throw te(e);let a=[...h.values()].find(m=>m.token===s&&m.identity!==e)?.identity,l=a&&c.has(a)?a:null;return g(d,e),{name:e,cid:c.get(e).cid,switchedFrom:l}}async function Ne(r){if(c.size===0)return[];let o=r.leaseToken(),e=t=>{let a=h.get(t);return a?a.token===o?"mine":I(a.pid)?"other-live":null:null},i=t=>{if(!t.temp)return null;let a=t.temp.owner.pid;return t.temp.closing?{state:"closing",ownerPid:a}:o!==void 0&&t.temp.owner.tokenHash===w(o)?{state:"mine",ownerPid:a}:I(a)?{state:"other-live",ownerPid:a}:{state:"stale",ownerPid:a}},d=(t,a)=>({name:t.name,cid:t.cid,kind:a,temp:i(t),session:e(t.name)}),s=f?c.get(f):void 0,n=[];if(s){n.push({...d(s,"root"),temp:null});for(let t of c.values())t.name!==s.name&&b(t).roleId!==""&&n.push(d(t,"role"));for(let t of c.values())t.name===s.name||b(t).roleId!==""||n.push(d(t,"flat"))}else for(let t of c.values())n.push(d(t,"flat"));return n}async function Ee(r){let o=pe(r),e=le(o);return{name:o.name,cid:o.cid,bio:e?.bio??"",persona:e?.persona??"",roleId:e?.roleId??"",rootCid:e?.rootCid??"",rootName:e?.rootName??"",temporary:o.temp!==void 0,isRoot:o.name===f,described:e!==null}}async function Pe(r,o){let{name:e}=o,i=c.get(e);if(!i)throw p("remove_identity",`no identity named "${e}".`,"NO_SUCH_IDENTITY");if(i.temp){let s=r.leaseToken(),n=i.temp.owner;if((s===void 0||n.tokenHash!==w(s))&&!i.temp.closing&&I(n.pid))throw oe(e,n.pid);try{let t=await A(i,"remove_identity");if(t.deleteError){let a=t.attempted===0?"":` Remove-me notices: ${t.notified}/${t.attempted} queued, ${t.failed} not sent (best effort).`;throw ne(e,t.deleteError,a)}return{name:e,kind:"temporary",close:t}}catch(t){throw t instanceof T?t:p("remove_identity",String(t),"CLOSE_FAILED")}}if(e===f){let s=[...c.values()].filter(n=>n.name!==e&&b(n).rootCid===i.cid);if(s.length>0)throw re(e,s.map(n=>n.name))}let d=se(i);if(d)throw ie(e,d);return{name:e,kind:"permanent"}}async function Oe(r){let o=r.leaseToken();if(!o)throw S();let e=[];for(let[i,d]of[...h]){if(d.token!==o)continue;h.delete(i),e.push(i);let s=c.get(i);s?.temp&&s.temp.owner.tokenHash===w(o)&&!s.temp.closing&&A(s,"owning session released its lease").catch(n=>R(`[${i}] close on lease release failed:`,String(n)))}return v.delete(o),H(),R(`lease released by token \u2026${o.slice(-6)}`),{released:e}}export{pe as a,ke as b,Ae as c,Ce as d,ve as e,Le as f,Se as g,Ne as h,Ee as i,Pe as j,Oe as k};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import{c as L,d as x}from"./chunk-NMYSFQBL.js";import{d as A}from"./chunk-VOYMK2OO.js";import{a as u,b as a,c as U,d as D,e as C,f as P}from"./chunk-HCIVLHKC.js";import{A as M,T as N,g as k,s as g,u as h,x as v,z as I}from"./chunk-NQQ4GSVI.js";import{a as b,b as O,c as $}from"./chunk-YRPUM6JG.js";import{g as E}from"./chunk-RAGUBE4Y.js";import{a as f,b as T,c,d as w,q as y,r as R,w as S}from"./chunk-Q3UVLSCX.js";import{d as l,h as n,i as r}from"./chunk-HSVIKO4D.js";import{adapt_wrapper as H}from"@adapt-toolkit/sdk/executables";async function te(){n?.update("wrapper"),$(b());let B=["--broker_address",l,"--test_mode","--logger_config","--level","INFO","--stdout","stderr","--logger_config_end"];r(`booting wrapper (unit ${O.hash.slice(0,12)}\u2026, broker ${l})`),T(await H.start(B)),f.on_packet_created_cb=e=>r(`wrapper: packet ready ${e.slice(0,12)}\u2026`),f.start();let p=Number(process.env.OURS_TEST_BOOT_HOLD_MS||"")||0;p>0&&(r(`TEST HOLD: boot window open ${p}ms (OURS_TEST_BOOT_HOLD_MS)`),await new Promise(e=>setTimeout(e,p))),n?.update("registrar");try{await M()}catch(e){r("failed to start the contact-book registrar (local contact book disabled):",String(e))}R();let i=S(),d=Math.max(0,Number(process.env.OURS_TEST_FAKE_RESTORE_COUNT||"")||0),m=Math.max(0,Number(process.env.OURS_TEST_FAKE_RESTORE_MS||"")||0),F=i.length===0&&d>0?d:i.length;n?.update("identities",{completed:0,total:F});for(let e of i)v.add(e);if(i.length===0&&d>0){r(`TEST: simulating ${d} fake identity restore(s), ${m}ms each`);for(let e=0;e<d;e++)m>0&&await new Promise(s=>setTimeout(s,m)),n?.update("identities",{completed:e+1,total:d})}else if(i.length===0)r("no persisted identities \u2014 start with create_identity");else{r(`restoring ${i.length} identit${i.length===1?"y":"ies"}: ${i.join(", ")}`);for(let[e,s]of i.entries()){try{let t=await I(s);w&&await N(t);let o=y(t.dir);o&&(t.temp=o)}catch(t){r(`failed to restore "${s}":`,String(t))}n?.update("identities",{completed:e+1,total:i.length})}}n?.update("reconciliation"),A(),u(U()),a&&!c.has(a)&&(r(`root marker names a missing identity "${a}" \u2014 clearing it`),u(null),D()),a&&r(`root identity: ${a}`);{let e=a?c.get(a):void 0;a&&!e&&r(`re-delegation on upgrade DEGRADED: root "${a}" is not among the restored identities \u2014 role certs not refreshed this boot`);let s=[];if(e)for(let t of c.values()){if(t.name===e.name)continue;let o;try{o=C(t)}catch{o=void 0}if(!(!o||!o.hasCert)){if(o.rootCid!==e.cid){r(`[${t.name}] re-delegation skipped: delegated by a different root (${o.rootCid.slice(0,12)}\u2026), not this host root \u2014 left as-is`);continue}try{await P(e,t),s.push(t)}catch(_){k(t,{event:"redelegation_failed",error:String(_).slice(0,300)}),r(`[${t.name}] boot re-delegation (upgrade cert refresh) failed:`,String(_))}}}for(let t of c.values()){await g(t),await h(t);for(let o of[1e4,3e4,9e4])setTimeout(()=>{g(t).catch(()=>{})},o),setTimeout(()=>{h(t).catch(()=>{})},o)}s.length>0&&r(`refreshed ${s.length} role delegation cert(s) against the live AD on boot`)}E(),x(),L()}export{te as a};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import{a as s}from"./chunk-7UUFYO6G.js";import{F as h,G as F,H as x,I as y,J as a}from"./chunk-UM73BGFH.js";import{E as g,F as p,G as w,J as S,m as u}from"./chunk-NQQ4GSVI.js";import{d as f,f as m}from"./chunk-X4RVJ5VL.js";import{t as c,u as l,v as d}from"./chunk-Q3UVLSCX.js";async function T(n){let r=s(n);try{return g(t=>f(w(r,"::actor::list_incoming_files",t)))}catch(t){throw a("list_incoming_files",String(t))}}async function E(n,r={}){let t=s(n),{wire_ids:e}=r;if(e!==void 0){if(e.length<1||e.length>l)throw h(l);if(e.some(i=>!c(i)))throw F();if(new Set(e).size!==e.length)throw x()}try{let i=await p(async o=>{let _=await S(t,"::actor::get_files",e===void 0?{}:{wire_ids:e},o);return await m(t,_.Reduce("files"))});return u(t),{files:i.files,text:i.text,mode:e===void 0?"all_unread":"selected",requested:e??null}}catch(i){let o=String(i);throw e!==void 0&&/unknown, stale, or no longer unread/i.test(o)?y():a("get_files",o)}}function O(n,r){let t=s(n);return{existsOnDisk:d(t,r.wire_id)!==null}}export{T as a,E as b,O as c};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ var w="x-ours-kind=voice-message",$="voice-message-";function C(e,o){let t=(e??"").toLowerCase().split(";").map(r=>r.trim());return t[0].startsWith("audio/")&&t.slice(1).includes(w)?!0:o.toLowerCase().startsWith($)&&t[0].startsWith("audio/")}function T(e){return(e??"").split(";")[0].trim()||"application/octet-stream"}var g=["openai-compatible","elevenlabs","deepgram","custom"],P=5*1024*1024,A=6e4;function E(e){let o="configure it in config.json `stt: {}` or via OURS_STT_* env";if(!e?.provider)return{ready:!1,reason:`no STT provider configured (stt.provider: ${g.join(" | ")}) \u2014 ${o}`};let t=e.provider.trim().toLowerCase();if(!g.includes(t))return{ready:!1,reason:`unknown STT provider "${e.provider}" (expected: ${g.join(" | ")})`};if(!e.apiKey?.trim())return{ready:!1,reason:`STT provider "${t}" is set but the API key is missing (stt.apiKey / OURS_STT_API_KEY)`};if(t==="openai-compatible"){if(!e.baseUrl?.trim())return{ready:!1,reason:"openai-compatible STT needs stt.baseUrl / OURS_STT_BASE_URL (e.g. your provider's /v1 root) \u2014 no endpoint is assumed"};if(!e.model?.trim())return{ready:!1,reason:"openai-compatible STT needs stt.model / OURS_STT_MODEL (passed to the provider verbatim) \u2014 no model is assumed"}}if(t==="elevenlabs"&&!e.model?.trim())return{ready:!1,reason:"elevenlabs STT needs stt.model / OURS_STT_MODEL (the model_id, e.g. from your ElevenLabs account) \u2014 no model is assumed"};if(t==="custom"){if(!e.custom?.url?.trim())return{ready:!1,reason:"custom STT needs stt.custom.url (the full endpoint URL of your provider)"};if((e.custom.url.includes("{model}")||e.custom.modelField!==void 0&&e.custom.modelField!=="")&&!e.model?.trim())return{ready:!1,reason:"the custom STT template references a model (url {model} or modelField) but stt.model / OURS_STT_MODEL is not set"}}return{ready:!0,provider:t}}function c(e,o){let t=e;for(let r of o.split(".")){if(t===null||typeof t!="object")return;t=t[r]}return typeof t=="string"?t:void 0}async function p(e,o,t,r=[]){let a=new AbortController,i=setTimeout(()=>a.abort(),t);try{let n=await fetch(e,{...o,signal:a.signal});if(!n.ok){let s=await n.text().catch(()=>"");for(let d of r)d&&(s=s.split(d).join("[redacted]"));return{ok:!1,error:`STT HTTP ${n.status}${s?`: ${s.slice(0,200)}`:""}`}}return{ok:!0,json:await n.json()}}catch(n){return n?.name==="AbortError"?{ok:!1,error:`STT timeout after ${t}ms`}:{ok:!1,error:n instanceof Error?n.message:String(n)}}finally{clearTimeout(i)}}var y=(e,o)=>new Blob([new Uint8Array(e)],{type:T(o)}),O=async(e,o,t,r,a)=>{let i=new FormData;i.set("file",y(e,t),o),i.set("model",r.model.trim()),i.set("response_format","json"),r.language?.trim()&&i.set("language",r.language.trim());let n=await p(`${r.baseUrl.trim().replace(/\/$/,"")}/audio/transcriptions`,{method:"POST",headers:{Authorization:`Bearer ${r.apiKey.trim()}`},body:i},a,[r.apiKey.trim()]);if(!n.ok)return n;let s=c(n.json,"text");return s!==void 0?{ok:!0,text:s}:{ok:!1,error:"STT response missing text"}},U=async(e,o,t,r,a)=>{let i=new FormData;i.set("file",y(e,t),o),i.set("model_id",r.model.trim()),r.language?.trim()&&i.set("language_code",r.language.trim());let n=await p(`${(r.baseUrl?.trim()||"https://api.elevenlabs.io").replace(/\/$/,"")}/v1/speech-to-text`,{method:"POST",headers:{"xi-api-key":r.apiKey.trim()},body:i},a,[r.apiKey.trim()]);if(!n.ok)return n;let s=c(n.json,"text");return s!==void 0?{ok:!0,text:s}:{ok:!1,error:"STT response missing text"}},R=async(e,o,t,r,a)=>{let i=new URLSearchParams;r.model?.trim()&&i.set("model",r.model.trim()),r.language?.trim()&&i.set("language",r.language.trim());let n=i.toString(),s=await p(`${(r.baseUrl?.trim()||"https://api.deepgram.com").replace(/\/$/,"")}/v1/listen${n?`?${n}`:""}`,{method:"POST",headers:{Authorization:`Token ${r.apiKey.trim()}`,"Content-Type":T(t)},body:new Uint8Array(e)},a,[r.apiKey.trim()]);if(!s.ok)return s;let d=c(s.json,"results.channels.0.alternatives.0.transcript");return d!==void 0?{ok:!0,text:d}:{ok:!1,error:"STT response missing transcript"}},M=async(e,o,t,r,a)=>{let i=r.custom,n=r.model?.trim()??"",s=i.url.replaceAll("{model}",encodeURIComponent(n)),d={},x=i.authHeaderName?.trim()||"Authorization",S=(i.authHeaderTemplate??"Bearer {key}").replaceAll("{key}",r.apiKey.trim());S&&(d[x]=S);let h=i.bodyMode??"multipart",v=i.fileField?.trim()||"file",u=i.modelField===void 0?"model":i.modelField.trim(),l;if(h==="multipart"){let m=new FormData;m.set(v,y(e,t),o),u&&n&&m.set(u,n);for(let[b,k]of Object.entries(i.extraFields??{}))m.set(b,k);l=m}else h==="raw"?(d["Content-Type"]=T(t),l=new Uint8Array(e)):(d["Content-Type"]="application/json",l=JSON.stringify({[v]:e.toString("base64"),...u&&n?{[u]:n}:{},...i.extraFields??{}}));let f=await p(s,{method:i.method?.trim()||"POST",headers:d,body:l},a,[r.apiKey.trim()]);if(!f.ok)return f;let _=c(f.json,i.responseTextPath?.trim()||"text");return _!==void 0?{ok:!0,text:_}:{ok:!1,error:`STT response has no text at "${i.responseTextPath?.trim()||"text"}"`}},B={"openai-compatible":O,elevenlabs:U,deepgram:R,custom:M};async function I(e,o,t,r){let a=E(r);if(!a.ready)return{ok:!1,error:a.reason};let i=r.maxBytes??P;if(e.length>i)return{ok:!1,error:`voice message is ${e.length} B \u2014 over the ${i} B STT limit (stt.maxBytes)`};let n=r.timeoutMs??A;try{return await B[a.provider](e,o,t,r,n)}catch(s){return{ok:!1,error:s instanceof Error?s.message:String(s)}}}function F(e){return/limit|over .* bytes/i.test(e)?"size_limit":/timeout/i.test(e)?"timeout":/HTTP \d+/i.test(e)?"provider_http":/missing|no text|no transcript/i.test(e)?"invalid_response":"provider_error"}function j(e,o,t){return!e.ready||o.kind==="unconfigured"?{configured:!1,attempted:!1,status:"unavailable",provider:null,text:null,error_category:"not_configured",audio_path:t.audioPath,file_wire_id:t.wireId}:o.kind==="transcript"?{configured:!0,attempted:!0,status:"succeeded",provider:e.provider,text:o.text,error_category:null,audio_path:t.audioPath,file_wire_id:t.wireId}:{configured:!0,attempted:!0,status:"failed",provider:e.provider,text:null,error_category:F(o.error),audio_path:t.audioPath,file_wire_id:t.wireId}}function L(e,o){let t=` \u2022 \u{1F3A4} voice message from ${e.sender} (${e.sizeBytes} B)`,r=`audio saved \u2192 ${e.savedPath} {${e.wire}}`;switch(o.kind){case"transcript":return`${t}: "${o.text}" \u2014 transcribed from voice message (STT); ${r}`;case"unconfigured":return`${t}: cannot transcribe \u2014 ${o.reason}. Tell the user you can't listen to voice messages until the operator configures transcription on this ours-mcp server, and ask them to send text meanwhile; ${r}`;case"failed":return`${t}: transcription failed (${o.error}). Tell the user their voice message could not be transcribed right now and ask them to send text or retry; ${r}`}}export{w as a,$ as b,C as c,T as d,g as e,P as f,A as g,E as h,c as i,I as j,j as k,L as l};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import{E as m,F as p,G as l,J as a,P as f}from"./chunk-NQQ4GSVI.js";import{c as u}from"./chunk-Q3UVLSCX.js";import{c as d,i}from"./chunk-HSVIKO4D.js";import{join as x}from"node:path";import*as r from"node:fs";function V(e){y=e}var c=()=>x(d,"root.json"),y=null;function $(){try{let e=JSON.parse(r.readFileSync(c(),"utf8"));return typeof e.name=="string"?e.name:null}catch{return null}}function I(e){r.mkdirSync(d,{recursive:!0});let o=`${c()}.tmp`;r.writeFileSync(o,JSON.stringify({v:1,name:e})),r.renameSync(o,c())}function G(){r.rmSync(c(),{force:!0})}function z(e){return m(o=>{let t=l(e,"::actor::describe_identity",o);return{bio:t.Reduce("bio").Visualize(),persona:t.Reduce("persona").Visualize(),hasCert:t.Reduce("has_cert").GetBoolean(),roleId:t.Reduce("role_id").Visualize(),rootCid:t.Reduce("root_cid").Visualize(),rootName:t.Reduce("root_name").Visualize(),monitoringEnabled:t.Reduce("monitoring_enabled").GetBoolean()}})}async function A(e,o){await p(async t=>{let n=f(o),s=await a(e,"::actor::sign_delegation",{role_ad:e.pw.packet.NewBinaryFromBuffer(n).Attach(t),role_id:o.name},t),g=Buffer.from(s.Reduce("cert").GetBinary()),B=await a(e,"::actor::export_root_profile",{},t),w=Buffer.from(B.Reduce("profile").GetBinary()),h=f(e),_=Buffer.from((await a(o,"::actor::export_v1_address_document",{},t)).Reduce("ad").GetBinary()),R=await a(e,"::actor::sign_delegation",{role_ad:e.pw.packet.NewBinaryFromBuffer(_).Attach(t),role_id:o.name},t),b=Buffer.from(R.Reduce("cert").GetBinary());await a(o,"::actor::set_delegation",{cert:o.pw.packet.NewBinaryFromBuffer(g).Attach(t),root_ad:o.pw.packet.NewBinaryFromBuffer(h).Attach(t),root_profile:o.pw.packet.NewBinaryFromBuffer(w).Attach(t),cert_v1:o.pw.packet.NewBinaryFromBuffer(b).Attach(t)},t)}),i(`[${o.name}] delegated as a role under root "${e.name}"`)}async function C(e){y=e.name,I(e.name);let o=[],t=[];for(let n of u.values())if(n.name!==e.name&&!n.temp)try{await A(e,n),o.push(n.name)}catch(s){i(`failed to adopt "${n.name}" as a role under new root "${e.name}":`,String(s)),t.push(n.name)}return i(`[${e.name}] established as the host root${o.length?` (adopted ${o.length} role(s))`:""}`),{adopted:o,failed:t}}export{V as a,y as b,$ as c,G as d,z as e,A as f,C as g};
@@ -0,0 +1,3 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import{e as a}from"./chunk-ZHH3PWEW.js";import{d as s,f as i,g as u,h as p}from"./chunk-IB2U7K6Y.js";import{timingSafeEqual as d}from"node:crypto";var b="0.1.1",r=s(),_=r.stateDir,k=r.brokerUrl,g=process.env.OURS_TRANSPORT??"http",E=r.port,A=r.gcIntervalMs,c=r.apiVisibility,R=Number(process.env.OURS_TEST_STARTUP_HEARTBEAT_MS||"")||void 0,N=g==="http"?a(_,{heartbeatMs:R}):null,v=(...e)=>process.stderr.write(`ours: ${e.join(" ")}
3
+ `);function S(){if(c==="open")return null;if(c==="shared"){let e=u(r);if(!e)throw new Error(`apiVisibility=shared requires an operator-supplied token so it can be distributed to cross-user agents \u2014 set OURS_API_TOKEN or "apiToken" in config (${i(r)} is not used for shared mode). Use apiVisibility=owner for a same-user-only auto-token, or =open to disable auth.`);return e}return p(r,{generate:!0}).token}var f=S();function T(e){let t=e.headers["x-ours-api-token"];if(typeof t=="string"&&t)return t;let o=e.headers.authorization;if(typeof o=="string"){let n=/^Bearer\s+(.+)$/i.exec(o.trim());if(n)return n[1]}}function h(e){if(f===null)return!0;let t=T(e);if(!t)return!1;let o=Buffer.from(t),n=Buffer.from(f);return o.length===n.length&&d(o,n)}function P(e,t){return h(e)?!0:(t.writeHead(401,{"Content-Type":"application/json"}),t.end(JSON.stringify({error:"unauthorized"})),!1)}var O=/^[A-Za-z0-9 _.@-]{1,64}$/,l="contact-book";function y(e){return O.test(e)?e==="."||e===".."||e.includes("/")||e.includes("\\")?"invalid name":e===l?`"${l}" is reserved for the local contact book`:e==="root.json"||e==="bindings.json"?`"${e}" is reserved for daemon bookkeeping`:null:"name must be 1-64 chars of letters, digits, space, _ . @ or -"}export{b as a,r as b,_ as c,k as d,E as e,A as f,c as g,N as h,v as i,f as j,T as k,h as l,P as m,O as n,l as o,y as p};
@@ -0,0 +1,5 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import*as o from"node:fs";import{randomBytes as S}from"node:crypto";import{homedir as g}from"node:os";import{resolve as a,join as c,dirname as u,basename as b}from"node:path";var d=["owner","shared","open"],s={brokerUrl:"wss://broker1.ours.network",port:3050,stateDir:a(g(),".ours"),gcIntervalMs:36e5,autoStart:!1,apiVisibility:"owner"};function y(){return process.env.OURS_CONFIG??c(g(),".ours","config.json")}function T(){let t;try{t=o.readFileSync(y(),"utf8")}catch{return{}}let e;try{e=JSON.parse(t)}catch{return{}}let i={};if(typeof e.brokerUrl=="string"&&(i.brokerUrl=e.brokerUrl),typeof e.port=="number"&&Number.isFinite(e.port)&&(i.port=e.port),typeof e.stateDir=="string"&&(i.stateDir=a(e.stateDir)),typeof e.gcIntervalMs=="number"&&Number.isFinite(e.gcIntervalMs)&&(i.gcIntervalMs=e.gcIntervalMs),typeof e.autoStart=="boolean"&&(i.autoStart=e.autoStart),typeof e.apiVisibility=="string"&&d.includes(e.apiVisibility)&&(i.apiVisibility=e.apiVisibility),typeof e.apiToken=="string"&&e.apiToken.trim()&&(i.apiToken=e.apiToken.trim()),e.stt&&typeof e.stt=="object"){let r=e.stt,n={};typeof r.provider=="string"&&(n.provider=r.provider),typeof r.apiKey=="string"&&(n.apiKey=r.apiKey),typeof r.model=="string"&&(n.model=r.model),typeof r.baseUrl=="string"&&(n.baseUrl=r.baseUrl),typeof r.language=="string"&&(n.language=r.language),typeof r.maxBytes=="number"&&Number.isFinite(r.maxBytes)&&(n.maxBytes=r.maxBytes),typeof r.timeoutMs=="number"&&Number.isFinite(r.timeoutMs)&&(n.timeoutMs=r.timeoutMs),r.custom&&typeof r.custom=="object"&&(n.custom=r.custom),i.stt=n}return i}function v(){let t=process.env.OURS_API_VISIBILITY?.trim().toLowerCase();return t&&d.includes(t)?t:void 0}function _(t){let e=process.env[t];if(e!==void 0)return e==="1"||e.toLowerCase()==="true"}function l(t){let e=process.env[t];if(e===void 0)return;let i=parseInt(e,10);return Number.isNaN(i)?void 0:i}function C(){let t=T();return{brokerUrl:process.env.OURS_BROKER_URL??t.brokerUrl??s.brokerUrl,port:l("OURS_PORT")??t.port??s.port,stateDir:a(process.env.OURS_STATE_DIR??t.stateDir??s.stateDir),gcIntervalMs:l("OURS_GC_INTERVAL_MS")??t.gcIntervalMs??s.gcIntervalMs,autoStart:_("OURS_AUTOSTART")??t.autoStart??s.autoStart,apiVisibility:v()??t.apiVisibility??s.apiVisibility,apiToken:process.env.OURS_API_TOKEN?.trim()||t.apiToken,stt:O(t.stt)}}function O(t){let e={};process.env.OURS_STT_PROVIDER?.trim()&&(e.provider=process.env.OURS_STT_PROVIDER.trim()),process.env.OURS_STT_API_KEY?.trim()&&(e.apiKey=process.env.OURS_STT_API_KEY.trim()),process.env.OURS_STT_MODEL?.trim()&&(e.model=process.env.OURS_STT_MODEL.trim()),process.env.OURS_STT_BASE_URL?.trim()&&(e.baseUrl=process.env.OURS_STT_BASE_URL.trim()),process.env.OURS_STT_LANGUAGE?.trim()&&(e.language=process.env.OURS_STT_LANGUAGE.trim());let i={...t??{},...e};return Object.keys(i).length?i:void 0}var U="daemon-token";function k(t){return c(t.stateDir,U)}function w(t){let e=process.env.OURS_API_TOKEN?.trim();return e||t.apiToken?.trim()||void 0}function F(t,e={}){let i=process.env.OURS_API_TOKEN?.trim();if(i)return{token:i,source:"env"};let r=t.apiToken?.trim();if(r)return{token:r,source:"config"};let n=k(t);try{let p=o.readFileSync(n,"utf8").trim();if(p)return{token:p,source:"file"}}catch{}if(!e.generate)return null;let f=S(32).toString("hex");try{o.mkdirSync(u(n),{recursive:!0}),o.writeFileSync(n,f+`
3
+ `,{mode:384}),o.chmodSync(n,384)}catch{}return{token:f,source:"generated"}}function N(t){let e=y();o.mkdirSync(u(e),{recursive:!0}),o.writeFileSync(e,JSON.stringify(t,null,2)+`
4
+ `,{mode:384});try{o.chmodSync(e,384)}catch{}return e}var m=".ours-identity";function I(t){if(!t.name.trim())throw new Error("identity name must not be empty");let e={identity:t.name.trim()};return t.force&&(e.force=!0),e.expose_local=t.exposeLocal??!0,e.local_auto_accept=t.localAutoAccept??!0,e}function R(t){let e=a(t);return b(e)===m?e:c(e,m)}function V(t,e,i=!1){let r=I(e),n=R(t);if(!i&&o.existsSync(n))throw new Error(`${n} already exists \u2014 pass overwrite to replace it`);return o.mkdirSync(u(n),{recursive:!0}),o.writeFileSync(n,JSON.stringify(r,null,2)+`
5
+ `),n}export{d as a,s as b,y as c,C as d,U as e,k as f,w as g,F as h,N as i,m as j,I as k,R as l,V as m};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ import{a as d}from"./chunk-7UUFYO6G.js";import{J as r,y as T,z as j}from"./chunk-UM73BGFH.js";import{E as y,F as u,G as p,J as l,N,R as L,S as A,m as z,o as P,t as f}from"./chunk-NQQ4GSVI.js";import{a as C,b as V,g as x,h as I,j as S,k as B}from"./chunk-X4RVJ5VL.js";import{d as _,f as k}from"./chunk-RAGUBE4Y.js";async function U(s,a={}){let e=d(s),{name:i,mode:o}=a;if(o==="public"&&i)throw T();try{return await u(async t=>{let n={};i&&(n.name=i),o&&(n.mode=o);let c=await l(e,"::a2a_messaging::generate_invite",n,t);return{blob:S(Buffer.from(c.Reduce("invite").GetBinary())),inviteId:c.Reduce("invite_id").Visualize(),mode:c.Reduce("mode").Visualize()==="public"?"public":"one_time"}})}catch(t){throw r("generate_invite",String(t))}}async function $(s){let a=d(s);try{return y(e=>{let i=p(a,"::a2a_messaging::list_invites",e),o=[];if(i.IsNil())return o;for(let t of i.GetKeys()){let n=i.Reduce(t);if(n.IsNil())continue;let c=n.Reduce("assigned").Visualize(),m=n.Reduce("created").Visualize();o.push({invite_id:typeof t=="string"?t:t.Visualize(),mode:n.Reduce("mode").Visualize(),assigned:c==="%%NIL"?"":c,created:m==="%%NIL"?"":m})}return o})}catch(e){throw r("list_invites",String(e))}}async function H(s,a){let e=d(s),{invite_id:i}=a;try{return await u(async o=>{let t=await l(e,"::a2a_messaging::revoke_invite",{invite_id:i},o),n=t.Reduce("was_public");return{revoked:t.Reduce("revoked").GetBoolean(),wasPublic:n.IsNil()?!1:n.GetBoolean()}})}catch(o){throw r("revoke_invite",String(o))}}async function J(s,a){let e=d(s),{invite:i,name:o}=a,t;try{if(t=B(i),t.length===0)throw new Error("the invite blob is empty")}catch(n){throw r("add_contact",n instanceof Error?n.message:"the invite blob is not valid.","INVITE_MALFORMED")}try{return await u(async n=>{let m={invite:e.pw.packet.NewBinaryFromBuffer(t).Attach(n)};o&&(m.name=o);let g=await l(e,"::a2a_messaging::add_contact",m,n),R=g.Reduce("container_id").Visualize(),v=g.Reduce("pending").Visualize(),h=g.Reduce("inviter_name").Visualize(),w=b=>!b||b==="%%NIL",G=w(v)?w(h)?R:h:v;return f(e),{display:G,cid:R}})}catch(n){throw r("add_contact",String(n))}}async function Q(s){let a=d(s);try{return y(e=>({contacts:C(p(a,"::a2a_messaging::list_contacts",e)),pending:x(p(a,"::actor::list_pending_introductions",e)),roots:I(p(a,"::a2a_messaging::list_contact_roots",e)),degraded:P(p(a,"::a2a_messaging::list_degraded_contacts",e)),renames:V(p(a,"::a2a_messaging::list_import_renames",e))}))}catch(e){throw r("list_contacts",String(e))}}async function X(s){let a=Object.values(N()),e=s.leaseToken(),i=e?k(e)?.identity:void 0;return a.map(o=>({name:o.name,container_id:o.container_id,published_at:o.published_at,isMine:o.name===i}))}async function Y(s,a){let e=d(s),{expose:i,auto_accept:o}=a;if(i===void 0&&o===void 0)throw j();let t=[];try{return o!==void 0&&(await u(async n=>{await l(e,"::actor::set_local_policy",{auto_accept:o},n)}),t.push(`auto_accept=${o}`)),i===!0?(await L(e),t.push("published in the local contact book")):i===!1&&(A(e),t.push("removed from the local contact book")),{identity:e.name,changes:t}}catch(n){throw r("set_local_book_policy",String(n))}}async function Z(s,a){let e=d(s),{contact:i}=a;try{return _.add(e.name),await u(async o=>{let t=await l(e,"::a2a_messaging::remove_contact",{contact:i},o),n=t.Reduce("removed").Visualize(),c=t.Reduce("container_id").Visualize(),m=t.Reduce("notified"),g=m.IsNil()?void 0:m.GetBoolean();return{name:n,cid:c,notified:g}})}catch(o){throw r("remove_contact",String(o))}finally{_.delete(e.name)}}async function ee(s,a){let e=d(s),{contact:i,name:o}=a;try{return await u(async t=>{let n=await l(e,"::a2a_messaging::rename_contact",{contact:i,name:o},t);return{from:n.Reduce("renamed").Visualize(),cid:n.Reduce("container_id").Visualize()}})}catch(t){throw r("rename_contact",String(t))}}async function te(s,a){let e=d(s),{contact:i,action:o}=a;try{if(o==="approve"){let t=await u(async n=>{let c=await l(e,"::actor::approve_introduction",{contact:i},n);return{action:"approve",name:c.Reduce("approved").Visualize(),cid:c.Reduce("container_id").Visualize(),flushed:c.Reduce("flushed").Visualize()}});return z(e),f(e),t}return await u(async t=>{let n=await l(e,"::actor::reject_introduction",{contact:i},t);return{action:"reject",name:n.Reduce("rejected").Visualize(),dropped:n.Reduce("dropped_messages").Visualize()}})}catch(t){throw r("respond_to_introduction",String(t))}}export{U as a,$ as b,H as c,J as d,Q as e,X as f,Y as g,Z as h,ee as i,te as j};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
2
+ var i=new Set(["e2e_app_recv","migration_deferred_flush"]);function a(e){let n=new Set;for(let t of e){if(!t||typeof t!="object")continue;let r=t.event;if(typeof r!="string"||!i.has(r))continue;let s=t.wire_id;typeof s=="string"&&s.length>0&&n.add(s)}return n}function o(e,n){return e&&n.has(e)?"e2e":"legacy"}function g(e,n){let t=o(e.wire_id,n);return{msg_id:e.msg_id,wire_id:e.wire_id,from:{id:e.sender_id,name:e.sender_name},encryption:t,transport:t==="e2e"?"double_ratchet":"legacy_box",text:e.text,date:e.date,status:e.status,reply_to:e.reply_to}}function d(e,n){let t=e.map(r=>g(r,n));return{count:t.length,messages:t}}export{a,o as b,g as c,d};