@agimon-ai/po-wake 0.0.1-alpha.27 → 0.0.1-alpha.28

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 CHANGED
@@ -26,15 +26,28 @@ Only sessions marked as bots are woken. After an uncovered turn, Wake uses a sep
26
26
 
27
27
  lists every record for the session with `[covers]` and `[due]` marks.
28
28
 
29
- ## Help and authoring
29
+ ## Skills and exports
30
30
 
31
- The package publishes `src/prompts/help-how-to-wake/SKILL.md` through a named resource route and `llms.txt`. Keep additional guides package-owned and in the publish allowlist; do not export Markdown or copy it into `dist`.
31
+ The package ships three skill guides:
32
32
 
33
- The build generates host entries from named `src/extensions` routes. For extension layout, scoped services and lifecycle obligations, follow [Po architecture](https://github.com/AgiFlow/po/blob/main/docs/architecture.md#extensions).
33
+ - `codemode-how-to-wake`: code-mode usage for the bot `wake` namespace (`wake.schedule` and related operations).
34
+ - `codemode-how-to-wake-admin`: Help-mode usage for `wakeAdmin` (including `wakeAdmin.setPlanner`).
35
+ - `help-how-to-wake`: Help-mode guide explaining wake records, coverage, and bot reminders.
36
+
37
+ Subpath exports:
38
+
39
+ - `@agimon-ai/po-wake/wakeRecords`: exports `PO_WAKE_RECORDS_SERVICE`, `readPoWakeRecords`, `PoWakeRecordsService`, `WakeProvider`, `WakeRecord`, and `WakeSlot` for plugins contributing wake records.
40
+ - `@agimon-ai/po-wake/apiContracts`: typed HTTP API contracts.
41
+ - `@agimon-ai/po-wake/extensions/server`: server extension entry point.
34
42
 
35
43
  ## Development
36
44
 
37
- Run the package's `build`, `typecheck`, `test`, and `lint` scripts from this directory. Use `npm pack --dry-run` to inspect published contents before release.
45
+ ```bash
46
+ pnpm build
47
+ pnpm typecheck
48
+ pnpm test
49
+ pnpm lint
50
+ ```
38
51
 
39
52
  ## License
40
53
 
@@ -2,6 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
+ const require_type = require("../type-CxLUGacY.cjs");
5
6
  const require_wakeRecords = require("../wakeRecords-CfkvJoto.cjs");
6
7
  let _agimon_ai_po_core_serverPlugin = require("@agimon-ai/po-core/serverPlugin");
7
8
  let _agimon_ai_po_core_extensionFile = require("@agimon-ai/po-core/extensionFile");
@@ -453,6 +454,8 @@ async function planWake(input) {
453
454
  signal,
454
455
  tools: plannerTools(periodMs)
455
456
  };
457
+ if (input.authorize && !await input.authorize()) return { kind: "unavailable" };
458
+ signal.throwIfAborted();
456
459
  return parseWakePlannerResult(await abortable(execution.toolCompletion.complete(model, request), signal), periodMs);
457
460
  }
458
461
  //#endregion
