@peer-agent/runtime-core 0.0.1-beta.47 → 0.0.1-beta.48

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.
@@ -29,6 +29,13 @@ export declare function createUnknownContextAccountingSnapshot(input: Readonly<{
29
29
  now?: number;
30
30
  }>): ContextAccountingSnapshot;
31
31
  export declare function isContextAccountingSnapshotCurrent(snapshot: ContextAccountingSnapshot | null | undefined, identity: ContextAccountingIdentity): snapshot is ContextAccountingSnapshot;
32
+ /**
33
+ * Reproject a restored/displayed context-accounting snapshot onto the current
34
+ * model config window (e.g. Qoder tier projection). Occupied tokens stay from
35
+ * the snapshot; only capacity fields + percent are refreshed so UI/runtime do
36
+ * not keep a stale window after the user changes tiers or projection is fixed.
37
+ */
38
+ export declare function reprojectContextAccountingWindow(snapshot: ContextAccountingSnapshot | null | undefined, contextWindow: number | null | undefined): ContextAccountingSnapshot | null;
32
39
  /**
33
40
  * Owns accounting revision order and pending-content transitions for one host
34
41
  * turn. Both Desktop and TUI publish this exact snapshot; presentation never
@@ -40,6 +40,37 @@ export function isContextAccountingSnapshotCurrent(snapshot, identity) {
40
40
  && snapshot.contentRevision === identity.contentRevision
41
41
  && snapshot.modelKey === identity.modelKey);
42
42
  }
43
+ /**
44
+ * Reproject a restored/displayed context-accounting snapshot onto the current
45
+ * model config window (e.g. Qoder tier projection). Occupied tokens stay from
46
+ * the snapshot; only capacity fields + percent are refreshed so UI/runtime do
47
+ * not keep a stale window after the user changes tiers or projection is fixed.
48
+ */
49
+ export function reprojectContextAccountingWindow(snapshot, contextWindow) {
50
+ if (!snapshot || snapshot.version !== 1)
51
+ return snapshot ?? null;
52
+ const nextWindow = normalizeWindow(contextWindow);
53
+ if (nextWindow == null)
54
+ return snapshot;
55
+ const nextThreshold = Math.floor(nextWindow * 0.8);
56
+ const authoritative = snapshot.authoritativeInputTokens;
57
+ const nextPercent = typeof authoritative === 'number' && Number.isFinite(authoritative)
58
+ ? Math.min(100, Math.round((authoritative / nextWindow) * 100))
59
+ : null;
60
+ if (snapshot.contextWindow === nextWindow
61
+ && snapshot.inputBudget === nextWindow
62
+ && snapshot.compactionThresholdTokens === nextThreshold
63
+ && snapshot.percent === nextPercent) {
64
+ return snapshot;
65
+ }
66
+ return Object.freeze({
67
+ ...snapshot,
68
+ contextWindow: nextWindow,
69
+ inputBudget: nextWindow,
70
+ compactionThresholdTokens: nextThreshold,
71
+ percent: nextPercent,
72
+ });
73
+ }
43
74
  /**
44
75
  * Owns accounting revision order and pending-content transitions for one host
45
76
  * turn. Both Desktop and TUI publish this exact snapshot; presentation never
@@ -157,9 +157,9 @@ export function decideGoalToolReplay(input) {
157
157
  };
158
158
  }
159
159
  const openCalls = Array.isArray(input.openToolCalls) ? input.openToolCalls : [];
160
+ // Replay protection only applies to an exact logical-call match. Tool names are
161
+ // not identities: two different bash commands (or writes) may run in one Goal.
160
162
  const matched = openCalls.find((call) => asString(call.idempotencyKey) === idempotencyKey)
161
- || openCalls.find((call) => (asString(call.toolName) === asString(input.toolName)
162
- && (call.status === 'running' || call.status === 'requested' || call.status === 'completed')))
163
163
  || null;
164
164
  if (matched?.status === 'completed' && (matched.resultEvidenceRefs?.length ?? 0) > 0) {
165
165
  return {
@@ -192,16 +192,9 @@ export function decideGoalToolReplay(input) {
192
192
  matchedCall: matched,
193
193
  };
194
194
  }
195
- if (mutationClass === 'unknown') {
196
- return {
197
- action: 'ask_user',
198
- reason: 'unknown_mutation_class',
199
- policy: 'ask_user',
200
- mutationClass,
201
- idempotencyKey,
202
- matchedCall: matched,
203
- };
204
- }
195
+ // No exact ledger/checkpoint match means this is a fresh call, not a replay.
196
+ // Unknown mutation safety still matters for a matched unsettled call above, but
197
+ // must not pre-empt the downstream PermissionGate on first execution.
205
198
  return {
206
199
  action: 'execute',
207
200
  reason: 'no_prior_attempt',
@@ -33,13 +33,14 @@ export declare const SHARED_LOCAL_TOOL_CONTRACT_LIST: readonly (Readonly<LocalTo
33
33
  * these contracts instead of ignoring arbitrary browser-prefixed additions.
34
34
  */
