@agimon-ai/po-core 0.0.0-alpha.73 → 0.0.0-alpha.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/headlessHub.cjs +30 -25
  2. package/dist/headlessHub.cjs.map +1 -1
  3. package/dist/headlessHub.d.mts +1 -0
  4. package/dist/headlessHub.d.mts.map +1 -1
  5. package/dist/headlessHub.mjs +26 -21
  6. package/dist/headlessHub.mjs.map +1 -1
  7. package/dist/headlessServer.cjs +4 -0
  8. package/dist/headlessServer.cjs.map +1 -1
  9. package/dist/headlessServer.d.mts.map +1 -1
  10. package/dist/headlessServer.mjs +4 -0
  11. package/dist/headlessServer.mjs.map +1 -1
  12. package/dist/src/schemas/headless.cjs.map +1 -1
  13. package/dist/src/schemas/headless.d.mts +13 -0
  14. package/dist/src/schemas/headless.d.mts.map +1 -1
  15. package/dist/src/schemas/headless.mjs.map +1 -1
  16. package/dist/src/server/directHarnessRuntime.cjs +66 -129
  17. package/dist/src/server/directHarnessRuntime.cjs.map +1 -1
  18. package/dist/src/server/directHarnessRuntime.d.mts.map +1 -1
  19. package/dist/src/server/directHarnessRuntime.mjs +55 -118
  20. package/dist/src/server/directHarnessRuntime.mjs.map +1 -1
  21. package/dist/src/services/durableResumeSnapshots/docs.cjs +49 -0
  22. package/dist/src/services/durableResumeSnapshots/docs.cjs.map +1 -0
  23. package/dist/src/services/durableResumeSnapshots/docs.mjs +48 -0
  24. package/dist/src/services/durableResumeSnapshots/docs.mjs.map +1 -0
  25. package/dist/src/services/durableResumeSnapshots/index.cjs +365 -0
  26. package/dist/src/services/durableResumeSnapshots/index.cjs.map +1 -0
  27. package/dist/src/services/durableResumeSnapshots/index.mjs +365 -0
  28. package/dist/src/services/durableResumeSnapshots/index.mjs.map +1 -0
  29. package/dist/src/services/durableResumeSnapshots/type.d.mts +27 -0
  30. package/dist/src/services/durableResumeSnapshots/type.d.mts.map +1 -0
  31. package/dist/src/services/piExtensionHost/index.cjs +23 -15
  32. package/dist/src/services/piExtensionHost/index.cjs.map +1 -1
  33. package/dist/src/services/piExtensionHost/index.mjs +24 -16
  34. package/dist/src/services/piExtensionHost/index.mjs.map +1 -1
  35. package/dist/src/systems/child/adapters/headlessChildSessionService.cjs +1 -1
  36. package/dist/src/systems/child/adapters/headlessChildSessionService.cjs.map +1 -1
  37. package/dist/src/systems/child/adapters/headlessChildSessionService.mjs +1 -1
  38. package/dist/src/systems/child/adapters/headlessChildSessionService.mjs.map +1 -1
  39. package/dist/src/systems/main/adapters/headlessSessionHost.cjs +3 -1
  40. package/dist/src/systems/main/adapters/headlessSessionHost.cjs.map +1 -1
  41. package/dist/src/systems/main/adapters/headlessSessionHost.mjs +3 -1
  42. package/dist/src/systems/main/adapters/headlessSessionHost.mjs.map +1 -1
  43. package/dist/src/types/server/directHarnessRuntime.d.mts +16 -0
  44. package/dist/src/types/server/directHarnessRuntime.d.mts.map +1 -1
  45. package/dist/src/web/types/template.d.mts +5 -0
  46. package/dist/src/web/types/template.d.mts.map +1 -1
  47. package/package.json +4 -4
@@ -4,18 +4,17 @@ const require_approvalPrompt = require("./src/schemas/approvalPrompt.cjs");
4
4
  require("./src/schemas/approval.cjs");
