open-multi-agent-kit 0.98.2 → 0.98.4
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 +45 -0
- package/README.md +11 -2
- package/dist/cli/args.d.ts +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +14 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +3 -0
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/mcp-attach.d.ts +3 -3
- package/dist/cli/mcp-attach.d.ts.map +1 -1
- package/dist/cli/mcp-attach.js +5 -4
- package/dist/cli/mcp-attach.js.map +1 -1
- package/dist/cli/model-contract.d.ts +5 -0
- package/dist/cli/model-contract.d.ts.map +1 -0
- package/dist/cli/model-contract.js +45 -0
- package/dist/cli/model-contract.js.map +1 -0
- package/dist/commands/adaptorch-doctor-cli.d.ts.map +1 -1
- package/dist/commands/adaptorch-doctor-cli.js +32 -10
- package/dist/commands/adaptorch-doctor-cli.js.map +1 -1
- package/dist/commands/init-cli.d.ts +12 -0
- package/dist/commands/init-cli.d.ts.map +1 -0
- package/dist/commands/init-cli.js +76 -0
- package/dist/commands/init-cli.js.map +1 -0
- package/dist/commands/provider-sync-cli.d.ts +27 -0
- package/dist/commands/provider-sync-cli.d.ts.map +1 -0
- package/dist/commands/provider-sync-cli.js +177 -0
- package/dist/commands/provider-sync-cli.js.map +1 -0
- package/dist/commands/run-command.d.ts +8 -0
- package/dist/commands/run-command.d.ts.map +1 -0
- package/dist/commands/run-command.js +26 -0
- package/dist/commands/run-command.js.map +1 -0
- package/dist/core/active-skill-state.d.ts +7 -0
- package/dist/core/active-skill-state.d.ts.map +1 -0
- package/dist/core/active-skill-state.js +25 -0
- package/dist/core/active-skill-state.js.map +1 -0
- package/dist/core/advisory-judge-model.d.ts.map +1 -1
- package/dist/core/advisory-judge-model.js +8 -1
- package/dist/core/advisory-judge-model.js.map +1 -1
- package/dist/core/advisory-judge-types.d.ts +18 -1
- package/dist/core/advisory-judge-types.d.ts.map +1 -1
- package/dist/core/advisory-judge-types.js.map +1 -1
- package/dist/core/advisory-judge.d.ts.map +1 -1
- package/dist/core/advisory-judge.js +41 -6
- package/dist/core/advisory-judge.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +2 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +2 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +0 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +30 -85
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/codex-chatgpt-web-bridge.d.ts +99 -0
- package/dist/core/codex-chatgpt-web-bridge.d.ts.map +1 -0
- package/dist/core/codex-chatgpt-web-bridge.js +192 -0
- package/dist/core/codex-chatgpt-web-bridge.js.map +1 -0
- package/dist/core/codex-chatgpt-web-sync.d.ts +50 -0
- package/dist/core/codex-chatgpt-web-sync.d.ts.map +1 -0
- package/dist/core/codex-chatgpt-web-sync.js +119 -0
- package/dist/core/codex-chatgpt-web-sync.js.map +1 -0
- package/dist/core/compaction/compaction-headroom.d.ts +30 -0
- package/dist/core/compaction/compaction-headroom.d.ts.map +1 -0
- package/dist/core/compaction/compaction-headroom.js +48 -0
- package/dist/core/compaction/compaction-headroom.js.map +1 -0
- package/dist/core/compaction/compaction.d.ts +2 -29
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +19 -47
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/overflow-retry-guard.d.ts +20 -0
- package/dist/core/compaction/overflow-retry-guard.d.ts.map +1 -0
- package/dist/core/compaction/overflow-retry-guard.js +38 -0
- package/dist/core/compaction/overflow-retry-guard.js.map +1 -0
- package/dist/core/context-budget-headroom-types.d.ts.map +1 -1
- package/dist/core/context-budget-headroom-types.js +1 -1
- package/dist/core/context-budget-headroom-types.js.map +1 -1
- package/dist/core/context-budget-token-counter-types.d.ts +27 -0
- package/dist/core/context-budget-token-counter-types.d.ts.map +1 -0
- package/dist/core/context-budget-token-counter-types.js +2 -0
- package/dist/core/context-budget-token-counter-types.js.map +1 -0
- package/dist/core/context-budget-token-counter.d.ts +2 -26
- package/dist/core/context-budget-token-counter.d.ts.map +1 -1
- package/dist/core/context-budget-token-counter.js +2 -0
- package/dist/core/context-budget-token-counter.js.map +1 -1
- package/dist/core/context-budget-v2-scoring.d.ts.map +1 -1
- package/dist/core/context-budget-v2-scoring.js +14 -10
- package/dist/core/context-budget-v2-scoring.js.map +1 -1
- package/dist/core/domain-router.d.ts.map +1 -1
- package/dist/core/domain-router.js +1 -1
- package/dist/core/domain-router.js.map +1 -1
- package/dist/core/grok-harness-dispatch.d.ts +4 -0
- package/dist/core/grok-harness-dispatch.d.ts.map +1 -1
- package/dist/core/grok-harness-dispatch.js +20 -3
- package/dist/core/grok-harness-dispatch.js.map +1 -1
- package/dist/core/grok-harness.d.ts +15 -9
- package/dist/core/grok-harness.d.ts.map +1 -1
- package/dist/core/grok-harness.js +34 -8
- package/dist/core/grok-harness.js.map +1 -1
- package/dist/core/mcp/tools.d.ts +2 -2
- package/dist/core/mcp/tools.d.ts.map +1 -1
- package/dist/core/mcp/tools.js +29 -3
- package/dist/core/mcp/tools.js.map +1 -1
- package/dist/core/model-registry-schema.d.ts +1081 -0
- package/dist/core/model-registry-schema.d.ts.map +1 -0
- package/dist/core/model-registry-schema.js +148 -0
- package/dist/core/model-registry-schema.js.map +1 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +1 -146
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts +2 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +2 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/prompt-preset.d.ts +1 -1
- package/dist/core/prompt-preset.d.ts.map +1 -1
- package/dist/core/prompt-preset.js +16 -1
- package/dist/core/prompt-preset.js.map +1 -1
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +1 -0
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/provider-resilience.d.ts +8 -0
- package/dist/core/provider-resilience.d.ts.map +1 -1
- package/dist/core/provider-resilience.js +20 -3
- package/dist/core/provider-resilience.js.map +1 -1
- package/dist/core/provider-usage-types.d.ts +42 -0
- package/dist/core/provider-usage-types.d.ts.map +1 -0
- package/dist/core/provider-usage-types.js +2 -0
- package/dist/core/provider-usage-types.js.map +1 -0
- package/dist/core/provider-usage.d.ts +2 -31
- package/dist/core/provider-usage.d.ts.map +1 -1
- package/dist/core/provider-usage.js +4 -0
- package/dist/core/provider-usage.js.map +1 -1
- package/dist/core/redaction.d.ts.map +1 -1
- package/dist/core/redaction.js +18 -2
- package/dist/core/redaction.js.map +1 -1
- package/dist/core/sandbox/policy-merge.d.ts +6 -0
- package/dist/core/sandbox/policy-merge.d.ts.map +1 -0
- package/dist/core/sandbox/policy-merge.js +74 -0
- package/dist/core/sandbox/policy-merge.js.map +1 -0
- package/dist/core/sandbox/policy-paths.d.ts +4 -0
- package/dist/core/sandbox/policy-paths.d.ts.map +1 -0
- package/dist/core/sandbox/policy-paths.js +21 -0
- package/dist/core/sandbox/policy-paths.js.map +1 -0
- package/dist/core/sandbox/policy-types.d.ts +75 -0
- package/dist/core/sandbox/policy-types.d.ts.map +1 -0
- package/dist/core/sandbox/policy-types.js +2 -0
- package/dist/core/sandbox/policy-types.js.map +1 -0
- package/dist/core/sandbox/policy.d.ts +3 -77
- package/dist/core/sandbox/policy.d.ts.map +1 -1
- package/dist/core/sandbox/policy.js +3 -98
- package/dist/core/sandbox/policy.js.map +1 -1
- package/dist/core/sdk-provider-stream.d.ts +14 -0
- package/dist/core/sdk-provider-stream.d.ts.map +1 -0
- package/dist/core/sdk-provider-stream.js +38 -0
- package/dist/core/sdk-provider-stream.js.map +1 -0
- package/dist/core/sdk.d.ts +5 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +17 -33
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-bash-runtime.d.ts +7 -0
- package/dist/core/session-bash-runtime.d.ts.map +1 -1
- package/dist/core/session-bash-runtime.js +10 -1
- package/dist/core/session-bash-runtime.js.map +1 -1
- package/dist/core/session-failure-cause.d.ts.map +1 -1
- package/dist/core/session-failure-cause.js +10 -3
- package/dist/core/session-failure-cause.js.map +1 -1
- package/dist/core/session-run-termination.d.ts +18 -0
- package/dist/core/session-run-termination.d.ts.map +1 -0
- package/dist/core/session-run-termination.js +61 -0
- package/dist/core/session-run-termination.js.map +1 -0
- package/dist/core/session-termination.d.ts.map +1 -1
- package/dist/core/session-termination.js +1 -1
- package/dist/core/session-termination.js.map +1 -1
- package/dist/core/skill-selector.d.ts +40 -0
- package/dist/core/skill-selector.d.ts.map +1 -0
- package/dist/core/skill-selector.js +102 -0
- package/dist/core/skill-selector.js.map +1 -0
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +2 -4
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/turn-metrics-record.d.ts +55 -0
- package/dist/core/turn-metrics-record.d.ts.map +1 -0
- package/dist/core/turn-metrics-record.js +149 -0
- package/dist/core/turn-metrics-record.js.map +1 -0
- package/dist/core/turn-metrics.d.ts +4 -56
- package/dist/core/turn-metrics.d.ts.map +1 -1
- package/dist/core/turn-metrics.js +12 -60
- package/dist/core/turn-metrics.js.map +1 -1
- package/dist/core/verified-bash-runtime.d.ts +40 -0
- package/dist/core/verified-bash-runtime.d.ts.map +1 -1
- package/dist/core/verified-bash-runtime.js +60 -13
- package/dist/core/verified-bash-runtime.js.map +1 -1
- package/dist/guardrails/evidence-system.d.ts +1 -1
- package/dist/guardrails/evidence-system.d.ts.map +1 -1
- package/dist/guardrails/evidence-system.js +18 -29
- package/dist/guardrails/evidence-system.js.map +1 -1
- package/dist/guardrails/merge-gate-result.d.ts +4 -0
- package/dist/guardrails/merge-gate-result.d.ts.map +1 -0
- package/dist/guardrails/merge-gate-result.js +32 -0
- package/dist/guardrails/merge-gate-result.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +22 -22
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/interactive-login-options.d.ts +27 -0
- package/dist/modes/interactive/interactive-login-options.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-login-options.js +54 -0
- package/dist/modes/interactive/interactive-login-options.js.map +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts +7 -4
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +138 -140
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/interactive-resume-command.d.ts +3 -0
- package/dist/modes/interactive/interactive-resume-command.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-resume-command.js +24 -0
- package/dist/modes/interactive/interactive-resume-command.js.map +1 -0
- package/dist/modes/interactive/interactive-tool-result.d.ts +32 -0
- package/dist/modes/interactive/interactive-tool-result.d.ts.map +1 -0
- package/dist/modes/interactive/interactive-tool-result.js +59 -0
- package/dist/modes/interactive/interactive-tool-result.js.map +1 -0
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +22 -0
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/utils/clipboard-image.d.ts.map +1 -1
- package/dist/utils/clipboard-image.js +10 -60
- package/dist/utils/clipboard-image.js.map +1 -1
- package/dist/utils/terminal-links.d.ts +13 -0
- package/dist/utils/terminal-links.d.ts.map +1 -0
- package/dist/utils/terminal-links.js +68 -0
- package/dist/utils/terminal-links.js.map +1 -0
- package/dist/utils/windows-clipboard-image.d.ts +16 -0
- package/dist/utils/windows-clipboard-image.d.ts.map +1 -0
- package/dist/utils/windows-clipboard-image.js +87 -0
- package/dist/utils/windows-clipboard-image.js.map +1 -0
- package/docs/adaptorch-onboarding.md +80 -0
- package/docs/advisory-selection.md +112 -0
- package/docs/containerization.md +12 -0
- package/docs/context-files.md +97 -0
- package/docs/correctness-wall.md +8 -0
- package/docs/custom-provider.md +35 -0
- package/docs/development.md +18 -3
- package/docs/environment-variables.md +2 -0
- package/docs/grok-harness.md +4 -0
- package/docs/harness-boundaries.md +154 -0
- package/docs/harness-improvements.md +90 -0
- package/docs/json.md +19 -0
- package/docs/keybindings.md +1 -1
- package/docs/mcp.md +22 -2
- package/docs/metrics.md +66 -16
- package/docs/model-catalog-refresh.md +190 -0
- package/docs/model-contract.md +168 -0
- package/docs/models.md +21 -4
- package/docs/provider-resilience.md +5 -3
- package/docs/providers.md +68 -1
- package/docs/quickstart.md +4 -0
- package/docs/release-audit-0.98.3.md +97 -0
- package/docs/release-audit-0.98.4.md +112 -0
- package/docs/review-bundle-followup.md +195 -0
- package/docs/run-protocol.md +3 -1
- package/docs/runtime-algorithms.md +38 -2
- package/docs/sdk.md +35 -3
- package/docs/sessions.md +1 -1
- package/docs/settings.md +17 -1
- package/docs/skills.md +2 -0
- package/docs/tb21-audit.md +131 -0
- package/docs/terminal-setup.md +20 -0
- package/docs/usage.md +23 -1
- package/docs/windows.md +48 -0
- package/examples/README.md +4 -0
- package/examples/context/AGENTS.md +64 -0
- package/examples/context/CLAUDE.md +17 -0
- package/examples/context/INTERNET.md +42 -0
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +18 -18
- package/package.json +6 -6
|
@@ -24,6 +24,7 @@ import { stripFrontmatter } from "../utils/frontmatter.js";
|
|
|
24
24
|
import { resolvePath } from "../utils/paths.js";
|
|
25
25
|
import { getShellConfig } from "../utils/shell.js";
|
|
26
26
|
import { sleep } from "../utils/sleep.js";
|
|
27
|
+
import { addActiveSkills, createActiveSkillState } from "./active-skill-state.js";
|
|
27
28
|
import { createAdaptorchBridge } from "./adaptorch-bridge.js";
|
|
28
29
|
import { applyCategoryTimeoutDefaults, resolveAgentToolSettings, resolveToolTimeoutCategory, } from "./agent-tool-settings.js";
|
|
29
30
|
import { formatNoApiKeyFoundMessage, formatNoModelSelectedMessage } from "./auth-guidance.js";
|
|
@@ -43,7 +44,7 @@ import { exportSessionToHtml } from "./export-html/index.js";
|
|
|
43
44
|
import { createToolHtmlRenderer } from "./export-html/tool-renderer.js";
|
|
44
45
|
import { ExtensionRunner, wrapRegisteredTools, } from "./extensions/index.js";
|
|
45
46
|
import { emitSessionShutdownEvent } from "./extensions/runner.js";
|
|
46
|
-
import { assertTextChatModelForCompletion } from "./grok-harness.js";
|
|
47
|
+
import { assertTextChatModelForCompletion, grokHarnessAutoApplyEnabled, isGrokOAuthProvider, selectGrokHarnessSkills, } from "./grok-harness.js";
|
|
47
48
|
import { grokPlaybookAppendForProvider } from "./grok-playbook.js";
|
|
48
49
|
import { captureHostResourceSnapshot } from "./host-resource-snapshot.js";
|
|
49
50
|
import { decideLoadoutAccess } from "./loadout-access-policy.js";
|
|
@@ -107,9 +108,10 @@ import { RunResourceLeaseController } from "./run-resource-lease.js";
|
|
|
107
108
|
import { SessionBashRuntime } from "./session-bash-runtime.js";
|
|
108
109
|
import { SessionBashService } from "./session-bash-service.js";
|
|
109
110
|
import { SessionCompactionService } from "./session-compaction-service.js";
|
|
110
|
-
import { preflightFailureCause,
|
|
111
|
+
import { preflightFailureCause, runtimeFailureCause, terminationMessage } from "./session-failure-cause.js";
|
|
111
112
|
import { CURRENT_SESSION_VERSION, getLatestCompactionEntry } from "./session-manager.js";
|
|
112
113
|
import { acquireSessionOwnerLeaseSync } from "./session-owner-lease.js";
|
|
114
|
+
import { classifyRunTermination } from "./session-run-termination.js";
|
|
113
115
|
import { assembleSessionSystemPrompt } from "./session-system-prompt.js";
|
|
114
116
|
import { classifySessionTermination, } from "./session-termination.js";
|
|
115
117
|
import { createSyntheticSourceInfo } from "./source-info.js";
|
|
@@ -136,17 +138,6 @@ export function parseSkillBlock(text) {
|
|
|
136
138
|
userMessage: match[4]?.trim() || undefined,
|
|
137
139
|
};
|
|
138
140
|
}
|
|
139
|
-
function mergePromptActiveSkillNames(first, second) {
|
|
140
|
-
const names = [];
|
|
141
|
-
const seen = new Set();
|
|
142
|
-
for (const name of [...first, ...second]) {
|
|
143
|
-
if (!seen.has(name)) {
|
|
144
|
-
seen.add(name);
|
|
145
|
-
names.push(name);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return names;
|
|
149
|
-
}
|
|
150
141
|
const PENDING_TOOL_RESULT_TOKENS = {
|
|
151
142
|
text: 1024,
|
|
152
143
|
image: 4096,
|
|
@@ -515,64 +506,6 @@ export class AgentSession {
|
|
|
515
506
|
});
|
|
516
507
|
this._appendReplayEvent(event, details);
|
|
517
508
|
}
|
|
518
|
-
_classifyRunTermination(runId, event) {
|
|
519
|
-
const timestamp = new Date().toISOString();
|
|
520
|
-
let assistant;
|
|
521
|
-
for (let index = event.messages.length - 1; index >= 0; index -= 1) {
|
|
522
|
-
const message = event.messages[index];
|
|
523
|
-
if (message?.role === "assistant") {
|
|
524
|
-
assistant = message;
|
|
525
|
-
break;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
let cause;
|
|
529
|
-
let message;
|
|
530
|
-
let sideEffects = this._sessionRiskLevel === "elevated" ? "possible" : "none";
|
|
531
|
-
let toolCallId;
|
|
532
|
-
let toolName;
|
|
533
|
-
if (this._activeRunToolTermination) {
|
|
534
|
-
cause = { area: "tool", code: "timeout" };
|
|
535
|
-
message = `Tool ${this._activeRunToolTermination.toolName} timed out.`;
|
|
536
|
-
toolCallId = this._activeRunToolTermination.toolCallId;
|
|
537
|
-
toolName = this._activeRunToolTermination.toolName;
|
|
538
|
-
sideEffects = this._activeRunToolTermination.executionStarted ? "possible" : sideEffects;
|
|
539
|
-
}
|
|
540
|
-
else if (!assistant) {
|
|
541
|
-
cause = { area: "internal", code: "unclassified" };
|
|
542
|
-
message = "Agent run ended without an assistant result.";
|
|
543
|
-
}
|
|
544
|
-
else if (assistant.stopReason === "aborted") {
|
|
545
|
-
cause = this._userAbortRequested ? { area: "user", code: "abort" } : { area: "provider", code: "abort" };
|
|
546
|
-
message = terminationMessage(assistant.errorMessage, this._userAbortRequested ? "The user aborted the run." : "The provider aborted the run.");
|
|
547
|
-
}
|
|
548
|
-
else if (assistant.stopReason === "error") {
|
|
549
|
-
cause = providerFailureCause(assistant, this.model?.contextWindow ?? 0);
|
|
550
|
-
message = terminationMessage(assistant.errorMessage, "The provider request failed.");
|
|
551
|
-
}
|
|
552
|
-
else {
|
|
553
|
-
cause = { area: "completed" };
|
|
554
|
-
message = "Run completed.";
|
|
555
|
-
}
|
|
556
|
-
let provider = this.model?.provider;
|
|
557
|
-
if (assistant?.provider)
|
|
558
|
-
provider = assistant.provider;
|
|
559
|
-
let model = this.model?.id;
|
|
560
|
-
if (assistant?.model)
|
|
561
|
-
model = assistant.model;
|
|
562
|
-
return classifySessionTermination({
|
|
563
|
-
sessionId: this.sessionId,
|
|
564
|
-
runId,
|
|
565
|
-
timestamp,
|
|
566
|
-
source: "observed",
|
|
567
|
-
message,
|
|
568
|
-
cause,
|
|
569
|
-
sideEffects,
|
|
570
|
-
...(provider ? { provider } : {}),
|
|
571
|
-
...(model ? { model } : {}),
|
|
572
|
-
...(toolCallId ? { toolCallId } : {}),
|
|
573
|
-
...(toolName ? { toolName } : {}),
|
|
574
|
-
});
|
|
575
|
-
}
|
|
576
509
|
_publishTermination(termination) {
|
|
577
510
|
this._lastTermination = termination;
|
|
578
511
|
this._emit({ type: "session_termination", termination });
|
|
@@ -647,11 +580,23 @@ export class AgentSession {
|
|
|
647
580
|
}
|
|
648
581
|
return;
|
|
649
582
|
}
|
|
583
|
+
if (event.type === "provider_denied" && event.deniedReason === "contract-violation") {
|
|
584
|
+
this._pendingRuntimeTerminationCause = { area: "configuration", code: "invalid" };
|
|
585
|
+
}
|
|
650
586
|
if (event.type !== "agent_end")
|
|
651
587
|
return;
|
|
652
588
|
if (this._activeRunId === null)
|
|
653
589
|
throw new Error("run journal received agent_end without run_started");
|
|
654
|
-
const termination =
|
|
590
|
+
const termination = classifyRunTermination(event.messages, {
|
|
591
|
+
sessionId: this.sessionId,
|
|
592
|
+
runId: this._activeRunId,
|
|
593
|
+
timestamp: new Date().toISOString(),
|
|
594
|
+
model: this.model,
|
|
595
|
+
elevatedRisk: this._sessionRiskLevel === "elevated",
|
|
596
|
+
userAbortRequested: this._userAbortRequested,
|
|
597
|
+
pendingCause: this._pendingRuntimeTerminationCause,
|
|
598
|
+
toolTimeout: this._activeRunToolTermination,
|
|
599
|
+
});
|
|
655
600
|
try {
|
|
656
601
|
this._runJournalStore.finish({
|
|
657
602
|
termination,
|
|
@@ -1815,12 +1760,7 @@ export class AgentSession {
|
|
|
1815
1760
|
const preflightResult = options?.preflightResult;
|
|
1816
1761
|
let currentText = redactSensitiveText(text);
|
|
1817
1762
|
const defaultActiveSkills = this._getDefaultActiveSkills();
|
|
1818
|
-
let
|
|
1819
|
-
let promptActiveSkillSource = defaultActiveSkills.length > 0
|
|
1820
|
-
? options?.activeSkillSource
|
|
1821
|
-
? `settings+${options.activeSkillSource}`
|
|
1822
|
-
: "settings"
|
|
1823
|
-
: options?.activeSkillSource;
|
|
1763
|
+
let promptSkills = createActiveSkillState(defaultActiveSkills, options?.activeSkillNames ?? [], options?.activeSkillSource);
|
|
1824
1764
|
let isBangSkillInvocation = false;
|
|
1825
1765
|
if (expandPromptTemplates) {
|
|
1826
1766
|
const bangInvocation = parseBangInvocation(text, {
|
|
@@ -1831,9 +1771,7 @@ export class AgentSession {
|
|
|
1831
1771
|
currentText = bangInvocation.prompt
|
|
1832
1772
|
? `/skill:${bangInvocation.skillName} ${bangInvocation.prompt}`
|
|
1833
1773
|
: `/skill:${bangInvocation.skillName}`;
|
|
1834
|
-
|
|
1835
|
-
promptActiveSkillSource =
|
|
1836
|
-
defaultActiveSkills.length > 0 ? `settings+${bangInvocation.source}` : bangInvocation.source;
|
|
1774
|
+
promptSkills = addActiveSkills(promptSkills, bangInvocation.activeSkillNames, bangInvocation.source);
|
|
1837
1775
|
}
|
|
1838
1776
|
}
|
|
1839
1777
|
let messages;
|
|
@@ -1934,11 +1872,18 @@ export class AgentSession {
|
|
|
1934
1872
|
messages.push(msg);
|
|
1935
1873
|
}
|
|
1936
1874
|
this._pendingNextTurnMessages = [];
|
|
1875
|
+
if (isGrokOAuthProvider(this.model?.provider) && grokHarnessAutoApplyEnabled(process.env)) {
|
|
1876
|
+
const skillQuery = isBangSkillInvocation ? currentText : expandedText;
|
|
1877
|
+
const grokSkills = selectGrokHarnessSkills(skillQuery, this._resourceLoader.getSkills().skills, {
|
|
1878
|
+
contextPressure: this._computePressureBucket(messages) > 0,
|
|
1879
|
+
});
|
|
1880
|
+
promptSkills = addActiveSkills(promptSkills, grokSkills, "grok-harness");
|
|
1881
|
+
}
|
|
1937
1882
|
const turnSystemPromptOptions = {
|
|
1938
1883
|
...this._baseSystemPromptOptions,
|
|
1939
1884
|
contextBudget: this._getContextBudgetOptions(expandedText),
|
|
1940
|
-
activeSkillNames:
|
|
1941
|
-
activeSkillSource:
|
|
1885
|
+
activeSkillNames: promptSkills.names,
|
|
1886
|
+
activeSkillSource: promptSkills.source,
|
|
1942
1887
|
};
|
|
1943
1888
|
const turnSystemPrompt = buildSystemPromptPlan(turnSystemPromptOptions);
|
|
1944
1889
|
// Emit before_agent_start extension event
|
|
@@ -2573,11 +2518,11 @@ export class AgentSession {
|
|
|
2573
2518
|
* 1..<0.75, 2..<0.9, 3..>=0.9. The released default pressure coefficient
|
|
2574
2519
|
* is 1 and participates only after the classifier has prompt evidence.
|
|
2575
2520
|
*/
|
|
2576
|
-
_computePressureBucket() {
|
|
2521
|
+
_computePressureBucket(pendingMessages = []) {
|
|
2577
2522
|
const contextWindow = this.model?.contextWindow ?? 0;
|
|
2578
2523
|
if (contextWindow <= 0)
|
|
2579
2524
|
return 0;
|
|
2580
|
-
const estimate = estimateProjectedContextTokens(this.agent.state.messages,
|
|
2525
|
+
const estimate = estimateProjectedContextTokens(this.agent.state.messages, pendingMessages);
|
|
2581
2526
|
const pressure = estimate.tokens / contextWindow;
|
|
2582
2527
|
if (pressure >= 0.9)
|
|
2583
2528
|
return 3;
|