@ours.network/sdk 2.0.1 → 3.0.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 +25 -2
- package/dist/api/contacts.js +1 -1
- package/dist/api/files.d.ts +4 -6
- package/dist/api/files.js +1 -1
- package/dist/api/history.d.ts +14 -0
- package/dist/api/history.js +2 -0
- package/dist/api/identity.js +1 -1
- package/dist/api/messaging.d.ts +7 -7
- package/dist/api/messaging.js +1 -1
- package/dist/api/profile.js +1 -1
- package/dist/api/types.d.ts +21 -69
- package/dist/book.js +1 -1
- package/dist/boot.js +1 -1
- package/dist/chunk-23BNCGF6.js +2 -0
- package/dist/{chunk-64C2NWXL.js → chunk-2TG2NHED.js} +1 -1
- package/dist/{chunk-HPPNU5YV.js → chunk-32DN6MBS.js} +1 -1
- package/dist/{chunk-T76BFV6S.js → chunk-4NP2YNWX.js} +1 -1
- package/dist/{chunk-7JZS2BAP.js → chunk-5DE7MMDG.js} +1 -1
- package/dist/{chunk-OWZIFNZN.js → chunk-7GBZLXV2.js} +1 -1
- package/dist/{chunk-2PVVBIA7.js → chunk-7M7H7ZAV.js} +1 -1
- package/dist/chunk-DRALQ2W5.js +2 -0
- package/dist/chunk-EPLWWBVB.js +2 -0
- package/dist/chunk-GZNPN3B5.js +4 -0
- package/dist/chunk-H7CVIQ7G.js +2 -0
- package/dist/{chunk-OA7XXAFG.js → chunk-HZCFYJAG.js} +1 -1
- package/dist/chunk-JOKNFUW3.js +4 -0
- package/dist/chunk-JTBQO6IT.js +2 -0
- package/dist/chunk-KIS5USR4.js +2 -0
- package/dist/chunk-OMUFZVAY.js +4 -0
- package/dist/chunk-P62PZ44T.js +2 -0
- package/dist/{chunk-3CDGP5EO.js → chunk-Q44JJZFN.js} +1 -1
- package/dist/chunk-S4JI2DB5.js +2 -0
- package/dist/{chunk-3KI5FM4I.js → chunk-SEZTXIKN.js} +1 -1
- package/dist/chunk-TXAIJEXA.js +171 -0
- package/dist/{chunk-CGAOZPMV.js → chunk-USG7J2P2.js} +1 -1
- package/dist/chunk-UVQY3IFO.js +2 -0
- package/dist/chunk-VIZVYPRQ.js +2 -0
- package/dist/chunk-WXCHUQ3J.js +2 -0
- package/dist/client/http.d.ts +7 -8
- package/dist/client/http.js +1 -1
- package/dist/client/select.js +1 -1
- package/dist/client.js +1 -1
- package/dist/cluster/control.js +1 -1
- package/dist/cluster/manifest.js +1 -1
- package/dist/connector.js +1 -1
- package/dist/events.d.ts +6 -12
- package/dist/events.js +1 -1
- package/dist/gc.js +1 -1
- package/dist/history.d.ts +195 -0
- package/dist/history.js +2 -0
- package/dist/http/api-routes.d.ts +5 -6
- package/dist/http/api-routes.js +1 -1
- package/dist/http/server.js +1 -1
- package/dist/identity/hierarchy.js +1 -1
- package/dist/identity/lease.js +1 -1
- package/dist/identity/lifecycle.js +1 -1
- package/dist/identity/model.d.ts +0 -1
- package/dist/identity/model.js +1 -1
- package/dist/identity/provision.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/messaging/send.d.ts +8 -2
- package/dist/messaging/send.js +1 -1
- package/dist/mufl/handlers.js +1 -1
- package/dist/mufl/tx.js +1 -1
- package/dist/mufl_code/{7962BB01B1D3E782A1F80B083A900AEC30BAC8F8CE79282B31821802B94A39B6.muflo → 351F16D444E6DAA252D4A8D829D17204360D9015FEF670ACE68FB4747BB3B14E.muflo} +0 -0
- package/dist/notify.d.ts +0 -1
- package/dist/notify.js +1 -1
- package/dist/render/adapt-to-json.d.ts +0 -5
- package/dist/render/adapt-to-json.js +1 -1
- package/dist/runtime/env.js +1 -1
- package/dist/state.js +1 -1
- package/dist/sweeps.js +1 -1
- package/dist/uploads.js +1 -1
- package/package.json +5 -3
- package/dist/api/conversations.d.ts +0 -48
- package/dist/api/conversations.js +0 -2
- package/dist/chunk-AQK45DI7.js +0 -2
- package/dist/chunk-CGXQP3Q4.js +0 -2
- package/dist/chunk-CIHGEBUR.js +0 -2
- package/dist/chunk-K7TLSZ3X.js +0 -2
- package/dist/chunk-LKFYUCN7.js +0 -2
- package/dist/chunk-MQ5AXTPT.js +0 -5
- package/dist/chunk-PQXV4GQ5.js +0 -2
- package/dist/chunk-R5ISAB5B.js +0 -2
- package/dist/chunk-TIBWO3T3.js +0 -2
- package/dist/chunk-TUWHVJ37.js +0 -6
- package/dist/chunk-V7PKYHV7.js +0 -2
- package/dist/chunk-W2BPK7VV.js +0 -2
- package/dist/chunk-XT75POTM.js +0 -2
- package/dist/chunk-XYU2DSWR.js +0 -2
- package/dist/inbox.d.ts +0 -38
- package/dist/inbox.js +0 -2
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import Database from 'better-sqlite3';
|
|
2
|
+
import type { Identity } from './identity/model.js';
|
|
3
|
+
export type HistoryDirection = 'in' | 'out';
|
|
4
|
+
export type HistoryEncryption = 'legacy' | 'e2e';
|
|
5
|
+
export type InboxState = 'pending_introduction' | 'unread' | 'read';
|
|
6
|
+
export type DeliveryState = 'sent' | 'delivered' | 'read' | null;
|
|
7
|
+
export type HistoryReply = {
|
|
8
|
+
wire_id: string;
|
|
9
|
+
sentence?: number;
|
|
10
|
+
} | null;
|
|
11
|
+
export interface MessageHostEvent {
|
|
12
|
+
kind: 'message';
|
|
13
|
+
wireId: string;
|
|
14
|
+
peerCid: string;
|
|
15
|
+
peerName: string;
|
|
16
|
+
direction: HistoryDirection;
|
|
17
|
+
inboxState?: 'pending_introduction' | 'unread';
|
|
18
|
+
body: string;
|
|
19
|
+
occurredAtMs: number;
|
|
20
|
+
replyToWireId?: string;
|
|
21
|
+
replyToSentence?: number;
|
|
22
|
+
encryption: HistoryEncryption;
|
|
23
|
+
}
|
|
24
|
+
export interface FileHostEvent {
|
|
25
|
+
kind: 'file';
|
|
26
|
+
wireId: string;
|
|
27
|
+
peerCid: string;
|
|
28
|
+
peerName: string;
|
|
29
|
+
direction: HistoryDirection;
|
|
30
|
+
inboxState?: 'pending_introduction' | 'unread';
|
|
31
|
+
filename: string;
|
|
32
|
+
mime: string;
|
|
33
|
+
bytes: Uint8Array;
|
|
34
|
+
occurredAtMs: number;
|
|
35
|
+
replyToWireId?: string;
|
|
36
|
+
replyToSentence?: number;
|
|
37
|
+
encryption: HistoryEncryption;
|
|
38
|
+
}
|
|
39
|
+
export type ApplicationHostEvent = MessageHostEvent | FileHostEvent;
|
|
40
|
+
export interface MonitoringHostEvent {
|
|
41
|
+
kind: 'monitoring_copy';
|
|
42
|
+
itemId: string;
|
|
43
|
+
sourceCid: string;
|
|
44
|
+
sourceName: string;
|
|
45
|
+
direction: HistoryDirection;
|
|
46
|
+
peerCid: string;
|
|
47
|
+
peerName: string;
|
|
48
|
+
body: string;
|
|
49
|
+
occurredAtMs: number;
|
|
50
|
+
}
|
|
51
|
+
export interface ControlHostEvent {
|
|
52
|
+
kind: 'control_request';
|
|
53
|
+
itemId: string;
|
|
54
|
+
senderCid: string;
|
|
55
|
+
senderName: string;
|
|
56
|
+
payload: string;
|
|
57
|
+
occurredAtMs: number;
|
|
58
|
+
}
|
|
59
|
+
export interface HistoryMessage {
|
|
60
|
+
seq: number;
|
|
61
|
+
msg_id: number;
|
|
62
|
+
wire_id: string;
|
|
63
|
+
from: {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
};
|
|
67
|
+
peer: {
|
|
68
|
+
id: string;
|
|
69
|
+
name: string;
|
|
70
|
+
};
|
|
71
|
+
direction: HistoryDirection;
|
|
72
|
+
text: string;
|
|
73
|
+
body: string;
|
|
74
|
+
occurred_at_ms: number;
|
|
75
|
+
date: string;
|
|
76
|
+
encryption: HistoryEncryption;
|
|
77
|
+
transport: 'legacy_box' | 'double_ratchet';
|
|
78
|
+
inbox_state: InboxState;
|
|
79
|
+
status: InboxState;
|
|
80
|
+
delivery_state: DeliveryState;
|
|
81
|
+
human_read_at_ms: number | null;
|
|
82
|
+
reply_to: HistoryReply;
|
|
83
|
+
}
|
|
84
|
+
export interface IncomingMessageMetadata {
|
|
85
|
+
seq: number;
|
|
86
|
+
msg_id: number;
|
|
87
|
+
wire_id: string;
|
|
88
|
+
from: {
|
|
89
|
+
id: string;
|
|
90
|
+
name: string;
|
|
91
|
+
};
|
|
92
|
+
occurred_at_ms: number;
|
|
93
|
+
date: string;
|
|
94
|
+
encryption: HistoryEncryption;
|
|
95
|
+
inbox_state: 'unread';
|
|
96
|
+
status: 'unread';
|
|
97
|
+
reply_to: HistoryReply;
|
|
98
|
+
}
|
|
99
|
+
export interface HistoryFile {
|
|
100
|
+
seq: number;
|
|
101
|
+
file_id: number;
|
|
102
|
+
wire_id: string;
|
|
103
|
+
from: {
|
|
104
|
+
id: string;
|
|
105
|
+
name: string;
|
|
106
|
+
};
|
|
107
|
+
peer: {
|
|
108
|
+
id: string;
|
|
109
|
+
name: string;
|
|
110
|
+
};
|
|
111
|
+
direction: HistoryDirection;
|
|
112
|
+
filename: string;
|
|
113
|
+
mime: string;
|
|
114
|
+
size: number;
|
|
115
|
+
byte_length: number;
|
|
116
|
+
sha256: string;
|
|
117
|
+
occurred_at_ms: number;
|
|
118
|
+
date: string;
|
|
119
|
+
encryption: HistoryEncryption;
|
|
120
|
+
inbox_state: InboxState;
|
|
121
|
+
status: InboxState;
|
|
122
|
+
delivery_state: DeliveryState;
|
|
123
|
+
human_read_at_ms: number | null;
|
|
124
|
+
reply_to: HistoryReply;
|
|
125
|
+
blob_path: string;
|
|
126
|
+
kind: 'file' | 'voice_message';
|
|
127
|
+
}
|
|
128
|
+
export interface HistoryQuery {
|
|
129
|
+
peer_cid?: string;
|
|
130
|
+
direction?: HistoryDirection;
|
|
131
|
+
before_seq?: number;
|
|
132
|
+
limit?: number;
|
|
133
|
+
}
|
|
134
|
+
export interface HistoryPage<T> {
|
|
135
|
+
items: T[];
|
|
136
|
+
next_cursor: number | null;
|
|
137
|
+
}
|
|
138
|
+
export interface HistorySummary {
|
|
139
|
+
total: number;
|
|
140
|
+
unread: number;
|
|
141
|
+
}
|
|
142
|
+
export interface HistoryHealth {
|
|
143
|
+
write_failures: number;
|
|
144
|
+
message_write_failures: number;
|
|
145
|
+
file_write_failures: number;
|
|
146
|
+
receipt_update_failures: number;
|
|
147
|
+
last_failure_at_ms: number | null;
|
|
148
|
+
}
|
|
149
|
+
export interface SecondaryQueueCounts {
|
|
150
|
+
pending_introductions: number;
|
|
151
|
+
monitoring_copies: number;
|
|
152
|
+
control_requests: number;
|
|
153
|
+
}
|
|
154
|
+
export declare const historyPath: (id: Pick<Identity, "dir">) => string;
|
|
155
|
+
export declare const blobRoot: (id: Pick<Identity, "dir">) => string;
|
|
156
|
+
export declare function historyHealth(id: Pick<Identity, 'dir'>): HistoryHealth;
|
|
157
|
+
export declare function noteHistoryFailure(id: Pick<Identity, 'dir'>, kind: 'message' | 'file' | 'receipt', wireId?: string, direction?: HistoryDirection): void;
|
|
158
|
+
export declare function consumeOutboundHistoryFailure(id: Pick<Identity, 'dir'>, wireId: string): boolean;
|
|
159
|
+
export declare function openHistory(id: Pick<Identity, 'dir'>): Database.Database;
|
|
160
|
+
export declare function closeHistory(id: Pick<Identity, 'dir'>): void;
|
|
161
|
+
export declare function ingestApplicationEvent(id: Pick<Identity, 'dir'>, event: ApplicationHostEvent): boolean;
|
|
162
|
+
export declare function ingestMonitoringEvent(id: Pick<Identity, 'dir'>, event: MonitoringHostEvent): boolean;
|
|
163
|
+
export declare function ingestControlEvent(id: Pick<Identity, 'dir'>, event: ControlHostEvent): boolean;
|
|
164
|
+
export declare function promotePendingIntroduction(id: Pick<Identity, 'dir'>, peerCid: string): number;
|
|
165
|
+
export declare function rejectPendingIntroduction(id: Pick<Identity, 'dir'>, peerCid: string): number;
|
|
166
|
+
export declare function secondaryQueueCounts(id: Pick<Identity, 'dir'>): SecondaryQueueCounts;
|
|
167
|
+
export declare function listIncomingMessages(id: Pick<Identity, 'dir'>): IncomingMessageMetadata[];
|
|
168
|
+
export declare function takeUnreadMessages(id: Pick<Identity, 'dir'>, input?: {
|
|
169
|
+
wire_ids?: string[];
|
|
170
|
+
limit?: number;
|
|
171
|
+
}): {
|
|
172
|
+
messages: HistoryMessage[];
|
|
173
|
+
remaining: number;
|
|
174
|
+
};
|
|
175
|
+
export declare function listIncomingFiles(id: Pick<Identity, 'dir'>): HistoryFile[];
|
|
176
|
+
export declare function takeUnreadFiles(id: Pick<Identity, 'dir'>, input?: {
|
|
177
|
+
wire_ids?: string[];
|
|
178
|
+
limit?: number;
|
|
179
|
+
}): {
|
|
180
|
+
files: HistoryFile[];
|
|
181
|
+
remaining: number;
|
|
182
|
+
};
|
|
183
|
+
export declare function listMessageHistory(id: Pick<Identity, 'dir'>, query?: HistoryQuery): HistoryPage<HistoryMessage>;
|
|
184
|
+
export declare function getMessageHistoryItem(id: Pick<Identity, 'dir'>, wireId: string): HistoryMessage | null;
|
|
185
|
+
export declare function getMessageHistorySummary(id: Pick<Identity, 'dir'>, input: {
|
|
186
|
+
peer_cid: string;
|
|
187
|
+
}): HistorySummary;
|
|
188
|
+
export declare function listFileHistory(id: Pick<Identity, 'dir'>, query?: HistoryQuery): HistoryPage<HistoryFile>;
|
|
189
|
+
export declare function getFileHistoryItem(id: Pick<Identity, 'dir'>, wireId: string): HistoryFile | null;
|
|
190
|
+
export declare function resolveStoredFile(id: Pick<Identity, 'dir'>, wireId: string): string | null;
|
|
191
|
+
export declare function updateDeliveryState(id: Pick<Identity, 'dir'>, peerCid: string, kind: 'delivered' | 'read', wireIds: string[]): void;
|
|
192
|
+
export declare function unreadCounts(id: Pick<Identity, 'dir'>): {
|
|
193
|
+
messages: number;
|
|
194
|
+
files: number;
|
|
195
|
+
};
|
package/dist/history.js
ADDED
|
@@ -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,l,m,n,o,p,q,r,s,t,u,v,w,x,y}from"./chunk-TXAIJEXA.js";export{b as blobRoot,g as closeHistory,e as consumeOutboundHistoryFailure,v as getFileHistoryItem,s as getMessageHistoryItem,t as getMessageHistorySummary,c as historyHealth,a as historyPath,h as ingestApplicationEvent,j as ingestControlEvent,i as ingestMonitoringEvent,u as listFileHistory,p as listIncomingFiles,n as listIncomingMessages,r as listMessageHistory,d as noteHistoryFailure,f as openHistory,k as promotePendingIntroduction,l as rejectPendingIntroduction,w as resolveStoredFile,m as secondaryQueueCounts,q as takeUnreadFiles,o as takeUnreadMessages,y as unreadCounts,x as updateDeliveryState};
|
|
@@ -40,12 +40,11 @@ export declare const API_OPERATIONS: {
|
|
|
40
40
|
sendFile: ApiHandler;
|
|
41
41
|
listIncomingMessages: ApiHandler;
|
|
42
42
|
getMessages: ApiHandler;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
setConversationPolicy: ApiHandler;
|
|
43
|
+
listHistory: ApiHandler;
|
|
44
|
+
getHistoryItem: ApiHandler;
|
|
45
|
+
getHistorySummary: ApiHandler;
|
|
46
|
+
listFiles: ApiHandler;
|
|
47
|
+
getFileInfo: ApiHandler;
|
|
49
48
|
listIncomingFiles: ApiHandler;
|
|
50
49
|
getFiles: ApiHandler;
|
|
51
50
|
saveFileFallbackNotice: ApiHandler;
|
package/dist/http/api-routes.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d}from"../chunk-
|
|
2
|
+
import{a,b,c,d}from"../chunk-DRALQ2W5.js";import"../chunk-KIS5USR4.js";import"../chunk-OMUFZVAY.js";import"../chunk-WXCHUQ3J.js";import"../chunk-P62PZ44T.js";import"../chunk-7GBZLXV2.js";import"../chunk-VXVW4KJU.js";import"../chunk-S4JI2DB5.js";import"../chunk-P55RJGZU.js";import"../chunk-2TG2NHED.js";import"../chunk-32DN6MBS.js";import"../chunk-UVQY3IFO.js";import"../chunk-JOKNFUW3.js";import"../chunk-DIRW7I4S.js";import"../chunk-65KGEJBX.js";import"../chunk-Q44JJZFN.js";import"../chunk-USG7J2P2.js";import"../chunk-7M7H7ZAV.js";import"../chunk-H7CVIQ7G.js";import"../chunk-YRPUM6JG.js";import"../chunk-GZNPN3B5.js";import"../chunk-5DE7MMDG.js";import"../chunk-EPLWWBVB.js";import"../chunk-4NP2YNWX.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";export{b as API_OPERATIONS,a as API_PREFIX,c as enterApiSession,d as serveApiOperation};
|
package/dist/http/server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as ye}from"../chunk-NBEWKZG4.js";import{d as $}from"../chunk-V64IUVSS.js";import{a as G}from"../chunk-37D5PCFY.js";import{a as ue,b as z}from"../chunk-PQXV4GQ5.js";import{a as ge,d as he}from"../chunk-CGXQP3Q4.js";import{b as me}from"../chunk-W2BPK7VV.js";import"../chunk-EHCBEY52.js";import"../chunk-TIBWO3T3.js";import"../chunk-XT75POTM.js";import"../chunk-R5ISAB5B.js";import"../chunk-AQK45DI7.js";import{e as le,f as pe,h as fe}from"../chunk-OWZIFNZN.js";import{b as ce}from"../chunk-VXVW4KJU.js";import"../chunk-V7PKYHV7.js";import"../chunk-64C2NWXL.js";import"../chunk-HPPNU5YV.js";import{b as re,c as ae}from"../chunk-K7TLSZ3X.js";import"../chunk-65KGEJBX.js";import{b as de}from"../chunk-3CDGP5EO.js";import"../chunk-CGAOZPMV.js";import"../chunk-2PVVBIA7.js";import{F as se,a as ne,b as U,o as oe,q as ie}from"../chunk-MQ5AXTPT.js";import"../chunk-YRPUM6JG.js";import"../chunk-TUWHVJ37.js";import"../chunk-DIRW7I4S.js";import{a as M,b as ee,c as w,e as L,f as A,g as te}from"../chunk-7JZS2BAP.js";import{c as v,o as Z,u as q}from"../chunk-CIHGEBUR.js";import{a as P,b as Q,c as H,d as W,e as N,g as X,h as b,i as l,m as I,p as Y}from"../chunk-T76BFV6S.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-Y3VPZJTG.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-WS6UFNKF.js";import{createServer as ke}from"node:http";import{randomUUID as Re}from"node:crypto";import*as D from"node:fs";ye();function Ne(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;let f=r;return f.jsonrpc==="2.0"&&f.method==="initialize"}var Oe=["brokerUrl","port","stateDir","gcIntervalMs","apiVisibility"];function we(r){return new Promise((f,u)=>{let O="";r.on("data",g=>O+=g),r.on("end",()=>{try{f(JSON.parse(O))}catch(g){u(g)}}),r.on("error",u)})}async function Ve(r={}){try{return await Ce(r)}catch(f){throw b?.failed(),l(`fatal startup error: ${f?.stack??f}`),f}}async function Ce(r){let f=r.handleSignals!==!1;if(process.env.OURS_TEST_STARTUP_FAIL==="1")throw new Error("forced startup failure (OURS_TEST_STARTUP_FAIL)");if(r.config){let t=Oe.filter(e=>r.config[e]!==Q[e]);if(t.length>0)throw new Error(`startDaemon(config) disagrees with the config resolved at module load (${t.join(", ")}). The engine reads its config when src/runtime/env.ts is imported, so a later override cannot move the state dir, port or broker \u2014 set OURS_* env or config.json before importing the SDK.`)}let u=r.mcp,O=u?.isInitializeRequest??Ne,g=null;if(typeof r.onIdentityNotify=="function"){let t=r.onIdentityNotify;g=(e,i)=>{t(e,i,M.get(e)?.sid??null)},ne(g)}l("booting wrapper\u2026");try{await me(),ue()}catch(t){throw g&&U(g),z(),t}l(`wrapper ready (identities=${v.size}), starting HTTP server\u2026`),b?.update("server");let p={},T=new Map,k=new Map,Se=3e4,J=t=>{let e=k.get(t);e?e.n++:k.set(t,{n:1,since:Date.now()})},B=t=>{let e=k.get(t);e&&--e.n<=0&&k.delete(t)},F=()=>{let t=0;for(let e of[...T.keys()]){if(e==="stdio")continue;let i=w.get(e)?.pid;if(i===void 0||i<=1||L(i))continue;let n=k.get(e);if(n&&n.n>0&&Date.now()-n.since<Se)continue;let o=T.get(e);T.delete(e),delete p[e],w.delete(e),k.delete(e),o?.close().catch(()=>{}),u?.onSessionClosed?.(e),t++,l(`session ${e.slice(0,8)}\u2026 reaped (client pid ${i} dead)`)}return t},V=setInterval(()=>{F(),ae(),fe()},6e4);V.unref?.();let _=1e3,ve=10*6e4,h=new Map,Ie=(t,e)=>{let i=Array.isArray(e)?e:[e];for(let n of i){let o=n;!o||typeof o!="object"||o.id===void 0||o.id===null||typeof o.method!="string"||h.set(`${t}:${String(o.id)}`,{method:o.method,at:Date.now()})}if(h.size>_){let n=Date.now()-ve;for(let[o,a]of h)if(a.at<n&&h.delete(o),h.size<=_)break;for(;h.size>_;){let o=h.keys().next();if(o.done)break;h.delete(o.value)}}},Te=(t,e)=>{try{let i=e instanceof Error?e.message:String(e),n=/No connection established for request ID:\s*(\S+)/.exec(i);if(!n)return;let o=n[1],a=h.get(`${t}:${o}`);h.delete(`${t}:${o}`),l(`UNDELIVERABLE RESPONSE session=${t.slice(0,8)}\u2026 request_id=${o} method=${a?.method??"unknown"} age_ms=${a?Date.now()-a.at:"unknown"} at=${new Date().toISOString()} \u2014 the answer was produced but its stream was already gone`)}catch{}},S=ke(async(t,e)=>{let i=new URL(t.url,`http://localhost:${N}`);if(t.method==="GET"&&i.pathname==="/state-dir"){e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({stateDir:H,version:P,compat:1}));return}if(t.method==="GET"&&(i.pathname==="/version"||i.pathname==="/info")){e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({name:"ours",version:P,compat:1,protocol:de,pid:process.pid,stateDir:H}));return}if(t.method==="GET"&&i.pathname==="/identities"){if(!I(t,e))return;e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({identities:[...v.values()].map(n=>({name:n.name,...n.temp?{temporary:!0,stale:!L(n.temp.owner.pid)}:{}}))}));return}if(t.method==="GET"&&i.pathname==="/unread"){if(!I(t,e))return;e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify(ie()));return}{let n=/^\/identities\/([^/]+)\/notifications$/.exec(i.pathname);if(t.method==="GET"&&n){if(!I(t,e))return;let o=decodeURIComponent(n[1]);if(Y(o)!==null){e.writeHead(400,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"invalid identity name"}));return}await oe(t,e,o,i.searchParams.get("since"),i.searchParams.get("kinds"));return}}if(t.method==="POST"&&i.pathname==="/files/upload"){if(!I(t,e))return;let n=t.headers["x-ours-lease-token"],o=typeof n=="string"&&n?A(n):void 0,a=o?v.get(o.identity):void 0;if(!a){e.writeHead(401,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"no identity bound to this session"}));return}let y=t.headers["content-length"],d=typeof y=="string"?Number(y):NaN,m=t.headers["x-ours-filename"];try{let s=await pe(a,t,{filename:typeof m=="string"?decodeURIComponent(m):"",mime:typeof t.headers["content-type"]=="string"?t.headers["content-type"]:"",declaredBytes:Number.isInteger(d)&&d>=0?d:null,cap:ce()});e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify(s))}catch(s){let R=s instanceof le?s.status:500;e.headersSent||(e.writeHead(R,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:s instanceof Error?s.message:String(s)})))}return}{let n=/^\/files\/([^/]+)$/.exec(i.pathname);if(t.method==="GET"&&n){if(!I(t,e))return;let o=decodeURIComponent(n[1]),a=t.headers["x-ours-lease-token"],y=typeof a=="string"&&a?A(a):void 0,d=y?v.get(y.identity):void 0;if(!d){e.writeHead(401,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"no identity bound to this session"}));return}let m=q(d,o);if(!m){e.writeHead(404,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"no such file for the bound identity (run get_files first, or it belongs to another identity)"}));return}try{let s=D.statSync(m);e.writeHead(200,{"Content-Type":"application/octet-stream","Content-Length":String(s.size)});let R=D.createReadStream(m);R.on("error",()=>{try{e.destroy()}catch{}}),R.pipe(e)}catch(s){e.writeHead(500,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:`failed to read file: ${String(s)}`}))}return}}if(i.pathname.startsWith(ge)){await he(t,e,i.pathname,we);return}if(i.pathname!=="/mcp"||!u){e.writeHead(404,{"Content-Type":"text/plain"}),e.end("Not found");return}if(I(t,e))try{if(t.method==="POST"){let n=await we(t),o=t.headers["mcp-session-id"],a=t.headers["x-ours-lease-token"],y=t.headers["x-ours-client-pid"],d=y?parseInt(y,10):void 0,m={token:a,pid:Number.isInteger(d)?d:void 0};if(o&&p[o]){w.set(o,m),Ie(o,n),J(o),$(e);try{await p[o].handleRequest(t,e,n)}finally{B(o)}}else if(!o&&O(n)){F();let s=u.createTransport({sessionIdGenerator:()=>Re(),onsessioninitialized:c=>{p[c]=s,w.set(c,m),T.set(c,E),u.onSessionInitialized?.(c,E),l(`session ${c.slice(0,8)}\u2026 initialized`)}}),R={sessionId:()=>s.sessionId??"pending",leaseToken:()=>w.get(s.sessionId??"pending")?.token,clientPid:()=>w.get(s.sessionId??"pending")?.pid},E=u.createServer(R);E.server.onerror=c=>Te(s.sessionId??"pending",c),s.onclose=()=>{let c=s.sessionId;c&&(delete p[c],T.delete(c),w.delete(c),u.onSessionClosed?.(c),l(`session ${c.slice(0,8)}\u2026 closed (lease kept)`))},await E.connect(s),$(e),await s.handleRequest(t,e,n)}else e.writeHead(400,{"Content-Type":"application/json"}),e.end(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Bad Request: No valid session ID"},id:null}))}else if(t.method==="GET"){let n=t.headers["mcp-session-id"];if(!n||!p[n]){e.writeHead(400,{"Content-Type":"text/plain"}),e.end("Invalid or missing session ID");return}J(n),$(e);try{await p[n].handleRequest(t,e)}finally{B(n)}}else if(t.method==="DELETE"){let n=t.headers["mcp-session-id"];if(!n||!p[n]){e.writeHead(400,{"Content-Type":"text/plain"}),e.end("Invalid or missing session ID");return}let o=w.get(n)?.token??t.headers["x-ours-lease-token"];if(o){for(let[a,y]of[...M]){if(y.token!==o)continue;M.delete(a);let d=v.get(a);d?.temp&&d.temp.owner.tokenHash===Z(o)&&!d.temp.closing&&re(d,"owning session released its lease").catch(m=>l(`[${a}] close on lease release failed:`,String(m)))}ee.delete(o),te(),l(`lease released by token \u2026${o.slice(-6)}`)}await p[n].handleRequest(t,e)}else e.writeHead(405,{"Content-Type":"text/plain"}),e.end("Method not allowed")}catch(n){l("HTTP handler error:",String(n)),e.headersSent||(e.writeHead(500,{"Content-Type":"application/json"}),e.end(JSON.stringify({jsonrpc:"2.0",error:{code:-32603,message:"Internal server error"},id:null})))}});S.requestTimeout=0;let K=!1,x=async()=>{if(!K){K=!0,clearInterval(V),z(),g&&U(g);for(let t of Object.keys(p)){try{await p[t].close()}catch{}delete p[t]}T.clear();for(let t of v.values())try{se(t)}catch(e){l(`[${t.name}] shutdown save failed:`,String(e))}S.closeAllConnections?.()}};try{await new Promise((t,e)=>{let i=n=>e(n);S.once("error",i),S.listen(N,"127.0.0.1",()=>{S.off("error",i),b?.ready(),l(`MCP server v${r.version??P} ready (transport=http, port=${N}, visibility=${X}, identities=${v.size}, state=${H}, broker=${W})`),t()})})}catch(t){throw await x(),t}let C=async()=>{l("shutting down\u2026"),await x(),S.close(),await r.onShutdown?.(),process.exit(0)};f&&(process.on("SIGINT",C),process.on("SIGTERM",C));let j=S.address();return{port:typeof j=="object"&&j!==null?j.port:N,close:async()=>{f&&(process.off("SIGINT",C),process.off("SIGTERM",C)),await x(),await new Promise(t=>S.close(()=>t()))}}}export{Ve as startDaemon};
|
|
2
|
+
import{a as ye}from"../chunk-NBEWKZG4.js";import{d as $}from"../chunk-V64IUVSS.js";import{a as G}from"../chunk-37D5PCFY.js";import{a as ue,b as z}from"../chunk-23BNCGF6.js";import{a as ge,d as he}from"../chunk-DRALQ2W5.js";import{b as me}from"../chunk-VIZVYPRQ.js";import"../chunk-EHCBEY52.js";import"../chunk-KIS5USR4.js";import"../chunk-OMUFZVAY.js";import"../chunk-WXCHUQ3J.js";import"../chunk-P62PZ44T.js";import{e as le,f as pe,h as fe}from"../chunk-7GBZLXV2.js";import{b as ce}from"../chunk-VXVW4KJU.js";import"../chunk-S4JI2DB5.js";import"../chunk-P55RJGZU.js";import"../chunk-2TG2NHED.js";import"../chunk-32DN6MBS.js";import{b as re,c as ae}from"../chunk-UVQY3IFO.js";import"../chunk-JOKNFUW3.js";import"../chunk-DIRW7I4S.js";import"../chunk-65KGEJBX.js";import{b as de}from"../chunk-Q44JJZFN.js";import"../chunk-USG7J2P2.js";import"../chunk-7M7H7ZAV.js";import{o as se}from"../chunk-H7CVIQ7G.js";import"../chunk-YRPUM6JG.js";import{a as ne,b as U,n as oe,p as ie}from"../chunk-GZNPN3B5.js";import{a as M,b as ee,c as w,e as L,f as A,g as te}from"../chunk-5DE7MMDG.js";import{c as v,n as Z,t as q}from"../chunk-EPLWWBVB.js";import{a as P,b as Q,c as H,d as W,e as N,g as X,h as b,i as l,m as I,p as Y}from"../chunk-4NP2YNWX.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";import{createServer as ke}from"node:http";import{randomUUID as Re}from"node:crypto";import*as D from"node:fs";ye();function Ne(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;let f=r;return f.jsonrpc==="2.0"&&f.method==="initialize"}var Oe=["brokerUrl","port","stateDir","gcIntervalMs","apiVisibility"];function we(r){return new Promise((f,u)=>{let O="";r.on("data",g=>O+=g),r.on("end",()=>{try{f(JSON.parse(O))}catch(g){u(g)}}),r.on("error",u)})}async function Ve(r={}){try{return await Ce(r)}catch(f){throw b?.failed(),l(`fatal startup error: ${f?.stack??f}`),f}}async function Ce(r){let f=r.handleSignals!==!1;if(process.env.OURS_TEST_STARTUP_FAIL==="1")throw new Error("forced startup failure (OURS_TEST_STARTUP_FAIL)");if(r.config){let t=Oe.filter(e=>r.config[e]!==Q[e]);if(t.length>0)throw new Error(`startDaemon(config) disagrees with the config resolved at module load (${t.join(", ")}). The engine reads its config when src/runtime/env.ts is imported, so a later override cannot move the state dir, port or broker \u2014 set OURS_* env or config.json before importing the SDK.`)}let u=r.mcp,O=u?.isInitializeRequest??Ne,g=null;if(typeof r.onIdentityNotify=="function"){let t=r.onIdentityNotify;g=(e,i)=>{t(e,i,M.get(e)?.sid??null)},ne(g)}l("booting wrapper\u2026");try{await me(),ue()}catch(t){throw g&&U(g),z(),t}l(`wrapper ready (identities=${v.size}), starting HTTP server\u2026`),b?.update("server");let p={},T=new Map,k=new Map,Se=3e4,J=t=>{let e=k.get(t);e?e.n++:k.set(t,{n:1,since:Date.now()})},B=t=>{let e=k.get(t);e&&--e.n<=0&&k.delete(t)},F=()=>{let t=0;for(let e of[...T.keys()]){if(e==="stdio")continue;let i=w.get(e)?.pid;if(i===void 0||i<=1||L(i))continue;let n=k.get(e);if(n&&n.n>0&&Date.now()-n.since<Se)continue;let o=T.get(e);T.delete(e),delete p[e],w.delete(e),k.delete(e),o?.close().catch(()=>{}),u?.onSessionClosed?.(e),t++,l(`session ${e.slice(0,8)}\u2026 reaped (client pid ${i} dead)`)}return t},V=setInterval(()=>{F(),ae(),fe()},6e4);V.unref?.();let _=1e3,ve=10*6e4,h=new Map,Ie=(t,e)=>{let i=Array.isArray(e)?e:[e];for(let n of i){let o=n;!o||typeof o!="object"||o.id===void 0||o.id===null||typeof o.method!="string"||h.set(`${t}:${String(o.id)}`,{method:o.method,at:Date.now()})}if(h.size>_){let n=Date.now()-ve;for(let[o,a]of h)if(a.at<n&&h.delete(o),h.size<=_)break;for(;h.size>_;){let o=h.keys().next();if(o.done)break;h.delete(o.value)}}},Te=(t,e)=>{try{let i=e instanceof Error?e.message:String(e),n=/No connection established for request ID:\s*(\S+)/.exec(i);if(!n)return;let o=n[1],a=h.get(`${t}:${o}`);h.delete(`${t}:${o}`),l(`UNDELIVERABLE RESPONSE session=${t.slice(0,8)}\u2026 request_id=${o} method=${a?.method??"unknown"} age_ms=${a?Date.now()-a.at:"unknown"} at=${new Date().toISOString()} \u2014 the answer was produced but its stream was already gone`)}catch{}},S=ke(async(t,e)=>{let i=new URL(t.url,`http://localhost:${N}`);if(t.method==="GET"&&i.pathname==="/state-dir"){e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({stateDir:H,version:P,compat:1}));return}if(t.method==="GET"&&(i.pathname==="/version"||i.pathname==="/info")){e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({name:"ours",version:P,compat:1,protocol:de,pid:process.pid,stateDir:H}));return}if(t.method==="GET"&&i.pathname==="/identities"){if(!I(t,e))return;e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify({identities:[...v.values()].map(n=>({name:n.name,...n.temp?{temporary:!0,stale:!L(n.temp.owner.pid)}:{}}))}));return}if(t.method==="GET"&&i.pathname==="/unread"){if(!I(t,e))return;e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify(ie()));return}{let n=/^\/identities\/([^/]+)\/notifications$/.exec(i.pathname);if(t.method==="GET"&&n){if(!I(t,e))return;let o=decodeURIComponent(n[1]);if(Y(o)!==null){e.writeHead(400,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"invalid identity name"}));return}await oe(t,e,o,i.searchParams.get("since"),i.searchParams.get("kinds"));return}}if(t.method==="POST"&&i.pathname==="/files/upload"){if(!I(t,e))return;let n=t.headers["x-ours-lease-token"],o=typeof n=="string"&&n?A(n):void 0,a=o?v.get(o.identity):void 0;if(!a){e.writeHead(401,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"no identity bound to this session"}));return}let y=t.headers["content-length"],d=typeof y=="string"?Number(y):NaN,m=t.headers["x-ours-filename"];try{let s=await pe(a,t,{filename:typeof m=="string"?decodeURIComponent(m):"",mime:typeof t.headers["content-type"]=="string"?t.headers["content-type"]:"",declaredBytes:Number.isInteger(d)&&d>=0?d:null,cap:ce()});e.writeHead(200,{"Content-Type":"application/json"}),e.end(JSON.stringify(s))}catch(s){let R=s instanceof le?s.status:500;e.headersSent||(e.writeHead(R,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:s instanceof Error?s.message:String(s)})))}return}{let n=/^\/files\/([^/]+)$/.exec(i.pathname);if(t.method==="GET"&&n){if(!I(t,e))return;let o=decodeURIComponent(n[1]),a=t.headers["x-ours-lease-token"],y=typeof a=="string"&&a?A(a):void 0,d=y?v.get(y.identity):void 0;if(!d){e.writeHead(401,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"no identity bound to this session"}));return}let m=q(d,o);if(!m){e.writeHead(404,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:"no such file for the bound identity (run get_files first, or it belongs to another identity)"}));return}try{let s=D.statSync(m);e.writeHead(200,{"Content-Type":"application/octet-stream","Content-Length":String(s.size)});let R=D.createReadStream(m);R.on("error",()=>{try{e.destroy()}catch{}}),R.pipe(e)}catch(s){e.writeHead(500,{"Content-Type":"application/json"}),e.end(JSON.stringify({error:`failed to read file: ${String(s)}`}))}return}}if(i.pathname.startsWith(ge)){await he(t,e,i.pathname,we);return}if(i.pathname!=="/mcp"||!u){e.writeHead(404,{"Content-Type":"text/plain"}),e.end("Not found");return}if(I(t,e))try{if(t.method==="POST"){let n=await we(t),o=t.headers["mcp-session-id"],a=t.headers["x-ours-lease-token"],y=t.headers["x-ours-client-pid"],d=y?parseInt(y,10):void 0,m={token:a,pid:Number.isInteger(d)?d:void 0};if(o&&p[o]){w.set(o,m),Ie(o,n),J(o),$(e);try{await p[o].handleRequest(t,e,n)}finally{B(o)}}else if(!o&&O(n)){F();let s=u.createTransport({sessionIdGenerator:()=>Re(),onsessioninitialized:c=>{p[c]=s,w.set(c,m),T.set(c,E),u.onSessionInitialized?.(c,E),l(`session ${c.slice(0,8)}\u2026 initialized`)}}),R={sessionId:()=>s.sessionId??"pending",leaseToken:()=>w.get(s.sessionId??"pending")?.token,clientPid:()=>w.get(s.sessionId??"pending")?.pid},E=u.createServer(R);E.server.onerror=c=>Te(s.sessionId??"pending",c),s.onclose=()=>{let c=s.sessionId;c&&(delete p[c],T.delete(c),w.delete(c),u.onSessionClosed?.(c),l(`session ${c.slice(0,8)}\u2026 closed (lease kept)`))},await E.connect(s),$(e),await s.handleRequest(t,e,n)}else e.writeHead(400,{"Content-Type":"application/json"}),e.end(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Bad Request: No valid session ID"},id:null}))}else if(t.method==="GET"){let n=t.headers["mcp-session-id"];if(!n||!p[n]){e.writeHead(400,{"Content-Type":"text/plain"}),e.end("Invalid or missing session ID");return}J(n),$(e);try{await p[n].handleRequest(t,e)}finally{B(n)}}else if(t.method==="DELETE"){let n=t.headers["mcp-session-id"];if(!n||!p[n]){e.writeHead(400,{"Content-Type":"text/plain"}),e.end("Invalid or missing session ID");return}let o=w.get(n)?.token??t.headers["x-ours-lease-token"];if(o){for(let[a,y]of[...M]){if(y.token!==o)continue;M.delete(a);let d=v.get(a);d?.temp&&d.temp.owner.tokenHash===Z(o)&&!d.temp.closing&&re(d,"owning session released its lease").catch(m=>l(`[${a}] close on lease release failed:`,String(m)))}ee.delete(o),te(),l(`lease released by token \u2026${o.slice(-6)}`)}await p[n].handleRequest(t,e)}else e.writeHead(405,{"Content-Type":"text/plain"}),e.end("Method not allowed")}catch(n){l("HTTP handler error:",String(n)),e.headersSent||(e.writeHead(500,{"Content-Type":"application/json"}),e.end(JSON.stringify({jsonrpc:"2.0",error:{code:-32603,message:"Internal server error"},id:null})))}});S.requestTimeout=0;let K=!1,x=async()=>{if(!K){K=!0,clearInterval(V),z(),g&&U(g);for(let t of Object.keys(p)){try{await p[t].close()}catch{}delete p[t]}T.clear();for(let t of v.values())try{se(t)}catch(e){l(`[${t.name}] shutdown save failed:`,String(e))}S.closeAllConnections?.()}};try{await new Promise((t,e)=>{let i=n=>e(n);S.once("error",i),S.listen(N,"127.0.0.1",()=>{S.off("error",i),b?.ready(),l(`MCP server v${r.version??P} ready (transport=http, port=${N}, visibility=${X}, identities=${v.size}, state=${H}, broker=${W})`),t()})})}catch(t){throw await x(),t}let C=async()=>{l("shutting down\u2026"),await x(),S.close(),await r.onShutdown?.(),process.exit(0)};f&&(process.on("SIGINT",C),process.on("SIGTERM",C));let j=S.address();return{port:typeof j=="object"&&j!==null?j.port:N,close:async()=>{f&&(process.off("SIGINT",C),process.off("SIGTERM",C)),await x(),await new Promise(t=>S.close(()=>t()))}}}export{Ve as startDaemon};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d,e,f,g}from"../chunk-
|
|
2
|
+
import{a,b,c,d,e,f,g}from"../chunk-7M7H7ZAV.js";import"../chunk-H7CVIQ7G.js";import"../chunk-YRPUM6JG.js";import"../chunk-GZNPN3B5.js";import"../chunk-5DE7MMDG.js";import"../chunk-EPLWWBVB.js";import"../chunk-4NP2YNWX.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";export{d as clearRootMarker,f as delegateRole,e as describeIdentity,g as establishRoot,c as readRootMarker,b as rootName,a as setRootName};
|
package/dist/identity/lease.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d,e,f,g,h,i}from"../chunk-
|
|
2
|
+
import{a,b,c,d,e,f,g,h,i}from"../chunk-5DE7MMDG.js";import"../chunk-EPLWWBVB.js";import"../chunk-4NP2YNWX.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-WS6UFNKF.js";export{i as bindSession,f as leaseByToken,a as leases,d as outboundRemovalInFlight,g as persistBindings,e as pidAlive,h as resolveBound,c as sessionHeaders,b as tombstones};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d}from"../chunk-
|
|
2
|
+
import{a,b,c,d}from"../chunk-UVQY3IFO.js";import"../chunk-JOKNFUW3.js";import"../chunk-DIRW7I4S.js";import"../chunk-7M7H7ZAV.js";import"../chunk-H7CVIQ7G.js";import"../chunk-YRPUM6JG.js";import"../chunk-GZNPN3B5.js";import"../chunk-5DE7MMDG.js";import"../chunk-EPLWWBVB.js";import"../chunk-4NP2YNWX.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";export{b as closeTemporaryIdentity,a as deleteIdentityCompletely,d as sweepOrphanTempDirs,c as sweepStaleTempIdentities};
|
package/dist/identity/model.d.ts
CHANGED
|
@@ -42,7 +42,6 @@ export declare const keyPath: (dir: string) => string;
|
|
|
42
42
|
export declare const dataPath: (dir: string) => string;
|
|
43
43
|
export declare const notifyLogPath: (dir: string) => string;
|
|
44
44
|
export declare const unreadPath: (dir: string) => string;
|
|
45
|
-
export declare const filesDirFor: (id: Identity) => string;
|
|
46
45
|
export declare const tempMetaPath: (dir: string) => string;
|
|
47
46
|
export declare const hashLeaseToken: (token: string) => string;
|
|
48
47
|
export declare function writeTempMetaFile(dir: string, meta: {
|
package/dist/identity/model.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q,q as r,r as s,s as t,t as u,u as v
|
|
2
|
+
import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q,q as r,r as s,s as t,t as u,u as v}from"../chunk-EPLWWBVB.js";import"../chunk-4NP2YNWX.js";import"../chunk-ZHH3PWEW.js";import{a}from"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-WS6UFNKF.js";export{a as FILE_SELECTION_CAP,k as dataPath,u as findIdentityFile,o as hashLeaseToken,d as identities,i as identityDir,t as isSelectableWireId,s as isWireId,j as keyPath,v as listPersistedNames,l as notifyLogPath,q as readTempMetaFile,e as registrar,f as registrarAdBlob,g as setRegistrar,h as setRegistrarAdBlob,c as setWrapper,n as tempMetaPath,r as tightenIdentityPerms,m as unreadPath,b as wrapper,p as writeTempMetaFile};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{
|
|
2
|
+
import{i as a,j as b,k as c,l as d}from"../chunk-H7CVIQ7G.js";import"../chunk-YRPUM6JG.js";import"../chunk-GZNPN3B5.js";import"../chunk-5DE7MMDG.js";import"../chunk-EPLWWBVB.js";import"../chunk-4NP2YNWX.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";export{a as createPacket,c as provisionIdentity,b as reservedNames,d as restoreIdentity};
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export * from './client/http.js';
|
|
|
3
3
|
export * from './client/select.js';
|
|
4
4
|
export * from './version-advisory.js';
|
|
5
5
|
export { FILE_SELECTION_CAP } from './constants.js';
|
|
6
|
+
export type { HistoryFile, HistoryMessage, HistoryPage, HistoryQuery, HistorySummary, } from './history.js';
|
|
6
7
|
export type { MessageReceivedRecord, MessengerNotificationEvent, NotificationEvent, ReceiptKind, ReceiptReceivedRecord, SyncRequiredRecord, UnknownNotificationEvent, } from './events.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as
|
|
2
|
+
import{a as U,b,c as z,d as B,e as D,f as G,g as J,h as V}from"./chunk-SEZTXIKN.js";import{a as T}from"./chunk-HZCFYJAG.js";import{a as W}from"./chunk-5EWCIQH6.js";import{A as I,B as L,C as P,D as _,E as h,F as k,G as l,H as q,I as w,J as A,K,L as O,M as Q,a as o,b as r,c as t,d as i,e as s,f as n,g as c,h as p,i as y,j as f,k as m,l as R,m as a,n as d,o as x,p as v,q as E,r as H,s as g,t as N,u,v as M,w as S,x as j,y as C,z as F}from"./chunk-65KGEJBX.js";import{a as e}from"./chunk-Y3VPZJTG.js";import"./chunk-JTBQO6IT.js";import"./chunk-WS6UFNKF.js";export{B as DAEMON_TOKEN_FILE,z as DEFAULT_DAEMON_PORT,U as DaemonSelectionError,b as DaemonUnavailableError,e as FILE_SELECTION_CAP,T as OursClient,o as OursError,J as assertDaemonStateDir,V as attachOursClient,G as describeDaemonConfig,t as errBindingReassigned,N as errBoundElsewhere,i as errBoundIdentityGone,K as errDuplicateId,k as errFileTooLarge,P as errFileUnreadable,M as errIdentityClosedWithError,j as errIdentityPartiallyRemoved,w as errInvalidSelection,A as errMalformedId,n as errNameTaken,c as errNoLeaseHeaders,v as errNoLeaseToken,F as errNoPolicyArgs,q as errNoRoot,x as errNoSuchIdentity,r as errNotBound,f as errNotBoundNoName,m as errNotTemporary,d as errPathNotAbsolute,C as errPublicInviteNamed,p as errRandomNameExhausted,y as errRootExists,S as errRootHasRoles,l as errSaveFileFallback,I as errSendFileArgs,L as errSendFileFilenameRequired,_ as errSendFileUploadArgs,a as errTempClosedWithError,s as errTempClosingBound,E as errTempClosingChoose,R as errTempOwnedElsewhereClose,u as errTempOwnedElsewhereRemove,H as errTempOwnedLive,g as errTempStale,Q as errTool,O as errUnknownOrStaleId,h as errUploadNotFound,W as formatVersionAdvisory,D as resolveDaemonConfig};
|
package/dist/messaging/send.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import type { AdaptValue } from '@adapt-toolkit/sdk/backend';
|
|
2
2
|
import { type Identity } from '../identity/model.js';
|
|
3
3
|
export declare function findSibling(id: Identity, contact: string): Identity | null;
|
|
4
|
-
export declare function sendViaSibling(id: Identity, target: Identity, text: string): Promise<
|
|
5
|
-
|
|
4
|
+
export declare function sendViaSibling(id: Identity, target: Identity, text: string): Promise<{
|
|
5
|
+
text: string;
|
|
6
|
+
wireId: string;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function sendViaLocalBook(id: Identity, contact: string, text: string): Promise<{
|
|
9
|
+
text: string;
|
|
10
|
+
wireId: string;
|
|
11
|
+
}>;
|
|
6
12
|
export type SendVerdict = {
|
|
7
13
|
kind: 'refused';
|
|
8
14
|
wireId: string;
|
package/dist/messaging/send.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d}from"../chunk-
|
|
2
|
+
import{a,b,c,d}from"../chunk-S4JI2DB5.js";import"../chunk-7M7H7ZAV.js";import"../chunk-H7CVIQ7G.js";import"../chunk-YRPUM6JG.js";import"../chunk-GZNPN3B5.js";import"../chunk-5DE7MMDG.js";import"../chunk-EPLWWBVB.js";import"../chunk-4NP2YNWX.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";export{a as findSibling,d as parseSendVerdict,c as sendViaLocalBook,b as sendViaSibling};
|
package/dist/mufl/handlers.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{
|
|
2
|
+
import{h as a}from"../chunk-H7CVIQ7G.js";import"../chunk-YRPUM6JG.js";import"../chunk-GZNPN3B5.js";import"../chunk-5DE7MMDG.js";import"../chunk-EPLWWBVB.js";import"../chunk-4NP2YNWX.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";export{a as wireHandlers};
|
package/dist/mufl/tx.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{
|
|
2
|
+
import{q as a,r as b,s as c,t as d,u as e,v as f}from"../chunk-H7CVIQ7G.js";import"../chunk-YRPUM6JG.js";import"../chunk-GZNPN3B5.js";import"../chunk-5DE7MMDG.js";import"../chunk-EPLWWBVB.js";import"../chunk-4NP2YNWX.js";import"../chunk-ZHH3PWEW.js";import"../chunk-Y3VPZJTG.js";import"../chunk-TXAIJEXA.js";import"../chunk-JTBQO6IT.js";import"../chunk-WS6UFNKF.js";export{e as enqueueMutation,f as mutatingTx,c as readonlyTx,d as withLock,a as withScope,b as withScopeAsync};
|
|
Binary file
|
package/dist/notify.d.ts
CHANGED
|
@@ -15,7 +15,6 @@ export declare function notifyEventMatches(event: Record<string, unknown>, keep:
|
|
|
15
15
|
export declare function fireNotifyWaiters(name: string): void;
|
|
16
16
|
export declare function waitForNotify(name: string, ms: number): Promise<void>;
|
|
17
17
|
export declare function appendNotifyLog(id: Identity, event: Record<string, unknown>): void;
|
|
18
|
-
export declare function readE2eWireIds(id: Identity): Set<string>;
|
|
19
18
|
export declare function binHexField(av: AdaptValue, field: string): string;
|
|
20
19
|
export declare function notifyLogSize(logPath: string): number;
|
|
21
20
|
export declare function readNotifyRange(logPath: string, from: number, to: number): {
|
package/dist/notify.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
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,l,m,n,o,p
|
|
2
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"./chunk-GZNPN3B5.js";import"./chunk-EPLWWBVB.js";import"./chunk-4NP2YNWX.js";import"./chunk-ZHH3PWEW.js";import"./chunk-Y3VPZJTG.js";import"./chunk-TXAIJEXA.js";import"./chunk-JTBQO6IT.js";import"./chunk-WS6UFNKF.js";export{e as NOTIFY_KIND_SETS,j as appendNotifyLog,k as binHexField,b as clearNotifyHook,c as fireNotify,h as fireNotifyWaiters,g as notifyEventMatches,d as notifyHooks,l as notifyLogSize,f as parseNotifyKinds,m as readNotifyRange,o as refreshUnread,n as serveNotifications,a as setNotifyHook,p as unreadSummary,i as waitForNotify};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { AdaptValue } from '@adapt-toolkit/sdk/backend';
|
|
2
|
-
import { type Identity } from '../identity/model.js';
|
|
3
2
|
import { type StructuredVoiceOutcome } from '../transcribe.js';
|
|
4
3
|
export declare function renderContacts(v: AdaptValue): Array<{
|
|
5
4
|
name: string;
|
|
@@ -62,10 +61,6 @@ export type ReceivedFileMeta = {
|
|
|
62
61
|
transcription?: StructuredVoiceOutcome;
|
|
63
62
|
sender: string;
|
|
64
63
|
};
|
|
65
|
-
export declare function writeIncomingFiles(id: Identity, v: AdaptValue): Promise<{
|
|
66
|
-
text: string;
|
|
67
|
-
files: ReceivedFileMeta[];
|
|
68
|
-
}>;
|
|
69
64
|
export declare function renderPending(v: AdaptValue): Array<{
|
|
70
65
|
container_id: string;
|
|
71
66
|
name: string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
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
|
|
2
|
+
import{a,b,c,d,e,f,g,h,i,j,k}from"../chunk-JOKNFUW3.js";import"../chunk-DIRW7I4S.js";export{k as adaptValueToJson,j as decodeWireBin,i as encodeWireBin,h as fmtContactRoot,g as renderContactRoots,a as renderContacts,d as renderFileMetadata,e as renderFiles,b as renderImportRenames,c as renderInbox,f as renderPending};
|
package/dist/runtime/env.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
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,l,m,n,o,p}from"../chunk-
|
|
2
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}from"../chunk-4NP2YNWX.js";import"../chunk-ZHH3PWEW.js";import"../chunk-WS6UFNKF.js";export{j as API_TOKEN,g as API_VISIBILITY,o as BOOK_DIR_NAME,d as BROKER_URL,b as CONFIG,f as GC_INTERVAL_MS,n as NAME_RE,e as PORT,c as STATE_DIR,a as VERSION,l as authOk,i as log,m as requireAuth,h as startupProgress,k as tokenFromReq,p as validateName};
|
package/dist/state.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{
|
|
2
|
+
import{m as a,n as b,o as c,p as d}from"./chunk-H7CVIQ7G.js";import"./chunk-YRPUM6JG.js";import"./chunk-GZNPN3B5.js";import"./chunk-5DE7MMDG.js";import"./chunk-EPLWWBVB.js";import"./chunk-4NP2YNWX.js";import"./chunk-ZHH3PWEW.js";import"./chunk-Y3VPZJTG.js";import"./chunk-TXAIJEXA.js";import"./chunk-JTBQO6IT.js";import"./chunk-WS6UFNKF.js";export{a as ensureRegistrar,b as hasSavedState,c as saveState,d as saveStateFailClosed};
|
package/dist/sweeps.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{
|
|
2
|
+
import{a,b,c,d,e,f,g}from"./chunk-H7CVIQ7G.js";import"./chunk-YRPUM6JG.js";import"./chunk-GZNPN3B5.js";import"./chunk-5DE7MMDG.js";import"./chunk-EPLWWBVB.js";import"./chunk-4NP2YNWX.js";import"./chunk-ZHH3PWEW.js";import"./chunk-Y3VPZJTG.js";import"./chunk-TXAIJEXA.js";import"./chunk-JTBQO6IT.js";import"./chunk-WS6UFNKF.js";export{e as capabilityReconcileSweep,d as contactRestoreSweep,g as e2eRecoverySweep,c as flushDeferredFor,b as renderDeferredQueues,a as renderDegraded,f as scheduleCapabilityReconcile};
|
package/dist/uploads.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d,e,f,g,h}from"./chunk-
|
|
2
|
+
import{a,b,c,d,e,f,g,h}from"./chunk-7GBZLXV2.js";import"./chunk-EPLWWBVB.js";import"./chunk-4NP2YNWX.js";import"./chunk-ZHH3PWEW.js";import"./chunk-Y3VPZJTG.js";import"./chunk-TXAIJEXA.js";import"./chunk-WS6UFNKF.js";export{b as UPLOAD_TTL_MS,e as UploadRefused,g as consumeStagedUpload,c as isUploadId,d as sanitizeUploadFilename,f as stageUpload,h as sweepStaleUploads,a as uploadsDirFor};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ours.network/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"types": "./dist/index.d.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "FSL-1.1-Apache-2.0",
|
|
@@ -39,15 +39,17 @@
|
|
|
39
39
|
"pretest": "bash scripts/compile-mufl.sh && node test/cli-packed-artifact.test.mjs",
|
|
40
40
|
"test:cli": "node build.mjs && npm run build --workspace @ours.network/cli && node test/cli-operations.test.mjs && node test/cli-lifecycle.test.mjs && node test/cli-service-instance.test.mjs && node test/cli-service-launchd.test.mjs && node test/cli-command.test.mjs && node test/cli-help.test.mjs",
|
|
41
41
|
"//test": "test/ux-strings.test.mjs is DELIBERATELY NOT CHAINED HERE: it is red by design until the split completes (687 of 1205 strings still missing — the test prints that number itself) and would make CI permanently red. The missing strings are MCP tool copy and CLI copy that belongs in ours-mcp; the gate only goes green in PR 2, with OURS_MCP_SPLIT pointing at the refactored ours-mcp. Please do not 'helpfully' add it before then.",
|
|
42
|
-
"test": "node build.mjs && bash scripts/test-receipts-mufl.sh && bash scripts/test-notifications-mufl.sh && bash scripts/test-contact-uniqueness-mufl.sh && bash scripts/test-temp-remove-me-mufl.sh && node test/state-root-singleton.test.mjs && node test/bump-version.test.mjs && node test/cli-publish-workflow.test.mjs && node test/mufl-integrity.test.mjs && node test/verbatim-moves.test.mjs && node test/errors.test.mjs && node test/file-limit.test.mjs && node test/validate-name.test.mjs && node test/locate-unit.test.mjs && node test/lease-unit.test.mjs && node test/tx-lock.test.mjs && node test/wire-handlers-integrity.test.mjs && node test/moved-blocks-integrity.test.mjs && node test/ux-literals.test.mjs && node test/dist-shared-state.test.mjs && node test/public-boundary.test.mjs && node test/api-error-parity.test.mjs && node test/files-helpers.test.mjs && node test/
|
|
42
|
+
"test": "node build.mjs && bash scripts/test-receipts-mufl.sh && bash scripts/test-notifications-mufl.sh && bash scripts/test-contact-uniqueness-mufl.sh && bash scripts/test-temp-remove-me-mufl.sh && node test/state-root-singleton.test.mjs && node test/bump-version.test.mjs && node test/cli-publish-workflow.test.mjs && node test/mufl-integrity.test.mjs && node test/verbatim-moves.test.mjs && node test/errors.test.mjs && node test/file-limit.test.mjs && node test/validate-name.test.mjs && node test/locate-unit.test.mjs && node test/lease-unit.test.mjs && node test/tx-lock.test.mjs && node test/wire-handlers-integrity.test.mjs && node test/moved-blocks-integrity.test.mjs && node test/external-history-boundary.test.mjs && node test/history-store.test.mjs && node test/ux-literals.test.mjs && node test/dist-shared-state.test.mjs && node test/public-boundary.test.mjs && node test/api-error-parity.test.mjs && node test/files-helpers.test.mjs && node test/notification-events.test.mjs && node test/notify-kinds.test.mjs && node test/process-state.test.mjs && node test/startup-progress.test.mjs && node test/transcribe-detect.test.mjs && node test/transcribe-stt.test.mjs && node test/voice-setup-config.test.mjs && node test/cli-operations.test.mjs && node test/cli-lifecycle.test.mjs && node test/cli-service-instance.test.mjs && node test/cli-service-launchd.test.mjs && node test/cli-command.test.mjs && node test/cli-help.test.mjs && node test/mig1867-verify.test.mjs && node test/boot-smoke.test.mjs && node test/boot-guards.test.mjs && node test/api-identity.test.mjs && node test/api-contacts.test.mjs && node test/api-messaging.test.mjs && node test/api-files.test.mjs && node test/file-upload.test.mjs && node test/daemon-routes.test.mjs && node test/daemon-lifecycle.test.mjs && node test/notify-hook.test.mjs && node test/daemon-events.test.mjs && node test/cross-entry-singleton.test.mjs && node test/client-parity.test.mjs && node test/daemon-selection.test.mjs && node test/api-auth.test.mjs && node test/release-lease.test.mjs && node test/delegation-survives.test.mjs && node test/proxy-annotate-hook.test.mjs && node test/connector-exit-on-stdin-eof.test.mjs && node test/version-advisory.test.mjs && node test/session-restore.test.mjs && node test/loopback-bind.test.mjs && node test/port-visibility.test.mjs && node test/unread-http-api.test.mjs && node test/lease-binding.test.mjs"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@adapt-toolkit/sdk": "0.10.12",
|
|
46
|
-
"@adapt-toolkit/sdk-native": "0.10.12"
|
|
46
|
+
"@adapt-toolkit/sdk-native": "0.10.12",
|
|
47
|
+
"better-sqlite3": "^11.10.0"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
50
|
"@adapt-toolkit/broker": "0.10.12",
|
|
50
51
|
"@adapt-toolkit/mufl": "0.10.12",
|
|
52
|
+
"@types/better-sqlite3": "^9.6.0",
|
|
51
53
|
"@types/node": "^20.14.0",
|
|
52
54
|
"esbuild": "^0.24.2",
|
|
53
55
|
"tsx": "^4.19.0",
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { ConversationResult, ConversationPolicyResult, MarkReadResult, ReceiptsResult, SessionContext } from './types.js';
|
|
2
|
-
export type * from './types.js';
|
|
3
|
-
/**
|
|
4
|
-
* The whole conversation with one contact, oldest first, both directions.
|
|
5
|
-
*
|
|
6
|
-
* READS NOTHING INTO EXISTENCE AND SENDS NOTHING. Empty for an identity that
|
|
7
|
-
* does not keep history — that is a correct answer to a reasonable question,
|
|
8
|
-
* not an error.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getConversation(ctx: SessionContext, a: {
|
|
11
|
-
contact: string;
|
|
12
|
-
}): Promise<ConversationResult>;
|
|
13
|
-
/**
|
|
14
|
-
* `wire_id -> "delivered" | "read"` for one conversation — what the PEER has
|
|
15
|
-
* told us about messages we sent.
|
|
16
|
-
*
|
|
17
|
-
* Only populated for an identity that keeps history: receipts arrive because
|
|
18
|
-
* such an identity advertises `core.receipts.receive`, and an agent identity
|
|
19
|
-
* deliberately does not (its peers are told not to send what it would discard).
|
|
20
|
-
*/
|
|
21
|
-
export declare function getReceipts(ctx: SessionContext, a: {
|
|
22
|
-
contact: string;
|
|
23
|
-
}): Promise<ReceiptsResult>;
|
|
24
|
-
/**
|
|
25
|
-
* THE HUMAN READ EVENT. Flips this conversation's unread inbound entries and
|
|
26
|
-
* emits read receipts for exactly those wire ids — exact-once, because the
|
|
27
|
-
* transition is the event, not the call. Calling it twice marks 0 the second
|
|
28
|
-
* time and sends nothing.
|
|
29
|
-
*/
|
|
30
|
-
export declare function markRead(ctx: SessionContext, a: {
|
|
31
|
-
contact: string;
|
|
32
|
-
}): Promise<MarkReadResult>;
|
|
33
|
-
/**
|
|
34
|
-
* Turn conversation history on (or off) for the bound identity.
|
|
35
|
-
*
|
|
36
|
-
* TURNING IT ON ALSO ADVERTISES `core.receipts.receive`, because an identity
|
|
37
|
-
* that keeps a conversation can hold receipts and one that does not cannot —
|
|
38
|
-
* the actor's rule that "peers must not send receipts that it discards" stays
|
|
39
|
-
* true either way.
|
|
40
|
-
*
|
|
41
|
-
* CONTACTS YOU ALREADY HAVE do not learn the new capability until your next
|
|
42
|
-
* outbound message carries the caps piggyback. Call `readvertiseOnUpgrade` after
|
|
43
|
-
* enabling to push a fresh AD to every non-epoch-pinned contact — it is a SEND,
|
|
44
|
-
* which is why it is not folded into this state write.
|
|
45
|
-
*/
|
|
46
|
-
export declare function setConversationPolicy(ctx: SessionContext, a: {
|
|
47
|
-
keep_history: boolean;
|
|
48
|
-
}): Promise<ConversationPolicyResult>;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d}from"../chunk-XT75POTM.js";import"../chunk-HPPNU5YV.js";import"../chunk-K7TLSZ3X.js";import"../chunk-65KGEJBX.js";import"../chunk-3CDGP5EO.js";import"../chunk-CGAOZPMV.js";import"../chunk-2PVVBIA7.js";import"../chunk-MQ5AXTPT.js";import"../chunk-YRPUM6JG.js";import"../chunk-TUWHVJ37.js";import"../chunk-DIRW7I4S.js";import"../chunk-7JZS2BAP.js";import"../chunk-CIHGEBUR.js";import"../chunk-T76BFV6S.js";import"../chunk-ZHH3PWEW.js";import"../chunk-LKFYUCN7.js";import"../chunk-Y3VPZJTG.js";import"../chunk-P55RJGZU.js";import"../chunk-XYU2DSWR.js";import"../chunk-WS6UFNKF.js";export{a as getConversation,b as getReceipts,c as markRead,d as setConversationPolicy};
|
package/dist/chunk-AQK45DI7.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{g as z}from"./chunk-OWZIFNZN.js";import{b as D,g as V}from"./chunk-VXVW4KJU.js";import{a as O,b as q,c as L,d as v}from"./chunk-V7PKYHV7.js";import{a as u}from"./chunk-HPPNU5YV.js";import{A as P,B as M,C as N,D as T,E as U,F as C,M as c,a as F}from"./chunk-65KGEJBX.js";import{H as k,I as p,J as E,M as _,j as S,k as A,p as x}from"./chunk-MQ5AXTPT.js";import{c as b}from"./chunk-TUWHVJ37.js";import{i as f}from"./chunk-T76BFV6S.js";import{d as $}from"./chunk-LKFYUCN7.js";import{a as R}from"./chunk-P55RJGZU.js";import{readFile as G}from"node:fs/promises";import{basename as H}from"node:path";function j(s,i){if(s)return i!==void 0?{wire_id:s,sentence:i}:{wire_id:s}}async function de(s,i){let t=u(s),{contact:a,text:n}=i,d=j(i.reply_to_wire_id,i.reply_to_sentence);try{let r=await p(async o=>v(await _(t,"::a2a_messaging::send_message",{contact:a,text:n,...d?{reply_to:d}:{}},o)));switch(r.kind){case"refused":f(`[e2e-route] refused cid=${r.cid} wire_id=${r.wireId} (downgrade_refused)`);break;case"migrating":f(`[migration] queued cid=${r.cid} wire_id=${r.wireId} (migrating, ${r.queued} queued)`);break;case"e2e":f(`[e2e-route] cid=${r.cid} wire_id=${r.wireId} verdict=e2e (core delivered over migrated session)${r.notRetained?" NOT RETAINED (oversized)":""}`),r.notRetained&&S(t,{event:"send_not_retained",wire_id:r.wireId,kind:"message"});break;default:break}return r}catch(r){if(!/Unknown contact/.test(String(r)))throw c("send_message",String(r));try{let o=O(t,a);return{kind:"introduced",text:o?await q(t,o,n):await L(t,a,n)}}catch(o){throw c("send_message",String(o),"FALLBACK_FAILED")}}}async function ce(s,i){let t=u(s),{contact:a,path:n,data_base64:d,upload_id:r,filename:o,mime:B}=i;if((n?1:0)+(d?1:0)+(r?1:0)!=1)throw r?T():P();let l,m,I=null;try{if(n)l=await G(n),m=o??H(n);else if(r){let e=z(t,r);if(!e)throw U(r);I=e.meta,l=e.buf,m=o??e.meta.filename}else{if(!o)throw M();l=Buffer.from(d,"base64"),m=o}}catch(e){throw e instanceof F?e:N(String(e))}let y=B??(n?R(n):I?.mime||""),h=j(i.reply_to_wire_id,i.reply_to_sentence),W=D(),g;try{g=k(e=>V({packet:{NewBinaryFromBuffer:w=>t.pw.packet.NewBinaryFromBuffer(w)},lifetime:e,filename:m,mime:y,payload:l,replyTo:h,cap:W}))}catch(e){throw e instanceof F?e:c("send_file",String(e))}if(!g.ok)throw C({filename:m,bytes:g.bytes,limit:g.cap,envelopeBytes:g.envelopeBytes,maxPayloadBytes:g.maxPayloadBytes});try{let e=await p(async w=>{let K=t.pw.packet.NewBinaryFromBuffer(l).Attach(w);return v(await _(t,"::a2a_messaging::send_file",{contact:a,filename:m,mime:y,data:K,...h?{reply_to:h}:{}},w))});switch(e.kind){case"refused":f(`[e2e-route] refused cid=${e.cid} wire_id=${e.wireId} (downgrade_refused, file)`);break;case"migrating":f(`[migration] file-defer cid=${e.cid} wire_id=${e.wireId} (migrating, not queued)`);break;case"e2e":f(`[e2e-route] cid=${e.cid} wire_id=${e.wireId} verdict=e2e file (core delivered over migrated session)${e.notRetained?" NOT RETAINED (oversized)":""}`),e.notRetained&&S(t,{event:"send_not_retained",wire_id:e.wireId,kind:"file"});break;default:break}return{...e,filename:m,bytes:l.length,mime:y}}catch(e){throw c("send_file",String(e))}}async function me(s){let i=u(s);try{return k(t=>b(E(i,"::actor::list_incoming_messages",t)))}catch(t){throw c("list_incoming_messages",String(t))}}async function fe(s){let i=u(s);try{let t=await p(async n=>{let d=await _(i,"::actor::get_messages",{},n);return b(d.Reduce("messages"))});x(i);let a=A(i);return $(t,a)}catch(t){throw c("get_messages",String(t))}}async function le(s,i){let t=u(s),{msg_ids:a}=i;try{let n=await p(async d=>(await _(t,"::actor::defer_messages",{msg_ids:a},d)).Reduce("deferred").Visualize());return x(t),{deferred:n}}catch(n){throw c("defer_messages",String(n))}}export{de as a,ce as b,me as c,fe as d,le as e};
|
package/dist/chunk-CGXQP3Q4.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as M,b,c as F,d as w,e as T,f as N,g as L,h as H,i as B,j}from"./chunk-TIBWO3T3.js";import{a as E,b as J,c as _,d as $}from"./chunk-XT75POTM.js";import{a as U,b as V,c as X,d as q}from"./chunk-R5ISAB5B.js";import{a as z,b as D,c as G,d as K,e as Q}from"./chunk-AQK45DI7.js";import{a as W,b as Y,c as Z,d as ee}from"./chunk-64C2NWXL.js";import{b as u,c as v,d as k,e as R,f as C,g as S,h as x,i as h,j as P,k as O}from"./chunk-HPPNU5YV.js";import{a as I}from"./chunk-65KGEJBX.js";import{c as d}from"./chunk-7JZS2BAP.js";import{o as f}from"./chunk-CIHGEBUR.js";import{i as m,m as y}from"./chunk-T76BFV6S.js";var ne="/api/v1/",e=i=>(t,n)=>i(t,n),s=i=>t=>i(t),oe=i=>(t,n)=>i(n),te={createIdentity:e(u),createTemporaryIdentity:e(v),closeTemporaryIdentityOp:e(k),createRootIdentity:e(R),defineLocalIdentityFile:oe(C),chooseIdentity:e(S),listIdentities:s(x),currentIdentity:s(h),removeIdentity:e(P),releaseLease:s(O),generateInvite:e(M),listInvites:s(b),revokeInvite:e(F),addContact:e(w),listContacts:s(T),listLocalContactBook:s(N),setLocalBookPolicy:e(L),removeContact:e(H),renameContact:e(B),respondToIntroduction:e(j),setBio:e(W),advertiseMigrate:s(Y),readvertiseOnUpgrade:s(ee),setPersona:e(Z),sendMessage:e(z),sendFile:e(D),listIncomingMessages:s(G),getMessages:s(K),deferMessages:e(Q),deferFiles:e(q),getConversation:e(E),getReceipts:e(J),markRead:e(_),setConversationPolicy:e($),listIncomingFiles:s(U),getFiles:e(V),saveFileFallbackNotice:e(X)},l=new Map,ie=(i,t)=>{let n=i.headers[t];return typeof n=="string"&&n!==""?n:void 0};function se(i){let t=ie(i,"x-ours-lease-token"),n=ie(i,"x-ours-client-pid"),A=n?parseInt(n,10):NaN,a=Number.isInteger(A)?A:void 0,o=t?`api:${f(t)}`:"api:anonymous";return d.set(o,{token:t,pid:a}),l.set(o,(l.get(o)??0)+1),{ctx:{sessionId:()=>o,leaseToken:()=>d.get(o)?.token,clientPid:()=>d.get(o)?.pid},release:()=>{let r=(l.get(o)??1)-1;if(r>0){l.set(o,r);return}l.delete(o),d.delete(o)}}}var p=(i,t,n)=>{i.writableEnded||(i.writeHead(t,{"Content-Type":"application/json"}),i.end(JSON.stringify(n??null)))};async function fe(i,t,n,A){let a=n.slice(ne.length);if(!y(i,t))return;if(i.method!=="POST"){p(t,405,{error:"method not allowed: the typed API is POST-only"});return}let o=Object.prototype.hasOwnProperty.call(te,a)?te[a]:void 0;if(!o){p(t,404,{error:`unknown operation "${a}"`});return}let r;try{r=await A(i)}catch{p(t,400,{error:"the request body must be JSON"});return}if(r===null||typeof r!="object"||Array.isArray(r)){p(t,400,{error:"the request body must be a JSON object"});return}let g=se(i);try{p(t,200,await o(g.ctx,r))}catch(c){if(c instanceof I){p(t,400,{error:{code:c.code,message:c.message}});return}m("api handler error:",a,String(c)),p(t,500,{error:`internal error in ${a}: ${String(c)}`})}finally{g.release()}}export{ne as a,te as b,se as c,fe as d};
|
package/dist/chunk-CIHGEBUR.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as i,i as a}from"./chunk-T76BFV6S.js";import{join as n}from"node:path";import{createHash as u}from"node:crypto";import*as r from"node:fs";var m;function v(t){m=t}var T=new Map,g=null,y=null;function I(t){g=t}function _(t){y=t}var F=t=>n(i,t),d=t=>n(t,"identity.key"),h=t=>n(t,"state_data.bin"),W=t=>n(t,"notifications.log"),E=t=>n(t,"unread.json"),x=t=>n(t.dir,"files"),c=t=>n(t,"temp.json"),H=t=>u("sha256").update(t).digest("hex");function M(t,e){r.writeFileSync(c(t),JSON.stringify({v:1,owner:{token_sha256:e.owner.tokenHash,pid:e.owner.pid},created_at:e.createdAt}),{mode:384})}function R(t){try{let e=JSON.parse(r.readFileSync(c(t),"utf8"));return e.v!==1||typeof e.owner?.token_sha256!="string"||typeof e.owner?.pid!="number"?null:{owner:{tokenHash:e.owner.token_sha256,pid:e.owner.pid},createdAt:typeof e.created_at=="number"?e.created_at:0}}catch{return null}}function $(){for(let t of w()){let e=n(i,t);try{r.chmodSync(e,448)}catch(o){a(`[${t}] chmod 0700 failed:`,String(o))}for(let o of[h(e),d(e)])if(r.existsSync(o))try{r.chmodSync(o,384)}catch(s){a(`[${t}] chmod 0600 ${o} failed:`,String(s))}}}var k=t=>/^[A-Za-z0-9]+$/.test(t)&&t.length>0&&t.length<=128,j=t=>/^[A-Fa-f0-9]{64}$/.test(t);function B(t,e){if(!k(e))return null;let o=x(t),s;try{s=r.readdirSync(o)}catch{return null}let l=`${e}-`,p=s.find(f=>f.startsWith(l));return p?n(o,p):null}function w(){return r.existsSync(i)?r.readdirSync(i,{withFileTypes:!0}).filter(t=>t.isDirectory()&&r.existsSync(d(n(i,t.name)))).map(t=>t.name):[]}export{m as a,v as b,T as c,g as d,y as e,I as f,_ as g,F as h,d as i,h as j,W as k,E as l,x as m,c as n,H as o,M as p,R as q,$ as r,k as s,j as t,B as u,w as v};
|