visionclaw 0.1.213-beta.12 → 0.1.213-beta.14
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/agent/backup-uploader.d.ts.map +1 -1
- package/dist/agent/backup-uploader.js +2 -1
- package/dist/agent/backup-uploader.js.map +1 -1
- package/dist/agent/compaction-failure.d.ts +9 -0
- package/dist/agent/compaction-failure.d.ts.map +1 -0
- package/dist/agent/compaction-failure.js +11 -0
- package/dist/agent/compaction-failure.js.map +1 -0
- package/dist/agent/compaction-policy.d.ts +2 -0
- package/dist/agent/compaction-policy.d.ts.map +1 -1
- package/dist/agent/compaction-policy.js +2 -0
- package/dist/agent/compaction-policy.js.map +1 -1
- package/dist/agent/context-refresh.d.ts +2 -0
- package/dist/agent/context-refresh.d.ts.map +1 -1
- package/dist/agent/context-refresh.js +8 -2
- package/dist/agent/context-refresh.js.map +1 -1
- package/dist/agent/deep-night-dreaming.d.ts +68 -0
- package/dist/agent/deep-night-dreaming.d.ts.map +1 -0
- package/dist/agent/deep-night-dreaming.js +99 -0
- package/dist/agent/deep-night-dreaming.js.map +1 -0
- package/dist/agent/engines/pi-coding/session.d.ts +1 -0
- package/dist/agent/engines/pi-coding/session.d.ts.map +1 -1
- package/dist/agent/engines/pi-coding/session.js +36 -5
- package/dist/agent/engines/pi-coding/session.js.map +1 -1
- package/dist/agent/heartbeat-manager.d.ts +20 -0
- package/dist/agent/heartbeat-manager.d.ts.map +1 -1
- package/dist/agent/heartbeat-manager.js +24 -0
- package/dist/agent/heartbeat-manager.js.map +1 -1
- package/dist/agent/lab-run-system-prompt.js +1 -1
- package/dist/agent/loop.d.ts.map +1 -1
- package/dist/agent/loop.js +15 -33
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/memory-dreaming-sweep.d.ts +99 -0
- package/dist/agent/memory-dreaming-sweep.d.ts.map +1 -0
- package/dist/agent/memory-dreaming-sweep.js +171 -0
- package/dist/agent/memory-dreaming-sweep.js.map +1 -0
- package/dist/agent/memory-dreaming.d.ts +85 -43
- package/dist/agent/memory-dreaming.d.ts.map +1 -1
- package/dist/agent/memory-dreaming.js +476 -188
- package/dist/agent/memory-dreaming.js.map +1 -1
- package/dist/agent/memory-injector.d.ts.map +1 -1
- package/dist/agent/memory-injector.js +16 -14
- package/dist/agent/memory-injector.js.map +1 -1
- package/dist/agent/stream-handler.d.ts.map +1 -1
- package/dist/agent/stream-handler.js +13 -1
- package/dist/agent/stream-handler.js.map +1 -1
- package/dist/agent/transcript-summarizer.d.ts +6 -2
- package/dist/agent/transcript-summarizer.d.ts.map +1 -1
- package/dist/agent/transcript-summarizer.js +8 -4
- package/dist/agent/transcript-summarizer.js.map +1 -1
- package/dist/agent/wake-cycle-runner.d.ts.map +1 -1
- package/dist/agent/wake-cycle-runner.js +72 -0
- package/dist/agent/wake-cycle-runner.js.map +1 -1
- package/dist/builtin-skills/catalog/github-dev-ops/SKILL.md +7 -2
- package/dist/builtin-skills/fin-app/SKILL.md +2 -2
- package/dist/builtin-skills/visionclaw-manual/SKILL.md +1 -1
- package/dist/onboarding/prepare-windows.d.ts.map +1 -1
- package/dist/onboarding/prepare-windows.js +2 -28
- package/dist/onboarding/prepare-windows.js.map +1 -1
- package/dist/onboarding/windows-permissions.d.ts +0 -1
- package/dist/onboarding/windows-permissions.d.ts.map +1 -1
- package/dist/onboarding/windows-permissions.js +0 -26
- package/dist/onboarding/windows-permissions.js.map +1 -1
- package/dist/threads/ipc.d.ts +0 -4
- package/dist/threads/ipc.d.ts.map +1 -1
- package/dist/threads/ipc.js.map +1 -1
- package/dist/threads/lab-run-runtime.d.ts.map +1 -1
- package/dist/threads/lab-run-runtime.js +70 -1
- package/dist/threads/lab-run-runtime.js.map +1 -1
- package/dist/threads/lab-runtime-policy.d.ts +2 -0
- package/dist/threads/lab-runtime-policy.d.ts.map +1 -1
- package/dist/threads/lab-runtime-policy.js +4 -0
- package/dist/threads/lab-runtime-policy.js.map +1 -1
- package/dist/threads/relay-adapter.d.ts +6 -6
- package/dist/threads/relay-adapter.d.ts.map +1 -1
- package/dist/threads/relay-adapter.js +7 -9
- package/dist/threads/relay-adapter.js.map +1 -1
- package/dist/threads/supervisor.d.ts +28 -6
- package/dist/threads/supervisor.d.ts.map +1 -1
- package/dist/threads/supervisor.js +54 -25
- package/dist/threads/supervisor.js.map +1 -1
- package/dist/tools/calendar.d.ts +1 -0
- package/dist/tools/calendar.d.ts.map +1 -1
- package/dist/tools/calendar.js +43 -6
- package/dist/tools/calendar.js.map +1 -1
- package/dist/tools/drive.d.ts +4 -0
- package/dist/tools/drive.d.ts.map +1 -1
- package/dist/tools/drive.js +46 -12
- package/dist/tools/drive.js.map +1 -1
- package/dist/tools/event-trigger.d.ts +0 -1
- package/dist/tools/event-trigger.d.ts.map +1 -1
- package/dist/tools/event-trigger.js +7 -2
- package/dist/tools/event-trigger.js.map +1 -1
- package/dist/tools/transcribe-audio.d.ts +7 -3
- package/dist/tools/transcribe-audio.d.ts.map +1 -1
- package/dist/tools/transcribe-audio.js +15 -4
- package/dist/tools/transcribe-audio.js.map +1 -1
- package/dist/workspace/google/google-calendar.d.ts +1 -0
- package/dist/workspace/google/google-calendar.d.ts.map +1 -1
- package/dist/workspace/google/google-calendar.js +5 -1
- package/dist/workspace/google/google-calendar.js.map +1 -1
- package/dist/workspace/google/google-drive.d.ts +3 -3
- package/dist/workspace/google/google-drive.d.ts.map +1 -1
- package/dist/workspace/google/google-drive.js +48 -15
- package/dist/workspace/google/google-drive.js.map +1 -1
- package/dist/workspace/internal-calendar.d.ts +3 -1
- package/dist/workspace/internal-calendar.d.ts.map +1 -1
- package/dist/workspace/internal-calendar.js +6 -2
- package/dist/workspace/internal-calendar.js.map +1 -1
- package/dist/workspace/types.d.ts +27 -4
- package/dist/workspace/types.d.ts.map +1 -1
- package/dist/workspace/zoho/zoho-calendar.d.ts +2 -0
- package/dist/workspace/zoho/zoho-calendar.d.ts.map +1 -1
- package/dist/workspace/zoho/zoho-calendar.js +7 -0
- package/dist/workspace/zoho/zoho-calendar.js.map +1 -1
- package/dist/workspace/zoho/zoho-workdrive.d.ts +2 -2
- package/dist/workspace/zoho/zoho-workdrive.d.ts.map +1 -1
- package/dist/workspace/zoho/zoho-workdrive.js +7 -3
- package/dist/workspace/zoho/zoho-workdrive.js.map +1 -1
- package/dist-agent/bundle.cjs +1438 -1024
- package/package.json +1 -1
- package/dist/agent/memory-warm-compaction.d.ts +0 -79
- package/dist/agent/memory-warm-compaction.d.ts.map +0 -1
- package/dist/agent/memory-warm-compaction.js +0 -270
- package/dist/agent/memory-warm-compaction.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backup-uploader.d.ts","sourceRoot":"","sources":["../../src/agent/backup-uploader.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,KAAK,CAAC;AAE9C,MAAM,WAAW,oBAAoB;IACnC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,IAAI,CAAC;CACvD;AAED,MAAM,WAAW,yBAA0B,SAAQ,uBAAuB;IACxE,QAAQ,EAAE,QAAQ,CAAC;IACnB,MAAM,EAAE,gBAAgB,CAAC;IACzB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,sBAAuB,SAAQ,uBAAuB;IACrE,QAAQ,EAAE,KAAK,CAAC;IAChB,GAAG,EAAE;QACH,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;QACxB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QAC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
|
34
34
|
// No owner address means no grantee. Sharing is what produces the URL the
|
|
35
35
|
// owner would open, so without it we fall through to the file's own link.
|
|
36
|
-
const
|
|
36
|
+
const shareResult = options.ownerEmail
|
|
37
37
|
? await drive.shareFile({
|
|
38
38
|
fileId: uploaded.id,
|
|
39
39
|
email: options.ownerEmail,
|
|
@@ -41,6 +41,7 @@ export async function uploadBackupToGoogleDrive(options) {
|
|
|
41
41
|
sendNotification: false,
|
|
42
42
|
})
|
|
43
43
|
: null;
|
|
44
|
+
const shareUrl = shareResult?.url;
|
|
44
45
|
// Only assert the share URL when we actually asked for one — a channel-only
|
|
45
46
|
// owner legitimately gets none, and failing the whole backup over that would
|
|
46
47
|
// turn an optional email into a hard requirement by the back door.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backup-uploader.js","sourceRoot":"","sources":["../../src/agent/backup-uploader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAsDtF,SAAS,OAAO,CAAC,KAAa;IAC5B,MAAM,IAAI,GAAG,KAAK;SACf,IAAI,EAAE;SACN,WAAW,EAAE;SACb,OAAO,CAAC,gBAAgB,EAAE,GAAG,CAAC;SAC9B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC3B,OAAO,IAAI,IAAI,SAAS,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAwB,EAAE,OAAe;IACzE,OAAO,WAAW,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC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aAAa,EAAE,QAAQ,CAAC,aAAa,EAAE,CAAC,CAAC;QAClE,CAAC;KACF,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,kBAAkB,CAAC;QACnC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM;QAC1B,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG;QACpB,WAAW;QACX,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB;QACnD,cAAc,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;KAC3C,CAAC,CAAC;IACH,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC;IAElG,OAAO;QACL,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;QAC3D,SAAS;QACT,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG;QACpB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM;QAC1B,SAAS;QACT,SAAS;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class CompactionFailureError extends Error {
|
|
2
|
+
readonly errorCode: string;
|
|
3
|
+
readonly sessionId: string | null;
|
|
4
|
+
constructor(message: string, options: {
|
|
5
|
+
errorCode: string;
|
|
6
|
+
sessionId: string | null;
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=compaction-failure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compaction-failure.d.ts","sourceRoot":"","sources":["../../src/agent/compaction-failure.ts"],"names":[],"mappings":"AAAA,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;gBAEtB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE;CAMtF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export class CompactionFailureError extends Error {
|
|
2
|
+
errorCode;
|
|
3
|
+
sessionId;
|
|
4
|
+
constructor(message, options) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = "CompactionFailureError";
|
|
7
|
+
this.errorCode = options.errorCode;
|
|
8
|
+
this.sessionId = options.sessionId;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=compaction-failure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compaction-failure.js","sourceRoot":"","sources":["../../src/agent/compaction-failure.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IACtC,SAAS,CAAS;IAClB,SAAS,CAAgB;IAElC,YAAY,OAAe,EAAE,OAAwD;QACnF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IACrC,CAAC;CACF"}
|
|
@@ -34,6 +34,8 @@ export declare const CONTEXT_REFRESH_RESTART_TIMEOUT_MS = 420000;
|
|
|
34
34
|
export declare const AUTO_REFRESH_ENABLED: boolean;
|
|
35
35
|
/** Consecutive compaction timeouts required before forcing a refresh. */
|
|
36
36
|
export declare const AUTO_REFRESH_TIMEOUT_STREAK = 2;
|
|
37
|
+
/** Error codes that identify a failed Pi auto-compaction worth recovering. */
|
|
38
|
+
export declare const COMPACTION_FAILURE_ERROR_CODES: Set<string>;
|
|
37
39
|
/** Minimum gap between two automatic refreshes. */
|
|
38
40
|
export declare const AUTO_REFRESH_COOLDOWN_MS = 1800000;
|
|
39
41
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compaction-policy.d.ts","sourceRoot":"","sources":["../../src/agent/compaction-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,SAAU,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,QAAS,CAAC;AAExD,2EAA2E;AAC3E,eAAO,MAAM,kCAAkC,SAAU,CAAC;AAE1D;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,EAAW,OAAO,CAAC;AAEpD,yEAAyE;AACzE,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAE7C,mDAAmD;AACnD,eAAO,MAAM,wBAAwB,UAAY,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAW,OAAO,CAAC"}
|
|
1
|
+
{"version":3,"file":"compaction-policy.d.ts","sourceRoot":"","sources":["../../src/agent/compaction-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,SAAU,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,QAAS,CAAC;AAExD,2EAA2E;AAC3E,eAAO,MAAM,kCAAkC,SAAU,CAAC;AAE1D;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,EAAW,OAAO,CAAC;AAEpD,yEAAyE;AACzE,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAE7C,8EAA8E;AAC9E,eAAO,MAAM,8BAA8B,aAAiC,CAAC;AAE7E,mDAAmD;AACnD,eAAO,MAAM,wBAAwB,UAAY,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAW,OAAO,CAAC"}
|
|
@@ -34,6 +34,8 @@ export const CONTEXT_REFRESH_RESTART_TIMEOUT_MS = 420_000; // 7 minutes
|
|
|
34
34
|
export const AUTO_REFRESH_ENABLED = true;
|
|
35
35
|
/** Consecutive compaction timeouts required before forcing a refresh. */
|
|
36
36
|
export const AUTO_REFRESH_TIMEOUT_STREAK = 2;
|
|
37
|
+
/** Error codes that identify a failed Pi auto-compaction worth recovering. */
|
|
38
|
+
export const COMPACTION_FAILURE_ERROR_CODES = new Set(["400", "413", "504"]);
|
|
37
39
|
/** Minimum gap between two automatic refreshes. */
|
|
38
40
|
export const AUTO_REFRESH_COOLDOWN_MS = 1_800_000; // 30 minutes
|
|
39
41
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compaction-policy.js","sourceRoot":"","sources":["../../src/agent/compaction-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,OAAO,CAAC,CAAC,YAAY;AAElE;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,MAAM,CAAC;AAExD,2EAA2E;AAC3E,MAAM,CAAC,MAAM,kCAAkC,GAAG,OAAO,CAAC,CAAC,YAAY;AAEvE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAe,CAAC;AAEpD,yEAAyE;AACzE,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAE7C,mDAAmD;AACnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,SAAS,CAAC,CAAC,aAAa;AAEhE;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"compaction-policy.js","sourceRoot":"","sources":["../../src/agent/compaction-policy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,OAAO,CAAC,CAAC,YAAY;AAElE;;;;GAIG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,MAAM,CAAC;AAExD,2EAA2E;AAC3E,MAAM,CAAC,MAAM,kCAAkC,GAAG,OAAO,CAAC,CAAC,YAAY;AAEvE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAe,CAAC;AAEpD,yEAAyE;AACzE,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAE7C,8EAA8E;AAC9E,MAAM,CAAC,MAAM,8BAA8B,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAE7E,mDAAmD;AACnD,MAAM,CAAC,MAAM,wBAAwB,GAAG,SAAS,CAAC,CAAC,aAAa;AAEhE;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAe,CAAC"}
|
|
@@ -11,6 +11,8 @@ export interface PerformContextRefreshDeps {
|
|
|
11
11
|
export interface PerformContextRefreshOptions {
|
|
12
12
|
/** Short reason for logs (e.g. "manual" or "compaction-timeout-streak"). */
|
|
13
13
|
reason: string;
|
|
14
|
+
/** Bound the summarizer input after a provider payload overflow. */
|
|
15
|
+
compactInput?: boolean;
|
|
14
16
|
/**
|
|
15
17
|
* System message enqueued for the next wake cycle so the new session knows
|
|
16
18
|
* a refresh happened. Defaults to the manual-refresh wording.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-refresh.d.ts","sourceRoot":"","sources":["../../src/agent/context-refresh.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAM7C,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,cAAc,CAAC;IACxB,MAAM,EAAE,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AAc,CAAC,EAAE,OAAO,CAAC;IACzB,gEAAgE;IAChE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,sBAAsB,CAAC;CAChC;AAED,MAAM,MAAM,wBAAwB,GAChC;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAC/C;IAAE,MAAM,EAAE,YAAY,CAAA;CAAE,GACxB;IAAE,MAAM,EAAE,cAAc,CAAA;CAAE,CAAC;AAoB/B;;;;;;;;;;;;GAYG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,qBAAqB,EAC3B,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,wBAAwB,CAAC,CAkDnC"}
|
|
@@ -44,7 +44,9 @@ export async function performContextRefresh(deps, options) {
|
|
|
44
44
|
? transcriptInfo.sessionFilePath ?? activeSession.getTranscriptPath()
|
|
45
45
|
: null;
|
|
46
46
|
const { summarizeWithFallback } = await import("./transcript-summarizer.js");
|
|
47
|
-
const finalSummary =
|
|
47
|
+
const finalSummary = options.compactInput
|
|
48
|
+
? await summarizeWithFallback(transcriptPath, config, { compactInput: true })
|
|
49
|
+
: await summarizeWithFallback(transcriptPath, config);
|
|
48
50
|
// Persist critical working state to /memories before the reset so the next
|
|
49
51
|
// session can rehydrate it. Self-gated on the memory feature flag. Wrapped so
|
|
50
52
|
// that neither the dynamic import nor the flush can block the refresh.
|
|
@@ -126,7 +128,11 @@ export async function runContextRefresh(deps, options) {
|
|
|
126
128
|
config,
|
|
127
129
|
messageQueue,
|
|
128
130
|
taskReplyTarget: agentState.currentTaskReplyTarget,
|
|
129
|
-
}, {
|
|
131
|
+
}, {
|
|
132
|
+
reason,
|
|
133
|
+
systemMessage,
|
|
134
|
+
...(options.compactInput ? { compactInput: true } : {}),
|
|
135
|
+
});
|
|
130
136
|
if (!result.refreshed) {
|
|
131
137
|
return { status: "no_session" };
|
|
132
138
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-refresh.js","sourceRoot":"","sources":["../../src/agent/context-refresh.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,kCAAkC,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"context-refresh.js","sourceRoot":"","sources":["../../src/agent/context-refresh.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAE,kCAAkC,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AA4B5D;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,GAAoE,EACpE,aAAqB,EACrB,mBAA2B,EAC3B,KAAa;IAEb,IAAI,CAAC,GAAG,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC/B,IAAI,aAAa,GAAG,GAAG,CAAC,aAAa;QAAE,OAAO,KAAK,CAAC;IACpD,IAAI,KAAK,GAAG,mBAAmB,GAAG,GAAG,CAAC,UAAU;QAAE,OAAO,KAAK,CAAC;IAC/D,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,sBAAsB,GAC1B,uFAAuF;IACvF,2EAA2E;IAC3E,8EAA8E,CAAC;AAEjF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,IAA+B,EAC/B,OAAqC;IAErC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC;IAChE,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAC5C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CAAC,SAAS,EAAE,CAAC;YACtB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;QAClC,CAAC;QACD,MAAM,KAAK,EAAE,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC;QACnC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC;IAC1D,CAAC;YAAS,CAAC;QACT,qBAAqB,EAAE,CAAC;QACxB,UAAU,CAAC,UAAU,GAAG,KAAK,CAAC;IAChC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side deep-night dreaming decision.
|
|
3
|
+
*
|
|
4
|
+
* The agent decides for itself when to dream. Everything the decision needs is
|
|
5
|
+
* local: its own wall clock (the deep-night window), its own `.dream_log`
|
|
6
|
+
* state (has it already dreamed today), and its own transcripts (whether there
|
|
7
|
+
* is anything worth dreaming — that gate lives downstream in
|
|
8
|
+
* `runMemoryDreaming`). The server contributes nothing: dreaming is a default
|
|
9
|
+
* agent capability with no feature gate, so there is no delivery ordering, no
|
|
10
|
+
* ack and no server-side latch to keep in sync.
|
|
11
|
+
*
|
|
12
|
+
* This replaces the earlier server-dispatched `do_dreaming` command. Four of
|
|
13
|
+
* the defects found in review of that design (handler-registration race,
|
|
14
|
+
* ack-before-drain, the supervisor-free dispatch failure, and the swallowed
|
|
15
|
+
* dispatch error) were failure shapes of the distribution itself, not of the
|
|
16
|
+
* scheduling rule — a local `if` cannot have them.
|
|
17
|
+
*/
|
|
18
|
+
import type { VisionClawConfig } from "../config/types.js";
|
|
19
|
+
import type { ThreadSupervisor } from "../threads/supervisor.js";
|
|
20
|
+
/**
|
|
21
|
+
* Deep-night window, half-open `[start, end)`, in the agent's own local time.
|
|
22
|
+
* Inherited unchanged from the deleted server-side dispatcher.
|
|
23
|
+
*/
|
|
24
|
+
export declare const DREAM_WINDOW_START_HOUR = 2;
|
|
25
|
+
export declare const DREAM_WINDOW_END_HOUR = 6;
|
|
26
|
+
/** `YYYYMMDD` for a local date — the granularity of the once-a-day latch. */
|
|
27
|
+
export declare function localDayNumber(now: Date): number;
|
|
28
|
+
/** Why a deep-night check declined to run, for logging and tests. */
|
|
29
|
+
export type DeepNightSkipReason = "outside-window" | "already-dreamed-today";
|
|
30
|
+
export type DeepNightDecision = {
|
|
31
|
+
run: true;
|
|
32
|
+
localDay: number;
|
|
33
|
+
} | {
|
|
34
|
+
run: false;
|
|
35
|
+
reason: DeepNightSkipReason;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Pure scheduling rule: inside the local deep-night window, at most once per
|
|
39
|
+
* local natural day.
|
|
40
|
+
*
|
|
41
|
+
* `lastDreamedDay` is the `YYYYMMDD` latch read from `.dream_log/state.json`.
|
|
42
|
+
* Comparing for equality rather than ordering means a backwards clock jump (or
|
|
43
|
+
* a state file copied from another machine) costs at most one extra sweep,
|
|
44
|
+
* where `>=` could latch the agent out of dreaming until the stored day passes.
|
|
45
|
+
*/
|
|
46
|
+
export declare function decideDeepNightDreaming(input: {
|
|
47
|
+
now: Date;
|
|
48
|
+
lastDreamedDay: number | null;
|
|
49
|
+
}): DeepNightDecision;
|
|
50
|
+
/**
|
|
51
|
+
* Evaluate the rule and, when it says yes, run the sweep. Called from the idle
|
|
52
|
+
* heartbeat tick (every 5 minutes while asleep), so it must be cheap in the
|
|
53
|
+
* overwhelmingly common "not 2am" case — reading the latch file only happens
|
|
54
|
+
* once the window check has already passed.
|
|
55
|
+
*
|
|
56
|
+
* The day latch is written BEFORE the sweep starts. That makes "one sweep per
|
|
57
|
+
* local day" hold even if the sweep throws or the process dies mid-way: the
|
|
58
|
+
* cost of a failed night is one skipped night, whereas latching afterwards
|
|
59
|
+
* would let a reproducible failure retry every five minutes for four hours.
|
|
60
|
+
* Per-transcript progress is not lost either way — `runMemoryDreaming` keeps
|
|
61
|
+
* its own mtime watermark and only latches transcripts it actually dreamed.
|
|
62
|
+
*
|
|
63
|
+
* Never throws: this is fire-and-forget from the heartbeat tick.
|
|
64
|
+
*/
|
|
65
|
+
export declare function maybeRunDeepNightDreaming(config: VisionClawConfig, getSupervisor: () => ThreadSupervisor | null, options?: {
|
|
66
|
+
now?: Date;
|
|
67
|
+
}): Promise<DeepNightDecision>;
|
|
68
|
+
//# sourceMappingURL=deep-night-dreaming.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-night-dreaming.d.ts","sourceRoot":"","sources":["../../src/agent/deep-night-dreaming.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGjE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,6EAA6E;AAC7E,wBAAgB,cAAc,CAAC,GAAG,EAAE,IAAI,GAAG,MAAM,CAEhD;AAED,qEAAqE;AACrE,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,GAAG,uBAAuB,CAAC;AAE7E,MAAM,MAAM,iBAAiB,GACzB;IAAE,GAAG,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,GAAG,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,mBAAmB,CAAA;CAAE,CAAC;AAEhD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAC7C,GAAG,EAAE,IAAI,CAAC;IACV,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,GAAG,iBAAiB,CAUpB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,gBAAgB,EACxB,aAAa,EAAE,MAAM,gBAAgB,GAAG,IAAI,EAC5C,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,IAAI,CAAA;CAAO,GAC3B,OAAO,CAAC,iBAAiB,CAAC,CAqC5B"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side deep-night dreaming decision.
|
|
3
|
+
*
|
|
4
|
+
* The agent decides for itself when to dream. Everything the decision needs is
|
|
5
|
+
* local: its own wall clock (the deep-night window), its own `.dream_log`
|
|
6
|
+
* state (has it already dreamed today), and its own transcripts (whether there
|
|
7
|
+
* is anything worth dreaming — that gate lives downstream in
|
|
8
|
+
* `runMemoryDreaming`). The server contributes nothing: dreaming is a default
|
|
9
|
+
* agent capability with no feature gate, so there is no delivery ordering, no
|
|
10
|
+
* ack and no server-side latch to keep in sync.
|
|
11
|
+
*
|
|
12
|
+
* This replaces the earlier server-dispatched `do_dreaming` command. Four of
|
|
13
|
+
* the defects found in review of that design (handler-registration race,
|
|
14
|
+
* ack-before-drain, the supervisor-free dispatch failure, and the swallowed
|
|
15
|
+
* dispatch error) were failure shapes of the distribution itself, not of the
|
|
16
|
+
* scheduling rule — a local `if` cannot have them.
|
|
17
|
+
*/
|
|
18
|
+
import { logger } from "../logger.js";
|
|
19
|
+
/**
|
|
20
|
+
* Deep-night window, half-open `[start, end)`, in the agent's own local time.
|
|
21
|
+
* Inherited unchanged from the deleted server-side dispatcher.
|
|
22
|
+
*/
|
|
23
|
+
export const DREAM_WINDOW_START_HOUR = 2;
|
|
24
|
+
export const DREAM_WINDOW_END_HOUR = 6;
|
|
25
|
+
/** `YYYYMMDD` for a local date — the granularity of the once-a-day latch. */
|
|
26
|
+
export function localDayNumber(now) {
|
|
27
|
+
return now.getFullYear() * 10_000 + (now.getMonth() + 1) * 100 + now.getDate();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Pure scheduling rule: inside the local deep-night window, at most once per
|
|
31
|
+
* local natural day.
|
|
32
|
+
*
|
|
33
|
+
* `lastDreamedDay` is the `YYYYMMDD` latch read from `.dream_log/state.json`.
|
|
34
|
+
* Comparing for equality rather than ordering means a backwards clock jump (or
|
|
35
|
+
* a state file copied from another machine) costs at most one extra sweep,
|
|
36
|
+
* where `>=` could latch the agent out of dreaming until the stored day passes.
|
|
37
|
+
*/
|
|
38
|
+
export function decideDeepNightDreaming(input) {
|
|
39
|
+
const hour = input.now.getHours();
|
|
40
|
+
if (hour < DREAM_WINDOW_START_HOUR || hour >= DREAM_WINDOW_END_HOUR) {
|
|
41
|
+
return { run: false, reason: "outside-window" };
|
|
42
|
+
}
|
|
43
|
+
const localDay = localDayNumber(input.now);
|
|
44
|
+
if (input.lastDreamedDay === localDay) {
|
|
45
|
+
return { run: false, reason: "already-dreamed-today" };
|
|
46
|
+
}
|
|
47
|
+
return { run: true, localDay };
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Evaluate the rule and, when it says yes, run the sweep. Called from the idle
|
|
51
|
+
* heartbeat tick (every 5 minutes while asleep), so it must be cheap in the
|
|
52
|
+
* overwhelmingly common "not 2am" case — reading the latch file only happens
|
|
53
|
+
* once the window check has already passed.
|
|
54
|
+
*
|
|
55
|
+
* The day latch is written BEFORE the sweep starts. That makes "one sweep per
|
|
56
|
+
* local day" hold even if the sweep throws or the process dies mid-way: the
|
|
57
|
+
* cost of a failed night is one skipped night, whereas latching afterwards
|
|
58
|
+
* would let a reproducible failure retry every five minutes for four hours.
|
|
59
|
+
* Per-transcript progress is not lost either way — `runMemoryDreaming` keeps
|
|
60
|
+
* its own mtime watermark and only latches transcripts it actually dreamed.
|
|
61
|
+
*
|
|
62
|
+
* Never throws: this is fire-and-forget from the heartbeat tick.
|
|
63
|
+
*/
|
|
64
|
+
export async function maybeRunDeepNightDreaming(config, getSupervisor, options = {}) {
|
|
65
|
+
const now = options.now ?? new Date();
|
|
66
|
+
const hour = now.getHours();
|
|
67
|
+
// Cheap pre-check so an idle agent doesn't touch the filesystem 288 times a
|
|
68
|
+
// day to learn it is not 2am.
|
|
69
|
+
if (hour < DREAM_WINDOW_START_HOUR || hour >= DREAM_WINDOW_END_HOUR) {
|
|
70
|
+
return { run: false, reason: "outside-window" };
|
|
71
|
+
}
|
|
72
|
+
const { readDeepNightDreamDay, recordDeepNightDreamDay } = await import("./memory-dreaming.js");
|
|
73
|
+
const decision = decideDeepNightDreaming({ now, lastDreamedDay: readDeepNightDreamDay() });
|
|
74
|
+
if (!decision.run)
|
|
75
|
+
return decision;
|
|
76
|
+
recordDeepNightDreamDay(decision.localDay);
|
|
77
|
+
try {
|
|
78
|
+
const supervisor = getSupervisor();
|
|
79
|
+
const { resolveDreamingTargets, runDreamingSweep } = await import("./memory-dreaming-sweep.js");
|
|
80
|
+
if (!supervisor) {
|
|
81
|
+
// No supervisor means no persisted business threads to sweep (single
|
|
82
|
+
// process — `multiThread.enabled === false`, which is what lab-runner
|
|
83
|
+
// profiles write). This process's own transcripts are the whole agent.
|
|
84
|
+
logger.system("[memory-dreaming] Deep-night window reached; dreaming main thread inline");
|
|
85
|
+
const summary = await runDreamingSweep(resolveDreamingTargets([]), config);
|
|
86
|
+
logger.debug(`[memory-dreaming] Inline sweep done: ${JSON.stringify(summary)}`);
|
|
87
|
+
return decision;
|
|
88
|
+
}
|
|
89
|
+
logger.system("[memory-dreaming] Deep-night window reached; enqueuing dreaming sweep");
|
|
90
|
+
const targets = supervisor.enqueueDeepNightDreaming();
|
|
91
|
+
await supervisor.waitForDreamingIdle();
|
|
92
|
+
logger.debug(`[memory-dreaming] Deep-night sweep drained (${targets} target(s))`);
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
logger.debug(`[memory-dreaming] Deep-night sweep failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
96
|
+
}
|
|
97
|
+
return decision;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=deep-night-dreaming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-night-dreaming.js","sourceRoot":"","sources":["../../src/agent/deep-night-dreaming.ts"],"names":[],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AAO,GAAG,EAAE,CAAC;QACb,MAAM,CAAC,KAAK,CACV,8CAA8C,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CACjG,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -75,4 +75,5 @@ export declare class PiCodingAgentSession implements AgentSessionLike {
|
|
|
75
75
|
private consumeResetSummaryContent;
|
|
76
76
|
private streamMessages;
|
|
77
77
|
}
|
|
78
|
+
export declare function extractCompactionErrorCode(message: string): string | null;
|
|
78
79
|
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/agent/engines/pi-coding/session.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../../src/agent/engines/pi-coding/session.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAehE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,OAAO,KAAK,EACV,2BAA2B,EAC3B,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAEhB,oBAAoB,EACpB,oBAAoB,EAEpB,aAAa,EACd,MAAM,qBAAqB,CAAC;AAkC7B,qBAAa,oBAAqB,YAAW,gBAAgB;IAC3D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmB;IAC1C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA2B;IAC7D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;IAChD,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAgB;IACt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BzB,OAAO,CAAC,iBAAiB;YAWX,aAAa;IAwJ3B,OAAO,CAAC,kBAAkB;IA+E1B,OAAO,CAAC,gCAAgC;IAmCxC,OAAO,CAAC,0BAA0B;YAUnB,cAAc;CAqM9B;AAqBD,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAWzE"}
|
|
@@ -8,7 +8,7 @@ import { isGeminiEnabled, isTunnelEnabled, isWorkspaceEnabled } from "../../../c
|
|
|
8
8
|
import { logger } from "../../../logger.js";
|
|
9
9
|
import { armContextActionRestartFallback } from "../../context-action-restart-fallback.js";
|
|
10
10
|
import { awaitSdkSettled } from "./settlement.js";
|
|
11
|
-
import { COMPACTION_ABORT_RESTART_GRACE_MS, DEFAULT_COMPACTION_TIMEOUT_MS, } from "../../compaction-policy.js";
|
|
11
|
+
import { COMPACTION_ABORT_RESTART_GRACE_MS, DEFAULT_COMPACTION_TIMEOUT_MS, COMPACTION_FAILURE_ERROR_CODES, } from "../../compaction-policy.js";
|
|
12
12
|
import { logSystemPrompt } from "../system-prompt-log.js";
|
|
13
13
|
import { resolvePiModel } from "../pi/shared/model.js";
|
|
14
14
|
import { resolvePiCompactionSettings, resolvePiMaxBase64ImageBlocks, } from "../pi/shared/context-window.js";
|
|
@@ -25,6 +25,7 @@ import { ensureBrowserForTool, isPlaywrightToolName } from "../browser-tool-poli
|
|
|
25
25
|
import { sanitizeToolSchemasInPayload } from "./tool-schema-sanitizer.js";
|
|
26
26
|
import { getAgentState } from "../../state.js";
|
|
27
27
|
import { resolvePiLabToolNames } from "../../../threads/lab-runtime-policy.js";
|
|
28
|
+
import { CompactionFailureError } from "../../compaction-failure.js";
|
|
28
29
|
const MAX_TURNS = 100;
|
|
29
30
|
async function loadMcpAdapter() {
|
|
30
31
|
const module = await import("pi-mcp-adapter");
|
|
@@ -660,6 +661,7 @@ export class PiCodingAgentSession {
|
|
|
660
661
|
const usage = createPiUsageAccumulator();
|
|
661
662
|
let turnCount = 0;
|
|
662
663
|
const compactionTrim = { needed: false };
|
|
664
|
+
let compactionFailure = null;
|
|
663
665
|
let unsubscribed = false;
|
|
664
666
|
const unsubscribe = session.subscribe((event) => {
|
|
665
667
|
const messages = piCodingEventToStreamMessages(event, session.sessionId);
|
|
@@ -679,9 +681,27 @@ export class PiCodingAgentSession {
|
|
|
679
681
|
});
|
|
680
682
|
}
|
|
681
683
|
}
|
|
682
|
-
if (event.type === "compaction_end"
|
|
683
|
-
|
|
684
|
-
|
|
684
|
+
if (event.type === "compaction_end") {
|
|
685
|
+
if (event.result) {
|
|
686
|
+
this.capturePostCompactionSnapshot(estimatePostCompactionTokens(event.result.summary));
|
|
687
|
+
compactionTrim.needed = true;
|
|
688
|
+
compactionFailure = null;
|
|
689
|
+
}
|
|
690
|
+
else if (!event.aborted && !event.willRetry && event.errorMessage) {
|
|
691
|
+
const errorCode = extractCompactionErrorCode(event.errorMessage);
|
|
692
|
+
const codeLabel = errorCode ?? "unknown";
|
|
693
|
+
logger.err(JSON.stringify({
|
|
694
|
+
event: "session_compaction_failed",
|
|
695
|
+
errorCode: codeLabel,
|
|
696
|
+
sessionId: session.sessionId,
|
|
697
|
+
reason: event.reason,
|
|
698
|
+
willRetry: event.willRetry,
|
|
699
|
+
error: event.errorMessage,
|
|
700
|
+
}));
|
|
701
|
+
if (errorCode && COMPACTION_FAILURE_ERROR_CODES.has(errorCode)) {
|
|
702
|
+
compactionFailure = new CompactionFailureError(`Pi auto-compaction failed (${errorCode}): ${event.errorMessage}`, { errorCode, sessionId: session.sessionId });
|
|
703
|
+
}
|
|
704
|
+
}
|
|
685
705
|
}
|
|
686
706
|
if (event.type === "tool_execution_end") {
|
|
687
707
|
// TODO: detect MCP-proxied Playwright browser actions when Pi reports them through the generic mcp tool name.
|
|
@@ -748,7 +768,7 @@ export class PiCodingAgentSession {
|
|
|
748
768
|
}
|
|
749
769
|
const assistantError = usage.assistantErrors.at(-1);
|
|
750
770
|
yield buildPiResultMessage({
|
|
751
|
-
error: runError ?? (assistantError ? new Error(assistantError) : null),
|
|
771
|
+
error: runError ?? compactionFailure ?? (assistantError ? new Error(assistantError) : null),
|
|
752
772
|
inputTokens: usage.inputTokens,
|
|
753
773
|
outputTokens: usage.outputTokens,
|
|
754
774
|
numTurns: turnCount,
|
|
@@ -787,6 +807,17 @@ function stableStringify(value) {
|
|
|
787
807
|
function estimatePostCompactionTokens(summary) {
|
|
788
808
|
return Math.ceil(summary.length / 4);
|
|
789
809
|
}
|
|
810
|
+
export function extractCompactionErrorCode(message) {
|
|
811
|
+
const codes = new Set([...message.matchAll(/(?:^|[^0-9])(400|413|504)(?=[^0-9]|$)/g)]
|
|
812
|
+
.map((match) => match[1]));
|
|
813
|
+
// A gateway may wrap an inner payload overflow in an outer 400. The inner
|
|
814
|
+
// 413 determines recovery because replaying the same body cannot succeed.
|
|
815
|
+
for (const code of ["413", "504", "400"]) {
|
|
816
|
+
if (codes.has(code))
|
|
817
|
+
return code;
|
|
818
|
+
}
|
|
819
|
+
return null;
|
|
820
|
+
}
|
|
790
821
|
function renderSystemPrompt(prompt) {
|
|
791
822
|
if (typeof prompt === "string")
|
|
792
823
|
return prompt;
|