@oscharko-dev/keiko-contracts 0.2.7 → 0.2.9
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/.tsbuildinfo +1 -1
- package/dist/bff-wire.d.ts +86 -19
- package/dist/bff-wire.d.ts.map +1 -1
- package/dist/command-runner.d.ts +81 -0
- package/dist/command-runner.d.ts.map +1 -0
- package/dist/command-runner.js +209 -0
- package/dist/container-runtime.d.ts +125 -0
- package/dist/container-runtime.d.ts.map +1 -0
- package/dist/container-runtime.js +287 -0
- package/dist/context-engineering.js +2 -2
- package/dist/discussion-intelligence.d.ts +70 -0
- package/dist/discussion-intelligence.d.ts.map +1 -0
- package/dist/discussion-intelligence.js +440 -0
- package/dist/editor-agent-governance.d.ts +65 -0
- package/dist/editor-agent-governance.d.ts.map +1 -0
- package/dist/editor-agent-governance.js +180 -0
- package/dist/editor-agent.d.ts +29 -1
- package/dist/editor-agent.d.ts.map +1 -1
- package/dist/editor-agent.js +183 -6
- package/dist/editor-builtin-capabilities.d.ts +13 -0
- package/dist/editor-builtin-capabilities.d.ts.map +1 -0
- package/dist/editor-builtin-capabilities.js +135 -0
- package/dist/editor-language-mode-map.d.ts +11 -0
- package/dist/editor-language-mode-map.d.ts.map +1 -0
- package/dist/editor-language-mode-map.js +89 -0
- package/dist/editor-layout.d.ts +37 -0
- package/dist/editor-layout.d.ts.map +1 -1
- package/dist/editor-layout.js +125 -8
- package/dist/editor-workspace-path.d.ts +20 -0
- package/dist/editor-workspace-path.d.ts.map +1 -0
- package/dist/editor-workspace-path.js +133 -0
- package/dist/evidence.d.ts +3 -1
- package/dist/evidence.d.ts.map +1 -1
- package/dist/gateway.d.ts +72 -3
- package/dist/gateway.d.ts.map +1 -1
- package/dist/gateway.js +73 -3
- package/dist/git-commit-intent.d.ts +28 -0
- package/dist/git-commit-intent.d.ts.map +1 -0
- package/dist/git-commit-intent.js +155 -0
- package/dist/git-commit-policy.d.ts +29 -0
- package/dist/git-commit-policy.d.ts.map +1 -0
- package/dist/git-commit-policy.js +173 -0
- package/dist/git-delivery-action-sheet.d.ts +157 -0
- package/dist/git-delivery-action-sheet.d.ts.map +1 -0
- package/dist/git-delivery-action-sheet.js +430 -0
- package/dist/git-delivery-evidence.d.ts +92 -0
- package/dist/git-delivery-evidence.d.ts.map +1 -0
- package/dist/git-delivery-evidence.js +272 -0
- package/dist/git-delivery-policy.d.ts +40 -0
- package/dist/git-delivery-policy.d.ts.map +1 -0
- package/dist/git-delivery-policy.js +183 -0
- package/dist/git-delivery-provider.d.ts +53 -0
- package/dist/git-delivery-provider.d.ts.map +1 -0
- package/dist/git-delivery-provider.js +96 -0
- package/dist/git-delivery.d.ts +202 -0
- package/dist/git-delivery.d.ts.map +1 -0
- package/dist/git-delivery.js +410 -0
- package/dist/git-history.d.ts +27 -0
- package/dist/git-history.d.ts.map +1 -0
- package/dist/git-history.js +73 -0
- package/dist/git-merge.d.ts +67 -0
- package/dist/git-merge.d.ts.map +1 -0
- package/dist/git-merge.js +323 -0
- package/dist/git-pull-request.d.ts +112 -0
- package/dist/git-pull-request.d.ts.map +1 -0
- package/dist/git-pull-request.js +351 -0
- package/dist/git-repository-agent.d.ts +46 -0
- package/dist/git-repository-agent.d.ts.map +1 -0
- package/dist/git-repository-agent.js +198 -0
- package/dist/git-repository-summary.d.ts +54 -0
- package/dist/git-repository-summary.d.ts.map +1 -0
- package/dist/git-repository-summary.js +105 -0
- package/dist/git-repository.d.ts +60 -0
- package/dist/git-repository.d.ts.map +1 -0
- package/dist/git-repository.js +106 -0
- package/dist/git-sync.d.ts +49 -0
- package/dist/git-sync.d.ts.map +1 -0
- package/dist/git-sync.js +110 -0
- package/dist/index.d.ts +63 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -6
- package/dist/lsp-process.d.ts +38 -0
- package/dist/lsp-process.d.ts.map +1 -0
- package/dist/lsp-process.js +103 -0
- package/dist/prompt-enhancer-analyzer.d.ts.map +1 -1
- package/dist/prompt-enhancer-analyzer.js +198 -22
- package/dist/runtime-capabilities.d.ts +44 -0
- package/dist/runtime-capabilities.d.ts.map +1 -0
- package/dist/runtime-capabilities.js +141 -0
- package/dist/task-workspace.d.ts +302 -0
- package/dist/task-workspace.d.ts.map +1 -0
- package/dist/task-workspace.js +1236 -0
- package/dist/voice-action-intent.d.ts +86 -0
- package/dist/voice-action-intent.d.ts.map +1 -0
- package/dist/voice-action-intent.js +387 -0
- package/dist/voice-playback.d.ts +50 -0
- package/dist/voice-playback.d.ts.map +1 -0
- package/dist/voice-playback.js +240 -0
- package/dist/voice-protocol.d.ts +165 -0
- package/dist/voice-protocol.d.ts.map +1 -0
- package/dist/voice-protocol.js +312 -0
- package/dist/voice-transcript.d.ts +57 -0
- package/dist/voice-transcript.d.ts.map +1 -0
- package/dist/voice-transcript.js +221 -0
- package/package.json +5 -1
- package/dist/conversation-budget.d.ts +0 -37
- package/dist/conversation-budget.d.ts.map +0 -1
- package/dist/conversation-budget.js +0 -97
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
// Conversation budget estimator (Issue #151 / Epic #142).
|
|
2
|
-
//
|
|
3
|
-
// Pure, deterministic helper that estimates how much of a chat model's context
|
|
4
|
-
// window is consumed by a conversation turn. The UI uses this for the
|
|
5
|
-
// pre-send pressure indicator (AC#1) and the "clear history" affordance
|
|
6
|
-
// (AC#4). The breakdown carries connected-context byte counts so they can
|
|
7
|
-
// be disclosed and removable from the next call (AC#5).
|
|
8
|
-
//
|
|
9
|
-
// Engineering note (from the issue): token counting is APPROXIMATE here.
|
|
10
|
-
// We use bytes/4 as a rough proxy. UI copy and tests MUST state this
|
|
11
|
-
// precisely — do not present byte estimates as exact tokens.
|
|
12
|
-
// Average ASCII byte ≈ 4 chars per token in mainstream BPE tokenizers. This
|
|
13
|
-
// is an over-simplification; we surface it as APPROXIMATE everywhere.
|
|
14
|
-
const APPROX_BYTES_PER_TOKEN = 4;
|
|
15
|
-
// Pressure thresholds, applied against the fraction of availableInputTokens
|
|
16
|
-
// the approximate token count consumes.
|
|
17
|
-
const PRESSURE_LOW = 0.5;
|
|
18
|
-
const PRESSURE_MODERATE = 0.75;
|
|
19
|
-
const PRESSURE_HIGH = 0.95;
|
|
20
|
-
function coerceNonNegativeInt(value) {
|
|
21
|
-
if (value === undefined)
|
|
22
|
-
return 0;
|
|
23
|
-
if (!Number.isFinite(value))
|
|
24
|
-
return 0;
|
|
25
|
-
if (value <= 0)
|
|
26
|
-
return 0;
|
|
27
|
-
return Math.floor(value);
|
|
28
|
-
}
|
|
29
|
-
function utf8ByteLength(text) {
|
|
30
|
-
// Browsers and Node both expose TextEncoder. Falls back to char length
|
|
31
|
-
// when (in some legacy harness) it is absent — acceptable since the
|
|
32
|
-
// result is documented approximate.
|
|
33
|
-
if (typeof TextEncoder !== "undefined") {
|
|
34
|
-
return new TextEncoder().encode(text).length;
|
|
35
|
-
}
|
|
36
|
-
return text.length;
|
|
37
|
-
}
|
|
38
|
-
function sumHistoryBytes(history) {
|
|
39
|
-
let total = 0;
|
|
40
|
-
for (const message of history) {
|
|
41
|
-
total += utf8ByteLength(message.role);
|
|
42
|
-
total += utf8ByteLength(message.content);
|
|
43
|
-
}
|
|
44
|
-
return total;
|
|
45
|
-
}
|
|
46
|
-
function sumDocumentBytes(documents) {
|
|
47
|
-
if (documents === undefined)
|
|
48
|
-
return 0;
|
|
49
|
-
let total = 0;
|
|
50
|
-
for (const document of documents) {
|
|
51
|
-
total += coerceNonNegativeInt(document.extractedBytes);
|
|
52
|
-
}
|
|
53
|
-
return total;
|
|
54
|
-
}
|
|
55
|
-
function classifyPressure(tokens, availableInputTokens) {
|
|
56
|
-
if (availableInputTokens <= 0)
|
|
57
|
-
return "exceeded";
|
|
58
|
-
const ratio = tokens / availableInputTokens;
|
|
59
|
-
if (ratio > PRESSURE_HIGH)
|
|
60
|
-
return "exceeded";
|
|
61
|
-
if (ratio > PRESSURE_MODERATE)
|
|
62
|
-
return "high";
|
|
63
|
-
if (ratio > PRESSURE_LOW)
|
|
64
|
-
return "moderate";
|
|
65
|
-
return "low";
|
|
66
|
-
}
|
|
67
|
-
export function estimateConversationBudget(input) {
|
|
68
|
-
const contextWindowTokens = coerceNonNegativeInt(input.modelContextWindow);
|
|
69
|
-
const reservedOutputTokens = coerceNonNegativeInt(input.modelMaxOutputTokens);
|
|
70
|
-
const availableInputTokens = Math.max(0, contextWindowTokens - reservedOutputTokens);
|
|
71
|
-
const draftBytes = utf8ByteLength(input.userDraftText);
|
|
72
|
-
const historyBytes = sumHistoryBytes(input.conversationHistory);
|
|
73
|
-
const documentBytes = sumDocumentBytes(input.documentContext);
|
|
74
|
-
const repoContextBytes = coerceNonNegativeInt(input.repoContextPackBytes);
|
|
75
|
-
const knowledgeBytes = coerceNonNegativeInt(input.knowledgeCapsuleBytes);
|
|
76
|
-
const memoryBytes = coerceNonNegativeInt(input.memoryContextBytes);
|
|
77
|
-
const breakdown = {
|
|
78
|
-
draftBytes,
|
|
79
|
-
historyBytes,
|
|
80
|
-
documentBytes,
|
|
81
|
-
repoContextBytes,
|
|
82
|
-
knowledgeBytes,
|
|
83
|
-
memoryBytes,
|
|
84
|
-
};
|
|
85
|
-
const approximateBytes = draftBytes + historyBytes + documentBytes + repoContextBytes + knowledgeBytes + memoryBytes;
|
|
86
|
-
const approximateTokens = Math.ceil(approximateBytes / APPROX_BYTES_PER_TOKEN);
|
|
87
|
-
const pressure = classifyPressure(approximateTokens, availableInputTokens);
|
|
88
|
-
return {
|
|
89
|
-
approximateBytes,
|
|
90
|
-
approximateTokens,
|
|
91
|
-
contextWindowTokens,
|
|
92
|
-
reservedOutputTokens,
|
|
93
|
-
availableInputTokens,
|
|
94
|
-
pressure,
|
|
95
|
-
breakdown,
|
|
96
|
-
};
|
|
97
|
-
}
|