@yadsh/dsh-user-correction-miner 0.1.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/LICENSE +21 -0
- package/README.md +68 -0
- package/compatibility.json +16 -0
- package/cordis.patch.yml +4 -0
- package/lib/config.d.ts +109 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +80 -0
- package/lib/config.js.map +1 -0
- package/lib/dsh/commands.d.ts +25 -0
- package/lib/dsh/commands.d.ts.map +1 -0
- package/lib/dsh/commands.js +69 -0
- package/lib/dsh/commands.js.map +1 -0
- package/lib/dsh/lifecycle.d.ts +5 -0
- package/lib/dsh/lifecycle.d.ts.map +1 -0
- package/lib/dsh/lifecycle.js +10 -0
- package/lib/dsh/lifecycle.js.map +1 -0
- package/lib/dsh/plugin.d.ts +11 -0
- package/lib/dsh/plugin.d.ts.map +1 -0
- package/lib/dsh/plugin.js +58 -0
- package/lib/dsh/plugin.js.map +1 -0
- package/lib/dsh/sessions.d.ts +14 -0
- package/lib/dsh/sessions.d.ts.map +1 -0
- package/lib/dsh/sessions.js +27 -0
- package/lib/dsh/sessions.js.map +1 -0
- package/lib/dsh/storage.d.ts +108 -0
- package/lib/dsh/storage.d.ts.map +1 -0
- package/lib/dsh/storage.js +159 -0
- package/lib/dsh/storage.js.map +1 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +11 -0
- package/lib/index.js.map +1 -0
- package/lib/mining/context-extractor.d.ts +9 -0
- package/lib/mining/context-extractor.d.ts.map +1 -0
- package/lib/mining/context-extractor.js +75 -0
- package/lib/mining/context-extractor.js.map +1 -0
- package/lib/mining/engine.d.ts +39 -0
- package/lib/mining/engine.d.ts.map +1 -0
- package/lib/mining/engine.js +241 -0
- package/lib/mining/engine.js.map +1 -0
- package/lib/mining/message-text.d.ts +4 -0
- package/lib/mining/message-text.d.ts.map +1 -0
- package/lib/mining/message-text.js +14 -0
- package/lib/mining/message-text.js.map +1 -0
- package/lib/mining/prefilter.d.ts +7 -0
- package/lib/mining/prefilter.d.ts.map +1 -0
- package/lib/mining/prefilter.js +39 -0
- package/lib/mining/prefilter.js.map +1 -0
- package/lib/mining/sanitize.d.ts +3 -0
- package/lib/mining/sanitize.d.ts.map +1 -0
- package/lib/mining/sanitize.js +13 -0
- package/lib/mining/sanitize.js.map +1 -0
- package/lib/mining/scanner.d.ts +14 -0
- package/lib/mining/scanner.d.ts.map +1 -0
- package/lib/mining/scanner.js +25 -0
- package/lib/mining/scanner.js.map +1 -0
- package/lib/mining/text-budget.d.ts +7 -0
- package/lib/mining/text-budget.d.ts.map +1 -0
- package/lib/mining/text-budget.js +34 -0
- package/lib/mining/text-budget.js.map +1 -0
- package/lib/types.d.ts +81 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/lib/utils/hashing.d.ts +3 -0
- package/lib/utils/hashing.d.ts.map +1 -0
- package/lib/utils/hashing.js +8 -0
- package/lib/utils/hashing.js.map +1 -0
- package/lib/utils/workspace.d.ts +4 -0
- package/lib/utils/workspace.d.ts.map +1 -0
- package/lib/utils/workspace.js +14 -0
- package/lib/utils/workspace.js.map +1 -0
- package/package.json +78 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-plugins contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# @yadsh/dsh-user-correction-miner
|
|
2
|
+
|
|
3
|
+
Server-side DeepSeek Harness plugin that scans persisted and live session logs for explicit user corrections. The current Phase 1 implementation produces provenance-preserving correction evidence; it does not generate, approve, or apply durable rules.
|
|
4
|
+
|
|
5
|
+
## Design principles
|
|
6
|
+
|
|
7
|
+
- Corrections are evidence, not durable instructions.
|
|
8
|
+
- Every record retains its source session and event sequence.
|
|
9
|
+
- Historical reads use `ctx.sessionQuery`; the plugin does not parse persistence backends directly.
|
|
10
|
+
- Live observation stays off the model request path.
|
|
11
|
+
- Stored text is bounded and redacted by default.
|
|
12
|
+
- Plugin failures are contained and never change agent authority.
|
|
13
|
+
|
|
14
|
+
## Commands
|
|
15
|
+
|
|
16
|
+
- `/corrections` — show the current workspace summary.
|
|
17
|
+
- `/corrections scan` — incrementally scan previous sessions for the current workspace.
|
|
18
|
+
- `/corrections scan <N>` — scan at most the newest `N` workspace sessions.
|
|
19
|
+
- `/corrections review` — show recent mined evidence. This is debug output, not an approval surface.
|
|
20
|
+
|
|
21
|
+
## Configuration
|
|
22
|
+
|
|
23
|
+
```yaml
|
|
24
|
+
- id: dsh-user-correction-miner
|
|
25
|
+
config:
|
|
26
|
+
enabled: true
|
|
27
|
+
retention:
|
|
28
|
+
maxRecordsPerWorkspace: 1000
|
|
29
|
+
live:
|
|
30
|
+
maxPendingSessions: 256
|
|
31
|
+
maxPendingEventsPerSession: 32
|
|
32
|
+
pendingTtlMs: 1800000
|
|
33
|
+
analysis:
|
|
34
|
+
maxContextEvents: 20
|
|
35
|
+
maxContextBytes: 32768
|
|
36
|
+
privacy:
|
|
37
|
+
redactSecrets: true
|
|
38
|
+
persistRawMessages: false
|
|
39
|
+
maxStoredTextChars: 512
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
`privacy.maxStoredTextChars` counts Unicode code points, including the
|
|
43
|
+
ellipsis added when stored text is truncated. `analysis.maxContextBytes`
|
|
44
|
+
counts UTF-8 bytes, also including any truncation ellipsis.
|
|
45
|
+
|
|
46
|
+
`retention.maxRecordsPerWorkspace` bounds durable evidence independently for
|
|
47
|
+
each workspace. After an insert, the oldest records in that workspace are
|
|
48
|
+
deleted until the limit is met; records belonging to other workspaces are not
|
|
49
|
+
counted or removed. The storage-domain API currently has no secondary index,
|
|
50
|
+
so retention performs a workspace-filtered table scan when a record is
|
|
51
|
+
inserted. Status counting is a single pass and does not materialize or sort
|
|
52
|
+
records.
|
|
53
|
+
|
|
54
|
+
Live candidates are also bounded. At most `live.maxPendingSessions` session
|
|
55
|
+
IDs and `live.maxPendingEventsPerSession` matching event IDs per session are
|
|
56
|
+
kept in memory. Entries expire after `live.pendingTtlMs` without a session
|
|
57
|
+
event. Capacity and TTL evictions emit metadata-only warnings; pending state
|
|
58
|
+
is cleared when the plugin is disposed.
|
|
59
|
+
|
|
60
|
+
## Development
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pnpm --filter @yadsh/dsh-user-correction-miner check
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
MIT
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"deepseekHarness": {
|
|
3
|
+
"channel": "next",
|
|
4
|
+
"range": ">=0.1.1-rc.2 <0.2.0",
|
|
5
|
+
"testedReleases": [
|
|
6
|
+
"0.1.1-rc.2"
|
|
7
|
+
],
|
|
8
|
+
"requiredHostFeatures": [
|
|
9
|
+
"session-query",
|
|
10
|
+
"storage-domain",
|
|
11
|
+
"session/event",
|
|
12
|
+
"session/disposed"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"node": ">=22"
|
|
16
|
+
}
|
package/cordis.patch.yml
ADDED
package/lib/config.d.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import z from "@deepseek-ai/schemastery";
|
|
2
|
+
export interface UserCorrectionMinerConfig {
|
|
3
|
+
readonly enabled?: boolean;
|
|
4
|
+
readonly retention?: {
|
|
5
|
+
readonly maxRecordsPerWorkspace?: number;
|
|
6
|
+
};
|
|
7
|
+
readonly live?: {
|
|
8
|
+
readonly maxPendingSessions?: number;
|
|
9
|
+
readonly maxPendingEventsPerSession?: number;
|
|
10
|
+
readonly pendingTtlMs?: number;
|
|
11
|
+
};
|
|
12
|
+
readonly analysis?: {
|
|
13
|
+
readonly maxContextEvents?: number;
|
|
14
|
+
readonly maxContextBytes?: number;
|
|
15
|
+
};
|
|
16
|
+
readonly privacy?: {
|
|
17
|
+
readonly redactSecrets?: boolean;
|
|
18
|
+
readonly persistRawMessages?: boolean;
|
|
19
|
+
readonly maxStoredTextChars?: number;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface ResolvedUserCorrectionMinerConfig {
|
|
23
|
+
readonly enabled: boolean;
|
|
24
|
+
readonly retention: {
|
|
25
|
+
readonly maxRecordsPerWorkspace: number;
|
|
26
|
+
};
|
|
27
|
+
readonly live: {
|
|
28
|
+
readonly maxPendingSessions: number;
|
|
29
|
+
readonly maxPendingEventsPerSession: number;
|
|
30
|
+
readonly pendingTtlMs: number;
|
|
31
|
+
};
|
|
32
|
+
readonly analysis: {
|
|
33
|
+
readonly maxContextEvents: number;
|
|
34
|
+
readonly maxContextBytes: number;
|
|
35
|
+
};
|
|
36
|
+
readonly privacy: {
|
|
37
|
+
readonly redactSecrets: boolean;
|
|
38
|
+
readonly persistRawMessages: boolean;
|
|
39
|
+
readonly maxStoredTextChars: number;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export declare const DEFAULT_CONFIG: ResolvedUserCorrectionMinerConfig;
|
|
43
|
+
export declare function resolveConfig(config?: UserCorrectionMinerConfig): ResolvedUserCorrectionMinerConfig;
|
|
44
|
+
export declare const Config: z<Schemastery.ObjectS<{
|
|
45
|
+
enabled: z<boolean, boolean>;
|
|
46
|
+
retention: z<Schemastery.ObjectS<{
|
|
47
|
+
maxRecordsPerWorkspace: z<number, number>;
|
|
48
|
+
}>, Schemastery.ObjectT<{
|
|
49
|
+
maxRecordsPerWorkspace: z<number, number>;
|
|
50
|
+
}>>;
|
|
51
|
+
live: z<Schemastery.ObjectS<{
|
|
52
|
+
maxPendingSessions: z<number, number>;
|
|
53
|
+
maxPendingEventsPerSession: z<number, number>;
|
|
54
|
+
pendingTtlMs: z<number, number>;
|
|
55
|
+
}>, Schemastery.ObjectT<{
|
|
56
|
+
maxPendingSessions: z<number, number>;
|
|
57
|
+
maxPendingEventsPerSession: z<number, number>;
|
|
58
|
+
pendingTtlMs: z<number, number>;
|
|
59
|
+
}>>;
|
|
60
|
+
analysis: z<Schemastery.ObjectS<{
|
|
61
|
+
maxContextEvents: z<number, number>;
|
|
62
|
+
maxContextBytes: z<number, number>;
|
|
63
|
+
}>, Schemastery.ObjectT<{
|
|
64
|
+
maxContextEvents: z<number, number>;
|
|
65
|
+
maxContextBytes: z<number, number>;
|
|
66
|
+
}>>;
|
|
67
|
+
privacy: z<Schemastery.ObjectS<{
|
|
68
|
+
redactSecrets: z<boolean, boolean>;
|
|
69
|
+
persistRawMessages: z<boolean, boolean>;
|
|
70
|
+
maxStoredTextChars: z<number, number>;
|
|
71
|
+
}>, Schemastery.ObjectT<{
|
|
72
|
+
redactSecrets: z<boolean, boolean>;
|
|
73
|
+
persistRawMessages: z<boolean, boolean>;
|
|
74
|
+
maxStoredTextChars: z<number, number>;
|
|
75
|
+
}>>;
|
|
76
|
+
}>, Schemastery.ObjectT<{
|
|
77
|
+
enabled: z<boolean, boolean>;
|
|
78
|
+
retention: z<Schemastery.ObjectS<{
|
|
79
|
+
maxRecordsPerWorkspace: z<number, number>;
|
|
80
|
+
}>, Schemastery.ObjectT<{
|
|
81
|
+
maxRecordsPerWorkspace: z<number, number>;
|
|
82
|
+
}>>;
|
|
83
|
+
live: z<Schemastery.ObjectS<{
|
|
84
|
+
maxPendingSessions: z<number, number>;
|
|
85
|
+
maxPendingEventsPerSession: z<number, number>;
|
|
86
|
+
pendingTtlMs: z<number, number>;
|
|
87
|
+
}>, Schemastery.ObjectT<{
|
|
88
|
+
maxPendingSessions: z<number, number>;
|
|
89
|
+
maxPendingEventsPerSession: z<number, number>;
|
|
90
|
+
pendingTtlMs: z<number, number>;
|
|
91
|
+
}>>;
|
|
92
|
+
analysis: z<Schemastery.ObjectS<{
|
|
93
|
+
maxContextEvents: z<number, number>;
|
|
94
|
+
maxContextBytes: z<number, number>;
|
|
95
|
+
}>, Schemastery.ObjectT<{
|
|
96
|
+
maxContextEvents: z<number, number>;
|
|
97
|
+
maxContextBytes: z<number, number>;
|
|
98
|
+
}>>;
|
|
99
|
+
privacy: z<Schemastery.ObjectS<{
|
|
100
|
+
redactSecrets: z<boolean, boolean>;
|
|
101
|
+
persistRawMessages: z<boolean, boolean>;
|
|
102
|
+
maxStoredTextChars: z<number, number>;
|
|
103
|
+
}>, Schemastery.ObjectT<{
|
|
104
|
+
redactSecrets: z<boolean, boolean>;
|
|
105
|
+
persistRawMessages: z<boolean, boolean>;
|
|
106
|
+
maxStoredTextChars: z<number, number>;
|
|
107
|
+
}>>;
|
|
108
|
+
}>>;
|
|
109
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
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,gBAAgB,EAAE,MAAM,CAAC;QAClC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;KAClC,CAAC;IACF,QAAQ,CAAC,OAAO,EAAE;QAChB,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;QAChC,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;QACrC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;KACrC,CAAC;CACH;AAED,eAAO,MAAM,cAAc,EAAE,iCAmB5B,CAAC;AAUF,wBAAgB,aAAa,CAAC,MAAM,GAAE,yBAA8B,GAAG,iCAAiC,CAkDvG;AAED,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BjB,CAAC"}
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import z from "@deepseek-ai/schemastery";
|
|
2
|
+
export const DEFAULT_CONFIG = {
|
|
3
|
+
enabled: true,
|
|
4
|
+
retention: {
|
|
5
|
+
maxRecordsPerWorkspace: 1_000,
|
|
6
|
+
},
|
|
7
|
+
live: {
|
|
8
|
+
maxPendingSessions: 256,
|
|
9
|
+
maxPendingEventsPerSession: 32,
|
|
10
|
+
pendingTtlMs: 30 * 60 * 1_000,
|
|
11
|
+
},
|
|
12
|
+
analysis: {
|
|
13
|
+
maxContextEvents: 20,
|
|
14
|
+
maxContextBytes: 32_768,
|
|
15
|
+
},
|
|
16
|
+
privacy: {
|
|
17
|
+
redactSecrets: true,
|
|
18
|
+
persistRawMessages: false,
|
|
19
|
+
maxStoredTextChars: 512,
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
function positiveInteger(name, value, fallback) {
|
|
23
|
+
if (value === undefined)
|
|
24
|
+
return fallback;
|
|
25
|
+
if (!Number.isSafeInteger(value) || value < 1) {
|
|
26
|
+
throw new TypeError(`${name} must be a positive safe integer`);
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
export function resolveConfig(config = {}) {
|
|
31
|
+
return {
|
|
32
|
+
enabled: config.enabled ?? DEFAULT_CONFIG.enabled,
|
|
33
|
+
retention: {
|
|
34
|
+
maxRecordsPerWorkspace: positiveInteger("retention.maxRecordsPerWorkspace", config.retention?.maxRecordsPerWorkspace, DEFAULT_CONFIG.retention.maxRecordsPerWorkspace),
|
|
35
|
+
},
|
|
36
|
+
live: {
|
|
37
|
+
maxPendingSessions: positiveInteger("live.maxPendingSessions", config.live?.maxPendingSessions, DEFAULT_CONFIG.live.maxPendingSessions),
|
|
38
|
+
maxPendingEventsPerSession: positiveInteger("live.maxPendingEventsPerSession", config.live?.maxPendingEventsPerSession, DEFAULT_CONFIG.live.maxPendingEventsPerSession),
|
|
39
|
+
pendingTtlMs: positiveInteger("live.pendingTtlMs", config.live?.pendingTtlMs, DEFAULT_CONFIG.live.pendingTtlMs),
|
|
40
|
+
},
|
|
41
|
+
analysis: {
|
|
42
|
+
maxContextEvents: positiveInteger("analysis.maxContextEvents", config.analysis?.maxContextEvents, DEFAULT_CONFIG.analysis.maxContextEvents),
|
|
43
|
+
maxContextBytes: positiveInteger("analysis.maxContextBytes", config.analysis?.maxContextBytes, DEFAULT_CONFIG.analysis.maxContextBytes),
|
|
44
|
+
},
|
|
45
|
+
privacy: {
|
|
46
|
+
redactSecrets: config.privacy?.redactSecrets ?? DEFAULT_CONFIG.privacy.redactSecrets,
|
|
47
|
+
persistRawMessages: config.privacy?.persistRawMessages ?? DEFAULT_CONFIG.privacy.persistRawMessages,
|
|
48
|
+
maxStoredTextChars: positiveInteger("privacy.maxStoredTextChars", config.privacy?.maxStoredTextChars, DEFAULT_CONFIG.privacy.maxStoredTextChars),
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export const Config = z.object({
|
|
53
|
+
enabled: z.boolean().default(DEFAULT_CONFIG.enabled),
|
|
54
|
+
retention: z
|
|
55
|
+
.object({
|
|
56
|
+
maxRecordsPerWorkspace: z.number().min(1).default(DEFAULT_CONFIG.retention.maxRecordsPerWorkspace),
|
|
57
|
+
})
|
|
58
|
+
.default(DEFAULT_CONFIG.retention),
|
|
59
|
+
live: z
|
|
60
|
+
.object({
|
|
61
|
+
maxPendingSessions: z.number().min(1).default(DEFAULT_CONFIG.live.maxPendingSessions),
|
|
62
|
+
maxPendingEventsPerSession: z.number().min(1).default(DEFAULT_CONFIG.live.maxPendingEventsPerSession),
|
|
63
|
+
pendingTtlMs: z.number().min(1).default(DEFAULT_CONFIG.live.pendingTtlMs),
|
|
64
|
+
})
|
|
65
|
+
.default(DEFAULT_CONFIG.live),
|
|
66
|
+
analysis: z
|
|
67
|
+
.object({
|
|
68
|
+
maxContextEvents: z.number().min(1).default(DEFAULT_CONFIG.analysis.maxContextEvents),
|
|
69
|
+
maxContextBytes: z.number().min(1).default(DEFAULT_CONFIG.analysis.maxContextBytes),
|
|
70
|
+
})
|
|
71
|
+
.default(DEFAULT_CONFIG.analysis),
|
|
72
|
+
privacy: z
|
|
73
|
+
.object({
|
|
74
|
+
redactSecrets: z.boolean().default(DEFAULT_CONFIG.privacy.redactSecrets),
|
|
75
|
+
persistRawMessages: z.boolean().default(DEFAULT_CONFIG.privacy.persistRawMessages),
|
|
76
|
+
maxStoredTextChars: z.number().min(1).default(DEFAULT_CONFIG.privacy.maxStoredTextChars),
|
|
77
|
+
})
|
|
78
|
+
.default(DEFAULT_CONFIG.privacy),
|
|
79
|
+
});
|
|
80
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,0BAA0B,CAAC;AA4CzC,MAAM,CAAC,MAAM,cAAc,GAAsC;IAC/D,OAAO,EAAE,IAAI;IACb,SAAS,EAAE;QACT,sBAAsB,EAAE,KAAK;KAC9B;IACD,IAAI,EAAE;QACJ,kBAAkB,EAAE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AC,OAAO,CACnD,cAAc,CAAC,IAAI,CAAC,0BAA0B,CAC/C;QACD,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC;KAC1E,CAAC;SACD,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC;IAC/B,QAAQ,EAAE,CAAC;SACR,MAAM,CAAC;QACN,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QACrF,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,eAAe,CAAC;KACpF,CAAC;SACD,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC;IACnC,OAAO,EAAE,CAAC;SACP,MAAM,CAAC;QACN,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,aAAa,CAAC;QACxE,kBAAkB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,kBAAkB,CAAC;QAClF,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,kBAAkB,CAAC;KACzF,CAAC;SACD,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC;CACnC,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CorrectionMinerEngine } from "../mining/engine.js";
|
|
2
|
+
interface Invocation {
|
|
3
|
+
readonly rawInput: string;
|
|
4
|
+
readonly agent: {
|
|
5
|
+
readonly session: {
|
|
6
|
+
readonly header?: {
|
|
7
|
+
readonly cwd?: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
type CommandResult = {
|
|
13
|
+
readonly kind: "success" | "error";
|
|
14
|
+
readonly text: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function createCorrectionsCommand(engine: CorrectionMinerEngine): {
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
input: {
|
|
20
|
+
hint: string;
|
|
21
|
+
};
|
|
22
|
+
handler(invocation: Invocation): Promise<CommandResult>;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/dsh/commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAGjE,UAAU,UAAU;IAClB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,OAAO,EAAE;YAChB,QAAQ,CAAC,MAAM,CAAC,EAAE;gBAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;aAAE,CAAC;SAC7C,CAAC;KACH,CAAC;CACH;AAED,KAAK,aAAa,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAanF,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,qBAAqB;;;;;;wBAKxC,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC;EAwDhE"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
function reportText(report) {
|
|
2
|
+
return [
|
|
3
|
+
`Scanned ${report.sessionsScanned}/${report.sessionsConsidered} session(s).`,
|
|
4
|
+
`Inspected ${report.eventsScanned} new event(s).`,
|
|
5
|
+
`Found ${report.correctionsFound} correction message(s); added ${report.correctionsAdded}.`,
|
|
6
|
+
report.sessionsFailed === 0 ? undefined : `${report.sessionsFailed} session(s) failed; see plugin logs.`,
|
|
7
|
+
]
|
|
8
|
+
.filter((line) => line !== undefined)
|
|
9
|
+
.join("\n");
|
|
10
|
+
}
|
|
11
|
+
export function createCorrectionsCommand(engine) {
|
|
12
|
+
return {
|
|
13
|
+
name: "corrections",
|
|
14
|
+
description: "Scan and inspect user-correction evidence.",
|
|
15
|
+
input: { hint: "[scan [N]|review]" },
|
|
16
|
+
async handler(invocation) {
|
|
17
|
+
const cwd = invocation.agent.session.header?.cwd;
|
|
18
|
+
if (cwd === undefined || cwd.length === 0) {
|
|
19
|
+
return { kind: "error", text: "This session has no workspace directory." };
|
|
20
|
+
}
|
|
21
|
+
const parts = invocation.rawInput.trim().split(/\s+/u).filter(Boolean);
|
|
22
|
+
const subcommand = parts[0] ?? "status";
|
|
23
|
+
if (subcommand === "status") {
|
|
24
|
+
const count = engine.count(cwd);
|
|
25
|
+
return {
|
|
26
|
+
kind: "success",
|
|
27
|
+
text: `${count} correction evidence record(s) are stored for this workspace.`,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (subcommand === "scan") {
|
|
31
|
+
const rawLimit = parts[1];
|
|
32
|
+
const limit = rawLimit === undefined ? undefined : Number(rawLimit);
|
|
33
|
+
if (limit !== undefined && (!Number.isSafeInteger(limit) || limit < 1)) {
|
|
34
|
+
return { kind: "error", text: "Session limit must be a positive integer." };
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
return {
|
|
38
|
+
kind: "success",
|
|
39
|
+
text: reportText(await engine.scan({
|
|
40
|
+
cwd,
|
|
41
|
+
...(limit === undefined ? {} : { lastSessions: limit }),
|
|
42
|
+
incremental: true,
|
|
43
|
+
})),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
return {
|
|
48
|
+
kind: "error",
|
|
49
|
+
text: `Correction scan failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (subcommand === "review") {
|
|
54
|
+
const records = engine.list(cwd, 10);
|
|
55
|
+
if (records.length === 0) {
|
|
56
|
+
return { kind: "success", text: "No correction evidence is stored for this workspace." };
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
kind: "success",
|
|
60
|
+
text: records
|
|
61
|
+
.map((record) => `- ${record.sessionId}#${record.eventSeq}: ${record.text.replace(/\s+/gu, " ")}`)
|
|
62
|
+
.join("\n"),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return { kind: "error", text: "Usage: /corrections [scan [N]|review]" };
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/dsh/commands.ts"],"names":[],"mappings":"AAcA,SAAS,UAAU,CAAC,MAAkB;IACpC,OAAO;QACL,WAAW,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC,kBAAkB,cAAc;QAC5E,aAAa,MAAM,CAAC,aAAa,gBAAgB;QACjD,SAAS,MAAM,CAAC,gBAAgB,iCAAiC,MAAM,CAAC,gBAAgB,GAAG;QAC3F,MAAM,CAAC,cAAc,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,cAAc,sCAAsC;KACzG;SACE,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC;SACpD,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,MAA6B;IACpE,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,4CAA4C;QACzD,KAAK,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAA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|
+
/** Register only O(1) observation on the synchronous session event hot path. */
|
|
4
|
+
export declare function registerLifecycle(ctx: Context, engine: CorrectionMinerEngine): void;
|
|
5
|
+
//# sourceMappingURL=lifecycle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/dsh/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAOnF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Register only O(1) observation on the synchronous session event hot path. */
|
|
2
|
+
export function registerLifecycle(ctx, engine) {
|
|
3
|
+
ctx.on("session/event", (session, event) => {
|
|
4
|
+
engine.observeEvent(session, event);
|
|
5
|
+
});
|
|
6
|
+
ctx.on("session/disposed", (session) => {
|
|
7
|
+
engine.observeDisposed(session);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/dsh/lifecycle.ts"],"names":[],"mappings":"AAIA,gFAAgF;AAChF,MAAM,UAAU,iBAAiB,CAAC,GAAY,EAAE,MAA6B;IAC3E,GAAG,CAAC,EAAE,CAAC,eAAe,EAAE,CAAC,OAAgB,EAAE,KAAmB,EAAE,EAAE;QAChE,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,EAAE,CAAC,kBAAkB,EAAE,CAAC,OAAgB,EAAE,EAAE;QAC9C,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import { Config, type UserCorrectionMinerConfig } from "../config.js";
|
|
3
|
+
export declare const name = "user-correction-miner";
|
|
4
|
+
export declare const inject: readonly ["sessionQuery", "storageDomain"];
|
|
5
|
+
export { Config };
|
|
6
|
+
/**
|
|
7
|
+
* Host-only Phase 1 adapter. Mining failures are contained; no listener runs
|
|
8
|
+
* in `agent/pre-step`, and this plugin never mutates instructions or policy.
|
|
9
|
+
*/
|
|
10
|
+
export declare function apply(ctx: Context, rawConfig?: UserCorrectionMinerConfig): Promise<() => Promise<void>>;
|
|
11
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/dsh/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAMnD,OAAO,EACL,MAAM,EAEN,KAAK,yBAAyB,EAC/B,MAAM,cAAc,CAAC;AAWtB,eAAO,MAAM,IAAI,0BAA0B,CAAC;AAC5C,eAAO,MAAM,MAAM,4CAA6C,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,CAAC;AAkBlB;;;GAGG;AACH,wBAAsB,KAAK,CACzB,GAAG,EAAE,OAAO,EACZ,SAAS,GAAE,yBAA8B,GACxC,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAyC9B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createHostLoggerSink, getPluginLogger, } from "@yadsh/dsh-plugin-log";
|
|
2
|
+
import { Config, resolveConfig, } from "../config.js";
|
|
3
|
+
import { CorrectionMinerEngine } from "../mining/engine.js";
|
|
4
|
+
import { createCorrectionsCommand } from "./commands.js";
|
|
5
|
+
import { registerLifecycle } from "./lifecycle.js";
|
|
6
|
+
import { createSessionSource } from "./sessions.js";
|
|
7
|
+
import { CORRECTION_MINER_DOMAIN, DomainCorrectionStore, } from "./storage.js";
|
|
8
|
+
export const name = "user-correction-miner";
|
|
9
|
+
export const inject = ["sessionQuery", "storageDomain"];
|
|
10
|
+
export { Config };
|
|
11
|
+
function errorFields(error) {
|
|
12
|
+
return { reason: error instanceof Error ? error.message : String(error) };
|
|
13
|
+
}
|
|
14
|
+
async function closeResources(domain, logger) {
|
|
15
|
+
await domain?.close().catch((error) => {
|
|
16
|
+
logger.warn("storage.close_failed", errorFields(error));
|
|
17
|
+
});
|
|
18
|
+
await logger.close();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Host-only Phase 1 adapter. Mining failures are contained; no listener runs
|
|
22
|
+
* in `agent/pre-step`, and this plugin never mutates instructions or policy.
|
|
23
|
+
*/
|
|
24
|
+
export async function apply(ctx, rawConfig = {}) {
|
|
25
|
+
const logger = getPluginLogger({
|
|
26
|
+
pluginId: "dsh-user-correction-miner",
|
|
27
|
+
console: "trace",
|
|
28
|
+
consoleSink: createHostLoggerSink(ctx.logger),
|
|
29
|
+
});
|
|
30
|
+
let domain;
|
|
31
|
+
let engine;
|
|
32
|
+
try {
|
|
33
|
+
const config = resolveConfig(rawConfig);
|
|
34
|
+
if (!config.enabled) {
|
|
35
|
+
logger.info("plugin.disabled");
|
|
36
|
+
return async () => logger.close();
|
|
37
|
+
}
|
|
38
|
+
domain = await ctx.storageDomain.open(CORRECTION_MINER_DOMAIN);
|
|
39
|
+
const createdEngine = new CorrectionMinerEngine(createSessionSource(ctx.sessionQuery), new DomainCorrectionStore(domain), config, logger.child("engine"));
|
|
40
|
+
engine = createdEngine;
|
|
41
|
+
registerLifecycle(ctx, createdEngine);
|
|
42
|
+
ctx.inject(["commands"], (commandCtx) => commandCtx.commands.register(createCorrectionsCommand(createdEngine)));
|
|
43
|
+
logger.info("plugin.ready", {
|
|
44
|
+
domain: CORRECTION_MINER_DOMAIN.name,
|
|
45
|
+
maxRecordsPerWorkspace: config.retention.maxRecordsPerWorkspace,
|
|
46
|
+
maxContextEvents: config.analysis.maxContextEvents,
|
|
47
|
+
maxContextBytes: config.analysis.maxContextBytes,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
logger.error("plugin.initialization_failed", errorFields(error));
|
|
52
|
+
}
|
|
53
|
+
return async () => {
|
|
54
|
+
engine?.dispose();
|
|
55
|
+
await closeResources(domain, logger);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/dsh/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EACpB,eAAe,GAEhB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,MAAM,EACN,aAAa,GAEd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EACL,uBAAuB,EACvB,qBAAqB,GAEtB,MAAM,cAAc,CAAC;AAEtB,MAAM,CAAC,MAAM,IAAI,GAAG,uBAAuB,CAAC;AAC5C,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,cAAc,EAAE,eAAe,CAAU,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,CAAC;AAOlB,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,EAAE,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AAC5E,CAAC;AAED,KAAK,UAA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AU,EAAE,EAAE,CACrC,UAAqC,CAAC,QAAQ,CAAC,QAAQ,CACtD,wBAAwB,CAAC,aAAa,CAAC,CACxC,CACF,CAAC;QACF,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE;YAC1B,MAAM,EAAE,uBAAuB,CAAC,IAAI;YACpC,sBAAsB,EAAE,MAAM,CAAC,SAAS,CAAC,sBAAsB;YAC/D,gBAAgB,EAAE,MAAM,CAAC,QAAQ,CAAC,gBAAgB;YAClD,eAAe,EAAE,MAAM,CAAC,QAAQ,CAAC,eAAe;SACjD,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,8BAA8B,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,KAAK,IAAI,EAAE;QAChB,MAAM,EAAE,OAAO,EAAE,CAAC;QAClB,MAAM,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SessionLogSnapshot, SessionQueryEngine, SessionRecord } from "@deepseek-ai/dsh-session-query";
|
|
2
|
+
import type { ScanRequest } from "../types.js";
|
|
3
|
+
export interface SessionQueryLike {
|
|
4
|
+
listSessions(signal?: AbortSignal): Promise<SessionRecord[]>;
|
|
5
|
+
readSession(sessionId: string): Promise<SessionLogSnapshot>;
|
|
6
|
+
}
|
|
7
|
+
export declare class SessionSource {
|
|
8
|
+
private readonly query;
|
|
9
|
+
constructor(query: SessionQueryLike);
|
|
10
|
+
list(request: ScanRequest, signal?: AbortSignal): Promise<SessionRecord[]>;
|
|
11
|
+
read(sessionId: string): Promise<SessionLogSnapshot>;
|
|
12
|
+
}
|
|
13
|
+
export declare function createSessionSource(query: SessionQueryEngine): SessionSource;
|
|
14
|
+
//# sourceMappingURL=sessions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../src/dsh/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACd,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,MAAM,WAAW,gBAAgB;IAC/B,YAAY,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC;IAC7D,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC7D;AAED,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,gBAAgB;IAE9C,IAAI,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAWhF,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAGrD;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,GAAG,aAAa,CAE5E"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { sameWorkspace } from "../utils/workspace.js";
|
|
2
|
+
export class SessionSource {
|
|
3
|
+
query;
|
|
4
|
+
constructor(query) {
|
|
5
|
+
this.query = query;
|
|
6
|
+
}
|
|
7
|
+
async list(request, signal) {
|
|
8
|
+
const all = await this.query.listSessions(signal);
|
|
9
|
+
const matching = all.filter(({ header }) => {
|
|
10
|
+
if (!sameWorkspace(header.cwd, request.cwd))
|
|
11
|
+
return false;
|
|
12
|
+
if (request.from !== undefined && header.createdAt < request.from)
|
|
13
|
+
return false;
|
|
14
|
+
if (request.to !== undefined && header.createdAt > request.to)
|
|
15
|
+
return false;
|
|
16
|
+
return true;
|
|
17
|
+
});
|
|
18
|
+
return request.lastSessions === undefined ? matching : matching.slice(0, request.lastSessions);
|
|
19
|
+
}
|
|
20
|
+
read(sessionId) {
|
|
21
|
+
return this.query.readSession(sessionId);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function createSessionSource(query) {
|
|
25
|
+
return new SessionSource(query);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=sessions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessions.js","sourceRoot":"","sources":["../../src/dsh/sessions.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAOtD,MAAM,OAAO,aAAa;IACK;IAA7B,YAA6B,KAAuB;QAAvB,UAAK,GAAL,KAAK,CAAkB;IAAG,CAAC;IAExD,KAAK,CAAC,IAAI,CAAC,OAAoB,EAAE,MAAoB;QACnD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAClD,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE;YACzC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC;gBAAE,OAAO,KAAK,CAAC;YAC1D,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,IAAI;gBAAE,OAAO,KAAK,CAAC;YAChF,IAAI,OAAO,CAAC,EAAE,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,EAAE;gBAAE,OAAO,KAAK,CAAC;YAC5E,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IACjG,CAAC;IAED,IA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