@qvac/harness 0.8.13 → 0.8.15
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/CHANGELOG.md +31 -1
- package/dist-lib/index.js +2 -1
- package/dist-lib/lib/capabilities/completion.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion.js +101 -58
- package/dist-lib/lib/capabilities/tool-turns.d.ts +1 -0
- package/dist-lib/lib/capabilities/tool-turns.js +14 -3
- package/dist-lib/lib/models/model-pool.js +1 -2
- package/dist-lib/lib/prompt.d.ts +4 -2
- package/dist-lib/lib/prompt.js +16 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,28 @@ While the major version is `0`, a breaking change bumps the minor version.
|
|
|
8
8
|
|
|
9
9
|
## [Unreleased]
|
|
10
10
|
|
|
11
|
+
## [0.8.15] - 2026-11-02
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- Android CPU LLM loads no longer restrict later embedding loads to the LLM's
|
|
16
|
+
selected cores, preventing severe knowledge-indexing slowdowns. The LLM
|
|
17
|
+
thread count is unchanged. (#753)
|
|
18
|
+
|
|
19
|
+
## [0.8.14] - 2026-10-26
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- A skill picked with `@` that cannot serve the request, or whose input is not
|
|
24
|
+
in the chat, now makes the model say so in one sentence instead of calling
|
|
25
|
+
tools to force it. (#643)
|
|
26
|
+
- A loaded skill's body reaches the model as text, not one JSON-escaped line,
|
|
27
|
+
so small models no longer copy `\"` into Mermaid blocks they write. (#639)
|
|
28
|
+
- An enabled skill that is `disconnected` or `needs-setup` stays listed with
|
|
29
|
+
its remedy, and an `@mention` or load of it returns that remedy, so the agent
|
|
30
|
+
tells the user to reconnect instead of improvising. The system prompt names
|
|
31
|
+
the host OS. (#638)
|
|
32
|
+
|
|
11
33
|
## [0.8.13] - 2026-10-23
|
|
12
34
|
|
|
13
35
|
### Added
|
|
@@ -40,6 +62,12 @@ While the major version is `0`, a breaking change bumps the minor version.
|
|
|
40
62
|
|
|
41
63
|
### Fixed
|
|
42
64
|
|
|
65
|
+
- A loaded skill's body reaches the model as text under its `[Tool: skill …]`
|
|
66
|
+
header, with only `name` and `file` on the JSON line, instead of stringified
|
|
67
|
+
whole. Qwen3.5-4B copied the escaped quotes of `A[\"First step\"]` into its
|
|
68
|
+
own Mermaid block, which the app then could not render (QVAC-24502). Turns
|
|
69
|
+
an older harness stringified whole still read as loaded; an existing chat
|
|
70
|
+
with a replayed skill stub re-reads once after the update.
|
|
43
71
|
- The wrap-up round a run ends on after blocked repeats keeps the tool block in
|
|
44
72
|
the prompt and forbids a call with `tool_choice: "none"`, instead of dropping
|
|
45
73
|
the block. Under `@qvac/sdk` 0.22 the dropped block rewrote the chat's one
|
|
@@ -2214,7 +2242,9 @@ Install 0.2.12 or later to get them.
|
|
|
2214
2242
|
- Every dependency installs from the public npm registry: GPU stats are read
|
|
2215
2243
|
through `bare-gpu-info`. (#12)
|
|
2216
2244
|
|
|
2217
|
-
[Unreleased]: https://github.com/tetherto/qvac-harness/compare/v0.8.
|
|
2245
|
+
[Unreleased]: https://github.com/tetherto/qvac-harness/compare/v0.8.15...HEAD
|
|
2246
|
+
[0.8.15]: https://github.com/tetherto/qvac-harness/compare/v0.8.14...v0.8.15
|
|
2247
|
+
[0.8.14]: https://github.com/tetherto/qvac-harness/compare/v0.8.13...v0.8.14
|
|
2218
2248
|
[0.8.13]: https://github.com/tetherto/qvac-harness/compare/v0.8.12...v0.8.13
|
|
2219
2249
|
[0.8.12]: https://github.com/tetherto/qvac-harness/compare/v0.8.11...v0.8.12
|
|
2220
2250
|
[0.8.11]: https://github.com/tetherto/qvac-harness/compare/v0.8.10...v0.8.11
|
package/dist-lib/index.js
CHANGED
|
@@ -336,6 +336,7 @@ interface CompletionArgs {
|
|
|
336
336
|
fsRoots?: readonly DriveRoot[];
|
|
337
337
|
fsWriteRoots?: readonly DriveRoot[];
|
|
338
338
|
captureInferenceCalls?: boolean;
|
|
339
|
+
platform?: string;
|
|
339
340
|
}
|
|
340
341
|
export { CONTEXT_OVERFLOW_MESSAGE } from '../errors.ts';
|
|
341
342
|
export declare function trustedSourcesFrom(history: readonly Message[]): TrustedSource[];
|
|
@@ -344,4 +345,4 @@ export declare function toSdkTool(tool: ToolDefinition): SdkTool;
|
|
|
344
345
|
export type CompletionSkillEntry = SkillCatalogEntry & {
|
|
345
346
|
readonly status?: SkillState;
|
|
346
347
|
};
|
|
347
|
-
export declare function completion(sdk: CompletionSdk, { modelId, acquireRound, model, agent, ctxSize, cacheKey, session, thinkingDefault, canThink, generationParams: generationParamsOverride, responseFormat, messages: storedMessages, typedText, tools: allTools, skillCatalog, approve, attach, fetchAttachment, ragSearch, progress, askUser, signal, toolConfigs, fsRoots, fsWriteRoots, captureInferenceCalls }: CompletionArgs): AsyncGenerator<CompletionEvent>;
|
|
348
|
+
export declare function completion(sdk: CompletionSdk, { modelId, acquireRound, model, agent, ctxSize, cacheKey, session, thinkingDefault, canThink, generationParams: generationParamsOverride, responseFormat, messages: storedMessages, typedText, tools: allTools, skillCatalog, approve, attach, fetchAttachment, ragSearch, progress, askUser, signal, toolConfigs, fsRoots, fsWriteRoots, captureInferenceCalls, platform }: CompletionArgs): AsyncGenerator<CompletionEvent>;
|
|
@@ -27,14 +27,14 @@ import { executeToolSearch, loadedToolNames, renderedTools, TOOL_SEARCH_NAME } f
|
|
|
27
27
|
import { promptUsageParts, usageBreakdown } from './usage-breakdown.js';
|
|
28
28
|
import { collectToolGrants, enabledTools, isSelected, skillIsActive, skillsAreSelected } from './tool-selection.js';
|
|
29
29
|
import { guardToolCall } from '../tools/outbound-guard.js';
|
|
30
|
-
import { isAvailableState } from '../tools/skills/skill-state-constants.js';
|
|
31
|
-
import { resolveImplicitSkill, resolveSkillMention } from '../tools/skills/mention.js';
|
|
30
|
+
import { isAvailableState, SKILL_STATE } from '../tools/skills/skill-state-constants.js';
|
|
31
|
+
import { resolveImplicitSkill, resolveSkillMention, skillMentionHandle } from '../tools/skills/mention.js';
|
|
32
32
|
import { parseToolGrant } from '../tools/skills/tool-grants.js';
|
|
33
33
|
import { NETWORK_TOOLSETS, permittedTools } from '../tools/toolsets.js';
|
|
34
34
|
import { promptPrefixHash } from './prompt-prefix.js';
|
|
35
35
|
import { logToolPrompt } from './tool-prompt-log.js';
|
|
36
36
|
import { responseRoomChars } from '../tools/http-request/truncate-response.js';
|
|
37
|
-
import { DIRECT_CALL_ID, deliversFile, FILE_DELIVERED_NUDGE, loadedSkillFilesFrom, loadedSkillsFrom, TOOL_CONTINUATION_NUDGE, toolResultTurn } from './tool-turns.js';
|
|
37
|
+
import { DIRECT_CALL_ID, deliversFile, FILE_DELIVERED_NUDGE, loadedSkillFilesFrom, loadedSkillsFrom, skillMentionNudge, TOOL_CONTINUATION_NUDGE, toolResultTurn } from './tool-turns.js';
|
|
38
38
|
export function imageSettingsFrom(agent) {
|
|
39
39
|
if (!agent)
|
|
40
40
|
return undefined;
|
|
@@ -154,12 +154,13 @@ function explicitlyDisablesWebSearch(text) {
|
|
|
154
154
|
return (/\b(?:do\s+not|don't|dont|never)\s+(?:search|browse|look\s+up|find|use)\s+(?:the\s+)?(?:web|internet|online)\b/i.test(text) ||
|
|
155
155
|
/\b(?:avoid|without)\s+(?:searching|browsing|using)\s+(?:the\s+)?(?:web|internet|online)\b/i.test(text));
|
|
156
156
|
}
|
|
157
|
-
function directToolHistory(history, call, output) {
|
|
157
|
+
function directToolHistory(history, { call, output, loads = [], nudge = TOOL_CONTINUATION_NUDGE }) {
|
|
158
158
|
return [
|
|
159
159
|
...history,
|
|
160
160
|
{ role: 'assistant', content: toolCallMarkup([call]) },
|
|
161
161
|
{ role: 'tool', content: toolResultTurn(call.name, DIRECT_CALL_ID, output) },
|
|
162
|
-
|
|
162
|
+
...loads,
|
|
163
|
+
{ role: 'user', content: nudge }
|
|
163
164
|
];
|
|
164
165
|
}
|
|
165
166
|
function assistantToolTurn(contentText, calls) {
|
|
@@ -415,6 +416,33 @@ function unreadySkillState(name, catalog) {
|
|
|
415
416
|
const status = catalog.find((entry) => entry.name === name)?.status;
|
|
416
417
|
return status !== undefined && !isAvailableState(status) ? status : null;
|
|
417
418
|
}
|
|
419
|
+
const FIXABLE_STATES = new Set([
|
|
420
|
+
SKILL_STATE.disconnected,
|
|
421
|
+
SKILL_STATE.needsSetup
|
|
422
|
+
]);
|
|
423
|
+
function fixableInSkills(entry) {
|
|
424
|
+
return entry.status !== undefined && FIXABLE_STATES.has(entry.status);
|
|
425
|
+
}
|
|
426
|
+
function unreadyRemedy(state) {
|
|
427
|
+
if (state === SKILL_STATE.disconnected)
|
|
428
|
+
return 'reconnect it in Skills';
|
|
429
|
+
if (state === SKILL_STATE.needsSetup)
|
|
430
|
+
return 'set it up in Skills';
|
|
431
|
+
return 'open it in Skills to see what it needs';
|
|
432
|
+
}
|
|
433
|
+
function promptSkill(entry) {
|
|
434
|
+
const state = skillInContext(entry) ? undefined : entry.status;
|
|
435
|
+
return {
|
|
436
|
+
name: entry.name,
|
|
437
|
+
description: entry.description,
|
|
438
|
+
note: state ? `${state} — tell the user to ${unreadyRemedy(state)}` : undefined
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
function unreadyCall(name, state) {
|
|
442
|
+
const reason = `skill "${name}" is ${state} and cannot be used yet. Tell the user to ${unreadyRemedy(state)}, ` +
|
|
443
|
+
`and do not do this task with another tool.`;
|
|
444
|
+
return blockedResult({ error: reason }, reason);
|
|
445
|
+
}
|
|
418
446
|
function blockedSkillMessage(name, catalog, listShown) {
|
|
419
447
|
if (catalog.some((entry) => entry.name === name)) {
|
|
420
448
|
return (`skill "${name}" is not enabled for this agent. Do not rebuild what it does with another ` +
|
|
@@ -735,7 +763,7 @@ function* reportUnnamedWrites(said, landed) {
|
|
|
735
763
|
yield { type: 'content', text: unreported };
|
|
736
764
|
}
|
|
737
765
|
}
|
|
738
|
-
export async function* completion(sdk, { modelId, acquireRound, model, agent, ctxSize, cacheKey, session, thinkingDefault, canThink, generationParams: generationParamsOverride, responseFormat, messages: storedMessages, typedText, tools: allTools = [], skillCatalog = [], approve, attach, fetchAttachment, ragSearch, progress, askUser, signal, toolConfigs, fsRoots = [], fsWriteRoots = [], captureInferenceCalls = false }) {
|
|
766
|
+
export async function* completion(sdk, { modelId, acquireRound, model, agent, ctxSize, cacheKey, session, thinkingDefault, canThink, generationParams: generationParamsOverride, responseFormat, messages: storedMessages, typedText, tools: allTools = [], skillCatalog = [], approve, attach, fetchAttachment, ragSearch, progress, askUser, signal, toolConfigs, fsRoots = [], fsWriteRoots = [], captureInferenceCalls = false, platform }) {
|
|
739
767
|
const pipeline = new HookPipeline();
|
|
740
768
|
const agentId = agent?.id ?? null;
|
|
741
769
|
const disabledToolsets = agent?.sandboxMode
|
|
@@ -775,15 +803,19 @@ export async function* completion(sdk, { modelId, acquireRound, model, agent, ct
|
|
|
775
803
|
const turnImages = lastUserImages(messages);
|
|
776
804
|
const toolsSelected = isSelected(agent?.toolsScope, agent?.enabledTools);
|
|
777
805
|
const skillsSelected = skillsAreSelected(agent?.skillsScope, Boolean(agent));
|
|
778
|
-
const inContextSkills = skillCatalog.filter(skillInContext);
|
|
779
806
|
const loadedSkills = loadedSkillsFrom(messages);
|
|
780
807
|
const loadedSkillFiles = loadedSkillFilesFrom(messages);
|
|
781
808
|
const activation = {
|
|
782
809
|
skillsSelected,
|
|
783
810
|
enabledSkills: agent?.enabledSkills ?? []
|
|
784
811
|
};
|
|
785
|
-
const
|
|
786
|
-
|
|
812
|
+
const listedSkills = skillCatalog.filter((skill) => skillIsActive(skill.name, activation) &&
|
|
813
|
+
(skillInContext(skill) || (skillsSelected && fixableInSkills(skill))));
|
|
814
|
+
const activeSkills = listedSkills.filter(skillInContext);
|
|
815
|
+
const unreadySkills = listedSkills.filter((skill) => !skillInContext(skill));
|
|
816
|
+
const inContextSkills = [...skillCatalog.filter(skillInContext), ...unreadySkills];
|
|
817
|
+
const spendsCredentials = (name) => skillIsActive(name, activation) && !unreadySkillState(name, skillCatalog);
|
|
818
|
+
const mention = resolveSkillMention(userText, listedSkills);
|
|
787
819
|
const { grantedNames, grantedOwners, grantedOps } = collectToolGrants(activeSkills);
|
|
788
820
|
function selectEnabled(offered = false) {
|
|
789
821
|
if (responseFormat)
|
|
@@ -797,7 +829,7 @@ export async function* completion(sdk, { modelId, acquireRound, model, agent, ct
|
|
|
797
829
|
loadedGrantedNames: offered ? grantedNames : collectToolGrants(loaded).grantedNames,
|
|
798
830
|
hasRoots: fsRoots.length > 0,
|
|
799
831
|
hasWriteRoots: writableRoots.length > 0,
|
|
800
|
-
hasActiveSkills:
|
|
832
|
+
hasActiveSkills: listedSkills.length > 0,
|
|
801
833
|
capabilityProfile: model ? modelNameToCapabilityProfile(model) : undefined
|
|
802
834
|
});
|
|
803
835
|
}
|
|
@@ -847,46 +879,51 @@ export async function* completion(sdk, { modelId, acquireRound, model, agent, ct
|
|
|
847
879
|
let preloadedSkill = null;
|
|
848
880
|
let preloadedResult = null;
|
|
849
881
|
const preload = mention ?? resolveImplicitSkill(userText, activeSkills);
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
const
|
|
882
|
+
const loader = tools.find((tool) => tool.name === SKILL_TOOL_NAME);
|
|
883
|
+
if (preload && loader) {
|
|
884
|
+
const preloadState = unreadySkillState(preload.name, skillCatalog);
|
|
885
|
+
const loaded = preloadState
|
|
886
|
+
? null
|
|
887
|
+
: await loader.execute({ name: preload.name }, toolContext());
|
|
853
888
|
if (loaded && typeof loaded === 'object' && 'content' in loaded) {
|
|
854
889
|
preloadedSkill = String(loaded.content);
|
|
855
890
|
preloadedResult = loaded;
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
891
|
+
}
|
|
892
|
+
if (preloadState || (preloadedSkill !== null && !loadedSkills.has(preload.name))) {
|
|
893
|
+
const preloadArgs = { name: preload.name };
|
|
894
|
+
const preloadEffect = 'read';
|
|
895
|
+
const preloadResource = loader.resource?.(preloadArgs) ?? null;
|
|
896
|
+
yield {
|
|
897
|
+
type: 'tool-call',
|
|
898
|
+
name: SKILL_TOOL_NAME,
|
|
899
|
+
args: preloadArgs,
|
|
900
|
+
effect: preloadEffect,
|
|
901
|
+
display: labelOf(SKILL_TOOL_NAME, preloadArgs, skillEmoji(preload.name))
|
|
902
|
+
};
|
|
903
|
+
yield {
|
|
904
|
+
type: 'tool-activity',
|
|
905
|
+
name: SKILL_TOOL_NAME,
|
|
906
|
+
args: { name: preload.name },
|
|
907
|
+
resource: null,
|
|
908
|
+
effect: 'read',
|
|
909
|
+
decision: preloadState ? 'blocked' : 'auto'
|
|
910
|
+
};
|
|
911
|
+
const settled = await settleToolCall(pipeline, preloadState
|
|
912
|
+
? unreadyCall(preload.name, preloadState)
|
|
913
|
+
: executedCall(loaded, { kind: 'success' }), {
|
|
914
|
+
agentId,
|
|
915
|
+
tool: loader,
|
|
916
|
+
name: SKILL_TOOL_NAME,
|
|
917
|
+
args: preloadArgs,
|
|
918
|
+
effect: preloadEffect,
|
|
919
|
+
resource: preloadResource
|
|
920
|
+
});
|
|
921
|
+
preloadedResult = settled.result;
|
|
922
|
+
yield {
|
|
923
|
+
type: 'tool-result',
|
|
924
|
+
name: SKILL_TOOL_NAME,
|
|
925
|
+
result: settled.result
|
|
926
|
+
};
|
|
890
927
|
}
|
|
891
928
|
}
|
|
892
929
|
if (preload && preloadedSkill) {
|
|
@@ -900,7 +937,8 @@ export async function* completion(sdk, { modelId, acquireRound, model, agent, ct
|
|
|
900
937
|
const system = systemPromptParts({
|
|
901
938
|
bio: agent?.bio,
|
|
902
939
|
toolNames: enabled.map((tool) => tool.name),
|
|
903
|
-
skillsSection: skillsPromptSection(
|
|
940
|
+
skillsSection: skillsPromptSection(listedSkills.map(promptSkill)),
|
|
941
|
+
platform
|
|
904
942
|
});
|
|
905
943
|
const systemContent = system.text;
|
|
906
944
|
const promptPrefix = promptPrefixHash({ system: systemContent, tools: sdkTools });
|
|
@@ -925,9 +963,13 @@ export async function* completion(sdk, { modelId, acquireRound, model, agent, ct
|
|
|
925
963
|
}
|
|
926
964
|
logSelection();
|
|
927
965
|
let history = annotateUserTimes(systemContent ? [{ role: 'system', content: systemContent }, ...messages] : messages);
|
|
928
|
-
if (preload &&
|
|
929
|
-
history = directToolHistory(history, {
|
|
930
|
-
|
|
966
|
+
if (preload && preloadedResult !== null) {
|
|
967
|
+
history = directToolHistory(history, {
|
|
968
|
+
call: { name: SKILL_TOOL_NAME, arguments: { name: preload.name } },
|
|
969
|
+
output: preloadedResult,
|
|
970
|
+
loads: preloadedSkill !== null ? skillToolLoads(preload.name, history) : [],
|
|
971
|
+
nudge: mention ? skillMentionNudge(skillMentionHandle(mention)) : undefined
|
|
972
|
+
});
|
|
931
973
|
}
|
|
932
974
|
let roundCacheKey = cacheKey;
|
|
933
975
|
const runUsage = () => usageBreakdown(promptParts, stats.cacheTokens, model);
|
|
@@ -938,7 +980,7 @@ export async function* completion(sdk, { modelId, acquireRound, model, agent, ct
|
|
|
938
980
|
let webSearches = 0;
|
|
939
981
|
const sources = trustedSourcesFrom(history);
|
|
940
982
|
const query = explicitWebSearchQuery(userText, enabled, {
|
|
941
|
-
skillPreloaded:
|
|
983
|
+
skillPreloaded: preloadedResult !== null
|
|
942
984
|
});
|
|
943
985
|
const webSearch = enabled.find((tool) => tool.name === WEB_SEARCH_TOOL_NAME);
|
|
944
986
|
if (query && webSearch) {
|
|
@@ -1013,7 +1055,10 @@ export async function* completion(sdk, { modelId, acquireRound, model, agent, ct
|
|
|
1013
1055
|
name: webSearch.name,
|
|
1014
1056
|
result: output
|
|
1015
1057
|
};
|
|
1016
|
-
history = directToolHistory(history, {
|
|
1058
|
+
history = directToolHistory(history, {
|
|
1059
|
+
call: { name: webSearch.name, arguments: args },
|
|
1060
|
+
output
|
|
1061
|
+
});
|
|
1017
1062
|
}
|
|
1018
1063
|
let outcome = 'exhausted';
|
|
1019
1064
|
let said = '';
|
|
@@ -1176,7 +1221,7 @@ export async function* completion(sdk, { modelId, acquireRound, model, agent, ct
|
|
|
1176
1221
|
const searchCapped = tool?.name === WEB_SEARCH_TOOL_NAME && webSearches >= MAX_WEB_SEARCHES_PER_TURN;
|
|
1177
1222
|
const callCtx = {
|
|
1178
1223
|
...toolContext(turnImages, ctxSize),
|
|
1179
|
-
skills: [...loadedSkills].filter(
|
|
1224
|
+
skills: [...loadedSkills].filter(spendsCredentials),
|
|
1180
1225
|
skillsLoadedThisTurn: [...loadedThisTurn],
|
|
1181
1226
|
settings: toolConfigs?.[call.name],
|
|
1182
1227
|
toolOps: grantedOps,
|
|
@@ -1208,9 +1253,7 @@ export async function* completion(sdk, { modelId, acquireRound, model, agent, ct
|
|
|
1208
1253
|
const unreadyState = skillCall ? unreadySkillState(skillName, skillCatalog) : null;
|
|
1209
1254
|
const skillBlocked = skillCall && !unreadyState && (!tool || !skillIsActive(skillName, activation));
|
|
1210
1255
|
let activity = null;
|
|
1211
|
-
const blockedReason = blockedSkillMessage(skillName, skillCatalog,
|
|
1212
|
-
const unreadyReason = `skill "${skillName}" is ${unreadyState ?? 'unavailable'} and cannot be used yet. ` +
|
|
1213
|
-
`Tell the user to open it in Skills and finish its setup; do not retry.`;
|
|
1256
|
+
const blockedReason = blockedSkillMessage(skillName, skillCatalog, listedSkills.length > 0);
|
|
1214
1257
|
let execution;
|
|
1215
1258
|
if (priorFailure) {
|
|
1216
1259
|
blockedRepeats++;
|
|
@@ -1239,7 +1282,7 @@ export async function* completion(sdk, { modelId, acquireRound, model, agent, ct
|
|
|
1239
1282
|
execution = blockedResult({ error: blockedReason }, blockedReason);
|
|
1240
1283
|
}
|
|
1241
1284
|
else if (unreadyState) {
|
|
1242
|
-
execution =
|
|
1285
|
+
execution = unreadyCall(skillName, unreadyState);
|
|
1243
1286
|
}
|
|
1244
1287
|
else if (searchCapped) {
|
|
1245
1288
|
execution = terminalCall({ content: WEB_SEARCH_LIMIT_MESSAGE }, { kind: 'success' }, { executed: false });
|
|
@@ -2,6 +2,7 @@ import type { Message } from './completion.ts';
|
|
|
2
2
|
export declare const DIRECT_CALL_ID = "call-direct";
|
|
3
3
|
export declare const TOOL_CONTINUATION_NUDGE = "[Tool results above. Continue the user's request: call the next tool, or answer.]";
|
|
4
4
|
export declare const FILE_DELIVERED_NUDGE = "[Tool results above. The file is attached to the chat and shown to the user. Answer now, unless the request still needs a file that is not made yet.]";
|
|
5
|
+
export declare function skillMentionNudge(handle: string): string;
|
|
5
6
|
export declare function isContinuationNudge(content: string): boolean;
|
|
6
7
|
export declare function deliversFile(output: unknown): boolean;
|
|
7
8
|
export declare function toolResultTurn(name: string, id: string, output: unknown): string;
|
|
@@ -3,14 +3,25 @@ import { SKILL_TOOL_NAME } from './tool-names.js';
|
|
|
3
3
|
export const DIRECT_CALL_ID = 'call-direct';
|
|
4
4
|
export const TOOL_CONTINUATION_NUDGE = "[Tool results above. Continue the user's request: call the next tool, or answer.]";
|
|
5
5
|
export const FILE_DELIVERED_NUDGE = '[Tool results above. The file is attached to the chat and shown to the user. Answer now, unless the request still needs a file that is not made yet.]';
|
|
6
|
+
const MENTION_NUDGE_PREFIX = '[Tool results above. The user picked @';
|
|
7
|
+
export function skillMentionNudge(handle) {
|
|
8
|
+
return `${MENTION_NUDGE_PREFIX}${handle} for this request. If @${handle} cannot do what they asked, or what it works on is not in this chat, call no tool: tell them in one sentence that @${handle} cannot do this, and why. Otherwise continue: call the next tool, or answer.]`;
|
|
9
|
+
}
|
|
6
10
|
export function isContinuationNudge(content) {
|
|
7
|
-
return content === TOOL_CONTINUATION_NUDGE ||
|
|
11
|
+
return (content === TOOL_CONTINUATION_NUDGE ||
|
|
12
|
+
content === FILE_DELIVERED_NUDGE ||
|
|
13
|
+
content.startsWith(MENTION_NUDGE_PREFIX));
|
|
8
14
|
}
|
|
9
15
|
export function deliversFile(output) {
|
|
10
16
|
return isRecord(output) && Array.isArray(output.attachments) && output.attachments.length > 0;
|
|
11
17
|
}
|
|
12
18
|
export function toolResultTurn(name, id, output) {
|
|
13
|
-
|
|
19
|
+
const header = `[Tool: ${name} (${id})]`;
|
|
20
|
+
if (name === SKILL_TOOL_NAME && isRecord(output) && typeof output.content === 'string') {
|
|
21
|
+
const { content, ...rest } = output;
|
|
22
|
+
return `${header}\n${JSON.stringify(historyPayload(rest))}\n\n${content}`;
|
|
23
|
+
}
|
|
24
|
+
return `${header}\n${JSON.stringify(historyPayload(output))}`;
|
|
14
25
|
}
|
|
15
26
|
export function skillLoadedTurn(name) {
|
|
16
27
|
return toolResultTurn(SKILL_TOOL_NAME, DIRECT_CALL_ID, {
|
|
@@ -87,7 +98,7 @@ function skillLoadPayload(turn) {
|
|
|
87
98
|
return null;
|
|
88
99
|
}
|
|
89
100
|
try {
|
|
90
|
-
const payload = JSON.parse(text.
|
|
101
|
+
const payload = JSON.parse(text.split('\n')[1] ?? '');
|
|
91
102
|
if (typeof payload !== 'object' || payload === null) {
|
|
92
103
|
return null;
|
|
93
104
|
}
|
|
@@ -389,8 +389,7 @@ export function createModelPool(loadSdk, notify, { deviceConfig = {}, loads = cr
|
|
|
389
389
|
gpu_layers: deviceConfig.gpuLayers,
|
|
390
390
|
'main-gpu': mainGpu,
|
|
391
391
|
openclCacheDir: openclCache || undefined,
|
|
392
|
-
threads: placement?.threads
|
|
393
|
-
'cpu-mask': placement?.mask
|
|
392
|
+
threads: placement?.threads
|
|
394
393
|
});
|
|
395
394
|
const pending = { key, model, modelSrc, modelType: 'llamacpp-completion' };
|
|
396
395
|
const ctxSize = resolved.ctxSize ||
|
package/dist-lib/lib/prompt.d.ts
CHANGED
|
@@ -9,16 +9,18 @@ export interface SystemPromptInput {
|
|
|
9
9
|
bio?: string | null | undefined;
|
|
10
10
|
toolNames?: ReadonlyArray<string>;
|
|
11
11
|
skillsSection?: string | null;
|
|
12
|
+
platform?: string | null | undefined;
|
|
12
13
|
}
|
|
13
14
|
export interface SystemPromptParts {
|
|
14
15
|
text: string;
|
|
15
16
|
bioChars: number;
|
|
16
17
|
skillsChars: number;
|
|
17
18
|
}
|
|
18
|
-
export declare function systemPromptParts({ bio, toolNames, skillsSection }: SystemPromptInput): SystemPromptParts;
|
|
19
|
+
export declare function systemPromptParts({ bio, toolNames, skillsSection, platform }: SystemPromptInput): SystemPromptParts;
|
|
19
20
|
export declare function buildSystemPrompt(input: SystemPromptInput): string;
|
|
20
21
|
export interface PromptSkill {
|
|
21
22
|
readonly name: string;
|
|
22
23
|
readonly description: string;
|
|
24
|
+
readonly note?: string | undefined;
|
|
23
25
|
}
|
|
24
|
-
export declare function skillsPromptSection(
|
|
26
|
+
export declare function skillsPromptSection(skills: ReadonlyArray<PromptSkill>): string | null;
|
package/dist-lib/lib/prompt.js
CHANGED
|
@@ -58,14 +58,23 @@ function buildGuidelines(active) {
|
|
|
58
58
|
}
|
|
59
59
|
return `**Guidelines:**\n${lines.map((line) => `- ${line}`).join('\n')}`;
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
const PLATFORM_LABELS = {
|
|
62
|
+
darwin: 'macOS',
|
|
63
|
+
linux: 'Linux',
|
|
64
|
+
win32: 'Windows',
|
|
65
|
+
ios: 'iOS',
|
|
66
|
+
android: 'Android'
|
|
67
|
+
};
|
|
68
|
+
export function systemPromptParts({ bio, toolNames = [], skillsSection, platform }) {
|
|
62
69
|
const active = new Set(toolNames);
|
|
63
70
|
const header = active.size
|
|
64
71
|
? 'You are a helpful AI assistant with access to tools.'
|
|
65
72
|
: 'You are a helpful AI assistant.';
|
|
66
73
|
const preamble = `${header}\n\n${METADATA_SECTION}`;
|
|
74
|
+
const label = platform ? PLATFORM_LABELS[platform] : undefined;
|
|
75
|
+
const host = label ? `You run on ${label}.` : null;
|
|
67
76
|
const skills = active.has('skill') ? skillsSection : null;
|
|
68
|
-
const text = [preamble, bio, skills, buildGuidelines(active)]
|
|
77
|
+
const text = [preamble, host, bio, skills, buildGuidelines(active)]
|
|
69
78
|
.filter((part) => Boolean(part))
|
|
70
79
|
.join('\n\n');
|
|
71
80
|
return { text, bioChars: (bio ?? '').length, skillsChars: (skills ?? '').length };
|
|
@@ -73,9 +82,11 @@ export function systemPromptParts({ bio, toolNames = [], skillsSection }) {
|
|
|
73
82
|
export function buildSystemPrompt(input) {
|
|
74
83
|
return systemPromptParts(input).text;
|
|
75
84
|
}
|
|
76
|
-
export function skillsPromptSection(
|
|
77
|
-
if (!
|
|
85
|
+
export function skillsPromptSection(skills) {
|
|
86
|
+
if (!skills.length)
|
|
78
87
|
return null;
|
|
79
|
-
const lines =
|
|
88
|
+
const lines = skills
|
|
89
|
+
.map((skill) => `- ${skill.name}: ${skill.description}${skill.note ? ` [${skill.note}]` : ''}`)
|
|
90
|
+
.join('\n');
|
|
80
91
|
return `Skills available this turn. You MUST call the \`skill\` tool with its name BEFORE using the capability it describes — load the skill first, then act.\n${lines}`;
|
|
81
92
|
}
|