openclaw/src/shared
Peter Steinberger 062f88e3e3
refactor: extract reusable AI runtime package (#99059)
* refactor: extract reusable AI runtime package

* refactor: complete AI provider relocation

* refactor: keep llm core internal

* refactor(ai): make @openclaw/ai self-contained with host policy ports

Move pure transport helpers (tool projections, strict-schema normalization,
prompt-cache boundary, stream guards, anthropic/openai compat, request
activity) from src into packages/ai; move utf16-slice into
normalization-core. Inject host policy (guarded fetch, redaction,
strict-tool defaults, diagnostics logging) through AiTransportHost with
inert library defaults installed by src/llm/stream.ts. Narrow the public
barrel to instance-scoped createApiRegistry/createLlmRuntime; the
process-default runtime moves behind internal/ and
registerBuiltInApiProviders takes an explicit registry. Delete the
src/llm/api-registry re-export facade.

* fix(ai): teach node, jiti, and vite resolvers the @openclaw/ai and utf16-slice subpaths

The workspace alias tables in root-alias.cjs, plugin-sdk-native-resolver,
sdk-alias, the shared vitest config, and the Control UI vite config only
knew @openclaw/llm-core; Node-side plugin loading resolved @openclaw/ai
through the pnpm symlink to the unbuilt dist (checks-node-compact CI
failures), and the Control UI build broke on the new
normalization-core/utf16-slice subpath.

* chore(ui): drop leftover service-worker debug logging

* build(release): ship @openclaw/ai with its own shrinkwrap and honest dependency set

packages/ai declares only its six real runtime deps (kysely, chalk, json5,
tslog, zod, fs-safe, and proxyline were never imported); orphaned root deps
removed. generate-npm-shrinkwrap now treats publishable packages/* like
publishable plugins so the AI tarball pins its transitive tree even though
workspace deps are omitted from the root shrinkwrap. knip learns the
package entry points; the tsdown dts neverBundle option moves to its
documented deps.dts home; the README documents the no-semver internal/*
contract and host ports.

* docs(ai): add minimal external-consumer example app

examples/ai-chat consumes only the public @openclaw/ai surface (built dist
via the workspace link): isolated runtime, built-in provider registration,
one streamed completion. Supports Anthropic/OpenAI via env keys and a
keyless local Ollama target; live-verified against Ollama.

* docs(ai): document the @openclaw/ai package and workspace shrinkwrap boundary

* chore(check): include examples/ in duplicate-scan targets

* fix: emit normalization package subpaths

* fix: complete AI package boundary artifacts

* fix: align AI package boundary contracts

* fix(ci): stabilize package release contracts

* test: align documentation contract checks

* test: keep cron docs guard aligned

* test: align restored docs contract guards

* test: follow upstream docs contracts

* docs: drop superseded talk wording
2026-07-05 01:56:40 -04:00
..
text refactor: extract reusable AI runtime package (#99059) 2026-07-05 01:56:40 -04:00
account-enabled.test.ts test(shared): add unit tests for account enabled guard (#98395) 2026-07-01 01:10:57 -07:00
account-enabled.ts refactor(channels): share account enabled predicate 2026-06-22 14:08:46 +08:00
agent-liveness.ts
agent-run-status.test.ts
agent-run-status.ts
assistant-error-format.ts refactor: extract reusable AI runtime package (#99059) 2026-07-05 01:56:40 -04:00
assistant-identity-values.test.ts
assistant-identity-values.ts
avatar-policy.test.ts
avatar-policy.ts refactor(shared): hide parser helper internals 2026-06-17 15:59:58 +08:00
balanced-json.ts refactor(shared): hide parser helper internals 2026-06-17 15:59:58 +08:00
chat-content.test.ts
chat-content.ts
chat-envelope.test.ts
chat-envelope.ts
chat-message-content.test.ts fix(ui): render persisted history text blocks (#93841) 2026-06-22 10:07:09 -07:00
chat-message-content.ts fix(ui): render persisted history text blocks (#93841) 2026-06-22 10:07:09 -07:00
config-eval.test.ts Add prototype pollution guard to resolveConfigPath (#59694) 2026-06-28 13:48:24 -07:00
config-eval.ts Add prototype pollution guard to resolveConfigPath (#59694) 2026-06-28 13:48:24 -07:00
config-ui-hints-types.ts
custom-command-config.ts
deferred.test.ts refactor: consolidate deferred promise construction (#99755) 2026-07-03 19:55:00 -07:00
deferred.ts refactor: consolidate deferred promise construction (#99755) 2026-07-03 19:55:00 -07:00
device-auth-store.test.ts
device-auth-store.ts
device-auth.test.ts
device-auth.ts
device-bootstrap-profile.test.ts Rework Android gateway onboarding setup (#98752) 2026-07-03 21:20:12 +10:00
device-bootstrap-profile.ts
device-pairing-access.test.ts fix(device-pairing): guard role normalization against non-string entries (#93504) 2026-06-22 18:56:01 +08:00
device-pairing-access.ts fix(device-pairing): guard role normalization against non-string entries (#93504) 2026-06-22 18:56:01 +08:00
entry-metadata.test.ts
entry-metadata.ts
entry-status.test.ts
entry-status.ts refactor(shared): hide helper option types 2026-06-17 16:03:38 +08:00
env-var-candidates.ts refactor(secrets): share env var candidate deduplication 2026-06-23 08:04:35 +08:00
fast-mode.ts feat: forward-port fast talks auto mode (#85104) 2026-06-22 09:37:09 +08:00
frontmatter.test.ts
frontmatter.ts
gateway-bind-url.test.ts
gateway-bind-url.ts
gateway-method-policy.ts
gateway-tailscale-auth-policy.ts
global-singleton.test.ts
global-singleton.ts
google-turn-ordering.ts
human-list.test.ts test(shared): add unit tests for human-readable list formatting 2026-07-01 06:42:54 -07:00
human-list.ts
ignore-rules.ts refactor(files): share nested ignore rule loading 2026-06-23 07:56:52 +08:00
import-specifier.ts
json-schema-defaults.test.ts
json-schema-defaults.ts refactor(shared): consolidate core record guards (#99359) 2026-07-02 22:13:17 -07:00
json-schema.types.ts
lazy-promise.test.ts refactor(shared): establish lazy runtime loader foundation (#99261) 2026-07-02 17:24:59 -07:00
lazy-promise.ts refactor(shared): establish lazy runtime loader foundation (#99261) 2026-07-02 17:24:59 -07:00
lazy-runtime.test.ts refactor(shared): establish lazy runtime loader foundation (#99261) 2026-07-02 17:24:59 -07:00
lazy-runtime.ts refactor(shared): establish lazy runtime loader foundation (#99261) 2026-07-02 17:24:59 -07:00
levenshtein-distance.ts chore(deadcode): share levenshtein distance helper 2026-06-21 14:23:43 +08:00
listeners.ts
markdown-code.test.ts refactor: consolidate markdown code fences, error coercion, and byte-identical helper pairs (#99932) 2026-07-04 08:40:41 -04:00
markdown-code.ts refactor: consolidate markdown code fences, error coercion, and byte-identical helper pairs (#99932) 2026-07-04 08:40:41 -04:00
message-content-blocks.ts
model-key.ts refactor(models): centralize model key normalization 2026-06-23 07:45:50 +08:00
model-param-b.test.ts fix(model-param-b): match both adjacent <num>b tokens sharing one delimiter (#96288) 2026-06-24 15:51:55 +08:00
model-param-b.ts fix(model-param-b): match both adjacent <num>b tokens sharing one delimiter (#96288) 2026-06-24 15:51:55 +08:00
node-list-parse.test.ts fix(nodes): guard node scalar fields against malformed entries 2026-06-29 10:36:29 -07:00
node-list-parse.ts fix(nodes): guard node scalar fields against malformed entries 2026-06-29 10:36:29 -07:00
node-list-types.ts fix(nodes): surface pending reapproval diagnostics (#92547) 2026-06-13 17:40:18 -07:00
node-match.test.ts refactor(config): drop dead baseline and node wrappers 2026-06-19 09:41:52 +08:00
node-match.ts refactor(config): drop dead baseline and node wrappers 2026-06-19 09:41:52 +08:00
node-presence.ts refactor(shared): hide helper option types 2026-06-17 16:03:38 +08:00
node-resolve.test.ts
node-resolve.ts
number-coercion.ts refactor(numbers): share non-negative finite guard 2026-06-23 03:46:22 +08:00
operator-scope-compat.test.ts
operator-scope-compat.ts
path-array-index.ts refactor(shared): trim helper constants 2026-06-17 16:06:41 +08:00
pid-alive.test.ts
pid-alive.ts
regexp.ts
requirements.test.ts
requirements.ts
runtime-import.test.ts refactor(shared): drop unused internal format/import aliases 2026-06-19 21:36:52 +08:00
runtime-import.ts refactor(shared): drop unused internal format/import aliases 2026-06-19 21:36:52 +08:00
safe-record.ts
scoped-expiring-id-cache.test.ts
scoped-expiring-id-cache.ts refactor: consolidate number coercion callers (#99671) 2026-07-03 16:24:43 -07:00
session-types.ts
session-usage-timeseries-types.ts
silent-reply-policy.test.ts
silent-reply-policy.ts
store-writer-queue.test.ts feat: add session thread management (#98510) 2026-07-04 14:30:47 -04:00
store-writer-queue.ts feat: add session thread management (#98510) 2026-07-04 14:30:47 -04:00
string-sample.test.ts
string-sample.ts
subagents-format.test.ts fix: keep subagent truncation within max length (#100013) 2026-07-04 18:48:23 -07:00
subagents-format.ts refactor: extract reusable AI runtime package (#99059) 2026-07-05 01:56:40 -04:00
tailscale-status.test.ts
tailscale-status.ts
text-chunking.test.ts
text-chunking.ts fix(telegram): guard UTF-16 surrogate pairs in outbound chunkers (#93938) 2026-06-17 18:56:25 +08:00
thread-binding-lifecycle.test.ts
thread-binding-lifecycle.ts
tilde-path.ts refactor: consolidate markdown code fences, error coercion, and byte-identical helper pairs (#99932) 2026-07-04 08:40:41 -04:00
transcript-only-openclaw-assistant.ts fix(transcripts): mark delivery mirrors as artifacts (#99855) 2026-07-04 04:02:55 -07:00
usage-aggregates.test.ts
usage-aggregates.ts
usage-types.ts