@blackbelt-technology/pi-dashboard-extension 0.7.0 → 0.9.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/.pi/skills/browser/SKILL.md +84 -29
- package/.pi/skills/browser/UPSTREAM.md +13 -1
- package/.pi/skills/browser/references/challenge.md +183 -0
- package/.pi/skills/browser/references/dashboard-relay.md +150 -0
- package/.pi/skills/browser/references/electron.agent.md +57 -0
- package/.pi/skills/browser/references/own-browser.md +305 -0
- package/.pi/skills/browser/references/web.agent.md +323 -0
- package/.pi/skills/browser/scripts/check-panerelay.sh +157 -0
- package/.pi/skills/doctor/SKILL.md +4 -9
- package/.pi/skills/doctor/_lib/checks.ts +133 -54
- package/.pi/skills/doctor/_lib/derive-tokens.ts +5 -0
- package/.pi/skills/doctor/modules/apple-tools.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/apple-tools.md +52 -0
- package/.pi/skills/doctor/modules/mcp-builtin.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/mcp-builtin.md +61 -0
- package/.pi/skills/doctor/modules/oauth-redirect-base.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/oauth-redirect-base.md +71 -0
- package/.pi/skills/doctor/modules/pi-resolution.knowledge.hash +1 -1
- package/.pi/skills/doctor/modules/pi-resolution.md +21 -1
- package/.pi/skills/doctor/modules/plugins-bridges.md +14 -1
- package/.pi/skills/pi-dashboard/SKILL.md +10 -3
- package/.pi/skills/pi-dashboard/references/api-reference.agent.md +69 -0
- package/.pi/skills/pi-dashboard/scripts/dashboard-bus.ts +4 -4
- package/.pi/skills/project-init/SKILL.md +41 -34
- package/.pi/skills/project-init/profiles/coding/AGENTS.md.tmpl +0 -23
- package/.pi/skills/project-init/profiles/docs/profile.json +1 -1
- package/README.md +19 -0
- package/agents/DoxTriage.md +80 -0
- package/package.json +30 -16
- package/src/ask-user-tool.ts +4 -0
- package/src/auto-session-namer.ts +486 -70
- package/src/autostart-guard.ts +99 -0
- package/src/autostart-lock.ts +258 -0
- package/src/bridge-activation.ts +26 -0
- package/src/bridge-context.ts +106 -23
- package/src/bridge-default-model-gate.ts +38 -0
- package/src/bridge-polling.ts +148 -0
- package/src/bridge-ticket-client.ts +105 -0
- package/src/bridge.ts +1760 -350
- package/src/canvas-tool.ts +5 -0
- package/src/command-handler.ts +392 -71
- package/src/connect-target.ts +130 -0
- package/src/connection.ts +846 -17
- package/src/custom-entry-forward.ts +92 -0
- package/src/endpoint-resolution.ts +253 -0
- package/src/event-forwarder.ts +42 -0
- package/src/extension-identity.ts +59 -0
- package/src/flow-event-wiring.ts +125 -3
- package/src/followup-buffer.ts +217 -0
- package/src/git-dir-watcher.ts +79 -0
- package/src/git-poll.ts +45 -12
- package/src/git-probe-scheduler.ts +119 -0
- package/src/git-tracker.ts +284 -0
- package/src/instance-verification.ts +156 -0
- package/src/local-token-header.ts +44 -0
- package/src/mcp-token-delivery.ts +147 -0
- package/src/message-update-coalescer.ts +340 -0
- package/src/model-refresh.ts +95 -0
- package/src/model-tracker.ts +118 -35
- package/src/notify-proxy.ts +36 -0
- package/src/path-gate/decide.ts +149 -0
- package/src/path-gate/grant-cache.ts +71 -0
- package/src/path-gate/grant-link.ts +108 -0
- package/src/path-gate/handler.ts +307 -0
- package/src/path-gate/index.ts +155 -0
- package/src/path-gate/resolve.ts +126 -0
- package/src/path-gate/roots.ts +137 -0
- package/src/path-gate/suppression.ts +27 -0
- package/src/pending-prompt-emitter.ts +59 -0
- package/src/pi-env.d.ts +6 -10
- package/src/pi-retry-settings.ts +91 -0
- package/src/plugin-request-client.ts +114 -0
- package/src/poll-cost.ts +40 -0
- package/src/pr-status.ts +338 -0
- package/src/process-metrics.ts +77 -1
- package/src/process-scan-scheduler.ts +137 -0
- package/src/process-scanner.ts +226 -247
- package/src/project-init/dox-kb-config.ts +3 -0
- package/src/project-init/scaffold.ts +1 -4
- package/src/project-init/seed-doctrine.ts +23 -60
- package/src/prompt-bus.ts +13 -0
- package/src/provider-register.ts +92 -21
- package/src/remote-registration-gate.ts +102 -0
- package/src/retry-tracker.ts +258 -86
- package/src/role-manager.ts +38 -91
- package/src/role-model-tools.ts +44 -3
- package/src/server-auto-start.ts +331 -20
- package/src/server-launcher.ts +70 -34
- package/src/server-pin-store.ts +92 -0
- package/src/session-move.ts +275 -0
- package/src/session-sync.ts +75 -20
- package/src/slash-dispatch.ts +66 -81
- package/src/subagent-fanout-admission.ts +234 -0
- package/src/subagent-forward-sites.ts +69 -0
- package/src/subagent-frame-buffer.ts +24 -3
- package/src/subagent-frame-strip.ts +109 -0
- package/src/subagent-saturation.ts +196 -0
- package/src/subagent-tick-throttle.ts +250 -0
- package/src/terminal-reload.ts +298 -0
- package/src/transcript-backfill.ts +151 -0
- package/src/transport-diagnostics.ts +76 -0
- package/src/tui-prompt-adapter.ts +13 -1
- package/src/turn-actionability.ts +20 -0
- package/src/ui-stale-guard.ts +58 -0
- package/src/usage-drain.ts +167 -0
- package/src/vcs-info.ts +261 -63
- package/.pi/skills/doctor/AGENTS.md +0 -27
- package/.pi/skills/project-init/dox-doctrine.md +0 -104
- package/src/AGENTS.md +0 -57
- package/src/__tests__/abort-latch.test.ts +0 -97
- package/src/__tests__/agent-settled.test.ts +0 -82
- package/src/__tests__/artifact-roots.test.ts +0 -83
- package/src/__tests__/ask-user-attachments.test.ts +0 -106
- package/src/__tests__/ask-user-schema-discriminator.test.ts +0 -141
- package/src/__tests__/ask-user-tool.test.ts +0 -571
- package/src/__tests__/auto-session-namer.test.ts +0 -339
- package/src/__tests__/bridge-default-model-apply.test.ts +0 -242
- package/src/__tests__/bridge-default-model-gate.test.ts +0 -50
- package/src/__tests__/bridge-entry-id-pi-070.test.ts +0 -174
- package/src/__tests__/bridge-followup-chat-order.test.ts +0 -215
- package/src/__tests__/bridge-followup-multi-entry.test.ts +0 -202
- package/src/__tests__/bridge-followup-mutation.test.ts +0 -217
- package/src/__tests__/bridge-followup-queue-drain.test.ts +0 -266
- package/src/__tests__/bridge-hasui-flip.test.ts +0 -109
- package/src/__tests__/bridge-no-queue-mutation.test.ts +0 -112
- package/src/__tests__/bridge-plugin-emit-event.test.ts +0 -44
- package/src/__tests__/bridge-queue-update-forward.test.ts +0 -77
- package/src/__tests__/bridge-resume-disconnect.test.ts +0 -333
- package/src/__tests__/bridge-shadow-queue-gate.test.ts +0 -299
- package/src/__tests__/bridge-shutdown-reset.test.ts +0 -159
- package/src/__tests__/bridge-slash-command-routing.test.ts +0 -458
- package/src/__tests__/bridge-stop-after-turn.test.ts +0 -72
- package/src/__tests__/bridge-system-followup.test.ts +0 -163
- package/src/__tests__/bridge-thinking-level-select.test.ts +0 -68
- package/src/__tests__/browser-skill-registered.test.ts +0 -84
- package/src/__tests__/build-provider-catalogue.test.ts +0 -210
- package/src/__tests__/command-handler.test.ts +0 -1180
- package/src/__tests__/commit-draft.test.ts +0 -100
- package/src/__tests__/connection-dropped-frames.test.ts +0 -78
- package/src/__tests__/connection-suppress-auto-start.test.ts +0 -97
- package/src/__tests__/connection.test.ts +0 -344
- package/src/__tests__/credentials-updated.test.ts +0 -26
- package/src/__tests__/custom-provider-apikey-roundtrip.test.ts +0 -128
- package/src/__tests__/cwd-missing-probe.test.ts +0 -82
- package/src/__tests__/dashboard-commands-shipped.test.ts +0 -53
- package/src/__tests__/dashboard-context-injector.test.ts +0 -190
- package/src/__tests__/dashboard-default-adapter.test.ts +0 -77
- package/src/__tests__/dev-build.test.ts +0 -79
- package/src/__tests__/doctor/checks.test.ts +0 -121
- package/src/__tests__/doctor/modules.test.ts +0 -64
- package/src/__tests__/doctor/provenance-hash.test.ts +0 -94
- package/src/__tests__/doctor/router.test.ts +0 -143
- package/src/__tests__/empty-actionable-guard-config.test.ts +0 -32
- package/src/__tests__/empty-actionable-guard.test.ts +0 -73
- package/src/__tests__/enrich-model-metadata.test.ts +0 -222
- package/src/__tests__/event-forwarder.test.ts +0 -119
- package/src/__tests__/extension-slash-command-detection.test.ts +0 -143
- package/src/__tests__/filter-enabled-models.test.ts +0 -151
- package/src/__tests__/fixtures/turn-actionability-fixtures.ts +0 -69
- package/src/__tests__/fork-entryid-timing.test.ts +0 -88
- package/src/__tests__/git-info-status.test.ts +0 -73
- package/src/__tests__/git-link-builder.test.ts +0 -102
- package/src/__tests__/git-poll.test.ts +0 -69
- package/src/__tests__/markdown-image-inliner.test.ts +0 -392
- package/src/__tests__/model-resolve.test.ts +0 -379
- package/src/__tests__/multiselect-dashboard-routing.test.ts +0 -203
- package/src/__tests__/multiselect-list.test.ts +0 -137
- package/src/__tests__/multiselect-polyfill.test.ts +0 -92
- package/src/__tests__/no-session-replacement-calls.test.ts +0 -99
- package/src/__tests__/no-tui-multiselect-arm-regression.test.ts +0 -81
- package/src/__tests__/openspec-activity-detector.test.ts +0 -337
- package/src/__tests__/openspec-cli-shim.test.ts +0 -145
- package/src/__tests__/openspec-poller.test.ts +0 -124
- package/src/__tests__/pi-version-tracker.test.ts +0 -109
- package/src/__tests__/process-metrics.test.ts +0 -47
- package/src/__tests__/process-scanner-kill.test.ts +0 -61
- package/src/__tests__/process-scanner.test.ts +0 -292
- package/src/__tests__/project-init-detect-stack.test.ts +0 -61
- package/src/__tests__/project-init-dox-kb-config.test.ts +0 -53
- package/src/__tests__/project-init-profiles.test.ts +0 -84
- package/src/__tests__/project-init-scaffold.test.ts +0 -139
- package/src/__tests__/project-init-seed-doctrine.test.ts +0 -100
- package/src/__tests__/project-trust.test.ts +0 -92
- package/src/__tests__/prompt-bus-wiring.test.ts +0 -791
- package/src/__tests__/prompt-bus.test.ts +0 -513
- package/src/__tests__/prompt-expander.test.ts +0 -398
- package/src/__tests__/provider-register-native-models.test.ts +0 -182
- package/src/__tests__/provider-register-reload.test.ts +0 -498
- package/src/__tests__/provider-register-thinking-levels.test.ts +0 -104
- package/src/__tests__/retry-tracker.test.ts +0 -152
- package/src/__tests__/role-manager.test.ts +0 -585
- package/src/__tests__/role-model-tools-registry-readiness.test.ts +0 -114
- package/src/__tests__/role-model-tools.test.ts +0 -229
- package/src/__tests__/search-files-completeness.test.ts +0 -111
- package/src/__tests__/search-files-ranking.test.ts +0 -168
- package/src/__tests__/server-auto-start.test.ts +0 -375
- package/src/__tests__/server-launcher-launch.test.ts +0 -96
- package/src/__tests__/server-launcher.test.ts +0 -101
- package/src/__tests__/server-probe.test.ts +0 -25
- package/src/__tests__/session-switch.test.ts +0 -139
- package/src/__tests__/session-sync.test.ts +0 -243
- package/src/__tests__/single-derivation-guard.test.ts +0 -39
- package/src/__tests__/source-detector.test.ts +0 -88
- package/src/__tests__/stats-extractor.test.ts +0 -92
- package/src/__tests__/subagent-frame-buffer.test.ts +0 -239
- package/src/__tests__/tool-result-image-inliner.test.ts +0 -206
- package/src/__tests__/tui-prompt-adapter.test.ts +0 -213
- package/src/__tests__/turn-actionability.test.ts +0 -86
- package/src/__tests__/ui-decorators.test.ts +0 -309
- package/src/__tests__/ui-modules.test.ts +0 -293
- package/src/__tests__/vcs-info.test.ts +0 -265
- package/src/__tests__/visibility-intent.test.ts +0 -43
- package/src/__tests__/watchdog.test.ts +0 -161
- package/src/abort-latch.ts.AGENTS.md +0 -3
- package/src/agent-settled.ts +0 -72
- package/src/agent-settled.ts.AGENTS.md +0 -3
- package/src/artifact-roots.ts.AGENTS.md +0 -3
- package/src/ask-user-attachments.ts.AGENTS.md +0 -3
- package/src/ask-user-tool.ts.AGENTS.md +0 -3
- package/src/auto-session-namer.ts.AGENTS.md +0 -3
- package/src/bridge-context.ts.AGENTS.md +0 -3
- package/src/bridge-default-model-gate.ts.AGENTS.md +0 -3
- package/src/bridge.ts.AGENTS.md +0 -3
- package/src/command-handler.ts.AGENTS.md +0 -3
- package/src/commit-draft-agent.ts.AGENTS.md +0 -3
- package/src/commit-draft.ts.AGENTS.md +0 -3
- package/src/connection.ts.AGENTS.md +0 -3
- package/src/dashboard-context-injector.ts.AGENTS.md +0 -3
- package/src/dashboard-default-adapter.ts.AGENTS.md +0 -3
- package/src/dev-build.ts.AGENTS.md +0 -3
- package/src/empty-actionable-guard-config.ts.AGENTS.md +0 -3
- package/src/empty-actionable-guard.ts.AGENTS.md +0 -3
- package/src/event-forwarder.ts.AGENTS.md +0 -3
- package/src/flow-event-wiring.ts.AGENTS.md +0 -3
- package/src/git-link-builder.ts.AGENTS.md +0 -3
- package/src/git-poll.ts.AGENTS.md +0 -3
- package/src/hasui-flip.ts.AGENTS.md +0 -3
- package/src/markdown-image-inliner.ts.AGENTS.md +0 -3
- package/src/model-tracker.ts.AGENTS.md +0 -3
- package/src/multiselect-decode.ts.AGENTS.md +0 -3
- package/src/multiselect-list.ts.AGENTS.md +0 -3
- package/src/multiselect-polyfill.ts.AGENTS.md +0 -3
- package/src/openspec-cli-shim.ts.AGENTS.md +0 -7
- package/src/process-metrics.ts.AGENTS.md +0 -3
- package/src/process-scanner.ts.AGENTS.md +0 -3
- package/src/project-init/AGENTS.md +0 -12
- package/src/project-trust.ts.AGENTS.md +0 -3
- package/src/prompt-bus.ts.AGENTS.md +0 -3
- package/src/prompt-expander.ts.AGENTS.md +0 -3
- package/src/provider-register.ts.AGENTS.md +0 -3
- package/src/retry-tracker.ts.AGENTS.md +0 -3
- package/src/role-manager.ts.AGENTS.md +0 -3
- package/src/role-model-tools.ts.AGENTS.md +0 -3
- package/src/server-auto-start.ts.AGENTS.md +0 -3
- package/src/server-launcher.ts.AGENTS.md +0 -3
- package/src/session-sync.ts.AGENTS.md +0 -3
- package/src/slash-dispatch.ts.AGENTS.md +0 -3
- package/src/source-detector.ts.AGENTS.md +0 -3
- package/src/subagent-frame-buffer.ts.AGENTS.md +0 -3
- package/src/tool-result-image-inliner.ts.AGENTS.md +0 -3
- package/src/tui-prompt-adapter.ts.AGENTS.md +0 -3
- package/src/turn-actionability.ts.AGENTS.md +0 -3
- package/src/ui-modules.ts.AGENTS.md +0 -3
- package/src/vcs-info.ts.AGENTS.md +0 -3
- package/src/visibility-intent.ts.AGENTS.md +0 -3
|
@@ -1,83 +1,46 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* DOX-doctrine seeding for the `project-init` skill.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* READ (kb) — retrieval via `kb agents` / `kb_search` before grep.
|
|
10
|
-
* READ (manual) — upstream manual chain-walk wording; NO kb references.
|
|
4
|
+
* Doctrine is no longer copied into a project's `AGENTS.md`: the kb extension
|
|
5
|
+
* (`pi-dashboard-kb-extension`) injects it into the system prompt per turn,
|
|
6
|
+
* governed by the layered `doctrine` config group. The seed is therefore a
|
|
7
|
+
* fixed marker + pointer block naming the extension and the project settings
|
|
8
|
+
* file — no doctrine text, no drift (change: inject-dox-doctrine-and-describe).
|
|
11
9
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* already carries the `<!-- dox-doctrine -->` marker is left untouched.
|
|
15
|
-
*
|
|
16
|
-
* See change: project-init-skill-and-profiles.
|
|
10
|
+
* Marker-gated + idempotent: a target `AGENTS.md` that already carries the
|
|
11
|
+
* `<!-- dox-doctrine -->` marker is left untouched.
|
|
17
12
|
*/
|
|
18
13
|
import * as fs from "node:fs";
|
|
19
14
|
import * as path from "node:path";
|
|
20
|
-
import { fileURLToPath } from "node:url";
|
|
21
15
|
|
|
22
|
-
/** Stable sentinel that marks an AGENTS.md as already carrying the
|
|
16
|
+
/** Stable sentinel that marks an AGENTS.md as already carrying the pointer. */
|
|
23
17
|
export const DOX_MARKER = "<!-- dox-doctrine -->";
|
|
24
18
|
|
|
25
|
-
const
|
|
26
|
-
const WRITE_END = "<!-- dox:write:end -->";
|
|
27
|
-
const READ_KB_START = "<!-- dox:read:kb:start -->";
|
|
28
|
-
const READ_KB_END = "<!-- dox:read:kb:end -->";
|
|
29
|
-
const READ_MANUAL_START = "<!-- dox:read:manual:start -->";
|
|
30
|
-
const READ_MANUAL_END = "<!-- dox:read:manual:end -->";
|
|
19
|
+
const POINTER_BLOCK = `${DOX_MARKER}
|
|
31
20
|
|
|
32
|
-
|
|
33
|
-
export function doctrinePath(): string {
|
|
34
|
-
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
35
|
-
const pkgRoot = path.resolve(here, "..", "..");
|
|
36
|
-
return path.join(pkgRoot, ".pi", "skills", "project-init", "dox-doctrine.md");
|
|
37
|
-
}
|
|
21
|
+
## DOX doctrine
|
|
38
22
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
if (s === -1 || e === -1 || e < s) return "";
|
|
44
|
-
return source.slice(s + start.length, e).trim();
|
|
45
|
-
}
|
|
23
|
+
Per-turn DOX doctrine — the kb-first READ discipline and the directory \`AGENTS.md\`
|
|
24
|
+
WRITE discipline — is injected by the \`pi-dashboard-kb-extension\`. Tune it in
|
|
25
|
+
\`.pi/dashboard/knowledge_base.json\` under the \`doctrine\` key (\`inject\`, \`write\`).
|
|
26
|
+
`;
|
|
46
27
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
/** Override the doctrine source text (tests). Defaults to the shipped file. */
|
|
51
|
-
source?: string;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Compose the seeded doctrine block for an AGENTS.md: the marker followed by
|
|
56
|
-
* the WRITE discipline and the kb-appropriate READ discipline.
|
|
57
|
-
*/
|
|
58
|
-
export function buildDoctrineBlock(opts: BuildDoctrineOptions): string {
|
|
59
|
-
const raw = opts.source ?? fs.readFileSync(doctrinePath(), "utf8");
|
|
60
|
-
const write = section(raw, WRITE_START, WRITE_END);
|
|
61
|
-
const read = opts.kbWired
|
|
62
|
-
? section(raw, READ_KB_START, READ_KB_END)
|
|
63
|
-
: section(raw, READ_MANUAL_START, READ_MANUAL_END);
|
|
64
|
-
return `${DOX_MARKER}\n\n${write}\n\n${read}\n`;
|
|
28
|
+
/** The fixed pointer block (marker + pointer). Never contains doctrine text. */
|
|
29
|
+
export function buildDoctrineBlock(): string {
|
|
30
|
+
return POINTER_BLOCK;
|
|
65
31
|
}
|
|
66
32
|
|
|
67
33
|
export interface SeedResult {
|
|
68
|
-
/** True when the
|
|
34
|
+
/** True when the pointer was appended; false when it was already present. */
|
|
69
35
|
seeded: boolean;
|
|
70
36
|
}
|
|
71
37
|
|
|
72
38
|
/**
|
|
73
|
-
* Append the
|
|
74
|
-
*
|
|
75
|
-
*
|
|
39
|
+
* Append the pointer block to `agentsMdPath` only when the file does not already
|
|
40
|
+
* carry the marker. Idempotent: a present marker is a no-op. Creates the file
|
|
41
|
+
* when absent.
|
|
76
42
|
*/
|
|
77
|
-
export function seedDoctrine(
|
|
78
|
-
agentsMdPath: string,
|
|
79
|
-
opts: BuildDoctrineOptions,
|
|
80
|
-
): SeedResult {
|
|
43
|
+
export function seedDoctrine(agentsMdPath: string): SeedResult {
|
|
81
44
|
let existing = "";
|
|
82
45
|
try {
|
|
83
46
|
existing = fs.readFileSync(agentsMdPath, "utf8");
|
|
@@ -86,7 +49,7 @@ export function seedDoctrine(
|
|
|
86
49
|
}
|
|
87
50
|
if (existing.includes(DOX_MARKER)) return { seeded: false };
|
|
88
51
|
|
|
89
|
-
const block = buildDoctrineBlock(
|
|
52
|
+
const block = buildDoctrineBlock();
|
|
90
53
|
const sep = existing.length === 0 || existing.endsWith("\n") ? "" : "\n";
|
|
91
54
|
const joiner = existing.length === 0 ? "" : "\n";
|
|
92
55
|
fs.mkdirSync(path.dirname(agentsMdPath), { recursive: true });
|
package/src/prompt-bus.ts
CHANGED
|
@@ -132,6 +132,19 @@ export class PromptBus {
|
|
|
132
132
|
*/
|
|
133
133
|
request(options: Omit<PromptRequest, "id">): Promise<PromptResponse> {
|
|
134
134
|
const id = crypto.randomUUID();
|
|
135
|
+
return this.submit(id, options);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Like {@link request} but with a CALLER-chosen id, so the caller can
|
|
140
|
+
* `cancel(id)` its own prompt (agent path gate budget expiry). The caller owns
|
|
141
|
+
* uniqueness. See change: ask-agent-file-access-in-chat.
|
|
142
|
+
*/
|
|
143
|
+
requestWithId(id: string, options: Omit<PromptRequest, "id">): Promise<PromptResponse> {
|
|
144
|
+
return this.submit(id, options);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
private submit(id: string, options: Omit<PromptRequest, "id">): Promise<PromptResponse> {
|
|
135
148
|
const request: PromptRequest = { id, ...options };
|
|
136
149
|
|
|
137
150
|
return new Promise<PromptResponse>((resolve) => {
|
package/src/provider-register.ts
CHANGED
|
@@ -27,6 +27,11 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
27
27
|
import { homedir } from "node:os";
|
|
28
28
|
import { join } from "node:path";
|
|
29
29
|
import { flattenModelsJson, type NativeModelEntry } from "@blackbelt-technology/pi-dashboard-shared/models-json-reader.js";
|
|
30
|
+
import {
|
|
31
|
+
type AdvertisedModelMetadata,
|
|
32
|
+
isFullyAdvertised,
|
|
33
|
+
mapAdvertisedModels,
|
|
34
|
+
} from "@blackbelt-technology/pi-dashboard-shared/provider-model-metadata.js";
|
|
30
35
|
import type { ProviderInfo } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
31
36
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
32
37
|
import { loadRoleConfig, lookupRole } from "./role-manager.js";
|
|
@@ -49,11 +54,14 @@ export interface ModelMetadata {
|
|
|
49
54
|
input: InputModality[];
|
|
50
55
|
/**
|
|
51
56
|
* `"catalog"` when the probe resolved the model against pi's registry (real
|
|
52
|
-
* capabilities); `"
|
|
53
|
-
*
|
|
54
|
-
*
|
|
57
|
+
* capabilities); `"endpoint"` when the custom provider advertised every
|
|
58
|
+
* projected field itself; `"fallback"` when defaults were forced because no
|
|
59
|
+
* catalog match (and `input` is the image-capable DEFAULT_INPUT assumption,
|
|
60
|
+
* not a verified capability). A mixed-tier model reports its WEAKEST tier.
|
|
61
|
+
* See changes: enrich-model-selector-capabilities-favorites,
|
|
62
|
+
* fix-custom-provider-model-metadata.
|
|
55
63
|
*/
|
|
56
|
-
metadataSource: "catalog" | "fallback";
|
|
64
|
+
metadataSource: "catalog" | "endpoint" | "fallback";
|
|
57
65
|
/**
|
|
58
66
|
* Native per-model thinking-level override table + opaque request-formatting
|
|
59
67
|
* hints, present only when the metadata came from the user-authored native
|
|
@@ -63,6 +71,13 @@ export interface ModelMetadata {
|
|
|
63
71
|
*/
|
|
64
72
|
thinkingLevelMap?: Record<string, unknown>;
|
|
65
73
|
compat?: Record<string, unknown>;
|
|
74
|
+
/**
|
|
75
|
+
* Arbitrary OpenAI-compatible sampling parameters (pi 0.84.0), incl. opt-in
|
|
76
|
+
* vLLM `thinking_token_budget`. Opaque passthrough: pi owns validation, and
|
|
77
|
+
* a pre-0.84 pi ignores the field. Omitted entirely when the native entry
|
|
78
|
+
* declares none. See change: update-pi-core-0-84-adopt-apis.
|
|
79
|
+
*/
|
|
80
|
+
samplingParams?: Record<string, unknown>;
|
|
66
81
|
}
|
|
67
82
|
|
|
68
83
|
/**
|
|
@@ -224,7 +239,7 @@ function loadNativeModels(): NativeModelEntry[] {
|
|
|
224
239
|
}
|
|
225
240
|
|
|
226
241
|
/** Turn a native `models.json` entry into `ModelMetadata`, filling gaps with api-typed floors. */
|
|
227
|
-
function metadataFromNative(native: NativeModelEntry, api?: string): ModelMetadata {
|
|
242
|
+
export function metadataFromNative(native: NativeModelEntry, api?: string): ModelMetadata {
|
|
228
243
|
const resolvedApi = api && api in FALLBACK_DEFAULTS ? api : "openai-completions";
|
|
229
244
|
const fb = FALLBACK_DEFAULTS[resolvedApi] ?? FALLBACK_DEFAULTS["openai-completions"];
|
|
230
245
|
return {
|
|
@@ -243,16 +258,29 @@ function metadataFromNative(native: NativeModelEntry, api?: string): ModelMetada
|
|
|
243
258
|
metadataSource: "catalog",
|
|
244
259
|
...(native.thinkingLevelMap ? { thinkingLevelMap: native.thinkingLevelMap } : {}),
|
|
245
260
|
...(native.compat ? { compat: native.compat } : {}),
|
|
261
|
+
// pi 0.84.0 advanced custom-model sampling. Omitted when absent, so a
|
|
262
|
+
// floor-pi session sees exactly the pre-0.84 metadata shape.
|
|
263
|
+
// See change: update-pi-core-0-84-adopt-apis.
|
|
264
|
+
...(native.samplingParams ? { samplingParams: native.samplingParams } : {}),
|
|
246
265
|
};
|
|
247
266
|
}
|
|
248
267
|
|
|
249
268
|
/**
|
|
250
269
|
* Resolve a discovered/authored model id to metadata in precedence order,
|
|
251
|
-
* first hit wins: (1) the native `models.json` entry for `name/id`;
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
*
|
|
270
|
+
* PER FIELD, first hit wins: (1) the native `models.json` entry for `name/id`;
|
|
271
|
+
* (2) the metadata the provider advertised in its own model list; (3) the
|
|
272
|
+
* session registry's own `find(name, id)` for the custom provider name;
|
|
273
|
+
* (4) the api-typed `enrichModelMetadata` fallback (which itself probes
|
|
274
|
+
* built-in candidate catalogs). Only path 1 supplies
|
|
275
|
+
* `thinkingLevelMap`/`compat`.
|
|
276
|
+
*
|
|
277
|
+
* Tier 2 outranks the name-matched catalog probe because the probe cannot
|
|
278
|
+
* resolve prefixed/hybrid ids (`ag/claude-opus-4-6-thinking`, `glm/glm-5.3`)
|
|
279
|
+
* and is not conservative when it does match — it would report that model at
|
|
280
|
+
* 1M while the provider advertises 200k. Only the endpoint knows what a given
|
|
281
|
+
* proxy route serves.
|
|
282
|
+
* See changes: honor-native-models-json-metadata (D-E1),
|
|
283
|
+
* fix-custom-provider-model-metadata (design D3).
|
|
256
284
|
*/
|
|
257
285
|
function resolveMetadata(
|
|
258
286
|
name: string,
|
|
@@ -260,10 +288,37 @@ function resolveMetadata(
|
|
|
260
288
|
api: string | undefined,
|
|
261
289
|
probe: CatalogProbe | null,
|
|
262
290
|
native: NativeModelEntry | undefined,
|
|
291
|
+
advertised: AdvertisedModelMetadata = {},
|
|
263
292
|
): ModelMetadata {
|
|
264
293
|
// Path 1: native user-authored models.json.
|
|
265
294
|
if (native) return metadataFromNative(native, api);
|
|
266
|
-
// Path 2: the
|
|
295
|
+
// Path 2: fields the provider advertised, overlaid on the lower tiers so a
|
|
296
|
+
// partially-advertising model keeps BOTH its advertised values and the
|
|
297
|
+
// catalog/floor values for the fields it omitted.
|
|
298
|
+
const lower = resolveLowerTiers(name, id, api, probe);
|
|
299
|
+
if (Object.keys(advertised).length > 0) {
|
|
300
|
+
return {
|
|
301
|
+
...lower,
|
|
302
|
+
...(advertised.contextWindow !== undefined ? { contextWindow: advertised.contextWindow } : {}),
|
|
303
|
+
...(advertised.maxTokens !== undefined ? { maxTokens: advertised.maxTokens } : {}),
|
|
304
|
+
...(advertised.reasoning !== undefined ? { reasoning: advertised.reasoning } : {}),
|
|
305
|
+
...(advertised.input !== undefined ? { input: [...advertised.input] } : {}),
|
|
306
|
+
// Weakest adopted tier: only a fully-advertised model is "endpoint";
|
|
307
|
+
// otherwise the lower tier that filled the gap owns the provenance.
|
|
308
|
+
metadataSource: isFullyAdvertised(advertised) ? "endpoint" : lower.metadataSource,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
return lower;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/** Tiers 3 + 4 of `resolveMetadata`: session-registry probe, then api-typed floors. */
|
|
315
|
+
function resolveLowerTiers(
|
|
316
|
+
name: string,
|
|
317
|
+
id: string,
|
|
318
|
+
api: string | undefined,
|
|
319
|
+
probe: CatalogProbe | null,
|
|
320
|
+
): ModelMetadata {
|
|
321
|
+
// Path 3: the session registry's own entry for the custom provider name.
|
|
267
322
|
if (probe) {
|
|
268
323
|
let hit: ReturnType<CatalogProbe> | undefined;
|
|
269
324
|
try {
|
|
@@ -282,7 +337,7 @@ function resolveMetadata(
|
|
|
282
337
|
};
|
|
283
338
|
}
|
|
284
339
|
}
|
|
285
|
-
// Path
|
|
340
|
+
// Path 4: api-typed enrichment fallback (built-in candidate probe → floors).
|
|
286
341
|
return enrichModelMetadata(id, api, probe);
|
|
287
342
|
}
|
|
288
343
|
|
|
@@ -302,7 +357,7 @@ const lastRegistered = new Map<string, ProviderEntry>();
|
|
|
302
357
|
// catalog models are NOT in this map — they carry real pi-ai metadata, so the
|
|
303
358
|
// push helper defaults them to "catalog".
|
|
304
359
|
// See change: enrich-model-selector-capabilities-favorites.
|
|
305
|
-
const enrichmentSource = new Map<string, "catalog" | "fallback">();
|
|
360
|
+
const enrichmentSource = new Map<string, "catalog" | "endpoint" | "fallback">();
|
|
306
361
|
|
|
307
362
|
// Canonical thinking-level order. Extends pi 0.75.5's EXTENDED_THINKING_LEVELS
|
|
308
363
|
// (off..xhigh) with the opt-in, runtime-gated `max` tier (reachable on newer
|
|
@@ -375,7 +430,7 @@ export function toModelInfo(m: any): {
|
|
|
375
430
|
reasoning?: boolean;
|
|
376
431
|
vision?: boolean;
|
|
377
432
|
contextWindow?: number;
|
|
378
|
-
metadataSource?: "catalog" | "fallback";
|
|
433
|
+
metadataSource?: "catalog" | "endpoint" | "fallback";
|
|
379
434
|
supportedThinkingLevels?: string[];
|
|
380
435
|
} {
|
|
381
436
|
const provider = m?.provider ?? "";
|
|
@@ -477,6 +532,12 @@ function hasApiKey(_providerName: string, entry: ProviderEntry): boolean {
|
|
|
477
532
|
interface DiscoveredModel {
|
|
478
533
|
id: string;
|
|
479
534
|
owned_by?: string;
|
|
535
|
+
/**
|
|
536
|
+
* Capability fields this provider advertised in its model list. An absent
|
|
537
|
+
* key = not advertised, so the catalog probe / api-typed floor supplies it
|
|
538
|
+
* (per-field fallback). See change: fix-custom-provider-model-metadata.
|
|
539
|
+
*/
|
|
540
|
+
advertised: AdvertisedModelMetadata;
|
|
480
541
|
}
|
|
481
542
|
|
|
482
543
|
async function discoverModels(baseUrl: string, apiKey: string): Promise<DiscoveredModel[]> {
|
|
@@ -499,15 +560,16 @@ async function discoverModels(baseUrl: string, apiKey: string): Promise<Discover
|
|
|
499
560
|
return [];
|
|
500
561
|
}
|
|
501
562
|
|
|
502
|
-
const body = await response.json() as
|
|
503
|
-
|
|
563
|
+
const body = await response.json() as unknown;
|
|
564
|
+
// Shape-keyed mapping preserving every advertised capability field. The
|
|
565
|
+
// former `{ id, owned_by }` projection discarded the metadata one function
|
|
566
|
+
// too early. See change: fix-custom-provider-model-metadata (design D2).
|
|
567
|
+
const shaped = body as { data?: unknown; models?: unknown } | null;
|
|
568
|
+
if (!Array.isArray(shaped?.data) && !Array.isArray(shaped?.models)) {
|
|
504
569
|
console.warn(`[provider] Model discovery: unexpected response format from ${url}`);
|
|
505
570
|
return [];
|
|
506
571
|
}
|
|
507
|
-
|
|
508
|
-
return body.data
|
|
509
|
-
.filter((m: any) => m?.id && typeof m.id === "string")
|
|
510
|
-
.map((m: any) => ({ id: m.id, owned_by: m.owned_by }));
|
|
572
|
+
return mapAdvertisedModels(body);
|
|
511
573
|
} catch (err: any) {
|
|
512
574
|
console.warn(`[provider] Model discovery failed for ${url}: ${err.message}`);
|
|
513
575
|
return [];
|
|
@@ -591,6 +653,7 @@ export function _buildProviderCatalogue(
|
|
|
591
653
|
} catch { /* fallback to id */ }
|
|
592
654
|
let configured = false;
|
|
593
655
|
let source: ProviderInfo["source"];
|
|
656
|
+
let authLabel: string | undefined;
|
|
594
657
|
try {
|
|
595
658
|
// Registry-level status (pi-ai 0.80.x) sees keys supplied via
|
|
596
659
|
// pi.registerProvider() (held in providerRequestConfigs), which
|
|
@@ -602,6 +665,10 @@ export function _buildProviderCatalogue(
|
|
|
602
665
|
if (regStatus) {
|
|
603
666
|
configured = !!regStatus.configured;
|
|
604
667
|
source = regStatus.source;
|
|
668
|
+
// pi >= 0.99.2 labels environment auth (e.g. "workload identity
|
|
669
|
+
// federation", which no env-key probe can see). See change:
|
|
670
|
+
// update-pi-core-1-0-adopt-apis (D7).
|
|
671
|
+
if (typeof regStatus.label === "string" && regStatus.label) authLabel = regStatus.label;
|
|
605
672
|
}
|
|
606
673
|
} else {
|
|
607
674
|
const status = modelRegistry.authStorage?.getAuthStatus?.(id);
|
|
@@ -635,6 +702,7 @@ export function _buildProviderCatalogue(
|
|
|
635
702
|
source,
|
|
636
703
|
envVar,
|
|
637
704
|
ambient,
|
|
705
|
+
...(authLabel ? { authLabel } : {}),
|
|
638
706
|
expires,
|
|
639
707
|
custom: customIds.has(id) || undefined,
|
|
640
708
|
};
|
|
@@ -792,6 +860,9 @@ async function registerEntry(pi: ExtensionAPI, name: string, entry: ProviderEntr
|
|
|
792
860
|
// model authored under `providers.<name>.models[]` but absent from
|
|
793
861
|
// `/v1/models` (or when `/v1/models` is unreachable) still reaches the
|
|
794
862
|
// session and the web UI — matching the server path (AC5).
|
|
863
|
+
const advertisedById = new Map<string, AdvertisedModelMetadata>();
|
|
864
|
+
for (const d of discovered) advertisedById.set(d.id, d.advertised);
|
|
865
|
+
|
|
795
866
|
const unionIds: string[] = [];
|
|
796
867
|
const seenIds = new Set<string>();
|
|
797
868
|
for (const id of [...discovered.map((d) => d.id), ...nativeForProvider.keys()]) {
|
|
@@ -801,7 +872,7 @@ async function registerEntry(pi: ExtensionAPI, name: string, entry: ProviderEntr
|
|
|
801
872
|
}
|
|
802
873
|
|
|
803
874
|
const models = unionIds.map((id) => {
|
|
804
|
-
const meta = resolveMetadata(name, id, entry.api, probe, nativeForProvider.get(id));
|
|
875
|
+
const meta = resolveMetadata(name, id, entry.api, probe, nativeForProvider.get(id), advertisedById.get(id));
|
|
805
876
|
// Record enrichment confidence so models_list push sites can flag
|
|
806
877
|
// assumed-vs-verified capabilities. Keyed by the registered provider name.
|
|
807
878
|
enrichmentSource.set(`${name}/${id}`, meta.metadataSource);
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Is the server behind this remote endpoint the one I paired with?" — asked
|
|
3
|
+
* BEFORE a session is registered, not after (D8, tasks 7.2/7.3).
|
|
4
|
+
*
|
|
5
|
+
* Local endpoints are out of scope: a unix socket's filesystem ownership (D5)
|
|
6
|
+
* and the loopback token (D6) already answer entitlement there, and the
|
|
7
|
+
* instance check in `instance-verification.ts` answers *which* instance. This
|
|
8
|
+
* gate covers the case those cannot reach — a server across a network, where an
|
|
9
|
+
* address proves nothing at all.
|
|
10
|
+
*
|
|
11
|
+
* The challenge is injected so the decision table is testable without I/O.
|
|
12
|
+
*
|
|
13
|
+
* See change: add-pi-gateway-transport-identity (D8).
|
|
14
|
+
*/
|
|
15
|
+
import type { PinVerdict, ServerPin } from "@blackbelt-technology/pi-dashboard-shared/server-pinning.js";
|
|
16
|
+
import { challengePinnedServer } from "@blackbelt-technology/pi-dashboard-shared/server-pinning.js";
|
|
17
|
+
import type { PinnedServer, ServerPinStore } from "./server-pin-store.js";
|
|
18
|
+
import { resolvePinForEndpoint } from "./server-pin-store.js";
|
|
19
|
+
|
|
20
|
+
const LOOPBACK_HOSTS = new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
21
|
+
|
|
22
|
+
/** A socket or loopback endpoint is local; anything else crosses a network. */
|
|
23
|
+
export function isRemoteEndpoint(endpoint: string): boolean {
|
|
24
|
+
if (endpoint.startsWith("ws+unix:")) return false;
|
|
25
|
+
try {
|
|
26
|
+
const u = new URL(endpoint);
|
|
27
|
+
return !LOOPBACK_HOSTS.has(u.hostname) && !LOOPBACK_HOSTS.has(u.host);
|
|
28
|
+
} catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The http origin serving `/api/pair/challenge` for a ws endpoint. */
|
|
34
|
+
export function httpBaseUrlFor(endpoint: string): string | null {
|
|
35
|
+
try {
|
|
36
|
+
const u = new URL(endpoint);
|
|
37
|
+
if (u.protocol === "ws:") return `http://${u.host}`;
|
|
38
|
+
if (u.protocol === "wss:") return `https://${u.host}`;
|
|
39
|
+
return null;
|
|
40
|
+
} catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type GateCause = PinVerdict["cause"] | "local" | "unpinned-legacy";
|
|
46
|
+
|
|
47
|
+
export interface GateResult {
|
|
48
|
+
allow: boolean;
|
|
49
|
+
cause: GateCause;
|
|
50
|
+
reason: string;
|
|
51
|
+
/** The identity that was verified, when one was. */
|
|
52
|
+
fingerprint?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface GateInput {
|
|
56
|
+
endpoint: string;
|
|
57
|
+
store: ServerPinStore;
|
|
58
|
+
challenge?: (baseUrl: string, pin: ServerPin) => Promise<PinVerdict>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const defaultChallenge = (baseUrl: string, pin: ServerPin) => challengePinnedServer({ baseUrl, pin });
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Decide whether this bridge may register over `endpoint`.
|
|
65
|
+
*
|
|
66
|
+
* A bridge that has never paired keeps working against a remote URL — refusing
|
|
67
|
+
* would break every existing `PI_DASHBOARD_URL` deployment on upgrade — but the
|
|
68
|
+
* connection is reported as unverified, on the same deprecation horizon as the
|
|
69
|
+
* unauthenticated TCP path (D10b, task 8.5). Once ANY pin exists, the fail-open
|
|
70
|
+
* is over: an uncovered endpoint is refused rather than pinned on sight.
|
|
71
|
+
*/
|
|
72
|
+
export async function gateRemoteRegistration(input: GateInput): Promise<GateResult> {
|
|
73
|
+
if (!isRemoteEndpoint(input.endpoint)) {
|
|
74
|
+
return { allow: true, cause: "local", reason: `local endpoint ${input.endpoint} — authorised by the transport` };
|
|
75
|
+
}
|
|
76
|
+
if (input.store.servers.length === 0) {
|
|
77
|
+
return {
|
|
78
|
+
allow: true,
|
|
79
|
+
cause: "unpinned-legacy",
|
|
80
|
+
reason: `unverified: ${input.endpoint} is remote and this bridge has pinned no server identity — pair to verify it`,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const pin: PinnedServer | undefined = resolvePinForEndpoint(input.store, input.endpoint);
|
|
84
|
+
if (!pin) {
|
|
85
|
+
return {
|
|
86
|
+
allow: false,
|
|
87
|
+
cause: "not-pinned",
|
|
88
|
+
reason: `refused: ${input.endpoint} matches no pinned server identity`,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const baseUrl = httpBaseUrlFor(input.endpoint);
|
|
92
|
+
if (!baseUrl) {
|
|
93
|
+
return { allow: false, cause: "unreachable", reason: `refused: ${input.endpoint} has no http origin to challenge` };
|
|
94
|
+
}
|
|
95
|
+
const verdict = await (input.challenge ?? defaultChallenge)(baseUrl, pin);
|
|
96
|
+
return {
|
|
97
|
+
allow: verdict.accept,
|
|
98
|
+
cause: verdict.cause,
|
|
99
|
+
reason: verdict.reason,
|
|
100
|
+
fingerprint: verdict.accept ? pin.fingerprint : undefined,
|
|
101
|
+
};
|
|
102
|
+
}
|