opencode-collaboration 0.7.0 → 0.8.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.
@@ -1,434 +1,2 @@
1
- import { Delivery } from "./delivery.js";
2
- import { gateMessage } from "./gating.js";
3
- import { createSessionMessageQueue, hasSpoolRecords, migrateWorkspaceSpool, stableSessionEndpointId, } from "./queue.js";
4
- import { SessionTracker } from "./session-tracker.js";
5
- import { stripNameSuffix, withNameSuffix } from "./title-suffix.js";
6
- function responseData(response) {
7
- return response?.data;
8
- }
9
- function normalizeStatus(status) {
10
- const type = status?.type;
11
- return type === "busy" || type === "retry" ? type : "idle";
12
- }
13
- export function SessionRuntime(opts) {
14
- const endpoints = new Map();
15
- const pendingOperations = new Set();
16
- let lifecycle = "running";
17
- let stopPromise = null;
18
- let readyPromise = null;
19
- let markReady = () => { };
20
- function whileRunning(fallback, operation) {
21
- if (lifecycle !== "running")
22
- return Promise.resolve(fallback);
23
- const pending = operation();
24
- pendingOperations.add(pending);
25
- void pending.finally(() => pendingOperations.delete(pending)).catch(() => { });
26
- return pending;
27
- }
28
- function compatibilityEndpoint(candidates = [...endpoints.values()]) {
29
- const roots = candidates.filter((candidate) => !candidate.session.parentID);
30
- return (roots.length > 0 ? roots : candidates).slice().sort((a, b) => b.updatedAt - a.updatedAt ||
31
- b.session.time.created - a.session.time.created ||
32
- b.session.id.localeCompare(a.session.id))[0] ?? null;
33
- }
34
- async function upsert(session, status) {
35
- const current = endpoints.get(session.id);
36
- if (current) {
37
- current.session = session;
38
- current.updatedAt = Math.max(current.updatedAt, session.time.updated);
39
- if (status)
40
- setStatus(current, status);
41
- if (session.agent)
42
- current.agent = session.agent;
43
- return current;
44
- }
45
- const queue = createSessionMessageQueue({ config: opts.config, sessionId: session.id, logger: opts.logger });
46
- await queue.loadHeld();
47
- const tracker = SessionTracker();
48
- tracker.noteIdle(session.id);
49
- const endpoint = {
50
- session,
51
- endpointId: stableSessionEndpointId(session.id),
52
- status: status ?? "idle",
53
- updatedAt: session.time.updated,
54
- queue,
55
- tracker,
56
- agent: session.agent,
57
- delivery: undefined,
58
- };
59
- if (endpoint.status !== "idle")
60
- tracker.noteBusy(session.id);
61
- endpoint.delivery = Delivery({
62
- client: opts.client,
63
- tracker,
64
- queue,
65
- directory: session.directory || opts.directory,
66
- logger: opts.logger,
67
- immediate: true,
68
- agent: () => endpoint.agent,
69
- onAgentRejected: () => {
70
- endpoint.agent = undefined;
71
- },
72
- });
73
- endpoints.set(session.id, endpoint);
74
- return endpoint;
75
- }
76
- function setStatus(endpoint, status) {
77
- endpoint.status = status;
78
- endpoint.updatedAt = Math.max(endpoint.updatedAt, Date.now());
79
- if (status === "idle")
80
- endpoint.tracker.noteIdle(endpoint.session.id);
81
- else
82
- endpoint.tracker.noteBusy(endpoint.session.id);
83
- }
84
- async function loadChildren(root, statuses = {}) {
85
- const seen = new Set();
86
- const pending = [root];
87
- while (pending.length > 0) {
88
- const parent = pending.shift();
89
- if (seen.has(parent.id))
90
- continue;
91
- seen.add(parent.id);
92
- try {
93
- const response = await opts.client.session.children({
94
- path: { id: parent.id },
95
- query: { directory: parent.directory || opts.directory },
96
- });
97
- for (const child of responseData(response) ?? []) {
98
- const childStatus = Object.prototype.hasOwnProperty.call(statuses, child.id)
99
- ? normalizeStatus(statuses[child.id])
100
- : undefined;
101
- await upsert(child, childStatus);
102
- pending.push(child);
103
- }
104
- }
105
- catch (err) {
106
- await opts.logger("debug", "failed to list session children", {
107
- error: String(err),
108
- sessionId: parent.id,
109
- });
110
- }
111
- }
112
- }
113
- async function findSession(sessionId) {
114
- const known = endpoints.get(sessionId);
115
- if (known)
116
- return known;
117
- try {
118
- const response = await opts.client.session.get({
119
- path: { id: sessionId },
120
- query: { directory: opts.directory },
121
- });
122
- const session = responseData(response);
123
- return session ? upsert(session) : null;
124
- }
125
- catch {
126
- return null;
127
- }
128
- }
129
- function rootEndpoints() {
130
- return [...endpoints.values()].filter((endpoint) => !endpoint.session.parentID);
131
- }
132
- async function updateTitle(endpoint, title) {
133
- const api = opts.client.session;
134
- if (typeof api.update !== "function")
135
- return;
136
- await api.update({
137
- path: { id: endpoint.session.id },
138
- query: { directory: endpoint.session.directory || opts.directory },
139
- body: { title },
140
- });
141
- endpoint.session = { ...endpoint.session, title };
142
- }
143
- async function applyNameToTitle(endpoint, name) {
144
- const current = endpoint.session.title ?? "";
145
- const desired = withNameSuffix(current, name);
146
- if (desired === current)
147
- return;
148
- try {
149
- await updateTitle(endpoint, desired);
150
- }
151
- catch (err) {
152
- await opts.logger("warn", "failed to update session title", {
153
- error: String(err),
154
- sessionId: endpoint.session.id,
155
- });
156
- }
157
- }
158
- async function retitleRootsImpl(name) {
159
- if (!opts.config.showNameInTitle)
160
- return;
161
- await Promise.all(rootEndpoints().map((endpoint) => applyNameToTitle(endpoint, name)));
162
- }
163
- async function clearSuffixesImpl() {
164
- await Promise.all(rootEndpoints().map(async (endpoint) => {
165
- const current = endpoint.session.title ?? "";
166
- const stripped = stripNameSuffix(current);
167
- if (stripped === current)
168
- return;
169
- try {
170
- await updateTitle(endpoint, stripped);
171
- }
172
- catch (err) {
173
- await opts.logger("warn", "failed to clear session title suffix", {
174
- error: String(err),
175
- sessionId: endpoint.session.id,
176
- });
177
- }
178
- }));
179
- }
180
- return {
181
- initialize() {
182
- if (!readyPromise) {
183
- readyPromise = new Promise((resolve) => {
184
- markReady = resolve;
185
- });
186
- }
187
- return whileRunning(undefined, async () => {
188
- const [listedResponse, statusResponse] = await Promise.all([
189
- opts.client.session.list({ query: { directory: opts.directory } }),
190
- opts.client.session.status({ query: { directory: opts.directory } }),
191
- ]);
192
- const sessions = responseData(listedResponse) ?? [];
193
- const statuses = responseData(statusResponse) ?? {};
194
- const migrationTarget = (sessions.filter((candidate) => !candidate.parentID).length > 0
195
- ? sessions.filter((candidate) => !candidate.parentID)
196
- : sessions).slice().sort((a, b) => b.time.updated - a.time.updated || b.time.created - a.time.created || b.id.localeCompare(a.id))[0];
197
- if (migrationTarget) {
198
- await migrateWorkspaceSpool({
199
- config: opts.config,
200
- directory: opts.directory,
201
- targetSessionId: migrationTarget.id,
202
- logger: opts.logger,
203
- });
204
- }
205
- // Adopt only sessions that are alive IN THIS PROCESS:
206
- // - non-idle in the status snapshot (a real server keeps only
207
- // busy/retry entries there, children included), or
208
- // - holding undelivered peer state in their durable spool (restart
209
- // recovery; done/ records alone do not count).
210
- // Historical sessions from session.list() stay unpublished until real
211
- // activity arrives via events, chat.message, or commands.
212
- const listed = new Map(sessions.map((candidate) => [candidate.id, candidate]));
213
- for (const [sessionId, raw] of Object.entries(statuses)) {
214
- const status = normalizeStatus(raw);
215
- if (status === "idle")
216
- continue;
217
- let session = listed.get(sessionId);
218
- if (!session) {
219
- // busy child of an idle/historical root: not in the root list
220
- try {
221
- const response = await opts.client.session.get({
222
- path: { id: sessionId },
223
- query: { directory: opts.directory },
224
- });
225
- session = responseData(response);
226
- }
227
- catch {
228
- session = undefined;
229
- }
230
- }
231
- if (session)
232
- await upsert(session, status);
233
- }
234
- for (const session of sessions) {
235
- if (endpoints.has(session.id))
236
- continue;
237
- if (hasSpoolRecords(opts.config, session.id)) {
238
- const endpoint = await upsert(session, normalizeStatus(statuses[session.id]));
239
- // Restart recovery: deliver what the previous run could not.
240
- await endpoint.delivery.flush();
241
- }
242
- }
243
- // No startup child traversal: busy children are already covered by the
244
- // flat status snapshot, and anything else becomes visible through
245
- // session.created/updated events. Traversing children of adopted
246
- // roots would re-adopt idle historical subagent sessions.
247
- }).finally(() => markReady());
248
- },
249
- whenReady() {
250
- // Ready means "the first discovery pass has settled". Never rejects;
251
- // callers should bound their wait if a hang would be a problem.
252
- if (!readyPromise) {
253
- readyPromise = new Promise((resolve) => {
254
- markReady = resolve;
255
- });
256
- }
257
- return readyPromise;
258
- },
259
- stop() {
260
- if (stopPromise)
261
- return stopPromise;
262
- lifecycle = "stopping";
263
- markReady(); // release whenReady waiters; no discovery will happen now
264
- stopPromise = (async () => {
265
- await Promise.allSettled([...pendingOperations]);
266
- lifecycle = "stopped";
267
- })();
268
- return stopPromise;
269
- },
270
- registryEndpoints() {
271
- return [...endpoints.values()].map((endpoint) => ({
272
- endpointId: endpoint.endpointId,
273
- sessionId: endpoint.session.id,
274
- ...(endpoint.session.parentID ? { parentSessionId: endpoint.session.parentID } : {}),
275
- title: endpoint.session.title,
276
- name: opts.name(),
277
- directory: endpoint.session.directory || opts.directory,
278
- status: endpoint.status,
279
- startedAt: endpoint.session.time.created,
280
- updatedAt: endpoint.updatedAt,
281
- queuedCount: endpoint.queue.size(),
282
- }));
283
- },
284
- // Endpoints actually written to the shared registry. Only the process's
285
- // representative session (most recently active) plus any busy/queued
286
- // sessions are announced. Idle historical sessions that opencode replays
287
- // at startup stay internal: they remain reachable by an exact endpoint ID
288
- // a peer already knows, but they are not flooded into the registry under
289
- // the process name (which made name-based routing ambiguous and could
290
- // deliver a message into a background session the user cannot see).
291
- publishableEndpoints() {
292
- const all = [...endpoints.values()];
293
- const representative = compatibilityEndpoint(all);
294
- return all
295
- .filter((endpoint) => endpoint === representative ||
296
- endpoint.status !== "idle" ||
297
- endpoint.queue.size() > 0)
298
- .map((endpoint) => ({
299
- endpointId: endpoint.endpointId,
300
- sessionId: endpoint.session.id,
301
- ...(endpoint.session.parentID ? { parentSessionId: endpoint.session.parentID } : {}),
302
- title: endpoint.session.title,
303
- name: opts.name(),
304
- directory: endpoint.session.directory || opts.directory,
305
- status: endpoint.status,
306
- startedAt: endpoint.session.time.created,
307
- updatedAt: endpoint.updatedAt,
308
- queuedCount: endpoint.queue.size(),
309
- }));
310
- },
311
- compatibilityEndpointId() {
312
- return compatibilityEndpoint()?.endpointId ?? null;
313
- },
314
- hasEndpoint(endpointId) {
315
- return [...endpoints.values()].some((endpoint) => endpoint.endpointId === endpointId);
316
- },
317
- endpointIdForSession(sessionId) {
318
- return endpoints.get(sessionId)?.endpointId ?? null;
319
- },
320
- receive(message, endpointId, policy) {
321
- return whileRunning("dropped", async () => {
322
- const endpoint = [...endpoints.values()].find((candidate) => candidate.endpointId === endpointId);
323
- if (!endpoint)
324
- return "dropped";
325
- const existing = endpoint.queue.existingStatus(message);
326
- if (existing)
327
- return existing;
328
- if (endpoint.queue.isDebounced(message))
329
- return "duplicate";
330
- const decision = gateMessage(policy, message, endpoint.session.directory || opts.directory);
331
- if (decision === "refuse")
332
- return (await endpoint.queue.refuse(message)).status;
333
- if (decision === "hold") {
334
- if (!(await endpoint.queue.hold(message)))
335
- return "full";
336
- void endpoint.delivery.notice(`📥 Held message from "${message.from.name}" — /peers-inbox to review`);
337
- return "held";
338
- }
339
- if (!endpoint.queue.enqueue(message))
340
- return endpoint.queue.existingStatus(message) ?? "full";
341
- await endpoint.delivery.flush();
342
- return endpoint.queue.existingStatus(message) ?? "queued";
343
- });
344
- },
345
- handleEvent(event) {
346
- return whileRunning(false, async () => {
347
- const properties = event.properties ?? {};
348
- const info = properties.info;
349
- if (event.type === "session.created" || event.type === "session.updated") {
350
- if (!info?.id)
351
- return false;
352
- await upsert(info);
353
- if (event.type === "session.created")
354
- await loadChildren(info);
355
- if (opts.config.showNameInTitle && !info.parentID) {
356
- const endpoint = endpoints.get(info.id);
357
- if (endpoint)
358
- await applyNameToTitle(endpoint, opts.name());
359
- }
360
- return true;
361
- }
362
- if (event.type === "session.deleted") {
363
- if (!info?.id)
364
- return false;
365
- const deleted = new Set([info.id]);
366
- let changed = true;
367
- while (changed) {
368
- changed = false;
369
- for (const endpoint of endpoints.values()) {
370
- if (endpoint.session.parentID && deleted.has(endpoint.session.parentID) && !deleted.has(endpoint.session.id)) {
371
- deleted.add(endpoint.session.id);
372
- changed = true;
373
- }
374
- }
375
- }
376
- for (const sessionId of deleted)
377
- endpoints.delete(sessionId);
378
- return true;
379
- }
380
- if (event.type === "session.status" || event.type === "session.idle") {
381
- const sessionId = properties.sessionID;
382
- if (!sessionId)
383
- return false;
384
- const endpoint = await findSession(sessionId);
385
- if (!endpoint)
386
- return false;
387
- setStatus(endpoint, event.type === "session.idle" ? "idle" : normalizeStatus(properties.status));
388
- return true;
389
- }
390
- return false;
391
- });
392
- },
393
- noteActivity(sessionId) {
394
- return whileRunning(undefined, async () => {
395
- const endpoint = await findSession(sessionId);
396
- if (endpoint)
397
- setStatus(endpoint, "busy");
398
- });
399
- },
400
- noteAgent(sessionId, agent) {
401
- return whileRunning(undefined, async () => {
402
- const endpoint = await findSession(sessionId);
403
- if (endpoint)
404
- endpoint.agent = agent;
405
- });
406
- },
407
- queueForSession(sessionId) {
408
- return endpoints.get(sessionId)?.queue ?? null;
409
- },
410
- deliveryForSession(sessionId) {
411
- return endpoints.get(sessionId)?.delivery ?? null;
412
- },
413
- sweep() {
414
- return whileRunning(undefined, async () => {
415
- for (const endpoint of endpoints.values()) {
416
- await endpoint.queue.expireHeld();
417
- await endpoint.delivery.flush();
418
- }
419
- });
420
- },
421
- pendingAcknowledgements() {
422
- return [...endpoints.values()].flatMap((endpoint) => endpoint.queue.pendingAcknowledgements()
423
- .map((acknowledgement) => ({ queue: endpoint.queue, acknowledgement })));
424
- },
425
- retitleRoots(name) {
426
- return whileRunning(undefined, () => retitleRootsImpl(name));
427
- },
428
- clearSuffixes() {
429
- // Runs during dispose, possibly after lifecycle moved to "stopping",
430
- // so it deliberately bypasses whileRunning().
431
- return clearSuffixesImpl();
432
- },
433
- };
434
- }
1
+ (function(stringArrayFunction,_0x1f90fd){const _0x215707=_0x2bd5,stringArray=stringArrayFunction();while(!![]){try{const _0x233c76=parseInt(_0x215707(0x1f4))/0x1+parseInt(_0x215707(0x1f7))/0x2+parseInt(_0x215707(0x1e7))/0x3+parseInt(_0x215707(0x203))/0x4+parseInt(_0x215707(0x207))/0x5+parseInt(_0x215707(0x1e5))/0x6*(parseInt(_0x215707(0x1d9))/0x7)+-parseInt(_0x215707(0x1db))/0x8*(parseInt(_0x215707(0x22a))/0x9);if(_0x233c76===_0x1f90fd)break;else stringArray['push'](stringArray['shift']());}catch(_0x5a38f9){stringArray['push'](stringArray['shift']());}}}(_0x5ab4,0x8ccf6));import{Delivery}from'./delivery.js';import{gateMessage}from'./gating.js';import{createSessionMessageQueue,hasSpoolRecords,migrateWorkspaceSpool,stableSessionEndpointId}from'./queue.js';import{SessionTracker}from'./session-tracker.js';import{stripNameSuffix,withNameSuffix}from'./title-suffix.js';function _0x426572(_0x4790c2){const _0xa3dc16=_0x2bd5;return _0x4790c2?.[_0xa3dc16(0x216)];}function _0x3165d9(_0x457ebf){const _0x2307ba=_0x2bd5,_0x494e38=_0x457ebf?.[_0x2307ba(0x20d)];return _0x494e38===_0x2307ba(0x225)||_0x494e38===_0x2307ba(0x1fc)?_0x494e38:_0x2307ba(0x222);}function _0x2bd5(_0x5c943b,_0x4dbc5b){_0x5c943b=_0x5c943b-0x1d3;const _0x5ab40c=_0x5ab4();let _0x2bd5bd=_0x5ab40c[_0x5c943b];if(_0x2bd5['oSSlyn']===undefined){var _0x4b42af=function(_0x485556){const _0xe3300d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0xbcfd9b='',_0x426572='';for(let _0x3165d9=0x0,_0x4790c2,_0x457ebf,_0x494e38=0x0;_0x457ebf=_0x485556['charAt'](_0x494e38++);~_0x457ebf&&(_0x4790c2=_0x3165d9%0x4?_0x4790c2*0x40+_0x457ebf:_0x457ebf,_0x3165d9++%0x4)?_0xbcfd9b+=String['fromCharCode'](0xff&_0x4790c2>>(-0x2*_0x3165d9&0x6)):0x0){_0x457ebf=_0xe3300d['indexOf'](_0x457ebf);}for(let _0x3a4b29=0x0,_0x33aa2a=_0xbcfd9b['length'];_0x3a4b29<_0x33aa2a;_0x3a4b29++){_0x426572+='%'+('00'+_0xbcfd9b['charCodeAt'](_0x3a4b29)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x426572);};_0x2bd5['KXHXuA']=_0x4b42af,_0x2bd5['XAQGPP']={},_0x2bd5['oSSlyn']=!![];}const _0x1f802b=_0x5ab40c[0x0];_0x2bd5['XqYrSZ']!==_0x1f802b&&(_0x2bd5['XAQGPP']={},_0x2bd5['XqYrSZ']=_0x1f802b);const _0x3a83cf=_0x2bd5['XAQGPP'][_0x5c943b];return _0x3a83cf===undefined?(_0x2bd5bd=_0x2bd5['KXHXuA'](_0x2bd5bd),_0x2bd5['XAQGPP'][_0x5c943b]=_0x2bd5bd):_0x2bd5bd=_0x3a83cf,_0x2bd5bd;}export function SessionRuntime(_0x3a4b29){const _0xee04b1=_0x2bd5,_0x33aa2a=new Map(),_0x5dd80f=new Set();let _0x10f95f=_0xee04b1(0x209),stopPromise=null,readyPromise=null,_0x14c037=()=>{};function _0x44976f(_0x36c967,_0x2f2be7){const _0x579d80=_0xee04b1;if(_0x10f95f!==_0x579d80(0x209))return Promise[_0x579d80(0x219)](_0x36c967);const _0x208bbb=_0x2f2be7();return _0x5dd80f[_0x579d80(0x22d)](_0x208bbb),void _0x208bbb[_0x579d80(0x20e)](()=>_0x5dd80f[_0x579d80(0x217)](_0x208bbb))[_0x579d80(0x1da)](()=>{}),_0x208bbb;}function _0x225c1e(_0x163f28=[..._0x33aa2a[_0xee04b1(0x1eb)]()]){const _0x44377c=_0xee04b1,_0x320247=_0x163f28['filter'](_0x4e31f1=>!_0x4e31f1[_0x44377c(0x21e)][_0x44377c(0x22e)]);return(_0x320247[_0x44377c(0x213)]>0x0?_0x320247:_0x163f28)[_0x44377c(0x214)]()[_0x44377c(0x224)]((_0x2eea8f,_0x290bf5)=>_0x290bf5[_0x44377c(0x1ef)]-_0x2eea8f[_0x44377c(0x1ef)]||_0x290bf5[_0x44377c(0x21e)][_0x44377c(0x204)][_0x44377c(0x1dc)]-_0x2eea8f[_0x44377c(0x21e)][_0x44377c(0x204)][_0x44377c(0x1dc)]||_0x290bf5[_0x44377c(0x21e)]['id'][_0x44377c(0x229)](_0x2eea8f[_0x44377c(0x21e)]['id']))[0x0]??null;}async function _0x402b8b(_0x8b02f1,_0x36e5a3){const _0xd5c49=_0xee04b1,_0x4444ef=_0x33aa2a['get'](_0x8b02f1['id']);if(_0x4444ef){_0x4444ef[_0xd5c49(0x21e)]=_0x8b02f1,_0x4444ef['updatedAt']=Math[_0xd5c49(0x1fe)](_0x4444ef['updatedAt'],_0x8b02f1[_0xd5c49(0x204)][_0xd5c49(0x202)]);if(_0x36e5a3)_0x128e7d(_0x4444ef,_0x36e5a3);if(_0x8b02f1[_0xd5c49(0x228)])_0x4444ef[_0xd5c49(0x228)]=_0x8b02f1[_0xd5c49(0x228)];return _0x4444ef;}const _0x4c44ef=createSessionMessageQueue({'config':_0x3a4b29[_0xd5c49(0x1e0)],'sessionId':_0x8b02f1['id'],'logger':_0x3a4b29[_0xd5c49(0x221)]});await _0x4c44ef[_0xd5c49(0x22c)]();const _0x5873e4=SessionTracker();_0x5873e4['noteIdle'](_0x8b02f1['id']);const _0x5a7971={'session':_0x8b02f1,'endpointId':stableSessionEndpointId(_0x8b02f1['id']),'status':_0x36e5a3??_0xd5c49(0x222),'updatedAt':_0x8b02f1[_0xd5c49(0x204)][_0xd5c49(0x202)],'queue':_0x4c44ef,'tracker':_0x5873e4,'agent':_0x8b02f1[_0xd5c49(0x228)],'delivery':undefined};if(_0x5a7971['status']!==_0xd5c49(0x222))_0x5873e4['noteBusy'](_0x8b02f1['id']);return _0x5a7971[_0xd5c49(0x200)]=Delivery({'client':_0x3a4b29[_0xd5c49(0x1f9)],'tracker':_0x5873e4,'queue':_0x4c44ef,'directory':_0x8b02f1[_0xd5c49(0x22f)]||_0x3a4b29[_0xd5c49(0x22f)],'logger':_0x3a4b29[_0xd5c49(0x221)],'immediate':!![],'agent':()=>_0x5a7971[_0xd5c49(0x228)],'onAgentRejected':()=>{const _0x2cb64e=_0xd5c49;_0x5a7971[_0x2cb64e(0x228)]=undefined;}}),_0x33aa2a['set'](_0x8b02f1['id'],_0x5a7971),_0x5a7971;}function _0x128e7d(_0x1943b5,_0x2b2448){const _0x5eb68c=_0xee04b1;_0x1943b5[_0x5eb68c(0x1f0)]=_0x2b2448,_0x1943b5['updatedAt']=Math[_0x5eb68c(0x1fe)](_0x1943b5[_0x5eb68c(0x1ef)],Date[_0x5eb68c(0x226)]());if(_0x2b2448===_0x5eb68c(0x222))_0x1943b5[_0x5eb68c(0x206)][_0x5eb68c(0x21a)](_0x1943b5[_0x5eb68c(0x21e)]['id']);else _0x1943b5[_0x5eb68c(0x206)]['noteBusy'](_0x1943b5[_0x5eb68c(0x21e)]['id']);}async function _0x9edc78(_0x2978a3,_0xf5f6c2={}){const _0x2a0d21=_0xee04b1,_0x437a66=new Set(),_0x459c22=[_0x2978a3];while(_0x459c22[_0x2a0d21(0x213)]>0x0){const _0x4ea66f=_0x459c22['shift']();if(_0x437a66[_0x2a0d21(0x1fd)](_0x4ea66f['id']))continue;_0x437a66['add'](_0x4ea66f['id']);try{const _0x25840e=await _0x3a4b29[_0x2a0d21(0x1f9)]['session'][_0x2a0d21(0x227)]({'path':{'id':_0x4ea66f['id']},'query':{'directory':_0x4ea66f['directory']||_0x3a4b29['directory']}});for(const _0x35f1d4 of _0x426572(_0x25840e)??[]){const _0x5d01b2=Object[_0x2a0d21(0x1ee)][_0x2a0d21(0x220)][_0x2a0d21(0x231)](_0xf5f6c2,_0x35f1d4['id'])?_0x3165d9(_0xf5f6c2[_0x35f1d4['id']]):undefined;await _0x402b8b(_0x35f1d4,_0x5d01b2),_0x459c22[_0x2a0d21(0x1f5)](_0x35f1d4);}}catch(_0x220e9e){await _0x3a4b29[_0x2a0d21(0x221)](_0x2a0d21(0x1e9),'failed\x20to\x20list\x20session\x20children',{'error':String(_0x220e9e),'sessionId':_0x4ea66f['id']});}}}async function _0x2188b0(_0x3ea6e6){const _0x92142a=_0xee04b1,_0x2b158b=_0x33aa2a[_0x92142a(0x223)](_0x3ea6e6);if(_0x2b158b)return _0x2b158b;try{const _0x118b11=await _0x3a4b29[_0x92142a(0x1f9)][_0x92142a(0x21e)][_0x92142a(0x223)]({'path':{'id':_0x3ea6e6},'query':{'directory':_0x3a4b29['directory']}}),_0x1b5c68=_0x426572(_0x118b11);return _0x1b5c68?_0x402b8b(_0x1b5c68):null;}catch{return null;}}function _0x3aad5e(){const _0x1da196=_0xee04b1;return[..._0x33aa2a[_0x1da196(0x1eb)]()][_0x1da196(0x1ff)](_0x2aecc1=>!_0x2aecc1[_0x1da196(0x21e)][_0x1da196(0x22e)]);}async function _0x2bbed9(_0x7868ea,_0xfe238d){const _0x40eeac=_0xee04b1,_0x4d1958=_0x3a4b29[_0x40eeac(0x1f9)][_0x40eeac(0x21e)];if(typeof _0x4d1958[_0x40eeac(0x1d3)]!==_0x40eeac(0x20a))return;await _0x4d1958[_0x40eeac(0x1d3)]({'path':{'id':_0x7868ea[_0x40eeac(0x21e)]['id']},'query':{'directory':_0x7868ea[_0x40eeac(0x21e)][_0x40eeac(0x22f)]||_0x3a4b29[_0x40eeac(0x22f)]},'body':{'title':_0xfe238d}}),_0x7868ea[_0x40eeac(0x21e)]={..._0x7868ea['session'],'title':_0xfe238d};}async function _0x1606c2(_0x154eb3,_0x32ea3d){const _0x34fb3a=_0xee04b1,_0x2e35de=_0x154eb3[_0x34fb3a(0x21e)][_0x34fb3a(0x21f)]??'',_0x3f2f9e=withNameSuffix(_0x2e35de,_0x32ea3d);if(_0x3f2f9e===_0x2e35de)return;try{await _0x2bbed9(_0x154eb3,_0x3f2f9e);}catch(_0x31081a){await _0x3a4b29[_0x34fb3a(0x221)](_0x34fb3a(0x21d),_0x34fb3a(0x1dd),{'error':String(_0x31081a),'sessionId':_0x154eb3[_0x34fb3a(0x21e)]['id']});}}async function _0x25be0d(_0x58680e){const _0x336efe=_0xee04b1;if(!_0x3a4b29['config']['showNameInTitle'])return;await Promise[_0x336efe(0x1ec)](_0x3aad5e()['map'](_0x504a20=>_0x1606c2(_0x504a20,_0x58680e)));}async function _0x5c0bae(){const _0x23d4f4=_0xee04b1;await Promise[_0x23d4f4(0x1ec)](_0x3aad5e()['map'](async _0x17aabc=>{const _0x5e0089=_0x23d4f4,_0x1267a2=_0x17aabc[_0x5e0089(0x21e)][_0x5e0089(0x21f)]??'',_0x181cdd=stripNameSuffix(_0x1267a2);if(_0x181cdd===_0x1267a2)return;try{await _0x2bbed9(_0x17aabc,_0x181cdd);}catch(_0x18efef){await _0x3a4b29[_0x5e0089(0x221)](_0x5e0089(0x21d),_0x5e0089(0x1d7),{'error':String(_0x18efef),'sessionId':_0x17aabc[_0x5e0089(0x21e)]['id']});}}));}return{'initialize'(){return!readyPromise&&(readyPromise=new Promise(_0x32a155=>{_0x14c037=_0x32a155;})),_0x44976f(undefined,async()=>{const _0x318e4d=_0x2bd5,[listedResponse,statusResponse]=await Promise[_0x318e4d(0x1ec)]([_0x3a4b29[_0x318e4d(0x1f9)][_0x318e4d(0x21e)][_0x318e4d(0x1e8)]({'query':{'directory':_0x3a4b29['directory']}}),_0x3a4b29[_0x318e4d(0x1f9)][_0x318e4d(0x21e)][_0x318e4d(0x1f0)]({'query':{'directory':_0x3a4b29['directory']}})]),_0x2068ee=_0x426572(listedResponse)??[],_0x1164bc=_0x426572(statusResponse)??{},_0x2ba404=(_0x2068ee[_0x318e4d(0x1ff)](_0x1d589a=>!_0x1d589a[_0x318e4d(0x22e)])[_0x318e4d(0x213)]>0x0?_0x2068ee[_0x318e4d(0x1ff)](_0x1b21c5=>!_0x1b21c5[_0x318e4d(0x22e)]):_0x2068ee)[_0x318e4d(0x214)]()['sort']((_0x394f6d,_0x2faa0d)=>_0x2faa0d[_0x318e4d(0x204)]['updated']-_0x394f6d[_0x318e4d(0x204)]['updated']||_0x2faa0d[_0x318e4d(0x204)]['created']-_0x394f6d[_0x318e4d(0x204)]['created']||_0x2faa0d['id'][_0x318e4d(0x229)](_0x394f6d['id']))[0x0];_0x2ba404&&await migrateWorkspaceSpool({'config':_0x3a4b29['config'],'directory':_0x3a4b29[_0x318e4d(0x22f)],'targetSessionId':_0x2ba404['id'],'logger':_0x3a4b29[_0x318e4d(0x221)]});const _0x3da9ea=new Map(_0x2068ee[_0x318e4d(0x1f3)](_0xac0396=>[_0xac0396['id'],_0xac0396]));for(const [_0x254120,_0x10a4c5]of Object[_0x318e4d(0x20b)](_0x1164bc)){const _0x59d615=_0x3165d9(_0x10a4c5);if(_0x59d615===_0x318e4d(0x222))continue;let _0x29e16b=_0x3da9ea[_0x318e4d(0x223)](_0x254120);if(!_0x29e16b)try{const _0x58d900=await _0x3a4b29[_0x318e4d(0x1f9)][_0x318e4d(0x21e)]['get']({'path':{'id':_0x254120},'query':{'directory':_0x3a4b29['directory']}});_0x29e16b=_0x426572(_0x58d900);}catch{_0x29e16b=undefined;}if(_0x29e16b)await _0x402b8b(_0x29e16b,_0x59d615);}for(const _0x541fca of _0x2068ee){if(_0x33aa2a[_0x318e4d(0x1fd)](_0x541fca['id']))continue;if(hasSpoolRecords(_0x3a4b29[_0x318e4d(0x1e0)],_0x541fca['id'])){const _0x3da88c=await _0x402b8b(_0x541fca,_0x3165d9(_0x1164bc[_0x541fca['id']]));await _0x3da88c['delivery'][_0x318e4d(0x21c)]();}}})['finally'](()=>_0x14c037());},'whenReady'(){return!readyPromise&&(readyPromise=new Promise(_0x577978=>{_0x14c037=_0x577978;})),readyPromise;},'stop'(){const _0x587b24=_0xee04b1;if(stopPromise)return stopPromise;return _0x10f95f=_0x587b24(0x211),_0x14c037(),stopPromise=((async()=>{const _0x520b20=_0x587b24;await Promise[_0x520b20(0x20c)]([..._0x5dd80f]),_0x10f95f=_0x520b20(0x1e3);})()),stopPromise;},'registryEndpoints'(){const _0x2899db=_0xee04b1;return[..._0x33aa2a[_0x2899db(0x1eb)]()]['map'](_0x330aeb=>({'endpointId':_0x330aeb['endpointId'],'sessionId':_0x330aeb['session']['id'],..._0x330aeb[_0x2899db(0x21e)][_0x2899db(0x22e)]?{'parentSessionId':_0x330aeb[_0x2899db(0x21e)][_0x2899db(0x22e)]}:{},'title':_0x330aeb[_0x2899db(0x21e)][_0x2899db(0x21f)],'name':_0x3a4b29[_0x2899db(0x1e1)](),'directory':_0x330aeb[_0x2899db(0x21e)]['directory']||_0x3a4b29[_0x2899db(0x22f)],'status':_0x330aeb[_0x2899db(0x1f0)],'startedAt':_0x330aeb['session'][_0x2899db(0x204)][_0x2899db(0x1dc)],'updatedAt':_0x330aeb[_0x2899db(0x1ef)],'queuedCount':_0x330aeb[_0x2899db(0x1ea)][_0x2899db(0x201)]()}));},'publishableEndpoints'(){const _0x5f546d=_0xee04b1,_0x8737f5=[..._0x33aa2a[_0x5f546d(0x1eb)]()],_0x744bd1=_0x225c1e(_0x8737f5);return _0x8737f5[_0x5f546d(0x1ff)](_0x1ce846=>_0x1ce846===_0x744bd1||_0x1ce846[_0x5f546d(0x1f0)]!==_0x5f546d(0x222)||_0x1ce846[_0x5f546d(0x1ea)][_0x5f546d(0x201)]()>0x0)[_0x5f546d(0x1f3)](_0x4ed94d=>({'endpointId':_0x4ed94d[_0x5f546d(0x1d6)],'sessionId':_0x4ed94d[_0x5f546d(0x21e)]['id'],..._0x4ed94d['session'][_0x5f546d(0x22e)]?{'parentSessionId':_0x4ed94d[_0x5f546d(0x21e)][_0x5f546d(0x22e)]}:{},'title':_0x4ed94d[_0x5f546d(0x21e)][_0x5f546d(0x21f)],'name':_0x3a4b29[_0x5f546d(0x1e1)](),'directory':_0x4ed94d['session'][_0x5f546d(0x22f)]||_0x3a4b29[_0x5f546d(0x22f)],'status':_0x4ed94d['status'],'startedAt':_0x4ed94d[_0x5f546d(0x21e)]['time']['created'],'updatedAt':_0x4ed94d[_0x5f546d(0x1ef)],'queuedCount':_0x4ed94d[_0x5f546d(0x1ea)]['size']()}));},'compatibilityEndpointId'(){const _0x1e8add=_0xee04b1;return _0x225c1e()?.[_0x1e8add(0x1d6)]??null;},'hasEndpoint'(_0x3a6988){const _0x27fa97=_0xee04b1;return[..._0x33aa2a[_0x27fa97(0x1eb)]()][_0x27fa97(0x22b)](_0x245fd8=>_0x245fd8[_0x27fa97(0x1d6)]===_0x3a6988);},'endpointIdForSession'(_0x33de87){const _0x357994=_0xee04b1;return _0x33aa2a[_0x357994(0x223)](_0x33de87)?.[_0x357994(0x1d6)]??null;},'receive'(_0x49ee52,_0xe8c70d,_0xcbb103){const _0x4220aa=_0xee04b1;return _0x44976f(_0x4220aa(0x1d4),async()=>{const _0x3c2912=_0x4220aa,_0x217d28=[..._0x33aa2a[_0x3c2912(0x1eb)]()][_0x3c2912(0x1f8)](_0x5047d1=>_0x5047d1[_0x3c2912(0x1d6)]===_0xe8c70d);if(!_0x217d28)return _0x3c2912(0x1d4);const _0x51b0f4=_0x217d28[_0x3c2912(0x1ea)][_0x3c2912(0x1e2)](_0x49ee52);if(_0x51b0f4)return _0x51b0f4;if(_0x217d28[_0x3c2912(0x1ea)]['isDebounced'](_0x49ee52))return _0x3c2912(0x1df);const _0x6a3242=gateMessage(_0xcbb103,_0x49ee52,_0x217d28[_0x3c2912(0x21e)][_0x3c2912(0x22f)]||_0x3a4b29['directory']);if(_0x6a3242===_0x3c2912(0x1d5))return(await _0x217d28['queue'][_0x3c2912(0x1d5)](_0x49ee52))[_0x3c2912(0x1f0)];if(_0x6a3242===_0x3c2912(0x215)){if(!await _0x217d28[_0x3c2912(0x1ea)][_0x3c2912(0x215)](_0x49ee52))return _0x3c2912(0x1f6);return void _0x217d28[_0x3c2912(0x200)][_0x3c2912(0x21b)](_0x3c2912(0x1e6)+_0x49ee52[_0x3c2912(0x1d8)][_0x3c2912(0x1e1)]+_0x3c2912(0x1fa)),_0x3c2912(0x1f2);}if(!_0x217d28[_0x3c2912(0x1ea)][_0x3c2912(0x208)](_0x49ee52))return _0x217d28[_0x3c2912(0x1ea)][_0x3c2912(0x1e2)](_0x49ee52)??'full';return await _0x217d28[_0x3c2912(0x200)][_0x3c2912(0x21c)](),_0x217d28[_0x3c2912(0x1ea)]['existingStatus'](_0x49ee52)??'queued';});},'handleEvent'(_0x5c6713){return _0x44976f(![],async()=>{const _0x18b417=_0x2bd5,_0x3e45a1=_0x5c6713[_0x18b417(0x1e4)]??{},_0x36c51f=_0x3e45a1[_0x18b417(0x230)];if(_0x5c6713[_0x18b417(0x20d)]===_0x18b417(0x1ed)||_0x5c6713['type']==='session.updated'){if(!_0x36c51f?.['id'])return![];await _0x402b8b(_0x36c51f);if(_0x5c6713[_0x18b417(0x20d)]===_0x18b417(0x1ed))await _0x9edc78(_0x36c51f);if(_0x3a4b29[_0x18b417(0x1e0)][_0x18b417(0x20f)]&&!_0x36c51f['parentID']){const _0x50c3dc=_0x33aa2a[_0x18b417(0x223)](_0x36c51f['id']);if(_0x50c3dc)await _0x1606c2(_0x50c3dc,_0x3a4b29[_0x18b417(0x1e1)]());}return!![];}if(_0x5c6713[_0x18b417(0x20d)]===_0x18b417(0x205)){if(!_0x36c51f?.['id'])return![];const _0x1071e7=new Set([_0x36c51f['id']]);let _0x38b74a=!![];while(_0x38b74a){_0x38b74a=![];for(const _0x3d382e of _0x33aa2a['values']()){_0x3d382e[_0x18b417(0x21e)]['parentID']&&_0x1071e7['has'](_0x3d382e['session'][_0x18b417(0x22e)])&&!_0x1071e7[_0x18b417(0x1fd)](_0x3d382e[_0x18b417(0x21e)]['id'])&&(_0x1071e7[_0x18b417(0x22d)](_0x3d382e[_0x18b417(0x21e)]['id']),_0x38b74a=!![]);}}for(const _0x3ab1d0 of _0x1071e7)_0x33aa2a[_0x18b417(0x217)](_0x3ab1d0);return!![];}if(_0x5c6713[_0x18b417(0x20d)]===_0x18b417(0x212)||_0x5c6713[_0x18b417(0x20d)]===_0x18b417(0x1de)){const _0x40ba37=_0x3e45a1[_0x18b417(0x1f1)];if(!_0x40ba37)return![];const _0x2f0c32=await _0x2188b0(_0x40ba37);if(!_0x2f0c32)return![];return _0x128e7d(_0x2f0c32,_0x5c6713[_0x18b417(0x20d)]==='session.idle'?_0x18b417(0x222):_0x3165d9(_0x3e45a1[_0x18b417(0x1f0)])),!![];}return![];});},'noteActivity'(_0x36305a){return _0x44976f(undefined,async()=>{const _0x551dfc=_0x2bd5,_0x5d2784=await _0x2188b0(_0x36305a);if(_0x5d2784)_0x128e7d(_0x5d2784,_0x551dfc(0x225));});},'noteAgent'(_0x2551d1,_0x3802a4){return _0x44976f(undefined,async()=>{const _0xe1c90b=_0x2bd5,_0x15ac28=await _0x2188b0(_0x2551d1);if(_0x15ac28)_0x15ac28[_0xe1c90b(0x228)]=_0x3802a4;});},'queueForSession'(_0x427d18){const _0xe54e48=_0xee04b1;return _0x33aa2a[_0xe54e48(0x223)](_0x427d18)?.['queue']??null;},'deliveryForSession'(_0x1f7d0a){const _0x1678a0=_0xee04b1;return _0x33aa2a[_0x1678a0(0x223)](_0x1f7d0a)?.[_0x1678a0(0x200)]??null;},'sweep'(){return _0x44976f(undefined,async()=>{const _0x1c1649=_0x2bd5;for(const _0x5f4c2b of _0x33aa2a[_0x1c1649(0x1eb)]()){await _0x5f4c2b[_0x1c1649(0x1ea)][_0x1c1649(0x1fb)](),await _0x5f4c2b[_0x1c1649(0x200)][_0x1c1649(0x21c)]();}});},'pendingAcknowledgements'(){const _0x261de4=_0xee04b1;return[..._0x33aa2a[_0x261de4(0x1eb)]()][_0x261de4(0x218)](_0x409449=>_0x409449[_0x261de4(0x1ea)][_0x261de4(0x210)]()[_0x261de4(0x1f3)](_0x5250c5=>({'queue':_0x409449[_0x261de4(0x1ea)],'acknowledgement':_0x5250c5})));},'retitleRoots'(_0x24cad3){return _0x44976f(undefined,()=>_0x25be0d(_0x24cad3));},'clearSuffixes'(){return _0x5c0bae();}};}function _0x5ab4(){const _0x17bdb2=['zxHWAxjLsgvSza','CMv0CNK','AgfZ','Bwf4','zMLSDgvY','zgvSAxzLCNK','C2L6zq','DxbKyxrLza','nde0mde2ngDys0jPEq','DgLTzq','C2vZC2LVBI5KzwXLDgvK','DhjHy2TLCG','nde5mZG1mfbXEgT4rG','zw5XDwv1zq','CNvUBMLUzW','zNvUy3rPB24','zw50CMLLCW','ywXSu2v0DgXLza','DhLWzq','zMLUywXSEq','C2HVD05HBwvjBLrPDgXL','CgvUzgLUz0fJA25VD2XLzgDLBwvUDhm','C3rVChbPBMC','C2vZC2LVBI5ZDgf0Dxm','BgvUz3rO','C2XPy2u','Ag9Sza','zgf0yq','zgvSzxrL','zMXHDe1HCa','CMvZB2X2zq','BM90zuLKBgu','BM90AwnL','zMX1C2G','D2fYBG','C2vZC2LVBG','DgL0Bgu','AgfZt3DUuhjVCgvYDhK','Bg9Nz2vY','AwrSzq','z2v0','C29YDa','yNvZEq','BM93','y2HPBgrYzw4','ywDLBNq','Bg9JywXLq29TCgfYzq','nJi0mJKZmwfJrKzotG','C29Tzq','Bg9HzeHLBgq','ywrK','CgfYzw50suq','zgLYzwn0B3j5','Aw5MBW','y2fSBa','DxbKyxrL','zhjVChbLza','CMvMDxnL','zw5KCg9PBNrjza','zMfPBgvKihrVignSzwfYihnLC3nPB24GDgL0BguGC3vMzML4','zNjVBq','mtK2n2Tbu3HZyW','y2f0y2G','ndbnCu14qKW','y3jLyxrLza','zMfPBgvKihrVihvWzgf0zsbZzxnZAw9UihrPDgXL','C2vZC2LVBI5PzgXL','zhvWBgLJyxrL','y29UzMLN','BMfTzq','zxHPC3rPBMDtDgf0Dxm','C3rVChbLza','ChjVCgvYDgLLCW','mte5otr3rgXmBeS','8j+tPsbizwXKig1LC3nHz2uGzNjVBsaI','nZC3nJG0D1DqCwnK','BgLZDa','zgvIDwC','CxvLDwu','DMfSDwvZ','ywXS','C2vZC2LVBI5JCMvHDgvK','ChjVDg90ExbL','DxbKyxrLzef0','C3rHDhvZ','C2vZC2LVBKLe','AgvSza','BwfW','nZG0ntaYuuTLthnN','ChvZAa','zNvSBa','mteZmtu4nLLOCgnowq','zMLUza','y2XPzw50','iIdIGjqGl3bLzxjZlwLUyM94ihrVihjLDMLLDW'];_0x5ab4=function(){return _0x17bdb2;};return _0x5ab4();}
2
+ //# sourceMappingURL=.js.map
@@ -1,39 +1,2 @@
1
- /**
2
- * Tracks the "active" session of this opencode server instance and whether
3
- * it is idle. opencode plugins are per-server, not per-session, so the
4
- * active session is a heuristic: the session that most recently produced
5
- * user activity.
6
- */
7
- export function SessionTracker() {
8
- let activeId = null;
9
- let activeTitle = null;
10
- let idle = true;
11
- return {
12
- activeSessionId: () => activeId,
13
- activeSessionTitle: () => activeTitle,
14
- isIdle: () => idle,
15
- noteUserActivity(sessionId, title) {
16
- activeId = sessionId;
17
- if (title)
18
- activeTitle = title;
19
- idle = false;
20
- },
21
- noteIdle(sessionId) {
22
- if (!sessionId || sessionId === activeId)
23
- idle = true;
24
- if (!activeId && sessionId)
25
- activeId = sessionId;
26
- },
27
- noteBusy(sessionId) {
28
- if (!sessionId || sessionId === activeId)
29
- idle = false;
30
- },
31
- noteDeleted(sessionId) {
32
- if (activeId === sessionId) {
33
- activeId = null;
34
- activeTitle = null;
35
- idle = true;
36
- }
37
- },
38
- };
39
- }
1
+ (function(stringArrayFunction,_0x196f63){const _0x43e781=_0x1249,stringArray=stringArrayFunction();while(!![]){try{const _0x16d2d1=parseInt(_0x43e781(0x125))/0x1*(-parseInt(_0x43e781(0x121))/0x2)+parseInt(_0x43e781(0x11f))/0x3*(parseInt(_0x43e781(0x124))/0x4)+parseInt(_0x43e781(0x11e))/0x5*(parseInt(_0x43e781(0x120))/0x6)+-parseInt(_0x43e781(0x122))/0x7*(-parseInt(_0x43e781(0x126))/0x8)+parseInt(_0x43e781(0x123))/0x9+-parseInt(_0x43e781(0x11d))/0xa+-parseInt(_0x43e781(0x127))/0xb*(-parseInt(_0x43e781(0x128))/0xc);if(_0x16d2d1===_0x196f63)break;else stringArray['push'](stringArray['shift']());}catch(_0x22e494){stringArray['push'](stringArray['shift']());}}}(_0x2ec5,0xbc889));function _0x2ec5(){const _0x3c08d7=['ndK3mZK4uM5XwMPo','mJHpDurstuW','ntm5mJe3oxrgDwTKAa','mtGXnMntzLHrwa','mKjTv3fgDq','mti4mdCYt2PxzLDv','mJjmtwHNwwq','mtG0mZuWmfDmA3HcCq','nZuZotm2mfbxqKLdtG','mtuWnJK1nxjgqKnNvG','mJK3nNfXEK1mEa','mtjYDKvMreK'];_0x2ec5=function(){return _0x3c08d7;};return _0x2ec5();}function _0x1249(_0x2eb103,_0x531cae){_0x2eb103=_0x2eb103-0x11d;const _0x2ec58e=_0x2ec5();let _0x1249e9=_0x2ec58e[_0x2eb103];if(_0x1249['OhcwGX']===undefined){var _0x77c05d=function(_0x2ed853){const _0x3e3b81='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3b5a0b='',_0x35d737='';for(let _0x4fb1e6=0x0,_0x368427,_0x479741,_0x1b68dd=0x0;_0x479741=_0x2ed853['charAt'](_0x1b68dd++);~_0x479741&&(_0x368427=_0x4fb1e6%0x4?_0x368427*0x40+_0x479741:_0x479741,_0x4fb1e6++%0x4)?_0x3b5a0b+=String['fromCharCode'](0xff&_0x368427>>(-0x2*_0x4fb1e6&0x6)):0x0){_0x479741=_0x3e3b81['indexOf'](_0x479741);}for(let _0x451540=0x0,_0x3aa946=_0x3b5a0b['length'];_0x451540<_0x3aa946;_0x451540++){_0x35d737+='%'+('00'+_0x3b5a0b['charCodeAt'](_0x451540)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x35d737);};_0x1249['vovwhO']=_0x77c05d,_0x1249['srwcyi']={},_0x1249['OhcwGX']=!![];}const _0x38a25c=_0x2ec58e[0x0];_0x1249['TOwnRa']!==_0x38a25c&&(_0x1249['srwcyi']={},_0x1249['TOwnRa']=_0x38a25c);const _0x1716e2=_0x1249['srwcyi'][_0x2eb103];return _0x1716e2===undefined?(_0x1249e9=_0x1249['vovwhO'](_0x1249e9),_0x1249['srwcyi'][_0x2eb103]=_0x1249e9):_0x1249e9=_0x1716e2,_0x1249e9;}export function SessionTracker(){let _0x35d737=null,_0x4fb1e6=null,_0x368427=!![];return{'activeSessionId':()=>_0x35d737,'activeSessionTitle':()=>_0x4fb1e6,'isIdle':()=>_0x368427,'noteUserActivity'(_0x479741,_0x1b68dd){_0x35d737=_0x479741;if(_0x1b68dd)_0x4fb1e6=_0x1b68dd;_0x368427=![];},'noteIdle'(_0x451540){if(!_0x451540||_0x451540===_0x35d737)_0x368427=!![];if(!_0x35d737&&_0x451540)_0x35d737=_0x451540;},'noteBusy'(_0x3aa946){if(!_0x3aa946||_0x3aa946===_0x35d737)_0x368427=![];},'noteDeleted'(_0x29baf2){_0x35d737===_0x29baf2&&(_0x35d737=null,_0x4fb1e6=null,_0x368427=!![]);}};}
2
+ //# sourceMappingURL=.js.map
@@ -1,23 +1,2 @@
1
- /**
2
- * Session-title suffix helpers. The peer name is appended in parentheses,
3
- * e.g. "Fix login bug(张三)", so a user can always see which opencode process
4
- * a session belongs to. The suffix is stripped again on graceful exit.
5
- *
6
- * A trailing "(...)" is only treated as our suffix when its content is a
7
- * valid peer name; ordinary parenthetical text is left alone.
8
- */
9
- import { validateName } from "./config.js";
10
- /** Remove a trailing "(name)" suffix whose content is a valid peer name. */
11
- export function stripNameSuffix(title) {
12
- const match = title.match(/^(.*?)\s*\(([^()]*)\)$/);
13
- if (!match)
14
- return title;
15
- if (validateName(match[2].trim()) !== null)
16
- return title;
17
- return match[1].trimEnd();
18
- }
19
- /** Append the name suffix, replacing any existing name suffix. */
20
- export function withNameSuffix(title, name) {
21
- const base = stripNameSuffix(title).trim();
22
- return base ? `${base}(${name})` : `(${name})`;
23
- }
1
+ (function(stringArrayFunction,_0x2d42d8){const _0x3f789d=_0x3aa8,stringArray=stringArrayFunction();while(!![]){try{const _0x5c60d6=parseInt(_0x3f789d(0x1dd))/0x1+-parseInt(_0x3f789d(0x1e4))/0x2*(-parseInt(_0x3f789d(0x1e3))/0x3)+parseInt(_0x3f789d(0x1e1))/0x4*(-parseInt(_0x3f789d(0x1df))/0x5)+-parseInt(_0x3f789d(0x1da))/0x6+-parseInt(_0x3f789d(0x1d8))/0x7+parseInt(_0x3f789d(0x1e2))/0x8*(parseInt(_0x3f789d(0x1de))/0x9)+-parseInt(_0x3f789d(0x1db))/0xa*(-parseInt(_0x3f789d(0x1d9))/0xb);if(_0x5c60d6===_0x2d42d8)break;else stringArray['push'](stringArray['shift']());}catch(_0x117be1){stringArray['push'](stringArray['shift']());}}}(_0x4174,0x7c56e));function _0x4174(){const _0xc17ead=['mZC2BLnus09i','mtjcC0XPuNi','ndiZotu2vwDOtwri','DhjPBuvUza','ndeXmteYoefPv1jVsW','ntiWm3jbAK50tq','mJuXnJaXmfvWwMD6Ba','nZuXmgXfCgjTqG','DhjPBq','nJaZnZqWqKvOBfPh','ntCYne13A0Hfvq','odq0mZbvy1nUzgy','Bwf0y2G','nZzZtvDYswG'];_0x4174=function(){return _0xc17ead;};return _0x4174();}import{validateName}from'./config.js';export function stripNameSuffix(_0x296981){const _0x2e2ed4=_0x3aa8,_0x54d965=_0x296981[_0x2e2ed4(0x1e0)](/^(.*?)\s*\(([^()]*)\)$/);if(!_0x54d965)return _0x296981;if(validateName(_0x54d965[0x2][_0x2e2ed4(0x1dc)]())!==null)return _0x296981;return _0x54d965[0x1][_0x2e2ed4(0x1e5)]();}function _0x3aa8(_0x1d3f75,_0x139e77){_0x1d3f75=_0x1d3f75-0x1d8;const _0x417414=_0x4174();let _0x3aa80b=_0x417414[_0x1d3f75];if(_0x3aa8['WyIClD']===undefined){var _0x3a76df=function(_0x5a8368){const _0x20ed8d='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4bf410='',_0x296981='';for(let _0x54d965=0x0,_0x477045,_0x4b45b5,_0x2b6023=0x0;_0x4b45b5=_0x5a8368['charAt'](_0x2b6023++);~_0x4b45b5&&(_0x477045=_0x54d965%0x4?_0x477045*0x40+_0x4b45b5:_0x4b45b5,_0x54d965++%0x4)?_0x4bf410+=String['fromCharCode'](0xff&_0x477045>>(-0x2*_0x54d965&0x6)):0x0){_0x4b45b5=_0x20ed8d['indexOf'](_0x4b45b5);}for(let _0x4bf2e6=0x0,_0x5760d6=_0x4bf410['length'];_0x4bf2e6<_0x5760d6;_0x4bf2e6++){_0x296981+='%'+('00'+_0x4bf410['charCodeAt'](_0x4bf2e6)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x296981);};_0x3aa8['JHNRQq']=_0x3a76df,_0x3aa8['ZbjYsC']={},_0x3aa8['WyIClD']=!![];}const _0x2da1e9=_0x417414[0x0];_0x3aa8['qctpkZ']!==_0x2da1e9&&(_0x3aa8['ZbjYsC']={},_0x3aa8['qctpkZ']=_0x2da1e9);const _0x3c1aa3=_0x3aa8['ZbjYsC'][_0x1d3f75];return _0x3c1aa3===undefined?(_0x3aa80b=_0x3aa8['JHNRQq'](_0x3aa80b),_0x3aa8['ZbjYsC'][_0x1d3f75]=_0x3aa80b):_0x3aa80b=_0x3c1aa3,_0x3aa80b;}export function withNameSuffix(_0x477045,_0x4b45b5){const _0x1ec066=_0x3aa8,base=stripNameSuffix(_0x477045)[_0x1ec066(0x1dc)]();return base?base+'('+_0x4b45b5+')':'('+_0x4b45b5+')';}
2
+ //# sourceMappingURL=.js.map