@agimon-ai/po-session 0.0.0-alpha.189 → 0.0.0-alpha.190
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/dist/extensions/server.cjs +67 -2
- package/dist/extensions/server.cjs.map +1 -1
- package/dist/extensions/server.mjs +67 -2
- package/dist/extensions/server.mjs.map +1 -1
- package/dist/index.cjs +7 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +10 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +7 -5
- package/dist/index.mjs.map +1 -1
- package/dist/po-runtime-identity.json +1 -1
- package/dist/{type-_AY3ZJm0.cjs → type-CTnURqO7.cjs} +67 -8
- package/dist/type-CTnURqO7.cjs.map +1 -0
- package/dist/{type-AJ2dhlAr.mjs → type-CsOWjmfl.mjs} +68 -9
- package/dist/type-CsOWjmfl.mjs.map +1 -0
- package/package.json +9 -9
- package/src/prompts/codemode-how-to-network/SKILL.md +6 -1
- package/dist/type-AJ2dhlAr.mjs.map +0 -1
- package/dist/type-_AY3ZJm0.cjs.map +0 -1
|
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
const require_type = require("../type-
|
|
5
|
+
const require_type = require("../type-CTnURqO7.cjs");
|
|
6
6
|
let _agimon_ai_po_core_backgroundWork = require("@agimon-ai/po-core/backgroundWork");
|
|
7
7
|
let typebox = require("typebox");
|
|
8
8
|
let _agimon_ai_po_core_hubChannel = require("@agimon-ai/po-core/hubChannel");
|
|
@@ -349,14 +349,68 @@ async function recorded(run, name, input, call) {
|
|
|
349
349
|
throw error;
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
|
+
const OUT_OF_SCOPE = "Session is outside your communication scope.";
|
|
353
|
+
/** A session name long enough to recognise and short enough to fit the approval card title. */
|
|
354
|
+
const TITLE_NAME_MAX = 80;
|
|
355
|
+
const MESSAGE_PREVIEW_MAX = 300;
|
|
356
|
+
/**
|
|
357
|
+
* Asks the person before messaging a live session whose `@session:` mention expired when this session compacted.
|
|
358
|
+
* Every other target runs without asking: a live mention or a shared group passes, and anything else is refused.
|
|
359
|
+
*/
|
|
360
|
+
function expiredMentionApproval(operations, verb, parse) {
|
|
361
|
+
return {
|
|
362
|
+
requirement: "human",
|
|
363
|
+
applies: (raw) => {
|
|
364
|
+
const to = raw?.to;
|
|
365
|
+
return typeof to === "string" && to !== "" && operations.mentionApprovalTarget?.(to) !== void 0;
|
|
366
|
+
},
|
|
367
|
+
resolve: ([raw]) => {
|
|
368
|
+
const { to, text, urgent } = parse(raw);
|
|
369
|
+
const target = operations.mentionApprovalTarget?.(to);
|
|
370
|
+
if (target === void 0) throw new Error(OUT_OF_SCOPE);
|
|
371
|
+
return [{
|
|
372
|
+
to: target.sessionId,
|
|
373
|
+
text,
|
|
374
|
+
...urgent ? { urgent } : {}
|
|
375
|
+
}];
|
|
376
|
+
},
|
|
377
|
+
describe: (raw) => {
|
|
378
|
+
const { to, text } = parse(raw);
|
|
379
|
+
const name = operations.mentionApprovalTarget?.(to)?.name ?? to;
|
|
380
|
+
return {
|
|
381
|
+
source: "Sessions",
|
|
382
|
+
title: `Let this session ${verb} ${name.slice(0, TITLE_NAME_MAX)} again`,
|
|
383
|
+
summary: "The earlier @session: mention expired when this session compacted. Approving restores access until the next compaction and delivers this message.",
|
|
384
|
+
details: [{
|
|
385
|
+
label: "Session",
|
|
386
|
+
value: name
|
|
387
|
+
}, {
|
|
388
|
+
label: "Message",
|
|
389
|
+
value: text.slice(0, MESSAGE_PREVIEW_MAX)
|
|
390
|
+
}]
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
}
|
|
352
395
|
/** Messaging between sessions on this host and linked hosts, with Team intercom's send, ask, reply and pending. */
|
|
353
396
|
function createNetworkNamespace(options) {
|
|
354
397
|
(0, _agimon_ai_po_core_codemode.assertCodemodeNamespaceName)("network");
|
|
355
398
|
const { operations } = options;
|
|
399
|
+
const parseAsk = (raw) => {
|
|
400
|
+
const { to, text } = require_type.fields(raw, ["to", "text"]);
|
|
401
|
+
return {
|
|
402
|
+
to,
|
|
403
|
+
text
|
|
404
|
+
};
|
|
405
|
+
};
|
|
356
406
|
return {
|
|
357
407
|
name: "network",
|
|
358
408
|
summary: "Message sessions on this host and linked hosts: send, ask with a tracked reply, answer questions, and keep a coordinator logbook.",
|
|
359
409
|
portable: true,
|
|
410
|
+
...operations.mentionApprovalTarget === void 0 ? {} : { approval: {
|
|
411
|
+
send: expiredMentionApproval(operations, "message", (raw) => parseSend(raw, operations.lanes === true)),
|
|
412
|
+
...operations.ask ? { ask: expiredMentionApproval(operations, "ask", parseAsk) } : {}
|
|
413
|
+
} },
|
|
360
414
|
declarations: `declare const network: {
|
|
361
415
|
list(): Promise<unknown>;
|
|
362
416
|
${operations.lanes ? `/** Queued: arrives in one digest when the recipient's run ends. urgent joins its running turn. Both are budgeted per session. */
|
|
@@ -395,11 +449,13 @@ function createNetworkNamespace(options) {
|
|
|
395
449
|
methods.send = (raw) => recorded(run, "network.send", raw, async () => {
|
|
396
450
|
check();
|
|
397
451
|
const { to, text, urgent } = parseSend(raw, operations.lanes === true);
|
|
452
|
+
if (run.approvedCall !== void 0) operations.restoreMention?.(to);
|
|
398
453
|
return require_type.detach(await (urgent ? operations.send(to, text, signal, { urgent }) : operations.send(to, text, signal)));
|
|
399
454
|
});
|
|
400
455
|
if (operations.ask) methods.ask = (raw) => recorded(run, "network.ask", raw, async () => {
|
|
401
456
|
check();
|
|
402
|
-
const { to, text } =
|
|
457
|
+
const { to, text } = parseAsk(raw);
|
|
458
|
+
if (run.approvedCall !== void 0) operations.restoreMention?.(to);
|
|
403
459
|
return require_type.detach(await operations.ask(to, text, signal));
|
|
404
460
|
});
|
|
405
461
|
if (operations.reply) methods.reply = (raw) => recorded(run, "network.reply", raw, async () => {
|
|
@@ -663,6 +719,14 @@ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)((plug
|
|
|
663
719
|
if (event.aborted !== true) await inbox.settled();
|
|
664
720
|
}
|
|
665
721
|
});
|
|
722
|
+
const compacted = agent.registerHook({
|
|
723
|
+
event: "session_compact",
|
|
724
|
+
handle: (event) => {
|
|
725
|
+
if (event.status !== "completed") return;
|
|
726
|
+
sessionService.mentions?.expire(agent.context.sessionId);
|
|
727
|
+
service.reauthorize?.().catch((error) => pluginContext.host.context.onNotice(`Delivery reauthorization failed: ${String(error)}`));
|
|
728
|
+
}
|
|
729
|
+
});
|
|
666
730
|
inbox.note();
|
|
667
731
|
await require_type.rearmAskReminders(service, (text, requestId, details) => remindSession(agent, text, requestId, details), (error) => pluginContext.host.context.onNotice(`Ask reminder failed: ${String(error)}`));
|
|
668
732
|
logbookWake = require_type.createLogbookWake({
|
|
@@ -727,6 +791,7 @@ var root_server_default = (0, _agimon_ai_po_core_extensionFile.defineRoot)((plug
|
|
|
727
791
|
return async () => {
|
|
728
792
|
unregister();
|
|
729
793
|
settledInbox.dispose();
|
|
794
|
+
compacted.dispose();
|
|
730
795
|
inbox.close();
|
|
731
796
|
logbookWake?.close();
|
|
732
797
|
releaseGroups?.();
|