@xenosystem/agent-interface-core 0.1.3
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 +67 -0
- package/dist/agentDiscovery.d.ts +97 -0
- package/dist/agentDiscovery.d.ts.map +1 -0
- package/dist/agentDiscovery.js +93 -0
- package/dist/agentDiscovery.js.map +1 -0
- package/dist/capabilityRouting.d.ts +72 -0
- package/dist/capabilityRouting.d.ts.map +1 -0
- package/dist/capabilityRouting.js +124 -0
- package/dist/capabilityRouting.js.map +1 -0
- package/dist/capabilityTier.d.ts +105 -0
- package/dist/capabilityTier.d.ts.map +1 -0
- package/dist/capabilityTier.js +120 -0
- package/dist/capabilityTier.js.map +1 -0
- package/dist/combinationVerification.d.ts +101 -0
- package/dist/combinationVerification.d.ts.map +1 -0
- package/dist/combinationVerification.js +115 -0
- package/dist/combinationVerification.js.map +1 -0
- package/dist/context/agentAttachedContextPrompt.d.ts +13 -0
- package/dist/context/agentAttachedContextPrompt.d.ts.map +1 -0
- package/dist/context/agentAttachedContextPrompt.js +50 -0
- package/dist/context/agentAttachedContextPrompt.js.map +1 -0
- package/dist/context/agentModelContext.d.ts +77 -0
- package/dist/context/agentModelContext.d.ts.map +1 -0
- package/dist/context/agentModelContext.js +297 -0
- package/dist/context/agentModelContext.js.map +1 -0
- package/dist/fanOutPlanner.d.ts +65 -0
- package/dist/fanOutPlanner.d.ts.map +1 -0
- package/dist/fanOutPlanner.js +78 -0
- package/dist/fanOutPlanner.js.map +1 -0
- package/dist/fleetBoardProjection.d.ts +143 -0
- package/dist/fleetBoardProjection.d.ts.map +1 -0
- package/dist/fleetBoardProjection.js +156 -0
- package/dist/fleetBoardProjection.js.map +1 -0
- package/dist/fleetProjection.d.ts +63 -0
- package/dist/fleetProjection.d.ts.map +1 -0
- package/dist/fleetProjection.js +86 -0
- package/dist/fleetProjection.js.map +1 -0
- package/dist/hostBackedCapabilities.d.ts +50 -0
- package/dist/hostBackedCapabilities.d.ts.map +1 -0
- package/dist/hostBackedCapabilities.js +66 -0
- package/dist/hostBackedCapabilities.js.map +1 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +134 -0
- package/dist/index.js.map +1 -0
- package/dist/intakeBoardProjection.d.ts +75 -0
- package/dist/intakeBoardProjection.d.ts.map +1 -0
- package/dist/intakeBoardProjection.js +90 -0
- package/dist/intakeBoardProjection.js.map +1 -0
- package/dist/intakeClaim.d.ts +156 -0
- package/dist/intakeClaim.d.ts.map +1 -0
- package/dist/intakeClaim.js +190 -0
- package/dist/intakeClaim.js.map +1 -0
- package/dist/knowledgeBoardProjection.d.ts +57 -0
- package/dist/knowledgeBoardProjection.d.ts.map +1 -0
- package/dist/knowledgeBoardProjection.js +74 -0
- package/dist/knowledgeBoardProjection.js.map +1 -0
- package/dist/landingOverlap.d.ts +127 -0
- package/dist/landingOverlap.d.ts.map +1 -0
- package/dist/landingOverlap.js +107 -0
- package/dist/landingOverlap.js.map +1 -0
- package/dist/landingQueue.d.ts +152 -0
- package/dist/landingQueue.d.ts.map +1 -0
- package/dist/landingQueue.js +258 -0
- package/dist/landingQueue.js.map +1 -0
- package/dist/markdown/markdownWindowsPaths.d.ts +20 -0
- package/dist/markdown/markdownWindowsPaths.d.ts.map +1 -0
- package/dist/markdown/markdownWindowsPaths.js +208 -0
- package/dist/markdown/markdownWindowsPaths.js.map +1 -0
- package/dist/reviewProjection.d.ts +118 -0
- package/dist/reviewProjection.d.ts.map +1 -0
- package/dist/reviewProjection.js +133 -0
- package/dist/reviewProjection.js.map +1 -0
- package/dist/runDiff.d.ts +86 -0
- package/dist/runDiff.d.ts.map +1 -0
- package/dist/runDiff.js +103 -0
- package/dist/runDiff.js.map +1 -0
- package/dist/runtime/agentReasoningEffort.d.ts +22 -0
- package/dist/runtime/agentReasoningEffort.d.ts.map +1 -0
- package/dist/runtime/agentReasoningEffort.js +76 -0
- package/dist/runtime/agentReasoningEffort.js.map +1 -0
- package/dist/runtime/agentRuntimeProvider.d.ts +12 -0
- package/dist/runtime/agentRuntimeProvider.d.ts.map +1 -0
- package/dist/runtime/agentRuntimeProvider.js +294 -0
- package/dist/runtime/agentRuntimeProvider.js.map +1 -0
- package/dist/runtime/agentRuntimeProviderTypes.d.ts +100 -0
- package/dist/runtime/agentRuntimeProviderTypes.d.ts.map +1 -0
- package/dist/runtime/agentRuntimeProviderTypes.js +2 -0
- package/dist/runtime/agentRuntimeProviderTypes.js.map +1 -0
- package/dist/runtime/conversationRuntime.d.ts +53 -0
- package/dist/runtime/conversationRuntime.d.ts.map +1 -0
- package/dist/runtime/conversationRuntime.js +207 -0
- package/dist/runtime/conversationRuntime.js.map +1 -0
- package/dist/runtime/legacyAgentRuntimeEvents.d.ts +65 -0
- package/dist/runtime/legacyAgentRuntimeEvents.d.ts.map +1 -0
- package/dist/runtime/legacyAgentRuntimeEvents.js +104 -0
- package/dist/runtime/legacyAgentRuntimeEvents.js.map +1 -0
- package/dist/runtimeProjection.d.ts +19 -0
- package/dist/runtimeProjection.d.ts.map +1 -0
- package/dist/runtimeProjection.js +133 -0
- package/dist/runtimeProjection.js.map +1 -0
- package/dist/sessionBoardProjection.d.ts +84 -0
- package/dist/sessionBoardProjection.d.ts.map +1 -0
- package/dist/sessionBoardProjection.js +103 -0
- package/dist/sessionBoardProjection.js.map +1 -0
- package/dist/sessionMode.d.ts +115 -0
- package/dist/sessionMode.d.ts.map +1 -0
- package/dist/sessionMode.js +98 -0
- package/dist/sessionMode.js.map +1 -0
- package/dist/workspace/workspaceSelectionContinuation.d.ts +8 -0
- package/dist/workspace/workspaceSelectionContinuation.d.ts.map +1 -0
- package/dist/workspace/workspaceSelectionContinuation.js +18 -0
- package/dist/workspace/workspaceSelectionContinuation.js.map +1 -0
- package/dist/workspaceKnowledge.d.ts +90 -0
- package/dist/workspaceKnowledge.d.ts.map +1 -0
- package/dist/workspaceKnowledge.js +103 -0
- package/dist/workspaceKnowledge.js.map +1 -0
- package/dist/writeLease.d.ts +92 -0
- package/dist/writeLease.d.ts.map +1 -0
- package/dist/writeLease.js +108 -0
- package/dist/writeLease.js.map +1 -0
- package/package.json +29 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tier resolution — ADE spec §2.9, "structure comes from the substrate, not from
|
|
3
|
+
* the agent".
|
|
4
|
+
*
|
|
5
|
+
* The apparent cost of running a third-party agent in its own TUI is that it
|
|
6
|
+
* tells us nothing structured. §2.9's answer is that we should not have been
|
|
7
|
+
* asking it:
|
|
8
|
+
*
|
|
9
|
+
* > "Every run gets a sandbox. Every file write and every process spawn
|
|
10
|
+
* > therefore passes through a boundary we own — and **a boundary you own is a
|
|
11
|
+
* > sensor.** The sandbox is not only a wall; it is an observation plane. So the
|
|
12
|
+
* > question is not *how do we get the agent to narrate its work*. It is *why
|
|
13
|
+
* > are we asking the agent at all*."
|
|
14
|
+
*
|
|
15
|
+
* ## Two ways to get this wrong, and the spec names both
|
|
16
|
+
*
|
|
17
|
+
* **Understating.** §8: "Review, landing, diffs, checkpoints and the command
|
|
18
|
+
* timeline are tier-1 and therefore work for every agent in every mode,
|
|
19
|
+
* including a third-party TUI we render nothing of. **Reporting them unavailable
|
|
20
|
+
* for a third-party agent is a defect, not honest degradation — the data is in
|
|
21
|
+
* the sandbox.**"
|
|
22
|
+
*
|
|
23
|
+
* **Overstating.** §2.9: "The honest boundary: **effects are recoverable, intent
|
|
24
|
+
* is not.** Review and landing are about effects and therefore work at tier 1
|
|
25
|
+
* for every agent. Steering and reasoning capture genuinely require tier 3."
|
|
26
|
+
*
|
|
27
|
+
* So a resolver that answered "available" for everything would be as wrong as
|
|
28
|
+
* one that answered "unavailable" without a sandbox — in opposite directions,
|
|
29
|
+
* and this module is tested against both.
|
|
30
|
+
*
|
|
31
|
+
* ## There is no scraping tier
|
|
32
|
+
*
|
|
33
|
+
* §2.9: "**Explicitly excluded: parsing the TUI.** Scraping ANSI is the brittle
|
|
34
|
+
* path that breaks on every vendor UI change. We do not need it, because tier 1
|
|
35
|
+
* supplies the same facts from a source that cannot change out from under us."
|
|
36
|
+
*
|
|
37
|
+
* `CapabilityTier` therefore has no value meaning "scraped". A future
|
|
38
|
+
* contributor cannot route a capability through ANSI parsing without changing
|
|
39
|
+
* this type, which is a conversation rather than a commit.
|
|
40
|
+
*/
|
|
41
|
+
/**
|
|
42
|
+
* The §2.9 capability map, stated once.
|
|
43
|
+
*
|
|
44
|
+
* Kept as data rather than scattered through call sites so "is this effects or
|
|
45
|
+
* intent?" has one answer. Getting it wrong for a single capability is how a
|
|
46
|
+
* surface ends up telling a user that review is unavailable for the agent they
|
|
47
|
+
* chose — the defect §8 names.
|
|
48
|
+
*/
|
|
49
|
+
export const CAPABILITY_NEEDS = {
|
|
50
|
+
// Effects — recoverable from the substrate, for ANY agent, including one whose
|
|
51
|
+
// interface we render nothing of.
|
|
52
|
+
'file.changes': 'effects',
|
|
53
|
+
'review.diff': 'effects',
|
|
54
|
+
'review.hunks': 'effects',
|
|
55
|
+
'checkpoints': 'effects',
|
|
56
|
+
'command.timeline': 'effects',
|
|
57
|
+
'landing': 'effects',
|
|
58
|
+
// Intent — exists only inside the agent, and no amount of watching the
|
|
59
|
+
// filesystem recovers it.
|
|
60
|
+
'steering.mid-turn': 'intent',
|
|
61
|
+
'reasoning.capture': 'intent',
|
|
62
|
+
'permission.events': 'intent',
|
|
63
|
+
'tool.semantics': 'intent',
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Resolves a capability to the highest tier that can actually deliver it.
|
|
67
|
+
*
|
|
68
|
+
* `available: false` is reserved for cases where NOTHING can deliver it — never
|
|
69
|
+
* used as a shorthand for "the agent did not tell us", which is the failure §8
|
|
70
|
+
* calls a defect.
|
|
71
|
+
*/
|
|
72
|
+
export function resolveCapabilityTier(capability, sources) {
|
|
73
|
+
const need = CAPABILITY_NEEDS[capability];
|
|
74
|
+
if (need === 'intent') {
|
|
75
|
+
// No substrate observation recovers intent. §2.9: "Steering and reasoning
|
|
76
|
+
// capture genuinely require tier 3." Answering from tier 1 here would be an
|
|
77
|
+
// invention, not a degradation.
|
|
78
|
+
if (sources.acp) {
|
|
79
|
+
return { available: true, tier: 3, reason: 'intent is only expressible over ACP' };
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
available: false,
|
|
83
|
+
reason: 'this capability needs the agent\'s intent, which the substrate cannot observe; it requires ACP',
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// Effects. Highest tier first — a richer source is preferred when present,
|
|
87
|
+
// because tier 3 carries semantics tier 1 has to infer.
|
|
88
|
+
if (sources.acp) {
|
|
89
|
+
return { available: true, tier: 3, reason: 'the agent reports this over ACP' };
|
|
90
|
+
}
|
|
91
|
+
if (sources.vendorSideChannel) {
|
|
92
|
+
return {
|
|
93
|
+
available: true,
|
|
94
|
+
tier: 2,
|
|
95
|
+
reason: 'a vendor-supported side channel reports this alongside the TUI',
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
if (sources.sandboxObservation) {
|
|
99
|
+
return {
|
|
100
|
+
available: true,
|
|
101
|
+
tier: 1,
|
|
102
|
+
reason: 'derived from the sandbox: every file write and process spawn crosses a boundary we own',
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
available: false,
|
|
107
|
+
reason: 'the run has no sandbox, so its effects pass through no boundary we observe',
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* True when a capability would be wrongly reported unavailable.
|
|
112
|
+
*
|
|
113
|
+
* §8 calls that a DEFECT rather than honest degradation, so it is worth being
|
|
114
|
+
* able to assert directly — a surface can check itself instead of a human
|
|
115
|
+
* noticing that review vanished for one agent.
|
|
116
|
+
*/
|
|
117
|
+
export function isUnderstatedCapability(capability, sources, reportedAvailable) {
|
|
118
|
+
return resolveCapabilityTier(capability, sources).available && !reportedAvailable;
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=capabilityTier.js.map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CAAC;QAC9B,OAAO;YACL,SAAS,EAAE,IAAI;YACf,IAAI,EAAE,CAAC;YACP,MAAM,EAAE,gEAAgE;SACzE,CAAA;IACH,CAAC;IACD,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAC/B,OAAO;YACL,SAAS,EAAE,IAAI;YACf,IAAI,EAAE,CAAC;YACP,MAAM,EACJ,wFAAwF;SAC3F,CAAA;IACH,CAAC;IACD,OAAO;QACL,SAAS,EAAE,KAAK;QAChB,MAAM,EAAE,4EAA4E;KACrF,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,UAA2B,EAC3B,OAA0B,EAC1B,iBAA0B;IAE1B,OAAO,qBAAqB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,SAAS,IAAI,CAAC,iBAAiB,CAAA;AACnF,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Combination verification — ADE spec §5.7, the direct answer to context
|
|
3
|
+
* blindness.
|
|
4
|
+
*
|
|
5
|
+
* > "Run the checks against the *union* of accepted changes, not each change in
|
|
6
|
+
* > isolation." The failure this answers is the one the research names:
|
|
7
|
+
* > **"every agent's tests pass and the merge is still wrong."**
|
|
8
|
+
*
|
|
9
|
+
* ## Why that failure happens, stated precisely
|
|
10
|
+
*
|
|
11
|
+
* It is not that the checks are bad. It is that **each verification ran against
|
|
12
|
+
* a different input.** Run A verified {A}. Run B verified {B}. Nobody verified
|
|
13
|
+
* {A, B} — and {A, B} is what lands. Every individual result was true and the
|
|
14
|
+
* conclusion drawn from them was not.
|
|
15
|
+
*
|
|
16
|
+
* So a verification result is meaningless without the **exact set it ran
|
|
17
|
+
* against**, and this module makes that pairing unbreakable: a result carries
|
|
18
|
+
* the fingerprint of its input, and a landing gate compares that fingerprint to
|
|
19
|
+
* what is being landed. Accepting one more change invalidates every earlier
|
|
20
|
+
* result, which is the correct and slightly uncomfortable consequence.
|
|
21
|
+
*
|
|
22
|
+
* ## Unverified is not the same as failed
|
|
23
|
+
*
|
|
24
|
+
* Both refuse to land, and a gate that collapsed them would be easier to write
|
|
25
|
+
* and worse to use: "we have not checked this combination" and "we checked it
|
|
26
|
+
* and it is broken" call for completely different actions from a human. They are
|
|
27
|
+
* separate outcomes here for that reason alone.
|
|
28
|
+
*/
|
|
29
|
+
/** One accepted change, identified by its run and the revision of that run. */
|
|
30
|
+
export interface AcceptedChange {
|
|
31
|
+
runId: string;
|
|
32
|
+
/**
|
|
33
|
+
* A token that changes whenever the run's content changes.
|
|
34
|
+
*
|
|
35
|
+
* Run id alone is NOT enough: a run that kept working after being verified is
|
|
36
|
+
* a different input wearing the same name, and that is exactly how a stale
|
|
37
|
+
* result gets trusted. The caller supplies whatever it has — an event count,
|
|
38
|
+
* a content hash, a commit sha.
|
|
39
|
+
*/
|
|
40
|
+
revision: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A stable identity for a SET of accepted changes.
|
|
44
|
+
*
|
|
45
|
+
* Order-independent, because accepting A then B is the same combination as B
|
|
46
|
+
* then A, and a fingerprint that disagreed would force a needless re-run and
|
|
47
|
+
* quietly teach people to bypass the gate.
|
|
48
|
+
*/
|
|
49
|
+
export declare function fingerprintCombination(changes: AcceptedChange[]): string;
|
|
50
|
+
export interface CombinationVerification {
|
|
51
|
+
/** The fingerprint of the set this result actually ran against. */
|
|
52
|
+
fingerprint: string;
|
|
53
|
+
passed: boolean;
|
|
54
|
+
/** What ran, for a human deciding whether to trust it. */
|
|
55
|
+
checks: string[];
|
|
56
|
+
}
|
|
57
|
+
export type CombinationVerdict = {
|
|
58
|
+
ok: true;
|
|
59
|
+
fingerprint: string;
|
|
60
|
+
reason: string;
|
|
61
|
+
} | {
|
|
62
|
+
ok: false;
|
|
63
|
+
code: 'unverified';
|
|
64
|
+
fingerprint: string;
|
|
65
|
+
reason: string;
|
|
66
|
+
} | {
|
|
67
|
+
ok: false;
|
|
68
|
+
code: 'stale';
|
|
69
|
+
fingerprint: string;
|
|
70
|
+
verifiedFingerprint: string;
|
|
71
|
+
reason: string;
|
|
72
|
+
} | {
|
|
73
|
+
ok: false;
|
|
74
|
+
code: 'failed';
|
|
75
|
+
fingerprint: string;
|
|
76
|
+
failedChecks: string[];
|
|
77
|
+
reason: string;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Whether this combination has been verified as it stands.
|
|
81
|
+
*
|
|
82
|
+
* §5.7's gate is that the system "refuses to land on a red combination". This
|
|
83
|
+
* refuses on three distinct grounds, and keeping them distinct is the point:
|
|
84
|
+
*
|
|
85
|
+
* - **unverified** — nothing has run against this set. The honest state at the
|
|
86
|
+
* start, and the one a naive gate reports as success.
|
|
87
|
+
* - **stale** — something ran, but against a DIFFERENT set. This is the
|
|
88
|
+
* "every agent's tests pass and the merge is still wrong" case caught in the
|
|
89
|
+
* act: a real green result that does not describe what is being landed.
|
|
90
|
+
* - **failed** — this exact set was checked and it is red.
|
|
91
|
+
*/
|
|
92
|
+
export declare function verdictForCombination(accepted: AcceptedChange[], verifications: CombinationVerification[]): CombinationVerdict;
|
|
93
|
+
/**
|
|
94
|
+
* Which verifications are still meaningful after accepting more work.
|
|
95
|
+
*
|
|
96
|
+
* Returns only those matching the new fingerprint — everything else described a
|
|
97
|
+
* combination that no longer exists. Discarding rather than downgrading is
|
|
98
|
+
* deliberate: a "probably still fine" result is the one someone lands on.
|
|
99
|
+
*/
|
|
100
|
+
export declare function pruneStaleVerifications(accepted: AcceptedChange[], verifications: CombinationVerification[]): CombinationVerification[];
|
|
101
|
+
//# sourceMappingURL=combinationVerification.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combinationVerification.d.ts","sourceRoot":"","sources":["../src/combinationVerification.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb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E spec §5.7, the direct answer to context
|
|
3
|
+
* blindness.
|
|
4
|
+
*
|
|
5
|
+
* > "Run the checks against the *union* of accepted changes, not each change in
|
|
6
|
+
* > isolation." The failure this answers is the one the research names:
|
|
7
|
+
* > **"every agent's tests pass and the merge is still wrong."**
|
|
8
|
+
*
|
|
9
|
+
* ## Why that failure happens, stated precisely
|
|
10
|
+
*
|
|
11
|
+
* It is not that the checks are bad. It is that **each verification ran against
|
|
12
|
+
* a different input.** Run A verified {A}. Run B verified {B}. Nobody verified
|
|
13
|
+
* {A, B} — and {A, B} is what lands. Every individual result was true and the
|
|
14
|
+
* conclusion drawn from them was not.
|
|
15
|
+
*
|
|
16
|
+
* So a verification result is meaningless without the **exact set it ran
|
|
17
|
+
* against**, and this module makes that pairing unbreakable: a result carries
|
|
18
|
+
* the fingerprint of its input, and a landing gate compares that fingerprint to
|
|
19
|
+
* what is being landed. Accepting one more change invalidates every earlier
|
|
20
|
+
* result, which is the correct and slightly uncomfortable consequence.
|
|
21
|
+
*
|
|
22
|
+
* ## Unverified is not the same as failed
|
|
23
|
+
*
|
|
24
|
+
* Both refuse to land, and a gate that collapsed them would be easier to write
|
|
25
|
+
* and worse to use: "we have not checked this combination" and "we checked it
|
|
26
|
+
* and it is broken" call for completely different actions from a human. They are
|
|
27
|
+
* separate outcomes here for that reason alone.
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* A stable identity for a SET of accepted changes.
|
|
31
|
+
*
|
|
32
|
+
* Order-independent, because accepting A then B is the same combination as B
|
|
33
|
+
* then A, and a fingerprint that disagreed would force a needless re-run and
|
|
34
|
+
* quietly teach people to bypass the gate.
|
|
35
|
+
*/
|
|
36
|
+
export function fingerprintCombination(changes) {
|
|
37
|
+
if (changes.length === 0)
|
|
38
|
+
return 'empty';
|
|
39
|
+
const seen = new Map();
|
|
40
|
+
for (const change of changes) {
|
|
41
|
+
// Last revision wins: re-accepting a run after more work replaces the older
|
|
42
|
+
// entry rather than producing a set containing the run twice.
|
|
43
|
+
seen.set(change.runId, change.revision);
|
|
44
|
+
}
|
|
45
|
+
return [...seen.entries()]
|
|
46
|
+
.map(([runId, revision]) => `${runId}@${revision}`)
|
|
47
|
+
.sort()
|
|
48
|
+
.join('+');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Whether this combination has been verified as it stands.
|
|
52
|
+
*
|
|
53
|
+
* §5.7's gate is that the system "refuses to land on a red combination". This
|
|
54
|
+
* refuses on three distinct grounds, and keeping them distinct is the point:
|
|
55
|
+
*
|
|
56
|
+
* - **unverified** — nothing has run against this set. The honest state at the
|
|
57
|
+
* start, and the one a naive gate reports as success.
|
|
58
|
+
* - **stale** — something ran, but against a DIFFERENT set. This is the
|
|
59
|
+
* "every agent's tests pass and the merge is still wrong" case caught in the
|
|
60
|
+
* act: a real green result that does not describe what is being landed.
|
|
61
|
+
* - **failed** — this exact set was checked and it is red.
|
|
62
|
+
*/
|
|
63
|
+
export function verdictForCombination(accepted, verifications) {
|
|
64
|
+
const fingerprint = fingerprintCombination(accepted);
|
|
65
|
+
const matching = verifications.filter((verification) => verification.fingerprint === fingerprint);
|
|
66
|
+
if (matching.length === 0) {
|
|
67
|
+
// Naming the nearest thing that DID run turns "no" into something a human
|
|
68
|
+
// can act on, rather than leaving them to guess whether anything ran at all.
|
|
69
|
+
const nearest = verifications.at(-1);
|
|
70
|
+
if (nearest) {
|
|
71
|
+
return {
|
|
72
|
+
ok: false,
|
|
73
|
+
code: 'stale',
|
|
74
|
+
fingerprint,
|
|
75
|
+
verifiedFingerprint: nearest.fingerprint,
|
|
76
|
+
reason: 'the checks that passed ran against a different combination; every individual result can be true while the union is still wrong',
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
ok: false,
|
|
81
|
+
code: 'unverified',
|
|
82
|
+
fingerprint,
|
|
83
|
+
reason: 'no checks have run against this combination',
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// A single red result decides it. Taking the most recent instead would let a
|
|
87
|
+
// re-run that skipped a check overwrite a real failure.
|
|
88
|
+
const failed = matching.filter((verification) => !verification.passed);
|
|
89
|
+
if (failed.length > 0) {
|
|
90
|
+
return {
|
|
91
|
+
ok: false,
|
|
92
|
+
code: 'failed',
|
|
93
|
+
fingerprint,
|
|
94
|
+
failedChecks: [...new Set(failed.flatMap((verification) => verification.checks))].sort(),
|
|
95
|
+
reason: 'this combination was checked and it is red',
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
ok: true,
|
|
100
|
+
fingerprint,
|
|
101
|
+
reason: 'the checks ran against exactly this combination and passed',
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Which verifications are still meaningful after accepting more work.
|
|
106
|
+
*
|
|
107
|
+
* Returns only those matching the new fingerprint — everything else described a
|
|
108
|
+
* combination that no longer exists. Discarding rather than downgrading is
|
|
109
|
+
* deliberate: a "probably still fine" result is the one someone lands on.
|
|
110
|
+
*/
|
|
111
|
+
export function pruneStaleVerifications(accepted, verifications) {
|
|
112
|
+
const fingerprint = fingerprintCombination(accepted);
|
|
113
|
+
return verifications.filter((verification) => verification.fingerprint === fingerprint);
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=combinationVerification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combinationVerification.js","sourceRoot":"","sources":["../src/combinationVerification.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAgBH;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAyB;IAC9D,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,OAAO,CAAA;IACxC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAA;IACtC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,4EAA4E;QAC5E,8DAA8D;QAC9D,IAAI,CAAC,GAAG,CAAC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O;YACL,EAAE,EAAE,KAAK;YACT,IAAI,EAAE,QAAQ;YACd,WAAW;YACX,YAAY,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE;YACxF,MAAM,EAAE,4CAA4C;SACrD,CAAA;IACH,CAAC;IAED,OAAO;QACL,EAAE,EAAE,IAAI;QACR,WAAW;QACX,MAAM,EAAE,4DAA4D;KACrE,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,QAA0B,EAC1B,aAAwC;IAExC,MAAM,WAAW,GAAG,sBAAsB,CAAC,QAAQ,CAAC,CAAA;IACpD,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC,WAAW,KAAK,WAAW,CAAC,CAAA;AACzF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface PromptAttachment {
|
|
2
|
+
name: string;
|
|
3
|
+
type: string;
|
|
4
|
+
}
|
|
5
|
+
interface BuildRuntimeAttachedContextPromptInput {
|
|
6
|
+
text: string;
|
|
7
|
+
attachments?: PromptAttachment[];
|
|
8
|
+
codeContextPrompt?: string;
|
|
9
|
+
searchAttachments?: unknown[];
|
|
10
|
+
}
|
|
11
|
+
export declare function buildRuntimeAttachedContextPrompt(input: BuildRuntimeAttachedContextPromptInput): string;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=agentAttachedContextPrompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentAttachedContextPrompt.d.ts","sourceRoot":"","sources":["../../src/context/agentAttachedContextPrompt.ts"],"names":[],"mappings":"AAAA,UAAU,gBAAgB;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,UAAU,sCAAsC;IAC9C,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAChC,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,iBAAiB,CAAC,EAAE,OAAO,EAAE,CAAA;CAC9B;AA2BD,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,sCAAsC,GAAG,MAAM,CAwBvG"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const SECRET_TEXT_PATTERN = /\b(sk-[A-Za-z0-9_-]{12,}|xai-[A-Za-z0-9_-]{12,}|BSA[A-Za-z0-9_-]{12,})\b/g;
|
|
2
|
+
const BEARER_TEXT_PATTERN = /\b(Bearer\s+)[A-Za-z0-9._~+/=-]{12,}/gi;
|
|
3
|
+
const SECRET_ASSIGNMENT_PATTERN = /(["']?(?:api[_-]?key|access[_-]?token|refresh[_-]?token|id[_-]?token|auth[_-]?token|bearer[_-]?token|secret|password|authorization|cookie|credential|credentials)["']?\s*[:=]\s*["']?)[^"',\s}]+/gi;
|
|
4
|
+
function truncateForPrompt(text, maxChars) {
|
|
5
|
+
if (!text)
|
|
6
|
+
return '';
|
|
7
|
+
if (text.length <= maxChars)
|
|
8
|
+
return text;
|
|
9
|
+
return `${text.slice(0, maxChars)}\n...[truncated]`;
|
|
10
|
+
}
|
|
11
|
+
function redactPromptText(text) {
|
|
12
|
+
return text
|
|
13
|
+
.replace(SECRET_TEXT_PATTERN, '[redacted-api-key]')
|
|
14
|
+
.replace(BEARER_TEXT_PATTERN, '$1[redacted-token]')
|
|
15
|
+
.replace(SECRET_ASSIGNMENT_PATTERN, '$1[redacted]');
|
|
16
|
+
}
|
|
17
|
+
function asRecord(value) {
|
|
18
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
19
|
+
}
|
|
20
|
+
function readPromptString(value, maxChars) {
|
|
21
|
+
return redactPromptText(typeof value === 'string' ? truncateForPrompt(value.trim(), maxChars) : '');
|
|
22
|
+
}
|
|
23
|
+
export function buildRuntimeAttachedContextPrompt(input) {
|
|
24
|
+
const blocks = [input.text];
|
|
25
|
+
const attachments = input.attachments || [];
|
|
26
|
+
if (attachments.length > 0) {
|
|
27
|
+
blocks.push(`Attached files:\n${attachments.slice(0, 12).map((attachment) => `- ${attachment.name} (${attachment.type})`).join('\n')}`);
|
|
28
|
+
}
|
|
29
|
+
const codeContext = readPromptString(input.codeContextPrompt, 12_000);
|
|
30
|
+
if (codeContext)
|
|
31
|
+
blocks.push(`Attached code context:\n${codeContext}`);
|
|
32
|
+
const searchContext = (input.searchAttachments || [])
|
|
33
|
+
.slice(0, 8)
|
|
34
|
+
.map((attachment) => {
|
|
35
|
+
const record = asRecord(attachment);
|
|
36
|
+
const acl = asRecord(record.aclSnapshot);
|
|
37
|
+
const source = readPromptString(record.sourceConversationId, 160) || 'attached conversation';
|
|
38
|
+
const summary = readPromptString(record.summary, 2200);
|
|
39
|
+
const tokenEstimate = typeof record.tokenEstimate === 'number' ? `, ~${record.tokenEstimate} tokens` : '';
|
|
40
|
+
const visibility = readPromptString(acl.visibility, 80);
|
|
41
|
+
const aclText = visibility ? `, ACL ${visibility}` : '';
|
|
42
|
+
return summary ? `- ${source}${tokenEstimate}${aclText}:\n${summary}` : '';
|
|
43
|
+
})
|
|
44
|
+
.filter(Boolean)
|
|
45
|
+
.join('\n\n');
|
|
46
|
+
if (searchContext)
|
|
47
|
+
blocks.push(`Attached search context:\n${searchContext}`);
|
|
48
|
+
return blocks.filter((block) => block.trim()).join('\n\n');
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=agentAttachedContextPrompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentAttachedContextPrompt.js","sourceRoot":"","sources":["../../src/context/agentAttachedContextPrompt.ts"],"names":[],"mappings":"AAYA,MAAM,mBAAmB,GAAG,2EAA2E,CAAA;AACvG,MAAM,mBAAmB,GAAG,wCAAwC,CAAA;AACpE,MAAM,yBAAyB,GAAG,oMAA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f,IAAI,CAAC,MAAM,CAAC,CAAA;IACf,IAAI,aAAa;QAAE,MAAM,CAAC,IAAI,CAAC,6BAA6B,aAAa,EAAE,CAAC,CAAA;IAC5E,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAC5D,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export interface AgentModelContextToolCall {
|
|
2
|
+
toolName: string;
|
|
3
|
+
params?: Record<string, unknown>;
|
|
4
|
+
result?: string;
|
|
5
|
+
success?: boolean;
|
|
6
|
+
status?: 'running' | 'done';
|
|
7
|
+
summary?: string;
|
|
8
|
+
cwd?: string;
|
|
9
|
+
artifacts?: Array<{
|
|
10
|
+
type: string;
|
|
11
|
+
label: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
15
|
+
export interface AgentModelContextMessage {
|
|
16
|
+
id?: string;
|
|
17
|
+
role: 'user' | 'assistant';
|
|
18
|
+
content: string;
|
|
19
|
+
timestamp?: number;
|
|
20
|
+
toolCalls?: AgentModelContextToolCall[];
|
|
21
|
+
attachments?: Array<{
|
|
22
|
+
name: string;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
export interface AgentModelContextWorkspaceState {
|
|
26
|
+
workspaceName?: string;
|
|
27
|
+
teamName?: string;
|
|
28
|
+
agentName?: string;
|
|
29
|
+
rootDirectory?: string;
|
|
30
|
+
grantedDirectories?: string[];
|
|
31
|
+
activeTasks?: Array<{
|
|
32
|
+
text: string;
|
|
33
|
+
status?: string;
|
|
34
|
+
}>;
|
|
35
|
+
checkpoints?: Array<{
|
|
36
|
+
name: string;
|
|
37
|
+
createdAt?: number;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
export interface AgentModelContextStats {
|
|
41
|
+
strategyVersion: number;
|
|
42
|
+
contextDigest: string;
|
|
43
|
+
rawMessageCount: number;
|
|
44
|
+
sentMessageCount: number;
|
|
45
|
+
compactedMessageCount: number;
|
|
46
|
+
rawCharacterCount: number;
|
|
47
|
+
sentCharacterCount: number;
|
|
48
|
+
estimatedRawTokens: number;
|
|
49
|
+
estimatedSentTokens: number;
|
|
50
|
+
retainedCompactedMessageCount: number;
|
|
51
|
+
retainedAnchorCount: number;
|
|
52
|
+
retainedArtifactCount: number;
|
|
53
|
+
retainedGrantedDirectoryCount: number;
|
|
54
|
+
}
|
|
55
|
+
export declare const AGENT_MODEL_CONTEXT_STRATEGY_VERSION = 1;
|
|
56
|
+
export interface AgentModelContextResult {
|
|
57
|
+
messages: Array<{
|
|
58
|
+
role: 'user' | 'assistant';
|
|
59
|
+
content: string;
|
|
60
|
+
}>;
|
|
61
|
+
systemPromptContext: string;
|
|
62
|
+
stats: AgentModelContextStats;
|
|
63
|
+
}
|
|
64
|
+
interface BuildAgentModelContextOptions {
|
|
65
|
+
messages: AgentModelContextMessage[];
|
|
66
|
+
workspaceState?: AgentModelContextWorkspaceState;
|
|
67
|
+
hotMessageCount?: number;
|
|
68
|
+
maxHotMessageCharacters?: number;
|
|
69
|
+
maxLatestMessageCharacters?: number;
|
|
70
|
+
maxSystemContextCharacters?: number;
|
|
71
|
+
maxLedgerItems?: number;
|
|
72
|
+
maxColdMemoryItems?: number;
|
|
73
|
+
}
|
|
74
|
+
export declare function appendAgentModelContextToSystemPrompt(systemPrompt: string | undefined, systemPromptContext: string): string | undefined;
|
|
75
|
+
export declare function buildAgentModelContext(options: BuildAgentModelContextOptions): AgentModelContextResult;
|
|
76
|
+
export {};
|
|
77
|
+
//# sourceMappingURL=agentModelContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentModelContext.d.ts","sourceRoot":"","sources":["../../src/context/agentModelContext.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,C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