@boyingliu01/dsh-plugin-xp-gate 0.31.4 → 0.32.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 +51 -2
- package/lib/client.js +760 -0
- package/lib/command.d.ts +11 -5
- package/lib/command.d.ts.map +1 -1
- package/lib/command.js +19 -13
- package/lib/command.js.map +1 -1
- package/lib/credentials.d.ts +39 -0
- package/lib/credentials.d.ts.map +1 -0
- package/lib/credentials.js +57 -0
- package/lib/credentials.js.map +1 -0
- package/lib/delphi-config.d.ts +34 -3
- package/lib/delphi-config.d.ts.map +1 -1
- package/lib/delphi-config.js +117 -48
- package/lib/delphi-config.js.map +1 -1
- package/lib/delphi-run.d.ts +1 -1
- package/lib/delphi-run.d.ts.map +1 -1
- package/lib/delphi-run.js +24 -3
- package/lib/delphi-run.js.map +1 -1
- package/lib/delphi-settings.d.ts +52 -0
- package/lib/delphi-settings.d.ts.map +1 -0
- package/lib/delphi-settings.js +76 -0
- package/lib/delphi-settings.js.map +1 -0
- package/lib/delphi.d.ts +6 -0
- package/lib/delphi.d.ts.map +1 -1
- package/lib/delphi.js +101 -55
- package/lib/delphi.js.map +1 -1
- package/lib/evidence.d.ts +70 -0
- package/lib/evidence.d.ts.map +1 -0
- package/lib/evidence.js +92 -0
- package/lib/evidence.js.map +1 -0
- package/lib/gate-runner.d.ts +33 -2
- package/lib/gate-runner.d.ts.map +1 -1
- package/lib/gate-runner.js +53 -4
- package/lib/gate-runner.js.map +1 -1
- package/lib/git-context.d.ts +26 -0
- package/lib/git-context.d.ts.map +1 -0
- package/lib/git-context.js +30 -0
- package/lib/git-context.js.map +1 -0
- package/lib/hooks.d.ts +55 -0
- package/lib/hooks.d.ts.map +1 -0
- package/lib/hooks.js +152 -0
- package/lib/hooks.js.map +1 -0
- package/lib/index.d.ts +79 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +385 -12
- package/lib/index.js.map +1 -1
- package/lib/skill-provider.d.ts +15 -0
- package/lib/skill-provider.d.ts.map +1 -0
- package/lib/skill-provider.js +205 -0
- package/lib/skill-provider.js.map +1 -0
- package/lib/sprint.d.ts +60 -0
- package/lib/sprint.d.ts.map +1 -0
- package/lib/sprint.js +92 -0
- package/lib/sprint.js.map +1 -0
- package/package.json +26 -10
- package/skills/delphi-review/AGENTS.md +3 -3
- package/skills/sprint-flow/AGENTS.md +3 -3
- package/skills/test-specification-alignment/AGENTS.md +3 -3
package/lib/delphi-run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delphi-run.js","sourceRoot":"","sources":["../src/delphi-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"delphi-run.js","sourceRoot":"","sources":["../src/delphi-run.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAGnD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,MAA+B;IACvD,IAAI,CAAC,MAAM,EAAE,OAAO;QAAE,OAAM;IAC5B,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAA;IACjE,KAAK,CAAC,IAAI,GAAG,YAAY,CAAA;IACzB,MAAM,KAAK,CAAA;AACb,CAAC;AAED,mFAAmF;AACnF,MAAM,yBAAyB,GAAG,EAAE,CAAC;AACrC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAS7B,gFAAgF;AAChF,SAAS,cAAc,CAAC,IAAgB,EAAE,OAAe;IACvD,OAAO,CACL,eAAe,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,oDAAoD;QAC1F,6DAA6D,OAAO,MAAM;QAC1E,mFAAmF;QACnF,0FAA0F;QAC1F,wFAAwF;QACxF,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|
3
|
+
*
|
|
4
|
+
* `.delphi-config.json` remains the portable, cross-platform source that the skill,
|
|
5
|
+
* the CI validator, and the other plugins share. This module adds a SECOND source —
|
|
6
|
+
* the `delphi` section of the plugin's Config, editable from the Plugins page — and
|
|
7
|
+
* the rules that keep the two from disagreeing in a way that costs money:
|
|
8
|
+
*
|
|
9
|
+
* - the settings layer, when it has any seats, WINS (it is the more recent edit)
|
|
10
|
+
* - it must still satisfy every Delphi invariant (`validateSeats`) before a single
|
|
11
|
+
* request is made, because a form is a convenience and the host is the authority
|
|
12
|
+
* - an absent settings layer resolves to `undefined`, so an existing JSON user is
|
|
13
|
+
* never silently migrated to an empty panel
|
|
14
|
+
*
|
|
15
|
+
* @test REQ-DSH-017 Delphi seats are configurable from the DSH settings document
|
|
16
|
+
* @intent 把 DSH settings 里的 delphi 段解析成与 JSON 同构的席位,并在这条新路径上
|
|
17
|
+
* 重新执行三席/三模型互异/非占位符等不变量,避免表单绕过校验。
|
|
18
|
+
* @covers AC-DSH-017-01 AC-DSH-017-02 AC-DSH-017-03
|
|
19
|
+
*/
|
|
20
|
+
import type { ExpertSeat } from "./delphi.js";
|
|
21
|
+
/** One seat as the settings document stores it. */
|
|
22
|
+
export interface DelphiSettingsSeat {
|
|
23
|
+
role: string;
|
|
24
|
+
model: string;
|
|
25
|
+
maxTokens?: number;
|
|
26
|
+
}
|
|
27
|
+
/** The `delphi` section of the plugin Config. */
|
|
28
|
+
export interface DelphiSettingsLayer {
|
|
29
|
+
baseUrl?: string;
|
|
30
|
+
apiKey?: string;
|
|
31
|
+
seats?: DelphiSettingsSeat[];
|
|
32
|
+
thresholdPercent?: number;
|
|
33
|
+
maxRounds?: number;
|
|
34
|
+
}
|
|
35
|
+
/** What {@link seatsFromSettings} produces: seats plus the transport they need. */
|
|
36
|
+
export interface SettingsReviewSetup {
|
|
37
|
+
readonly seats: readonly ExpertSeat[];
|
|
38
|
+
readonly baseUrl: string;
|
|
39
|
+
/** The still-unexpanded `api_key` expression; the caller resolves it. */
|
|
40
|
+
readonly apiKeyExpression: string;
|
|
41
|
+
readonly thresholdPercent: number;
|
|
42
|
+
readonly maxRounds: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Turn the settings layer into a review setup, or `undefined` when it holds no seats.
|
|
46
|
+
*
|
|
47
|
+
* Throws the same errors the JSON path throws, so a caller can report either source
|
|
48
|
+
* through one handler. `validateSeats` runs before any network call, which is what
|
|
49
|
+
* makes a misconfigured panel a configuration error rather than a provider failure.
|
|
50
|
+
*/
|
|
51
|
+
export declare function seatsFromSettings(layer: DelphiSettingsLayer | undefined): SettingsReviewSetup | undefined;
|
|
52
|
+
//# sourceMappingURL=delphi-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delphi-settings.d.ts","sourceRoot":"","sources":["../src/delphi-settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAI7C,mDAAmD;AACnD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,iDAAiD;AACjD,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,kBAAkB,EAAE,CAAA;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,mFAAmF;AACnF,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,CAAA;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,yEAAyE;IACzE,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAC3B;AA6BD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,mBAAmB,GAAG,SAAS,GAAG,mBAAmB,GAAG,SAAS,CA0BzG"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delphi seats supplied through DSH's own settings document.
|
|
3
|
+
*
|
|
4
|
+
* `.delphi-config.json` remains the portable, cross-platform source that the skill,
|
|
5
|
+
* the CI validator, and the other plugins share. This module adds a SECOND source —
|
|
6
|
+
* the `delphi` section of the plugin's Config, editable from the Plugins page — and
|
|
7
|
+
* the rules that keep the two from disagreeing in a way that costs money:
|
|
8
|
+
*
|
|
9
|
+
* - the settings layer, when it has any seats, WINS (it is the more recent edit)
|
|
10
|
+
* - it must still satisfy every Delphi invariant (`validateSeats`) before a single
|
|
11
|
+
* request is made, because a form is a convenience and the host is the authority
|
|
12
|
+
* - an absent settings layer resolves to `undefined`, so an existing JSON user is
|
|
13
|
+
* never silently migrated to an empty panel
|
|
14
|
+
*
|
|
15
|
+
* @test REQ-DSH-017 Delphi seats are configurable from the DSH settings document
|
|
16
|
+
* @intent 把 DSH settings 里的 delphi 段解析成与 JSON 同构的席位,并在这条新路径上
|
|
17
|
+
* 重新执行三席/三模型互异/非占位符等不变量,避免表单绕过校验。
|
|
18
|
+
* @covers AC-DSH-017-01 AC-DSH-017-02 AC-DSH-017-03
|
|
19
|
+
*/
|
|
20
|
+
import { validateSeats } from "./delphi.js";
|
|
21
|
+
import { DelphiSetupError } from "./delphi-config.js";
|
|
22
|
+
/** Delphi's documented defaults, applied when the settings omit a consensus value. */
|
|
23
|
+
const DEFAULT_THRESHOLD_PERCENT = 90;
|
|
24
|
+
const DEFAULT_MAX_ROUNDS = 5;
|
|
25
|
+
/**
|
|
26
|
+
* Is the settings layer actually configured?
|
|
27
|
+
*
|
|
28
|
+
* Judged by seats alone: a half-filled form (a gateway typed but no seats yet) must
|
|
29
|
+
* not pre-empt the JSON file, or opening the page would quietly disable every
|
|
30
|
+
* existing `.delphi-config.json` review.
|
|
31
|
+
*/
|
|
32
|
+
function isConfigured(layer) {
|
|
33
|
+
return Array.isArray(layer?.seats) && layer.seats.length > 0;
|
|
34
|
+
}
|
|
35
|
+
/** Reject a layer that names no gateway, rather than dialling a guess. */
|
|
36
|
+
function requireBaseUrl(layer) {
|
|
37
|
+
const baseUrl = (layer.baseUrl ?? "").trim();
|
|
38
|
+
if (baseUrl === "") {
|
|
39
|
+
throw new DelphiSetupError("The Delphi settings have seats but no base_url. Set the gateway URL, " +
|
|
40
|
+
"or clear the seats to fall back to .delphi-config.json.");
|
|
41
|
+
}
|
|
42
|
+
return baseUrl;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Turn the settings layer into a review setup, or `undefined` when it holds no seats.
|
|
46
|
+
*
|
|
47
|
+
* Throws the same errors the JSON path throws, so a caller can report either source
|
|
48
|
+
* through one handler. `validateSeats` runs before any network call, which is what
|
|
49
|
+
* makes a misconfigured panel a configuration error rather than a provider failure.
|
|
50
|
+
*/
|
|
51
|
+
export function seatsFromSettings(layer) {
|
|
52
|
+
if (!isConfigured(layer))
|
|
53
|
+
return undefined;
|
|
54
|
+
// Narrowed by isConfigured; non-null assertions are avoided to keep strict TS honest.
|
|
55
|
+
const configured = layer;
|
|
56
|
+
const rawSeats = configured.seats ?? [];
|
|
57
|
+
const seats = rawSeats.map((seat, index) => ({
|
|
58
|
+
id: seat.role || `Expert ${String.fromCharCode(65 + index)}`,
|
|
59
|
+
role: seat.role || `expert${index}`,
|
|
60
|
+
// Trim: a model id pasted from a catalog picker can carry padding, and
|
|
61
|
+
// `" model-a"` is not the model that was intended.
|
|
62
|
+
model: (seat.model ?? "").trim(),
|
|
63
|
+
maxTokens: seat.maxTokens,
|
|
64
|
+
}));
|
|
65
|
+
// The invariants are the reason this module exists; they run before the
|
|
66
|
+
// transport is even built.
|
|
67
|
+
validateSeats(seats);
|
|
68
|
+
return {
|
|
69
|
+
seats,
|
|
70
|
+
baseUrl: requireBaseUrl(configured),
|
|
71
|
+
apiKeyExpression: configured.apiKey ?? "",
|
|
72
|
+
thresholdPercent: configured.thresholdPercent ?? DEFAULT_THRESHOLD_PERCENT,
|
|
73
|
+
maxRounds: configured.maxRounds ?? DEFAULT_MAX_ROUNDS,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=delphi-settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delphi-settings.js","sourceRoot":"","sources":["../src/delphi-settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AA4BrD,sFAAsF;AACtF,MAAM,yBAAyB,GAAG,EAAE,CAAA;AACpC,MAAM,kBAAkB,GAAG,CAAC,CAAA;AAE5B;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,KAAsC;IAC1D,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAA;AAC9D,CAAC;AAED,0EAA0E;AAC1E,SAAS,cAAc,CAAC,KAA0B;IAChD,MAAM,OAAO,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IAC5C,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;QACnB,MAAM,IAAI,gBAAgB,CACxB,uEAAuE;YACrE,yDAAyD,CAC5D,CAAA;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAsC;IACtE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IAC1C,sFAAsF;IACtF,MAAM,UAAU,GAAG,KAA4B,CAAA;IAC/C,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,IAAI,EAAE,CAAA;IAEvC,MAAM,KAAK,GAAiB,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;QACzD,EAAE,EAAE,IAAI,CAAC,IAAI,IAAI,UAAU,MAAM,CAAC,YAAY,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE;QAC5D,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,SAAS,KAAK,EAAE;QACnC,uEAAuE;QACvE,mDAAmD;QACnD,KAAK,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE;QAChC,SAAS,EAAE,IAAI,CAAC,SAAS;KAC1B,CAAC,CAAC,CAAA;IAEH,wEAAwE;IACxE,2BAA2B;IAC3B,aAAa,CAAC,KAAK,CAAC,CAAA;IAEpB,OAAO;QACL,KAAK;QACL,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC;QACnC,gBAAgB,EAAE,UAAU,CAAC,MAAM,IAAI,EAAE;QACzC,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,IAAI,yBAAyB;QAC1E,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,kBAAkB;KACtD,CAAA;AACH,CAAC"}
|
package/lib/delphi.d.ts
CHANGED
|
@@ -57,6 +57,12 @@ export interface DelphiOptions {
|
|
|
57
57
|
readonly maxRounds?: number;
|
|
58
58
|
/** Per-request ceiling; the caller owns the overall timeout. */
|
|
59
59
|
readonly timeoutMs?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Caller cancellation. Aborting it stops the in-flight request immediately and
|
|
62
|
+
* raises TOOL_ABORTED, matching the three gate tools. Without this a cancelled
|
|
63
|
+
* review kept spending money on requests the user had already abandoned.
|
|
64
|
+
*/
|
|
65
|
+
readonly signal?: AbortSignal;
|
|
60
66
|
readonly fetchImpl?: typeof fetch;
|
|
61
67
|
}
|
|
62
68
|
/** Raised when the configured seats cannot satisfy the Delphi invariants. */
|
package/lib/delphi.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delphi.d.ts","sourceRoot":"","sources":["../src/delphi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,+DAA+D;AAC/D,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,8EAA8E;IAC9E,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC5B;AAED,sDAAsD;AACtD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IACrC,QAAQ,CAAC,OAAO,EAAE,UAAU,GAAG,iBAAiB,GAAG,oBAAoB,GAAG,OAAO,CAAA;IACjF,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,4DAA4D;IAC5D,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,uCAAuC;AACvC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAA;IAC3C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAA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C,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,CAAA;IACjC,UAAU,EAAE,MAAM,CAAA;CACnB,CAWA;AA0ID;;;GAGG;AACH,wBAAsB,QAAQ,CAC5B,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,MAAM,GACxC,OAAO,CAAC,WAAW,CAAC,CA8BtB"}
|
package/lib/delphi.js
CHANGED
|
@@ -21,6 +21,11 @@ const REQUIRED_EXPERTS = 3;
|
|
|
21
21
|
const DEFAULT_THRESHOLD_PERCENT = 90;
|
|
22
22
|
const DEFAULT_MAX_TOKENS = 8000;
|
|
23
23
|
const DEFAULT_TIMEOUT_MS = 180_000;
|
|
24
|
+
/**
|
|
25
|
+
* Sampling temperature. Low on purpose: reviewers must apply the rubric the same
|
|
26
|
+
* way every round, and creativity in a verdict is noise, not signal.
|
|
27
|
+
*/
|
|
28
|
+
const REVIEW_TEMPERATURE = 0.2;
|
|
24
29
|
/** Raised when the configured seats cannot satisfy the Delphi invariants. */
|
|
25
30
|
export class DelphiConfigError extends Error {
|
|
26
31
|
}
|
|
@@ -65,48 +70,110 @@ export function parseVerdict(text) {
|
|
|
65
70
|
const confidence = c ? Math.min(10, Math.max(0, Number(c[1]))) : 0;
|
|
66
71
|
return { verdict, confidence };
|
|
67
72
|
}
|
|
73
|
+
/** Cleanup for a case where no listener was attached, so there is nothing to undo. */
|
|
74
|
+
const NO_CLEANUP = () => undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Bridge caller cancellation into the controller that also owns the timeout.
|
|
77
|
+
* Bridging rather than racing two signals means one abort path, so the reason a
|
|
78
|
+
* request stopped is never ambiguous.
|
|
79
|
+
*/
|
|
80
|
+
function linkAbort(controller, callerSignal) {
|
|
81
|
+
if (!callerSignal)
|
|
82
|
+
return NO_CLEANUP;
|
|
83
|
+
const forwardAbort = () => controller.abort();
|
|
84
|
+
if (callerSignal.aborted) {
|
|
85
|
+
controller.abort();
|
|
86
|
+
return NO_CLEANUP;
|
|
87
|
+
}
|
|
88
|
+
callerSignal.addEventListener("abort", forwardAbort, { once: true });
|
|
89
|
+
return () => callerSignal.removeEventListener("abort", forwardAbort);
|
|
90
|
+
}
|
|
91
|
+
/** Extract the reviewer's text, or explain why there isn't any. */
|
|
92
|
+
function readContent(json, maxTokens) {
|
|
93
|
+
const content = json.choices?.[0]?.message?.content ?? "";
|
|
94
|
+
const finishReason = json.choices?.[0]?.finish_reason ?? "unknown";
|
|
95
|
+
// Empty content is a real failure -- typically a reasoning model that spent its
|
|
96
|
+
// whole budget on hidden tokens. Never let it pass as an empty review.
|
|
97
|
+
if (content.trim() === "") {
|
|
98
|
+
throw new Error(`empty content (finish_reason=${finishReason}, max_tokens=${maxTokens}); ` +
|
|
99
|
+
`raise max_tokens if this is a reasoning model`);
|
|
100
|
+
}
|
|
101
|
+
return { content, resolvedModel: json.model ?? null, finishReason };
|
|
102
|
+
}
|
|
103
|
+
/** Reject a non-2xx answer, keeping the body short enough to read in a verdict. */
|
|
104
|
+
async function ensureOk(res) {
|
|
105
|
+
if (res.ok)
|
|
106
|
+
return;
|
|
107
|
+
const body = await res.text().catch(() => "");
|
|
108
|
+
throw new Error(`HTTP ${res.status}: ${body.slice(0, 200)}`);
|
|
109
|
+
}
|
|
110
|
+
/** Build the chat-completions request for one seat. */
|
|
111
|
+
function buildRequest(opts, seat, system, user, maxTokens, signal) {
|
|
112
|
+
return {
|
|
113
|
+
method: "POST",
|
|
114
|
+
headers: {
|
|
115
|
+
Authorization: `Bearer ${opts.apiKey}`,
|
|
116
|
+
"Content-Type": "application/json",
|
|
117
|
+
},
|
|
118
|
+
body: JSON.stringify({
|
|
119
|
+
model: seat.model,
|
|
120
|
+
messages: [
|
|
121
|
+
{ role: "system", content: system },
|
|
122
|
+
{ role: "user", content: user },
|
|
123
|
+
],
|
|
124
|
+
max_tokens: maxTokens,
|
|
125
|
+
temperature: REVIEW_TEMPERATURE,
|
|
126
|
+
}),
|
|
127
|
+
signal,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
68
130
|
/** One provider call. Throws on transport failure or empty content. */
|
|
69
131
|
async function chatOnce(opts, seat, system, user) {
|
|
70
132
|
const doFetch = opts.fetchImpl ?? fetch;
|
|
71
133
|
const controller = new AbortController();
|
|
134
|
+
const maxTokens = seat.maxTokens ?? DEFAULT_MAX_TOKENS;
|
|
72
135
|
const timer = setTimeout(() => controller.abort(), opts.timeoutMs ?? DEFAULT_TIMEOUT_MS);
|
|
136
|
+
const unlink = linkAbort(controller, opts.signal);
|
|
137
|
+
const url = `${opts.baseUrl.replace(/\/+$/, "")}/v1/chat/completions`;
|
|
73
138
|
try {
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"Content-Type": "application/json",
|
|
79
|
-
},
|
|
80
|
-
body: JSON.stringify({
|
|
81
|
-
model: seat.model,
|
|
82
|
-
messages: [
|
|
83
|
-
{ role: "system", content: system },
|
|
84
|
-
{ role: "user", content: user },
|
|
85
|
-
],
|
|
86
|
-
max_tokens: seat.maxTokens ?? DEFAULT_MAX_TOKENS,
|
|
87
|
-
temperature: 0.2,
|
|
88
|
-
}),
|
|
89
|
-
signal: controller.signal,
|
|
90
|
-
});
|
|
91
|
-
if (!res.ok) {
|
|
92
|
-
const body = await res.text().catch(() => "");
|
|
93
|
-
throw new Error(`HTTP ${res.status}: ${body.slice(0, 200)}`);
|
|
94
|
-
}
|
|
95
|
-
const json = (await res.json());
|
|
96
|
-
const content = json.choices?.[0]?.message?.content ?? "";
|
|
97
|
-
const finishReason = json.choices?.[0]?.finish_reason ?? "unknown";
|
|
98
|
-
// Empty content is a real failure -- typically a reasoning model that spent
|
|
99
|
-
// its whole budget on hidden tokens. Never let it pass as an empty review.
|
|
100
|
-
if (content.trim() === "") {
|
|
101
|
-
throw new Error(`empty content (finish_reason=${finishReason}, max_tokens=${seat.maxTokens ?? DEFAULT_MAX_TOKENS}); ` +
|
|
102
|
-
`raise max_tokens if this is a reasoning model`);
|
|
103
|
-
}
|
|
104
|
-
return { content, resolvedModel: json.model ?? null, finishReason };
|
|
139
|
+
const request = buildRequest(opts, seat, system, user, maxTokens, controller.signal);
|
|
140
|
+
const res = await doFetch(url, request);
|
|
141
|
+
await ensureOk(res);
|
|
142
|
+
return readContent((await res.json()), maxTokens);
|
|
105
143
|
}
|
|
106
144
|
finally {
|
|
107
145
|
clearTimeout(timer);
|
|
146
|
+
unlink();
|
|
108
147
|
}
|
|
109
148
|
}
|
|
149
|
+
/** A seat that failed to answer. Its silence is never counted as agreement. */
|
|
150
|
+
function failedVerdict(seat, reason) {
|
|
151
|
+
return {
|
|
152
|
+
id: seat.id,
|
|
153
|
+
role: seat.role,
|
|
154
|
+
requestedModel: seat.model,
|
|
155
|
+
resolvedModel: null,
|
|
156
|
+
verdict: "ERROR",
|
|
157
|
+
confidence: 0,
|
|
158
|
+
counted: false,
|
|
159
|
+
report: "",
|
|
160
|
+
error: reason instanceof Error ? reason.message : String(reason),
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/** A seat that answered: parse its verdict and keep the report as evidence. */
|
|
164
|
+
function answeredVerdict(seat, answer) {
|
|
165
|
+
const { verdict, confidence } = parseVerdict(answer.content);
|
|
166
|
+
return {
|
|
167
|
+
id: seat.id,
|
|
168
|
+
role: seat.role,
|
|
169
|
+
requestedModel: seat.model,
|
|
170
|
+
resolvedModel: answer.resolvedModel,
|
|
171
|
+
verdict,
|
|
172
|
+
confidence,
|
|
173
|
+
counted: verdict !== "INVALID_NO_VERDICT",
|
|
174
|
+
report: answer.content,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
110
177
|
/**
|
|
111
178
|
* Run ONE round. All seats are asked concurrently and never see each other's
|
|
112
179
|
* output, which is what makes the round anonymous.
|
|
@@ -118,30 +185,9 @@ export async function runRound(opts, round, system, buildPrompt) {
|
|
|
118
185
|
}));
|
|
119
186
|
const verdicts = settled.map((s, i) => {
|
|
120
187
|
const seat = opts.seats[i];
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
role: seat.role,
|
|
125
|
-
requestedModel: seat.model,
|
|
126
|
-
resolvedModel: null,
|
|
127
|
-
verdict: "ERROR",
|
|
128
|
-
confidence: 0,
|
|
129
|
-
counted: false,
|
|
130
|
-
report: "",
|
|
131
|
-
error: s.reason instanceof Error ? s.reason.message : String(s.reason),
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
const { verdict, confidence } = parseVerdict(s.value.content);
|
|
135
|
-
return {
|
|
136
|
-
id: seat.id,
|
|
137
|
-
role: seat.role,
|
|
138
|
-
requestedModel: seat.model,
|
|
139
|
-
resolvedModel: s.value.resolvedModel,
|
|
140
|
-
verdict,
|
|
141
|
-
confidence,
|
|
142
|
-
counted: verdict !== "INVALID_NO_VERDICT",
|
|
143
|
-
report: s.value.content,
|
|
144
|
-
};
|
|
188
|
+
return s.status === "fulfilled"
|
|
189
|
+
? answeredVerdict(seat, s.value)
|
|
190
|
+
: failedVerdict(seat, s.reason);
|
|
145
191
|
});
|
|
146
192
|
const counted = verdicts.filter((v) => v.counted);
|
|
147
193
|
const approvals = counted.filter((v) => v.verdict === "APPROVED").length;
|
package/lib/delphi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delphi.js","sourceRoot":"","sources":["../src/delphi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;
|
|
1
|
+
{"version":3,"file":"delphi.js","sourceRoot":"","sources":["../src/delphi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAuDH,+EAA+E;AAC/E,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAErC,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAChC,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAEnC;;;GAGG;AACH,MAA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document that the pre-push
|
|
6
|
+
* validator accepts, from a review the plugin actually ran.
|
|
7
|
+
* @covers AC-DSH-012-01
|
|
8
|
+
*
|
|
9
|
+
* Every field here mirrors a check in githooks/lib/validate-code-walkthrough.cjs.
|
|
10
|
+
* Two of those checks are easy to misread and are pinned by test:
|
|
11
|
+
*
|
|
12
|
+
* - result_type belongs to each EXPERT record. Putting it at the top level looks
|
|
13
|
+
* right, passes no check, and fails with a message that never mentions placement.
|
|
14
|
+
* - requested_model comes from the configured seat, never from the gateway's
|
|
15
|
+
* response. The gateway answers with its own naming (Qwen3_8-flash-next for a seat
|
|
16
|
+
* configured as local-qwen3.8-flash), so using the response tripped #574.
|
|
17
|
+
*/
|
|
18
|
+
/** The document Gate MW reads. Field names are the validator's, not ours. */
|
|
19
|
+
export interface WalkthroughEvidence {
|
|
20
|
+
readonly commit: string;
|
|
21
|
+
readonly branch: string;
|
|
22
|
+
readonly timestamp: string;
|
|
23
|
+
readonly expires: string;
|
|
24
|
+
readonly consensus_ratio: number;
|
|
25
|
+
readonly verdict: "APPROVED";
|
|
26
|
+
readonly experts: readonly EvidenceExpert[];
|
|
27
|
+
}
|
|
28
|
+
export interface EvidenceExpert {
|
|
29
|
+
readonly role: string;
|
|
30
|
+
readonly requested_model: string;
|
|
31
|
+
readonly resolved_model: string;
|
|
32
|
+
/** Per-expert, not top-level. The validator reads it here. */
|
|
33
|
+
readonly result_type: "delphi_expert_result";
|
|
34
|
+
readonly channel: "external" | "local";
|
|
35
|
+
readonly verdict: "APPROVED";
|
|
36
|
+
}
|
|
37
|
+
/** One seat as observed by the review: what we asked for, and what answered. */
|
|
38
|
+
export interface SeatOutcome {
|
|
39
|
+
readonly role: string;
|
|
40
|
+
/** The model configured for this role. Becomes requested_model. */
|
|
41
|
+
readonly model: string;
|
|
42
|
+
/** The model the gateway reported. Becomes resolved_model. */
|
|
43
|
+
readonly resolved: string;
|
|
44
|
+
}
|
|
45
|
+
export interface BuildEvidenceInput {
|
|
46
|
+
readonly head: string;
|
|
47
|
+
readonly branch: string;
|
|
48
|
+
readonly seats: readonly SeatOutcome[];
|
|
49
|
+
readonly verdict: string;
|
|
50
|
+
readonly now: Date;
|
|
51
|
+
/** Gateway URL, used to label provenance. */
|
|
52
|
+
readonly baseUrl?: string;
|
|
53
|
+
/** Observed agreement. Defaults to unanimous, which is what a 3-seat APPROVED run is. */
|
|
54
|
+
readonly consensusRatio?: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Label a gateway as local or external.
|
|
58
|
+
*
|
|
59
|
+
* Only loopback counts as local: the validator uses this field as provenance, so a
|
|
60
|
+
* private-network host is still external — nothing about it is verifiable from here.
|
|
61
|
+
*/
|
|
62
|
+
export declare function evidenceChannel(baseUrl: string): "local" | "external";
|
|
63
|
+
/**
|
|
64
|
+
* Build the evidence document.
|
|
65
|
+
*
|
|
66
|
+
* Refuses on anything the validator would reject rather than emitting a document
|
|
67
|
+
* that fails at push time, where the cause is much harder to see.
|
|
68
|
+
*/
|
|
69
|
+
export declare function buildEvidence(input: BuildEvidenceInput): WalkthroughEvidence;
|
|
70
|
+
//# sourceMappingURL=evidence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence.d.ts","sourceRoot":"","sources":["../src/evidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,6EAA6E;AAC7E,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAA;IAC5B,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAA;CAC5C;AAED,MAAM,WAAW,c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evidence
|
|
5
|
+
* @intent Build the .code-walkthrough-result.json document that the pre-push
|
|
6
|
+
* validator accepts, from a review the plugin actually ran.
|
|
7
|
+
* @covers AC-DSH-012-01
|
|
8
|
+
*
|
|
9
|
+
* Every field here mirrors a check in githooks/lib/validate-code-walkthrough.cjs.
|
|
10
|
+
* Two of those checks are easy to misread and are pinned by test:
|
|
11
|
+
*
|
|
12
|
+
* - result_type belongs to each EXPERT record. Putting it at the top level looks
|
|
13
|
+
* right, passes no check, and fails with a message that never mentions placement.
|
|
14
|
+
* - requested_model comes from the configured seat, never from the gateway's
|
|
15
|
+
* response. The gateway answers with its own naming (Qwen3_8-flash-next for a seat
|
|
16
|
+
* configured as local-qwen3.8-flash), so using the response tripped #574.
|
|
17
|
+
*/
|
|
18
|
+
/** The validator requires exactly three seats. */
|
|
19
|
+
const REQUIRED_SEATS = 3;
|
|
20
|
+
/** Evidence is valid for exactly this long; the validator checks the delta. */
|
|
21
|
+
const VALIDITY_MS = 3_600_000;
|
|
22
|
+
/** The validator rejects anything below this. */
|
|
23
|
+
const MIN_CONSENSUS = 0.9;
|
|
24
|
+
/**
|
|
25
|
+
* Label a gateway as local or external.
|
|
26
|
+
*
|
|
27
|
+
* Only loopback counts as local: the validator uses this field as provenance, so a
|
|
28
|
+
* private-network host is still external — nothing about it is verifiable from here.
|
|
29
|
+
*/
|
|
30
|
+
export function evidenceChannel(baseUrl) {
|
|
31
|
+
const lowered = baseUrl.toLowerCase();
|
|
32
|
+
return lowered.includes("localhost") || lowered.includes("127.0.0.1") || lowered.includes("[::1]")
|
|
33
|
+
? "local"
|
|
34
|
+
: "external";
|
|
35
|
+
}
|
|
36
|
+
/** Refuse to emit a document the validator would reject, and say which field. */
|
|
37
|
+
function assertSeatsUsable(seats) {
|
|
38
|
+
if (seats.length !== REQUIRED_SEATS) {
|
|
39
|
+
throw new Error(`evidence needs exactly ${REQUIRED_SEATS} seats; got ${seats.length}`);
|
|
40
|
+
}
|
|
41
|
+
const requested = new Set();
|
|
42
|
+
const resolved = new Set();
|
|
43
|
+
for (const seat of seats) {
|
|
44
|
+
if (seat.resolved.trim() === "") {
|
|
45
|
+
throw new Error(`seat "${seat.role}" has no resolved_model; a failed seat cannot produce evidence`);
|
|
46
|
+
}
|
|
47
|
+
// Both are checked case-insensitively by some validator paths, so assert on the
|
|
48
|
+
// stricter reading: duplicated IDs mean one model answered twice.
|
|
49
|
+
if (requested.has(seat.model.trim()))
|
|
50
|
+
throw new Error(`duplicate requested_model "${seat.model}"`);
|
|
51
|
+
if (resolved.has(seat.resolved.trim().toLowerCase())) {
|
|
52
|
+
throw new Error(`duplicate resolved_model "${seat.resolved}"`);
|
|
53
|
+
}
|
|
54
|
+
requested.add(seat.model.trim());
|
|
55
|
+
resolved.add(seat.resolved.trim().toLowerCase());
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Build the evidence document.
|
|
60
|
+
*
|
|
61
|
+
* Refuses on anything the validator would reject rather than emitting a document
|
|
62
|
+
* that fails at push time, where the cause is much harder to see.
|
|
63
|
+
*/
|
|
64
|
+
export function buildEvidence(input) {
|
|
65
|
+
if (input.verdict !== "APPROVED") {
|
|
66
|
+
throw new Error(`evidence requires an APPROVED review; got ${input.verdict}`);
|
|
67
|
+
}
|
|
68
|
+
assertSeatsUsable(input.seats);
|
|
69
|
+
const ratio = input.consensusRatio ?? 1;
|
|
70
|
+
if (ratio < MIN_CONSENSUS || ratio > 1) {
|
|
71
|
+
throw new Error(`consensus_ratio must be ${MIN_CONSENSUS} through 1; got ${ratio}`);
|
|
72
|
+
}
|
|
73
|
+
const channel = evidenceChannel(input.baseUrl ?? "");
|
|
74
|
+
const expires = new Date(input.now.getTime() + VALIDITY_MS);
|
|
75
|
+
return {
|
|
76
|
+
commit: input.head,
|
|
77
|
+
branch: input.branch,
|
|
78
|
+
timestamp: input.now.toISOString(),
|
|
79
|
+
expires: expires.toISOString(),
|
|
80
|
+
consensus_ratio: ratio,
|
|
81
|
+
verdict: "APPROVED",
|
|
82
|
+
experts: input.seats.map((seat) => ({
|
|
83
|
+
role: seat.role,
|
|
84
|
+
requested_model: seat.model,
|
|
85
|
+
resolved_model: seat.resolved,
|
|
86
|
+
result_type: "delphi_expert_result",
|
|
87
|
+
channel,
|
|
88
|
+
verdict: "APPROVED",
|
|
89
|
+
})),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=evidence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evidence.js","sourceRoot":"","sources":["../src/evidence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AA4CH,kDAAkD;AAClD,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB,+EAA+E;AAC/E,MAAM,WAAW,GAAG,SAAS,CAAC;AAE9B,iDAAiD;AACjD,MAAM,aAAa,GAAG,GAAG,CAAC;AAE1B;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,EAAE,CAAA;IACrC,OAAO,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;QAChG,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,UAAU,CAAA;AAChB,CAAC;AAED,iFAAiF;AACjF,SAAS,iBAAiB,CAAC,KAA6B;IACtD,IAAI,KAAK,CAAC,MAAM,KAAK,cAAc,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,0BAA0B,cAAc,eAAe,KAAK,CAAC,MAAM,EAAE,CAAC,CAAA;IACxF,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAA;IACnC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAA;IAClC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,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IAAI,EAAE,CAAC,CAAA;IACpD,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,WAAW,CAAC,CAAA;IAE3D,OAAO;QACL,MAAM,EAAE,KAAK,CAAC,IAAI;QAClB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,EAAE;QAClC,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE;QAC9B,eAAe,EAAE,KAAK;QACtB,OAAO,EAAE,UAAU;QACnB,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAClC,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,eAAe,EAAE,IAAI,CAAC,KAAK;YAC3B,cAAc,EAAE,IAAI,CAAC,QAAQ;YAC7B,WAAW,EAAE,sBAAsB;YACnC,OAAO;YACP,OAAO,EAAE,UAAU;SACpB,CAAC,CAAC;KACJ,CAAA;AACH,CAAC"}
|
package/lib/gate-runner.d.ts
CHANGED
|
@@ -2,12 +2,43 @@ import type { ShellExecRequest, ShellExecSpec, ShellRunResult } from "@deepseek-
|
|
|
2
2
|
/**
|
|
3
3
|
* Structural view of `ctx.shell` so the runner is testable with a fake shell
|
|
4
4
|
* without importing the abstract `ShellExecutor` service.
|
|
5
|
+
*
|
|
6
|
+
* The shape tracks the 0.2.0-rc.2 seam: `execute()` returns a handle whose
|
|
7
|
+
* `result()` settles into the run result. Earlier 0.1.x exposed a single `run()`,
|
|
8
|
+
* which is why a stale devDependency made this compile while the real runtime
|
|
9
|
+
* had already moved on.
|
|
5
10
|
*/
|
|
6
11
|
export interface XpGateShell {
|
|
7
12
|
resolve(request: ShellExecRequest): ShellExecSpec;
|
|
8
|
-
|
|
13
|
+
execute(spec: ShellExecSpec): Promise<{
|
|
14
|
+
result(): Promise<ShellRunResult>;
|
|
15
|
+
}>;
|
|
9
16
|
}
|
|
10
|
-
/**
|
|
17
|
+
/** The three verdicts a gate run can produce. There is deliberately no fourth. */
|
|
18
|
+
export type GateVerdict = "PASS" | "GATE FAILED" | "INDETERMINATE";
|
|
19
|
+
/**
|
|
20
|
+
* Classify a completed shell run.
|
|
21
|
+
*
|
|
22
|
+
* The order below is load-bearing and must not be rearranged:
|
|
23
|
+
*
|
|
24
|
+
* 1. timeout / truncation -> INDETERMINATE (a killed or clipped run yields no verdict)
|
|
25
|
+
* 2. exit 0 with no stdout -> INDETERMINATE (the command succeeded but said nothing)
|
|
26
|
+
* 3. exit 0 with stdout -> PASS
|
|
27
|
+
* 4. otherwise -> GATE FAILED (nonzero with output) or INDETERMINATE (silent)
|
|
28
|
+
*
|
|
29
|
+
* Step 1 must precede step 3: a timed-out process can still report exit 0 from
|
|
30
|
+
* the state it held when the deadline killed it, so testing `exitCode === 0`
|
|
31
|
+
* first would render a timeout as a pass. That is the exact defect this project
|
|
32
|
+
* fixed in Gate 8 and Gate 10, and the plugin must not reintroduce it.
|
|
33
|
+
*/
|
|
34
|
+
export declare function classifyGateRun(result: ShellRunResult): GateVerdict;
|
|
35
|
+
/**
|
|
36
|
+
* Render a completed shell run as model-facing text.
|
|
37
|
+
*
|
|
38
|
+
* Every run resolves to exactly one of three verdicts. A run that could not
|
|
39
|
+
* establish a verdict says INDETERMINATE and states explicitly that it is not a
|
|
40
|
+
* pass, because an empty output read as a green check is worse than no output.
|
|
41
|
+
*/
|
|
11
42
|
export declare function renderGateResult(result: ShellRunResult): string;
|
|
12
43
|
/**
|
|
13
44
|
* Run an xp-gate command through the harness shell seam. Nonzero exits, timeouts,
|
package/lib/gate-runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gate-runner.d.ts","sourceRoot":"","sources":["../src/gate-runner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAE7F
|
|
1
|
+
{"version":3,"file":"gate-runner.d.ts","sourceRoot":"","sources":["../src/gate-runner.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAE7F;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,OAAO,EAAE,gBAAgB,GAAG,aAAa,CAAA;IACjD,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC;QAAE,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC,CAAA;KAAE,CAAC,CAAA;CAC7E;AAED,kFAAkF;AAClF,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,aAAa,GAAG,eAAe,CAAA;AAElE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,WAAW,CAUnE;AA+BD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CAa/D;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAC7B,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAUjB"}
|