35
35
  export declare const DESKTOP_ONLY_LOCAL_TOOL_CONTRACTS: Readonly<{
36
+ browserOpenPanel: Readonly<LocalToolContract<"browser_open_panel", "local.web.control.openPanel">>;
36
37
  browserNavigate: Readonly<LocalToolContract<"browser_navigate", "local.web.control.navigate">>;
37
38
  browserClick: Readonly<LocalToolContract<"browser_click", "local.web.control.click">>;
38
39
  browserType: Readonly<LocalToolContract<"browser_type", "local.web.control.type">>;
39
40
  browserScreenshot: Readonly<LocalToolContract<"browser_screenshot", "local.web.control.screenshot">>;
40
41
  browserReadDom: Readonly<LocalToolContract<"browser_read_dom", "local.web.control.readDom">>;
41
42
  }>;
42
- export declare const DESKTOP_ONLY_LOCAL_TOOL_CONTRACT_LIST: readonly (Readonly<LocalToolContract<"browser_navigate", "local.web.control.navigate">> | Readonly<LocalToolContract<"browser_click", "local.web.control.click">> | Readonly<LocalToolContract<"browser_type", "local.web.control.type">> | Readonly<LocalToolContract<"browser_screenshot", "local.web.control.screenshot">> | Readonly<LocalToolContract<"browser_read_dom", "local.web.control.readDom">>)[];
43
+ export declare const DESKTOP_ONLY_LOCAL_TOOL_CONTRACT_LIST: readonly (Readonly<LocalToolContract<"browser_open_panel", "local.web.control.openPanel">> | Readonly<LocalToolContract<"browser_navigate", "local.web.control.navigate">> | Readonly<LocalToolContract<"browser_click", "local.web.control.click">> | Readonly<LocalToolContract<"browser_type", "local.web.control.type">> | Readonly<LocalToolContract<"browser_screenshot", "local.web.control.screenshot">> | Readonly<LocalToolContract<"browser_read_dom", "local.web.control.readDom">>)[];
43
44
  /**
44
45
  * Read-time/inbound compatibility only. New Runtime Projections must never
45
46
  * expose these legacy capability IDs.
@@ -29,6 +29,7 @@ export const SHARED_LOCAL_TOOL_CONTRACT_LIST = Object.freeze(Object.values(SHARE
29
29
  * these contracts instead of ignoring arbitrary browser-prefixed additions.
30
30
  */
31
31
  export const DESKTOP_ONLY_LOCAL_TOOL_CONTRACTS = Object.freeze({
32
+ browserOpenPanel: defineToolContract('browser_open_panel', 'local.web.control.openPanel'),
32
33
  browserNavigate: defineToolContract('browser_navigate', 'local.web.control.navigate'),
33
34
  browserClick: defineToolContract('browser_click', 'local.web.control.click'),
34
35
  browserType: defineToolContract('browser_type', 'local.web.control.type'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peer-agent/runtime-core",
3
- "version": "0.0.1-beta.47",
3
+ "version": "0.0.1-beta.48",
4
4
  "description": "Host-neutral capability, permission, projection, and Evidence primitives for Peer Agent runtimes.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -38,7 +38,7 @@
38
38
  "LICENSE"
39
39
  ],
40
40
  "dependencies": {
41
- "@peer-agent/protocol": "0.0.1-beta.47"
41
+ "@peer-agent/protocol": "0.0.1-beta.48"
42
42
  },
43
43
  "devDependencies": {
44
44
  "typescript": "^5.9.3"