@karmaniverous/jeeves-meta 0.13.7 → 0.13.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/cli/jeeves-meta/index.js +20 -7
- package/dist/index.js +20 -7
- package/package.json +1 -1
|
@@ -9275,17 +9275,20 @@ class GatewayExecutor {
|
|
|
9275
9275
|
}
|
|
9276
9276
|
}
|
|
9277
9277
|
/** Invoke a gateway tool via the /tools/invoke HTTP endpoint. */
|
|
9278
|
-
async invoke(tool, args) {
|
|
9278
|
+
async invoke(tool, args, sessionKey) {
|
|
9279
9279
|
const headers = {
|
|
9280
9280
|
'Content-Type': 'application/json',
|
|
9281
9281
|
};
|
|
9282
9282
|
if (this.apiKey) {
|
|
9283
9283
|
headers['Authorization'] = 'Bearer ' + this.apiKey;
|
|
9284
9284
|
}
|
|
9285
|
+
const body = { tool, args };
|
|
9286
|
+
if (sessionKey)
|
|
9287
|
+
body.sessionKey = sessionKey;
|
|
9285
9288
|
const res = await fetch(this.gatewayUrl + '/tools/invoke', {
|
|
9286
9289
|
method: 'POST',
|
|
9287
9290
|
headers,
|
|
9288
|
-
body: JSON.stringify(
|
|
9291
|
+
body: JSON.stringify(body),
|
|
9289
9292
|
});
|
|
9290
9293
|
if (!res.ok) {
|
|
9291
9294
|
const text = await res.text();
|
|
@@ -9298,12 +9301,12 @@ class GatewayExecutor {
|
|
|
9298
9301
|
return data;
|
|
9299
9302
|
}
|
|
9300
9303
|
/** Look up totalTokens for a session via sessions_list. */
|
|
9301
|
-
async getSessionTokens(sessionKey) {
|
|
9304
|
+
async getSessionTokens(sessionKey, invokeSessionKey) {
|
|
9302
9305
|
try {
|
|
9303
9306
|
const result = await this.invoke('sessions_list', {
|
|
9304
9307
|
limit: 20,
|
|
9305
9308
|
messageLimit: 0,
|
|
9306
|
-
});
|
|
9309
|
+
}, invokeSessionKey);
|
|
9307
9310
|
const sessions = (result.result?.details?.sessions ??
|
|
9308
9311
|
result.result?.sessions ??
|
|
9309
9312
|
[]);
|
|
@@ -9331,6 +9334,7 @@ class GatewayExecutor {
|
|
|
9331
9334
|
// Generate unique output path for file-based output
|
|
9332
9335
|
const outputId = randomUUID();
|
|
9333
9336
|
const outputPath = this.workspaceDir + '/output-' + outputId + '.json';
|
|
9337
|
+
const invokeSessionKey = 'agent:main:meta-invoke:' + outputId;
|
|
9334
9338
|
// Append file output instruction to the task
|
|
9335
9339
|
const taskWithOutput = task +
|
|
9336
9340
|
'\n\n## OUTPUT DELIVERY\n\n' +
|
|
@@ -9348,7 +9352,7 @@ class GatewayExecutor {
|
|
|
9348
9352
|
runTimeoutSeconds: timeoutSeconds,
|
|
9349
9353
|
...(options?.thinking ? { thinking: options.thinking } : {}),
|
|
9350
9354
|
...(options?.model ? { model: options.model } : {}),
|
|
9351
|
-
});
|
|
9355
|
+
}, invokeSessionKey);
|
|
9352
9356
|
const details = (spawnResult.result?.details ?? spawnResult.result);
|
|
9353
9357
|
const sessionKey = details?.childSessionKey ?? details?.sessionKey;
|
|
9354
9358
|
if (typeof sessionKey !== 'string' || !sessionKey) {
|
|
@@ -9368,7 +9372,7 @@ class GatewayExecutor {
|
|
|
9368
9372
|
sessionKey,
|
|
9369
9373
|
limit: 5,
|
|
9370
9374
|
includeTools: false,
|
|
9371
|
-
});
|
|
9375
|
+
}, invokeSessionKey);
|
|
9372
9376
|
const messages = historyResult.result?.details?.messages ??
|
|
9373
9377
|
historyResult.result?.messages ??
|
|
9374
9378
|
[];
|
|
@@ -9381,7 +9385,7 @@ class GatewayExecutor {
|
|
|
9381
9385
|
lastMsg.stopReason !== 'toolUse' &&
|
|
9382
9386
|
lastMsg.stopReason !== 'error') {
|
|
9383
9387
|
// Fetch token usage from session metadata
|
|
9384
|
-
const tokens = await this.getSessionTokens(sessionKey);
|
|
9388
|
+
const tokens = await this.getSessionTokens(sessionKey, invokeSessionKey);
|
|
9385
9389
|
// Read output from file (sub-agent wrote it via Write tool)
|
|
9386
9390
|
if (existsSync(outputPath)) {
|
|
9387
9391
|
try {
|
|
@@ -9848,6 +9852,8 @@ function appendSharedSections(sections, ctx, options) {
|
|
|
9848
9852
|
*/
|
|
9849
9853
|
function buildArchitectTask(ctx, meta, config) {
|
|
9850
9854
|
const sections = [
|
|
9855
|
+
`# jeeves-meta · ARCHITECT · ${ctx.path}`,
|
|
9856
|
+
'',
|
|
9851
9857
|
meta._architect ?? config.defaultArchitect ?? DEFAULT_ARCHITECT_PROMPT,
|
|
9852
9858
|
'',
|
|
9853
9859
|
'## SCOPE',
|
|
@@ -9878,6 +9884,8 @@ function buildArchitectTask(ctx, meta, config) {
|
|
|
9878
9884
|
*/
|
|
9879
9885
|
function buildBuilderTask(ctx, meta, config) {
|
|
9880
9886
|
const sections = [
|
|
9887
|
+
`# jeeves-meta · BUILDER · ${ctx.path}`,
|
|
9888
|
+
'',
|
|
9881
9889
|
'## TASK BRIEF (from Architect)',
|
|
9882
9890
|
meta._builder ?? '(No architect brief available)',
|
|
9883
9891
|
'',
|
|
@@ -9906,6 +9914,8 @@ function buildBuilderTask(ctx, meta, config) {
|
|
|
9906
9914
|
*/
|
|
9907
9915
|
function buildCriticTask(ctx, meta, config) {
|
|
9908
9916
|
const sections = [
|
|
9917
|
+
`# jeeves-meta · CRITIC · ${ctx.path}`,
|
|
9918
|
+
'',
|
|
9909
9919
|
meta._critic ?? config.defaultCritic ?? DEFAULT_CRITIC_PROMPT,
|
|
9910
9920
|
'',
|
|
9911
9921
|
'## SYNTHESIS TO EVALUATE',
|
|
@@ -10578,6 +10588,7 @@ async function synthesizeNode(node, currentMeta, config, executor, watcher, onPr
|
|
|
10578
10588
|
const architectResult = await executor.spawn(architectTask, {
|
|
10579
10589
|
thinking: config.thinking,
|
|
10580
10590
|
timeout: config.architectTimeout,
|
|
10591
|
+
label: 'meta-architect',
|
|
10581
10592
|
});
|
|
10582
10593
|
builderBrief = parseArchitectOutput(architectResult.output);
|
|
10583
10594
|
architectTokens = architectResult.tokens;
|
|
@@ -10626,6 +10637,7 @@ async function synthesizeNode(node, currentMeta, config, executor, watcher, onPr
|
|
|
10626
10637
|
const builderResult = await executor.spawn(builderTask, {
|
|
10627
10638
|
thinking: config.thinking,
|
|
10628
10639
|
timeout: config.builderTimeout,
|
|
10640
|
+
label: 'meta-builder',
|
|
10629
10641
|
});
|
|
10630
10642
|
builderOutput = parseBuilderOutput(builderResult.output);
|
|
10631
10643
|
builderTokens = builderResult.tokens;
|
|
@@ -10680,6 +10692,7 @@ async function synthesizeNode(node, currentMeta, config, executor, watcher, onPr
|
|
|
10680
10692
|
const criticResult = await executor.spawn(criticTask, {
|
|
10681
10693
|
thinking: config.thinking,
|
|
10682
10694
|
timeout: config.criticTimeout,
|
|
10695
|
+
label: 'meta-critic',
|
|
10683
10696
|
});
|
|
10684
10697
|
feedback = parseCriticOutput(criticResult.output);
|
|
10685
10698
|
criticTokens = criticResult.tokens;
|
package/dist/index.js
CHANGED
|
@@ -8994,17 +8994,20 @@ class GatewayExecutor {
|
|
|
8994
8994
|
}
|
|
8995
8995
|
}
|
|
8996
8996
|
/** Invoke a gateway tool via the /tools/invoke HTTP endpoint. */
|
|
8997
|
-
async invoke(tool, args) {
|
|
8997
|
+
async invoke(tool, args, sessionKey) {
|
|
8998
8998
|
const headers = {
|
|
8999
8999
|
'Content-Type': 'application/json',
|
|
9000
9000
|
};
|
|
9001
9001
|
if (this.apiKey) {
|
|
9002
9002
|
headers['Authorization'] = 'Bearer ' + this.apiKey;
|
|
9003
9003
|
}
|
|
9004
|
+
const body = { tool, args };
|
|
9005
|
+
if (sessionKey)
|
|
9006
|
+
body.sessionKey = sessionKey;
|
|
9004
9007
|
const res = await fetch(this.gatewayUrl + '/tools/invoke', {
|
|
9005
9008
|
method: 'POST',
|
|
9006
9009
|
headers,
|
|
9007
|
-
body: JSON.stringify(
|
|
9010
|
+
body: JSON.stringify(body),
|
|
9008
9011
|
});
|
|
9009
9012
|
if (!res.ok) {
|
|
9010
9013
|
const text = await res.text();
|
|
@@ -9017,12 +9020,12 @@ class GatewayExecutor {
|
|
|
9017
9020
|
return data;
|
|
9018
9021
|
}
|
|
9019
9022
|
/** Look up totalTokens for a session via sessions_list. */
|
|
9020
|
-
async getSessionTokens(sessionKey) {
|
|
9023
|
+
async getSessionTokens(sessionKey, invokeSessionKey) {
|
|
9021
9024
|
try {
|
|
9022
9025
|
const result = await this.invoke('sessions_list', {
|
|
9023
9026
|
limit: 20,
|
|
9024
9027
|
messageLimit: 0,
|
|
9025
|
-
});
|
|
9028
|
+
}, invokeSessionKey);
|
|
9026
9029
|
const sessions = (result.result?.details?.sessions ??
|
|
9027
9030
|
result.result?.sessions ??
|
|
9028
9031
|
[]);
|
|
@@ -9050,6 +9053,7 @@ class GatewayExecutor {
|
|
|
9050
9053
|
// Generate unique output path for file-based output
|
|
9051
9054
|
const outputId = randomUUID();
|
|
9052
9055
|
const outputPath = this.workspaceDir + '/output-' + outputId + '.json';
|
|
9056
|
+
const invokeSessionKey = 'agent:main:meta-invoke:' + outputId;
|
|
9053
9057
|
// Append file output instruction to the task
|
|
9054
9058
|
const taskWithOutput = task +
|
|
9055
9059
|
'\n\n## OUTPUT DELIVERY\n\n' +
|
|
@@ -9067,7 +9071,7 @@ class GatewayExecutor {
|
|
|
9067
9071
|
runTimeoutSeconds: timeoutSeconds,
|
|
9068
9072
|
...(options?.thinking ? { thinking: options.thinking } : {}),
|
|
9069
9073
|
...(options?.model ? { model: options.model } : {}),
|
|
9070
|
-
});
|
|
9074
|
+
}, invokeSessionKey);
|
|
9071
9075
|
const details = (spawnResult.result?.details ?? spawnResult.result);
|
|
9072
9076
|
const sessionKey = details?.childSessionKey ?? details?.sessionKey;
|
|
9073
9077
|
if (typeof sessionKey !== 'string' || !sessionKey) {
|
|
@@ -9087,7 +9091,7 @@ class GatewayExecutor {
|
|
|
9087
9091
|
sessionKey,
|
|
9088
9092
|
limit: 5,
|
|
9089
9093
|
includeTools: false,
|
|
9090
|
-
});
|
|
9094
|
+
}, invokeSessionKey);
|
|
9091
9095
|
const messages = historyResult.result?.details?.messages ??
|
|
9092
9096
|
historyResult.result?.messages ??
|
|
9093
9097
|
[];
|
|
@@ -9100,7 +9104,7 @@ class GatewayExecutor {
|
|
|
9100
9104
|
lastMsg.stopReason !== 'toolUse' &&
|
|
9101
9105
|
lastMsg.stopReason !== 'error') {
|
|
9102
9106
|
// Fetch token usage from session metadata
|
|
9103
|
-
const tokens = await this.getSessionTokens(sessionKey);
|
|
9107
|
+
const tokens = await this.getSessionTokens(sessionKey, invokeSessionKey);
|
|
9104
9108
|
// Read output from file (sub-agent wrote it via Write tool)
|
|
9105
9109
|
if (existsSync(outputPath)) {
|
|
9106
9110
|
try {
|
|
@@ -9379,6 +9383,8 @@ function appendSharedSections(sections, ctx, options) {
|
|
|
9379
9383
|
*/
|
|
9380
9384
|
function buildArchitectTask(ctx, meta, config) {
|
|
9381
9385
|
const sections = [
|
|
9386
|
+
`# jeeves-meta · ARCHITECT · ${ctx.path}`,
|
|
9387
|
+
'',
|
|
9382
9388
|
meta._architect ?? config.defaultArchitect ?? DEFAULT_ARCHITECT_PROMPT,
|
|
9383
9389
|
'',
|
|
9384
9390
|
'## SCOPE',
|
|
@@ -9409,6 +9415,8 @@ function buildArchitectTask(ctx, meta, config) {
|
|
|
9409
9415
|
*/
|
|
9410
9416
|
function buildBuilderTask(ctx, meta, config) {
|
|
9411
9417
|
const sections = [
|
|
9418
|
+
`# jeeves-meta · BUILDER · ${ctx.path}`,
|
|
9419
|
+
'',
|
|
9412
9420
|
'## TASK BRIEF (from Architect)',
|
|
9413
9421
|
meta._builder ?? '(No architect brief available)',
|
|
9414
9422
|
'',
|
|
@@ -9437,6 +9445,8 @@ function buildBuilderTask(ctx, meta, config) {
|
|
|
9437
9445
|
*/
|
|
9438
9446
|
function buildCriticTask(ctx, meta, config) {
|
|
9439
9447
|
const sections = [
|
|
9448
|
+
`# jeeves-meta · CRITIC · ${ctx.path}`,
|
|
9449
|
+
'',
|
|
9440
9450
|
meta._critic ?? config.defaultCritic ?? DEFAULT_CRITIC_PROMPT,
|
|
9441
9451
|
'',
|
|
9442
9452
|
'## SYNTHESIS TO EVALUATE',
|
|
@@ -10109,6 +10119,7 @@ async function synthesizeNode(node, currentMeta, config, executor, watcher, onPr
|
|
|
10109
10119
|
const architectResult = await executor.spawn(architectTask, {
|
|
10110
10120
|
thinking: config.thinking,
|
|
10111
10121
|
timeout: config.architectTimeout,
|
|
10122
|
+
label: 'meta-architect',
|
|
10112
10123
|
});
|
|
10113
10124
|
builderBrief = parseArchitectOutput(architectResult.output);
|
|
10114
10125
|
architectTokens = architectResult.tokens;
|
|
@@ -10157,6 +10168,7 @@ async function synthesizeNode(node, currentMeta, config, executor, watcher, onPr
|
|
|
10157
10168
|
const builderResult = await executor.spawn(builderTask, {
|
|
10158
10169
|
thinking: config.thinking,
|
|
10159
10170
|
timeout: config.builderTimeout,
|
|
10171
|
+
label: 'meta-builder',
|
|
10160
10172
|
});
|
|
10161
10173
|
builderOutput = parseBuilderOutput(builderResult.output);
|
|
10162
10174
|
builderTokens = builderResult.tokens;
|
|
@@ -10211,6 +10223,7 @@ async function synthesizeNode(node, currentMeta, config, executor, watcher, onPr
|
|
|
10211
10223
|
const criticResult = await executor.spawn(criticTask, {
|
|
10212
10224
|
thinking: config.thinking,
|
|
10213
10225
|
timeout: config.criticTimeout,
|
|
10226
|
+
label: 'meta-critic',
|
|
10214
10227
|
});
|
|
10215
10228
|
feedback = parseCriticOutput(criticResult.output);
|
|
10216
10229
|
criticTokens = criticResult.tokens;
|