dsh-harbor-evolution 0.8.2 → 0.9.2
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 +28 -6
- package/index.js +120 -19
- package/lib/action-drafts.js +443 -0
- package/lib/bounded-process.js +190 -0
- package/lib/candidate-runtime.js +160 -0
- package/lib/candidate.js +7 -11
- package/lib/client.js +4110 -292
- package/lib/composer-context.js +56 -0
- package/lib/credential-redaction.js +155 -0
- package/lib/dashboard.js +417 -98
- package/lib/diagnostic-observation.js +175 -0
- package/lib/diagnostic-runner.js +206 -0
- package/lib/evaluator-saves.js +129 -0
- package/lib/evolution.js +126 -32
- package/lib/historical-run-lock.js +102 -0
- package/lib/historical-web.js +52 -16
- package/lib/interaction-objects.js +56 -0
- package/lib/model-runtime.js +48 -3
- package/lib/process.js +27 -1
- package/lib/runtime-identity.js +0 -1
- package/lib/service.js +1427 -28
- package/lib/session-diagnostic.js +0 -1
- package/lib/session-redaction.js +17 -31
- package/lib/session-selection.js +5 -3
- package/lib/trial-selection.js +46 -0
- package/lib/ui-context.js +518 -0
- package/lib/web.js +32 -6
- package/lib/workbench-health.js +27 -0
- package/package.json +4 -4
- package/skills/evolve-agent-with-harbor/SKILL.md +33 -4
|
@@ -215,7 +215,6 @@ export class SessionDiagnosticService {
|
|
|
215
215
|
schema_version: 1,
|
|
216
216
|
capability: 'historical-generation-evaluation',
|
|
217
217
|
jobKind: 'historical-generation-evaluation',
|
|
218
|
-
projectRoot: identity.projectRoot,
|
|
219
218
|
scope: 'exact-cwd',
|
|
220
219
|
order: 'last-activity-desc',
|
|
221
220
|
...(createdAfter === undefined ? {} : { createdAfter: new Date(createdAfter).toISOString() }),
|
package/lib/session-redaction.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import { canonicalDigest } from './session-selection.js'
|
|
2
|
+
import {
|
|
3
|
+
containsCredentialText,
|
|
4
|
+
containsLocalPath,
|
|
5
|
+
containsOpaqueSecretText,
|
|
6
|
+
redactCredentialTextWithCount,
|
|
7
|
+
redactLocalPathsWithCount,
|
|
8
|
+
redactOpaqueSecretTextWithCount,
|
|
9
|
+
} from './credential-redaction.js'
|
|
2
10
|
|
|
3
11
|
const MAX_MESSAGE_CHARS = 4_000
|
|
4
12
|
const MAX_TRANSCRIPT_MESSAGES = 80
|
|
5
13
|
const MAX_OBSERVATION_BYTES = 512 * 1024
|
|
6
14
|
|
|
7
|
-
const SECRET_PATTERNS = [
|
|
8
|
-
/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/gi,
|
|
9
|
-
/\b(?:authorization\s*[:=]\s*(?:bearer\s+)?|bearer\s+)[A-Za-z0-9._~+/=-]{8,}/gi,
|
|
10
|
-
/\b(?:api[_-]?key|access[_-]?token|refresh[_-]?token|secret|password|passwd)\s*[:=]\s*["']?[^\s,"'}\]]{4,}/gi,
|
|
11
|
-
/\b(?:sk|rk|pk)-[A-Za-z0-9_-]{12,}\b/g,
|
|
12
|
-
/\bgh[opusr]_[A-Za-z0-9]{20,}\b/g,
|
|
13
|
-
/\bAKIA[0-9A-Z]{16}\b/g,
|
|
14
|
-
]
|
|
15
|
-
|
|
16
|
-
const ABSOLUTE_PATH = /(?:[A-Za-z]:\\(?:[^\s<>:"|?*]+\\)+[^\s<>:"|?*]*|\/(?:Users|home|private|tmp|var|etc|opt|Volumes|workspace)(?:\/[A-Za-z0-9._ @+-]+)+)/g
|
|
17
|
-
|
|
18
15
|
function replaceCanaries(value, canaries) {
|
|
19
16
|
let text = value
|
|
20
17
|
let replacements = 0
|
|
@@ -29,20 +26,13 @@ function replaceCanaries(value, canaries) {
|
|
|
29
26
|
|
|
30
27
|
function replaceSecrets(value, canaries = []) {
|
|
31
28
|
const canaryResult = replaceCanaries(value, canaries)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
text
|
|
37
|
-
|
|
38
|
-
return '[REDACTED_SECRET]'
|
|
39
|
-
})
|
|
29
|
+
const credentials = redactCredentialTextWithCount(canaryResult.text, '[REDACTED_SECRET]', false)
|
|
30
|
+
const opaque = redactOpaqueSecretTextWithCount(credentials.text, '[REDACTED_SECRET]')
|
|
31
|
+
const paths = redactLocalPathsWithCount(opaque.text, '[REDACTED_PATH]')
|
|
32
|
+
return {
|
|
33
|
+
text: paths.text,
|
|
34
|
+
replacements: canaryResult.replacements + credentials.replacements + opaque.replacements + paths.replacements,
|
|
40
35
|
}
|
|
41
|
-
text = text.replace(ABSOLUTE_PATH, () => {
|
|
42
|
-
replacements += 1
|
|
43
|
-
return '[REDACTED_PATH]'
|
|
44
|
-
})
|
|
45
|
-
return { text, replacements }
|
|
46
36
|
}
|
|
47
37
|
|
|
48
38
|
function sanitizeText(value, maxChars = MAX_MESSAGE_CHARS, canaries = []) {
|
|
@@ -181,14 +171,10 @@ function assertNoSecret(value, canaries = []) {
|
|
|
181
171
|
throw new Error('SESSION_REDACTION_FAILED: a raw Session id survived the redaction pipeline')
|
|
182
172
|
}
|
|
183
173
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (pattern.test(serialized)) {
|
|
187
|
-
throw new Error('SESSION_REDACTION_FAILED: a credential-shaped value survived the redaction pipeline')
|
|
188
|
-
}
|
|
174
|
+
if (containsCredentialText(serialized) || containsOpaqueSecretText(serialized)) {
|
|
175
|
+
throw new Error('SESSION_REDACTION_FAILED: a credential-shaped value survived the redaction pipeline')
|
|
189
176
|
}
|
|
190
|
-
|
|
191
|
-
if (ABSOLUTE_PATH.test(serialized)) {
|
|
177
|
+
if (containsLocalPath(serialized)) {
|
|
192
178
|
throw new Error('SESSION_REDACTION_FAILED: an absolute local path survived the redaction pipeline')
|
|
193
179
|
}
|
|
194
180
|
if (Buffer.byteLength(serialized) > MAX_OBSERVATION_BYTES) {
|
package/lib/session-selection.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash, randomBytes } from 'node:crypto'
|
|
2
2
|
import path from 'node:path'
|
|
3
3
|
|
|
4
|
+
import { containsCredentialText, containsLocalPath, containsOpaqueSecretText } from './credential-redaction.js'
|
|
4
5
|
import { foldSessionDiagnosticIndex } from './session-projection.js'
|
|
5
6
|
|
|
6
7
|
function canonicalize(value) {
|
|
@@ -45,9 +46,10 @@ function safeIdentity(value, rawSessionId) {
|
|
|
45
46
|
const text = typeof value === 'string' ? value : ''
|
|
46
47
|
if (rawSessionId && text.includes(rawSessionId)) return '[redacted-identity]'
|
|
47
48
|
if (
|
|
48
|
-
|
|
49
|
-
||
|
|
50
|
-
||
|
|
49
|
+
containsCredentialText(text)
|
|
50
|
+
|| containsOpaqueSecretText(text)
|
|
51
|
+
|| containsLocalPath(text)
|
|
52
|
+
|| /(?:api[_-]?key|token|secret|password|authorization)/i.test(text)
|
|
51
53
|
) return '[redacted-identity]'
|
|
52
54
|
return text.slice(0, 160)
|
|
53
55
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto'
|
|
2
|
+
import { localObjectDigest } from './interaction-objects.js'
|
|
3
|
+
|
|
4
|
+
export const MAX_SELECTED_TRIALS = 1000
|
|
5
|
+
|
|
6
|
+
/** Server-owned, frozen IDs/revisions; a query can never silently expand later. */
|
|
7
|
+
export class TrialSelectionRegistry {
|
|
8
|
+
constructor({ now = Date.now, ttlMs = 15 * 60_000, maxEntries = 256 } = {}) {
|
|
9
|
+
this.now = now
|
|
10
|
+
this.ttlMs = ttlMs
|
|
11
|
+
this.maxEntries = maxEntries
|
|
12
|
+
this.entries = new Map()
|
|
13
|
+
}
|
|
14
|
+
issue({ sessionId, projectRoot, workspace, job, mode, filters, trials }) {
|
|
15
|
+
for (const [id, entry] of this.entries) if (entry.expiresAtMs <= this.now()) this.entries.delete(id)
|
|
16
|
+
if (!['explicit', 'query-snapshot'].includes(mode) || !trials?.length || trials.length > MAX_SELECTED_TRIALS) throw new Error('HARBOR_SELECTION_INVALID: Select 1–1000 Trials.')
|
|
17
|
+
if (this.entries.size >= this.maxEntries) throw new Error('HARBOR_SELECTION_LIMIT: Too many selections; wait for old selections to expire.')
|
|
18
|
+
const members = trials.map(trial => ({ id: trial.id, revision: localObjectDigest(trial) }))
|
|
19
|
+
if (new Set(members.map(item => item.id)).size !== members.length || members.some(item => !item.id)) throw new Error('HARBOR_SELECTION_INVALID: Trial identities must be unique.')
|
|
20
|
+
const filterDigest = localObjectDigest(filters ?? {})
|
|
21
|
+
const sourceDigest = localObjectDigest({ mode, filterDigest, members })
|
|
22
|
+
const id = `hsel_${randomBytes(18).toString('base64url')}`
|
|
23
|
+
const ref = { kind: 'trial-set', id, job, stage: 'judge', sourceDigest, selectionCount: members.length }
|
|
24
|
+
const entry = { ref, sessionId: String(sessionId), projectRoot, workspace, job, mode, filterDigest, members, expiresAtMs: this.now() + this.ttlMs }
|
|
25
|
+
this.entries.set(id, structuredClone(entry))
|
|
26
|
+
return { ref, count: members.length, mode, filterDigest, expiresAt: new Date(entry.expiresAtMs).toISOString() }
|
|
27
|
+
}
|
|
28
|
+
owned(ref, owner) {
|
|
29
|
+
const entry = this.entries.get(ref.id)
|
|
30
|
+
if (!entry || entry.expiresAtMs <= this.now()) throw new Error('HARBOR_SELECTION_EXPIRED: Select the Trial set again.')
|
|
31
|
+
if (entry.sessionId !== String(owner.sessionId) || entry.projectRoot !== owner.projectRoot || entry.workspace !== owner.workspace || entry.job !== ref.job || entry.ref.sourceDigest !== ref.sourceDigest || entry.ref.selectionCount !== ref.selectionCount) throw new Error('HARBOR_SELECTION_DENIED: Selection does not belong to this Session and Job.')
|
|
32
|
+
return entry
|
|
33
|
+
}
|
|
34
|
+
memberIds(ref, owner) {
|
|
35
|
+
return this.owned(ref, owner).members.map(member => member.id)
|
|
36
|
+
}
|
|
37
|
+
resolve(ref, owner, currentTrials) {
|
|
38
|
+
const entry = this.owned(ref, owner)
|
|
39
|
+
const byId = new Map(currentTrials.map(trial => [trial.id, trial]))
|
|
40
|
+
for (const member of entry.members) {
|
|
41
|
+
const current = byId.get(member.id)
|
|
42
|
+
if (!current || localObjectDigest(current) !== member.revision) throw new Error('HARBOR_CONTEXT_STALE_SELECTION: Selected Trials changed. Reselect before continuing.')
|
|
43
|
+
}
|
|
44
|
+
return { ref: { ...entry.ref }, value: { mode: entry.mode, filterDigest: entry.filterDigest, count: entry.members.length, members: entry.members, trials: entry.members.map(member => byId.get(member.id)) } }
|
|
45
|
+
}
|
|
46
|
+
}
|