5
5
  const require_docs = require("./src/services/durableSession/docs.cjs");
6
6
  const require_profileIdentity = require("./src/schemas/profileIdentity.cjs");
7
- const require_index = require("./src/services/transcriptPages/index.cjs");
8
7
  const require_hubChannel = require("./src/schemas/hubChannel.cjs");
9
8
  const require_home = require("./src/schemas/home.cjs");
10
9
  require("./src/schemas/notification.cjs");
11
10
  require("./src/schemas/sessionProtocol.cjs");
12
- require("./src/constants/agentSettled.cjs");
11
+ const require_agentSettled = require("./src/constants/agentSettled.cjs");
13
12
  const require_pluginProtocol = require("./src/schemas/pluginProtocol.cjs");
14
13
  require("./pluginProtocol.cjs");
15
- const require_index$1 = require("./src/services/serverHost/index.cjs");
14
+ const require_index = require("./src/services/serverHost/index.cjs");
16
15
  const require_serverScope = require("./src/server/serverScope.cjs");
17
16
  require("./serverPlugin.cjs");
18
- const require_index$2 = require("./src/services/sessionGitStatus/index.cjs");
17
+ const require_index$1 = require("./src/services/sessionGitStatus/index.cjs");
19
18
  let node_crypto = require("node:crypto");
20
19
  node_crypto = require_runtime.__toESM(node_crypto, 1);
21
20
  let dist_interop_chordContext_mjs = require("../dist/interop/chordContext.mjs");
@@ -30,18 +29,26 @@ const ICON_VERSION_LENGTH = 12;
30
29
  const ICON_DATA_URL = /^data:([a-z/+.-]+);base64,([A-Za-z0-9+/=]+)$/u;
31
30
  /** A rail line, not a log: a longer label is cut to this. */
32
31
  const MAX_ACTIVITY_LABEL = 80;
33
- /**
34
- * When a reopened session last settled, from the marker its runtime journals at every run end.
35
- * Without it a session with a whole history would read as fresh until its next turn.
36
- */
37
- async function lastSettledAt(host) {
32
+ /** Read only write-time proof of prior work. Missing coverage is not an empty history. */
33
+ async function storedHistory(host) {
34
+ let settledAt;
38
35
  try {
39
- const entry = await require_index.findNewestDurableEntry(host.runtime.scanEntries.bind(host.runtime), dist_interop_chordContext_mjs.BACKGROUND_CONTEXT, (entry) => entry.type === "custom" && entry.customType === "po.agent-settled");
40
- const data = entry?.type === "custom" ? entry.data : void 0;
41
- return typeof data?.timestamp === "number" && Number.isFinite(data.timestamp) ? new Date(data.timestamp).toISOString() : void 0;
42
- } catch {
43
- return;
44
- }
36
+ const snapshot = await host.runtime.customSnapshot(require_agentSettled.AGENT_SETTLED_ENTRY_TYPE);
37
+ const data = snapshot.entry?.data;
38
+ if (snapshot.available && typeof data?.timestamp === "number" && Number.isFinite(data.timestamp)) {
39
+ const date = new Date(data.timestamp);
40
+ if (Number.isFinite(date.getTime())) settledAt = date.toISOString();
41
+ }
42
+ } catch {}
43
+ if (settledAt !== void 0) return {
44
+ everPrompted: true,
45
+ lastSettledAt: settledAt
46
+ };
47
+ try {
48
+ const statistics = await host.runtime.readResumeStatistics();
49
+ if (statistics && statistics.messageCount > 0) return { everPrompted: true };
50
+ } catch {}
51
+ return { everPrompted: false };
45
52
  }
46
53
  /** The groups a resumed session was saved with. Sessions from before groups existed have none. */
