@pellux/goodvibes-agent 1.1.7 → 1.3.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/CHANGELOG.md +329 -0
- package/README.md +46 -30
- package/dist/package/{ast-grep-napi.linux-x64-gnu-mkk8xwww.node → ast-grep-napi.linux-x64-gnu-swtppvy9.node} +0 -0
- package/dist/package/{ast-grep-napi.linux-x64-musl-ryqtgdv6.node → ast-grep-napi.linux-x64-musl-ttfcdtap.node} +0 -0
- package/dist/package/main.js +138903 -91477
- package/docs/README.md +14 -7
- package/docs/channels-remote-and-api.md +8 -5
- package/docs/connected-host.md +14 -12
- package/docs/getting-started.md +58 -30
- package/docs/knowledge-artifacts-and-multimodal.md +7 -5
- package/docs/project-planning.md +2 -2
- package/docs/providers-and-routing.md +11 -3
- package/docs/tools-and-commands.md +116 -45
- package/docs/voice-and-live-tts.md +3 -1
- package/package.json +3 -2
- package/release/release-notes.md +142 -5
- package/release/release-readiness.json +124 -94
- package/src/agent/assistant-cockpit.ts +247 -0
- package/src/agent/autonomy-schedule-format.ts +96 -0
- package/src/agent/autonomy-schedule.ts +514 -0
- package/src/agent/channel-delivery-receipts.ts +292 -0
- package/src/agent/competitive-feature-inventory.ts +294 -0
- package/src/agent/document-registry-types.ts +106 -0
- package/src/agent/document-registry.ts +734 -0
- package/src/agent/harness-control.ts +2 -2
- package/src/agent/memory-prompt.ts +2 -2
- package/src/agent/operator-actions.ts +50 -6
- package/src/agent/persona-registry.ts +8 -0
- package/src/agent/project-context-files.ts +273 -0
- package/src/agent/prompt-context-receipts.ts +502 -0
- package/src/agent/reminder-schedule-format.ts +16 -2
- package/src/agent/research-run-registry.ts +582 -0
- package/src/agent/research-source-registry.ts +441 -0
- package/src/agent/routine-registry.ts +19 -3
- package/src/agent/routine-schedule-format.ts +27 -2
- package/src/agent/runtime-profile-starters.ts +7 -0
- package/src/agent/runtime-profile.ts +106 -4
- package/src/agent/schedule-edit-format.ts +129 -0
- package/src/agent/schedule-edit.ts +496 -0
- package/src/agent/schedule-next-routes.ts +42 -0
- package/src/agent/setup-wizard-artifact-receipts.ts +366 -0
- package/src/agent/setup-wizard-checkpoint.ts +140 -0
- package/src/agent/setup-wizard.ts +683 -0
- package/src/agent/skill-registry-types.ts +102 -0
- package/src/agent/skill-registry.ts +81 -107
- package/src/agent/vibe-confirmation-routes.ts +62 -0
- package/src/agent/vibe-file.ts +285 -0
- package/src/cli/agent-knowledge-command.ts +45 -2
- package/src/cli/help.ts +3 -0
- package/src/cli/profiles-command.ts +25 -11
- package/src/config/agent-settings-policy.ts +1 -18
- package/src/input/agent-workspace-activation.ts +53 -0
- package/src/input/agent-workspace-artifact-browser-editor.ts +494 -0
- package/src/input/agent-workspace-artifact-metadata.ts +17 -0
- package/src/input/agent-workspace-basic-command-editors.ts +5 -1
- package/src/input/agent-workspace-categories.ts +153 -155
- package/src/input/agent-workspace-channel-triage.ts +481 -0
- package/src/input/agent-workspace-channels.ts +263 -0
- package/src/input/agent-workspace-command-editor.ts +152 -0
- package/src/input/agent-workspace-context-snapshot.ts +349 -0
- package/src/input/agent-workspace-delegation-editor-submission.ts +8 -0
- package/src/input/agent-workspace-document-editor.ts +502 -0
- package/src/input/agent-workspace-document-ops-editor.ts +523 -0
- package/src/input/agent-workspace-host-category.ts +1 -1
- package/src/input/agent-workspace-local-library-snapshot.ts +167 -0
- package/src/input/agent-workspace-model-compare-editor.ts +376 -0
- package/src/input/agent-workspace-model-compare-prompt-submission.ts +552 -0
- package/src/input/agent-workspace-model-compare-types.ts +82 -0
- package/src/input/agent-workspace-model-compare-utils.ts +35 -0
- package/src/input/agent-workspace-onboarding-categories.ts +141 -0
- package/src/input/agent-workspace-operations-command-editor-submission.ts +53 -0
- package/src/input/agent-workspace-operations-command-editors.ts +22 -0
- package/src/input/agent-workspace-research-report-editor.ts +212 -0
- package/src/input/agent-workspace-research-run-editor.ts +144 -0
- package/src/input/agent-workspace-research-source-editor.ts +167 -0
- package/src/input/agent-workspace-review-packet-snapshot.ts +593 -0
- package/src/input/agent-workspace-review-packet-utils.ts +265 -0
- package/src/input/agent-workspace-settings.ts +313 -30
- package/src/input/agent-workspace-setup-checkpoint-action.ts +127 -0
- package/src/input/agent-workspace-setup-snapshot.ts +217 -0
- package/src/input/agent-workspace-setup.ts +61 -1
- package/src/input/agent-workspace-snapshot.ts +184 -149
- package/src/input/agent-workspace-types.ts +287 -2
- package/src/input/agent-workspace.ts +23 -1
- package/src/input/command-registry.ts +9 -2
- package/src/input/commands/agent-runtime-profile-runtime.ts +28 -13
- package/src/input/commands/channels-runtime.ts +102 -114
- package/src/input/commands/delegation-runtime.ts +87 -24
- package/src/input/commands/knowledge-browser-flags.ts +12 -0
- package/src/input/commands/knowledge.ts +28 -14
- package/src/input/commands/operator-actions-runtime.ts +6 -3
- package/src/input/commands/schedule-runtime.ts +71 -14
- package/src/input/commands/session-content.ts +2 -2
- package/src/input/commands/shell-core.ts +2 -0
- package/src/input/commands/vibe-runtime.ts +140 -0
- package/src/input/commands.ts +2 -0
- package/src/input/connected-host-routes.ts +123 -0
- package/src/input/settings-modal-types.ts +14 -0
- package/src/input/setup-wizard-live-receipts.ts +76 -0
- package/src/main.ts +15 -15
- package/src/panels/qr-panel.ts +2 -2
- package/src/renderer/agent-workspace-context-lines.ts +701 -0
- package/src/renderer/agent-workspace.ts +68 -421
- package/src/renderer/settings-modal-helpers.ts +12 -0
- package/src/renderer/settings-modal.ts +12 -0
- package/src/runtime/bootstrap-command-context.ts +11 -1
- package/src/runtime/bootstrap-command-parts.ts +14 -3
- package/src/runtime/bootstrap-core.ts +39 -1
- package/src/runtime/bootstrap-shell.ts +6 -0
- package/src/runtime/bootstrap.ts +113 -30
- package/src/runtime/connected-host-auth.ts +3 -2
- package/src/runtime/execution-ledger.ts +231 -0
- package/src/runtime/services.ts +88 -10
- package/src/runtime/tool-permission-safety.ts +199 -5
- package/src/shell/session-continuity-hints.ts +39 -0
- package/src/tools/agent-artifacts-tool.ts +606 -0
- package/src/tools/agent-audit-tool.ts +155 -0
- package/src/tools/agent-autonomy-schedule-tool.ts +238 -0
- package/src/tools/agent-autonomy-tool.ts +140 -0
- package/src/tools/agent-channel-send-tool.ts +24 -2
- package/src/tools/agent-channels-tool.ts +140 -0
- package/src/tools/agent-computer-tool.ts +168 -0
- package/src/tools/agent-context-policy.ts +137 -7
- package/src/tools/agent-context-tool.ts +143 -0
- package/src/tools/agent-delegation-tool.ts +128 -0
- package/src/tools/agent-device-tool.ts +240 -0
- package/src/tools/agent-documents-tool.ts +684 -0
- package/src/tools/agent-execution-tool.ts +230 -0
- package/src/tools/agent-harness-agent-orchestration-policy.ts +75 -0
- package/src/tools/agent-harness-agent-orchestration.ts +791 -0
- package/src/tools/agent-harness-autonomy-intake.ts +785 -0
- package/src/tools/agent-harness-autonomy-live-records.ts +742 -0
- package/src/tools/agent-harness-autonomy-queue-types.ts +88 -0
- package/src/tools/agent-harness-autonomy-queue.ts +571 -0
- package/src/tools/agent-harness-autonomy-watcher-read-models.ts +509 -0
- package/src/tools/agent-harness-background-processes-types.ts +35 -0
- package/src/tools/agent-harness-background-processes.ts +798 -0
- package/src/tools/agent-harness-browser-cockpit-route.ts +373 -0
- package/src/tools/agent-harness-browser-control.ts +346 -0
- package/src/tools/agent-harness-browser-pwa-read-models.ts +622 -0
- package/src/tools/agent-harness-channel-metadata.ts +168 -10
- package/src/tools/agent-harness-cli-command-policy.ts +110 -0
- package/src/tools/agent-harness-command-catalog.ts +4 -2
- package/src/tools/agent-harness-command-runner.ts +42 -0
- package/src/tools/agent-harness-connected-host-status.ts +7 -4
- package/src/tools/agent-harness-delegation-posture.ts +234 -19
- package/src/tools/agent-harness-device-live-read-models.ts +366 -0
- package/src/tools/agent-harness-document-ops-reviewer-readiness.ts +234 -0
- package/src/tools/agent-harness-document-ops-types.ts +72 -0
- package/src/tools/agent-harness-document-ops.ts +671 -0
- package/src/tools/agent-harness-execution-history.ts +489 -0
- package/src/tools/agent-harness-execution-posture.ts +385 -0
- package/src/tools/agent-harness-file-recovery.ts +135 -0
- package/src/tools/agent-harness-interactive-runtime-records.ts +421 -0
- package/src/tools/agent-harness-keybinding-metadata.ts +16 -12
- package/src/tools/agent-harness-learning-curator-common.ts +102 -0
- package/src/tools/agent-harness-learning-curator-consolidation.ts +295 -0
- package/src/tools/agent-harness-learning-curator-proposals.ts +606 -0
- package/src/tools/agent-harness-learning-curator-types.ts +151 -0
- package/src/tools/agent-harness-learning-curator.ts +417 -0
- package/src/tools/agent-harness-local-model-benchmarks.ts +269 -0
- package/src/tools/agent-harness-local-model-cookbook.ts +238 -0
- package/src/tools/agent-harness-local-model-endpoints.ts +788 -0
- package/src/tools/agent-harness-local-model-smoke.ts +277 -0
- package/src/tools/agent-harness-local-model-url.ts +78 -0
- package/src/tools/agent-harness-media-posture.ts +223 -2
- package/src/tools/agent-harness-memory-external-providers.ts +796 -0
- package/src/tools/agent-harness-memory-posture.ts +672 -0
- package/src/tools/agent-harness-memory-provider-certification.ts +219 -0
- package/src/tools/agent-harness-memory-refinement.ts +340 -0
- package/src/tools/agent-harness-metadata.ts +100 -168
- package/src/tools/agent-harness-mode-catalog.ts +86 -33
- package/src/tools/agent-harness-model-catalog.ts +162 -0
- package/src/tools/agent-harness-model-provider-health.ts +283 -0
- package/src/tools/agent-harness-model-readiness.ts +432 -0
- package/src/tools/agent-harness-model-routing-types.ts +327 -0
- package/src/tools/agent-harness-model-routing-utils.ts +30 -0
- package/src/tools/agent-harness-model-routing.ts +165 -193
- package/src/tools/agent-harness-operator-methods.ts +115 -133
- package/src/tools/agent-harness-pairing-posture.ts +452 -18
- package/src/tools/agent-harness-personal-ops-certification.ts +116 -0
- package/src/tools/agent-harness-personal-ops-discovery.ts +533 -0
- package/src/tools/agent-harness-personal-ops-intake.ts +385 -0
- package/src/tools/agent-harness-personal-ops-lanes.ts +270 -0
- package/src/tools/agent-harness-personal-ops-operations.ts +225 -0
- package/src/tools/agent-harness-personal-ops-provider-records.ts +358 -0
- package/src/tools/agent-harness-personal-ops-provider-task-records.ts +321 -0
- package/src/tools/agent-harness-personal-ops-records.ts +684 -0
- package/src/tools/agent-harness-personal-ops-runner.ts +637 -0
- package/src/tools/agent-harness-personal-ops-types.ts +240 -0
- package/src/tools/agent-harness-personal-ops.ts +613 -0
- package/src/tools/agent-harness-project-context.ts +144 -0
- package/src/tools/agent-harness-prompt-context.ts +589 -0
- package/src/tools/agent-harness-provider-account-metadata.ts +2 -2
- package/src/tools/agent-harness-release-evidence.ts +9 -7
- package/src/tools/agent-harness-release-readiness.ts +9 -7
- package/src/tools/agent-harness-remote-read-models.ts +541 -0
- package/src/tools/agent-harness-research-briefing.ts +446 -0
- package/src/tools/agent-harness-research-live-read-models.ts +500 -0
- package/src/tools/agent-harness-research-queue.ts +250 -0
- package/src/tools/agent-harness-research-runs.ts +307 -0
- package/src/tools/agent-harness-research-workflow.ts +395 -0
- package/src/tools/agent-harness-security-posture.ts +2 -2
- package/src/tools/agent-harness-service-posture.ts +9 -9
- package/src/tools/agent-harness-session-metadata.ts +3 -3
- package/src/tools/agent-harness-setup-connected-host.ts +501 -0
- package/src/tools/agent-harness-setup-describe.ts +557 -0
- package/src/tools/agent-harness-setup-handoffs.ts +502 -0
- package/src/tools/agent-harness-setup-model-helpers.ts +102 -0
- package/src/tools/agent-harness-setup-plan.ts +253 -0
- package/src/tools/agent-harness-setup-posture-types.ts +218 -0
- package/src/tools/agent-harness-setup-posture-utils.ts +173 -0
- package/src/tools/agent-harness-setup-posture.ts +449 -221
- package/src/tools/agent-harness-setup-smoke.ts +533 -0
- package/src/tools/agent-harness-sudo-posture.ts +114 -0
- package/src/tools/agent-harness-tool-schema.ts +142 -7
- package/src/tools/agent-harness-tool-types.ts +83 -0
- package/src/tools/agent-harness-tool-utils.ts +43 -0
- package/src/tools/agent-harness-tool.ts +319 -370
- package/src/tools/agent-harness-ui-surface-metadata.ts +76 -69
- package/src/tools/agent-harness-ui-surface-types.ts +46 -0
- package/src/tools/agent-harness-vibe-health.ts +105 -0
- package/src/tools/agent-harness-workspace-action-runner.ts +149 -0
- package/src/tools/agent-harness-workspace-actions.ts +114 -8
- package/src/tools/agent-harness-workspace-editor-execution.ts +214 -0
- package/src/tools/agent-harness-workspace-editor-runner.ts +755 -0
- package/src/tools/agent-host-tool.ts +159 -0
- package/src/tools/agent-knowledge-ingest-tool.ts +34 -1
- package/src/tools/agent-learning-consolidation-core.ts +327 -0
- package/src/tools/agent-learning-consolidation-tool.ts +758 -0
- package/src/tools/agent-memory-tool.ts +253 -0
- package/src/tools/agent-model-compare-export.ts +315 -0
- package/src/tools/agent-model-compare-handoff.ts +592 -0
- package/src/tools/agent-model-compare-judgment.ts +633 -0
- package/src/tools/agent-model-compare-run.ts +735 -0
- package/src/tools/agent-model-compare-tool.ts +698 -0
- package/src/tools/agent-model-compare-types.ts +191 -0
- package/src/tools/agent-model-compare-utils.ts +93 -0
- package/src/tools/agent-models-tool.ts +208 -0
- package/src/tools/agent-operator-action-tool.ts +1 -1
- package/src/tools/agent-operator-method-tool.ts +643 -0
- package/src/tools/agent-personal-ops-tool.ts +197 -0
- package/src/tools/agent-policy-explanation.ts +415 -0
- package/src/tools/agent-research-report-tool.ts +608 -0
- package/src/tools/agent-research-runner.ts +367 -0
- package/src/tools/agent-research-runs-tool.ts +434 -0
- package/src/tools/agent-research-sources-tool.ts +443 -0
- package/src/tools/agent-research-tool.ts +515 -0
- package/src/tools/agent-review-packet-presets-core.ts +757 -0
- package/src/tools/agent-review-packet-presets-tool.ts +466 -0
- package/src/tools/agent-review-packet-share-tool.ts +305 -0
- package/src/tools/agent-route-planner-candidates-setup.ts +411 -0
- package/src/tools/agent-route-planner-candidates-surfaces.ts +432 -0
- package/src/tools/agent-route-planner-candidates-work.ts +251 -0
- package/src/tools/agent-route-planner-helpers.ts +667 -0
- package/src/tools/agent-route-planner.ts +185 -0
- package/src/tools/agent-route-tool.ts +105 -0
- package/src/tools/agent-schedule-edit-tool.ts +210 -0
- package/src/tools/agent-schedule-tool.ts +282 -0
- package/src/tools/agent-security-tool.ts +145 -0
- package/src/tools/agent-sessions-tool.ts +122 -0
- package/src/tools/agent-settings-import-tool.ts +104 -0
- package/src/tools/agent-settings-tool.ts +176 -0
- package/src/tools/agent-setup-tool.ts +226 -0
- package/src/tools/agent-support-tool.ts +122 -0
- package/src/tools/agent-terminal-process-tools.ts +167 -0
- package/src/tools/agent-tool-policy-guard-types.ts +77 -0
- package/src/tools/agent-tool-policy-guard.ts +106 -85
- package/src/tools/agent-vibe-tool.ts +297 -0
- package/src/tools/agent-work-plan-tool.ts +265 -6
- package/src/tools/agent-workspace-tool.ts +305 -0
- package/src/tools/artifact-archive.ts +169 -0
- package/src/tools/tool-definition-compaction.ts +36 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { previewHarnessText } from './agent-harness-text.ts';
|
|
2
|
+
import { readRecord, readString } from './agent-harness-model-routing-utils.ts';
|
|
3
|
+
|
|
4
|
+
export interface MemoryExternalProviderCertification {
|
|
5
|
+
readonly schemaStatus: 'certified' | 'legacy';
|
|
6
|
+
readonly schemaVersion?: string;
|
|
7
|
+
readonly publicationGuarantee?: string;
|
|
8
|
+
readonly publisher?: string;
|
|
9
|
+
readonly provenance?: readonly string[];
|
|
10
|
+
readonly receiptId?: string;
|
|
11
|
+
readonly receiptStatus?: string;
|
|
12
|
+
readonly receiptRoute?: string;
|
|
13
|
+
readonly receiptIds?: readonly string[];
|
|
14
|
+
readonly receiptStreamStatus?: string;
|
|
15
|
+
readonly missingSignals: readonly string[];
|
|
16
|
+
readonly policy: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const MEMORY_CERT_SECRET_PATTERNS: readonly [RegExp, string][] = [
|
|
20
|
+
[/secret:\/\/[^\s,'"}]+/gi, 'secret://<redacted>'],
|
|
21
|
+
[/("?\b(?:api[-_]?key|apikey|token|secret|password|passwd|credential|authorization)\b"?\s*:\s*)("[^"]*"|'[^']*'|[^\s,}]+)/gi, '$1"<redacted>"'],
|
|
22
|
+
[/\b([A-Z0-9_]*(?:API[_-]?KEY|TOKEN|SECRET|PASSWORD|PASSWD|CREDENTIAL|AUTHORIZATION|BEARER)[A-Z0-9_]*)=("[^"]*"|'[^']*'|[^\s]+)/gi, '$1=<redacted>'],
|
|
23
|
+
[/(\b(?:token|secret|password|passwd|api[-_]?key|apikey|authorization|credential)\s*[:=]\s*)("[^"]*"|'[^']*'|[^\s,}]+)/gi, '$1<redacted>'],
|
|
24
|
+
[/(Authorization:\s*Bearer\s+)[A-Za-z0-9._~+/=-]+/gi, '$1<redacted>'],
|
|
25
|
+
];
|
|
26
|
+
|
|
27
|
+
function redactedPreview(value: unknown, limit = 180): string {
|
|
28
|
+
const raw = readString(value);
|
|
29
|
+
const redacted = MEMORY_CERT_SECRET_PATTERNS.reduce((text, [pattern, replacement]) => text.replace(pattern, replacement), raw);
|
|
30
|
+
return previewHarnessText(redacted, limit);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function firstString(record: Readonly<Record<string, unknown>>, keys: readonly string[]): string {
|
|
34
|
+
for (const key of keys) {
|
|
35
|
+
const value = readString(record[key]);
|
|
36
|
+
if (value) return value;
|
|
37
|
+
}
|
|
38
|
+
return '';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function readStringArray(value: unknown): readonly string[] {
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
return [...new Set(value.map((entry) => readString(entry)).filter(Boolean))].slice(0, 12);
|
|
44
|
+
}
|
|
45
|
+
const text = readString(value);
|
|
46
|
+
return text ? text.split(',').map((entry) => entry.trim()).filter(Boolean).slice(0, 12) : [];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function recordsForCertification(record: Readonly<Record<string, unknown>>): readonly Readonly<Record<string, unknown>>[] {
|
|
50
|
+
return [
|
|
51
|
+
record,
|
|
52
|
+
readRecord(record.schema),
|
|
53
|
+
readRecord(record.contract),
|
|
54
|
+
readRecord(record.providerContract),
|
|
55
|
+
readRecord(record.memoryProviderContract),
|
|
56
|
+
readRecord(record.receipt),
|
|
57
|
+
readRecord(record.receiptContract),
|
|
58
|
+
readRecord(record.publication),
|
|
59
|
+
readRecord(record.certification),
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function firstAcross(records: readonly Readonly<Record<string, unknown>>[], keys: readonly string[]): string {
|
|
64
|
+
for (const record of records) {
|
|
65
|
+
const value = firstString(record, keys);
|
|
66
|
+
if (value) return value;
|
|
67
|
+
}
|
|
68
|
+
return '';
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function normalizeSchemaStatus(records: readonly Readonly<Record<string, unknown>>[]): MemoryExternalProviderCertification['schemaStatus'] {
|
|
72
|
+
const explicit = firstAcross(records, ['schemaStatus', 'receiptSchemaStatus', 'certificationStatus'])
|
|
73
|
+
.toLowerCase()
|
|
74
|
+
.replace(/[_\s]+/g, '-');
|
|
75
|
+
if (['certified', 'valid', 'verified', 'schema-certified'].includes(explicit)) return 'certified';
|
|
76
|
+
const schemaVersion = firstAcross(records, ['schemaVersion', 'receiptSchemaVersion', 'contractVersion']);
|
|
77
|
+
const publicationGuarantee = firstAcross(records, ['publicationGuarantee', 'hostPublicationGuarantee', 'providerPublicationGuarantee', 'memoryPublicationGuarantee']);
|
|
78
|
+
const proof = firstAcross(records, ['methodId', 'sourceTool', 'actionId', 'publisher', 'publisherId', 'daemonId', 'hostId']);
|
|
79
|
+
return schemaVersion && publicationGuarantee && proof ? 'certified' : 'legacy';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function receiptIds(record: Readonly<Record<string, unknown>>, records: readonly Readonly<Record<string, unknown>>[], extraIds: readonly string[]): readonly string[] {
|
|
83
|
+
const explicit = [
|
|
84
|
+
...extraIds,
|
|
85
|
+
...readStringArray(record.receiptIds),
|
|
86
|
+
...readStringArray(record.effectReceiptIds),
|
|
87
|
+
...readStringArray(record.providerReceiptIds),
|
|
88
|
+
...readStringArray(record.syncReceiptIds),
|
|
89
|
+
firstAcross(records, ['receiptId', 'effectReceiptId', 'readReceiptId', 'writeReceiptId', 'syncReceiptId', 'forgetReceiptId', 'operationReceiptId']),
|
|
90
|
+
].filter(Boolean);
|
|
91
|
+
return [...new Set(explicit.map((entry) => redactedPreview(entry, 96)))].slice(0, 12);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function provenance(record: Readonly<Record<string, unknown>>, records: readonly Readonly<Record<string, unknown>>[], sourcePath: string): readonly string[] {
|
|
95
|
+
const values = [
|
|
96
|
+
...readStringArray(record.provenance),
|
|
97
|
+
sourcePath ? `source ${sourcePath}` : '',
|
|
98
|
+
firstAcross(records, ['methodId']) ? `method ${firstAcross(records, ['methodId'])}` : '',
|
|
99
|
+
firstAcross(records, ['actionId']) ? `action ${firstAcross(records, ['actionId'])}` : '',
|
|
100
|
+
firstAcross(records, ['sourceTool']) ? `sourceTool ${firstAcross(records, ['sourceTool'])}` : '',
|
|
101
|
+
];
|
|
102
|
+
return [...new Set(values.map((entry) => redactedPreview(entry, 180)).filter(Boolean))].slice(0, 8);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function certifiedBase(input: {
|
|
106
|
+
readonly record: Readonly<Record<string, unknown>>;
|
|
107
|
+
readonly sourcePath: string;
|
|
108
|
+
readonly receiptIds?: readonly string[];
|
|
109
|
+
}): Omit<MemoryExternalProviderCertification, 'missingSignals' | 'policy'> & { readonly rawPublicationGuarantee: string; readonly rawPublisher: string; readonly rawReceiptRoute: string; readonly rawReceiptStreamStatus: string; readonly rawReceiptStatus: string; readonly rawSchemaVersion: string; readonly receiptIdsValue: readonly string[]; readonly schemaStatusValue: MemoryExternalProviderCertification['schemaStatus'] } {
|
|
110
|
+
const records = recordsForCertification(input.record);
|
|
111
|
+
const schemaStatus = normalizeSchemaStatus(records);
|
|
112
|
+
const schemaVersion = firstAcross(records, ['schemaVersion', 'receiptSchemaVersion', 'contractVersion']);
|
|
113
|
+
const publicationGuarantee = firstAcross(records, ['publicationGuarantee', 'hostPublicationGuarantee', 'providerPublicationGuarantee', 'memoryPublicationGuarantee']);
|
|
114
|
+
const publisher = firstAcross(records, ['publisher', 'publisherId', 'daemonId', 'hostId']);
|
|
115
|
+
const ids = receiptIds(input.record, records, input.receiptIds ?? []);
|
|
116
|
+
const receiptStatus = firstAcross(records, ['receiptStatus', 'receiptOutcome', 'operationStatus', 'status']);
|
|
117
|
+
const receiptRoute = firstAcross(records, ['receiptRoute', 'inspectReceiptRoute', 'artifactRoute']);
|
|
118
|
+
const receiptStreamStatus = firstAcross(records, ['receiptStreamStatus', 'receiptPublicationStatus', 'receiptsStatus', 'streamStatus']);
|
|
119
|
+
const proof = provenance(input.record, records, input.sourcePath);
|
|
120
|
+
return {
|
|
121
|
+
schemaStatus,
|
|
122
|
+
...(schemaVersion ? { schemaVersion: redactedPreview(schemaVersion, 80) } : {}),
|
|
123
|
+
...(publicationGuarantee ? { publicationGuarantee: redactedPreview(publicationGuarantee, 220) } : {}),
|
|
124
|
+
...(publisher ? { publisher: redactedPreview(publisher, 80) } : {}),
|
|
125
|
+
...(proof.length > 0 ? { provenance: proof } : {}),
|
|
126
|
+
...(ids[0] ? { receiptId: ids[0] } : {}),
|
|
127
|
+
...(receiptStatus ? { receiptStatus: redactedPreview(receiptStatus, 80) } : {}),
|
|
128
|
+
...(receiptRoute ? { receiptRoute: redactedPreview(receiptRoute, 180) } : {}),
|
|
129
|
+
...(ids.length > 0 ? { receiptIds: ids } : {}),
|
|
130
|
+
...(receiptStreamStatus ? { receiptStreamStatus: redactedPreview(receiptStreamStatus, 80) } : {}),
|
|
131
|
+
rawPublicationGuarantee: publicationGuarantee,
|
|
132
|
+
rawPublisher: publisher,
|
|
133
|
+
rawReceiptRoute: receiptRoute,
|
|
134
|
+
rawReceiptStreamStatus: receiptStreamStatus,
|
|
135
|
+
rawReceiptStatus: receiptStatus,
|
|
136
|
+
rawSchemaVersion: schemaVersion,
|
|
137
|
+
receiptIdsValue: ids,
|
|
138
|
+
schemaStatusValue: schemaStatus,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function memoryExternalProviderLiveCertification(input: {
|
|
143
|
+
readonly record: Readonly<Record<string, unknown>>;
|
|
144
|
+
readonly sourcePath: string;
|
|
145
|
+
readonly providerId: string;
|
|
146
|
+
readonly readContractPublished: boolean;
|
|
147
|
+
readonly writeContractPublished: boolean;
|
|
148
|
+
readonly syncContractPublished: boolean;
|
|
149
|
+
readonly forgetContractPublished: boolean;
|
|
150
|
+
readonly receiptIds: readonly string[];
|
|
151
|
+
readonly receiptRoute: string | null;
|
|
152
|
+
}): MemoryExternalProviderCertification {
|
|
153
|
+
const base = certifiedBase({ record: input.record, sourcePath: input.sourcePath, receiptIds: input.receiptIds });
|
|
154
|
+
const {
|
|
155
|
+
rawPublicationGuarantee,
|
|
156
|
+
rawPublisher,
|
|
157
|
+
rawReceiptRoute,
|
|
158
|
+
rawReceiptStreamStatus,
|
|
159
|
+
rawReceiptStatus,
|
|
160
|
+
rawSchemaVersion,
|
|
161
|
+
receiptIdsValue,
|
|
162
|
+
schemaStatusValue,
|
|
163
|
+
...certification
|
|
164
|
+
} = base;
|
|
165
|
+
const receiptPublished = base.receiptIdsValue.length > 0 || Boolean(input.receiptRoute) || Boolean(base.rawReceiptRoute) || Boolean(base.rawReceiptStreamStatus);
|
|
166
|
+
const missingSignals = [
|
|
167
|
+
...(schemaStatusValue === 'certified' ? [] : ['Certified external memory provider schema is not published.']),
|
|
168
|
+
...(input.providerId ? [] : ['Durable external memory provider id is not published.']),
|
|
169
|
+
...(rawPublicationGuarantee ? [] : ['Provider-side external memory publication guarantee is not published.']),
|
|
170
|
+
...(rawPublisher ? [] : ['Provider-side external memory publisher is not published.']),
|
|
171
|
+
...(certification.provenance?.length ? [] : ['Provider-side external memory provenance is not published.']),
|
|
172
|
+
...(input.readContractPublished ? [] : ['Bounded read/search contract is not published.']),
|
|
173
|
+
...(input.writeContractPublished ? [] : ['Confirmed write/upsert contract is not published.']),
|
|
174
|
+
...(input.syncContractPublished ? [] : ['Confirmed sync/import/export contract is not published.']),
|
|
175
|
+
...(input.forgetContractPublished ? [] : ['Forget/delete contract or explicit not-supported contract is not published.']),
|
|
176
|
+
...(receiptPublished ? [] : ['External memory provider receipt stream or receipt ids are not published.']),
|
|
177
|
+
];
|
|
178
|
+
return {
|
|
179
|
+
...certification,
|
|
180
|
+
...(input.receiptRoute && !certification.receiptRoute ? { receiptRoute: redactedPreview(input.receiptRoute, 180) } : {}),
|
|
181
|
+
missingSignals,
|
|
182
|
+
policy: 'External memory provider records certify release readiness only when the host or SDK publishes schema, durable provider id, publication guarantee, publisher/provenance, bounded read, confirmed write/sync, forget or explicit not-supported, and receipt stream evidence without raw secrets or memory bodies.',
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function memoryExternalProviderReceiptCertification(input: {
|
|
187
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
188
|
+
readonly sourcePath: string;
|
|
189
|
+
readonly providerId: string;
|
|
190
|
+
readonly artifactId: string;
|
|
191
|
+
}): MemoryExternalProviderCertification {
|
|
192
|
+
const base = certifiedBase({ record: input.metadata, sourcePath: input.sourcePath });
|
|
193
|
+
const {
|
|
194
|
+
rawPublicationGuarantee,
|
|
195
|
+
rawPublisher,
|
|
196
|
+
rawReceiptRoute,
|
|
197
|
+
rawReceiptStreamStatus,
|
|
198
|
+
rawReceiptStatus,
|
|
199
|
+
rawSchemaVersion,
|
|
200
|
+
receiptIdsValue,
|
|
201
|
+
schemaStatusValue,
|
|
202
|
+
...certification
|
|
203
|
+
} = base;
|
|
204
|
+
const missingSignals = [
|
|
205
|
+
...(schemaStatusValue === 'certified' ? [] : ['Certified external memory receipt schema is not published.']),
|
|
206
|
+
...(input.providerId ? [] : ['Durable external memory provider id is not published.']),
|
|
207
|
+
...(input.artifactId || receiptIdsValue.length > 0 ? [] : ['Durable external memory receipt id is not published.']),
|
|
208
|
+
...(rawPublicationGuarantee ? [] : ['Provider-side external memory receipt publication guarantee is not published.']),
|
|
209
|
+
...(rawPublisher ? [] : ['Provider-side external memory receipt publisher is not published.']),
|
|
210
|
+
...(certification.provenance?.length ? [] : ['Provider-side external memory receipt provenance is not published.']),
|
|
211
|
+
...(receiptIdsValue.length > 0 ? [] : ['Confirmed external memory operation receipt id is not published.']),
|
|
212
|
+
];
|
|
213
|
+
return {
|
|
214
|
+
...certification,
|
|
215
|
+
...(certification.receiptId ? {} : { receiptId: redactedPreview(input.artifactId, 96), receiptIds: [redactedPreview(input.artifactId, 96)] }),
|
|
216
|
+
missingSignals,
|
|
217
|
+
policy: 'External memory receipt artifacts certify release evidence only when they include schema, durable provider and receipt ids, publication guarantee, publisher/provenance, status, redaction posture, and inspectable follow-up route metadata.',
|
|
218
|
+
};
|
|
219
|
+
}
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
KnowledgeRefinementTaskRecord,
|
|
3
|
+
KnowledgeSemanticSelfImproveResult,
|
|
4
|
+
} from '@pellux/goodvibes-sdk/platform/knowledge';
|
|
5
|
+
import type { CommandContext } from '../input/command-registry.ts';
|
|
6
|
+
import { previewHarnessText } from './agent-harness-text.ts';
|
|
7
|
+
|
|
8
|
+
interface AgentHarnessMemoryRefinementArgs {
|
|
9
|
+
readonly query?: unknown;
|
|
10
|
+
readonly target?: unknown;
|
|
11
|
+
readonly knowledgeSpaceId?: unknown;
|
|
12
|
+
readonly sourceIds?: unknown;
|
|
13
|
+
readonly gapIds?: unknown;
|
|
14
|
+
readonly limit?: unknown;
|
|
15
|
+
readonly maxRunMs?: unknown;
|
|
16
|
+
readonly timeoutMs?: unknown;
|
|
17
|
+
readonly force?: unknown;
|
|
18
|
+
readonly includeParameters?: unknown;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface KnowledgeRefinementService {
|
|
22
|
+
listRefinementTasks?: (
|
|
23
|
+
limit?: number,
|
|
24
|
+
input?: {
|
|
25
|
+
readonly spaceId?: string;
|
|
26
|
+
readonly state?: string;
|
|
27
|
+
readonly subjectKind?: string;
|
|
28
|
+
readonly subjectId?: string;
|
|
29
|
+
readonly gapId?: string;
|
|
30
|
+
},
|
|
31
|
+
) => readonly KnowledgeRefinementTaskRecord[];
|
|
32
|
+
getRefinementTask?: (id: string) => KnowledgeRefinementTaskRecord | null;
|
|
33
|
+
runRefinement?: (input?: {
|
|
34
|
+
readonly knowledgeSpaceId?: string;
|
|
35
|
+
readonly sourceIds?: readonly string[];
|
|
36
|
+
readonly gapIds?: readonly string[];
|
|
37
|
+
readonly limit?: number;
|
|
38
|
+
readonly maxRunMs?: number;
|
|
39
|
+
readonly force?: boolean;
|
|
40
|
+
}) => Promise<KnowledgeSemanticSelfImproveResult>;
|
|
41
|
+
listJobs?: () => readonly {
|
|
42
|
+
readonly id: string;
|
|
43
|
+
readonly kind: string;
|
|
44
|
+
readonly title: string;
|
|
45
|
+
readonly description: string;
|
|
46
|
+
readonly defaultMode: string;
|
|
47
|
+
}[];
|
|
48
|
+
listJobRuns?: (limit?: number, jobId?: string) => readonly {
|
|
49
|
+
readonly id: string;
|
|
50
|
+
readonly jobId: string;
|
|
51
|
+
readonly status: string;
|
|
52
|
+
readonly mode: string;
|
|
53
|
+
readonly requestedAt: number;
|
|
54
|
+
readonly completedAt?: number;
|
|
55
|
+
readonly error?: string;
|
|
56
|
+
}[];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const ACTIVE_STATES = new Set(['detected', 'queued', 'searching', 'evaluating', 'extracting', 'applying', 'verified']);
|
|
60
|
+
const ATTENTION_STATES = new Set(['blocked', 'needs_review', 'failed']);
|
|
61
|
+
|
|
62
|
+
function readString(value: unknown): string {
|
|
63
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function readStringArray(value: unknown): readonly string[] {
|
|
67
|
+
if (Array.isArray(value)) return value.filter((entry): entry is string => typeof entry === 'string').map((entry) => entry.trim()).filter(Boolean);
|
|
68
|
+
const text = readString(value);
|
|
69
|
+
if (!text) return [];
|
|
70
|
+
return text.split(',').map((entry) => entry.trim()).filter(Boolean);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function readLimit(value: unknown, fallback: number, max = 100): number {
|
|
74
|
+
const parsed = typeof value === 'string' && value.trim() ? Number(value) : value;
|
|
75
|
+
if (typeof parsed !== 'number' || !Number.isFinite(parsed)) return fallback;
|
|
76
|
+
return Math.max(1, Math.min(max, Math.trunc(parsed)));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function readRunBudgetMs(value: unknown): number | undefined {
|
|
80
|
+
const parsed = typeof value === 'string' && value.trim() ? Number(value) : value;
|
|
81
|
+
if (typeof parsed !== 'number' || !Number.isFinite(parsed)) return undefined;
|
|
82
|
+
return Math.max(5_000, Math.min(60_000, Math.trunc(parsed)));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function knowledgeService(context: CommandContext): KnowledgeRefinementService | null {
|
|
86
|
+
const service = context.extensions?.agentKnowledgeService;
|
|
87
|
+
return service && typeof service === 'object' ? service as KnowledgeRefinementService : null;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function iso(value: number | undefined): string | null {
|
|
91
|
+
return typeof value === 'number' && Number.isFinite(value) ? new Date(value).toISOString() : null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function routeValue(value: string): string {
|
|
95
|
+
return JSON.stringify(value);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function taskSearchText(task: KnowledgeRefinementTaskRecord): string {
|
|
99
|
+
return [
|
|
100
|
+
task.id,
|
|
101
|
+
task.spaceId,
|
|
102
|
+
task.state,
|
|
103
|
+
task.priority,
|
|
104
|
+
task.trigger,
|
|
105
|
+
task.subjectTitle ?? '',
|
|
106
|
+
task.subjectId ?? '',
|
|
107
|
+
task.subjectType ?? '',
|
|
108
|
+
task.gapId ?? '',
|
|
109
|
+
task.issueId ?? '',
|
|
110
|
+
task.blockedReason ?? '',
|
|
111
|
+
readString(task.metadata.gapTitle),
|
|
112
|
+
readString(task.metadata.gapKind),
|
|
113
|
+
].join('\n').toLowerCase();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function compactTask(task: KnowledgeRefinementTaskRecord, includeParameters: boolean): Record<string, unknown> {
|
|
117
|
+
const latestTrace = task.trace.at(-1);
|
|
118
|
+
const accepted = task.acceptedSourceIds ?? [];
|
|
119
|
+
const ingested = task.ingestedSourceIds ?? [];
|
|
120
|
+
return {
|
|
121
|
+
taskId: task.id,
|
|
122
|
+
spaceId: task.spaceId,
|
|
123
|
+
state: task.state,
|
|
124
|
+
priority: task.priority,
|
|
125
|
+
trigger: task.trigger,
|
|
126
|
+
...(task.subjectTitle ? { subject: previewHarnessText(task.subjectTitle, includeParameters ? 140 : 80) } : {}),
|
|
127
|
+
...(task.subjectId ? { subjectId: task.subjectId } : {}),
|
|
128
|
+
...(task.gapId ? { gapId: task.gapId } : {}),
|
|
129
|
+
attemptCount: task.attemptCount,
|
|
130
|
+
...(task.blockedReason ? { blockedReason: previewHarnessText(task.blockedReason, includeParameters ? 180 : 96) } : {}),
|
|
131
|
+
acceptedSourceCount: accepted.length,
|
|
132
|
+
ingestedSourceCount: ingested.length,
|
|
133
|
+
promotedFactCount: task.promotedFactCount ?? 0,
|
|
134
|
+
updatedAt: iso(task.updatedAt),
|
|
135
|
+
inspectRoute: `memory action:"refinement" query:${routeValue(task.id)} includeParameters:true`,
|
|
136
|
+
rerunRoute: task.gapId
|
|
137
|
+
? `memory action:"run_refinement" gapIds:[${routeValue(task.gapId)}] confirm:true explicitUserRequest:"..."`
|
|
138
|
+
: `memory action:"run_refinement" knowledgeSpaceId:${routeValue(task.spaceId)} limit:1 confirm:true explicitUserRequest:"..."`,
|
|
139
|
+
...(latestTrace ? {
|
|
140
|
+
latestTrace: {
|
|
141
|
+
at: iso(latestTrace.at),
|
|
142
|
+
state: latestTrace.state,
|
|
143
|
+
message: previewHarnessText(latestTrace.message, includeParameters ? 180 : 96),
|
|
144
|
+
},
|
|
145
|
+
} : {}),
|
|
146
|
+
...(includeParameters ? {
|
|
147
|
+
budget: task.budget,
|
|
148
|
+
acceptedSourceIds: accepted,
|
|
149
|
+
ingestedSourceIds: ingested,
|
|
150
|
+
rejectedSourceUrls: task.rejectedSourceUrls ?? [],
|
|
151
|
+
sourceAssessments: (task.sourceAssessments ?? []).slice(0, 5).map((entry) => ({
|
|
152
|
+
url: previewHarnessText(entry.url, 120),
|
|
153
|
+
accepted: entry.accepted,
|
|
154
|
+
confidence: entry.confidence,
|
|
155
|
+
reasons: entry.reasons.slice(0, 3),
|
|
156
|
+
})),
|
|
157
|
+
} : {}),
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function taskCounts(tasks: readonly KnowledgeRefinementTaskRecord[]): Record<string, number> {
|
|
162
|
+
const counts: Record<string, number> = {
|
|
163
|
+
total: tasks.length,
|
|
164
|
+
active: tasks.filter((task) => ACTIVE_STATES.has(task.state)).length,
|
|
165
|
+
attention: tasks.filter((task) => ATTENTION_STATES.has(task.state)).length,
|
|
166
|
+
closed: tasks.filter((task) => task.state === 'closed').length,
|
|
167
|
+
suppressed: tasks.filter((task) => task.state === 'suppressed').length,
|
|
168
|
+
cancelled: tasks.filter((task) => task.state === 'cancelled').length,
|
|
169
|
+
};
|
|
170
|
+
for (const task of tasks) counts[task.state] = (counts[task.state] ?? 0) + 1;
|
|
171
|
+
return counts;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function semanticJob(service: KnowledgeRefinementService): ReturnType<NonNullable<KnowledgeRefinementService['listJobs']>>[number] | null {
|
|
175
|
+
return service.listJobs?.().find((job) => job.kind === 'semantic-self-improvement' || job.id === 'knowledge-semantic-self-improvement') ?? null;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function memoryRefinementCatalogStatus(context: CommandContext): Record<string, unknown> {
|
|
179
|
+
const service = knowledgeService(context);
|
|
180
|
+
const tasks = service?.listRefinementTasks?.(1_000) ?? [];
|
|
181
|
+
const counts = taskCounts(tasks);
|
|
182
|
+
return {
|
|
183
|
+
modes: ['memory_refinement', 'run_memory_refinement'],
|
|
184
|
+
status: !service?.listRefinementTasks && !service?.runRefinement
|
|
185
|
+
? 'unavailable'
|
|
186
|
+
: counts.attention > 0
|
|
187
|
+
? 'attention'
|
|
188
|
+
: counts.active > 0
|
|
189
|
+
? 'active'
|
|
190
|
+
: counts.total > 0
|
|
191
|
+
? 'ready'
|
|
192
|
+
: 'empty',
|
|
193
|
+
serviceAvailable: Boolean(service),
|
|
194
|
+
taskCounts: counts,
|
|
195
|
+
semanticJobPublished: Boolean(service ? semanticJob(service) : null),
|
|
196
|
+
readOnlyRoute: 'memory action:"refinement"',
|
|
197
|
+
confirmedRunRoute: 'memory action:"run_refinement" confirm:true explicitUserRequest:"..."',
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export function memoryRefinementSummary(context: CommandContext, args: AgentHarnessMemoryRefinementArgs): Record<string, unknown> {
|
|
202
|
+
const includeParameters = args.includeParameters === true;
|
|
203
|
+
const service = knowledgeService(context);
|
|
204
|
+
if (!service?.listRefinementTasks && !service?.runRefinement) {
|
|
205
|
+
return {
|
|
206
|
+
status: 'unavailable',
|
|
207
|
+
summary: 'Agent Knowledge semantic refinement is not available in this runtime.',
|
|
208
|
+
requiredService: 'extensions.agentKnowledgeService.listRefinementTasks and runRefinement',
|
|
209
|
+
routes: {
|
|
210
|
+
knowledgeStatus: 'agent_knowledge action:"status"',
|
|
211
|
+
memoryCurator: 'memory action:"curator" includeParameters:true',
|
|
212
|
+
},
|
|
213
|
+
policy: 'No refinement mutation is attempted from posture inspection.',
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const query = (readString(args.query) || readString(args.target)).toLowerCase();
|
|
218
|
+
const limit = readLimit(args.limit, 25, 100);
|
|
219
|
+
const spaceId = readString(args.knowledgeSpaceId);
|
|
220
|
+
const allTasks = service.listRefinementTasks?.(1_000, spaceId ? { spaceId } : undefined) ?? [];
|
|
221
|
+
const filtered = allTasks.filter((task) => !query || taskSearchText(task).includes(query));
|
|
222
|
+
const counts = taskCounts(allTasks);
|
|
223
|
+
const job = semanticJob(service);
|
|
224
|
+
const latestRun = job ? service.listJobRuns?.(1, job.id)?.[0] : null;
|
|
225
|
+
|
|
226
|
+
return {
|
|
227
|
+
status: counts.attention > 0 ? 'attention' : counts.active > 0 ? 'active' : counts.total > 0 ? 'ready' : 'empty',
|
|
228
|
+
userOutcome: 'Semantic self-improvement is a supervised Agent Knowledge refinement lane: gaps and repair tasks stay inspectable before any source search, ingest, or prompt expansion.',
|
|
229
|
+
taskCounts: counts,
|
|
230
|
+
tasks: filtered.slice(0, limit).map((task) => compactTask(task, includeParameters)),
|
|
231
|
+
returned: Math.min(filtered.length, limit),
|
|
232
|
+
total: filtered.length,
|
|
233
|
+
semanticSelfImprovementJob: job ? {
|
|
234
|
+
id: job.id,
|
|
235
|
+
title: job.title,
|
|
236
|
+
defaultMode: job.defaultMode,
|
|
237
|
+
description: previewHarnessText(job.description, includeParameters ? 180 : 96),
|
|
238
|
+
runRoute: 'memory action:"run_refinement" confirm:true explicitUserRequest:"..."',
|
|
239
|
+
...(latestRun ? {
|
|
240
|
+
latestRun: {
|
|
241
|
+
id: latestRun.id,
|
|
242
|
+
status: latestRun.status,
|
|
243
|
+
mode: latestRun.mode,
|
|
244
|
+
requestedAt: iso(latestRun.requestedAt),
|
|
245
|
+
completedAt: iso(latestRun.completedAt),
|
|
246
|
+
...(latestRun.error ? { error: previewHarnessText(latestRun.error, 120) } : {}),
|
|
247
|
+
},
|
|
248
|
+
} : {}),
|
|
249
|
+
} : {
|
|
250
|
+
status: 'not-published',
|
|
251
|
+
description: 'KnowledgeService.runRefinement is available, but the scheduled semantic-self-improvement job is not listed.',
|
|
252
|
+
},
|
|
253
|
+
routes: {
|
|
254
|
+
inspect: 'memory action:"refinement" includeParameters:true',
|
|
255
|
+
inspectTask: 'memory action:"refinement" query:"<taskId>" includeParameters:true',
|
|
256
|
+
runManual: 'memory action:"run_refinement" limit:12 confirm:true explicitUserRequest:"..."',
|
|
257
|
+
runScopedSpace: 'memory action:"run_refinement" knowledgeSpaceId:"<spaceId>" limit:12 confirm:true explicitUserRequest:"..."',
|
|
258
|
+
runScopedGaps: 'memory action:"run_refinement" gapIds:["<gapId>"] confirm:true explicitUserRequest:"..."',
|
|
259
|
+
knowledgeStatus: 'agent_knowledge action:"status"',
|
|
260
|
+
memoryCurator: 'memory action:"curator" includeParameters:true',
|
|
261
|
+
},
|
|
262
|
+
nextActions: [
|
|
263
|
+
counts.attention > 0 ? 'Inspect blocked or failed refinement tasks before running a broader semantic self-improvement pass.' : '',
|
|
264
|
+
counts.active > 0 ? 'Let active refinement tasks finish or inspect their trace before starting another broad run.' : '',
|
|
265
|
+
counts.total === 0 ? 'Run a small confirmed manual refinement after useful Agent Knowledge sources exist.' : '',
|
|
266
|
+
'Keep reviewed Agent-local memory as the active prompt path until refined Knowledge evidence is inspected and promoted through existing confirmed routes.',
|
|
267
|
+
].filter(Boolean),
|
|
268
|
+
policy: 'Read-only refinement inspection never searches, ingests, writes prompt memory, or mutates Knowledge. Manual refinement runs require confirm:true and explicitUserRequest.',
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export async function runMemoryRefinement(context: CommandContext, args: AgentHarnessMemoryRefinementArgs): Promise<Record<string, unknown>> {
|
|
273
|
+
const service = knowledgeService(context);
|
|
274
|
+
if (!service?.runRefinement) {
|
|
275
|
+
return {
|
|
276
|
+
status: 'unavailable',
|
|
277
|
+
error: 'Agent Knowledge semantic refinement runner is not available in this runtime.',
|
|
278
|
+
inspectRoute: 'memory action:"refinement" includeParameters:true',
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
const sourceIds = readStringArray(args.sourceIds);
|
|
282
|
+
const gapIds = readStringArray(args.gapIds);
|
|
283
|
+
const knowledgeSpaceId = readString(args.knowledgeSpaceId);
|
|
284
|
+
const limit = readLimit(args.limit, 12, 24);
|
|
285
|
+
const maxRunMs = readRunBudgetMs(args.maxRunMs) ?? readRunBudgetMs(args.timeoutMs);
|
|
286
|
+
const run = await service.runRefinement({
|
|
287
|
+
...(knowledgeSpaceId ? { knowledgeSpaceId } : {}),
|
|
288
|
+
...(sourceIds.length > 0 ? { sourceIds } : {}),
|
|
289
|
+
...(gapIds.length > 0 ? { gapIds } : {}),
|
|
290
|
+
limit,
|
|
291
|
+
...(maxRunMs ? { maxRunMs } : {}),
|
|
292
|
+
...(args.force === true ? { force: true } : {}),
|
|
293
|
+
});
|
|
294
|
+
return {
|
|
295
|
+
status: run.errors.length > 0 || run.blockedGaps > 0 ? 'completed-with-attention' : 'completed',
|
|
296
|
+
result: {
|
|
297
|
+
scannedGaps: run.scannedGaps,
|
|
298
|
+
candidateGaps: run.candidateGaps ?? 0,
|
|
299
|
+
processedGaps: run.processedGaps ?? 0,
|
|
300
|
+
createdGaps: run.createdGaps,
|
|
301
|
+
repairableGaps: run.repairableGaps,
|
|
302
|
+
suppressedGaps: run.suppressedGaps,
|
|
303
|
+
skippedGaps: run.skippedGaps,
|
|
304
|
+
searched: run.searched,
|
|
305
|
+
ingestedSources: run.ingestedSources,
|
|
306
|
+
linkedRepairs: run.linkedRepairs,
|
|
307
|
+
blockedGaps: run.blockedGaps,
|
|
308
|
+
closedGaps: run.closedGaps,
|
|
309
|
+
queuedTasks: run.queuedTasks,
|
|
310
|
+
requestedLimit: run.requestedLimit ?? limit,
|
|
311
|
+
effectiveLimit: run.effectiveLimit ?? 0,
|
|
312
|
+
truncated: Boolean(run.truncated),
|
|
313
|
+
budgetExhausted: Boolean(run.budgetExhausted),
|
|
314
|
+
taskIds: run.taskIds,
|
|
315
|
+
acceptedSourceIds: run.acceptedSourceIds ?? [],
|
|
316
|
+
ingestedSourceIds: run.ingestedSourceIds,
|
|
317
|
+
promotedFactCount: run.promotedFactCount ?? 0,
|
|
318
|
+
...(run.nextRepairAttemptAt ? { nextRepairAttemptAt: iso(run.nextRepairAttemptAt) } : {}),
|
|
319
|
+
errors: run.errors.map((entry) => ({
|
|
320
|
+
gapId: entry.gapId,
|
|
321
|
+
error: previewHarnessText(entry.error, 160),
|
|
322
|
+
})),
|
|
323
|
+
},
|
|
324
|
+
scope: {
|
|
325
|
+
...(knowledgeSpaceId ? { knowledgeSpaceId } : {}),
|
|
326
|
+
...(sourceIds.length > 0 ? { sourceIds } : {}),
|
|
327
|
+
...(gapIds.length > 0 ? { gapIds } : {}),
|
|
328
|
+
limit,
|
|
329
|
+
...(maxRunMs ? { maxRunMs } : {}),
|
|
330
|
+
force: args.force === true,
|
|
331
|
+
},
|
|
332
|
+
nextRoutes: {
|
|
333
|
+
refinement: 'memory action:"refinement" includeParameters:true',
|
|
334
|
+
curator: 'memory action:"curator" includeParameters:true',
|
|
335
|
+
tasks: run.taskIds.map((taskId) => `memory action:"refinement" query:${routeValue(taskId)} includeParameters:true`).slice(0, 8),
|
|
336
|
+
knowledgeStatus: 'agent_knowledge action:"status"',
|
|
337
|
+
},
|
|
338
|
+
policy: 'Confirmed semantic refinement updates only Agent Knowledge semantic gaps/refinement tasks and source-backed repair evidence through KnowledgeService.runRefinement. It does not write Agent-local prompt memory, external memory providers, channel messages, or reports.',
|
|
339
|
+
};
|
|
340
|
+
}
|