@cortexkit/opencode-magic-context 0.13.2 → 0.14.1
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 +23 -11
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli.js +59 -3
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/schema/magic-context.d.ts +61 -22
- package/dist/config/schema/magic-context.d.ts.map +1 -1
- package/dist/features/magic-context/compartment-storage.d.ts.map +1 -1
- package/dist/features/magic-context/git-commits/git-log-reader.d.ts +57 -0
- package/dist/features/magic-context/git-commits/git-log-reader.d.ts.map +1 -0
- package/dist/features/magic-context/git-commits/index.d.ts +7 -0
- package/dist/features/magic-context/git-commits/index.d.ts.map +1 -0
- package/dist/features/magic-context/git-commits/indexer.d.ts +44 -0
- package/dist/features/magic-context/git-commits/indexer.d.ts.map +1 -0
- package/dist/features/magic-context/git-commits/search-git-commits.d.ts +32 -0
- package/dist/features/magic-context/git-commits/search-git-commits.d.ts.map +1 -0
- package/dist/features/magic-context/git-commits/storage-git-commit-embeddings.d.ts +18 -0
- package/dist/features/magic-context/git-commits/storage-git-commit-embeddings.d.ts.map +1 -0
- package/dist/features/magic-context/git-commits/storage-git-commits.d.ts +47 -0
- package/dist/features/magic-context/git-commits/storage-git-commits.d.ts.map +1 -0
- package/dist/features/magic-context/memory/embedding-local.d.ts +2 -2
- package/dist/features/magic-context/memory/embedding-local.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-openai.d.ts +25 -2
- package/dist/features/magic-context/memory/embedding-openai.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding-provider.d.ts +8 -2
- package/dist/features/magic-context/memory/embedding-provider.d.ts.map +1 -1
- package/dist/features/magic-context/memory/embedding.d.ts +2 -2
- package/dist/features/magic-context/memory/embedding.d.ts.map +1 -1
- package/dist/features/magic-context/migrations.d.ts.map +1 -1
- package/dist/features/magic-context/overflow-detection.d.ts +51 -0
- package/dist/features/magic-context/overflow-detection.d.ts.map +1 -0
- package/dist/features/magic-context/search.d.ts +40 -9
- package/dist/features/magic-context/search.d.ts.map +1 -1
- package/dist/features/magic-context/storage-db.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta-persisted.d.ts +40 -0
- package/dist/features/magic-context/storage-meta-persisted.d.ts.map +1 -1
- package/dist/features/magic-context/storage-meta.d.ts +1 -1
- package/dist/features/magic-context/storage-meta.d.ts.map +1 -1
- package/dist/features/magic-context/storage.d.ts +1 -1
- package/dist/features/magic-context/storage.d.ts.map +1 -1
- package/dist/hooks/magic-context/auto-search-hint.d.ts +34 -0
- package/dist/hooks/magic-context/auto-search-hint.d.ts.map +1 -0
- package/dist/hooks/magic-context/auto-search-runner.d.ts +51 -0
- package/dist/hooks/magic-context/auto-search-runner.d.ts.map +1 -0
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts +29 -0
- package/dist/hooks/magic-context/compaction-marker-manager.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-incremental.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-partial-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-recomp.d.ts.map +1 -1
- package/dist/hooks/magic-context/compartment-runner-types.d.ts +9 -0
- package/dist/hooks/magic-context/compartment-runner-types.d.ts.map +1 -1
- package/dist/hooks/magic-context/drop-stale-reduce-calls.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-handler.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-payloads.d.ts +15 -1
- package/dist/hooks/magic-context/event-payloads.d.ts.map +1 -1
- package/dist/hooks/magic-context/event-resolvers.d.ts +20 -1
- package/dist/hooks/magic-context/event-resolvers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook-handlers.d.ts +5 -2
- package/dist/hooks/magic-context/hook-handlers.d.ts.map +1 -1
- package/dist/hooks/magic-context/hook.d.ts +14 -6
- package/dist/hooks/magic-context/hook.d.ts.map +1 -1
- package/dist/hooks/magic-context/inject-compartments.d.ts +12 -0
- package/dist/hooks/magic-context/inject-compartments.d.ts.map +1 -1
- package/dist/hooks/magic-context/note-nudger.d.ts.map +1 -1
- package/dist/hooks/magic-context/nudger.d.ts +0 -3
- package/dist/hooks/magic-context/nudger.d.ts.map +1 -1
- package/dist/hooks/magic-context/reasoning-capability.d.ts +23 -0
- package/dist/hooks/magic-context/reasoning-capability.d.ts.map +1 -0
- package/dist/hooks/magic-context/sentinel.d.ts +53 -0
- package/dist/hooks/magic-context/sentinel.d.ts.map +1 -0
- package/dist/hooks/magic-context/strip-content.d.ts +66 -16
- package/dist/hooks/magic-context/strip-content.d.ts.map +1 -1
- package/dist/hooks/magic-context/strip-structural-noise.d.ts +14 -0
- package/dist/hooks/magic-context/strip-structural-noise.d.ts.map +1 -1
- package/dist/hooks/magic-context/system-prompt-hash.d.ts +18 -5
- package/dist/hooks/magic-context/system-prompt-hash.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts +2 -0
- package/dist/hooks/magic-context/transform-compartment-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts +22 -1
- package/dist/hooks/magic-context/transform-postprocess-phase.d.ts.map +1 -1
- package/dist/hooks/magic-context/transform.d.ts +12 -0
- package/dist/hooks/magic-context/transform.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2288 -738
- package/dist/plugin/dream-timer.d.ts +24 -7
- package/dist/plugin/dream-timer.d.ts.map +1 -1
- package/dist/plugin/hooks/create-session-hooks.d.ts +4 -0
- package/dist/plugin/hooks/create-session-hooks.d.ts.map +1 -1
- package/dist/plugin/tool-registry.d.ts.map +1 -1
- package/dist/shared/models-dev-cache.d.ts +20 -6
- package/dist/shared/models-dev-cache.d.ts.map +1 -1
- package/dist/tools/ctx-note/tools.d.ts.map +1 -1
- package/dist/tools/ctx-search/constants.d.ts +1 -1
- package/dist/tools/ctx-search/constants.d.ts.map +1 -1
- package/dist/tools/ctx-search/tools.d.ts.map +1 -1
- package/dist/tools/ctx-search/types.d.ts +8 -0
- package/dist/tools/ctx-search/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/shared/models-dev-cache.test.ts +57 -6
- package/src/shared/models-dev-cache.ts +119 -38
|
@@ -4,18 +4,41 @@ interface OpenAICompatibleEmbeddingProviderOptions {
|
|
|
4
4
|
model?: string;
|
|
5
5
|
apiKey?: string;
|
|
6
6
|
}
|
|
7
|
+
type CircuitState = "closed" | "open" | "half_open";
|
|
7
8
|
export declare class OpenAICompatibleEmbeddingProvider implements EmbeddingProvider {
|
|
8
9
|
readonly modelId: string;
|
|
9
10
|
private readonly endpoint;
|
|
10
11
|
private readonly model;
|
|
11
12
|
private readonly apiKey;
|
|
12
13
|
private initialized;
|
|
14
|
+
private failureTimes;
|
|
15
|
+
private circuitOpenUntil;
|
|
16
|
+
private openLogged;
|
|
17
|
+
/** True while a half-open probe is in flight. Only the caller who set this
|
|
18
|
+
* to true is allowed to make a real HTTP call; everyone else short-
|
|
19
|
+
* circuits as if the circuit were still OPEN. */
|
|
20
|
+
private halfOpenProbeInFlight;
|
|
13
21
|
constructor(options: OpenAICompatibleEmbeddingProviderOptions);
|
|
14
22
|
initialize(): Promise<boolean>;
|
|
15
|
-
embed(text: string): Promise<Float32Array | null>;
|
|
16
|
-
embedBatch(texts: string[]): Promise<(Float32Array | null)[]>;
|
|
23
|
+
embed(text: string, signal?: AbortSignal): Promise<Float32Array | null>;
|
|
24
|
+
embedBatch(texts: string[], signal?: AbortSignal): Promise<(Float32Array | null)[]>;
|
|
17
25
|
dispose(): Promise<void>;
|
|
18
26
|
isLoaded(): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Decide what this caller should do:
|
|
29
|
+
* - "allow": CLOSED — proceed with a real request, not as a probe
|
|
30
|
+
* - "probe": HALF_OPEN — this caller owns the probe slot
|
|
31
|
+
* - "short_circuit": OPEN or half-open probe already in flight — return nulls
|
|
32
|
+
*
|
|
33
|
+
* Claiming the probe slot (setting `halfOpenProbeInFlight = true`) is done
|
|
34
|
+
* here, synchronously, so concurrent callers see the flag and short-circuit.
|
|
35
|
+
*/
|
|
36
|
+
private claimProbeOrShortCircuit;
|
|
37
|
+
private recordFailure;
|
|
38
|
+
private recordSuccess;
|
|
39
|
+
_getCircuitState(): CircuitState;
|
|
40
|
+
_getFailureCount(): number;
|
|
41
|
+
_resetCircuit(): void;
|
|
19
42
|
}
|
|
20
43
|
export {};
|
|
21
44
|
//# sourceMappingURL=embedding-openai.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding-openai.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/embedding-openai.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,UAAU,wCAAwC;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;
|
|
1
|
+
{"version":3,"file":"embedding-openai.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/embedding-openai.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,UAAU,wCAAwC;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAyCD,KAAK,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;AAEpD,qBAAa,iCAAkC,YAAW,iBAAiB;IACvE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,WAAW,CAAS;IAI5B,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,gBAAgB,CAAK;IAC7B,OAAO,CAAC,UAAU,CAAS;IAC3B;;sDAEkD;IAClD,OAAO,CAAC,qBAAqB,CAAS;gBAE1B,OAAO,EAAE,wCAAwC;IAOvD,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAc9B,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAKvE,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,CAAC;IAqHnF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,QAAQ,IAAI,OAAO;IAInB;;;;;;;;OAQG;IACH,OAAO,CAAC,wBAAwB;IAsBhC,OAAO,CAAC,aAAa;IAiCrB,OAAO,CAAC,aAAa;IAUrB,gBAAgB,IAAI,YAAY;IAQhC,gBAAgB,IAAI,MAAM;IAG1B,aAAa,IAAI,IAAI;CAMxB"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
export interface EmbeddingProvider {
|
|
2
2
|
readonly modelId: string;
|
|
3
3
|
initialize(): Promise<boolean>;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/** Embed a single text. `signal` lets callers abort the underlying network
|
|
5
|
+
* request (or long-running local inference) before the provider's internal
|
|
6
|
+
* timeout fires — used by transform-hot-path callers that have their own
|
|
7
|
+
* sub-timeout (e.g. 3s auto-search wants to cancel the 30s embed fetch). */
|
|
8
|
+
embed(text: string, signal?: AbortSignal): Promise<Float32Array | null>;
|
|
9
|
+
/** Batch variant of `embed`. Same signal semantics: aborting cancels the
|
|
10
|
+
* whole batch request (including the underlying HTTP call for remote providers). */
|
|
11
|
+
embedBatch(texts: string[], signal?: AbortSignal): Promise<(Float32Array | null)[]>;
|
|
6
12
|
dispose(): Promise<void>;
|
|
7
13
|
isLoaded(): boolean;
|
|
8
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding-provider.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/embedding-provider.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"embedding-provider.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/embedding-provider.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/B;;;iFAG6E;IAC7E,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC;IACxE;yFACqF;IACrF,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;IACpF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,QAAQ,IAAI,OAAO,CAAC;CACvB"}
|
|
@@ -4,8 +4,8 @@ import { cosineSimilarity } from "./cosine-similarity";
|
|
|
4
4
|
export declare function initializeEmbedding(config: EmbeddingConfig): void;
|
|
5
5
|
export declare function isEmbeddingEnabled(): boolean;
|
|
6
6
|
export declare function ensureEmbeddingModel(): Promise<boolean>;
|
|
7
|
-
export declare function embedText(text: string): Promise<Float32Array | null>;
|
|
8
|
-
export declare function embedBatch(texts: string[]): Promise<(Float32Array | null)[]>;
|
|
7
|
+
export declare function embedText(text: string, signal?: AbortSignal): Promise<Float32Array | null>;
|
|
8
|
+
export declare function embedBatch(texts: string[], signal?: AbortSignal): Promise<(Float32Array | null)[]>;
|
|
9
9
|
export declare function embedUnembeddedMemories(db: Database, projectPath: string, config: EmbeddingConfig, batchSize?: number): Promise<number>;
|
|
10
10
|
/**
|
|
11
11
|
* Sweep ALL projects for unembedded memories, draining each fully before
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/embedding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAG5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AA0GvD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAmBjE;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C;AAED,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC,CAO7D;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../../../src/features/magic-context/memory/embedding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAG5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AA0GvD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,CAmBjE;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C;AAED,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC,CAO7D;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAWhG;AAED,wBAAsB,UAAU,CAC5B,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,CAAC,EAAE,WAAW,GACrB,OAAO,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,EAAE,CAAC,CAelC;AAED,wBAAsB,uBAAuB,CACzC,EAAE,EAAE,QAAQ,EACZ,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,eAAe,EACvB,SAAS,SAAK,GACf,OAAO,CAAC,MAAM,CAAC,CAEjB;AAgBD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAsB,0BAA0B,CAC5C,EAAE,EAAE,QAAQ,EACZ,MAAM,EAAE,eAAe,EACvB,SAAS,SAAK,GACf,OAAO,CAAC,MAAM,CAAC,CAsEjB;AAED,8CAA8C;AAC9C,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD;AAmDD,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAS3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AA8O3C;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAkChD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-agnostic context-overflow error detection.
|
|
3
|
+
*
|
|
4
|
+
* When a provider rejects a request because the prompt exceeds its context
|
|
5
|
+
* window, we want to react:
|
|
6
|
+
* 1. Trigger emergency recovery (historian + aggressive drops) so the next
|
|
7
|
+
* turn fits.
|
|
8
|
+
* 2. If the error message reveals the real context limit, persist it as a
|
|
9
|
+
* session-specific override so pressure math is accurate going forward.
|
|
10
|
+
*
|
|
11
|
+
* Pattern list adapted from OpenCode's `packages/opencode/src/provider/error.ts`
|
|
12
|
+
* (BSD-licensed). We keep our own copy rather than importing OpenCode internals
|
|
13
|
+
* so the plugin stays decoupled from OpenCode versioning.
|
|
14
|
+
*
|
|
15
|
+
* References:
|
|
16
|
+
* - OpenCode overflow detection (origin of patterns):
|
|
17
|
+
* https://github.com/sst/opencode/blob/main/packages/opencode/src/provider/error.ts
|
|
18
|
+
* - Adapted originally from:
|
|
19
|
+
* https://github.com/badlogic/pi-mono/blob/main/packages/ai/src/utils/overflow.ts
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Regexes that match provider-reported context-overflow errors. Keep in sync
|
|
23
|
+
* with upstream OpenCode patterns — new providers can be added here as they
|
|
24
|
+
* emerge.
|
|
25
|
+
*/
|
|
26
|
+
export declare const OVERFLOW_PATTERNS: ReadonlyArray<RegExp>;
|
|
27
|
+
export interface OverflowDetection {
|
|
28
|
+
/** True if the error message matches a known overflow pattern. */
|
|
29
|
+
isOverflow: boolean;
|
|
30
|
+
/** Reported context limit in tokens, if extractable from the message. */
|
|
31
|
+
reportedLimit?: number;
|
|
32
|
+
/** The pattern that matched, useful for logging/diagnostics. */
|
|
33
|
+
matchedPattern?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Extract an error message from any reasonable shape. Events from OpenCode can
|
|
37
|
+
* deliver errors as strings, Error instances, or plain objects with `message`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function extractErrorMessage(error: unknown): string;
|
|
40
|
+
/**
|
|
41
|
+
* Detect whether an error represents a provider-side context-overflow
|
|
42
|
+
* rejection, and optionally extract the reported limit.
|
|
43
|
+
*/
|
|
44
|
+
export declare function detectOverflow(error: unknown): OverflowDetection;
|
|
45
|
+
/**
|
|
46
|
+
* Extract the reported context-limit (in tokens) from an error message if one
|
|
47
|
+
* of the known patterns matches. Returns undefined when no plausible number
|
|
48
|
+
* can be extracted. Guards against false matches via plausibility clamp.
|
|
49
|
+
*/
|
|
50
|
+
export declare function parseReportedLimit(message: string): number | undefined;
|
|
51
|
+
//# sourceMappingURL=overflow-detection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overflow-detection.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/overflow-detection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,aAAa,CAAC,MAAM,CAqBnD,CAAC;AA8BF,MAAM,WAAW,iBAAiB;IAC9B,kEAAkE;IAClE,UAAU,EAAE,OAAO,CAAC;IACpB,yEAAyE;IACzE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gEAAgE;IAChE,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CA6B1D;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,CA8BhE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAatE"}
|
|
@@ -1,14 +1,42 @@
|
|
|
1
1
|
import type { Database } from "bun:sqlite";
|
|
2
2
|
import type { RawMessage } from "../../hooks/magic-context/read-session-raw";
|
|
3
|
+
export type SearchSource = "memory" | "message" | "git_commit";
|
|
3
4
|
export interface UnifiedSearchOptions {
|
|
4
5
|
limit?: number;
|
|
5
6
|
memoryEnabled?: boolean;
|
|
6
7
|
embeddingEnabled?: boolean;
|
|
7
8
|
readMessages?: (sessionId: string) => RawMessage[];
|
|
8
|
-
embedQuery?: (text: string) => Promise<Float32Array | null>;
|
|
9
|
+
embedQuery?: (text: string, signal?: AbortSignal) => Promise<Float32Array | null>;
|
|
9
10
|
isEmbeddingRuntimeEnabled?: () => boolean;
|
|
10
11
|
/** Only return message-history hits with ordinal ≤ this value (e.g. last compartment end). -1 or omit to search all. */
|
|
11
12
|
maxMessageOrdinal?: number;
|
|
13
|
+
/** Include indexed git commits in the result set. Default false — the
|
|
14
|
+
* feature is gated behind experimental.git_commit_indexing config. */
|
|
15
|
+
gitCommitsEnabled?: boolean;
|
|
16
|
+
/** Restrict results to these sources. Omit or pass undefined to search all
|
|
17
|
+
* enabled sources. Empty array is treated as "no sources enabled" → [].
|
|
18
|
+
* Facts are NOT a source — they're already always rendered in the
|
|
19
|
+
* <session-history> block injected into message[0]. */
|
|
20
|
+
sources?: SearchSource[];
|
|
21
|
+
/** Hard-filter memories already rendered in <session-history>. The agent
|
|
22
|
+
* can see them in message[0] — surfacing them via ctx_search wastes
|
|
23
|
+
* tokens and crowds out high-signal raw-history hits. Pass null or omit
|
|
24
|
+
* to disable filtering (for callers outside the transform context that
|
|
25
|
+
* can't resolve the visible set). */
|
|
26
|
+
visibleMemoryIds?: Set<number> | null;
|
|
27
|
+
/** Abort signal — if provided, cancels in-flight embedding requests
|
|
28
|
+
* (and any downstream HTTP calls) when the caller gives up. Used by
|
|
29
|
+
* transform-hot-path callers like auto-search whose own 3s timeout
|
|
30
|
+
* needs to cancel the 30s embedding fetch. */
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
/** When true (default), increment retrieval_count on memory hits. Explicit
|
|
33
|
+
* `ctx_search` tool calls from the agent SHOULD count — the agent asked
|
|
34
|
+
* for the memory, saw it, and used it. Plugin-internal automatic surfacing
|
|
35
|
+
* (e.g. auto-search hints appended to every user prompt) should NOT count
|
|
36
|
+
* because the agent may never actually consume the hint, and even if they
|
|
37
|
+
* do, automatic surfacing doesn't indicate usefulness. Mis-counting drives
|
|
38
|
+
* spurious retrieval-count-based memory promotion decisions. */
|
|
39
|
+
countRetrievals?: boolean;
|
|
12
40
|
}
|
|
13
41
|
export interface MemorySearchResult {
|
|
14
42
|
source: "memory";
|
|
@@ -18,13 +46,6 @@ export interface MemorySearchResult {
|
|
|
18
46
|
category: string;
|
|
19
47
|
matchType: "semantic" | "fts" | "hybrid";
|
|
20
48
|
}
|
|
21
|
-
export interface FactSearchResult {
|
|
22
|
-
source: "fact";
|
|
23
|
-
content: string;
|
|
24
|
-
score: number;
|
|
25
|
-
factId: number;
|
|
26
|
-
factCategory: string;
|
|
27
|
-
}
|
|
28
49
|
export interface MessageSearchResult {
|
|
29
50
|
source: "message";
|
|
30
51
|
content: string;
|
|
@@ -33,6 +54,16 @@ export interface MessageSearchResult {
|
|
|
33
54
|
messageId: string;
|
|
34
55
|
role: string;
|
|
35
56
|
}
|
|
36
|
-
export
|
|
57
|
+
export interface GitCommitSearchResult {
|
|
58
|
+
source: "git_commit";
|
|
59
|
+
content: string;
|
|
60
|
+
score: number;
|
|
61
|
+
sha: string;
|
|
62
|
+
shortSha: string;
|
|
63
|
+
author: string | null;
|
|
64
|
+
committedAtMs: number;
|
|
65
|
+
matchType: "semantic" | "fts" | "hybrid";
|
|
66
|
+
}
|
|
67
|
+
export type UnifiedSearchResult = MemorySearchResult | MessageSearchResult | GitCommitSearchResult;
|
|
37
68
|
export declare function unifiedSearch(db: Database, sessionId: string, projectPath: string, query: string, options?: UnifiedSearchOptions): Promise<UnifiedSearchResult[]>;
|
|
38
69
|
//# sourceMappingURL=search.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,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CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,UAAU,GAAG,KAAK,GAAG,QAAQ,CAAC;CAC5C;AAED,MAAM,WAAW,mBAAmB;IAChC,MAAM,EAAE,SAAS,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IAClC,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,UAAU,GAAG,KAAK,GAAG,QAAQ,CAAC;CAC5C;AAED,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,GAAG,mBAAmB,GAAG,qBAAqB,CAAC;AA+anG,wBAAsB,aAAa,CAC/B,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,oBAAyB,GACnC,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAmFhC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-db.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage-db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAkBtC,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"storage-db.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage-db.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAkBtC,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CA6UrD;AAsHD,wBAAgB,YAAY,IAAI,QAAQ,CAsCvC;AAED,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAEzD;AAED,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,QAAQ,GAAG,MAAM,GAAG,IAAI,CAEvE;AAED,wBAAgB,aAAa,IAAI,IAAI,CAUpC;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -21,6 +21,15 @@ export declare function loadPersistedUsage(db: Database, sessionId: string): {
|
|
|
21
21
|
} | null;
|
|
22
22
|
export declare function getPersistedReasoningWatermark(db: Database, sessionId: string): number;
|
|
23
23
|
export declare function setPersistedReasoningWatermark(db: Database, sessionId: string, tagNumber: number): void;
|
|
24
|
+
/**
|
|
25
|
+
* Reset the persisted reasoning watermark for a session.
|
|
26
|
+
*
|
|
27
|
+
* The watermark is model-specific because non-interleaved models may safely
|
|
28
|
+
* rewrite/remove typed reasoning parts while providers that expose
|
|
29
|
+
* `capabilities.interleaved.field` need those same parts to survive until
|
|
30
|
+
* OpenCode's provider transform serializes them onto the wire.
|
|
31
|
+
*/
|
|
32
|
+
export declare function clearPersistedReasoningWatermark(db: Database, sessionId: string): void;
|
|
24
33
|
export declare function getPersistedNudgePlacement(db: Database, sessionId: string): {
|
|
25
34
|
messageId: string;
|
|
26
35
|
nudgeText: string;
|
|
@@ -35,9 +44,40 @@ export declare function setPersistedNoteNudgeTrigger(db: Database, sessionId: st
|
|
|
35
44
|
export declare function setPersistedNoteNudgeTriggerMessageId(db: Database, sessionId: string, triggerMessageId: string): void;
|
|
36
45
|
export declare function setPersistedDeliveredNoteNudge(db: Database, sessionId: string, text: string, messageId?: string): void;
|
|
37
46
|
export declare function clearPersistedNoteNudge(db: Database, sessionId: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Return the timestamp of the most recent ctx_note(read) call for this session,
|
|
49
|
+
* or 0 when the session has never called it. Used by note-nudger to suppress
|
|
50
|
+
* reminders when the agent has already seen notes in recent context.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getNoteLastReadAt(db: Database, sessionId: string): number;
|
|
53
|
+
/**
|
|
54
|
+
* Record that ctx_note(read) was just called for this session. The watermark is
|
|
55
|
+
* compared against note updated_at / created_at on each nudge decision.
|
|
56
|
+
*/
|
|
57
|
+
export declare function setNoteLastReadAt(db: Database, sessionId: string, at?: number): void;
|
|
38
58
|
export declare function getHistorianFailureState(db: Database, sessionId: string): PersistedHistorianFailureState;
|
|
39
59
|
export declare function incrementHistorianFailure(db: Database, sessionId: string, error: string): void;
|
|
40
60
|
export declare function clearHistorianFailureState(db: Database, sessionId: string): void;
|
|
61
|
+
export interface PersistedOverflowState {
|
|
62
|
+
/** Provider-reported context limit from the overflow error; 0 means none detected. */
|
|
63
|
+
detectedContextLimit: number;
|
|
64
|
+
/** True while recovery is still required after an overflow. */
|
|
65
|
+
needsEmergencyRecovery: boolean;
|
|
66
|
+
}
|
|
67
|
+
export declare function getOverflowState(db: Database, sessionId: string): PersistedOverflowState;
|
|
68
|
+
/**
|
|
69
|
+
* Record that a provider reported an overflow. Sets the recovery flag
|
|
70
|
+
* unconditionally; also persists the real limit if one was extracted from the
|
|
71
|
+
* error message. Transactional so the two fields always agree.
|
|
72
|
+
*/
|
|
73
|
+
export declare function recordOverflowDetected(db: Database, sessionId: string, reportedLimit: number | undefined): void;
|
|
74
|
+
/** Clear the recovery flag. Keeps the detected limit (valuable even after recovery). */
|
|
75
|
+
export declare function clearEmergencyRecovery(db: Database, sessionId: string): void;
|
|
76
|
+
/**
|
|
77
|
+
* Clear the detected limit. Called when the session switches to a different
|
|
78
|
+
* model — the old limit is no longer relevant.
|
|
79
|
+
*/
|
|
80
|
+
export declare function clearDetectedContextLimit(db: Database, sessionId: string): void;
|
|
41
81
|
export interface PersistedCompactionMarkerState {
|
|
42
82
|
boundaryMessageId: string;
|
|
43
83
|
summaryMessageId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-meta-persisted.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage-meta-persisted.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAmC5C,MAAM,WAAW,2BAA2B;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,kBAAkB;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,8BAA8B;IAC3C,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAuED,wBAAgB,kBAAkB,CAC9B,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,GAClB;IAAE,KAAK,EAAE,YAAY,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAqBnD;AAED,wBAAgB,8BAA8B,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAMtF;AAED,wBAAgB,8BAA8B,CAC1C,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAClB,IAAI,CAKN;AAED,wBAAgB,0BAA0B,CACtC,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,GAClB;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,S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ON;AAID,wBAAgB,yBAAyB,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CActF;AAED,wBAAgB,yBAAyB,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAOjG;AAED,wBAAgB,2BAA2B,CACvC,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAClB,OAAO,CAQT"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { clearHistorianFailureState, clearPersistedNoteNudge, clearPersistedNudgePlacement, clearPersistedStickyTurnReminder, getHistorianFailureState, getPersistedNoteNudge, getPersistedNudgePlacement, getPersistedReasoningWatermark, getPersistedStickyTurnReminder, getStrippedPlaceholderIds, incrementHistorianFailure, loadPersistedUsage, removeStrippedPlaceholderId, setPersistedNudgePlacement, setPersistedReasoningWatermark, setPersistedStickyTurnReminder, setStrippedPlaceholderIds, } from "./storage-meta-persisted";
|
|
1
|
+
export { clearDetectedContextLimit, clearEmergencyRecovery, clearHistorianFailureState, clearPersistedNoteNudge, clearPersistedNudgePlacement, clearPersistedReasoningWatermark, clearPersistedStickyTurnReminder, getHistorianFailureState, getNoteLastReadAt, getOverflowState, getPersistedNoteNudge, getPersistedNudgePlacement, getPersistedReasoningWatermark, getPersistedStickyTurnReminder, getStrippedPlaceholderIds, incrementHistorianFailure, loadPersistedUsage, type PersistedOverflowState, recordOverflowDetected, removeStrippedPlaceholderId, setNoteLastReadAt, setPersistedNudgePlacement, setPersistedReasoningWatermark, setPersistedStickyTurnReminder, setStrippedPlaceholderIds, } from "./storage-meta-persisted";
|
|
2
2
|
export { clearSession, getOrCreateSessionMeta, updateSessionMeta, } from "./storage-meta-session";
|
|
3
3
|
//# sourceMappingURL=storage-meta.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-meta.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage-meta.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,0BAA0B,EAC1B,uBAAuB,EACvB,4BAA4B,EAC5B,gCAAgC,EAChC,wBAAwB,EACxB,qBAAqB,EACrB,0BAA0B,EAC1B,8BAA8B,EAC9B,8BAA8B,EAC9B,yBAAyB,EACzB,yBAAyB,EACzB,kBAAkB,EAClB,2BAA2B,EAC3B,0BAA0B,EAC1B,8BAA8B,EAC9B,8BAA8B,EAC9B,yBAAyB,GAC5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACH,YAAY,EACZ,sBAAsB,EACtB,iBAAiB,GACpB,MAAM,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"storage-meta.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage-meta.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,4BAA4B,EAC5B,gCAAgC,EAChC,gCAAgC,EAChC,wBAAwB,EACxB,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,0BAA0B,EAC1B,8BAA8B,EAC9B,8BAA8B,EAC9B,yBAAyB,EACzB,yBAAyB,EACzB,kBAAkB,EAClB,KAAK,sBAAsB,EAC3B,sBAAsB,EACtB,2BAA2B,EAC3B,iBAAiB,EACjB,0BAA0B,EAC1B,8BAA8B,EAC9B,8BAA8B,EAC9B,yBAAyB,GAC5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACH,YAAY,EACZ,sBAAsB,EACtB,iBAAiB,GACpB,MAAM,wBAAwB,CAAC"}
|
|
@@ -2,7 +2,7 @@ export { buildCompartmentBlock, escapeXmlAttr, escapeXmlContent, getCompartments
|
|
|
2
2
|
export { clearCompressionDepth, getAverageCompressionDepth, getMaxCompressionDepth, incrementCompressionDepth, } from "./compression-depth-storage";
|
|
3
3
|
export { clearIndexedMessages, deleteIndexedMessage, } from "./message-index";
|
|
4
4
|
export { type ContextDatabase, closeDatabase, getDatabasePersistenceError, isDatabasePersisted, openDatabase, } from "./storage-db";
|
|
5
|
-
export { clearHistorianFailureState, clearPersistedNoteNudge, clearPersistedNudgePlacement, clearPersistedStickyTurnReminder, clearSession, getHistorianFailureState, getOrCreateSessionMeta, getPersistedNoteNudge, getPersistedNudgePlacement, getPersistedReasoningWatermark, getPersistedStickyTurnReminder, getStrippedPlaceholderIds, incrementHistorianFailure, loadPersistedUsage, removeStrippedPlaceholderId, setPersistedNudgePlacement, setPersistedReasoningWatermark, setPersistedStickyTurnReminder, setStrippedPlaceholderIds, updateSessionMeta, } from "./storage-meta";
|
|
5
|
+
export { clearDetectedContextLimit, clearEmergencyRecovery, clearHistorianFailureState, clearPersistedNoteNudge, clearPersistedNudgePlacement, clearPersistedReasoningWatermark, clearPersistedStickyTurnReminder, clearSession, getHistorianFailureState, getNoteLastReadAt, getOrCreateSessionMeta, getOverflowState, getPersistedNoteNudge, getPersistedNudgePlacement, getPersistedReasoningWatermark, getPersistedStickyTurnReminder, getStrippedPlaceholderIds, incrementHistorianFailure, loadPersistedUsage, type PersistedOverflowState, recordOverflowDetected, removeStrippedPlaceholderId, setNoteLastReadAt, setPersistedNudgePlacement, setPersistedReasoningWatermark, setPersistedStickyTurnReminder, setStrippedPlaceholderIds, updateSessionMeta, } from "./storage-meta";
|
|
6
6
|
export { addNote, deleteNote, dismissNote, getNotes, getPendingSmartNotes, getReadySmartNotes, getSessionNotes, getSmartNotes, markNoteChecked, markNoteReady, type Note, type NoteStatus, type NoteType, replaceAllSessionNotes, updateNote, } from "./storage-notes";
|
|
7
7
|
export { clearPendingOps, getPendingOps, queuePendingOp, removePendingOp, } from "./storage-ops";
|
|
8
8
|
export { getSourceContents, replaceSourceContent, saveSourceContent, } from "./storage-source";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage.ts"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ACT,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAClB,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/features/magic-context/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,qBAAqB,EACrB,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,0BAA0B,EAC1B,KAAK,WAAW,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACH,qBAAqB,EACrB,0BAA0B,EAC1B,sBAAsB,EACtB,yBAAyB,GAC5B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACH,oBAAoB,EACpB,oBAAoB,GACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,KAAK,eAAe,EACpB,aAAa,EACb,2BAA2B,EAC3B,mBAAmB,EACnB,YAAY,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EACH,yBAAyB,EACzB,sBAAsB,EACtB,0BAA0B,EAC1B,uBAAuB,EACvB,4BAA4B,EAC5B,gCAAgC,EAChC,gCAAgC,EAChC,YAAY,EACZ,wBAAwB,EACxB,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,qBAAqB,EACrB,0BAA0B,EAC1B,8BAA8B,EAC9B,8BAA8B,EAC9B,yBAAyB,EACzB,yBAAyB,EACzB,kBAAkB,EAClB,KAAK,sBAAsB,EAC3B,sBAAsB,EACtB,2BAA2B,EAC3B,iBAAiB,EACjB,0BAA0B,EAC1B,8BAA8B,EAC9B,8BAA8B,EAC9B,yBAAyB,EACzB,iBAAiB,GACpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACH,OAAO,EACP,UAAU,EACV,WAAW,EACX,QAAQ,EACR,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,eAAe,EACf,aAAa,EACb,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,QAAQ,EACb,sBAAsB,EACtB,UAAU,GACb,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,eAAe,EACf,aAAa,EACb,cAAc,EACd,eAAe,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EACH,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACH,qBAAqB,EACrB,wBAAwB,EACxB,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,GAClB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a compact "you may recall something related" hint from unified search
|
|
3
|
+
* results, ready to append to a user message.
|
|
4
|
+
*
|
|
5
|
+
* The hint intentionally compresses fragments so they feel like vague recall
|
|
6
|
+
* rather than a drop-in answer — the goal is to nudge the agent to run
|
|
7
|
+
* ctx_search for full context, not to provide the answer itself.
|
|
8
|
+
*
|
|
9
|
+
* Compression strategy per source:
|
|
10
|
+
* - memory → caveman-ultra via `cavemanCompress()` (token-dense)
|
|
11
|
+
* - git_commit → raw commit subject (already terse); prefixed with SHA + age
|
|
12
|
+
* - message → caveman-ultra, role tag
|
|
13
|
+
*
|
|
14
|
+
* Guardrails:
|
|
15
|
+
* - Per-fragment token cap (~20 tokens, ~80 chars) with ellipsis truncation
|
|
16
|
+
* - Skip fragments whose source is already present in visible session-history
|
|
17
|
+
* (caller handles) — this module only knows about search results
|
|
18
|
+
* - Hard-caps total output at ~200 tokens so misconfigured thresholds can't
|
|
19
|
+
* balloon the user message
|
|
20
|
+
*/
|
|
21
|
+
import type { UnifiedSearchResult } from "../../features/magic-context/search";
|
|
22
|
+
export interface AutoSearchHintOptions {
|
|
23
|
+
maxFragments?: number;
|
|
24
|
+
fragmentCharCap?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Build the hint text. Returns null when `results` is empty, when no fragment
|
|
28
|
+
* has meaningful content after compression, or when limits zero out the budget.
|
|
29
|
+
*
|
|
30
|
+
* This function does NOT enforce score thresholds or message-length rules —
|
|
31
|
+
* callers (the transform-time auto-search wiring) apply those gates first.
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildAutoSearchHint(results: UnifiedSearchResult[], options?: AutoSearchHintOptions): string | null;
|
|
34
|
+
//# sourceMappingURL=auto-search-hint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-search-hint.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/auto-search-hint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAQ/E,MAAM,WAAW,qBAAqB;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B;AA2CD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAC/B,OAAO,EAAE,mBAAmB,EAAE,EAC9B,OAAO,GAAE,qBAA0B,GACpC,MAAM,GAAG,IAAI,CA+Bf"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transform-time auto-search hint runner.
|
|
3
|
+
*
|
|
4
|
+
* When a new user message arrives, optionally run ctx_search against the user's
|
|
5
|
+
* prompt and append a caveman-compressed "vague recall" fragment hint to that
|
|
6
|
+
* message. The hint nudges the agent to run ctx_search for full context rather
|
|
7
|
+
* than injecting the content directly.
|
|
8
|
+
*
|
|
9
|
+
* Cache safety:
|
|
10
|
+
* - Attaches to the latest user message (the message that triggered the turn),
|
|
11
|
+
* never to message[0] or to any assistant message. Appending to the current
|
|
12
|
+
* user message happens BEFORE it reaches Anthropic's cache because this
|
|
13
|
+
* transform runs on the prompt path — same property as note nudges.
|
|
14
|
+
* - Idempotent via in-memory turn cache + `.includes()` guard in
|
|
15
|
+
* appendReminderToUserMessageById. On defer passes we re-append the same
|
|
16
|
+
* text; `.includes()` makes that a no-op.
|
|
17
|
+
* - New user turn (different message id) → compute fresh hint, new append.
|
|
18
|
+
* - Process restart → cache cleared; next pass will recompute but the user
|
|
19
|
+
* message is a fresh turn anyway, no provider cache to preserve yet.
|
|
20
|
+
*/
|
|
21
|
+
import type { Database } from "bun:sqlite";
|
|
22
|
+
import type { MessageLike } from "./transform-operations";
|
|
23
|
+
export interface AutoSearchRunnerOptions {
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
scoreThreshold: number;
|
|
26
|
+
minPromptChars: number;
|
|
27
|
+
projectPath: string;
|
|
28
|
+
memoryEnabled: boolean;
|
|
29
|
+
embeddingEnabled: boolean;
|
|
30
|
+
gitCommitsEnabled: boolean;
|
|
31
|
+
/** Memory ids already rendered in the injected <session-history> block —
|
|
32
|
+
* skip fragments that just duplicate visible memories. */
|
|
33
|
+
visibleMemoryIds?: Set<number>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Entry point. Called from transform post-processing. No-op when disabled,
|
|
37
|
+
* when there is no meaningful user message, when prompt is too short, when
|
|
38
|
+
* search returns nothing strong enough, or when the hint has already been
|
|
39
|
+
* appended for this turn.
|
|
40
|
+
*/
|
|
41
|
+
export declare function runAutoSearchHint(args: {
|
|
42
|
+
sessionId: string;
|
|
43
|
+
db: Database;
|
|
44
|
+
messages: MessageLike[];
|
|
45
|
+
options: AutoSearchRunnerOptions;
|
|
46
|
+
}): Promise<void>;
|
|
47
|
+
/** Test hook — wipe the per-turn cache. */
|
|
48
|
+
export declare function _resetAutoSearchCache(): void;
|
|
49
|
+
/** Session cleanup hook — call on session.deleted. */
|
|
50
|
+
export declare function clearAutoSearchForSession(sessionId: string): void;
|
|
51
|
+
//# sourceMappingURL=auto-search-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-search-runner.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/auto-search-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAS3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAmD1D,MAAM,WAAW,uBAAuB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,iBAAiB,EAAE,OAAO,CAAC;IAC3B;+DAC2D;IAC3D,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAClC;AAsED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,QAAQ,CAAC;IACb,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,OAAO,EAAE,uBAAuB,CAAC;CACpC,GAAG,OAAO,CAAC,IAAI,CAAC,CAuGhB;AAED,2CAA2C;AAC3C,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED,sDAAsD;AACtD,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAEjE"}
|
|
@@ -24,4 +24,33 @@ export declare function removeCompactionMarkerForSession(db: Database, sessionId
|
|
|
24
24
|
* Close the writable OpenCode DB connection used for marker injection.
|
|
25
25
|
*/
|
|
26
26
|
export declare function closeCompactionMarkerConnection(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Startup consistency check for compaction markers.
|
|
29
|
+
*
|
|
30
|
+
* Magic Context persists marker state in context.db's `session_meta`, while the
|
|
31
|
+
* actual marker rows (compaction part + summary message + summary part) live in
|
|
32
|
+
* OpenCode's separate `opencode.db`. There is no cross-DB transaction between
|
|
33
|
+
* the two stores, so a crash between writes — or any external cleanup of
|
|
34
|
+
* OpenCode's DB — can leave the two in an inconsistent state:
|
|
35
|
+
*
|
|
36
|
+
* - Phantom state: persisted in context.db but the referenced rows no longer
|
|
37
|
+
* exist in opencode.db. On next publication, the manager tries to remove a
|
|
38
|
+
* marker that isn't there, ignores the failure, and re-injects, but the
|
|
39
|
+
* stale persisted state can also confuse readers that trust it.
|
|
40
|
+
* - Orphaned rows: rows in opencode.db exist without matching context.db
|
|
41
|
+
* state. Those can't be surfaced from here (we don't track them), but the
|
|
42
|
+
* natural-healing path already handles them: the next historian publication
|
|
43
|
+
* moves the boundary forward and the new injection replaces the orphans by
|
|
44
|
+
* moving filterCompacted past them.
|
|
45
|
+
*
|
|
46
|
+
* This function scans all persisted marker states and, for each one, verifies
|
|
47
|
+
* that the referenced rows still exist in opencode.db. If any referenced row
|
|
48
|
+
* is missing, it treats the marker as inconsistent, attempts to remove
|
|
49
|
+
* whatever rows ARE still present (best-effort cleanup of half-written
|
|
50
|
+
* markers), and clears the persisted state so the next publication can
|
|
51
|
+
* re-inject cleanly.
|
|
52
|
+
*
|
|
53
|
+
* Called once at plugin startup. Safe to call multiple times (idempotent).
|
|
54
|
+
*/
|
|
55
|
+
export declare function checkCompactionMarkerConsistency(db: Database): void;
|
|
27
56
|
//# sourceMappingURL=compaction-marker-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compaction-marker-manager.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compaction-marker-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"compaction-marker-manager.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compaction-marker-manager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAmB3C;;;GAGG;AACH,wBAAgB,sCAAsC,CAClD,EAAE,EAAE,QAAQ,EACZ,SAAS,EAAE,MAAM,EACjB,kBAAkB,EAAE,MAAM,EAC1B,SAAS,CAAC,EAAE,MAAM,GACnB,IAAI,CA6CN;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAAC,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAmBtF;AAED;;GAEG;AACH,wBAAgB,+BAA+B,IAAI,IAAI,CAEtD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gCAAgC,CAAC,EAAE,EAAE,QAAQ,GAAG,IAAI,CAmGnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compartment-runner-incremental.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-incremental.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compartment-runner-incremental.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-incremental.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAoBxE,+DAA+D;AAC/D,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAEhE;AAED,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CA0OpF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compartment-runner-partial-recomp.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-partial-recomp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,WAAW,EAEd,MAAM,kDAAkD,CAAC;AAqB1D,OAAO,KAAK,EAAwB,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAU9F,MAAM,WAAW,kBAAkB;IAC/B,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,GAAG,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAChC,kEAAkE;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,WAAW,EAAE,CAAC;IACjC,iBAAiB,EAAE,WAAW,EAAE,CAAC;IACjC,gBAAgB,EAAE,WAAW,EAAE,CAAC;CACnC;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACnC,YAAY,EAAE,WAAW,EAAE,EAC3B,KAAK,EAAE,kBAAkB,GAC1B,mBAAmB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CA2CzC;AAcD,wBAAsB,4BAA4B,CAC9C,IAAI,EAAE,qBAAqB,EAC3B,KAAK,EAAE,kBAAkB,GAC1B,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"compartment-runner-partial-recomp.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-partial-recomp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,WAAW,EAEd,MAAM,kDAAkD,CAAC;AAqB1D,OAAO,KAAK,EAAwB,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAU9F,MAAM,WAAW,kBAAkB;IAC/B,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,GAAG,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,mBAAmB;IAChC,kEAAkE;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,EAAE,WAAW,EAAE,CAAC;IACjC,iBAAiB,EAAE,WAAW,EAAE,CAAC;IACjC,gBAAgB,EAAE,WAAW,EAAE,CAAC;CACnC;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACnC,YAAY,EAAE,WAAW,EAAE,EAC3B,KAAK,EAAE,kBAAkB,GAC1B,mBAAmB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CA2CzC;AAcD,wBAAsB,4BAA4B,CAC9C,IAAI,EAAE,qBAAqB,EAC3B,KAAK,EAAE,kBAAkB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAqWjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compartment-runner-recomp.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-recomp.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAwB,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAc9F,wBAAsB,4BAA4B,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"compartment-runner-recomp.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-recomp.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAwB,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAc9F,wBAAsB,4BAA4B,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,CAiU/F"}
|
|
@@ -29,6 +29,15 @@ export interface CompartmentRunnerDeps {
|
|
|
29
29
|
compressorMinCompartmentRatio?: number;
|
|
30
30
|
/** Compressor max merge depth (1-5). Compartments at or above this depth are skipped. */
|
|
31
31
|
compressorMaxMergeDepth?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Called after the runner invalidates the in-memory injection cache
|
|
34
|
+
* (post-historian publication, post-recomp promotion, post-partial-recomp
|
|
35
|
+
* promotion). The caller should register the session as flush-pending so
|
|
36
|
+
* the very next transform pass is treated as cache-busting. Without this
|
|
37
|
+
* signal, background historian work can rebuild <session-history> on a
|
|
38
|
+
* defer pass and silently bust provider cache. See council Finding #9.
|
|
39
|
+
*/
|
|
40
|
+
onInjectionCacheCleared?: (sessionId: string) => void;
|
|
32
41
|
}
|
|
33
42
|
export interface CandidateCompartment {
|
|
34
43
|
sequence: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compartment-runner-types.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,MAAM,WAAW,qBAAqB;IAClC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,EAAE,EAAE,QAAQ,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,qBAAqB,CAAC,EAAE,MAAM,kBAAkB,CAAC;IACjD,gFAAgF;IAChF,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,0EAA0E;IAC1E,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,+EAA+E;IAC/E,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC;gEAC4D;IAC5D,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kFAAkF;IAClF,6BAA6B,CAAC,EAAE,MAAM,CAAC;IACvC,yFAAyF;IACzF,uBAAuB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"compartment-runner-types.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/compartment-runner-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAA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,MAAM,MAAM,4BAA4B,GAClC;IACI,EAAE,EAAE,IAAI,CAAC;IACT,YAAY,EAAE,oBAAoB,EAAE,CAAC;IACrC,KAAK,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B,GACD;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnC,MAAM,WAAW,sBAAsB;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,0BAA0B;IACvC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drop-stale-reduce-calls.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/drop-stale-reduce-calls.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"drop-stale-reduce-calls.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/drop-stale-reduce-calls.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAIlD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAoBvD;AAoBD,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,WAAW,EAAE,EAAE,cAAc,GAAE,MAAU,GAAG,OAAO,CAiCjG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-handler.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/event-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"event-handler.d.ts","source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,CAAC;QAC1B,sBAAsB,CAAC,EAAE;YAAE,OAAO,EAAE,OAAO,CAAC;YAAC,YAAY,EAAE,MAAM,CAAA;SAAE,CAAC;KACvE,CAAC;IACF,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,UAAU,CAAC,cAAc,sCAAsC,EAAE,YAAY,CAAC,CAAC;CACtF;AAqGD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,IACvC,OAAO;IAAE,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAAE,KAAG,OAAO,CAAC,IAAI,CAAC,CAoWzF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type MagicContextEventType = "session.created" | "message.updated" | "message.removed" | "session.compacted" | "session.deleted";
|
|
1
|
+
export type MagicContextEventType = "session.created" | "session.error" | "message.updated" | "message.removed" | "session.compacted" | "session.deleted";
|
|
2
2
|
export type MagicContextEvent = {
|
|
3
3
|
type: MagicContextEventType;
|
|
4
4
|
properties?: unknown;
|
|
@@ -25,6 +25,13 @@ export interface MessageUpdatedAssistantInfo {
|
|
|
25
25
|
write?: number;
|
|
26
26
|
};
|
|
27
27
|
};
|
|
28
|
+
/** Error attached to the assistant message, if any. OpenCode attaches
|
|
29
|
+
* context-overflow errors here in addition to emitting session.error. */
|
|
30
|
+
error?: unknown;
|
|
31
|
+
}
|
|
32
|
+
export interface SessionErrorInfo {
|
|
33
|
+
sessionID: string;
|
|
34
|
+
error: unknown;
|
|
28
35
|
}
|
|
29
36
|
export interface MessageRemovedInfo {
|
|
30
37
|
sessionID: string;
|
|
@@ -36,5 +43,12 @@ export declare function getSessionProperties(properties: unknown): {
|
|
|
36
43
|
} | undefined;
|
|
37
44
|
export declare function getSessionCreatedInfo(properties: unknown): SessionCreatedInfo | null;
|
|
38
45
|
export declare function getMessageUpdatedAssistantInfo(properties: unknown): MessageUpdatedAssistantInfo | null;
|
|
46
|
+
/**
|
|
47
|
+
* Extract `session.error` event payload. The event carries `{ sessionID, error }`
|
|
48
|
+
* at the top level (no `info` wrapper). We intentionally keep `error` as
|
|
49
|
+
* `unknown` — the plugin does not depend on OpenCode's NamedError shape, the
|
|
50
|
+
* overflow detector accepts strings, Errors, or objects with `message`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function getSessionErrorInfo(properties: unknown): SessionErrorInfo | null;
|
|
39
53
|
export declare function getMessageRemovedInfo(properties: unknown): MessageRemovedInfo | null;
|
|
40
54
|
//# sourceMappingURL=event-payloads.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-payloads.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/event-payloads.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,qBAAqB,GAC3B,iBAAiB,GACjB,iBAAiB,GACjB,iBAAiB,GACjB,mBAAmB,GACnB,iBAAiB,CAAC;AAExB,MAAM,MAAM,iBAAiB,GAAG;IAC5B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,WAAW,kBAAkB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,2BAA2B;IACxC,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB;wEACoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE;QACL,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE;YACJ,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,KAAK,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;KACL,CAAC;
|
|
1
|
+
{"version":3,"file":"event-payloads.d.ts","sourceRoot":"","sources":["../../../src/hooks/magic-context/event-payloads.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,qBAAqB,GAC3B,iBAAiB,GACjB,eAAe,GACf,iBAAiB,GACjB,iBAAiB,GACjB,mBAAmB,GACnB,iBAAiB,CAAC;AAExB,MAAM,MAAM,iBAAiB,GAAG;IAC5B,IAAI,EAAE,qBAAqB,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,WAAW,kBAAkB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,2BAA2B;IACxC,IAAI,EAAE,WAAW,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB;wEACoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE;QACL,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,KAAK,CAAC,EAAE;YACJ,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,KAAK,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;KACL,CAAC;IACF;8EAC0E;IAC1E,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,oBAAoB,CAChC,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