@octopi-agent/engine 0.86.38 → 0.97.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/dist/config-admin/agent-presets.d.ts +70 -0
- package/dist/config-admin/agent-presets.js +243 -0
- package/dist/config-admin/discover.d.ts +30 -0
- package/dist/config-admin/discover.js +48 -0
- package/dist/config-admin/env.d.ts +22 -0
- package/dist/config-admin/env.js +41 -0
- package/dist/config-admin/index.d.ts +20 -0
- package/dist/config-admin/index.js +15 -0
- package/dist/config-admin/model-presets.d.ts +75 -0
- package/dist/config-admin/model-presets.js +249 -0
- package/dist/config-admin/name-guard.d.ts +14 -0
- package/dist/config-admin/name-guard.js +24 -0
- package/dist/config-admin/patch.d.ts +56 -0
- package/dist/config-admin/patch.js +201 -0
- package/dist/config-admin/port.d.ts +68 -0
- package/dist/config-admin/port.js +21 -0
- package/dist/config-admin/redact.d.ts +39 -0
- package/dist/config-admin/redact.js +42 -0
- package/dist/config-schema/agent.d.ts +43 -1
- package/dist/config-schema/agent.js +12 -5
- package/dist/config-schema/context.d.ts +7 -2
- package/dist/config-schema/context.js +8 -0
- package/dist/config-schema/engine.d.ts +110 -8
- package/dist/config-schema/governance.d.ts +43 -1
- package/dist/config-schema/governance.js +160 -2
- package/dist/config-schema/models.d.ts +7 -4
- package/dist/config-schema/models.js +4 -1
- package/dist/config-schema/observability.d.ts +9 -0
- package/dist/config-schema/observability.js +29 -0
- package/dist/config-schema/run.d.ts +3 -0
- package/dist/config-schema/run.js +14 -0
- package/dist/config-schema/shared.d.ts +3 -0
- package/dist/config-schema/shared.js +12 -0
- package/dist/config-schema/substrate.d.ts +1 -1
- package/dist/config.d.ts +60 -13
- package/dist/config.js +81 -78
- package/dist/harness/activation/dispatcher.d.ts +8 -2
- package/dist/harness/activation/dispatcher.js +33 -5
- package/dist/harness/activation/inbox.d.ts +87 -0
- package/dist/harness/activation/inbox.js +169 -0
- package/dist/harness/activation/runtime.d.ts +9 -8
- package/dist/harness/activation/runtime.js +100 -8
- package/dist/harness/activation/types.d.ts +19 -0
- package/dist/harness/activation/types.js +2 -0
- package/dist/harness/agent/builder.d.ts +18 -3
- package/dist/harness/agent/builder.js +42 -17
- package/dist/harness/agent/config-bridge.d.ts +5 -0
- package/dist/harness/agent/config-bridge.js +7 -1
- package/dist/harness/agent/config-integrity.d.ts +72 -0
- package/dist/harness/agent/config-integrity.js +146 -0
- package/dist/harness/agent/tool-purpose.d.ts +9 -1
- package/dist/harness/agent/tool-purpose.js +11 -2
- package/dist/harness/agent/wire-agent-builder.js +11 -3
- package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.d.ts +11 -1
- package/dist/harness/collaboration/autonomous-subsystem/boundary/validator.js +11 -1
- package/dist/harness/collaboration/autonomous-subsystem/loader.d.ts +13 -0
- package/dist/harness/collaboration/autonomous-subsystem/loader.js +16 -1
- package/dist/harness/collaboration/autonomous-subsystem/runtime.d.ts +4 -0
- package/dist/harness/collaboration/autonomous-subsystem/runtime.js +3 -1
- package/dist/harness/collaboration/autonomous-subsystem/think/executor.js +3 -1
- package/dist/harness/collaboration/delegation/child-run.js +21 -5
- package/dist/harness/collaboration/delegation/notifier.js +4 -3
- package/dist/harness/collaboration/delegation/service.js +2 -3
- package/dist/harness/collaboration/delegation/wiring.js +6 -5
- package/dist/harness/collaboration/orchestration/reflector/llm-reflector.d.ts +1 -1
- package/dist/harness/collaboration/orchestration/reflector/llm-reflector.js +1 -1
- package/dist/harness/context/capabilities/compact/engine.d.ts +30 -0
- package/dist/harness/context/capabilities/compact/engine.js +198 -46
- package/dist/harness/context/capabilities/compact/handover.d.ts +78 -0
- package/dist/harness/context/capabilities/compact/handover.js +107 -0
- package/dist/harness/context/capabilities/compact/index.d.ts +3 -1
- package/dist/harness/context/capabilities/compact/index.js +2 -1
- package/dist/harness/context/capabilities/compact/types.d.ts +30 -1
- package/dist/harness/context/capabilities/summary/executor.js +2 -1
- package/dist/harness/context/capabilities/summary/policies.js +8 -5
- package/dist/harness/context/constitution/default-agents.md +11 -10
- package/dist/harness/context/default-context-engine.d.ts +34 -4
- package/dist/harness/context/default-context-engine.js +198 -53
- package/dist/harness/context/hybrid-compressor.js +6 -0
- package/dist/harness/context/layer-types.d.ts +36 -0
- package/dist/harness/context/layer-types.js +38 -0
- package/dist/harness/context/llm-summarizer.d.ts +2 -8
- package/dist/harness/context/llm-summarizer.js +69 -91
- package/dist/harness/context/message-selector.js +4 -3
- package/dist/harness/context/root-instructions.js +1 -1
- package/dist/harness/context/summarize.d.ts +2 -0
- package/dist/harness/context/summarize.js +7 -2
- package/dist/harness/context/system-prompt-assembler.js +10 -4
- package/dist/harness/context/tool-result-aging.js +2 -2
- package/dist/harness/context/truncate-compressor.js +7 -0
- package/dist/harness/context/turn-envelope.d.ts +4 -3
- package/dist/harness/context/turn-envelope.js +4 -3
- package/dist/harness/context/types.d.ts +33 -1
- package/dist/harness/extension/execution-environment/dangerous-commands.d.ts +28 -0
- package/dist/harness/extension/execution-environment/dangerous-commands.js +129 -0
- package/dist/harness/extension/execution-environment/effect-policy.d.ts +133 -4
- package/dist/harness/extension/execution-environment/effect-policy.js +263 -14
- package/dist/harness/extension/execution-environment/index.d.ts +4 -2
- package/dist/harness/extension/execution-environment/index.js +2 -1
- package/dist/harness/extension/execution-environment/isolation.js +5 -1
- package/dist/harness/extension/execution-environment/kill-switch.d.ts +34 -0
- package/dist/harness/extension/execution-environment/kill-switch.js +46 -0
- package/dist/harness/extension/execution-environment/ops-audit.d.ts +200 -0
- package/dist/harness/extension/execution-environment/ops-audit.js +338 -0
- package/dist/harness/extension/execution-environment/privileged-exec.d.ts +158 -0
- package/dist/harness/extension/execution-environment/privileged-exec.js +418 -0
- package/dist/harness/extension/execution-environment/process-info.d.ts +180 -0
- package/dist/harness/extension/execution-environment/process-info.js +466 -0
- package/dist/harness/extension/execution-environment/process-isolation.d.ts +7 -0
- package/dist/harness/extension/execution-environment/process-isolation.js +9 -0
- package/dist/harness/extension/execution-environment/sandbox.d.ts +109 -0
- package/dist/harness/extension/execution-environment/sandbox.js +264 -29
- package/dist/harness/extension/execution-environment/tool-capabilities.d.ts +1 -1
- package/dist/harness/extension/execution-environment/tool-capabilities.js +6 -0
- package/dist/harness/extension/execution-environment/types.d.ts +19 -0
- package/dist/harness/extension/plugin-ecosystem/channel-types.d.ts +5 -0
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.d.ts +6 -0
- package/dist/harness/extension/plugin-ecosystem/tools/allowlisted-run.js +50 -0
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.d.ts +4 -5
- package/dist/harness/extension/plugin-ecosystem/tools/ask-user.js +5 -15
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.d.ts +3 -0
- package/dist/harness/extension/plugin-ecosystem/tools/builtin.js +53 -2
- package/dist/harness/extension/plugin-ecosystem/tools/file-search.js +10 -17
- package/dist/harness/extension/plugin-ecosystem/tools/git-runner.d.ts +31 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-runner.js +104 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-status-snapshot.d.ts +111 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-status-snapshot.js +197 -0
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.d.ts +8 -8
- package/dist/harness/extension/plugin-ecosystem/tools/git-tools.js +9 -100
- package/dist/harness/extension/plugin-ecosystem/tools/index.d.ts +6 -0
- package/dist/harness/extension/plugin-ecosystem/tools/index.js +4 -0
- package/dist/harness/extension/plugin-ecosystem/tools/privileged-tool.d.ts +43 -0
- package/dist/harness/extension/plugin-ecosystem/tools/privileged-tool.js +350 -0
- package/dist/harness/extension/plugin-ecosystem/tools/process-tools.d.ts +30 -0
- package/dist/harness/extension/plugin-ecosystem/tools/process-tools.js +137 -0
- package/dist/harness/governance/human-in-the-loop/decision-cache.d.ts +54 -4
- package/dist/harness/governance/human-in-the-loop/decision-cache.js +42 -16
- package/dist/harness/governance/security/temp-path.d.ts +9 -0
- package/dist/harness/governance/security/temp-path.js +13 -2
- package/dist/harness/governance/session-acl/seed-roles.js +14 -0
- package/dist/harness/index.d.ts +4 -0
- package/dist/harness/index.js +3 -0
- package/dist/harness/knowledge/file-identity.d.ts +8 -0
- package/dist/harness/knowledge/file-identity.js +26 -1
- package/dist/harness/knowledge/fts.js +1 -2
- package/dist/harness/knowledge/grounding.js +5 -5
- package/dist/harness/knowledge/index-store.d.ts +31 -4
- package/dist/harness/knowledge/index-store.js +180 -48
- package/dist/harness/knowledge/ingest.d.ts +115 -115
- package/dist/harness/knowledge/ingest.js +150 -150
- package/dist/harness/knowledge/knowledge-serve-child.js +1 -1
- package/dist/harness/knowledge/purge.js +4 -1
- package/dist/harness/memory/backfill-coverage.js +3 -1
- package/dist/harness/memory/sqlite/keyword-search.d.ts +1 -0
- package/dist/harness/memory/sqlite/keyword-search.js +4 -3
- package/dist/harness/observability/observer/hub.js +38 -1
- package/dist/harness/observability/observer/run-snapshot.js +1 -0
- package/dist/harness/observability/observer/types.d.ts +27 -0
- package/dist/harness/run/agent/agent.d.ts +7 -0
- package/dist/harness/run/agent/agent.js +23 -1
- package/dist/harness/run/reliability/fallback-provider.d.ts +117 -5
- package/dist/harness/run/reliability/fallback-provider.js +262 -22
- package/dist/harness/run/reliability/harness-events.d.ts +24 -1
- package/dist/harness/run/reliability/model-error-policy.d.ts +32 -0
- package/dist/harness/run/reliability/model-error-policy.js +42 -0
- package/dist/harness/run/reliability/provider-wrapper.js +29 -2
- package/dist/harness/run/reliability/refusal-guard.d.ts +20 -0
- package/dist/harness/run/reliability/refusal-guard.js +102 -0
- package/dist/harness/run/reliability/run-agent.js +231 -33
- package/dist/harness/run/run-guard/default-run-guard.js +1 -1
- package/dist/harness/run/run-scope.d.ts +31 -0
- package/dist/harness/run/runner.d.ts +132 -2
- package/dist/harness/run/runner.js +679 -60
- package/dist/harness/session/attachments/llm-intent.js +2 -1
- package/dist/harness/session/history/port.js +15 -5
- package/dist/harness/session/in-memory-store.d.ts +5 -0
- package/dist/harness/session/in-memory-store.js +33 -2
- package/dist/harness/session/tasks/render.d.ts +4 -1
- package/dist/harness/session/tasks/render.js +10 -7
- package/dist/harness/session/title.js +25 -9
- package/dist/harness/shared/events/agent-event-map.d.ts +92 -0
- package/dist/harness/shared/events/agent-event-map.js +7 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +4 -3
- package/dist/integration/agent-runtime/channel-message-source.js +19 -1
- package/dist/integration/index.d.ts +2 -0
- package/dist/integration/index.js +1 -0
- package/dist/integration/observability/loop-watchdog.d.ts +56 -0
- package/dist/integration/observability/loop-watchdog.js +177 -0
- package/dist/integration/observability/metrics.d.ts +3 -0
- package/dist/integration/observability/metrics.js +18 -7
- package/dist/integration/observability/run-telemetry.d.ts +8 -0
- package/dist/integration/observability/run-telemetry.js +31 -8
- package/dist/integration/observability/trace-collector.js +26 -4
- package/dist/integration/observability/trace-events.d.ts +1 -0
- package/dist/integration/observability/trace-events.js +2 -0
- package/dist/integration/observability/trace-logger.js +27 -17
- package/dist/integration/providers/anthropic.d.ts +23 -0
- package/dist/integration/providers/anthropic.js +97 -12
- package/dist/integration/providers/fetch-timeout.d.ts +42 -0
- package/dist/integration/providers/fetch-timeout.js +51 -0
- package/dist/integration/providers/openai.d.ts +10 -0
- package/dist/integration/providers/openai.js +58 -11
- package/dist/integration/providers/provider-diagnostics.d.ts +80 -0
- package/dist/integration/providers/provider-diagnostics.js +89 -0
- package/dist/integration/providers/timeout-coherence.d.ts +52 -0
- package/dist/integration/providers/timeout-coherence.js +68 -0
- package/dist/integration/providers/wire-dump.d.ts +62 -0
- package/dist/integration/providers/wire-dump.js +111 -2
- package/dist/integration/storage/jsonl.d.ts +19 -1
- package/dist/integration/storage/jsonl.js +100 -4
- package/dist/paths.d.ts +19 -0
- package/dist/paths.js +38 -1
- package/dist/subsystems/cognition-steward/conceptualize/handler.js +1 -1
- package/dist/subsystems/memory-steward/backfill/handler.js +1 -1
- package/dist/subsystems/safety-guard/config.yaml +3 -1
- package/dist/subsystems/wisdom-steward/formation/handler.js +1 -1
- package/package.json +3 -2
|
@@ -44,7 +44,8 @@ export function createLlmIntentResolver(provider, opts) {
|
|
|
44
44
|
{ role: 'system', content: INTENT_SYSTEM },
|
|
45
45
|
{ role: 'user', content: lines.join('\n') },
|
|
46
46
|
],
|
|
47
|
-
|
|
47
|
+
// 未显式配置即不发送:由模型配置(ModelInfo.temperature)或服务端默认决定
|
|
48
|
+
temperature: opts?.temperature,
|
|
48
49
|
maxTokens: opts?.maxTokens ?? 300,
|
|
49
50
|
});
|
|
50
51
|
const raw = (response.content ?? '').trim();
|
|
@@ -11,6 +11,7 @@ import { join } from 'node:path';
|
|
|
11
11
|
import { computeEffectiveRights } from '../../governance/session-acl/rights.js';
|
|
12
12
|
import { sessionMatchesAgent } from '@octopi-agent/core/types/session.js';
|
|
13
13
|
import { formatHistoryRef, parseHistoryRef, messageText } from './types.js';
|
|
14
|
+
import { isChatReplayHidden } from '../../context/layer-types.js';
|
|
14
15
|
import { applyRoleWeight, authorAllows, extractSearchableFields, makeSnippet, matchFields, sessionScore, } from './score.js';
|
|
15
16
|
const gunzipAsync = promisify(gunzip);
|
|
16
17
|
/**
|
|
@@ -387,6 +388,15 @@ class DefaultSessionHistoryPort {
|
|
|
387
388
|
visibleMessages(session, agentId) {
|
|
388
389
|
const all = session.messages ?? [];
|
|
389
390
|
const indexed = all.map((message, index) => ({ index, message }));
|
|
391
|
+
// 聊天回放隐藏面(turn_end 载体 / 托管 systemPrompt…)不得作为 user/system 命中露出——
|
|
392
|
+
// 与 observer / ConversationAdapter 同一谓词(layer-types isChatReplayHidden)
|
|
393
|
+
const visible = indexed.filter(({ message }) => !isChatReplayHidden({
|
|
394
|
+
role: message.role,
|
|
395
|
+
source: typeof message.metadata?.source === 'string'
|
|
396
|
+
? String(message.metadata.source)
|
|
397
|
+
: undefined,
|
|
398
|
+
text: messageText(message),
|
|
399
|
+
}));
|
|
390
400
|
const scope = this.options.historyScope ?? 'participated';
|
|
391
401
|
if (scope === 'participated' && agentId) {
|
|
392
402
|
const pick = {
|
|
@@ -401,7 +411,7 @@ class DefaultSessionHistoryPort {
|
|
|
401
411
|
}
|
|
402
412
|
const acl = this.options.sessionAcl;
|
|
403
413
|
if (!acl || !agentId)
|
|
404
|
-
return
|
|
414
|
+
return visible;
|
|
405
415
|
const access = resolveHistoryAccess(acl, session, agentId, this.options.resolveAgentMax?.(agentId));
|
|
406
416
|
if (!access)
|
|
407
417
|
return [];
|
|
@@ -410,7 +420,7 @@ class DefaultSessionHistoryPort {
|
|
|
410
420
|
case 'none':
|
|
411
421
|
return [];
|
|
412
422
|
case 'full':
|
|
413
|
-
return
|
|
423
|
+
return visible;
|
|
414
424
|
case 'from_grant': {
|
|
415
425
|
const participant = access.participant;
|
|
416
426
|
// 缺 seq/at 一律 fail-closed(E6)
|
|
@@ -418,12 +428,12 @@ class DefaultSessionHistoryPort {
|
|
|
418
428
|
return [];
|
|
419
429
|
}
|
|
420
430
|
const at = participant.grantedAt;
|
|
421
|
-
return
|
|
431
|
+
return visible.filter(({ message }) => (message.timestamp ?? 0) >= at);
|
|
422
432
|
}
|
|
423
433
|
case 'summary_tail':
|
|
424
|
-
return
|
|
434
|
+
return visible.slice(-20);
|
|
425
435
|
default:
|
|
426
|
-
return
|
|
436
|
+
return visible;
|
|
427
437
|
}
|
|
428
438
|
}
|
|
429
439
|
renderMessage(m, format, includeToolIo) {
|
|
@@ -14,6 +14,11 @@ export declare class InMemorySessionStore implements SessionStore<SessionData> {
|
|
|
14
14
|
load(sessionId: string): Promise<SessionData | null>;
|
|
15
15
|
save(sessionId: string, data: SessionData): Promise<void>;
|
|
16
16
|
updateMetadata(sessionId: string, mutate: (meta: Record<string, unknown>) => void | Record<string, unknown>): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* 消息序列对齐。契约见 SessionStore.syncMessages;
|
|
19
|
+
* 内存后端直接替换消息数组(与 JsonlSessionStore 同口径:不存在则跳过)。
|
|
20
|
+
*/
|
|
21
|
+
syncMessages(sessionId: string, messages: readonly unknown[]): Promise<void>;
|
|
17
22
|
list(filter?: SessionListFilter): Promise<SessionMeta[]>;
|
|
18
23
|
delete(sessionId: string): Promise<void>;
|
|
19
24
|
exists(sessionId: string): Promise<boolean>;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @layer harness/session — Session 域纯内存默认实现(非生产落盘后端)。
|
|
8
8
|
*/
|
|
9
|
-
import { sessionMatchesAgent } from '@octopi-agent/core/types/session.js';
|
|
9
|
+
import { readTitleState, sessionMatchesAgent } from '@octopi-agent/core/types/session.js';
|
|
10
10
|
function toIndexPick(s) {
|
|
11
11
|
return {
|
|
12
12
|
agentId: s.agentId ?? s.meta.agentId,
|
|
@@ -19,7 +19,12 @@ function toIndexPick(s) {
|
|
|
19
19
|
export class InMemorySessionStore {
|
|
20
20
|
sessions = new Map();
|
|
21
21
|
async load(sessionId) {
|
|
22
|
-
|
|
22
|
+
const prev = this.sessions.get(sessionId);
|
|
23
|
+
if (!prev)
|
|
24
|
+
return null;
|
|
25
|
+
// 与 JsonlSessionStore.load 同口径:meta 是投影(标题三键权威在 metadata,
|
|
26
|
+
// updateMetadata 写后 load().meta 立即新鲜,与索引后端行为一致)
|
|
27
|
+
return { ...prev, meta: { ...prev.meta, ...readTitleState(prev.metadata) } };
|
|
23
28
|
}
|
|
24
29
|
async save(sessionId, data) {
|
|
25
30
|
const prev = this.sessions.get(sessionId);
|
|
@@ -28,6 +33,17 @@ export class InMemorySessionStore {
|
|
|
28
33
|
...(prev?.metadata ?? {}),
|
|
29
34
|
...(data.metadata ?? {}),
|
|
30
35
|
};
|
|
36
|
+
// 与 JsonlSessionStore 对齐:标题三键按 titleUpdatedAt 仲裁,陈旧值不回滚更新写入;
|
|
37
|
+
// incoming 缺时间戳视为陈旧(写端恒打三键),同样归磁盘胜
|
|
38
|
+
const freshTitle = readTitleState(prev?.metadata);
|
|
39
|
+
const incomingTitle = readTitleState(data.metadata);
|
|
40
|
+
if (freshTitle.titleUpdatedAt !== undefined &&
|
|
41
|
+
(incomingTitle.titleUpdatedAt === undefined ||
|
|
42
|
+
incomingTitle.titleUpdatedAt < freshTitle.titleUpdatedAt)) {
|
|
43
|
+
metadata.title = freshTitle.title;
|
|
44
|
+
metadata.titleSource = freshTitle.titleSource;
|
|
45
|
+
metadata.titleUpdatedAt = freshTitle.titleUpdatedAt;
|
|
46
|
+
}
|
|
31
47
|
this.sessions.set(sessionId, { ...data, id: sessionId, metadata });
|
|
32
48
|
}
|
|
33
49
|
async updateMetadata(sessionId, mutate) {
|
|
@@ -41,6 +57,19 @@ export class InMemorySessionStore {
|
|
|
41
57
|
metadata: replaced === undefined ? meta : replaced,
|
|
42
58
|
});
|
|
43
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* 消息序列对齐。契约见 SessionStore.syncMessages;
|
|
62
|
+
* 内存后端直接替换消息数组(与 JsonlSessionStore 同口径:不存在则跳过)。
|
|
63
|
+
*/
|
|
64
|
+
async syncMessages(sessionId, messages) {
|
|
65
|
+
const prev = this.sessions.get(sessionId);
|
|
66
|
+
if (!prev)
|
|
67
|
+
return;
|
|
68
|
+
this.sessions.set(sessionId, {
|
|
69
|
+
...prev,
|
|
70
|
+
messages: messages.slice(),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
44
73
|
async list(filter) {
|
|
45
74
|
const values = Array.from(this.sessions.values());
|
|
46
75
|
return values
|
|
@@ -54,6 +83,8 @@ export class InMemorySessionStore {
|
|
|
54
83
|
pinnedAt: typeof s.metadata?.pinnedAt === 'number' && Number.isFinite(s.metadata.pinnedAt)
|
|
55
84
|
? s.metadata.pinnedAt
|
|
56
85
|
: s.meta.pinnedAt,
|
|
86
|
+
// 与 JsonlSessionStore.buildIndexEntry 同规则:标题权威在 metadata 三键(无旧数据回退)
|
|
87
|
+
...readTitleState(s.metadata),
|
|
57
88
|
}));
|
|
58
89
|
}
|
|
59
90
|
async delete(sessionId) {
|
|
@@ -7,9 +7,12 @@ import type { SessionTask } from './types.js';
|
|
|
7
7
|
* 仅包含未闭合 goal;step 只出现 rollup,不罗列全部描述。
|
|
8
8
|
*
|
|
9
9
|
* @param tasks - 会话全部任务(含 step)
|
|
10
|
+
* @param opts - includeGuidance=false 时省略末尾「说明」段(交接式摘要等非对话消费者用)
|
|
10
11
|
* @returns 注入字符串;无活跃 goal 时返回空串
|
|
11
12
|
*/
|
|
12
|
-
export declare function renderSessionTasksInjection(tasks: SessionTask[]
|
|
13
|
+
export declare function renderSessionTasksInjection(tasks: SessionTask[], opts?: {
|
|
14
|
+
includeGuidance?: boolean;
|
|
15
|
+
}): string;
|
|
13
16
|
/**
|
|
14
17
|
* 从会话任务提取检索主题线索(Memory/Cognition 层 query 用)。
|
|
15
18
|
*
|
|
@@ -23,9 +23,10 @@ function stepProgressLine(goalId, all) {
|
|
|
23
23
|
* 仅包含未闭合 goal;step 只出现 rollup,不罗列全部描述。
|
|
24
24
|
*
|
|
25
25
|
* @param tasks - 会话全部任务(含 step)
|
|
26
|
+
* @param opts - includeGuidance=false 时省略末尾「说明」段(交接式摘要等非对话消费者用)
|
|
26
27
|
* @returns 注入字符串;无活跃 goal 时返回空串
|
|
27
28
|
*/
|
|
28
|
-
export function renderSessionTasksInjection(tasks) {
|
|
29
|
+
export function renderSessionTasksInjection(tasks, opts) {
|
|
29
30
|
const goals = tasks
|
|
30
31
|
.filter((t) => !t.parentId && isActive(t.status))
|
|
31
32
|
.sort((a, b) => a.createdAt - b.createdAt);
|
|
@@ -46,12 +47,14 @@ export function renderSessionTasksInjection(tasks) {
|
|
|
46
47
|
lines.push(` 进展:${goal.progressNote}`);
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
if (opts?.includeGuidance !== false) {
|
|
51
|
+
lines.push('');
|
|
52
|
+
lines.push('说明:');
|
|
53
|
+
lines.push('- 用户要求继续或话题回归时,可恢复对应任务或先说明进展。');
|
|
54
|
+
lines.push('- 与当前消息无关时,优先处理当前消息,不要强行续做。');
|
|
55
|
+
lines.push('- 完成或放弃时请调用 task_complete / task_drop,保持列表与对话一致。');
|
|
56
|
+
lines.push('- 复杂任务可先 task_create 建目标,再用 task_plan 或 task_create(parent_id) 登记步骤。');
|
|
57
|
+
}
|
|
55
58
|
lines.push('</session_tasks>');
|
|
56
59
|
return lines.join('\n');
|
|
57
60
|
}
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 目标:历史列表一眼可认;「你好」类碎消息不浪费 LLM 调用。
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { extractUserMessageText } from '../context/turn-envelope.js';
|
|
7
|
+
import { isHumanSpeech } from '../context/layer-types.js';
|
|
7
8
|
/** 首条有效用户消息达到该长度才可直接摘要 */
|
|
8
9
|
export const TITLE_MIN_FIRST_USER_CHARS = 16;
|
|
9
10
|
/** 累计有效用户内容达到该长度(且至少 1 轮完成)可摘要 */
|
|
@@ -12,18 +13,25 @@ export const TITLE_MIN_TOTAL_USER_CHARS = 40;
|
|
|
12
13
|
export const TITLE_SNIPPET_MAX_CHARS = 24;
|
|
13
14
|
/** 生成标题最大长度 */
|
|
14
15
|
export const TITLE_MAX_CHARS = 40;
|
|
15
|
-
/** 参与标题信号统计的用户消息(排除 slash
|
|
16
|
+
/** 参与标题信号统计的用户消息(排除 slash 命令留痕与机器插槽;唯一谓词在 layer-types) */
|
|
16
17
|
function isTitleRelevantUserMessage(msg) {
|
|
17
|
-
if (msg
|
|
18
|
+
if (!isHumanSpeech(msg))
|
|
18
19
|
return false;
|
|
19
20
|
const kind = msg.metadata?.kind;
|
|
20
21
|
if (kind === 'command' || kind === 'command_result')
|
|
21
22
|
return false;
|
|
22
23
|
return true;
|
|
23
24
|
}
|
|
24
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* 提取纯文本并压空白。
|
|
27
|
+
*
|
|
28
|
+
* f126dc9 后真实用户消息的 content 是 `<turn_start>` 整封(含 turn_context
|
|
29
|
+
* 快照/grounding):必须解包取 `<user_message>` 原文,否则标题信号被信封
|
|
30
|
+
* boilerplate 吃满、snippet 被信封形状误判为载荷(OP-WEB-5② 残留)。
|
|
31
|
+
* 非信封正文(assistant / 载体 / 便签)原样返回。
|
|
32
|
+
*/
|
|
25
33
|
function messageText(msg) {
|
|
26
|
-
return
|
|
34
|
+
return extractUserMessageText(msg.content).replace(/\s+/g, ' ').trim();
|
|
27
35
|
}
|
|
28
36
|
function safeDecodeURIComponent(s) {
|
|
29
37
|
try {
|
|
@@ -239,11 +247,19 @@ export function isWeakTitle(title) {
|
|
|
239
247
|
export function buildTitlePrompt(messages) {
|
|
240
248
|
const entries = [];
|
|
241
249
|
for (const msg of messages) {
|
|
242
|
-
if (msg.role
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
250
|
+
if (msg.role === 'user') {
|
|
251
|
+
// 用户侧复用唯一谓词(载体/命令留痕过滤单源)
|
|
252
|
+
if (!isTitleRelevantUserMessage(msg))
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
else if (msg.role === 'assistant') {
|
|
256
|
+
const kind = msg.metadata?.kind;
|
|
257
|
+
if (kind === 'command' || kind === 'command_result')
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
246
261
|
continue;
|
|
262
|
+
}
|
|
247
263
|
const text = titleText(msg);
|
|
248
264
|
if (!text)
|
|
249
265
|
continue;
|
|
@@ -19,19 +19,36 @@ export interface AgentEventMap {
|
|
|
19
19
|
error: string;
|
|
20
20
|
reason?: string;
|
|
21
21
|
};
|
|
22
|
+
/**
|
|
23
|
+
* 模型调用即将重试(重试窗口对用户可见)
|
|
24
|
+
*
|
|
25
|
+
* 此前重试不产生任何事件:一次 52 分钟停滞期间前端零反馈。
|
|
26
|
+
* `attempt` 从 1 起;`delayMs` 是**即将**等待的退避时长(通知先于等待发出)。
|
|
27
|
+
*/
|
|
28
|
+
'engine.model_retry': {
|
|
29
|
+
attempt: number;
|
|
30
|
+
maxAttempts: number;
|
|
31
|
+
reason: string;
|
|
32
|
+
delayMs: number;
|
|
33
|
+
error: string;
|
|
34
|
+
};
|
|
22
35
|
'iteration.start': Record<string, never>;
|
|
23
36
|
'llm.usage': {
|
|
24
37
|
usage: import('@octopi-agent/core/types/turn.js').TokenUsage;
|
|
25
38
|
};
|
|
26
39
|
'turn.end': {
|
|
40
|
+
/** 本次调用的正文;error=true 时 = 中断前的部分流出(不是回答,不得当回复外发) */
|
|
27
41
|
content?: string;
|
|
28
42
|
userText?: string;
|
|
29
43
|
hasToolCalls: boolean;
|
|
30
44
|
phase: 'pre_tools' | 'final';
|
|
31
45
|
truncated?: boolean;
|
|
32
46
|
stopped?: boolean;
|
|
47
|
+
/** 本次 LLM 调用失败(只出现在重试中途;彻底失败走 agent_end reason='error') */
|
|
33
48
|
error?: boolean;
|
|
34
49
|
usage?: import('@octopi-agent/core/types/turn.js').TokenUsage;
|
|
50
|
+
/** F3 LLM 计时摘要(loop turn_end 透传;Run 页签耗时区消费) */
|
|
51
|
+
llmTiming?: import('@octopi-agent/core/loop/types.js').LoopLLMTiming;
|
|
35
52
|
contextTokens?: number;
|
|
36
53
|
contextWindow?: number;
|
|
37
54
|
};
|
|
@@ -50,6 +67,16 @@ export interface AgentEventMap {
|
|
|
50
67
|
/** 行动简述 */
|
|
51
68
|
purpose?: string;
|
|
52
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* 工具执行中的部分输出(展示通道;不进对话历史、不参与 afterToolCall 定形)。
|
|
72
|
+
* 载荷已经过 SecurityGuard 出口扫描(与 tool.exec.end 同一判定),违规部分被扣发。
|
|
73
|
+
*/
|
|
74
|
+
'tool.exec.update': {
|
|
75
|
+
toolCallId: string;
|
|
76
|
+
toolName: string;
|
|
77
|
+
/** 部分输出内容(对齐 LoopToolResult.content 语义;发射端已截断) */
|
|
78
|
+
content?: unknown;
|
|
79
|
+
};
|
|
53
80
|
/** ToolEffectPolicy §5.6 效应账本摘要(turn 级;Observer tool.effect) */
|
|
54
81
|
'tool.effect.ledger': {
|
|
55
82
|
entries: number;
|
|
@@ -61,6 +88,28 @@ export interface AgentEventMap {
|
|
|
61
88
|
deleted?: string[];
|
|
62
89
|
};
|
|
63
90
|
};
|
|
91
|
+
/** Runner 收口计时(F3 `[timing]` 探针转正;wait/build/run_end 分段,事件旁路 eventSink) */
|
|
92
|
+
'run.timing': {
|
|
93
|
+
stage: 'run_start' | 'context_ready' | 'run_end';
|
|
94
|
+
/** 排队/等锁耗时(stage=run_start) */
|
|
95
|
+
waitMs?: number;
|
|
96
|
+
/** 上下文组装耗时,从拿锁后起算(stage=context_ready) */
|
|
97
|
+
buildMs?: number;
|
|
98
|
+
/** 消息数(stage=context_ready) */
|
|
99
|
+
msgs?: number;
|
|
100
|
+
/** system prompt 稳定前缀字符数(E8 后不含易变快照) */
|
|
101
|
+
sysChars?: number;
|
|
102
|
+
/** grounding 估算 tokens(stage=context_ready) */
|
|
103
|
+
groundingTokens?: number;
|
|
104
|
+
/** run 总耗时(stage=run_end) */
|
|
105
|
+
durMs?: number;
|
|
106
|
+
/** 观测口径结束原因(stage=run_end) */
|
|
107
|
+
reason?: string;
|
|
108
|
+
/** 循环结束原因(stage=run_end) */
|
|
109
|
+
loopEnd?: string;
|
|
110
|
+
/** 停止闸门原因(stage=run_end) */
|
|
111
|
+
stopReason?: string;
|
|
112
|
+
};
|
|
64
113
|
'budget.exceeded': {
|
|
65
114
|
reason: 'wall_clock' | 'iteration' | 'tool_calls';
|
|
66
115
|
report?: unknown;
|
|
@@ -146,6 +195,12 @@ export interface AgentEventMap {
|
|
|
146
195
|
error: string;
|
|
147
196
|
durationMs?: number;
|
|
148
197
|
};
|
|
198
|
+
/** 摘要请求 cache-miss 旁路/穷尽可观测(F22):no_prefix=无同形前缀,window_guard=前缀放不下改文本化旁路,window_exhausted=最终失败 */
|
|
199
|
+
'context.compact.summarize_fallback': {
|
|
200
|
+
reason?: 'proactive' | 'overflow';
|
|
201
|
+
fallback?: string;
|
|
202
|
+
cached?: boolean;
|
|
203
|
+
};
|
|
149
204
|
/**
|
|
150
205
|
* system prompt 七层装配完成(AssembleManifest 可观测快照)
|
|
151
206
|
* UI 用此事件渲染 Context Runtime;不进入模型输入。
|
|
@@ -193,6 +248,36 @@ export interface AgentEventMap {
|
|
|
193
248
|
};
|
|
194
249
|
/** RunMetricsCollector 快照(reliability → Observer) */
|
|
195
250
|
'run.guard.metrics': import('../../run/reliability/harness-events.js').RunGuardMetricsEvent['data'];
|
|
251
|
+
/** ops P0:jail 意图 × 实测后端(授权 vs 故障的事后判据,run 开始即记录) */
|
|
252
|
+
'ops.jail.state': import('../../extension/execution-environment/effect-policy.js').OpsJailState;
|
|
253
|
+
/** ops P2:run 级降级申报(securityDegraded 快照) */
|
|
254
|
+
'ops.policy.degraded': {
|
|
255
|
+
degradation: string[];
|
|
256
|
+
requestedVsEffective: {
|
|
257
|
+
requestedMode: string;
|
|
258
|
+
mode: string;
|
|
259
|
+
};
|
|
260
|
+
origin: {
|
|
261
|
+
sessionId: string;
|
|
262
|
+
agentId: string;
|
|
263
|
+
runId?: string | null;
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
/** ops P2:安全配置漂移 → 拒新 run(§8.4) */
|
|
267
|
+
'ops.config.security_changed': {
|
|
268
|
+
changed: string[];
|
|
269
|
+
action: string;
|
|
270
|
+
/** 旧→新摘要(§7) */
|
|
271
|
+
previousFingerprint: string | null;
|
|
272
|
+
currentFingerprint: string | null;
|
|
273
|
+
/** 谁改的无法从文件判定(agent 写与宿主写同样是磁盘字节)→ 如实 unattributed */
|
|
274
|
+
source: 'unattributed';
|
|
275
|
+
hostAttested: boolean;
|
|
276
|
+
origin: {
|
|
277
|
+
sessionId: string;
|
|
278
|
+
agentId: string;
|
|
279
|
+
};
|
|
280
|
+
};
|
|
196
281
|
'task.created': {
|
|
197
282
|
taskId: string;
|
|
198
283
|
taskType: string;
|
|
@@ -251,10 +336,14 @@ export declare const AgentEvents: {
|
|
|
251
336
|
readonly ENGINE_START: "engine.start";
|
|
252
337
|
readonly ENGINE_END: "engine.end";
|
|
253
338
|
readonly ENGINE_ERROR: "engine.error";
|
|
339
|
+
readonly ENGINE_MODEL_RETRY: "engine.model_retry";
|
|
254
340
|
readonly ITERATION_START: "iteration.start";
|
|
255
341
|
readonly TURN_END: "turn.end";
|
|
342
|
+
/** Runner 收口计时(F3 转正) */
|
|
343
|
+
readonly RUN_TIMING: "run.timing";
|
|
256
344
|
readonly TOOL_EXEC_START: "tool.exec.start";
|
|
257
345
|
readonly TOOL_EXEC_END: "tool.exec.end";
|
|
346
|
+
readonly TOOL_EXEC_UPDATE: "tool.exec.update";
|
|
258
347
|
readonly INJECTION_DETECTED: "injection.detected";
|
|
259
348
|
readonly POLICY_VIOLATED: "policy.violated";
|
|
260
349
|
readonly SENSITIVE_DATA_DETECTED: "sensitive_data.detected";
|
|
@@ -275,6 +364,9 @@ export declare const AgentEvents: {
|
|
|
275
364
|
readonly RUN_SCOPE_MESSAGES: "run.scope.messages";
|
|
276
365
|
readonly RUN_SCOPE_LLM: "run.scope.llm";
|
|
277
366
|
readonly RUN_GUARD_METRICS: "run.guard.metrics";
|
|
367
|
+
readonly OPS_JAIL_STATE: "ops.jail.state";
|
|
368
|
+
readonly OPS_POLICY_DEGRADED: "ops.policy.degraded";
|
|
369
|
+
readonly OPS_CONFIG_SECURITY_CHANGED: "ops.config.security_changed";
|
|
278
370
|
readonly TASK_CREATED: "task.created";
|
|
279
371
|
readonly TASK_STARTED: "task.started";
|
|
280
372
|
readonly TASK_COMPLETED: "task.completed";
|
|
@@ -18,10 +18,14 @@ export const AgentEvents = {
|
|
|
18
18
|
ENGINE_START: 'engine.start',
|
|
19
19
|
ENGINE_END: 'engine.end',
|
|
20
20
|
ENGINE_ERROR: 'engine.error',
|
|
21
|
+
ENGINE_MODEL_RETRY: 'engine.model_retry',
|
|
21
22
|
ITERATION_START: 'iteration.start',
|
|
22
23
|
TURN_END: 'turn.end',
|
|
24
|
+
/** Runner 收口计时(F3 转正) */
|
|
25
|
+
RUN_TIMING: 'run.timing',
|
|
23
26
|
TOOL_EXEC_START: 'tool.exec.start',
|
|
24
27
|
TOOL_EXEC_END: 'tool.exec.end',
|
|
28
|
+
TOOL_EXEC_UPDATE: 'tool.exec.update',
|
|
25
29
|
INJECTION_DETECTED: 'injection.detected',
|
|
26
30
|
POLICY_VIOLATED: 'policy.violated',
|
|
27
31
|
SENSITIVE_DATA_DETECTED: 'sensitive_data.detected',
|
|
@@ -42,6 +46,9 @@ export const AgentEvents = {
|
|
|
42
46
|
RUN_SCOPE_MESSAGES: 'run.scope.messages',
|
|
43
47
|
RUN_SCOPE_LLM: 'run.scope.llm',
|
|
44
48
|
RUN_GUARD_METRICS: 'run.guard.metrics',
|
|
49
|
+
OPS_JAIL_STATE: 'ops.jail.state',
|
|
50
|
+
OPS_POLICY_DEGRADED: 'ops.policy.degraded',
|
|
51
|
+
OPS_CONFIG_SECURITY_CHANGED: 'ops.config.security_changed',
|
|
45
52
|
TASK_CREATED: 'task.created',
|
|
46
53
|
TASK_STARTED: 'task.started',
|
|
47
54
|
TASK_COMPLETED: 'task.completed',
|
package/dist/index.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export type { ContextEngine, ContextEngineInfo, AssembleParams, AssembleResult,
|
|
|
26
26
|
export { setRunTelemetryFactory, getRunTelemetryFactory } from './harness/observability/run-telemetry.js';
|
|
27
27
|
export type { RunTelemetry, RunTelemetryFactory } from './harness/observability/run-telemetry.js';
|
|
28
28
|
export { createRunTelemetry } from './integration/observability/run-telemetry.js';
|
|
29
|
-
export { AgentBuilder, createAgent, isSubsystemAllowed, discoverSubsystemSpecs } from './harness/agent/builder.js';
|
|
29
|
+
export { AgentBuilder, createAgent, DefaultErrorStrategy, isSubsystemAllowed, discoverSubsystemSpecs } from './harness/agent/builder.js';
|
|
30
30
|
export type { AgentTraceOptions } from './harness/agent/builder.js';
|
|
31
31
|
export type { AgentBuildOptions, AgentBuildResult, AgentBuildCoreResult } from './harness/agent/builder.js';
|
|
32
32
|
export type { ChannelAdapter, ChannelMessage, ChannelReply } from './harness/extension/plugin-ecosystem/channel-types.js';
|
|
@@ -40,11 +40,11 @@ export { TurnFileUndoLog, commitSessionFileUndo, discardSessionFileUndo, resolve
|
|
|
40
40
|
export { TurnMemoryJournal, JournaledMemoryStore, createMemoryRestorer, discardMemoryUndo, } from './harness/extension/execution-environment/memory-undo.js';
|
|
41
41
|
export type { MemoryUndoEntry, MemoryEffectRestorer, DiscardMemoryEffectsResult, } from './harness/extension/execution-environment/memory-undo.js';
|
|
42
42
|
export type { MemoryEffectJournal, MemoryEffectDomain } from '@octopi-agent/core/types/tools.js';
|
|
43
|
-
export { resolveEffectiveEffectPolicy, isPathAllowed, isToolAllowedOnSurface, DEFAULT_EFFECT_RUN_MODE, readSessionEffectOverrides, normalizeTransactionRoots, mergeTransactionRoots, SESSION_EFFECT_OVERRIDES_KEY, } from './harness/extension/execution-environment/effect-policy.js';
|
|
43
|
+
export { resolveEffectiveEffectPolicy, requiresJail, buildOpsJailState, isPathAllowed, isToolAllowedOnSurface, DEFAULT_EFFECT_RUN_MODE, readSessionEffectOverrides, normalizeTransactionRoots, mergeTransactionRoots, SESSION_EFFECT_OVERRIDES_KEY, } from './harness/extension/execution-environment/effect-policy.js';
|
|
44
44
|
export { ProcessSandbox, createProcessSandbox, assessL4ProcessMinimum, probeProcessIsolation, scrubEnv, killProcessTree, supervisedSpawnProfile, } from './harness/extension/execution-environment/index.js';
|
|
45
45
|
export type { ProcessIsolationProfile, IsolationBackend, L4ProcessAssessment, } from './harness/extension/execution-environment/process-isolation.js';
|
|
46
46
|
export { runWithToolLimits, resolveToolTimeoutMs, ToolTimeoutError, } from './harness/extension/execution-environment/resource-limits.js';
|
|
47
|
-
export type { EffectIntent, ConfirmEffect, ConfirmEffectDecision, UntrustedAdmission, ToolSurface, SecurityDegradation, SessionEffectOverrides, } from './harness/extension/execution-environment/effect-policy.js';
|
|
47
|
+
export type { EffectIntent, ConfirmEffect, ConfirmEffectDecision, UntrustedAdmission, JailIntent, OnJailUnavailable, OpsJailState, ToolSurface, SecurityDegradation, SessionEffectOverrides, } from './harness/extension/execution-environment/effect-policy.js';
|
|
48
48
|
export type { EffectRunMode, EffectPolicyConfig, EffectiveEffectPolicy, PathContainment, ShellEscapePolicy, } from './harness/extension/execution-environment/effect-policy.js';
|
|
49
49
|
export { scanOrphanSessionUndo, } from './harness/extension/execution-environment/undo-log.js';
|
|
50
50
|
export type { SessionUndoPaths, FileUndoEntry, DiscardFileEffectsResult, DiscardConflictReason, EditResendResult, NotReversedEffects, NotReversedReason, UndoLimitConfig, OrphanUndoDir, } from './harness/extension/execution-environment/undo-log.js';
|
|
@@ -83,11 +83,13 @@ export type { SkillDefinition, SkillManager } from './harness/extension/plugin-e
|
|
|
83
83
|
/** 产品装配 DTO(非 Kernel);ModelInfo/ToolPolicy 仍从 core/types 导出 */
|
|
84
84
|
export type { AgentPersona, ModelConfig, AgentDefinition } from './harness/shared/types/agent-definition.js';
|
|
85
85
|
export { DefaultToolBus } from './harness/extension/plugin-ecosystem/tools/tool-bus.js';
|
|
86
|
-
export { buildToolLlmParameters, prepareHandlerArgs, readToolCallPurpose, resolveToolCallPurpose, sanitizeToolJsonSchema, toolDeclaresPurpose, TOOL_PURPOSE_PARAM, } from './harness/agent/tool-purpose.js';
|
|
86
|
+
export { buildToolLlmParameters, prepareHandlerArgs, readToolCallPurpose, resolveToolCallPurpose, sanitizeToolJsonSchema, toolDeclaresPurpose, TOOL_PURPOSE_PARAM, TOOL_PURPOSE_SYSTEM_NOTE, } from './harness/agent/tool-purpose.js';
|
|
87
87
|
export { createClientTool, makeClientToolCallId, ClientToolRegistry, DEFAULT_CLIENT_TOOL_TIMEOUT_MS, } from './harness/extension/plugin-ecosystem/client-tools/index.js';
|
|
88
88
|
export type { ClientToolCall, ClientToolCallId, ClientToolCallOutcome, ClientToolDescriptor, ClientToolDeviceMeta, ClientToolErrorReason, ClientToolInvoker, ClientToolInteraction, ClientToolName, ClientToolProvider, ClientToolFileRef, ClientToolResult, ClientToolSensitivity, ClientToolRouteDecision, } from './harness/extension/plugin-ecosystem/client-tools/index.js';
|
|
89
89
|
export { getBuiltinTools, createShellTool, createFileReadTool, createFileWriteTool, createFileListTool } from './harness/extension/plugin-ecosystem/tools/builtin.js';
|
|
90
90
|
export { createToolSet } from './harness/extension/plugin-ecosystem/tools/tool-set.js';
|
|
91
|
+
export { readGitStatusSnapshot, parsePorcelainV2 } from './harness/extension/plugin-ecosystem/tools/git-status-snapshot.js';
|
|
92
|
+
export type { GitStatusSnapshot, GitStatusSnapshotBody, GitStatusSnapshotOptions, GitStatusEntry, GitStatusBranch, GitStatusCounts, GitStatusGroup, GitStatusKind, } from './harness/extension/plugin-ecosystem/tools/git-status-snapshot.js';
|
|
91
93
|
export { createSummaryPort, applyToolOutputGate, createCompactEngine } from './harness/context/capabilities/index.js';
|
|
92
94
|
export { createDefaultDocumentPort, createDocumentPortFromConfig, DocumentExtractError } from './harness/capabilities/document/index.js';
|
|
93
95
|
export type { SummaryPort, SummaryPolicy, ContentUnit, ToolSummarySupport, CompactEngine } from './harness/context/capabilities/index.js';
|
package/dist/index.js
CHANGED
|
@@ -21,13 +21,13 @@ import { createRunTelemetry } from './integration/observability/run-telemetry.js
|
|
|
21
21
|
setRunTelemetryFactory(createRunTelemetry);
|
|
22
22
|
export { setRunTelemetryFactory, getRunTelemetryFactory } from './harness/observability/run-telemetry.js';
|
|
23
23
|
export { createRunTelemetry } from './integration/observability/run-telemetry.js';
|
|
24
|
-
export { AgentBuilder, createAgent, isSubsystemAllowed, discoverSubsystemSpecs } from './harness/agent/builder.js';
|
|
24
|
+
export { AgentBuilder, createAgent, DefaultErrorStrategy, isSubsystemAllowed, discoverSubsystemSpecs } from './harness/agent/builder.js';
|
|
25
25
|
export { Agent } from './harness/run/agent/index.js';
|
|
26
26
|
export { SessionAwareRunner } from './harness/run/runner.js';
|
|
27
27
|
export { DEFAULT_TOOL_ISOLATION, resolveToolIsolationCwd, } from './harness/extension/execution-environment/isolation.js';
|
|
28
28
|
export { TurnFileUndoLog, commitSessionFileUndo, discardSessionFileUndo, resolveSessionUndoPaths, resolveSessionUndoOnClose, createUnconfiguredFileEffects, createUnconfiguredMemoryEffects, } from './harness/extension/execution-environment/undo-log.js';
|
|
29
29
|
export { TurnMemoryJournal, JournaledMemoryStore, createMemoryRestorer, discardMemoryUndo, } from './harness/extension/execution-environment/memory-undo.js';
|
|
30
|
-
export { resolveEffectiveEffectPolicy, isPathAllowed, isToolAllowedOnSurface, DEFAULT_EFFECT_RUN_MODE, readSessionEffectOverrides, normalizeTransactionRoots, mergeTransactionRoots, SESSION_EFFECT_OVERRIDES_KEY, } from './harness/extension/execution-environment/effect-policy.js';
|
|
30
|
+
export { resolveEffectiveEffectPolicy, requiresJail, buildOpsJailState, isPathAllowed, isToolAllowedOnSurface, DEFAULT_EFFECT_RUN_MODE, readSessionEffectOverrides, normalizeTransactionRoots, mergeTransactionRoots, SESSION_EFFECT_OVERRIDES_KEY, } from './harness/extension/execution-environment/effect-policy.js';
|
|
31
31
|
export { ProcessSandbox, createProcessSandbox, assessL4ProcessMinimum, probeProcessIsolation, scrubEnv, killProcessTree, supervisedSpawnProfile, } from './harness/extension/execution-environment/index.js';
|
|
32
32
|
export { runWithToolLimits, resolveToolTimeoutMs, ToolTimeoutError, } from './harness/extension/execution-environment/resource-limits.js';
|
|
33
33
|
export { scanOrphanSessionUndo, } from './harness/extension/execution-environment/undo-log.js';
|
|
@@ -51,10 +51,11 @@ export { CapabilityRegistry } from './harness/extension/plugin-ecosystem/plugins
|
|
|
51
51
|
export { validateManifest, parseManifest } from './harness/extension/plugin-ecosystem/plugins/manifest.js';
|
|
52
52
|
export { DefaultSkillManager, FileSystemSkillSource } from './harness/extension/plugin-ecosystem/skills/manager.js';
|
|
53
53
|
export { DefaultToolBus } from './harness/extension/plugin-ecosystem/tools/tool-bus.js';
|
|
54
|
-
export { buildToolLlmParameters, prepareHandlerArgs, readToolCallPurpose, resolveToolCallPurpose, sanitizeToolJsonSchema, toolDeclaresPurpose, TOOL_PURPOSE_PARAM, } from './harness/agent/tool-purpose.js';
|
|
54
|
+
export { buildToolLlmParameters, prepareHandlerArgs, readToolCallPurpose, resolveToolCallPurpose, sanitizeToolJsonSchema, toolDeclaresPurpose, TOOL_PURPOSE_PARAM, TOOL_PURPOSE_SYSTEM_NOTE, } from './harness/agent/tool-purpose.js';
|
|
55
55
|
export { createClientTool, makeClientToolCallId, ClientToolRegistry, DEFAULT_CLIENT_TOOL_TIMEOUT_MS, } from './harness/extension/plugin-ecosystem/client-tools/index.js';
|
|
56
56
|
export { getBuiltinTools, createShellTool, createFileReadTool, createFileWriteTool, createFileListTool } from './harness/extension/plugin-ecosystem/tools/builtin.js';
|
|
57
57
|
export { createToolSet } from './harness/extension/plugin-ecosystem/tools/tool-set.js';
|
|
58
|
+
export { readGitStatusSnapshot, parsePorcelainV2 } from './harness/extension/plugin-ecosystem/tools/git-status-snapshot.js';
|
|
58
59
|
export { createSummaryPort, applyToolOutputGate, createCompactEngine } from './harness/context/capabilities/index.js';
|
|
59
60
|
export { createDefaultDocumentPort, createDocumentPortFromConfig, DocumentExtractError } from './harness/capabilities/document/index.js';
|
|
60
61
|
export { createWebSearchTool } from './harness/extension/plugin-ecosystem/tools/web-search.js';
|
|
@@ -50,9 +50,27 @@ export async function dispatchChannelMessage(options) {
|
|
|
50
50
|
const { runtime, msg, resolveAgentId, resolveSessionId, onEvent } = options;
|
|
51
51
|
const agentId = resolveAgentId(msg);
|
|
52
52
|
if (!agentId) {
|
|
53
|
+
// 回执契约 = 恒发一次(liveness);no_agent 的实际结果由上层 error/静默路径处理
|
|
54
|
+
msg.delivery = 'run';
|
|
55
|
+
msg.onDelivery?.('run');
|
|
53
56
|
return { status: 'skipped', reason: 'no_agent' };
|
|
54
57
|
}
|
|
55
58
|
const sessionId = resolveSessionId(msg);
|
|
56
59
|
const trigger = channelMessageToTrigger(msg, agentId, sessionId);
|
|
57
|
-
|
|
60
|
+
// 单一入口:dispatch 内部 offer;活跃 Run 接收即回执(早于 Run 结束)。
|
|
61
|
+
// 拒绝/早退路径(runtime_stopped 等)也要回执一次(liveness),错误走 error 通道。
|
|
62
|
+
let delivered = false;
|
|
63
|
+
const result = await runtime.dispatch(trigger, {
|
|
64
|
+
...(onEvent ? { onEvent } : {}),
|
|
65
|
+
onDelivery: (delivery) => {
|
|
66
|
+
delivered = true;
|
|
67
|
+
msg.delivery = delivery;
|
|
68
|
+
msg.onDelivery?.(delivery);
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
if (!delivered) {
|
|
72
|
+
msg.delivery = 'run';
|
|
73
|
+
msg.onDelivery?.('run');
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
58
76
|
}
|
|
@@ -12,6 +12,8 @@ export type { SessionIndexBackend, SessionIndexSink, SessionIndexPrefilterQuery,
|
|
|
12
12
|
export { NoopObserver } from './observability/noop-observer.js';
|
|
13
13
|
export { LogObserver } from './observability/log-observer.js';
|
|
14
14
|
export { createRunTelemetry } from './observability/run-telemetry.js';
|
|
15
|
+
export { startLoopWatchdog } from './observability/loop-watchdog.js';
|
|
16
|
+
export type { LoopWatchdog, LoopWatchdogOptions } from './observability/loop-watchdog.js';
|
|
15
17
|
export { SdkMcpClient, createSdkMcpClient } from './mcp/index.js';
|
|
16
18
|
export { createDuckDuckGoProvider, createTavilyProvider, createBraveProvider, createSerperProvider, createMimoProvider, createWebSearchProviderFromSlot, resolveWebSearchProviders, createWebSearchWithFallback, } from './web-search/index.js';
|
|
17
19
|
export type { WebSearchConfig, WebSearchProviderSlotConfig, ResolvedWebSearchProviders, } from './web-search/index.js';
|
|
@@ -12,6 +12,7 @@ export { createSqliteSessionIndex, rebuildSessionIndexFromStore, ensureSessionIn
|
|
|
12
12
|
export { NoopObserver } from './observability/noop-observer.js';
|
|
13
13
|
export { LogObserver } from './observability/log-observer.js';
|
|
14
14
|
export { createRunTelemetry } from './observability/run-telemetry.js';
|
|
15
|
+
export { startLoopWatchdog } from './observability/loop-watchdog.js';
|
|
15
16
|
// ── MCP ──
|
|
16
17
|
export { SdkMcpClient, createSdkMcpClient } from './mcp/index.js';
|
|
17
18
|
// ── Web Search ──
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 事件循环停滞看门狗(宿主自检器官)
|
|
3
|
+
*
|
|
4
|
+
* 背景(2026-10-28 事故):网关事件循环被同步阻塞整体冻结约 4.5 小时——两个 run 的
|
|
5
|
+
* turn 同时停摆、HTTP accept 停止、SIGTERM handler 无法运行,最终被 `serve restart`
|
|
6
|
+
* 的 SIGKILL 升级收尾。事后缺一份阻塞现场的栈采样,确切阻塞点永久失考。
|
|
7
|
+
*
|
|
8
|
+
* 机制:独立 worker 线程(不随主循环冻结)定期 ping 主线程;主线程 message handler
|
|
9
|
+
* 回 pong 以证明事件循环存活。主循环冻结 → pong 静默超阈值 → worker 判定停滞:
|
|
10
|
+
* 写 JSONL 报告 +(macOS)自动 `sample <pid>` 抓主线程栈。检测与取证全部发生在
|
|
11
|
+
* worker 侧,不依赖已被冻结的事件循环。
|
|
12
|
+
*
|
|
13
|
+
* 第二道闸:进程 RSS 越过 `footprintThresholdMb` 即同样落报告 + 采栈。停滞检测
|
|
14
|
+
* 只能证明「已经僵死」,内存失控则可能在冻死前给出一段可干预的窗口——2026-10-30
|
|
15
|
+
* 网关膨胀到 30.5G 的进程在采样完成后几分钟就被系统收走。
|
|
16
|
+
*
|
|
17
|
+
* 设计约束:
|
|
18
|
+
* - 观测 fail-open:看门狗自身的任何失败不得影响宿主(写盘/采样失败静默吞掉)。
|
|
19
|
+
* - worker unref:不阻止进程退出;宿主应显式 `stop()` 收尾。
|
|
20
|
+
* - 复发 runbook:报告文件给出停滞起点(lastPongAt),`.sample-*.txt` 给出阻塞栈;
|
|
21
|
+
* 若自动采样失败,在杀进程前手动执行 `sample <pid> 5 -f /tmp/octopi-hang.txt`。
|
|
22
|
+
*
|
|
23
|
+
* @module integration/observability/loop-watchdog
|
|
24
|
+
*/
|
|
25
|
+
/** 看门狗配置 */
|
|
26
|
+
export interface LoopWatchdogOptions {
|
|
27
|
+
/** 显式关闭(缺省开启;关闭态返回 no-op 句柄) */
|
|
28
|
+
enabled?: boolean;
|
|
29
|
+
/** 心跳间隔(毫秒,缺省 5_000) */
|
|
30
|
+
intervalMs?: number;
|
|
31
|
+
/** 主循环静默多久判停滞(毫秒,缺省 30_000) */
|
|
32
|
+
stallThresholdMs?: number;
|
|
33
|
+
/** 报告落盘路径(JSONL,每行一个事件;缺省 `<OCTOPI_HOME>/logs/loop-watchdog.jsonl`) */
|
|
34
|
+
reportFile?: string;
|
|
35
|
+
/** 停滞时自动 `sample` 抓主线程栈(macOS 专属;缺省 true,测试关闭) */
|
|
36
|
+
captureSample?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* 进程 RSS 阈值(MB,缺省 4096;传 0 关闭)
|
|
39
|
+
*
|
|
40
|
+
* 越过阈值即写 `footprint` 事件并采栈——不必等事件循环冻死。用于在内存
|
|
41
|
+
* 失控的早期抓住现场(滞回:跌回阈值的 80% 以下才复位,避免阈值附近反复采样)。
|
|
42
|
+
*/
|
|
43
|
+
footprintThresholdMb?: number;
|
|
44
|
+
}
|
|
45
|
+
/** 看门狗句柄 */
|
|
46
|
+
export interface LoopWatchdog {
|
|
47
|
+
/** 停止看门狗并回收 worker */
|
|
48
|
+
stop(): void;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 启动事件循环停滞看门狗
|
|
52
|
+
*
|
|
53
|
+
* @param options - 心跳间隔 / 停滞阈值 / 报告路径 / 是否自动栈采样
|
|
54
|
+
* @returns 看门狗句柄(`stop()` 回收 worker)
|
|
55
|
+
*/
|
|
56
|
+
export declare function startLoopWatchdog(options?: LoopWatchdogOptions): LoopWatchdog;
|