@cortexkit/aft-bridge 0.33.0 → 0.35.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/dist/bash-hints.d.ts +26 -0
- package/dist/bash-hints.d.ts.map +1 -0
- package/dist/bash-hints.js +48 -0
- package/dist/bash-hints.js.map +1 -0
- package/dist/bridge.d.ts +21 -0
- package/dist/bridge.d.ts.map +1 -1
- package/dist/bridge.js +34 -0
- package/dist/bridge.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/onnx-runtime.d.ts +14 -3
- package/dist/onnx-runtime.d.ts.map +1 -1
- package/dist/onnx-runtime.js +143 -55
- package/dist/onnx-runtime.js.map +1 -1
- package/dist/pool.d.ts +7 -0
- package/dist/pool.d.ts.map +1 -1
- package/dist/pool.js +13 -0
- package/dist/pool.js.map +1 -1
- package/dist/status-bar.d.ts +44 -0
- package/dist/status-bar.d.ts.map +1 -0
- package/dist/status-bar.js +86 -0
- package/dist/status-bar.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-bar.d.ts","sourceRoot":"","sources":["../src/status-bar.ts"],"names":[],"mappings":"AAYA,qFAAqF;AACrF,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C,wCAAwC;AACxC,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,wBAAgB,wBAAwB,IAAI,kBAAkB,CAE7D;AAED,+EAA+E;AAC/E,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS,CAgBhF;AAcD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,kBAAkB,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAY7F;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAO/D;AAED,oFAAoF;AACpF,wBAAgB,aAAa,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAE7D"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Agent status bar — the IDE-style "status bar" surfaced to the agent on tool
|
|
2
|
+
// results. The Rust bridge attaches raw counts to every response envelope as a
|
|
3
|
+
// top-level `status_bar` object (`Response.data` is `#[serde(flatten)]`, so it
|
|
4
|
+
// lands beside `id`/`success`, not nested under `data` — same as
|
|
5
|
+
// `bg_completions`); the plugin appends a compact one-line bar to the
|
|
6
|
+
// agent-facing tool output on an emit-on-change basis (plus a heartbeat so it
|
|
7
|
+
// never scrolls fully out of context).
|
|
8
|
+
//
|
|
9
|
+
// The legend is taught once in the system prompt (workflow-hints), so the
|
|
10
|
+
// per-call cost is just the compact values (~15-20 tokens). ASCII-only — cheaper
|
|
11
|
+
// to tokenize and easier for weaker models to parse than unicode glyphs.
|
|
12
|
+
/**
|
|
13
|
+
* Re-emit the bar after this many tool calls even when nothing changed, so the
|
|
14
|
+
* latest health state doesn't scroll out of the model's recent context during
|
|
15
|
+
* long read-only stretches.
|
|
16
|
+
*/
|
|
17
|
+
export const STATUS_BAR_HEARTBEAT_CALLS = 15;
|
|
18
|
+
export function createStatusBarEmitState() {
|
|
19
|
+
return { callsSinceEmit: 0 };
|
|
20
|
+
}
|
|
21
|
+
/** Parse/normalize an untrusted top-level `status_bar` payload into counts. */
|
|
22
|
+
export function parseStatusBarCounts(value) {
|
|
23
|
+
if (!value || typeof value !== "object")
|
|
24
|
+
return undefined;
|
|
25
|
+
const record = value;
|
|
26
|
+
const num = (key) => {
|
|
27
|
+
const raw = record[key];
|
|
28
|
+
return typeof raw === "number" && Number.isFinite(raw) ? raw : 0;
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
errors: num("errors"),
|
|
32
|
+
warnings: num("warnings"),
|
|
33
|
+
dead_code: num("dead_code"),
|
|
34
|
+
unused_exports: num("unused_exports"),
|
|
35
|
+
duplicates: num("duplicates"),
|
|
36
|
+
todos: num("todos"),
|
|
37
|
+
tier2_stale: record.tier2_stale === true,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function countsEqual(a, b) {
|
|
41
|
+
return (a.errors === b.errors &&
|
|
42
|
+
a.warnings === b.warnings &&
|
|
43
|
+
a.dead_code === b.dead_code &&
|
|
44
|
+
a.unused_exports === b.unused_exports &&
|
|
45
|
+
a.duplicates === b.duplicates &&
|
|
46
|
+
a.todos === b.todos &&
|
|
47
|
+
a.tier2_stale === b.tier2_stale);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Decide whether to emit the bar this tool call and advance the emit state.
|
|
51
|
+
* Emits when: first observation, any value changed, or the heartbeat elapsed.
|
|
52
|
+
* Mutates `state` (records last-emitted + resets/advances the call counter).
|
|
53
|
+
*/
|
|
54
|
+
export function shouldEmitStatusBar(state, next) {
|
|
55
|
+
const changed = state.last === undefined || !countsEqual(state.last, next);
|
|
56
|
+
// Count this call first, so the heartbeat fires on exactly the Nth call since
|
|
57
|
+
// the last emit (N-1 suppressed, then re-emit).
|
|
58
|
+
state.callsSinceEmit += 1;
|
|
59
|
+
const heartbeat = state.callsSinceEmit >= STATUS_BAR_HEARTBEAT_CALLS;
|
|
60
|
+
if (changed || heartbeat) {
|
|
61
|
+
state.last = next;
|
|
62
|
+
state.callsSinceEmit = 0;
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Render the compact one-line bar. Always shows every field (consistent shape
|
|
69
|
+
* is easier for weak models to parse than a variable one). A `~` before the
|
|
70
|
+
* dead-code count marks the Tier-2 counts (D/U/C) as stale — edited since the
|
|
71
|
+
* last background scan; run aft_inspect for current numbers.
|
|
72
|
+
*
|
|
73
|
+
* Example: `[AFT E2 W5 | D331 U221 C1159 | T8]`
|
|
74
|
+
* Stale: `[AFT E2 W5 | ~D331 U221 C1159 | T8]`
|
|
75
|
+
*/
|
|
76
|
+
export function formatStatusBar(counts) {
|
|
77
|
+
const staleMark = counts.tier2_stale ? "~" : "";
|
|
78
|
+
return (`[AFT E${counts.errors} W${counts.warnings} | ` +
|
|
79
|
+
`${staleMark}D${counts.dead_code} U${counts.unused_exports} C${counts.duplicates} | ` +
|
|
80
|
+
`T${counts.todos}]`);
|
|
81
|
+
}
|
|
82
|
+
/** The two-space-prefixed line appended to tool output (matches `[Hint]` style). */
|
|
83
|
+
export function statusBarLine(counts) {
|
|
84
|
+
return `\n\n${formatStatusBar(counts)}`;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=status-bar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-bar.js","sourceRoot":"","sources":["../src/status-bar.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,+EAA+E;AAC/E,+EAA+E;AAC/E,iEAAiE;AACjE,sEAAsE;AACtE,8EAA8E;AAC9E,uCAAuC;AACvC,EAAE;AACF,0EAA0E;AAC1E,iFAAiF;AACjF,yEAAyE;AAczE;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAQ7C,MAAM,UAAU,wBAAwB;IACtC,OAAO,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC;AAC/B,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,IAAI,CAAC,K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AS,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC3E,8EAA8E;IAC9E,gDAAgD;IAChD,KAAK,CAAC,cAAc,IAAI,CAAC,CAAC;IAC1B,MAAM,SAAS,GAAG,KAAK,CAAC,cAAc,IAAI,0BAA0B,CAAC;IACrE,IAAI,OAAO,IAAI,SAAS,EAAE,CAAC;QACzB,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QAClB,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,MAAuB;IACrD,MAAM,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAChD,OAAO,CACL,SAAS,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,QAAQ,KAAK;QAC/C,GAAG,SAAS,IAAI,MAAM,CAAC,SAAS,KAAK,MAAM,CAAC,cAAc,KAAK,MAAM,CAAC,UAAU,KAAK;QACrF,IAAI,MAAM,CAAC,KAAK,GAAG,CACpB,CAAC;AACJ,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,aAAa,CAAC,MAAuB;IACnD,OAAO,OAAO,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;AAC1C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/aft-bridge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Shared NDJSON bridge transport, binary resolution, and ONNX runtime helpers for AFT agent-host plugins (OpenCode, Pi)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,7 +26,8 @@
|
|
|
26
26
|
"build": "tsc",
|
|
27
27
|
"typecheck": "tsc --noEmit",
|
|
28
28
|
"test": "bun test src/__tests__",
|
|
29
|
-
"prepublishOnly": "bun run build"
|
|
29
|
+
"prepublishOnly": "bun run build",
|
|
30
|
+
"test:unit": "bun test src/__tests__"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
33
|
"undici": "^7.25.0"
|