@eddyskywalker/dsh-chatgpt-subscription 0.94.1 → 0.95.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/lib/client.js +203 -11
- package/lib/client.js.map +1 -1
- package/lib/codemode.js +1 -1
- package/lib/index.js +402 -71
- package/lib/{preset-sync-gvhSzmlr.js → preset-sync-6QI9tVA0.js} +1 -1
- package/lib/types/client/features/advisor/AdvisorModelOption.d.ts.map +1 -1
- package/lib/types/client/features/advisor/skin-effort-card.d.ts +65 -0
- package/lib/types/client/features/advisor/skin-effort-card.d.ts.map +1 -0
- package/lib/types/client/features/advisor/styles.d.ts.map +1 -1
- package/lib/types/compat.d.ts +1 -1
- package/lib/types/host/providers/claude-api/mapper.d.ts.map +1 -1
- package/lib/types/host/runtime/advisor/index.d.ts.map +1 -1
- package/lib/types/host/runtime/advisor/request.d.ts.map +1 -1
- package/lib/types/host/runtime/advisor/selection-store.d.ts +37 -6
- package/lib/types/host/runtime/advisor/selection-store.d.ts.map +1 -1
- package/lib/types/host/runtime/presets/agent-preset.d.ts +38 -0
- package/lib/types/host/runtime/presets/agent-preset.d.ts.map +1 -1
- package/lib/types/host/runtime/presets/preset-sync.d.ts.map +1 -1
- package/lib/types/host/runtime/presets/team-board-sweep.d.ts +50 -0
- package/lib/types/host/runtime/presets/team-board-sweep.d.ts.map +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/shared/advisor-contracts.d.ts +1 -1
- package/lib/types/shared/advisor-contracts.d.ts.map +1 -1
- package/package.json +19 -19
- package/presets/dispatch/agent.cordis.yml +1 -0
- package/presets/team/README.md +68 -0
- package/presets/team/agent.cordis.yml +422 -0
- package/presets/team/preset.yml +3 -0
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as resolveProgressUpdatesSettings, n as attachProgressSettings } from "./progress-updates-jiHnSAmz.js";
|
|
2
2
|
import { h as resolvePlanModePipelineEnabled, l as attachPlanModePipelineSettings } from "./plan-mode-pipeline-DQ8TM6mP.js";
|
|
3
|
-
import { a as PLUGIN_MESSAGE_SOURCE_KIND, c as formatToolUpdateNotice, d as midConversationUpdateToUserMessage, f as normalizeGenerateOptions, i as LlmError$1, l as leadingSystemEndIndex, n as installBundledPresets, o as extractSystemText, r as resolvesFromHere, s as formatMidConversationSystemReminder, u as midConversationSystemToUserMessage } from "./preset-sync-
|
|
3
|
+
import { a as PLUGIN_MESSAGE_SOURCE_KIND, c as formatToolUpdateNotice, d as midConversationUpdateToUserMessage, f as normalizeGenerateOptions, i as LlmError$1, l as leadingSystemEndIndex, n as installBundledPresets, o as extractSystemText, r as resolvesFromHere, s as formatMidConversationSystemReminder, u as midConversationSystemToUserMessage } from "./preset-sync-6QI9tVA0.js";
|
|
4
4
|
import { A as isDeepSeekV41Flash, B as estimateCodexPayloadTokens, C as isOpenModelSessionPrefixCacheProtected, D as matchOpenModelScope, E as matchOpenModelProfile, F as checkpointFromMetadata, G as shouldCompactCodexPayload, H as latestCodexCompaction, I as checkpointFromOutputItems, K as withCodexCompactionTrigger, L as codexCompactionReplayMetadata, M as isDeepSeekV41FlashSession, N as readScopeRoute, O as matchOpenModelSession, P as readSessionRoute, R as codexRemoteCompactionEnabled, S as isOpenModelPrefixCacheProtected, T as isStepOpenModel, U as noteCodexRemoteCompactionFailure, V as isCompactionItem, W as projectFreshCodexCompaction, _ as isKimiOpenModel, b as isMinimaxOpenModel, d as OPEN_MODEL_PROFILES, f as bareOpenModelId, g as isKimiK31OpenModel, h as isGlm5OpenModel, j as isDeepSeekV41FlashScope, k as DEEPSEEK_OFFICIAL_PROVIDERS, l as resolveSkipProviders, m as isGlm54OpenModel, n as DEFAULT_SKIP_PROVIDERS, p as isDeepSeekV4NonV41Model, r as PRUNER_SERVICE_NAME, u as shouldSkipPruningForSession, v as isLongSparseOpenModel, w as isQwenOpenModel, x as isOpenModelCacheWarmupProtected, y as isMimoOpenModel, z as codexRemoteCompactionThreshold } from "./tool-result-pruner-C1R1giga.js";
|
|
5
5
|
import { C as isDelegatedCaller, S as installDispatchExecutionGuard, T as resolveDispatchExecutionGuardEnabled, _ as installPlanModeExitReminder, b as registeredPlanControllerActive, h as createPlanNotice, l as PLAN_PROJECTION_KEY, n as EXIT_PLAN_MODE, w as isDelegatedSession } from "./plan-mode-cY8pp0PZ.js";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
@@ -15,7 +15,7 @@ import os, { homedir, platform, userInfo } from "node:os";
|
|
|
15
15
|
import { constants, createCipheriv, createDecipheriv, createHash, createHmac, publicEncrypt, randomBytes, randomUUID } from "node:crypto";
|
|
16
16
|
import { isDeepStrictEqual } from "node:util";
|
|
17
17
|
import { execFile, execFileSync, spawn } from "node:child_process";
|
|
18
|
-
import fs$1, { appendFileSync, constants as constants$1, existsSync, mkdirSync, mkdtempSync, readFileSync, rmdirSync, statSync, writeFileSync } from "node:fs";
|
|
18
|
+
import fs$1, { appendFileSync, constants as constants$1, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmdirSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
19
19
|
import http, { createServer } from "node:http";
|
|
20
20
|
import { WebError } from "@deepseek-ai/dsh-web";
|
|
21
21
|
import { lookup } from "node:dns/promises";
|
|
@@ -885,7 +885,7 @@ const ROUTE_PREFIX$6 = "/api/dsh-chatgpt-subscription";
|
|
|
885
885
|
* `test/responses-client.test.ts` asserts the two agree, so a release that
|
|
886
886
|
* forgets this constant fails the suite instead of shipping quietly.
|
|
887
887
|
*/
|
|
888
|
-
const PLUGIN_VERSION = "0.
|
|
888
|
+
const PLUGIN_VERSION = "0.95.0";
|
|
889
889
|
const CODEX_CHATGPT_PROVIDER_ID = "codex-chatgpt";
|
|
890
890
|
const CODEX_API_BASE = "https://chatgpt.com/backend-api/codex";
|
|
891
891
|
const CODEX_RESPONSES_URL = `${CODEX_API_BASE}/responses`;
|
|
@@ -14250,16 +14250,30 @@ const ZERO_USAGE = {
|
|
|
14250
14250
|
cacheWriteTokens: 0,
|
|
14251
14251
|
calls: 0
|
|
14252
14252
|
};
|
|
14253
|
+
/** Bound on the ancestor walk: lineage is finite, this only stops a corrupt log. */
|
|
14254
|
+
const LINEAGE_DEPTH_LIMIT = 16;
|
|
14255
|
+
function stringOf$5(value) {
|
|
14256
|
+
return typeof value === "string" && value !== "" ? value : void 0;
|
|
14257
|
+
}
|
|
14258
|
+
function spentTokens$1(usage) {
|
|
14259
|
+
return usage.inputTokens + usage.outputTokens + usage.cacheReadTokens + usage.cacheWriteTokens;
|
|
14260
|
+
}
|
|
14253
14261
|
/**
|
|
14254
14262
|
* Per-session Advisor choices plus the user-level default and the cumulative
|
|
14255
|
-
* advisor spend.
|
|
14256
|
-
*
|
|
14263
|
+
* advisor spend. A session with no choice of its own follows its nearest
|
|
14264
|
+
* ancestor, so enabling the advisor in a conversation also enables it for the
|
|
14265
|
+
* subagents that conversation delegates to. The JSON document contains routes,
|
|
14266
|
+
* booleans and token counts only: never credentials and never transcript content.
|
|
14257
14267
|
*/
|
|
14258
14268
|
var AdvisorSelectionStore = class {
|
|
14259
14269
|
defaults;
|
|
14270
|
+
lineage;
|
|
14260
14271
|
store;
|
|
14261
|
-
|
|
14272
|
+
/** Usage writes queue here: they share one conversation total. */
|
|
14273
|
+
pendingUsage = Promise.resolve();
|
|
14274
|
+
constructor(defaults, filePath, lineage) {
|
|
14262
14275
|
this.defaults = defaults;
|
|
14276
|
+
this.lineage = lineage;
|
|
14263
14277
|
this.store = new FilePreferencesStore(validateDocument, filePath ?? path.join(dshHomeDir(), "storages", "dsh-chatgpt-subscription-advisor.json"));
|
|
14264
14278
|
}
|
|
14265
14279
|
/** The user-level default: an explicit saved choice, else the configured seed. */
|
|
@@ -14270,18 +14284,34 @@ var AdvisorSelectionStore = class {
|
|
|
14270
14284
|
route: saved.route ?? fallback.selection
|
|
14271
14285
|
};
|
|
14272
14286
|
}
|
|
14273
|
-
|
|
14287
|
+
/**
|
|
14288
|
+
* The effective state for one session: its own choice first, then each
|
|
14289
|
+
* ancestor's, field by field, and finally the user-level default.
|
|
14290
|
+
* @param sessionId - the session whose seats are being read.
|
|
14291
|
+
* @param header - that session's own header when the caller already holds it.
|
|
14292
|
+
*/
|
|
14293
|
+
async state(sessionId, header) {
|
|
14274
14294
|
await this.store.hydrate();
|
|
14275
14295
|
const fallback = this.defaults();
|
|
14276
14296
|
const userDefault = this.base(fallback);
|
|
14277
|
-
const saved = this.store.get().sessions
|
|
14297
|
+
const saved = this.store.get().sessions;
|
|
14298
|
+
const chain = this.chain(sessionId, header);
|
|
14299
|
+
let enabled;
|
|
14300
|
+
let route;
|
|
14301
|
+
for (const id of chain) {
|
|
14302
|
+
const entry = saved[id];
|
|
14303
|
+
if (entry === void 0) continue;
|
|
14304
|
+
if (enabled === void 0) enabled = entry.enabled;
|
|
14305
|
+
if (route === void 0) route = entry.route;
|
|
14306
|
+
if (enabled !== void 0 && route !== void 0) break;
|
|
14307
|
+
}
|
|
14278
14308
|
return {
|
|
14279
14309
|
sessionId,
|
|
14280
|
-
enabled:
|
|
14281
|
-
selection:
|
|
14310
|
+
enabled: enabled ?? userDefault.enabled,
|
|
14311
|
+
selection: route ?? userDefault.route,
|
|
14282
14312
|
defaultEnabled: userDefault.enabled,
|
|
14283
14313
|
defaultSelection: userDefault.route,
|
|
14284
|
-
inherited:
|
|
14314
|
+
inherited: enabled === void 0 && route === void 0,
|
|
14285
14315
|
limits: {
|
|
14286
14316
|
maxTokens: fallback.maxTokens,
|
|
14287
14317
|
timeoutMs: fallback.timeoutMs,
|
|
@@ -14289,7 +14319,7 @@ var AdvisorSelectionStore = class {
|
|
|
14289
14319
|
contextTokenBudget: fallback.contextTokenBudget,
|
|
14290
14320
|
sessionTokenBudget: fallback.sessionTokenBudget
|
|
14291
14321
|
},
|
|
14292
|
-
usage: saved?.usage ?? { ...ZERO_USAGE }
|
|
14322
|
+
usage: saved[chain[chain.length - 1]]?.usage ?? { ...ZERO_USAGE }
|
|
14293
14323
|
};
|
|
14294
14324
|
}
|
|
14295
14325
|
/** Write one session's override. `null` reverts that field to the user-level default. */
|
|
@@ -14322,19 +14352,36 @@ var AdvisorSelectionStore = class {
|
|
|
14322
14352
|
if (enabled !== void 0) defaults.enabled = enabled;
|
|
14323
14353
|
await this.store.update({ defaults });
|
|
14324
14354
|
}
|
|
14325
|
-
/**
|
|
14326
|
-
|
|
14327
|
-
|
|
14355
|
+
/**
|
|
14356
|
+
* Add one consultation's spend and return the conversation's new running total.
|
|
14357
|
+
* The spend lands on the lineage root whichever member of the tree consulted.
|
|
14358
|
+
*/
|
|
14359
|
+
async addUsage(sessionId, usage, header) {
|
|
14360
|
+
const operation = this.pendingUsage.then(() => this.recordUsage(sessionId, usage, header));
|
|
14361
|
+
this.pendingUsage = operation.then(() => void 0, () => void 0);
|
|
14362
|
+
return operation;
|
|
14363
|
+
}
|
|
14364
|
+
async recordUsage(sessionId, usage, header) {
|
|
14365
|
+
const state = await this.state(sessionId, header);
|
|
14366
|
+
const chain = this.chain(sessionId, header);
|
|
14367
|
+
const budgetSessionId = chain[chain.length - 1];
|
|
14368
|
+
const sessions = { ...this.store.get().sessions };
|
|
14369
|
+
const own = budgetSessionId === sessionId ? void 0 : sessions[sessionId]?.usage;
|
|
14370
|
+
const folded = own !== void 0 && spentTokens$1(own) > 0 ? own : void 0;
|
|
14328
14371
|
const merged = {
|
|
14329
|
-
inputTokens: state.usage.inputTokens + usage.inputTokens,
|
|
14330
|
-
outputTokens: state.usage.outputTokens + usage.outputTokens,
|
|
14331
|
-
cacheReadTokens: state.usage.cacheReadTokens + usage.cacheReadTokens,
|
|
14332
|
-
cacheWriteTokens: state.usage.cacheWriteTokens + usage.cacheWriteTokens,
|
|
14333
|
-
calls: state.usage.calls + usage.calls
|
|
14372
|
+
inputTokens: state.usage.inputTokens + (folded?.inputTokens ?? 0) + usage.inputTokens,
|
|
14373
|
+
outputTokens: state.usage.outputTokens + (folded?.outputTokens ?? 0) + usage.outputTokens,
|
|
14374
|
+
cacheReadTokens: state.usage.cacheReadTokens + (folded?.cacheReadTokens ?? 0) + usage.cacheReadTokens,
|
|
14375
|
+
cacheWriteTokens: state.usage.cacheWriteTokens + (folded?.cacheWriteTokens ?? 0) + usage.cacheWriteTokens,
|
|
14376
|
+
calls: state.usage.calls + (folded?.calls ?? 0) + usage.calls
|
|
14377
|
+
};
|
|
14378
|
+
if (folded !== void 0) sessions[sessionId] = {
|
|
14379
|
+
...sessions[sessionId],
|
|
14380
|
+
usage: { ...ZERO_USAGE },
|
|
14381
|
+
updatedAt: Date.now()
|
|
14334
14382
|
};
|
|
14335
|
-
|
|
14336
|
-
|
|
14337
|
-
...sessions[sessionId] ?? {
|
|
14383
|
+
sessions[budgetSessionId] = {
|
|
14384
|
+
...sessions[budgetSessionId] ?? {
|
|
14338
14385
|
usage: { ...ZERO_USAGE },
|
|
14339
14386
|
updatedAt: 0
|
|
14340
14387
|
},
|
|
@@ -14344,6 +14391,31 @@ var AdvisorSelectionStore = class {
|
|
|
14344
14391
|
await this.commit(sessions);
|
|
14345
14392
|
return merged;
|
|
14346
14393
|
}
|
|
14394
|
+
/**
|
|
14395
|
+
* This session's id followed by each resolvable ancestor. The caller-supplied
|
|
14396
|
+
* header seeds the walk, so a delegated session still reaches its parent when
|
|
14397
|
+
* the registry no longer holds that session.
|
|
14398
|
+
*/
|
|
14399
|
+
chain(sessionId, header) {
|
|
14400
|
+
const chain = [sessionId];
|
|
14401
|
+
const seen = new Set(chain);
|
|
14402
|
+
let resolved = header ?? this.headerOf(sessionId);
|
|
14403
|
+
for (let depth = 0; depth < LINEAGE_DEPTH_LIMIT; depth += 1) {
|
|
14404
|
+
const parent = stringOf$5(resolved?.parentSession);
|
|
14405
|
+
if (parent === void 0 || seen.has(parent)) return chain;
|
|
14406
|
+
seen.add(parent);
|
|
14407
|
+
chain.push(parent);
|
|
14408
|
+
resolved = this.headerOf(parent);
|
|
14409
|
+
}
|
|
14410
|
+
return chain;
|
|
14411
|
+
}
|
|
14412
|
+
headerOf(sessionId) {
|
|
14413
|
+
try {
|
|
14414
|
+
return this.lineage?.(sessionId);
|
|
14415
|
+
} catch {
|
|
14416
|
+
return;
|
|
14417
|
+
}
|
|
14418
|
+
}
|
|
14347
14419
|
/** Bounded map: the 512 most recently touched sessions survive. */
|
|
14348
14420
|
async commit(sessions) {
|
|
14349
14421
|
const retained = Object.entries(sessions).sort((a, b) => b[1].updatedAt - a[1].updatedAt).slice(0, 512);
|
|
@@ -14568,6 +14640,14 @@ async function requestAdvisor(options) {
|
|
|
14568
14640
|
}
|
|
14569
14641
|
const advice = (deltas.length > 0 ? deltas.join("") : blocks.join("\n")).trim();
|
|
14570
14642
|
const spent = usageOf(usage);
|
|
14643
|
+
if (advice === "" && finishKind === "max-tokens") return {
|
|
14644
|
+
status: "truncated",
|
|
14645
|
+
advice,
|
|
14646
|
+
advisor: options.route,
|
|
14647
|
+
detail: "The advisor spent its whole output limit on reasoning and produced no answer. Raise the advisor output limit or lower its reasoning effort.",
|
|
14648
|
+
...spent === void 0 ? {} : { usage: spent },
|
|
14649
|
+
omittedMessages: options.transcript.omittedMessages
|
|
14650
|
+
};
|
|
14571
14651
|
return {
|
|
14572
14652
|
status: advice === "" ? "declined" : finishKind === "max-tokens" ? "truncated" : "ok",
|
|
14573
14653
|
advice,
|
|
@@ -14602,10 +14682,11 @@ async function requestAdvisor(options) {
|
|
|
14602
14682
|
function describeResult(result) {
|
|
14603
14683
|
const route = result.advisor === void 0 ? "" : `\nAdvisor: ${result.advisor.provider}/${result.advisor.model}`;
|
|
14604
14684
|
if (result.status === "disabled" || result.status === "unconfigured" || result.status === "unavailable" || result.status === "cancelled" || result.status === "budget-exhausted") return `${result.detail ?? `Advisor ${result.status}`}${route}`;
|
|
14605
|
-
if (result.status === "declined") return `Advisor declined to advise on this request.${result.detail === void 0 ? "" : `\n${result.detail}`}${route}`;
|
|
14606
14685
|
const usage = result.usage === void 0 ? "" : `\nUsage: ${result.usage.inputTokens ?? 0} input, ${result.usage.outputTokens ?? 0} output tokens.`;
|
|
14607
|
-
|
|
14608
|
-
|
|
14686
|
+
if (result.status === "declined") return `Advisor declined to advise on this request.${result.detail === void 0 ? "" : `\n${result.detail}`}${route}${usage}`;
|
|
14687
|
+
const silent = result.advice.trim() === "";
|
|
14688
|
+
const truncated = result.status === "truncated" && !silent ? "\n[Advisor output was truncated at its token limit.]" : "";
|
|
14689
|
+
return `${silent ? result.detail ?? "The advisor returned no advice." : result.advice}${truncated}${route}${usage}`;
|
|
14609
14690
|
}
|
|
14610
14691
|
const ADVISOR_OUTPUT = {
|
|
14611
14692
|
schema: { type: "json" },
|
|
@@ -14618,6 +14699,20 @@ const ADVISOR_OUTPUT = {
|
|
|
14618
14699
|
};
|
|
14619
14700
|
/** Context assumed for an advisor model whose real window could not be resolved. */
|
|
14620
14701
|
const UNKNOWN_CONTEXT_WINDOW = 32e3;
|
|
14702
|
+
/**
|
|
14703
|
+
* The Session registry answers one hop of the delegation lineage. A registry
|
|
14704
|
+
* that is absent or refuses the id is a missing ancestor, never a failed consult.
|
|
14705
|
+
* @param ctx - host context the Advisor was installed on.
|
|
14706
|
+
* @param sessionId - session whose parent link is wanted.
|
|
14707
|
+
* @returns that session's header, when the registry knows it.
|
|
14708
|
+
*/
|
|
14709
|
+
function sessionHeaderOf(ctx, sessionId) {
|
|
14710
|
+
try {
|
|
14711
|
+
return ctx.get("sessions")?.get?.(sessionId)?.header;
|
|
14712
|
+
} catch {
|
|
14713
|
+
return;
|
|
14714
|
+
}
|
|
14715
|
+
}
|
|
14621
14716
|
function value(input, fallback) {
|
|
14622
14717
|
return (typeof input === "object" && input !== null && "get" in input && typeof input.get === "function" ? input.get() : input) ?? fallback;
|
|
14623
14718
|
}
|
|
@@ -14660,7 +14755,8 @@ var AdvisorService = class {
|
|
|
14660
14755
|
advice: "",
|
|
14661
14756
|
detail: "Advisor requires an active agent session."
|
|
14662
14757
|
};
|
|
14663
|
-
const
|
|
14758
|
+
const header = agent?.session?.header;
|
|
14759
|
+
const state = await this.selections.state(sessionId, header);
|
|
14664
14760
|
if (!state.enabled) return {
|
|
14665
14761
|
status: "disabled",
|
|
14666
14762
|
advice: "",
|
|
@@ -14678,11 +14774,12 @@ var AdvisorService = class {
|
|
|
14678
14774
|
detail: `This conversation has spent ${spentTokens(state.usage)} of its ${state.limits.sessionTokenBudget} advisor tokens. Raise the budget or start a new conversation to consult again.`
|
|
14679
14775
|
};
|
|
14680
14776
|
const info = await this.llm.resolveModelInfo?.(state.selection.provider, state.selection.model, signal).catch(() => void 0);
|
|
14681
|
-
const
|
|
14777
|
+
const answerBudget = info?.maxTokens === void 0 ? state.limits.maxTokens : Math.min(state.limits.maxTokens, info.maxTokens);
|
|
14778
|
+
const maxTokens = info?.maxTokens ?? state.limits.maxTokens;
|
|
14682
14779
|
const contextTokenBudget = Math.min(state.limits.contextTokenBudget, info?.contextWindow ?? UNKNOWN_CONTEXT_WINDOW);
|
|
14683
14780
|
const transcript = projectAdvisorTranscript(agent.session.deriveMessages(), {
|
|
14684
14781
|
contextTokenBudget,
|
|
14685
|
-
maxTokens,
|
|
14782
|
+
maxTokens: answerBudget,
|
|
14686
14783
|
includeImages: info?.inputModalities?.includes("image") ?? true
|
|
14687
14784
|
});
|
|
14688
14785
|
const question = `Review focus: ${args.focus ?? "other"}\nQuestion: ${args.question}`;
|
|
@@ -14704,7 +14801,7 @@ var AdvisorService = class {
|
|
|
14704
14801
|
cacheReadTokens: result.usage?.cacheReadTokens ?? 0,
|
|
14705
14802
|
cacheWriteTokens: result.usage?.cacheWriteTokens ?? 0,
|
|
14706
14803
|
calls: 1
|
|
14707
|
-
}).catch(() => void 0);
|
|
14804
|
+
}, header).catch(() => void 0);
|
|
14708
14805
|
if (usage !== void 0 && state.limits.sessionTokenBudget > 0 && spentTokens(usage) > state.limits.sessionTokenBudget) return {
|
|
14709
14806
|
...result,
|
|
14710
14807
|
detail: `${result.detail === void 0 ? "" : `${result.detail}\n`}This consultation exhausted the conversation's advisor token budget.`
|
|
@@ -14730,7 +14827,7 @@ function installAdvisor(ctx, config) {
|
|
|
14730
14827
|
maxRetries: value(config.advisorMaxRetries, 1),
|
|
14731
14828
|
contextTokenBudget: value(config.advisorContextTokenBudget, 1e5),
|
|
14732
14829
|
sessionTokenBudget: value(config.advisorSessionTokenBudget, 2e5)
|
|
14733
|
-
}));
|
|
14830
|
+
}), void 0, (sessionId) => sessionHeaderOf(ctx, sessionId));
|
|
14734
14831
|
const service = new AdvisorService(store, ctx.llm);
|
|
14735
14832
|
const disposeTool = ctx.tools.register(defineTool({
|
|
14736
14833
|
name: CONSULT_ADVISOR_TOOL_NAME,
|
|
@@ -116015,6 +116112,117 @@ function installDispatchLedger(ctx, options = {}) {
|
|
|
116015
116112
|
};
|
|
116016
116113
|
}
|
|
116017
116114
|
//#endregion
|
|
116115
|
+
//#region src/host/runtime/presets/team-board-sweep.ts
|
|
116116
|
+
/**
|
|
116117
|
+
* Prune the team board archive.
|
|
116118
|
+
*
|
|
116119
|
+
* A board is kept after delivery so a run can be reviewed, which means the
|
|
116120
|
+
* archive needs a horizon rather than a delete-on-exit rule: this walks ONE
|
|
116121
|
+
* plugin-owned directory under the DSH home, removes boards older than the
|
|
116122
|
+
* retention window, and removes a run directory only when that board was its
|
|
116123
|
+
* only entry.
|
|
116124
|
+
*
|
|
116125
|
+
* Never recursive. A junction or symlink under the temp root would make a
|
|
116126
|
+
* recursive delete destroy a real tree somewhere else, so a link (or anything
|
|
116127
|
+
* that is not a plain directory) is skipped, and nothing but `board.jsonl` is
|
|
116128
|
+
* ever unlinked.
|
|
116129
|
+
* @module dsh-chatgpt-subscription/team-board-sweep
|
|
116130
|
+
*/
|
|
116131
|
+
/** The one directory this plugin owns under the DSH home, next to `sessions/`. */
|
|
116132
|
+
const TEAM_BOARD_ROOT_NAME = "team";
|
|
116133
|
+
/** The narrative file a run appends to, and the only name this sweep unlinks. */
|
|
116134
|
+
const TEAM_BOARD_FILE = "board.jsonl";
|
|
116135
|
+
/**
|
|
116136
|
+
* The directory the preset writes boards under, and the persona names.
|
|
116137
|
+
* @param base - DSH home, injectable for tests.
|
|
116138
|
+
* @returns the absolute root of the archive.
|
|
116139
|
+
*/
|
|
116140
|
+
function teamBoardRoot(base = dshHomeDir()) {
|
|
116141
|
+
return join(base, TEAM_BOARD_ROOT_NAME);
|
|
116142
|
+
}
|
|
116143
|
+
/** Whether one entry can be treated as a run directory this plugin owns. */
|
|
116144
|
+
function isPlainDirectory(path) {
|
|
116145
|
+
try {
|
|
116146
|
+
const stat = lstatSync(path);
|
|
116147
|
+
return stat.isDirectory() && !stat.isSymbolicLink();
|
|
116148
|
+
} catch {
|
|
116149
|
+
return false;
|
|
116150
|
+
}
|
|
116151
|
+
}
|
|
116152
|
+
/**
|
|
116153
|
+
* Remove boards past the retention window.
|
|
116154
|
+
*
|
|
116155
|
+
* Every failure is local to one entry and reported through `kept`; a read-only
|
|
116156
|
+
* temp root or a locked file must never fail plugin load.
|
|
116157
|
+
* @param options - root, clock, and the retention window.
|
|
116158
|
+
* @returns counts for the caller's log line.
|
|
116159
|
+
*/
|
|
116160
|
+
function sweepTeamBoards(options = {}) {
|
|
116161
|
+
const root = options.root ?? teamBoardRoot();
|
|
116162
|
+
const now = options.now ?? Date.now();
|
|
116163
|
+
const ttlMs = options.ttlMs ?? 2592e6;
|
|
116164
|
+
let removedFiles = 0;
|
|
116165
|
+
let removedDirs = 0;
|
|
116166
|
+
let kept = 0;
|
|
116167
|
+
let entries;
|
|
116168
|
+
try {
|
|
116169
|
+
entries = readdirSync(root);
|
|
116170
|
+
} catch {
|
|
116171
|
+
return {
|
|
116172
|
+
removedFiles: 0,
|
|
116173
|
+
removedDirs: 0,
|
|
116174
|
+
kept: 0
|
|
116175
|
+
};
|
|
116176
|
+
}
|
|
116177
|
+
for (const name of entries) {
|
|
116178
|
+
const dir = join(root, name);
|
|
116179
|
+
if (!isPlainDirectory(dir)) {
|
|
116180
|
+
kept++;
|
|
116181
|
+
continue;
|
|
116182
|
+
}
|
|
116183
|
+
try {
|
|
116184
|
+
if (now - lstatSync(dir).mtimeMs < ttlMs) {
|
|
116185
|
+
kept++;
|
|
116186
|
+
continue;
|
|
116187
|
+
}
|
|
116188
|
+
} catch {
|
|
116189
|
+
kept++;
|
|
116190
|
+
continue;
|
|
116191
|
+
}
|
|
116192
|
+
const board = join(dir, TEAM_BOARD_FILE);
|
|
116193
|
+
try {
|
|
116194
|
+
if (lstatSync(board).isSymbolicLink()) {
|
|
116195
|
+
kept++;
|
|
116196
|
+
continue;
|
|
116197
|
+
}
|
|
116198
|
+
unlinkSync(board);
|
|
116199
|
+
removedFiles++;
|
|
116200
|
+
} catch {}
|
|
116201
|
+
let remaining = [];
|
|
116202
|
+
try {
|
|
116203
|
+
remaining = readdirSync(dir);
|
|
116204
|
+
} catch {
|
|
116205
|
+
kept++;
|
|
116206
|
+
continue;
|
|
116207
|
+
}
|
|
116208
|
+
if (remaining.length > 0) {
|
|
116209
|
+
kept++;
|
|
116210
|
+
continue;
|
|
116211
|
+
}
|
|
116212
|
+
try {
|
|
116213
|
+
rmdirSync(dir);
|
|
116214
|
+
removedDirs++;
|
|
116215
|
+
} catch {
|
|
116216
|
+
kept++;
|
|
116217
|
+
}
|
|
116218
|
+
}
|
|
116219
|
+
return {
|
|
116220
|
+
removedFiles,
|
|
116221
|
+
removedDirs,
|
|
116222
|
+
kept
|
|
116223
|
+
};
|
|
116224
|
+
}
|
|
116225
|
+
//#endregion
|
|
116018
116226
|
//#region src/host/runtime/presets/agent-preset.ts
|
|
116019
116227
|
/**
|
|
116020
116228
|
* The `dispatch` agent preset as a runtime declaration.
|
|
@@ -116057,8 +116265,6 @@ const PTC_REGISTRY_PACKAGE = "@deepseek-ai/dsh-tool-registry-ptc";
|
|
|
116057
116265
|
const CODEMODE_PACKAGE = "@eddyskywalker/dsh-chatgpt-subscription/codemode";
|
|
116058
116266
|
/** The deprecated presentation row generations without a native executor keep. */
|
|
116059
116267
|
const AGENT_TOOL_PRESENTATION_PACKAGE = "@deepseek-ai/dsh-agent-tool-presentation";
|
|
116060
|
-
/** The id the `dispatch` preset is selectable under. */
|
|
116061
|
-
const DISPATCH_PRESET_ID = "dispatch";
|
|
116062
116268
|
/**
|
|
116063
116269
|
* The `dispatch` (调度模式) preset: identity from `presets/dispatch/preset.yml`,
|
|
116064
116270
|
* rows transcribed from `presets/dispatch/agent.cordis.yml` in the same order.
|
|
@@ -116070,7 +116276,7 @@ const DISPATCH_PRESET_ID = "dispatch";
|
|
|
116070
116276
|
* for text the Loader evaluates, and nothing evaluates this.
|
|
116071
116277
|
*/
|
|
116072
116278
|
const DISPATCH_PRESET = {
|
|
116073
|
-
id:
|
|
116279
|
+
id: "dispatch",
|
|
116074
116280
|
name: "调度模式",
|
|
116075
116281
|
description: "基于 Code Mode 的调度 Agent:按决策状态分诊,明确工程任务快速执行,治理任务先访谈与审批;由主代理选择拓扑、显式路由子代理并统一验收。",
|
|
116076
116282
|
order: 5,
|
|
@@ -116136,6 +116342,7 @@ One acceptance layer owned by Lead: subagents supply implementation/evidence; Le
|
|
|
116136
116342
|
|
|
116137
116343
|
## R-W · Turn Boundary (Waiting / Goals / Questions)
|
|
116138
116344
|
- [Waiting] End your turn and let the subagent completion notification wake you (Treat it as "there is now something to review", never as "this passed"). Never run sleep, polling loops, watch, or placeholder long commands to wait; only call job_output({ wait: true }) when genuinely blocked on an immediate collection. State who was dispatched, what you are waiting for, and what you will do next before ending the turn.
|
|
116345
|
+
- [Silent child] A dispatched subagent can end its turn without a report, or sit inactive after a failed run; a Lead that only waits waits forever. On every wake (user message, another child's completion, a progress event) reconcile expectation against list_agents: a child listed inactive with no report, or past the duration its brief implied, gets ONE send_message asking for a one-line status or a hand_back. Where the host mounts wait_agent, one bounded call (timeout_ms <= 600000) is the sanctioned heartbeat in place of any sleep. Two reconciliations with no answer means the child is gone: finish the task yourself under R8 and say so in the delivery summary.
|
|
116139
116346
|
- [Goals] Do not proactively create goals: never call create_goal or /goal unless the user asks; track tasks in todo_write.
|
|
116140
116347
|
- [Questions] Whenever a decision is missing, hand the question out with ONE code_run program containing exactly one tools.ask_user_question(...) sub-call. The same rule covers every decision stop outside the interview. Only two exceptions: plan-mode approval still goes through tools.exit_plan_mode inside code_run, and a finished task asks nothing.
|
|
116141
116348
|
|
|
@@ -116367,45 +116574,139 @@ Fallback is a task-scoped, non-session-wide exception and covers only the single
|
|
|
116367
116574
|
}
|
|
116368
116575
|
]
|
|
116369
116576
|
};
|
|
116577
|
+
/** The team domain: the shared task board, from harness 0.2.1-rc.2. */
|
|
116578
|
+
const TEAM_BOARD_PACKAGE = "@deepseek-ai/dsh-agent-team";
|
|
116579
|
+
/** The model-facing half of the team domain, same generation. */
|
|
116580
|
+
const TEAM_BOARD_TOOL_PACKAGE = "@deepseek-ai/dsh-tool-agent-team";
|
|
116581
|
+
/** The `team` (班组模式) preset id, and the directory `presets/team/` ships. */
|
|
116582
|
+
const TEAM_PRESET_ID = "team";
|
|
116583
|
+
/**
|
|
116584
|
+
* Insert one line after the unique line containing `anchor`.
|
|
116585
|
+
*
|
|
116586
|
+
* The Team persona is the dispatch persona plus a delta, so the delta is applied
|
|
116587
|
+
* to text this file already owns instead of to a second hand-copied 17 KB
|
|
116588
|
+
* literal. A missing or ambiguous anchor throws: a silent no-op would ship a
|
|
116589
|
+
* preset whose name promises rules its persona does not carry.
|
|
116590
|
+
* @param text - the persona block to edit.
|
|
116591
|
+
* @param anchor - a substring of the single line to insert after.
|
|
116592
|
+
* @param addition - the line to insert.
|
|
116593
|
+
* @returns the edited text.
|
|
116594
|
+
*/
|
|
116595
|
+
function insertPersonaLine(text, anchor, addition) {
|
|
116596
|
+
const lines = text.split("\n");
|
|
116597
|
+
const hits = lines.flatMap((line, index) => line.includes(anchor) ? [index] : []);
|
|
116598
|
+
if (hits.length !== 1) throw new Error(`persona anchor "${anchor}" matched ${hits.length} lines`);
|
|
116599
|
+
lines.splice(hits[0] + 1, 0, addition);
|
|
116600
|
+
return lines.join("\n");
|
|
116601
|
+
}
|
|
116370
116602
|
/**
|
|
116371
|
-
*
|
|
116372
|
-
*
|
|
116373
|
-
*
|
|
116374
|
-
*
|
|
116375
|
-
*
|
|
116376
|
-
|
|
116377
|
-
|
|
116378
|
-
|
|
116379
|
-
|
|
116380
|
-
|
|
116381
|
-
|
|
116382
|
-
|
|
116383
|
-
|
|
116384
|
-
|
|
116385
|
-
*
|
|
116386
|
-
* Code Mode needs the native tool executor (it is the pipeline the program's
|
|
116387
|
-
* sub-calls are delegated to), so that package's presence decides the
|
|
116388
|
-
* presentation rows:
|
|
116389
|
-
*
|
|
116390
|
-
* - resolvable: the `code-mode` row mounts as-is and no PTC executor row exists
|
|
116391
|
-
* beside it (one executor per scope);
|
|
116392
|
-
* - absent: the row falls back to the deprecated agent-tool-presentation row and,
|
|
116393
|
-
* when the standalone PTC executor exists, to that executor instead — the
|
|
116394
|
-
* behaviour of every generation before Code Mode.
|
|
116603
|
+
* Insert a whole section before the line starting with `before`.
|
|
116604
|
+
* @param text - the persona block to edit.
|
|
116605
|
+
* @param before - the prefix of the line the section goes above.
|
|
116606
|
+
* @param section - the section text, newline separated.
|
|
116607
|
+
* @returns the edited text.
|
|
116608
|
+
*/
|
|
116609
|
+
function insertPersonaSection(text, before, section) {
|
|
116610
|
+
const lines = text.split("\n");
|
|
116611
|
+
const index = lines.findIndex((line) => line.startsWith(before));
|
|
116612
|
+
if (index < 0) throw new Error(`persona section "${before}" is absent`);
|
|
116613
|
+
lines.splice(index, 0, ...section.split("\n"));
|
|
116614
|
+
return lines.join("\n");
|
|
116615
|
+
}
|
|
116616
|
+
/**
|
|
116617
|
+
* The two rows only the Team preset mounts: the durable shared task board.
|
|
116395
116618
|
*
|
|
116619
|
+
* `agent-team` owns the board and saves Team mode on for a new root, so selecting
|
|
116620
|
+
* the preset is the whole setup instead of preset + a menu toggle;
|
|
116621
|
+
* `tool-agent-team` is what puts team_task_create/update in the model's hands.
|
|
116622
|
+
* Both arrive with 0.2.1-rc.2 and are dropped from the definition on a
|
|
116623
|
+
* generation that cannot resolve them (see `resolvePreset`).
|
|
116624
|
+
*/
|
|
116625
|
+
const TEAM_BOARD_ROWS = [{
|
|
116626
|
+
id: "agent-team",
|
|
116627
|
+
name: TEAM_BOARD_PACKAGE,
|
|
116628
|
+
config: {
|
|
116629
|
+
maxTasks: 256,
|
|
116630
|
+
defaultEnabled: true
|
|
116631
|
+
}
|
|
116632
|
+
}, {
|
|
116633
|
+
id: "tool-agent-team",
|
|
116634
|
+
name: TEAM_BOARD_TOOL_PACKAGE
|
|
116635
|
+
}];
|
|
116636
|
+
/** The R1 bullet that introduces the Team topology without moving R5 or R6. */
|
|
116637
|
+
const TEAM_TOPOLOGY_BULLET = "- Team: >=3 orthogonal subtasks that must also exchange information while they run (A's product is B's input, and B has to ask A mid-flight), on a host that mounts send_message and wait_agent. Size the crew from the pool, not from ambition: list_agents reports limit and running (the root is not counted), so keep the last slot for the verifier and never let the tree exceed limit - running - 1; with no capacity left a piece waits its turn instead of adding a worker. Team changes who talks to whom, never who accepts — R5 briefs and R6 acceptance stay with the Lead.";
|
|
116638
|
+
/** The `## R-T` section: board, address, park, size and reduce. */
|
|
116639
|
+
const TEAM_TOPOLOGY_SECTION = [
|
|
116640
|
+
"## R-T · Team Topology Rules (only when R1 chose Team)",
|
|
116641
|
+
"The Team topology adds a shared board and lateral address; R5, R6 and R-W apply unchanged.",
|
|
116642
|
+
"- T1 Board: two artifacts. Work and conclusions live on the shared team board (team_task_create / team_task_update: owner, revision, write scopes). Narration lives in ONE board.jsonl under <DSH home>/team/<run>/ — the home that holds sessions/ — one JSON object {seq, agent, text, time} per line; append with a shell redirect only, never write or edit it, and take #seq from the line number you appended. The Lead states the path in every brief. The board outlives the run for review; the host prunes boards older than 30 days. If the sandbox denies the path, keep narration in the task descriptions, no fake board.",
|
|
116643
|
+
"- T2 Address: send_message({agent}) is the doorbell, not a courtesy copy: name the one member who acts next, one target per message. Completing a task wakes nobody — the host policy says task changes end no wait and add no inbox message — so whoever finishes names the next actor itself.",
|
|
116644
|
+
"- T3 Park: a worker with nothing to do calls wait_agent (10s-1h bound) instead of ending its turn, then reads the board from its last #seq and decides. This is an inbox wait, not the polling R-W forbids.",
|
|
116645
|
+
"- T4 Size: read the pool before adding anyone. list_agents returns limit and running, so resident workers <= limit - running - 1 and the last slot belongs to the verifier; when running already meets limit, add nobody and post what is queued, and where the host has no list_agents fall back to 4. Scale by splitting the task, never by raising the count.",
|
|
116646
|
+
"- T5 Reduce: one verifier per 2-4 workers; it reports to the author and never fixes — two workers in one file is the failure this avoids. Deliverables still return to the Lead for R6; the board is process evidence, never acceptance evidence."
|
|
116647
|
+
].join("\n");
|
|
116648
|
+
/**
|
|
116649
|
+
* The Team persona: the dispatch persona plus the Team topology delta.
|
|
116650
|
+
*
|
|
116651
|
+
* Applied to whichever persona the caller passes, so the two copies of a persona
|
|
116652
|
+
* edit (this file's literal and the `presets/<id>/agent.cordis.yml` copies) stay one edit.
|
|
116653
|
+
* @param persona - the dispatch persona prefix.
|
|
116654
|
+
* @returns the team persona prefix.
|
|
116655
|
+
*/
|
|
116656
|
+
function applyTeamDelta(persona) {
|
|
116657
|
+
return insertPersonaSection(insertPersonaLine(persona, "parallel/routing gain", TEAM_TOPOLOGY_BULLET), "## R2 · Model Routing", TEAM_TOPOLOGY_SECTION);
|
|
116658
|
+
}
|
|
116659
|
+
/**
|
|
116660
|
+
* The `team` (班组模式) preset: identity from `presets/team/preset.yml`, rows and
|
|
116661
|
+
* persona inherited from {@link DISPATCH_PRESET}.
|
|
116662
|
+
*
|
|
116663
|
+
* One row differs — the persona — and through {@link applyTeamDelta} only. The
|
|
116664
|
+
* baseline is harness 0.2.1: the topology relies on `send_message` and
|
|
116665
|
+
* `wait_agent` from the subagent-control row both presets already mount, and
|
|
116666
|
+
* adds no package this plugin has to keep compatible.
|
|
116667
|
+
*/
|
|
116668
|
+
const TEAM_PRESET = {
|
|
116669
|
+
...DISPATCH_PRESET,
|
|
116670
|
+
id: TEAM_PRESET_ID,
|
|
116671
|
+
name: "班组模式",
|
|
116672
|
+
description: "调度模式之上加 Team 拓扑:常驻工人共享一块 append-only 公告板,按名字点名唤醒、有界挂起,验证者只报不修;分诊、任务书与 Lead 验收与调度模式一致。",
|
|
116673
|
+
order: 6,
|
|
116674
|
+
plugins: DISPATCH_PRESET.plugins.flatMap((row) => {
|
|
116675
|
+
let base = row;
|
|
116676
|
+
if (row.id === "persona" && typeof row.config === "object" && row.config !== null) {
|
|
116677
|
+
const persona = row.config;
|
|
116678
|
+
if (typeof persona.prefix !== "string") throw new Error("the dispatch persona carries no prefix to extend");
|
|
116679
|
+
base = {
|
|
116680
|
+
...row,
|
|
116681
|
+
config: {
|
|
116682
|
+
...row.config,
|
|
116683
|
+
prefix: applyTeamDelta(persona.prefix)
|
|
116684
|
+
}
|
|
116685
|
+
};
|
|
116686
|
+
}
|
|
116687
|
+
return row.id === "delegation" ? [base, ...TEAM_BOARD_ROWS] : [base];
|
|
116688
|
+
})
|
|
116689
|
+
};
|
|
116690
|
+
/**
|
|
116691
|
+
* Reconcile any definition with the running harness generation.
|
|
116692
|
+
* @param definition - the preset to adapt.
|
|
116396
116693
|
* @param resolves - whether a bare specifier resolves in this installation.
|
|
116397
|
-
* @returns the
|
|
116694
|
+
* @returns the adapted definition.
|
|
116398
116695
|
*/
|
|
116399
|
-
function
|
|
116696
|
+
function resolvePreset(definition, resolves) {
|
|
116697
|
+
const withoutBoard = !definition.plugins.some((row) => TEAM_BOARD_ROWS.some((board) => board.id === row.id)) || resolves("@deepseek-ai/dsh-agent-team") && resolves("@deepseek-ai/dsh-tool-agent-team") ? definition : {
|
|
116698
|
+
...definition,
|
|
116699
|
+
plugins: definition.plugins.filter((row) => !TEAM_BOARD_ROWS.some((board) => board.id === row.id))
|
|
116700
|
+
};
|
|
116400
116701
|
const hasWorkingDirectory = resolves(WORKING_DIRECTORY_PACKAGE);
|
|
116401
116702
|
const hasLegacyListAgents = resolves("@deepseek-ai/dsh-tool-subagent-control/list-agents");
|
|
116402
116703
|
const hasPtcRegistry = resolves(PTC_REGISTRY_PACKAGE);
|
|
116403
116704
|
const hasPtcExecutor = resolves(PTC_EXECUTOR_PACKAGE);
|
|
116404
116705
|
const hasNativeToolSupport = resolves("@deepseek-ai/dsh-tool-registry-native") || resolves("@deepseek-ai/dsh-tool-executor-native");
|
|
116405
|
-
if (!hasWorkingDirectory && hasLegacyListAgents && !hasPtcRegistry && !hasPtcExecutor && hasNativeToolSupport) return
|
|
116706
|
+
if (!hasWorkingDirectory && hasLegacyListAgents && !hasPtcRegistry && !hasPtcExecutor && hasNativeToolSupport) return withoutBoard;
|
|
116406
116707
|
return {
|
|
116407
|
-
...
|
|
116408
|
-
plugins:
|
|
116708
|
+
...withoutBoard,
|
|
116709
|
+
plugins: withoutBoard.plugins.map((row) => {
|
|
116409
116710
|
if (row.id === "delegation" && !hasLegacyListAgents && Array.isArray(row.config)) return {
|
|
116410
116711
|
...row,
|
|
116411
116712
|
config: row.config.filter((nested) => nested.id !== "tool-subagent-list-agents")
|
|
@@ -116458,17 +116759,36 @@ function presetRegistry(host) {
|
|
|
116458
116759
|
* caller still has to copy the bundled tree into the discovery root.
|
|
116459
116760
|
*/
|
|
116460
116761
|
function installDispatchPreset(host, resolves = resolvesFromHere) {
|
|
116762
|
+
return installPreset(DISPATCH_PRESET, host, resolves);
|
|
116763
|
+
}
|
|
116764
|
+
/**
|
|
116765
|
+
* Declare `team` to the running harness, when the harness has the mechanism.
|
|
116766
|
+
* @param host - plugin context: service lookup, effect seam, and logger.
|
|
116767
|
+
* @param resolves - whether a bare specifier resolves in this installation.
|
|
116768
|
+
* @returns `'registered'` when this call took the preset, `'legacy'` otherwise.
|
|
116769
|
+
*/
|
|
116770
|
+
function installTeamPreset(host, resolves = resolvesFromHere) {
|
|
116771
|
+
return installPreset(TEAM_PRESET, host, resolves);
|
|
116772
|
+
}
|
|
116773
|
+
/**
|
|
116774
|
+
* The shared install path for every preset this plugin declares.
|
|
116775
|
+
* @param definition - the preset to declare.
|
|
116776
|
+
* @param host - plugin context: service lookup, effect seam, and logger.
|
|
116777
|
+
* @param resolves - whether a bare specifier resolves in this installation.
|
|
116778
|
+
* @returns `'registered'` when this call took the preset, `'legacy'` otherwise.
|
|
116779
|
+
*/
|
|
116780
|
+
function installPreset(definition, host, resolves) {
|
|
116461
116781
|
try {
|
|
116462
116782
|
if (!resolves("@deepseek-ai/dsh-agent-preset")) return "legacy";
|
|
116463
116783
|
const registry = presetRegistry(host);
|
|
116464
116784
|
if (registry === void 0) {
|
|
116465
|
-
host.logger.warn(`[dsh-chatgpt-subscription] agent preset "${
|
|
116785
|
+
host.logger.warn(`[dsh-chatgpt-subscription] agent preset "${definition.id}" fell back to the preset root: ${PRESET_REGISTRY_PACKAGE} is installed but no agentPresets service is available`);
|
|
116466
116786
|
return "legacy";
|
|
116467
116787
|
}
|
|
116468
|
-
host.effect(() =>
|
|
116788
|
+
host.effect(() => registerPreset(definition, host, registry, resolves), `dsh-chatgpt-subscription: ${definition.id} agent preset`);
|
|
116469
116789
|
return "registered";
|
|
116470
116790
|
} catch (error) {
|
|
116471
|
-
host.logger.warn(`[dsh-chatgpt-subscription] agent preset "${
|
|
116791
|
+
host.logger.warn(`[dsh-chatgpt-subscription] agent preset "${definition.id}" could not be registered: ${messageOf(error)}`);
|
|
116472
116792
|
return "legacy";
|
|
116473
116793
|
}
|
|
116474
116794
|
}
|
|
@@ -116480,13 +116800,13 @@ function installDispatchPreset(host, resolves = resolvesFromHere) {
|
|
|
116480
116800
|
* @param resolves - whether a bare specifier resolves in this installation.
|
|
116481
116801
|
* @returns the harness's own unregister function, or a no-op after a failure.
|
|
116482
116802
|
*/
|
|
116483
|
-
async function
|
|
116803
|
+
async function registerPreset(definition, host, registry, resolves) {
|
|
116484
116804
|
try {
|
|
116485
|
-
const unregister = await registry.register(
|
|
116486
|
-
host.logger.info(`[dsh-chatgpt-subscription] agent preset "${
|
|
116805
|
+
const unregister = await registry.register(resolvePreset(definition, resolves));
|
|
116806
|
+
host.logger.info(`[dsh-chatgpt-subscription] agent preset "${definition.id}" registered with the running harness`);
|
|
116487
116807
|
return unregister;
|
|
116488
116808
|
} catch (error) {
|
|
116489
|
-
host.logger.warn(`[dsh-chatgpt-subscription] agent preset "${
|
|
116809
|
+
host.logger.warn(`[dsh-chatgpt-subscription] agent preset "${definition.id}" was not mounted: ${messageOf(error)}`);
|
|
116490
116810
|
return () => Promise.resolve();
|
|
116491
116811
|
}
|
|
116492
116812
|
}
|
|
@@ -135229,6 +135549,7 @@ function buildClaudeApiRequest(options, images, context) {
|
|
|
135229
135549
|
budget_tokens: budget
|
|
135230
135550
|
} : void 0;
|
|
135231
135551
|
}
|
|
135552
|
+
if (entry.thinkingMode === "adaptive" && fields.enabled) maxTokens = entry.maxOutputTokens;
|
|
135232
135553
|
const thinkingEnabled = thinking !== void 0 && thinking.type !== "disabled";
|
|
135233
135554
|
const tools = wireTools(options);
|
|
135234
135555
|
const messages = cleanOrphanedToolCalls(mergeEntries(entries), mergeEntries);
|
|
@@ -136982,7 +137303,17 @@ function apply(ctx, pluginConfig = {}) {
|
|
|
136982
137303
|
credentials: () => asCredentialsSeam(ctx.get("credentials")),
|
|
136983
137304
|
logger: ctx.logger
|
|
136984
137305
|
});
|
|
136985
|
-
if (pluginConfig.syncAgentPresets !== false) ctx.effect(() =>
|
|
137306
|
+
if (pluginConfig.syncAgentPresets !== false) ctx.effect(() => {
|
|
137307
|
+
const dispatchInstall = installDispatchPreset(ctx);
|
|
137308
|
+
const teamInstall = installTeamPreset(ctx);
|
|
137309
|
+
return installBundledPresets(ctx, dispatchInstall === "registered" && teamInstall === "registered" ? "registered" : "legacy");
|
|
137310
|
+
}, "dsh-chatgpt-subscription: agent preset sync");
|
|
137311
|
+
try {
|
|
137312
|
+
const swept = sweepTeamBoards();
|
|
137313
|
+
if (swept.removedFiles > 0 || swept.removedDirs > 0) ctx.logger.info("[dsh-chatgpt-subscription] removed " + String(swept.removedFiles) + " stale team board file(s) and " + String(swept.removedDirs) + " empty director(ies)");
|
|
137314
|
+
} catch (error) {
|
|
137315
|
+
ctx.logger.warn("[dsh-chatgpt-subscription] team board sweep skipped: " + String(error));
|
|
137316
|
+
}
|
|
136986
137317
|
attachProgressSettings(() => resolveProgressUpdatesSettings(pluginConfig));
|
|
136987
137318
|
attachPlanModePipelineSettings(() => resolvePlanModePipelineEnabled(pluginConfig));
|
|
136988
137319
|
ctx.effect(() => installAdvisor(ctx, pluginConfig), "dsh-chatgpt-subscription: advisor");
|