@lexwdex-org/opencode-dcp 3.5.0 → 4.0.0
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.en.md +72 -47
- package/README.md +43 -52
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +698 -918
- package/dist/index.js.map +1 -1
- package/dist/lib/config.d.ts +7 -26
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/dtc/digest.d.ts +16 -0
- package/dist/lib/dtc/digest.d.ts.map +1 -0
- package/dist/lib/dtc/engine.d.ts +54 -0
- package/dist/lib/dtc/engine.d.ts.map +1 -0
- package/dist/lib/dtc/state.d.ts +28 -0
- package/dist/lib/dtc/state.d.ts.map +1 -0
- package/dist/lib/dtc/types.d.ts +44 -0
- package/dist/lib/dtc/types.d.ts.map +1 -0
- package/dist/lib/hooks.d.ts +62 -25
- package/dist/lib/hooks.d.ts.map +1 -1
- package/dist/lib/prompts/compaction.d.ts +2 -2
- package/dist/lib/prompts/compaction.d.ts.map +1 -1
- package/dist/lib/prune-tool.d.ts +3 -2
- package/dist/lib/prune-tool.d.ts.map +1 -1
- package/dist/lib/session-events.d.ts +7 -0
- package/dist/lib/session-events.d.ts.map +1 -0
- package/dist/lib/text.d.ts +19 -0
- package/dist/lib/text.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/lib/auto-prune.d.ts +0 -20
- package/dist/lib/auto-prune.d.ts.map +0 -1
- package/dist/lib/prune-service.d.ts +0 -104
- package/dist/lib/prune-service.d.ts.map +0 -1
- package/dist/lib/session-boundary.d.ts +0 -90
- package/dist/lib/session-boundary.d.ts.map +0 -1
- package/dist/lib/session-model.d.ts +0 -8
- package/dist/lib/session-model.d.ts.map +0 -1
- package/dist/lib/summarize.d.ts +0 -38
- package/dist/lib/summarize.d.ts.map +0 -1
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import type { Logger } from "./logger";
|
|
2
|
-
/**
|
|
3
|
-
* Per-session boundary phase. The compression boundary is NOT the raw
|
|
4
|
-
* `session.idle` instant: an idle observation opens a quiet window, and only
|
|
5
|
-
* a window that survives its full duration plus a live status probe is
|
|
6
|
-
* classified as AT-REST. Busy/retry evidence at any point cancels the window.
|
|
7
|
-
*/
|
|
8
|
-
export type BoundaryPhase = "unknown" | "busy" | "pending-rest" | "at-rest";
|
|
9
|
-
/** Why an at-rest classification fired. `probe-failopen` covers a missing
|
|
10
|
-
* endpoint, an HTTP error, and a timed-out probe — all fail open. */
|
|
11
|
-
export type RestFireReason = "window-expired" | "probe-failopen";
|
|
12
|
-
export type AtRestListener = (sessionID: string, reason: RestFireReason) => void | Promise<void>;
|
|
13
|
-
/** Internal constants — deliberately NOT config: safety semantics, not user
|
|
14
|
-
* preference (design ADR-0004). Clock and timers are injectable for tests. */
|
|
15
|
-
export declare const BOUNDARY_QUIET_MS = 2000;
|
|
16
|
-
export declare const PROBE_TIMEOUT_MS = 2000;
|
|
17
|
-
export interface SessionBoundaryDeps {
|
|
18
|
-
/** THE single busy probe (PruneService.probeBusy), injected — never
|
|
19
|
-
* imported, so this module never depends on prune-service. */
|
|
20
|
-
probeBusy: (sessionID: string) => Promise<boolean | null>;
|
|
21
|
-
logger: Logger;
|
|
22
|
-
now?: () => number;
|
|
23
|
-
setTimer?: (fn: () => void, ms: number) => unknown;
|
|
24
|
-
clearTimer?: (t: unknown) => void;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Classifies turn boundaries as AT-REST or relay-idle. Owns the ONLY
|
|
28
|
-
* per-session busy/idle event state machine (it absorbed the former
|
|
29
|
-
* SessionActivityTracker): exactly one entry per session, LRU-bounded.
|
|
30
|
-
*
|
|
31
|
-
* State model per session:
|
|
32
|
-
* - unknown no evidence (fresh, TTL-decayed, or post-lifecycle); fail-open
|
|
33
|
-
* - busy busy/retry evidence cached; TTL-decays to unknown
|
|
34
|
-
* - pending-rest quiet window armed (BOUNDARY_QUIET_MS); busy/retry cancels
|
|
35
|
-
* - at-rest rest confirmed; onAtRest fired once
|
|
36
|
-
*
|
|
37
|
-
* Idle handling: `pending-rest` + idle -> ignore (dual-publish second leg).
|
|
38
|
-
* `at-rest` + idle -> ignore on status-capable hosts (T1/T2: a real next turn
|
|
39
|
-
* is preceded by a busy/retry status that exits at-rest first). In degrade
|
|
40
|
-
* mode (T3: no status observation ever received) a legacy idle from at-rest
|
|
41
|
-
* RE-ARMS the window — every turn-end idle is a new boundary candidate.
|
|
42
|
-
*/
|
|
43
|
-
export declare class SessionBoundaryTracker {
|
|
44
|
-
private readonly sessions;
|
|
45
|
-
private readonly listeners;
|
|
46
|
-
private readonly probeBusy;
|
|
47
|
-
private readonly logger;
|
|
48
|
-
private readonly now;
|
|
49
|
-
private readonly setTimer;
|
|
50
|
-
private readonly clearTimer;
|
|
51
|
-
constructor(deps: SessionBoundaryDeps);
|
|
52
|
-
/** Register an at-rest listener; listeners fire in registration order
|
|
53
|
-
* (1. deferred drain, 2. heuristic auto prune) and are individually
|
|
54
|
-
* error-isolated: a throw or rejection is warn-logged and never blocks
|
|
55
|
-
* later listeners nor escapes into the timer callback. */
|
|
56
|
-
onAtRest(listener: AtRestListener): void;
|
|
57
|
-
/** Primary input: `session.status` event payload status type. */
|
|
58
|
-
observeStatus(sessionID: string | undefined, statusType: unknown): void;
|
|
59
|
-
/** First-class input: legacy `session.idle`. Absorbed by dedup on hosts
|
|
60
|
-
* that dual-publish; the only boundary signal on status-less hosts (T3). */
|
|
61
|
-
observeLegacyIdle(sessionID: string | undefined): void;
|
|
62
|
-
/** Lifecycle: cancel any pending window and forget the session. */
|
|
63
|
-
observeDeleted(sessionID: string | undefined): void;
|
|
64
|
-
/** Lifecycle: compaction ended; reset to unknown so the next idle opens a
|
|
65
|
-
* fresh window. */
|
|
66
|
-
observeCompacted(sessionID: string | undefined): void;
|
|
67
|
-
/** Absorbed busy-evidence cache: `busy` decays to `unknown` after the TTL;
|
|
68
|
-
* the table is LRU-bounded (pending-rest/at-rest entries have no TTL exit
|
|
69
|
-
* and rely on the cap). */
|
|
70
|
-
state(sessionID: string): BoundaryPhase;
|
|
71
|
-
dispose(sessionID: string): void;
|
|
72
|
-
private observeIdle;
|
|
73
|
-
private armWindow;
|
|
74
|
-
private onWindowExpiry;
|
|
75
|
-
private transition;
|
|
76
|
-
private cancelWindow;
|
|
77
|
-
private fireAtRest;
|
|
78
|
-
private entry;
|
|
79
|
-
private refresh;
|
|
80
|
-
private evictIfNeeded;
|
|
81
|
-
}
|
|
82
|
-
/** Ceil a cooldown to whole seconds for user-facing copy. */
|
|
83
|
-
export declare function retrySeconds(retryAfterMs: number): number;
|
|
84
|
-
/**
|
|
85
|
-
* Resolves the session ID from a host event's properties. Most events carry
|
|
86
|
-
* `sessionID` directly, but some (e.g. `session.deleted`) only carry
|
|
87
|
-
* `info: Session`. Returns `undefined` when neither is a non-empty string.
|
|
88
|
-
*/
|
|
89
|
-
export declare function eventSessionID(properties?: Record<string, any>): string | undefined;
|
|
90
|
-
//# sourceMappingURL=session-boundary.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-boundary.d.ts","sourceRoot":"","sources":["../../lib/session-boundary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEtC;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,MAAM,GAAG,cAAc,GAAG,SAAS,CAAA;AAE3E;qEACqE;AACrE,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG,gBAAgB,CAAA;AAEhE,MAAM,MAAM,cAAc,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;AAEhG;8EAC8E;AAC9E,eAAO,MAAM,iBAAiB,OAAQ,CAAA;AACtC,eAAO,MAAM,gBAAgB,OAAQ,CAAA;AAMrC,MAAM,WAAW,mBAAmB;IAChC;kEAC8D;IAC9D,S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AAI;IAIhC,OAAO,CAAC,WAAW;IAyBnB,OAAO,CAAC,SAAS;YAeH,cAAc;IAyC5B,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,UAAU;IAqBlB,OAAO,CAAC,KAAK;IAYb,OAAO,CAAC,OAAO;IAMf,OAAO,CAAC,aAAa;CAQxB;AAED,6DAA6D;AAC7D,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,GAAG,SAAS,CAMnF"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { OpenCodeClient } from "./opencode-client";
|
|
2
|
-
export interface SessionModel {
|
|
3
|
-
providerID: string;
|
|
4
|
-
modelID: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function latestUserModel(messages: unknown): SessionModel | null;
|
|
7
|
-
export declare function resolveSessionModel(client: OpenCodeClient, sessionID: string): Promise<SessionModel | null>;
|
|
8
|
-
//# sourceMappingURL=session-model.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"session-model.d.ts","sourceRoot":"","sources":["../../lib/session-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,MAAM,WAAW,YAAY;IACzB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAA;CAClB;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI,CAatE;AAED,wBAAsB,mBAAmB,CACrC,MAAM,EAAE,cAAc,EACtB,SAAS,EAAE,MAAM,GAClB,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAO9B"}
|
package/dist/lib/summarize.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { Logger } from "./logger";
|
|
2
|
-
import type { OpenCodeClient } from "./opencode-client";
|
|
3
|
-
export interface SummarizeRequest {
|
|
4
|
-
sessionID: string;
|
|
5
|
-
model: {
|
|
6
|
-
providerID: string;
|
|
7
|
-
modelID: string;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export type SummarizeResult = {
|
|
11
|
-
status: "succeeded";
|
|
12
|
-
} | {
|
|
13
|
-
status: "rejected";
|
|
14
|
-
reason: "busy";
|
|
15
|
-
} | {
|
|
16
|
-
status: "failed";
|
|
17
|
-
error: string;
|
|
18
|
-
} | {
|
|
19
|
-
status: "cooldown";
|
|
20
|
-
retryAfterMs: number;
|
|
21
|
-
};
|
|
22
|
-
interface SummarizeCoordinatorOptions {
|
|
23
|
-
failureCooldownMs: number;
|
|
24
|
-
now?: () => number;
|
|
25
|
-
}
|
|
26
|
-
export declare class SummarizeCoordinator {
|
|
27
|
-
private readonly client;
|
|
28
|
-
private readonly logger;
|
|
29
|
-
private readonly options;
|
|
30
|
-
private readonly inFlight;
|
|
31
|
-
private readonly failedAt;
|
|
32
|
-
private readonly now;
|
|
33
|
-
constructor(client: OpenCodeClient, logger: Logger, options: SummarizeCoordinatorOptions);
|
|
34
|
-
summarize(request: SummarizeRequest): Promise<SummarizeResult>;
|
|
35
|
-
private invokeNative;
|
|
36
|
-
}
|
|
37
|
-
export {};
|
|
38
|
-
//# sourceMappingURL=summarize.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"summarize.d.ts","sourceRoot":"","sources":["../../lib/summarize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,MAAM,WAAW,gBAAgB;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE;QACH,UAAU,EAAE,MAAM,CAAA;QAClB,OAAO,EA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