@aiwg/cli 2026.10.1 → 2026.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/agentic/code/providers/capability-matrix.yaml +270 -0
- package/agentic/code/providers/model-capabilities.v1.json +3183 -24
- package/bin/aiwg.mjs +135 -47
- package/dist/src/a2a/codecs.js +9 -0
- package/dist/src/agents/grounding/knowledge-base.js +54 -6
- package/dist/src/artifacts/browser-export.js +6 -0
- package/dist/src/artifacts/checksum-manifest.js +1 -0
- package/dist/src/artifacts/citation-parser.js +173 -92
- package/dist/src/artifacts/citation-table-schema.js +59 -0
- package/dist/src/artifacts/cli.js +57 -18
- package/dist/src/artifacts/corpus-tools/snapshot.js +1 -1
- package/dist/src/artifacts/corpus-tools/vision-extract.js +107 -15
- package/dist/src/artifacts/corpus-views/ref-parser.js +3 -1
- package/dist/src/artifacts/corpus-views/renderers.js +3 -3
- package/dist/src/artifacts/discovery-eval.js +6 -4
- package/dist/src/artifacts/fortemi-core-query-adapter.js +36 -3
- package/dist/src/artifacts/fortemi-core-sync.js +166 -40
- package/dist/src/artifacts/framework-capabilities.js +171 -0
- package/dist/src/artifacts/framework-index-paths.js +73 -0
- package/dist/src/artifacts/framework-source-digest.js +75 -0
- package/dist/src/artifacts/index-builder.js +285 -131
- package/dist/src/artifacts/index-files.js +132 -18
- package/dist/src/artifacts/index-preparation.js +65 -0
- package/dist/src/artifacts/index-refresh.js +576 -0
- package/dist/src/artifacts/index-worker.mjs +9 -0
- package/dist/src/artifacts/prebuilt-build-lock.js +47 -4
- package/dist/src/artifacts/prebuilt-deployment.js +46 -0
- package/dist/src/artifacts/prebuilt-relations.js +80 -0
- package/dist/src/artifacts/query-engine.js +410 -88
- package/dist/src/artifacts/relations-builder.js +168 -0
- package/dist/src/artifacts/relations.js +148 -0
- package/dist/src/artifacts/repair.js +9 -4
- package/dist/src/artifacts/stats.js +5 -2
- package/dist/src/artifacts/types.js +30 -10
- package/dist/src/artifacts/watcher.js +1 -1
- package/dist/src/auth/credential-store.js +2 -1
- package/dist/src/catalog/cli.d.mts +5 -0
- package/dist/src/channel/manager.d.mts +20 -0
- package/dist/src/channel/manager.mjs +78 -12
- package/dist/src/cli/child-process-result.js +40 -0
- package/dist/src/cli/command-log.js +2 -3
- package/dist/src/cli/env.js +38 -16
- package/dist/src/cli/flag-parsing.js +236 -0
- package/dist/src/cli/handlers/artifacts.js +3 -0
- package/dist/src/cli/handlers/auth.js +3 -0
- package/dist/src/cli/handlers/decision.js +218 -5
- package/dist/src/cli/handlers/diagnose.js +13 -5
- package/dist/src/cli/handlers/effect.js +4 -2
- package/dist/src/cli/handlers/evidence.js +3 -0
- package/dist/src/cli/handlers/feedback.js +14 -5
- package/dist/src/cli/handlers/help.js +1 -0
- package/dist/src/cli/handlers/index.js +3 -1
- package/dist/src/cli/handlers/init.js +248 -30
- package/dist/src/cli/handlers/lint.js +5 -0
- package/dist/src/cli/handlers/mc.js +23 -0
- package/dist/src/cli/handlers/models.js +169 -10
- package/dist/src/cli/handlers/ralph-launcher.js +2 -0
- package/dist/src/cli/handlers/ralph.js +3 -0
- package/dist/src/cli/handlers/refresh.js +28 -0
- package/dist/src/cli/handlers/regenerate.js +14 -0
- package/dist/src/cli/handlers/resource-versions.js +3 -0
- package/dist/src/cli/handlers/rules.js +195 -0
- package/dist/src/cli/handlers/run.js +4 -0
- package/dist/src/cli/handlers/runtime-info.js +25 -11
- package/dist/src/cli/handlers/script-runner.js +19 -8
- package/dist/src/cli/handlers/session.js +406 -62
- package/dist/src/cli/handlers/sessions.js +243 -76
- package/dist/src/cli/handlers/setup-manifest.js +474 -79
- package/dist/src/cli/handlers/setup.js +180 -39
- package/dist/src/cli/handlers/steward.js +11 -0
- package/dist/src/cli/handlers/subcommands.js +60 -3
- package/dist/src/cli/handlers/team.js +18 -8
- package/dist/src/cli/handlers/uhp.js +3 -0
- package/dist/src/cli/handlers/use.js +307 -55
- package/dist/src/cli/handlers/utilities.js +125 -26
- package/dist/src/cli/handlers/version.js +8 -0
- package/dist/src/cli/prompt-utils.js +72 -0
- package/dist/src/cli/provider-resolution.js +11 -0
- package/dist/src/cli/router.js +15 -1
- package/dist/src/cli/services/deployment-verification.js +19 -9
- package/dist/src/cli/services/provider-prepare-coordinator.js +24 -0
- package/dist/src/cli/skill-usage.js +2 -3
- package/dist/src/config/aiwg-config.js +349 -35
- package/dist/src/config/cli.js +256 -23
- package/dist/src/config/decision-config.js +106 -0
- package/dist/src/config/dispatch-thresholds-runtime.d.mts +8 -0
- package/dist/src/config/dispatch-thresholds-runtime.mjs +38 -0
- package/dist/src/config/gitignore.js +50 -0
- package/dist/src/config/index-graph-overrides.js +36 -0
- package/dist/src/config/project-artifacts-health.d.mts +37 -0
- package/dist/src/config/project-artifacts-health.mjs +14 -3
- package/dist/src/config/project-artifacts-runtime.d.mts +16 -0
- package/dist/src/config/user-config-dir.d.mts +9 -0
- package/dist/src/config/user-config.js +38 -11
- package/dist/src/config/user-registry.js +23 -15
- package/dist/src/config/user-state.js +7 -0
- package/dist/src/decision/adapters/jev.js +75 -27
- package/dist/src/decision/ask.js +203 -43
- package/dist/src/decision/context-live-qualification.js +2 -2
- package/dist/src/decision/driver.js +14 -7
- package/dist/src/decision/ensemble/aggregate.js +23 -10
- package/dist/src/decision/ensemble-study/multifact-study.js +6 -2
- package/dist/src/decision/entry.js +25 -6
- package/dist/src/decision/graph-live-qualification.js +1 -1
- package/dist/src/decision/graph-run.js +9 -0
- package/dist/src/decision/heldout/collector.js +15 -14
- package/dist/src/decision/heldout/contract.js +30 -7
- package/dist/src/decision/index.js +1 -0
- package/dist/src/decision/interop.js +60 -8
- package/dist/src/decision/jev-credentials.js +15 -1
- package/dist/src/decision/ledger.js +942 -0
- package/dist/src/decision/offload-activation.js +137 -0
- package/dist/src/decision/offload.js +550 -0
- package/dist/src/decision/qualification/load.js +4 -6
- package/dist/src/decision/savings.js +28 -0
- package/dist/src/decision/validate.js +6 -3
- package/dist/src/effects/dispatch-verifier.js +252 -0
- package/dist/src/effects/index.js +1 -0
- package/dist/src/effects/types.js +5 -1
- package/dist/src/effects/verifiers/git.js +2 -1
- package/dist/src/effects/verifiers/tracker.js +26 -14
- package/dist/src/extensions/commands/definitions.js +19 -0
- package/dist/src/extensions/project-local-remove.js +36 -1
- package/dist/src/features/installer.js +2 -2
- package/dist/src/flow/graph-metadata.js +5 -0
- package/dist/src/gates/providers/loader.js +64 -18
- package/dist/src/installation/manager-command.d.mts +18 -0
- package/dist/src/installation/manager-command.mjs +15 -3
- package/dist/src/installation/manager.d.mts +49 -0
- package/dist/src/installation/manager.mjs +95 -5
- package/dist/src/issues/cli.js +4 -4
- package/dist/src/issues/local.js +24 -5
- package/dist/src/jobs/runner.js +1 -1
- package/dist/src/lint/cli.js +27 -1
- package/dist/src/lint/loader.js +2 -1
- package/dist/src/lint/reporters.js +25 -1
- package/dist/src/lint/rule-activation.js +43 -0
- package/dist/src/lint/runner.js +137 -62
- package/dist/src/mcp/adapters/codex-runtime.js +366 -56
- package/dist/src/mcp/claude-install.d.mts +4 -0
- package/dist/src/mcp/claude-install.mjs +41 -0
- package/dist/src/mcp/cli.d.mts +1 -0
- package/dist/src/mcp/cli.mjs +620 -85
- package/dist/src/mcp/config-file.d.mts +28 -0
- package/dist/src/mcp/config-file.mjs +279 -0
- package/dist/src/mcp/config-layers.d.mts +36 -0
- package/dist/src/mcp/config-layers.mjs +348 -0
- package/dist/src/mcp/credentials.d.mts +51 -0
- package/dist/src/mcp/credentials.mjs +484 -0
- package/dist/src/mcp/grok-build-config.d.mts +6 -0
- package/dist/src/mcp/grok-build-config.mjs +17 -27
- package/dist/src/mcp/helpers.mjs +109 -4
- package/dist/src/mcp/muse-native-config.d.mts +13 -0
- package/dist/src/mcp/muse-native-config.mjs +1 -0
- package/dist/src/mcp/omp-config.d.mts +4 -0
- package/dist/src/mcp/omp-config.mjs +50 -29
- package/dist/src/mcp/profiles.js +97 -23
- package/dist/src/mcp/profiles.mjs +99 -27
- package/dist/src/mcp/registry.js +248 -131
- package/dist/src/mcp/registry.mjs +169 -100
- package/dist/src/mcp/server-config.d.mts +3 -0
- package/dist/src/mcp/server-config.mjs +89 -0
- package/dist/src/mcp/server.mjs +127 -82
- package/dist/src/mcp/test-simple.mjs +2 -1
- package/dist/src/mcp/toml-editor.d.mts +4 -0
- package/dist/src/mcp/toml-string.d.mts +1 -0
- package/dist/src/mcp/toml-string.mjs +9 -0
- package/dist/src/mcp/toml-strip-mcp.d.mts +1 -0
- package/dist/src/mcp/toml-strip-mcp.mjs +135 -0
- package/dist/src/mcp/tool-filters.d.mts +46 -0
- package/dist/src/mcp/tool-filters.mjs +357 -0
- package/dist/src/mcp/tools/agentic-sandbox.mjs +3 -1
- package/dist/src/mcp/tools/decision.mjs +22 -3
- package/dist/src/mcp/tools/discovery.mjs +62 -55
- package/dist/src/mcp/tools/orchestration.mjs +50 -2
- package/dist/src/mcp/tools/subsystems.mjs +39 -8
- package/dist/src/mcp/tools/worker-invoke.mjs +2856 -0
- package/dist/src/mcp/tools/worker-shell-control.mjs +289 -0
- package/dist/src/mcp/tools/worker-stdin-runtime.mjs +79 -0
- package/dist/src/memory/project-registry.js +2 -2
- package/dist/src/mission-protocol/codecs.js +647 -1
- package/dist/src/mission-protocol/types.js +110 -0
- package/dist/src/mission-protocol/worker-status.js +2 -0
- package/dist/src/models/config-loader.js +76 -14
- package/dist/src/models/grok-build-models.js +93 -41
- package/dist/src/models/model-capabilities.v1.json +3183 -24
- package/dist/src/models/model-discovery.js +931 -67
- package/dist/src/models/provider-policy.js +719 -11
- package/dist/src/models/qualification-digest.d.mts +2 -0
- package/dist/src/models/qualification-digest.mjs +17 -0
- package/dist/src/models/resolver.js +261 -0
- package/dist/src/models/worker-direct-readiness.js +550 -0
- package/dist/src/models/worker-dispatch-offer.js +169 -0
- package/dist/src/models/worker-health-readiness.js +144 -0
- package/dist/src/models/worker-installation.d.mts +39 -0
- package/dist/src/models/worker-installation.mjs +986 -0
- package/dist/src/models/wrapper-route.js +18 -0
- package/dist/src/ops/registry.js +9 -14
- package/dist/src/plugins/standalone-packager.js +4 -3
- package/dist/src/process/bounded-child-process.d.mts +84 -0
- package/dist/src/process/bounded-child-process.mjs +430 -0
- package/dist/src/process/cli-command.d.mts +16 -0
- package/dist/src/process/cli-command.mjs +75 -0
- package/dist/src/process/signal-child.d.mts +6 -0
- package/dist/src/process/signal-child.mjs +7 -0
- package/dist/src/providers/capability-matrix.js +8 -0
- package/dist/src/providers/capability-matrix.yaml +270 -0
- package/dist/src/providers/deployed-skill-roots.js +20 -0
- package/dist/src/providers/grok-build-acp.js +3 -2
- package/dist/src/providers/grok-build-headless.js +53 -23
- package/dist/src/providers/grok-build-inspect.js +1 -0
- package/dist/src/providers/omp-agent.d.mts +8 -0
- package/dist/src/providers/omp-diagnostics.d.mts +1 -0
- package/dist/src/providers/omp-paths.d.mts +13 -0
- package/dist/src/providers/provider-definitions.js +9 -1
- package/dist/src/providers/provider-definitions.mjs +9 -2
- package/dist/src/providers/skill-ownership.d.mts +9 -0
- package/dist/src/providers/skill-ownership.mjs +88 -0
- package/dist/src/rules/activation.d.mts +21 -0
- package/dist/src/rules/activation.mjs +62 -0
- package/dist/src/rules/inline-budget.d.mts +26 -0
- package/dist/src/rules/inline-budget.mjs +66 -0
- package/dist/src/rules/inventory.js +129 -0
- package/dist/src/rules/pin-state.js +73 -0
- package/dist/src/rules/pins.d.mts +14 -0
- package/dist/src/rules/pins.mjs +112 -0
- package/dist/src/rules/rule-frontmatter.schema.json +197 -0
- package/dist/src/serve/executor-registry.js +16 -24
- package/dist/src/serve/fleet-mission-conductor.js +9 -0
- package/dist/src/serve/mission-conductor.js +47 -12
- package/dist/src/serve/shared-host-scheduler.js +2 -0
- package/dist/src/serve/worker-invocation.js +558 -0
- package/dist/src/serve/worker-stdin-frame.d.mts +10 -0
- package/dist/src/serve/worker-stdin-frame.mjs +107 -0
- package/dist/src/sessions/adapter-registry.js +49 -0
- package/dist/src/sessions/adapters/claude.js +39 -54
- package/dist/src/sessions/adapters/codex.js +82 -67
- package/dist/src/sessions/adapters/copilot.js +4 -4
- package/dist/src/sessions/adapters/cursor.js +40 -57
- package/dist/src/sessions/adapters/deepseek-harness.js +15 -12
- package/dist/src/sessions/adapters/factory.js +31 -27
- package/dist/src/sessions/adapters/generic.js +43 -9
- package/dist/src/sessions/adapters/grok-build.js +11 -11
- package/dist/src/sessions/adapters/grokbot-locator.js +111 -0
- package/dist/src/sessions/adapters/grokbot.js +434 -24
- package/dist/src/sessions/adapters/hermes.js +27 -29
- package/dist/src/sessions/adapters/muse-workspace-scan.js +128 -0
- package/dist/src/sessions/adapters/muse.js +200 -104
- package/dist/src/sessions/adapters/omp.js +28 -14
- package/dist/src/sessions/adapters/openclaw.js +89 -79
- package/dist/src/sessions/adapters/opencode.js +27 -24
- package/dist/src/sessions/adapters/openhuman.js +18 -60
- package/dist/src/sessions/adapters/pi.js +30 -14
- package/dist/src/sessions/adapters/warp.js +3 -3
- package/dist/src/sessions/adapters/windsurf.js +19 -48
- package/dist/src/sessions/batch-contracts.js +25 -5
- package/dist/src/sessions/batch-import.js +72 -51
- package/dist/src/sessions/candidates.js +47 -11
- package/dist/src/sessions/contracts.js +75 -2
- package/dist/src/sessions/coverage-preflight.js +134 -0
- package/dist/src/sessions/discovery.js +3 -0
- package/dist/src/sessions/export-plan.js +4 -3
- package/dist/src/sessions/grok-build-cli.js +67 -5
- package/dist/src/sessions/import-exclusions.js +72 -0
- package/dist/src/sessions/import-lease.js +34 -18
- package/dist/src/sessions/import-limits.js +37 -0
- package/dist/src/sessions/importer.js +84 -46
- package/dist/src/sessions/index.js +2 -0
- package/dist/src/sessions/lifecycle.js +45 -0
- package/dist/src/sessions/policy.js +133 -25
- package/dist/src/sessions/readers.js +106 -53
- package/dist/src/sessions/refresh.js +106 -0
- package/dist/src/sessions/repository.js +199 -63
- package/dist/src/sessions/workspace-discovery.js +315 -88
- package/dist/src/sessions/workspace-matching.js +107 -0
- package/dist/src/skills/adapters/clawhub.js +10 -8
- package/dist/src/skills/adapters/openclaw.js +10 -7
- package/dist/src/skills/importer.js +1 -0
- package/dist/src/smiths/context-pipeline/aiwg-md.js +11 -0
- package/dist/src/smiths/context-pipeline/claude-hook.js +3 -26
- package/dist/src/smiths/context-pipeline/finalization.js +6 -5
- package/dist/src/smiths/context-pipeline/generator.js +21 -4
- package/dist/src/smiths/context-pipeline/parallelism-section.js +195 -14
- package/dist/src/smiths/context-pipeline/workspace-context.js +116 -9
- package/dist/src/smiths/hook-bridge/codex-translator.js +6 -5
- package/dist/src/smiths/mcpsmith/example.js +1 -1
- package/dist/src/smiths/mcpsmith/generator.js +1 -1
- package/dist/src/smiths/toolsmith/runtime-discovery.d.mts +10 -0
- package/dist/src/smiths/toolsmith/runtime-discovery.mjs +85 -31
- package/dist/src/storage/backends/fs.js +18 -76
- package/dist/src/storage/backends/logseq.js +68 -7
- package/dist/src/storage/backends/obsidian.js +1 -0
- package/dist/src/storage/fortemi-qualification-receipt.js +2 -2
- package/dist/src/testing/generators/test-code-generator.js +57 -30
- package/dist/src/tracker/forge-http.js +2 -1
- package/dist/src/uhp/client.js +11 -1
- package/dist/src/uhp/mission.js +5 -0
- package/dist/src/update/checker.d.mts +2 -0
- package/dist/src/update/checker.mjs +5 -5
- package/dist/src/update/notifier.mjs +54 -2
- package/dist/src/update/service.d.mts +22 -0
- package/dist/src/utils/contained-filesystem.d.mts +37 -0
- package/dist/src/utils/contained-filesystem.mjs +683 -0
- package/dist/src/utils/temporary-directory.js +36 -0
- package/dist/src/writing/example-generator.js +1 -1
- package/dist/src/writing/fidelity.js +18 -1
- package/package.json +32 -2
- package/schemas/mission-v1.schema.json +2429 -0
- package/schemas/models/model-catalog.v1.schema.json +301 -0
- package/schemas/models/model-config-compatibility.v1.schema.json +281 -0
- package/schemas/models/model-policy.v1.schema.json +14 -0
- package/schemas/models/provider-model-capabilities.v1.schema.json +1072 -0
- package/tools/_resolve-impl.mjs +39 -2
- package/tools/agents/deploy-agents.mjs +64 -23
- package/tools/agents/providers/base.mjs +153 -166
- package/tools/agents/providers/claude.mjs +8 -24
- package/tools/agents/providers/codex.mjs +18 -11
- package/tools/agents/providers/cursor.mjs +19 -18
- package/tools/agents/providers/grok-build.mjs +3 -1
- package/tools/agents/providers/grokbot.mjs +11 -12
- package/tools/agents/providers/hermes.mjs +62 -49
- package/tools/agents/providers/omp.mjs +5 -2
- package/tools/agents/providers/openclaw-translator.mjs +19 -5
- package/tools/agents/providers/openclaw.mjs +9 -4
- package/tools/agents/providers/pi.mjs +5 -0
- package/tools/agents/providers/provider-prepare-channel.mjs +5 -0
- package/tools/agents/providers/provider-prepare-coordinator.mjs +247 -0
- package/tools/agents/providers/provider-prepare-worker.mjs +84 -0
- package/tools/agents/providers/rule-delivery.mjs +1270 -0
- package/tools/agents/providers/warp.mjs +20 -26
- package/tools/cli/decision-offload-report.mjs +40 -0
- package/tools/cli/workspace-status.mjs +862 -0
- package/tools/plugin/package-plugins.mjs +186 -8
- package/tools/plugin/plugin-links.mjs +114 -0
- package/tools/providers/antigravity-transport.mjs +3 -1
- package/tools/providers/deepseek-harness-transport.mjs +360 -0
- package/tools/providers/omp-transport.mjs +194 -0
- package/tools/ralph-external/lib/claude-adapter.mjs +389 -0
- package/tools/ralph-external/lib/codex-adapter.mjs +432 -0
- package/tools/ralph-external/lib/consecutive-failure-circuit-breaker.mjs +1748 -0
- package/tools/ralph-external/lib/deepseek-harness-adapter.mjs +397 -0
- package/tools/ralph-external/lib/factory-adapter.mjs +503 -0
- package/tools/ralph-external/lib/launcher-recovery-evidence.mjs +55 -0
- package/tools/ralph-external/lib/muse-adapter.mjs +364 -0
- package/tools/ralph-external/lib/omp-adapter.mjs +315 -0
- package/tools/ralph-external/lib/opencode-adapter.mjs +575 -0
- package/tools/ralph-external/lib/openhuman-adapter.mjs +75 -0
- package/tools/ralph-external/lib/pi-adapter.mjs +329 -0
- package/tools/ralph-external/lib/provider-adapter.mjs +748 -0
- package/tools/ralph-external/lib/recovery-probe.mjs +72 -0
- package/tools/ralph-external/lib/session-environment.mjs +28 -0
- package/tools/ralph-external/lib/systemd-client.mjs +49 -0
- package/tools/ralph-external/lib/worker-health.mjs +439 -0
- package/tools/ralph-external/lib/worker-isolation.mjs +717 -0
- package/tools/ralph-external/lib/worker-overflow.mjs +50 -0
- package/tools/ralph-external/process-monitor.mjs +1017 -0
- package/tools/ralph-external/session-launcher.mjs +5057 -0
- package/tools/scripts/resource-preflight.mjs +541 -0
- package/tools/skills/deploy-skills-codex.mjs +2 -1
- package/vscode-extension/schemas/aiwg.config.v1.json +2916 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { basename, extname } from 'node:path';
|
|
2
|
-
import { SessionContractError, } from '../contracts.js';
|
|
2
|
+
import { SessionContractError, schemaIssueDetail, } from '../contracts.js';
|
|
3
3
|
import { readBoundedText } from '../readers.js';
|
|
4
4
|
export const GROK_BUILD_ADAPTER_VERSION = '1.0.0';
|
|
5
5
|
export const GROK_BUILD_CLI_EXPORT_SCHEMA_VERSION = '1.0.0';
|
|
@@ -75,7 +75,7 @@ export class GrokBuildSessionAdapter {
|
|
|
75
75
|
}
|
|
76
76
|
const filename = basename(source.locator, extname(source.locator));
|
|
77
77
|
if (extname(source.locator).toLowerCase() !== '.md' || !UUID.test(filename)) {
|
|
78
|
-
throw new SessionContractError('MALFORMED_SOURCE', 'Grok Build export filename must be <session-id>.md so the documented CLI session ID is preserved.');
|
|
78
|
+
throw new SessionContractError('MALFORMED_SOURCE', 'Grok Build export filename must be <session-id>.md so the documented CLI session ID is preserved.', schemaIssueDetail('filename'));
|
|
79
79
|
}
|
|
80
80
|
const { value } = await readBoundedText({
|
|
81
81
|
selectedPath: source.locator,
|
|
@@ -93,7 +93,7 @@ export function validateGrokBuildMarkdown(value) {
|
|
|
93
93
|
parseTools(block.text, sequence);
|
|
94
94
|
}
|
|
95
95
|
if (blocks.length === 0 || !blocks.some((block) => block.heading === 'User')) {
|
|
96
|
-
throw new SessionContractError('MALFORMED_SOURCE', 'Unrecognized Grok Build CLI export; expected exact `## User`, `## Assistant`, or `## Tools` headings.');
|
|
96
|
+
throw new SessionContractError('MALFORMED_SOURCE', 'Unrecognized Grok Build CLI export; expected exact `## User`, `## Assistant`, or `## Tools` headings.', schemaIssueDetail('headings'));
|
|
97
97
|
}
|
|
98
98
|
return blocks;
|
|
99
99
|
}
|
|
@@ -105,7 +105,7 @@ function parseBlocks(value) {
|
|
|
105
105
|
return;
|
|
106
106
|
const text = current.lines.join('\n').trim();
|
|
107
107
|
if (!text && current.heading === 'Tools') {
|
|
108
|
-
throw new SessionContractError('SCHEMA_DRIFT', 'Grok Build tools block is empty');
|
|
108
|
+
throw new SessionContractError('SCHEMA_DRIFT', 'Grok Build tools block is empty', schemaIssueDetail('tools'));
|
|
109
109
|
}
|
|
110
110
|
if (text)
|
|
111
111
|
blocks.push({ heading: current.heading, text });
|
|
@@ -117,13 +117,13 @@ function parseBlocks(value) {
|
|
|
117
117
|
current = { heading: match[1], lines: [] };
|
|
118
118
|
}
|
|
119
119
|
else if (/^##\s+/.test(line)) {
|
|
120
|
-
throw new SessionContractError('SCHEMA_DRIFT', `unknown Grok Build CLI export heading: ${line}
|
|
120
|
+
throw new SessionContractError('SCHEMA_DRIFT', `unknown Grok Build CLI export heading: ${line}`, schemaIssueDetail('headings'));
|
|
121
121
|
}
|
|
122
122
|
else if (current) {
|
|
123
123
|
current.lines.push(line);
|
|
124
124
|
}
|
|
125
125
|
else if (line.trim()) {
|
|
126
|
-
throw new SessionContractError('SCHEMA_DRIFT', 'unexpected content before the first Grok Build CLI export heading');
|
|
126
|
+
throw new SessionContractError('SCHEMA_DRIFT', 'unexpected content before the first Grok Build CLI export heading', schemaIssueDetail('headings'));
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
flush();
|
|
@@ -132,17 +132,17 @@ function parseBlocks(value) {
|
|
|
132
132
|
function parseTools(text, blockSequence) {
|
|
133
133
|
const lines = text.split('\n').filter((line) => line.trim());
|
|
134
134
|
if (lines.length === 0 || lines.length > 1_000) {
|
|
135
|
-
throw new SessionContractError('SCHEMA_DRIFT', 'Grok Build tools block has no summaries or exceeds 1,000 summaries');
|
|
135
|
+
throw new SessionContractError('SCHEMA_DRIFT', 'Grok Build tools block has no summaries or exceeds 1,000 summaries', schemaIssueDetail('tools'));
|
|
136
136
|
}
|
|
137
137
|
return lines.map((line, index) => {
|
|
138
138
|
const match = /^- (.+)$/.exec(line);
|
|
139
139
|
if (!match) {
|
|
140
|
-
throw new SessionContractError('SCHEMA_DRIFT', `unrecognized Grok Build tool summary: ${line}
|
|
140
|
+
throw new SessionContractError('SCHEMA_DRIFT', `unrecognized Grok Build tool summary: ${line}`, schemaIssueDetail('tools'));
|
|
141
141
|
}
|
|
142
142
|
const summary = match[1];
|
|
143
143
|
const name = summary.split(/:| \(/, 1)[0]?.trim();
|
|
144
144
|
if (!name) {
|
|
145
|
-
throw new SessionContractError('SCHEMA_DRIFT', 'empty Grok Build tool summary');
|
|
145
|
+
throw new SessionContractError('SCHEMA_DRIFT', 'empty Grok Build tool summary', schemaIssueDetail('tools'));
|
|
146
146
|
}
|
|
147
147
|
return { sequence: blockSequence * 1_000 + index, name, text: summary };
|
|
148
148
|
});
|
|
@@ -176,11 +176,11 @@ function parseCursor(value) {
|
|
|
176
176
|
if (!value)
|
|
177
177
|
return 0;
|
|
178
178
|
if (!/^\d+$/.test(value)) {
|
|
179
|
-
throw new SessionContractError('SCHEMA_DRIFT', 'invalid Grok Build export cursor');
|
|
179
|
+
throw new SessionContractError('SCHEMA_DRIFT', 'invalid Grok Build export cursor', schemaIssueDetail('cursor'));
|
|
180
180
|
}
|
|
181
181
|
const cursor = Number(value);
|
|
182
182
|
if (!Number.isSafeInteger(cursor)) {
|
|
183
|
-
throw new SessionContractError('SCHEMA_DRIFT', 'invalid Grok Build export cursor');
|
|
183
|
+
throw new SessionContractError('SCHEMA_DRIFT', 'invalid Grok Build export cursor', schemaIssueDetail('cursor'));
|
|
184
184
|
}
|
|
185
185
|
return cursor;
|
|
186
186
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grok Bot desktop native-store locator primitives (#2970).
|
|
3
|
+
*
|
|
4
|
+
* The Grok Bot desktop app ("sand") persists one JSON document per logical
|
|
5
|
+
* key under `$XDG_CONFIG_HOME/Grok Bot/sand-client-persistence/` (default
|
|
6
|
+
* `~/.config/Grok Bot/...`, Linux only — macOS/Windows equivalents are
|
|
7
|
+
* unverified and must never be guessed). Each file is named `<key>.blob`,
|
|
8
|
+
* where `<key>` is the RFC 4648 section 6 base32 encoding of the key string,
|
|
9
|
+
* lowercase, unpadded.
|
|
10
|
+
*
|
|
11
|
+
* This module decodes filenames ONLY — it never opens file content. The
|
|
12
|
+
* adapter layer uses {@link classifyGrokbotBlobName} to build a strict
|
|
13
|
+
* allowlist: only filenames that decode to a transcript-replica or
|
|
14
|
+
* last-roster key are ever candidates for opening. Every other `.blob` file
|
|
15
|
+
* (composer drafts, send journal, experiments, UI layout, secrets, cookies,
|
|
16
|
+
* local/session storage, etc.) is left untouched.
|
|
17
|
+
*
|
|
18
|
+
* @see docs/providers/grokbot-sessions.md
|
|
19
|
+
* @issue #2970
|
|
20
|
+
*/
|
|
21
|
+
const BASE32_ALPHABET = 'abcdefghijklmnopqrstuvwxyz234567';
|
|
22
|
+
const BASE32_INDEX = new Map(BASE32_ALPHABET.split('').map((char, index) => [char, index]));
|
|
23
|
+
const BASE32_SHAPE = /^[a-z2-7]+$/;
|
|
24
|
+
const TRANSCRIPT_REPLICA_KEY_PATTERN = /^sand\.client\.slice\.account\.grok%7Cuser_[^.]+\.transcript\.replicas\.([0-9a-fA-F-]{36})$/;
|
|
25
|
+
const ROSTER_KEY_PATTERN = /^sand\.client\.slice\.account\.grok%7Cuser_[^.]+\.roster\.last-roster$/;
|
|
26
|
+
/** Unpadded lowercase RFC 4648 base32 encode, most significant bit first. */
|
|
27
|
+
export function encodeGrokbotKey(key) {
|
|
28
|
+
const bytes = Buffer.from(key, 'utf8');
|
|
29
|
+
let bits = 0;
|
|
30
|
+
let value = 0;
|
|
31
|
+
let out = '';
|
|
32
|
+
for (const byte of bytes) {
|
|
33
|
+
value = ((value << 8) | byte) & 0xffff;
|
|
34
|
+
bits += 8;
|
|
35
|
+
while (bits >= 5) {
|
|
36
|
+
out += BASE32_ALPHABET[(value >>> (bits - 5)) & 31];
|
|
37
|
+
bits -= 5;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (bits > 0)
|
|
41
|
+
out += BASE32_ALPHABET[(value << (5 - bits)) & 31];
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Decode an unpadded lowercase RFC 4648 base32 string back to its original
|
|
46
|
+
* UTF-8 key. Returns null for anything that is not canonical base32 (wrong
|
|
47
|
+
* alphabet, or non-zero padding bits) rather than guessing.
|
|
48
|
+
*/
|
|
49
|
+
export function decodeGrokbotKey(encoded) {
|
|
50
|
+
if (encoded.length === 0 || !BASE32_SHAPE.test(encoded))
|
|
51
|
+
return null;
|
|
52
|
+
const bytes = [];
|
|
53
|
+
let buffer = 0;
|
|
54
|
+
let bitsLeft = 0;
|
|
55
|
+
for (const char of encoded) {
|
|
56
|
+
const index = BASE32_INDEX.get(char);
|
|
57
|
+
if (index === undefined)
|
|
58
|
+
return null;
|
|
59
|
+
buffer = (buffer << 5) | index;
|
|
60
|
+
bitsLeft += 5;
|
|
61
|
+
if (bitsLeft >= 8) {
|
|
62
|
+
bitsLeft -= 8;
|
|
63
|
+
bytes.push((buffer >> bitsLeft) & 0xff);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (bitsLeft >= 5)
|
|
67
|
+
return null;
|
|
68
|
+
if (bitsLeft > 0 && (buffer & ((1 << bitsLeft) - 1)) !== 0)
|
|
69
|
+
return null;
|
|
70
|
+
try {
|
|
71
|
+
return Buffer.from(bytes).toString('utf8');
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Classify a `<base32>.blob` filename WITHOUT opening it. Returns null for
|
|
79
|
+
* anything that is not a `.blob` file, does not decode to canonical base32,
|
|
80
|
+
* or decodes to a key outside the allowlist (composer drafts, send journal,
|
|
81
|
+
* experiments, ui-layout, secrets, cookies, storage, etc.).
|
|
82
|
+
*/
|
|
83
|
+
export function classifyGrokbotBlobName(filename) {
|
|
84
|
+
if (!filename.endsWith('.blob'))
|
|
85
|
+
return null;
|
|
86
|
+
const encoded = filename.slice(0, -'.blob'.length);
|
|
87
|
+
const key = decodeGrokbotKey(encoded);
|
|
88
|
+
if (key === null)
|
|
89
|
+
return null;
|
|
90
|
+
const transcript = TRANSCRIPT_REPLICA_KEY_PATTERN.exec(key);
|
|
91
|
+
if (transcript)
|
|
92
|
+
return { kind: 'transcript-replica', conversationId: transcript[1] };
|
|
93
|
+
if (ROSTER_KEY_PATTERN.test(key))
|
|
94
|
+
return { kind: 'roster' };
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
/** Build the `<key>.blob` filename for a transcript replica (test fixtures only). */
|
|
98
|
+
export function grokbotTranscriptReplicaFilename(account, conversationId) {
|
|
99
|
+
return `${encodeGrokbotKey(`sand.client.slice.account.grok%7Cuser_${account}.transcript.replicas.${conversationId}`)}.blob`;
|
|
100
|
+
}
|
|
101
|
+
/** Build the `<key>.blob` filename for the account roster (test fixtures only). */
|
|
102
|
+
export function grokbotRosterFilename(account) {
|
|
103
|
+
return `${encodeGrokbotKey(`sand.client.slice.account.grok%7Cuser_${account}.roster.last-roster`)}.blob`;
|
|
104
|
+
}
|
|
105
|
+
/** Extract the conversation id from an authorized transcript-replica locator path, or null. */
|
|
106
|
+
export function grokbotConversationIdFromLocator(locator) {
|
|
107
|
+
const base = locator.replaceAll('\\', '/').split('/').pop() ?? '';
|
|
108
|
+
const classification = classifyGrokbotBlobName(base);
|
|
109
|
+
return classification?.kind === 'transcript-replica' ? classification.conversationId : null;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=grokbot-locator.js.map
|