47
54
  async function storedGroups(host, onNotice) {
@@ -64,7 +71,7 @@ function scopeOf(session) {
64
71
  }
65
72
  /** Owns direct, same-process session and channel state for presentation adapters. */
66
73
  function createHeadlessHub(options) {
67
- const readGitStatus = options.readGitStatus ?? ((cwd) => require_index$2.readSessionGitStatus(options.platform.env(cwd), cwd));
74
+ const readGitStatus = options.readGitStatus ?? ((cwd) => require_index$1.readSessionGitStatus(options.platform.env(cwd), cwd));
68
75
  const sessions = /* @__PURE__ */ new Map();
69
76
  const pendingSetups = /* @__PURE__ */ new Map();
70
77
  const activities = /* @__PURE__ */ new Map();
@@ -667,7 +674,7 @@ function createHeadlessHub(options) {
667
674
  }, (error) => options.onNotice?.(`session ${session.id} git status failed (${error instanceof Error ? error.message : String(error)})`));
668
675
  };
669
676
  let attentionDialog;
670
- const stopPresentation = session.host.onPresentationFrame((frame) => {
677
+ const receivePresentation = (frame) => {
671
678
  if (sessions.get(session.id)?.host !== session.host) return;
672
679
  const type = typeof frame.type === "string" ? frame.type : "";
673
680
  const entry = frame.entry;
@@ -699,7 +706,7 @@ function createHeadlessHub(options) {
699
706
  updatedAt: now,
700
707
  phase,
701
708
  phaseSince: phaseChanged ? now : current.phaseSince,
702
- everPrompted: current.everPrompted || type === "agent_start",
709
+ everPrompted: type === "agent_start" || type === "agent_settled" ? true : current.everPrompted,
703
710
  awaitingInput,
704
711
  ...type === "agent_settled" ? { lastSettledAt: now } : {}
705
712
  };
@@ -743,7 +750,7 @@ function createHeadlessHub(options) {
743
750
  });
744
751
  }
745
752
  if (type === "agent_settled") refreshGit();
746
- });
753
+ };
747
754
  let registered = false;
748
755
  const root = () => session.workspaceId && workspaces.get(session.workspaceId)?.root || session.cwd;
749
756
  let selectedMode;
@@ -829,6 +836,7 @@ function createHeadlessHub(options) {
829
836
  session: current
830
837
  });
831
838
  });
839
+ const stopPresentation = session.host.onPresentationFrame(receivePresentation);
832
840
  presentationCleanups.set(session.id, () => {
833
841
  stopPresentation();
834
842
  stopSelection?.();
@@ -947,7 +955,7 @@ function createHeadlessHub(options) {
947
955
  };
948
956
  const key = mountKey(mount);
949
957
  if (scopeHosts.has(key)) throw new Error(`The '${key}' scope is already served.`);
950
- const host = require_index$1.createPoServerHost({
958
+ const host = require_index.createPoServerHost({
951
959
  scope: context.scope,
952
960
  context: {
953
961
  ...context,
@@ -1303,7 +1311,7 @@ function createHeadlessHub(options) {
1303
1311
  if (sessions.has(id)) throw new Error(`Session '${id}' is already registered.`);
1304
1312
  if (sessionShutdowns.get(id)?.pending) throw new Error(`Session '${id}' is still shutting down.`);
1305
1313
  const host = await options.manager.create(sessionOptions);
1306
- const settledAt = await lastSettledAt(host);
1314
+ const history = await storedHistory(host);
1307
1315
  const groups = await storedGroups(host, options.onNotice);
1308
1316
  const session = {
1309
1317
  id: sessionOptions.sessionId,
@@ -1317,10 +1325,7 @@ function createHeadlessHub(options) {
1317
1325
  ...sessionOptions.sessionProvenance === void 0 ? {} : { sessionProvenance: sessionOptions.sessionProvenance },
1318
1326
  ...sessionOptions.interaction === void 0 ? {} : { interaction: sessionOptions.interaction },
1319
1327
  environment: sessionOptions.environment,
1320
- ...settledAt === void 0 ? {} : {
1321
- everPrompted: true,
1322
- lastSettledAt: settledAt
1323
- },
1328
+ ...history,
1324
1329
  groups,
1325
1330
  host
1326
1331
  };