@kubbisec/ai-linux-arm64 0.1.21 → 0.1.22
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/bundled/clarify/clarify-gate-state.d.ts +1 -1
- package/bundled/clarify/clarify-gate-state.js +3 -3
- package/bundled/clarify/clarify-gate.d.ts +21 -14
- package/bundled/clarify/clarify-gate.js +118 -111
- package/bundled/clarify/clarify-select-panel.d.ts +16 -9
- package/bundled/clarify/clarify-select-panel.js +65 -67
- package/bundled/clarify/clarify-ui-state.d.ts +12 -10
- package/bundled/clarify/clarify-ui-state.js +26 -26
- package/bundled/clarify/parse-clarify-answer.d.ts +29 -18
- package/bundled/clarify/parse-clarify-answer.js +39 -45
- package/bundled/clarify/question-format.d.ts +34 -23
- package/bundled/clarify/question-format.js +112 -119
- package/bundled/clarify/questionnaire-tool.d.ts +28 -17
- package/bundled/clarify/questionnaire-tool.js +180 -144
- package/bundled/clarify/scope-discovery.d.ts +8 -5
- package/bundled/clarify/scope-discovery.js +102 -110
- package/bundled/clarify/session-questionnaire.d.ts +48 -13
- package/bundled/clarify/session-questionnaire.js +304 -312
- package/bundled/clarify/session-questionnaire.types.d.ts +29 -27
- package/bundled/clarify/session-questionnaire.types.js +10 -10
- package/bundled/components/kubbisec-model-selector.d.ts +47 -34
- package/bundled/components/kubbisec-model-selector.js +187 -177
- package/bundled/config/config.d.ts +6 -6
- package/bundled/config/config.js +55 -55
- package/bundled/config/detect-local-llm-providers.d.ts +26 -16
- package/bundled/config/detect-local-llm-providers.js +130 -142
- package/bundled/config/ensure-kubbisec-project-settings.d.ts +9 -9
- package/bundled/config/ensure-kubbisec-project-settings.js +44 -48
- package/bundled/config/extended-context.d.ts +5 -6
- package/bundled/config/extended-context.js +23 -22
- package/bundled/config/feature-flags.d.ts +10 -2
- package/bundled/config/feature-flags.js +8 -2
- package/bundled/config/format-kubbisec-footer-status.d.ts +1 -1
- package/bundled/config/format-kubbisec-footer-status.js +26 -31
- package/bundled/config/kubbisec-extension-manifest.d.ts +22 -2
- package/bundled/config/kubbisec-extension-manifest.js +20 -20
- package/bundled/config/llm-config-mutations.d.ts +51 -25
- package/bundled/config/llm-config-mutations.js +173 -182
- package/bundled/config/llm-config.d.ts +54 -41
- package/bundled/config/llm-config.js +199 -199
- package/bundled/config/llm-provider-catalog.d.ts +18 -15
- package/bundled/config/llm-provider-catalog.js +45 -46
- package/bundled/config/materialize-kubbisec-pi-resources.d.ts +1 -1
- package/bundled/config/materialize-kubbisec-pi-resources.js +174 -183
- package/bundled/config/register-custom-llm-providers.d.ts +11 -5
- package/bundled/config/register-custom-llm-providers.js +17 -15
- package/bundled/config/register-kubbisec-llm-provider.d.ts +14 -10
- package/bundled/config/register-kubbisec-llm-provider.js +50 -42
- package/bundled/config/resolve-agents-context-file.d.ts +1 -1
- package/bundled/config/resolve-agents-context-file.js +33 -34
- package/bundled/config/resource-budget.d.ts +12 -12
- package/bundled/config/resource-budget.js +28 -28
- package/bundled/config/sync-kubbisec-pi-models.d.ts +6 -3
- package/bundled/config/sync-kubbisec-pi-models.js +58 -58
- package/bundled/copy/cli-reference-index.d.ts +3 -2
- package/bundled/copy/cli-reference-index.js +1 -1
- package/bundled/copy/kubbisec-shell-copy.d.ts +11 -6
- package/bundled/copy/kubbisec-shell-copy.js +1 -1
- package/bundled/extensions/cli-local-shared.d.ts +45 -26
- package/bundled/extensions/cli-local-shared.js +128 -118
- package/bundled/extensions/kubbisec-aspm-local.extension.d.ts +18 -15
- package/bundled/extensions/kubbisec-aspm-local.extension.js +118 -114
- package/bundled/extensions/kubbisec-brand.extension.d.ts +1 -1
- package/bundled/extensions/kubbisec-brand.extension.js +25 -25
- package/bundled/extensions/kubbisec-byok-provider.extension.d.ts +1 -1
- package/bundled/extensions/kubbisec-byok-provider.extension.js +2 -2
- package/bundled/extensions/kubbisec-clarify.extension.d.ts +64 -35
- package/bundled/extensions/kubbisec-clarify.extension.js +323 -305
- package/bundled/extensions/kubbisec-exit.extension.d.ts +1 -1
- package/bundled/extensions/kubbisec-exit.extension.js +29 -32
- package/bundled/extensions/kubbisec-extended-context.extension.d.ts +1 -1
- package/bundled/extensions/kubbisec-extended-context.extension.js +56 -43
- package/bundled/extensions/kubbisec-footer.extension.d.ts +14 -14
- package/bundled/extensions/kubbisec-footer.extension.js +205 -215
- package/bundled/extensions/kubbisec-github-local.extension.d.ts +26 -18
- package/bundled/extensions/kubbisec-github-local.extension.js +123 -116
- package/bundled/extensions/kubbisec-llm-config.extension.d.ts +1 -1
- package/bundled/extensions/kubbisec-llm-config.extension.js +200 -181
- package/bundled/extensions/kubbisec-memory.extension.d.ts +9 -7
- package/bundled/extensions/kubbisec-memory.extension.js +88 -95
- package/bundled/extensions/kubbisec-naus-local.extension.d.ts +18 -15
- package/bundled/extensions/kubbisec-naus-local.extension.js +132 -111
- package/bundled/extensions/kubbisec-platform-tools.extension.d.ts +31 -21
- package/bundled/extensions/kubbisec-platform-tools.extension.js +152 -152
- package/bundled/extensions/kubbisec-runtime-status.extension.d.ts +10 -8
- package/bundled/extensions/kubbisec-runtime-status.extension.js +15 -13
- package/bundled/extensions/kubbisec-scope.extension.d.ts +12 -7
- package/bundled/extensions/kubbisec-scope.extension.js +13 -13
- package/bundled/extensions/kubbisec-skill-mentions.extension.d.ts +27 -16
- package/bundled/extensions/kubbisec-skill-mentions.extension.js +73 -63
- package/bundled/extensions/kubbisec-skill-telemetry.extension.d.ts +2 -3
- package/bundled/extensions/kubbisec-skill-telemetry.extension.js +59 -64
- package/bundled/extensions/kubbisec-theme-lock.extension.d.ts +1 -1
- package/bundled/extensions/kubbisec-theme-lock.extension.js +33 -34
- package/bundled/extensions/kubbisec-ui.extension.d.ts +1 -1
- package/bundled/extensions/kubbisec-ui.extension.js +114 -109
- package/bundled/extensions/kubbisec-workflow.extension.d.ts +20 -18
- package/bundled/extensions/kubbisec-workflow.extension.js +138 -140
- package/bundled/node_modules/@aspm/shared/dist/redaction.test.d.ts +2 -0
- package/bundled/node_modules/@aspm/shared/dist/redaction.test.d.ts.map +1 -0
- package/bundled/node_modules/@aspm/shared/dist/redaction.test.js +626 -0
- package/bundled/node_modules/@aspm/shared/dist/redaction.test.js.map +1 -0
- package/bundled/resolve-bundled-dist-root.js +122 -131
- package/bundled/skills/at-path-mentions.d.ts +1 -1
- package/bundled/skills/at-path-mentions.js +146 -153
- package/bundled/skills/chat-mention-render.d.ts +2 -2
- package/bundled/skills/chat-mention-render.js +121 -126
- package/bundled/skills/chat-mentions.d.ts +17 -8
- package/bundled/skills/chat-mentions.js +76 -76
- package/bundled/skills/list-bundled-skills.d.ts +3 -3
- package/bundled/skills/list-bundled-skills.js +33 -35
- package/bundled/skills/skill-mention.d.ts +10 -2
- package/bundled/skills/skill-mention.js +10 -2
- package/bundled/theme/clear-terminal.d.ts +1 -1
- package/bundled/theme/clear-terminal.js +3 -4
- package/bundled/theme/footer-render-hook.d.ts +1 -1
- package/bundled/theme/footer-render-hook.js +3 -3
- package/bundled/theme/kubbisec-brand-fg.d.ts +1 -1
- package/bundled/theme/kubbisec-brand-fg.js +2 -2
- package/bundled/theme/kubbisec-menu-themes.d.ts +7 -7
- package/bundled/theme/kubbisec-menu-themes.js +30 -31
- package/bundled/theme/kubbisec-theme-name.d.ts +1 -1
- package/bundled/theme/kubbisec-theme-name.js +1 -1
- package/bundled/theme/patch-pi-settings-theme.runtime.d.ts +1 -1
- package/bundled/theme/patch-pi-settings-theme.runtime.js +11 -10
- package/bundled/theme/render-compact-header.d.ts +13 -5
- package/bundled/theme/render-compact-header.js +127 -129
- package/bundled/workflow/session-workflow-mode.d.ts +1 -1
- package/bundled/workflow/session-workflow-mode.js +33 -33
- package/package.json +1 -1
|
@@ -1,211 +1,230 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
groupModelsForSelector,
|
|
3
|
+
KubbisecModelSelectorComponent,
|
|
4
|
+
} from "../components/kubbisec-model-selector.js";
|
|
2
5
|
import { syncAutodetectedLocalProviders } from "../config/detect-local-llm-providers.js";
|
|
3
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
applyLlmConfigToPiSettings,
|
|
8
|
+
applyTemperatureToProviderPayload,
|
|
9
|
+
getRuntimeTemperature,
|
|
10
|
+
readLlmConfig,
|
|
11
|
+
setRuntimeTemperature,
|
|
12
|
+
writeLlmConfig,
|
|
13
|
+
} from "../config/llm-config.js";
|
|
4
14
|
import { KUBBISEC_LLM_PROVIDER_ID } from "../config/llm-provider-catalog.js";
|
|
5
15
|
import { registerCustomLlmProviders } from "../config/register-custom-llm-providers.js";
|
|
6
16
|
import { registerKubbisecLlmProvider } from "../config/register-kubbisec-llm-provider.js";
|
|
7
17
|
import { requestKubbisecFooterRender } from "../theme/footer-render-hook.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"minimal",
|
|
11
|
-
"low",
|
|
12
|
-
"medium",
|
|
13
|
-
"high",
|
|
14
|
-
"xhigh",
|
|
15
|
-
];
|
|
18
|
+
|
|
19
|
+
const THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh"];
|
|
16
20
|
function isThinkingLevel(value) {
|
|
17
|
-
|
|
21
|
+
return THINKING_LEVELS.includes(value);
|
|
18
22
|
}
|
|
19
23
|
async function refreshProviders(api, cwd) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
await syncAutodetectedLocalProviders(cwd);
|
|
25
|
+
registerKubbisecLlmProvider(api.registerProvider.bind(api), cwd);
|
|
26
|
+
registerCustomLlmProviders(api.registerProvider.bind(api), readLlmConfig(cwd));
|
|
23
27
|
}
|
|
24
28
|
async function applyDefaultModel(api, ctx) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (current?.provider === model.provider && current.id === model.id)
|
|
35
|
-
return;
|
|
36
|
-
await api.setModel(model);
|
|
29
|
+
const config = readLlmConfig(ctx.cwd);
|
|
30
|
+
const provider = config.defaultProvider ?? KUBBISEC_LLM_PROVIDER_ID;
|
|
31
|
+
const modelId = config.defaultModel?.trim();
|
|
32
|
+
if (!modelId) return;
|
|
33
|
+
const model = ctx.modelRegistry.find(provider, modelId);
|
|
34
|
+
if (!model) return;
|
|
35
|
+
const current = ctx.model;
|
|
36
|
+
if (current?.provider === model.provider && current.id === model.id) return;
|
|
37
|
+
await api.setModel(model);
|
|
37
38
|
}
|
|
38
39
|
function applyDefaultThinking(api, ctx) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return;
|
|
44
|
-
api.setThinkingLevel(config.defaultThinkingLevel);
|
|
40
|
+
const config = readLlmConfig(ctx.cwd);
|
|
41
|
+
if (!config.defaultThinkingLevel) return;
|
|
42
|
+
if (api.getThinkingLevel() === config.defaultThinkingLevel) return;
|
|
43
|
+
api.setThinkingLevel(config.defaultThinkingLevel);
|
|
45
44
|
}
|
|
46
45
|
async function showGroupedModelSelector(api, ctx, initialSearch = "") {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
if (!ctx.hasUI) return;
|
|
47
|
+
ctx.modelRegistry.refresh();
|
|
48
|
+
const models = ctx.modelRegistry.getAvailable();
|
|
49
|
+
const groups = groupModelsForSelector(models, (provider) =>
|
|
50
|
+
ctx.modelRegistry.getProviderDisplayName(provider),
|
|
51
|
+
);
|
|
52
|
+
await ctx.ui.custom(
|
|
53
|
+
(tui, theme, _keybindings, done) =>
|
|
54
|
+
new KubbisecModelSelectorComponent(
|
|
55
|
+
tui,
|
|
56
|
+
ctx.model,
|
|
57
|
+
groups,
|
|
58
|
+
theme,
|
|
59
|
+
async (model) => {
|
|
60
|
+
const ok = await api.setModel(model);
|
|
61
|
+
if (!ok) {
|
|
62
|
+
ctx.ui.notify(
|
|
63
|
+
"Chave de API não configurada para este provedor. Edite .kubbisec/llm.json ou use /login.",
|
|
64
|
+
"error",
|
|
65
|
+
);
|
|
56
66
|
return;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
}
|
|
68
|
+
const config = readLlmConfig(ctx.cwd);
|
|
69
|
+
writeLlmConfig(ctx.cwd, {
|
|
60
70
|
...config,
|
|
61
71
|
defaultProvider: model.provider,
|
|
62
72
|
defaultModel: model.id,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
73
|
+
});
|
|
74
|
+
ctx.ui.notify(
|
|
75
|
+
`Modelo: ${ctx.modelRegistry.getProviderDisplayName(model.provider)} · ${model.name}`,
|
|
76
|
+
"info",
|
|
77
|
+
);
|
|
78
|
+
done(undefined);
|
|
79
|
+
},
|
|
80
|
+
() => done(undefined),
|
|
81
|
+
initialSearch,
|
|
82
|
+
),
|
|
83
|
+
);
|
|
67
84
|
}
|
|
68
85
|
async function handleModelCommand(api, args, ctx) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
86
|
+
const trimmed = args.trim();
|
|
87
|
+
if (!trimmed || trimmed === "list" || trimmed === "select") {
|
|
88
|
+
await showGroupedModelSelector(api, ctx, trimmed === "list" ? "" : "");
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const slash = trimmed.indexOf("/");
|
|
92
|
+
const provider = slash >= 0 ? trimmed.slice(0, slash).trim() : KUBBISEC_LLM_PROVIDER_ID;
|
|
93
|
+
const modelId = slash >= 0 ? trimmed.slice(slash + 1).trim() : trimmed;
|
|
94
|
+
if (!modelId) {
|
|
95
|
+
ctx.ui?.notify("Uso: /model [provedor/]modelo-id ou /model para abrir o seletor.", "warning");
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const model = ctx.modelRegistry.find(provider, modelId);
|
|
99
|
+
if (!model) {
|
|
100
|
+
ctx.ui?.notify(`Modelo não encontrado: ${provider}/${modelId}`, "error");
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const ok = await api.setModel(model);
|
|
104
|
+
if (!ok) {
|
|
105
|
+
ctx.ui?.notify("Chave de API não configurada para este provedor.", "error");
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const config = readLlmConfig(ctx.cwd);
|
|
109
|
+
writeLlmConfig(ctx.cwd, {
|
|
110
|
+
...config,
|
|
111
|
+
defaultProvider: model.provider,
|
|
112
|
+
defaultModel: model.id,
|
|
113
|
+
});
|
|
114
|
+
ctx.ui?.notify(
|
|
115
|
+
`Modelo: ${ctx.modelRegistry.getProviderDisplayName(model.provider)} · ${model.name}`,
|
|
116
|
+
"info",
|
|
117
|
+
);
|
|
98
118
|
}
|
|
99
119
|
async function handleTemperatureCommand(args, ctx) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
const parsed = Number.parseFloat(trimmed);
|
|
118
|
-
if (!Number.isFinite(parsed)) {
|
|
119
|
-
ctx.ui?.notify("Uso: /temperature 0.2 · /temperature status · /temperature reset", "warning");
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
setRuntimeTemperature(parsed, ctx.cwd);
|
|
123
|
-
ctx.ui?.notify(`Temperatura: ${getRuntimeTemperature()}`, "info");
|
|
120
|
+
const trimmed = args.trim().toLowerCase();
|
|
121
|
+
const config = readLlmConfig(ctx.cwd);
|
|
122
|
+
if (!trimmed || trimmed === "status") {
|
|
123
|
+
const value = getRuntimeTemperature(config);
|
|
124
|
+
ctx.ui?.notify(
|
|
125
|
+
value == null
|
|
126
|
+
? "Temperatura: padrão do modelo (não definida em .kubbisec/llm.json)"
|
|
127
|
+
: `Temperatura: ${value}`,
|
|
128
|
+
"info",
|
|
129
|
+
);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (trimmed === "reset" || trimmed === "default") {
|
|
133
|
+
setRuntimeTemperature(undefined, ctx.cwd);
|
|
134
|
+
const next = readLlmConfig(ctx.cwd);
|
|
135
|
+
writeLlmConfig(ctx.cwd, { ...next, temperature: config.temperature ?? 0.2 });
|
|
136
|
+
ctx.ui?.notify("Temperatura restaurada ao valor de .kubbisec/llm.json", "info");
|
|
124
137
|
requestKubbisecFooterRender();
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const parsed = Number.parseFloat(trimmed);
|
|
141
|
+
if (!Number.isFinite(parsed)) {
|
|
142
|
+
ctx.ui?.notify("Uso: /temperature 0.2 · /temperature status · /temperature reset", "warning");
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
setRuntimeTemperature(parsed, ctx.cwd);
|
|
146
|
+
ctx.ui?.notify(`Temperatura: ${getRuntimeTemperature()}`, "info");
|
|
147
|
+
requestKubbisecFooterRender();
|
|
125
148
|
}
|
|
126
149
|
async function handleThinkingCommand(api, args, ctx) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
150
|
+
const trimmed = args.trim().toLowerCase();
|
|
151
|
+
if (!trimmed || trimmed === "status") {
|
|
152
|
+
ctx.ui?.notify(`Reasoning effort: ${api.getThinkingLevel()}`, "info");
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (!isThinkingLevel(trimmed)) {
|
|
156
|
+
ctx.ui?.notify(`Uso: /thinking ${THINKING_LEVELS.join(" | ")}`, "warning");
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
api.setThinkingLevel(trimmed);
|
|
160
|
+
const config = readLlmConfig(ctx.cwd);
|
|
161
|
+
writeLlmConfig(ctx.cwd, { ...config, defaultThinkingLevel: trimmed });
|
|
162
|
+
ctx.ui?.notify(`Reasoning effort: ${trimmed}`, "info");
|
|
163
|
+
requestKubbisecFooterRender();
|
|
141
164
|
}
|
|
142
165
|
export default function kubbisecLlmConfig(api) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
writeLlmConfig(ctx.cwd, {
|
|
198
|
-
...config,
|
|
199
|
-
defaultProvider: model.provider,
|
|
200
|
-
defaultModel: model.id,
|
|
201
|
-
});
|
|
166
|
+
registerKubbisecLlmProvider(api.registerProvider.bind(api));
|
|
167
|
+
const modelsCommand = {
|
|
168
|
+
description: "Selecionar modelo (agrupado por provedor)",
|
|
169
|
+
handler: (args, ctx) => handleModelCommand(api, args, ctx),
|
|
170
|
+
};
|
|
171
|
+
api.registerCommand("models", modelsCommand);
|
|
172
|
+
api.on("input", async (event, ctx) => {
|
|
173
|
+
if (event.source !== "interactive" || !ctx.hasUI) return;
|
|
174
|
+
const trimmed = event.text.trim();
|
|
175
|
+
if (!trimmed.startsWith("/model")) return;
|
|
176
|
+
if (trimmed.length > 6 && !trimmed.startsWith("/model ")) return;
|
|
177
|
+
const args = trimmed === "/model" ? "" : trimmed.slice("/model ".length);
|
|
178
|
+
await handleModelCommand(api, args, ctx);
|
|
179
|
+
return { action: "handled" };
|
|
180
|
+
});
|
|
181
|
+
api.registerCommand("temperature", {
|
|
182
|
+
description: "Ver ou definir temperatura (0–2)",
|
|
183
|
+
handler: handleTemperatureCommand,
|
|
184
|
+
});
|
|
185
|
+
api.registerCommand("thinking", {
|
|
186
|
+
description: "Ver ou definir reasoning effort (off … xhigh)",
|
|
187
|
+
handler: (args, ctx) => handleThinkingCommand(api, args, ctx),
|
|
188
|
+
});
|
|
189
|
+
api.registerCommand("detect-local", {
|
|
190
|
+
description: "Detectar Ollama e LM Studio nesta máquina",
|
|
191
|
+
handler: async (_args, ctx) => {
|
|
192
|
+
const { result } = await syncAutodetectedLocalProviders(ctx.cwd);
|
|
193
|
+
await refreshProviders(api, ctx.cwd);
|
|
194
|
+
const names = result.detected.map((provider) => provider.name ?? provider.id);
|
|
195
|
+
if (names.length === 0) {
|
|
196
|
+
ctx.ui?.notify("Nenhum servidor local detectado (Ollama / LM Studio).", "info");
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
ctx.ui?.notify(`Detectados: ${names.join(", ")}`, "info");
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
api.on("session_start", async (_event, ctx) => {
|
|
203
|
+
await refreshProviders(api, ctx.cwd);
|
|
204
|
+
applyLlmConfigToPiSettings(ctx.cwd);
|
|
205
|
+
await applyDefaultModel(api, ctx);
|
|
206
|
+
applyDefaultThinking(api, ctx);
|
|
207
|
+
});
|
|
208
|
+
api.on("before_provider_request", async (event, ctx) => {
|
|
209
|
+
const temperature = getRuntimeTemperature(readLlmConfig(ctx.cwd));
|
|
210
|
+
return applyTemperatureToProviderPayload(event.payload, temperature);
|
|
211
|
+
});
|
|
212
|
+
api.on("model_select", async (_event, ctx) => {
|
|
213
|
+
const model = ctx.model;
|
|
214
|
+
if (!model) return;
|
|
215
|
+
const config = readLlmConfig(ctx.cwd);
|
|
216
|
+
writeLlmConfig(ctx.cwd, {
|
|
217
|
+
...config,
|
|
218
|
+
defaultProvider: model.provider,
|
|
219
|
+
defaultModel: model.id,
|
|
202
220
|
});
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
221
|
+
});
|
|
222
|
+
api.on("thinking_level_select", async (_event, ctx) => {
|
|
223
|
+
const config = readLlmConfig(ctx.cwd);
|
|
224
|
+
writeLlmConfig(ctx.cwd, {
|
|
225
|
+
...config,
|
|
226
|
+
defaultThinkingLevel: api.getThinkingLevel(),
|
|
209
227
|
});
|
|
228
|
+
});
|
|
210
229
|
}
|
|
211
|
-
//# sourceMappingURL=kubbisec-llm-config.extension.js.map
|
|
230
|
+
//# sourceMappingURL=kubbisec-llm-config.extension.js.map
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
type ExtensionApi = {
|
|
2
|
-
|
|
2
|
+
on: (
|
|
3
|
+
event: string,
|
|
4
|
+
handler: (event: unknown, ctx: ExtensionContext) => undefined | Promise<unknown>,
|
|
5
|
+
) => void;
|
|
3
6
|
};
|
|
4
7
|
type ExtensionContext = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
hasUI: boolean;
|
|
9
|
+
ui: {
|
|
10
|
+
setStatus: (key: string, text: string | undefined) => void;
|
|
11
|
+
};
|
|
9
12
|
};
|
|
10
13
|
export default function kubbisecMemory(api: ExtensionApi): void;
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=kubbisec-memory.extension.d.ts.map
|
|
14
|
+
//# sourceMappingURL=kubbisec-memory.extension.d.ts.map
|
|
@@ -1,107 +1,100 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* KubbiSec memory extension — recall before turn, remember after turn.
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
addChatMemoryTurn,
|
|
6
|
+
buildMemoryInjectBlock,
|
|
7
|
+
extractRememberCandidates,
|
|
8
|
+
isMemoryEnabled,
|
|
9
|
+
searchChatMemory,
|
|
10
|
+
} from "@kubbisec/chat-memory";
|
|
11
|
+
|
|
5
12
|
function resolveMemoryScope() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
};
|
|
13
|
+
const organizationId = process.env.KUBBISEC_ORG_ID?.trim();
|
|
14
|
+
const userId = process.env.KUBBISEC_USER_ID?.trim() ?? process.env.KUBBISEC_CLIENT_ID?.trim();
|
|
15
|
+
if (!organizationId || !userId) return null;
|
|
16
|
+
const projectId = process.env.KUBBISEC_PROJECT_ID?.trim();
|
|
17
|
+
return {
|
|
18
|
+
organizationId,
|
|
19
|
+
userId,
|
|
20
|
+
...(projectId ? { projectId } : {}),
|
|
21
|
+
};
|
|
16
22
|
}
|
|
17
23
|
function extractTextContent(content) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
.map((block) => block.text ?? "")
|
|
26
|
-
.join("\n");
|
|
24
|
+
if (typeof content === "string") return content;
|
|
25
|
+
if (!Array.isArray(content)) return "";
|
|
26
|
+
return content
|
|
27
|
+
.filter((block) => typeof block === "object" && block !== null)
|
|
28
|
+
.filter((block) => block.type === "text" && typeof block.text === "string")
|
|
29
|
+
.map((block) => block.text ?? "")
|
|
30
|
+
.join("\n");
|
|
27
31
|
}
|
|
28
32
|
function lastUserMessage(messages) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
33
|
+
for (let i = messages.length - 1; i >= 0; i -= 1) {
|
|
34
|
+
const msg = messages[i];
|
|
35
|
+
if (msg?.role === "user") {
|
|
36
|
+
return extractTextContent(msg.content);
|
|
34
37
|
}
|
|
35
|
-
|
|
38
|
+
}
|
|
39
|
+
return "";
|
|
36
40
|
}
|
|
37
41
|
export default function kubbisecMemory(api) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const agentEnd = event;
|
|
96
|
-
const userText = lastUserMessage(agentEnd.messages);
|
|
97
|
-
const assistantMsg = [...agentEnd.messages].reverse().find((m) => m.role === "assistant");
|
|
98
|
-
const assistantText = assistantMsg ? extractTextContent(assistantMsg.content) : "";
|
|
99
|
-
if (!userText || userText.length < 20)
|
|
100
|
-
return;
|
|
101
|
-
const candidates = extractRememberCandidates(userText, assistantText);
|
|
102
|
-
for (const candidate of candidates) {
|
|
103
|
-
await addChatMemoryTurn(scope, candidate);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
42
|
+
let lastUserPrompt = "";
|
|
43
|
+
api.on("before_agent_start", async (event) => {
|
|
44
|
+
if (!isMemoryEnabled()) return undefined;
|
|
45
|
+
const scope = resolveMemoryScope();
|
|
46
|
+
if (!scope) return undefined;
|
|
47
|
+
const { prompt } = event;
|
|
48
|
+
lastUserPrompt = prompt;
|
|
49
|
+
try {
|
|
50
|
+
const memories = await Promise.race([
|
|
51
|
+
searchChatMemory(scope, prompt, 5),
|
|
52
|
+
new Promise((_, reject) => {
|
|
53
|
+
setTimeout(() => reject(new Error("recall_timeout")), 3000);
|
|
54
|
+
}),
|
|
55
|
+
]);
|
|
56
|
+
const block = buildMemoryInjectBlock(memories);
|
|
57
|
+
if (!block) return undefined;
|
|
58
|
+
return {
|
|
59
|
+
message: {
|
|
60
|
+
customType: "kubbisec-memory-inject",
|
|
61
|
+
content: block,
|
|
62
|
+
display: false,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
} catch {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
api.on("turn_end", async (event, ctx) => {
|
|
70
|
+
if (!isMemoryEnabled()) return;
|
|
71
|
+
if (!lastUserPrompt || lastUserPrompt.length < 20) return;
|
|
72
|
+
const scope = resolveMemoryScope();
|
|
73
|
+
if (!scope) return;
|
|
74
|
+
const turn = event;
|
|
75
|
+
if (turn.message.role !== "assistant") return;
|
|
76
|
+
const assistantText = extractTextContent(turn.message.content);
|
|
77
|
+
const candidates = extractRememberCandidates(lastUserPrompt, assistantText);
|
|
78
|
+
for (const candidate of candidates) {
|
|
79
|
+
await addChatMemoryTurn(scope, candidate);
|
|
80
|
+
}
|
|
81
|
+
if (ctx.hasUI && candidates.length > 0) {
|
|
82
|
+
ctx.ui.setStatus("kubbisec-memory", `memory · ${candidates.length}`);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
api.on("agent_end", async (event) => {
|
|
86
|
+
if (!isMemoryEnabled()) return;
|
|
87
|
+
const scope = resolveMemoryScope();
|
|
88
|
+
if (!scope) return;
|
|
89
|
+
const agentEnd = event;
|
|
90
|
+
const userText = lastUserMessage(agentEnd.messages);
|
|
91
|
+
const assistantMsg = [...agentEnd.messages].reverse().find((m) => m.role === "assistant");
|
|
92
|
+
const assistantText = assistantMsg ? extractTextContent(assistantMsg.content) : "";
|
|
93
|
+
if (!userText || userText.length < 20) return;
|
|
94
|
+
const candidates = extractRememberCandidates(userText, assistantText);
|
|
95
|
+
for (const candidate of candidates) {
|
|
96
|
+
await addChatMemoryTurn(scope, candidate);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
106
99
|
}
|
|
107
|
-
//# sourceMappingURL=kubbisec-memory.extension.js.map
|
|
100
|
+
//# sourceMappingURL=kubbisec-memory.extension.js.map
|