@@ -612,7 +615,8 @@ function createWake(options) {
612
615
  const prompt = row.prompt?.trim().slice(0, SELF_WAKE_MAX_PROMPT);
613
616
  if (!prompt) return {};
614
617
  if (!live() || !await current() || !live()) return { retry: true };
615
- const receipt = await session.admitMessage({
618
+ const admission = options.admission?.();
619
+ const message = {
616
620
  type: WAKE_NUDGE_TYPE,
617
621
  text: [
618
622
  prompt,
@@ -621,7 +625,9 @@ function createWake(options) {
621
625
  ].join("\n"),
622
626
  display: true,
623
627
  details: { origin: row.origin }
624
- }, "followUp", row.requestId);
628
+ };
629
+ const receipt = admission ? await admission.submit(message, row.requestId) : await session.admitMessage(message, "followUp", row.requestId);
630
+ if (receipt === false) return {};
625
631
  if (!receipt) return { retry: true };
626
632
  await journal(session, "self", "delivered");
627
633
  if (live()) await timer.schedule("reminder", now() + horizonOf(bot));
@@ -661,11 +667,14 @@ function createWake(options) {
661
667
  routineAdmission = row.slot === "routine";
662
668
  let receipt;
663
669
  try {
664
- receipt = await session.admitMessage({
670
+ const admission = options.admission?.();
671
+ const message = {
665
672
  type: WAKE_NUDGE_TYPE,
666
673
  text,
667
674
  display: true
668
- }, "followUp", row.requestId);
675
+ };
676
+ receipt = admission ? await admission.submit(message, row.requestId) : await session.admitMessage(message, "followUp", row.requestId);
677
+ if (receipt === false) return {};
669
678
  if (!receipt) return { retry: true };
670
679
  await journal(session, row.slot, "delivered");
671
680
  if (row.slot === "routine") {
@@ -704,7 +713,8 @@ function createWake(options) {
704
713
  timeZone: options.timeZone?.(),
705
714
  now: now(),
706
715
  signal: stop,
707
- timeoutMs: options.plannerTimeoutMs
716
+ timeoutMs: options.plannerTimeoutMs,
717
+ authorize: async () => (!options.admission?.() || await options.admission().authorize()) && live()
708
718
  });
709
719
  if (decision.kind !== "schedule") return decision.kind;
710
720
  const latest = await session.customSnapshot(_agimon_ai_po_core_headless.AGENT_SETTLED_ENTRY_TYPE);
@@ -1146,6 +1156,7 @@ const NAMESPACE_SOURCE = "@agimon-ai/po-wake";
1146
1156
  function createWakeSessionState(agent, root, owner) {
1147
1157
  const providers = [];
1148
1158
  let profileRuntime;
1159
+ let admission;
1149
1160
  let translate = (_key, fallback, vars) => (0, _agimon_ai_po_core_locale.formatMessage)(fallback, vars);
1150
1161
  const t = (key, fallback, vars) => translate(key, fallback, vars);
1151
1162
  const lifetime = new AbortController();
@@ -1165,6 +1176,7 @@ function createWakeSessionState(agent, root, owner) {
1165
1176
  }
1166
1177
  };
1167
1178
  const wake = createWake({
1179
+ admission: () => admission,
1168
1180
  bot: () => root.botSession(owner),
1169
1181
  providers: () => providers,
1170
1182
  session: () => agent?.context.session,
@@ -1185,7 +1197,9 @@ function createWakeSessionState(agent, root, owner) {
1185
1197
  if (lifetime.signal.aborted || !root.botSession(owner)) return;
1186
1198
  let failed = false;
1187
1199
  try {
1200
+ if (admission && !await admission.authorize()) return;
1188
1201
  await ready();
1202
+ if (admission && !await admission.authorize()) return;
1189
1203
  failed = await operation() === "unavailable";
1190
1204
  } catch {
1191
1205
  failed = true;
@@ -1296,11 +1310,20 @@ function createWakeSessionState(agent, root, owner) {
1296
1310
  (context) => {
1297
1311
  const fiber = context.inject([_agimon_ai_po_core_serverPlugin.PO_SERVER_SCOPE_SERVICE], (bound) => {
1298
1312
  const scope = (0, _agimon_ai_po_core_serverPlugin.requirePoServerScope)(bound);
1313
+ admission = scope.resolve(require_type.WAKE_ADMISSION_CONTRACT);
1299
1314
  translate = (key, fallback, vars) => scope.resolve(_agimon_ai_po_core_locale.PO_LANG_CONTRACT)?.t((0, _agimon_ai_po_core_locale.readPoPersonLocale)(context)?.read(), key, fallback, vars) ?? (0, _agimon_ai_po_core_locale.formatMessage)(fallback, vars);
1315
+ const detachRefusal = admission?.onRefused?.(async () => {
1316
+ await agent?.context.client.notify({
1317
+ body: t("wake.notice.unauthorized", "Po could not authorize the bot wake nudge."),
1318
+ level: "warning"
1319
+ });
1320
+ });
1300
1321
  timeZone = () => (0, _agimon_ai_po_core_personTimeZone.readPoPersonTimeZone)(context)?.read()?.timeZone;
1301
1322
  return () => {
1302
1323
  translate = (_key, fallback, vars) => (0, _agimon_ai_po_core_locale.formatMessage)(fallback, vars);
1303
1324
  timeZone = () => void 0;
1325
+ detachRefusal?.();
1326
+ admission = void 0;
1304
1327
  };
1305
1328
  });
1306
1329
  return () => fiber.dispose();
@@ -1339,7 +1362,9 @@ function createWakeSessionState(agent, root, owner) {
1339
1362
  }))
1340
1363
  }));
1341
1364
  const detach = root.attach(owner.sessionId, () => check(() => wake.recover()), async (row, current) => {
1365
+ if (admission && !await admission.authorize()) return {};
1342
1366
  await ready();
1367
+ if (admission && !await admission.authorize()) return {};
1343
1368
  return wake.due(row, current);
1344
1369
  });
1345
1370
  return () => {