anymous 1.0.4 → 1.1.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/LICENSE +21 -0
- package/bin/anymous.cjs +45 -45
- package/package.json +1 -1
- package/{script/postinstall.mjs → postinstall.mjs} +5 -5
- package/src/account/account.ts +5 -5
- package/src/account/repo.ts +5 -5
- package/src/acp/agent.ts +2 -2
- package/src/acp/content.ts +1 -1
- package/src/acp/directory.ts +5 -5
- package/src/acp/event.ts +4 -4
- package/src/acp/permission.ts +2 -2
- package/src/acp/profile.ts +1 -1
- package/src/acp/service.ts +24 -24
- package/src/acp/session.ts +5 -5
- package/src/acp/usage.ts +11 -11
- package/src/agent/agent.ts +13 -13
- package/src/agent/prompt/debug-tools.txt +40 -40
- package/src/agent/prompt/exe-extractor.txt +39 -39
- package/src/agent/prompt/memory-dump.txt +37 -37
- package/src/agent/prompt/reverser-automator.txt +38 -38
- package/src/agent/prompt/reverser-binary.txt +39 -39
- package/src/agent/prompt/reverser-dynamic.txt +36 -36
- package/src/agent/prompt/reverser-source.txt +38 -38
- package/src/agent/prompt/reverser-static.txt +35 -35
- package/src/agent/subagent-permissions.ts +1 -1
- package/src/auth/index.ts +8 -8
- package/src/background/job.ts +3 -3
- package/src/cli/cmd/account.ts +1 -1
- package/src/cli/cmd/acp.ts +3 -3
- package/src/cli/cmd/agent.ts +2 -2
- package/src/cli/cmd/attach.ts +3 -3
- package/src/cli/cmd/db.ts +1 -1
- package/src/cli/cmd/debug/agent.handler.ts +2 -2
- package/src/cli/cmd/debug/file.ts +4 -4
- package/src/cli/cmd/debug/index.ts +5 -5
- package/src/cli/cmd/debug/ripgrep.ts +1 -1
- package/src/cli/cmd/debug/scrap.ts +2 -2
- package/src/cli/cmd/debug/v2.ts +4 -4
- package/src/cli/cmd/export.ts +1 -1
- package/src/cli/cmd/generate.ts +2 -2
- package/src/cli/cmd/github.handler.ts +27 -27
- package/src/cli/cmd/github.shared.ts +1 -1
- package/src/cli/cmd/import.ts +5 -5
- package/src/cli/cmd/mcp.ts +13 -13
- package/src/cli/cmd/models.ts +6 -6
- package/src/cli/cmd/plug.ts +2 -2
- package/src/cli/cmd/pr.ts +6 -6
- package/src/cli/cmd/prompt-display.ts +1 -1
- package/src/cli/cmd/providers.ts +12 -12
- package/src/cli/cmd/run/demo.ts +3 -3
- package/src/cli/cmd/run/footer.command.tsx +2 -2
- package/src/cli/cmd/run/footer.permission.tsx +3 -3
- package/src/cli/cmd/run/footer.prompt.tsx +9 -9
- package/src/cli/cmd/run/footer.question.tsx +1 -1
- package/src/cli/cmd/run/footer.subagent.tsx +3 -3
- package/src/cli/cmd/run/footer.ts +2 -2
- package/src/cli/cmd/run/footer.view.tsx +9 -9
- package/src/cli/cmd/run/permission.shared.ts +3 -3
- package/src/cli/cmd/run/question.shared.ts +1 -1
- package/src/cli/cmd/run/runtime.boot.ts +2 -2
- package/src/cli/cmd/run/runtime.lifecycle.ts +4 -4
- package/src/cli/cmd/run/runtime.ts +6 -6
- package/src/cli/cmd/run/session-data.ts +1 -1
- package/src/cli/cmd/run/session-replay.ts +1 -1
- package/src/cli/cmd/run/splash.ts +13 -5
- package/src/cli/cmd/run/stream.transport.ts +3 -3
- package/src/cli/cmd/run/subagent-data.ts +1 -1
- package/src/cli/cmd/run/theme.ts +2 -2
- package/src/cli/cmd/run/tool.ts +2 -2
- package/src/cli/cmd/run/trace.ts +4 -4
- package/src/cli/cmd/run/types.ts +13 -13
- package/src/cli/cmd/run/variant.shared.ts +5 -5
- package/src/cli/cmd/run.ts +22 -22
- package/src/cli/cmd/serve.ts +4 -4
- package/src/cli/cmd/session.ts +4 -4
- package/src/cli/cmd/stats.ts +2 -2
- package/src/cli/cmd/tui.ts +7 -7
- package/src/cli/cmd/uninstall.ts +21 -21
- package/src/cli/cmd/upgrade.ts +14 -14
- package/src/cli/cmd/web.ts +4 -4
- package/src/cli/error.ts +1 -1
- package/src/cli/heap.ts +3 -3
- package/src/cli/logo.ts +1 -1
- package/src/cli/network.ts +1 -1
- package/src/cli/tui/layer.ts +3 -3
- package/src/cli/tui/validate-session.ts +2 -2
- package/src/cli/ui.ts +12 -9
- package/src/cli/upgrade.ts +11 -11
- package/src/command/index.ts +3 -3
- package/src/command/template/initialize.txt +3 -3
- package/src/config/agent.ts +2 -2
- package/src/config/command.ts +3 -3
- package/src/config/config.ts +49 -49
- package/src/config/managed.ts +6 -6
- package/src/config/markdown.ts +2 -2
- package/src/config/parse.ts +2 -2
- package/src/config/paths.ts +7 -7
- package/src/config/plugin.ts +2 -2
- package/src/config/tui-host-attention.ts +2 -2
- package/src/config/tui-migrate.ts +12 -12
- package/src/config/tui.ts +23 -23
- package/src/config/variable.ts +1 -1
- package/src/control-plane/adapters/index.ts +1 -1
- package/src/control-plane/dev/README.md +5 -5
- package/src/control-plane/dev/debug-workspace-plugin.ts +2 -2
- package/src/control-plane/types.ts +3 -3
- package/src/control-plane/workspace-context.ts +1 -1
- package/src/control-plane/workspace.ts +17 -17
- package/src/effect/app-node-builder-v1.ts +2 -2
- package/src/effect/app-runtime.ts +9 -9
- package/src/effect/bootstrap-runtime.ts +4 -4
- package/src/effect/bridge.ts +1 -1
- package/src/effect/config-service.ts +3 -3
- package/src/effect/instance-ref.ts +3 -3
- package/src/effect/instance-state.ts +1 -1
- package/src/effect/run-service.ts +2 -2
- package/src/effect/runtime-flags.ts +34 -34
- package/src/env/index.ts +3 -3
- package/src/event-manifest.ts +1 -1
- package/src/event-v2-bridge.ts +7 -7
- package/src/format/formatter.ts +2 -2
- package/src/format/index.ts +4 -4
- package/src/git/index.ts +3 -3
- package/src/ide/index.ts +4 -4
- package/src/image/image.ts +4 -4
- package/src/index.ts +1 -1
- package/src/installation/index.ts +32 -32
- package/src/lsp/lsp.ts +5 -5
- package/src/lsp/server.ts +5 -5
- package/src/mcp/auth.ts +6 -6
- package/src/mcp/browser.ts +2 -2
- package/src/mcp/index.ts +17 -17
- package/src/mcp/oauth-callback.ts +1 -1
- package/src/mcp/oauth-provider.ts +2 -2
- package/src/node.ts +1 -1
- package/src/patch/index.ts +1 -1
- package/src/permission/index.ts +5 -5
- package/src/plugin/azure.ts +1 -1
- package/src/plugin/cloudflare.ts +1 -1
- package/src/plugin/digitalocean.ts +6 -6
- package/src/plugin/github-copilot/copilot.ts +7 -7
- package/src/plugin/github-copilot/models.ts +2 -2
- package/src/plugin/index.ts +7 -7
- package/src/plugin/install.ts +6 -6
- package/src/plugin/loader.ts +3 -3
- package/src/plugin/meta.ts +4 -4
- package/src/plugin/openai/README.md +1 -1
- package/src/plugin/openai/codex.ts +8 -8
- package/src/plugin/openai/ws-pool.ts +1 -1
- package/src/plugin/pty-environment.ts +1 -1
- package/src/plugin/shared.ts +7 -7
- package/src/plugin/snowflake-cortex.ts +6 -6
- package/src/plugin/tui/internal.ts +1 -1
- package/src/plugin/tui/runtime.ts +17 -17
- package/src/plugin/xai.ts +8 -8
- package/src/project/bootstrap-service.ts +1 -1
- package/src/project/bootstrap.ts +1 -1
- package/src/project/instance-context.ts +1 -1
- package/src/project/instance-store.ts +5 -5
- package/src/project/project.ts +18 -18
- package/src/project/vcs.ts +5 -5
- package/src/provider/auth.ts +6 -6
- package/src/provider/error.ts +3 -3
- package/src/provider/model-status.ts +1 -1
- package/src/provider/provider.ts +38 -38
- package/src/provider/transform.ts +4 -4
- package/src/question/index.ts +3 -3
- package/src/question/schema.ts +1 -1
- package/src/server/auth.ts +6 -6
- package/src/server/event.ts +1 -1
- package/src/server/mdns.ts +2 -2
- package/src/server/proxy-util.ts +2 -2
- package/src/server/routes/instance/httpapi/api.ts +10 -10
- package/src/server/routes/instance/httpapi/groups/config.ts +4 -4
- package/src/server/routes/instance/httpapi/groups/control-plane.ts +1 -1
- package/src/server/routes/instance/httpapi/groups/control.ts +1 -1
- package/src/server/routes/instance/httpapi/groups/experimental.ts +7 -7
- package/src/server/routes/instance/httpapi/groups/file.ts +3 -3
- package/src/server/routes/instance/httpapi/groups/global.ts +10 -10
- package/src/server/routes/instance/httpapi/groups/instance.ts +6 -6
- package/src/server/routes/instance/httpapi/groups/mcp.ts +2 -2
- package/src/server/routes/instance/httpapi/groups/permission.ts +2 -2
- package/src/server/routes/instance/httpapi/groups/project-copy.ts +1 -1
- package/src/server/routes/instance/httpapi/groups/project.ts +4 -4
- package/src/server/routes/instance/httpapi/groups/provider.ts +2 -2
- package/src/server/routes/instance/httpapi/groups/pty.ts +5 -5
- package/src/server/routes/instance/httpapi/groups/question.ts +1 -1
- package/src/server/routes/instance/httpapi/groups/session.ts +8 -8
- package/src/server/routes/instance/httpapi/groups/sync.ts +3 -3
- package/src/server/routes/instance/httpapi/groups/tui.ts +1 -1
- package/src/server/routes/instance/httpapi/groups/workspace.ts +1 -1
- package/src/server/routes/instance/httpapi/handlers/control-plane.ts +2 -2
- package/src/server/routes/instance/httpapi/handlers/control.ts +1 -1
- package/src/server/routes/instance/httpapi/handlers/event.ts +1 -1
- package/src/server/routes/instance/httpapi/handlers/file.ts +6 -6
- package/src/server/routes/instance/httpapi/handlers/global.ts +2 -2
- package/src/server/routes/instance/httpapi/handlers/instance.ts +1 -1
- package/src/server/routes/instance/httpapi/handlers/permission.ts +1 -1
- package/src/server/routes/instance/httpapi/handlers/project-copy.ts +2 -2
- package/src/server/routes/instance/httpapi/handlers/project.ts +1 -1
- package/src/server/routes/instance/httpapi/handlers/provider.ts +2 -2
- package/src/server/routes/instance/httpapi/handlers/pty.ts +9 -9
- package/src/server/routes/instance/httpapi/handlers/session.ts +3 -3
- package/src/server/routes/instance/httpapi/handlers/sync.ts +3 -3
- package/src/server/routes/instance/httpapi/middleware/authorization.ts +3 -3
- package/src/server/routes/instance/httpapi/middleware/error.ts +2 -2
- package/src/server/routes/instance/httpapi/middleware/fence.ts +3 -3
- package/src/server/routes/instance/httpapi/middleware/instance-context.ts +1 -1
- package/src/server/routes/instance/httpapi/middleware/schema-error.ts +1 -1
- package/src/server/routes/instance/httpapi/middleware/workspace-routing.ts +6 -6
- package/src/server/routes/instance/httpapi/public.ts +6 -6
- package/src/server/routes/instance/httpapi/server.ts +27 -27
- package/src/server/routes/instance/httpapi/websocket-tracker.ts +2 -2
- package/src/server/server.ts +3 -3
- package/src/server/shared/fence.ts +4 -4
- package/src/server/shared/pty-ticket.ts +1 -1
- package/src/server/shared/ui.ts +3 -3
- package/src/server/tui-event.ts +1 -1
- package/src/session/compaction.ts +9 -9
- package/src/session/instruction.ts +9 -9
- package/src/session/llm/AGENTS.md +12 -12
- package/src/session/llm/ai-sdk.ts +2 -2
- package/src/session/llm/native-request.ts +4 -4
- package/src/session/llm/native-runtime.ts +7 -7
- package/src/session/llm/request.ts +10 -10
- package/src/session/llm.ts +12 -12
- package/src/session/message-error.ts +1 -1
- package/src/session/message-v2.ts +7 -7
- package/src/session/message.ts +3 -3
- package/src/session/overflow.ts +2 -2
- package/src/session/processor.ts +6 -6
- package/src/session/prompt/anthropic.txt +2 -11
- package/src/session/prompt/beast.txt +147 -147
- package/src/session/prompt/codex.txt +1 -1
- package/src/session/prompt/copilot-gpt-5.txt +1 -1
- package/src/session/prompt/default.txt +1 -7
- package/src/session/prompt/gemini.txt +1 -1
- package/src/session/prompt/gpt.txt +1 -1
- package/src/session/prompt/kimi.txt +1 -1
- package/src/session/prompt/meta.txt +3 -4
- package/src/session/prompt/trinity.txt +1 -1
- package/src/session/prompt.ts +14 -14
- package/src/session/reminders.ts +2 -2
- package/src/session/retry.ts +5 -5
- package/src/session/revert.ts +3 -3
- package/src/session/run-state.ts +3 -3
- package/src/session/schema.ts +2 -2
- package/src/session/session.ts +22 -22
- package/src/session/status.ts +3 -3
- package/src/session/summary.ts +3 -3
- package/src/session/system.ts +7 -7
- package/src/session/todo.ts +5 -5
- package/src/session/tools.ts +3 -3
- package/src/share/session.ts +2 -2
- package/src/share/share-next.ts +11 -11
- package/src/skill/discovery.ts +7 -7
- package/src/skill/index.ts +21 -21
- package/src/snapshot/index.ts +7 -7
- package/src/storage/schema.ts +5 -5
- package/src/storage/storage.ts +5 -5
- package/src/sync/schema.ts +1 -1
- package/src/temporary.ts +4 -4
- package/src/tool/apply_patch.ts +3 -3
- package/src/tool/code-mode.ts +1 -1
- package/src/tool/edit.ts +3 -3
- package/src/tool/external-directory.ts +1 -1
- package/src/tool/glob.ts +2 -2
- package/src/tool/grep.ts +2 -2
- package/src/tool/lsp.ts +1 -1
- package/src/tool/lsp.txt +1 -1
- package/src/tool/plan.ts +1 -1
- package/src/tool/read.ts +2 -2
- package/src/tool/registry.ts +13 -13
- package/src/tool/schema.ts +1 -1
- package/src/tool/shell/id.ts +1 -1
- package/src/tool/shell/prompt.ts +2 -2
- package/src/tool/shell.ts +2 -2
- package/src/tool/skill.ts +1 -1
- package/src/tool/task.ts +3 -3
- package/src/tool/tool.ts +2 -2
- package/src/tool/truncate.ts +4 -4
- package/src/tool/truncation-dir.ts +1 -1
- package/src/tool/webfetch.ts +1 -1
- package/src/tool/websearch.ts +4 -4
- package/src/tool/write.ts +3 -3
- package/src/util/bom.ts +1 -1
- package/src/util/error.ts +1 -1
- package/src/util/filesystem.ts +2 -2
- package/src/util/locale.ts +2 -2
- package/src/util/process.ts +1 -1
- package/src/util/record.ts +1 -1
- package/src/util/repository.ts +2 -2
- package/src/util/token.ts +1 -1
- package/src/worktree/index.ts +12 -12
|
@@ -2,8 +2,8 @@ import { Config as EffectConfig, Context, Effect, Layer } from "effect"
|
|
|
2
2
|
import { HttpApiBuilder, OpenApi } from "effect/unstable/httpapi"
|
|
3
3
|
import { HttpClient, HttpMiddleware, HttpRouter, HttpServer, HttpServerResponse } from "effect/unstable/http"
|
|
4
4
|
import * as Socket from "effect/unstable/socket/Socket"
|
|
5
|
-
import { FSUtil } from "@
|
|
6
|
-
import * as Observability from "@
|
|
5
|
+
import { FSUtil } from "@anymous-ai/core/fs-util"
|
|
6
|
+
import * as Observability from "@anymous-ai/core/observability"
|
|
7
7
|
import { Account } from "@/account/account"
|
|
8
8
|
import { Agent } from "@/agent/agent"
|
|
9
9
|
import { Auth } from "@/auth"
|
|
@@ -49,29 +49,29 @@ import { ToolRegistry } from "@/tool/registry"
|
|
|
49
49
|
import { Truncate } from "@/tool/truncate"
|
|
50
50
|
import { Worktree } from "@/worktree"
|
|
51
51
|
import { RuntimeFlags } from "@/effect/runtime-flags"
|
|
52
|
-
import { MoveSession } from "@
|
|
53
|
-
import { Database } from "@
|
|
52
|
+
import { MoveSession } from "@anymous-ai/core/control-plane/move-session"
|
|
53
|
+
import { Database } from "@anymous-ai/core/database/database"
|
|
54
54
|
import { AppNodeBuilderV1 } from "@/effect/app-node-builder-v1"
|
|
55
|
-
import { LayerNode } from "@
|
|
56
|
-
import { httpClient } from "@
|
|
57
|
-
import { EventV2 } from "@
|
|
58
|
-
import { ModelsDev } from "@
|
|
59
|
-
import { Npm } from "@
|
|
60
|
-
import { PermissionSaved } from "@
|
|
61
|
-
import { ProjectV2 } from "@
|
|
62
|
-
import { ProjectCopy } from "@
|
|
63
|
-
import { PtyTicket } from "@
|
|
64
|
-
import { Ripgrep } from "@
|
|
65
|
-
import { SessionProjector } from "@
|
|
66
|
-
import { SessionV2 } from "@
|
|
67
|
-
import { SessionExecution } from "@
|
|
68
|
-
import * as SessionExecutionLocal from "@
|
|
55
|
+
import { LayerNode } from "@anymous-ai/core/effect/layer-node"
|
|
56
|
+
import { httpClient } from "@anymous-ai/core/effect/app-node-platform"
|
|
57
|
+
import { EventV2 } from "@anymous-ai/core/event"
|
|
58
|
+
import { ModelsDev } from "@anymous-ai/core/models-dev"
|
|
59
|
+
import { Npm } from "@anymous-ai/core/npm"
|
|
60
|
+
import { PermissionSaved } from "@anymous-ai/core/permission/saved"
|
|
61
|
+
import { ProjectV2 } from "@anymous-ai/core/project"
|
|
62
|
+
import { ProjectCopy } from "@anymous-ai/core/project/copy"
|
|
63
|
+
import { PtyTicket } from "@anymous-ai/core/pty/ticket"
|
|
64
|
+
import { Ripgrep } from "@anymous-ai/core/ripgrep"
|
|
65
|
+
import { SessionProjector } from "@anymous-ai/core/session/projector"
|
|
66
|
+
import { SessionV2 } from "@anymous-ai/core/session"
|
|
67
|
+
import { SessionExecution } from "@anymous-ai/core/session/execution"
|
|
68
|
+
import * as SessionExecutionLocal from "@anymous-ai/core/session/execution/local"
|
|
69
69
|
import { lazy } from "@/util/lazy"
|
|
70
|
-
import { CorsConfig, isAllowedCorsOrigin, type CorsOptions } from "@
|
|
70
|
+
import { CorsConfig, isAllowedCorsOrigin, type CorsOptions } from "@anymous-ai/server/cors"
|
|
71
71
|
import { serveUIEffect } from "@/server/shared/ui"
|
|
72
72
|
import { ServerAuth } from "@/server/auth"
|
|
73
73
|
import { InstanceHttpApi, RootHttpApi } from "./api"
|
|
74
|
-
import { Api } from "@
|
|
74
|
+
import { Api } from "@anymous-ai/server/api"
|
|
75
75
|
import { PublicApi } from "./public"
|
|
76
76
|
import {
|
|
77
77
|
authorizationLayer,
|
|
@@ -99,17 +99,17 @@ import { questionHandlers } from "./handlers/question"
|
|
|
99
99
|
import { sessionHandlers } from "./handlers/session"
|
|
100
100
|
import { syncHandlers } from "./handlers/sync"
|
|
101
101
|
import { tuiHandlers } from "./handlers/tui"
|
|
102
|
-
import { handlers } from "@
|
|
103
|
-
import { buildLocationServiceMap, LocationServiceMap } from "@
|
|
104
|
-
import { layer as locationLayer } from "@
|
|
105
|
-
import { sessionLocationLayer } from "@
|
|
106
|
-
import { PtyEnvironment } from "@
|
|
107
|
-
import { schemaErrorLayer as v2SchemaErrorLayer } from "@
|
|
102
|
+
import { handlers } from "@anymous-ai/server/handlers"
|
|
103
|
+
import { buildLocationServiceMap, LocationServiceMap } from "@anymous-ai/core/location-services"
|
|
104
|
+
import { layer as locationLayer } from "@anymous-ai/server/location"
|
|
105
|
+
import { sessionLocationLayer } from "@anymous-ai/server/middleware/session-location"
|
|
106
|
+
import { PtyEnvironment } from "@anymous-ai/server/pty-environment"
|
|
107
|
+
import { schemaErrorLayer as v2SchemaErrorLayer } from "@anymous-ai/server/middleware/schema-error"
|
|
108
108
|
import { workspaceHandlers } from "./handlers/workspace"
|
|
109
109
|
import { instanceContextLayer } from "./middleware/instance-context"
|
|
110
110
|
import { workspaceRoutingLayer } from "./middleware/workspace-routing"
|
|
111
111
|
import { disposeMiddleware } from "./lifecycle"
|
|
112
|
-
import { memoMap } from "@
|
|
112
|
+
import { memoMap } from "@anymous-ai/core/effect/memo-map"
|
|
113
113
|
import { compressionLayer } from "./middleware/compression"
|
|
114
114
|
import { corsVaryFix } from "./middleware/cors-vary"
|
|
115
115
|
import { errorLayer } from "./middleware/error"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Context, Effect, Layer, Option } from "effect"
|
|
2
|
-
import { LayerNode } from "@
|
|
2
|
+
import { LayerNode } from "@anymous-ai/core/effect/layer-node"
|
|
3
3
|
import * as Socket from "effect/unstable/socket/Socket"
|
|
4
4
|
|
|
5
5
|
export const SERVER_CLOSING_EVENT = () => new Socket.CloseEvent(1001, "server closing")
|
|
@@ -12,7 +12,7 @@ export interface Interface {
|
|
|
12
12
|
readonly closeAll: Effect.Effect<void>
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export class Service extends Context.Service<Service, Interface>()("@
|
|
15
|
+
export class Service extends Context.Service<Service, Interface>()("@anymous/HttpApiWebSocketTracker") {}
|
|
16
16
|
|
|
17
17
|
const layer = Layer.sync(Service)(() => {
|
|
18
18
|
const sockets = new Set<Close>()
|
package/src/server/server.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "./init-projectors"
|
|
2
2
|
|
|
3
3
|
import { NodeHttpServer } from "@effect/platform-node"
|
|
4
|
-
import { AppNodeBuilder } from "@
|
|
4
|
+
import { AppNodeBuilder } from "@anymous-ai/core/effect/app-node-builder"
|
|
5
5
|
import { ConfigProvider, Context, Effect, Exit, Layer, Scope } from "effect"
|
|
6
6
|
import { HttpRouter, HttpServer } from "effect/unstable/http"
|
|
7
7
|
import { OpenApi } from "effect/unstable/httpapi"
|
|
@@ -11,7 +11,7 @@ import { HttpApiApp } from "./routes/instance/httpapi/server"
|
|
|
11
11
|
import { disposeMiddleware } from "./routes/instance/httpapi/lifecycle"
|
|
12
12
|
import { WebSocketTracker } from "./routes/instance/httpapi/websocket-tracker"
|
|
13
13
|
import { PublicApi } from "./routes/instance/httpapi/public"
|
|
14
|
-
import type { CorsOptions } from "@
|
|
14
|
+
import type { CorsOptions } from "@anymous-ai/server/cors"
|
|
15
15
|
import { lazy } from "@/util/lazy"
|
|
16
16
|
|
|
17
17
|
// @ts-ignore This global is needed to prevent ai-sdk from logging warnings to stdout https://github.com/vercel/ai/blob/2dc67e0ef538307f21368db32d5a12345d98831b/packages/ai/src/logger/log-warnings.ts#L85
|
|
@@ -50,7 +50,7 @@ interface ListenerServer {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
class ListenerServerService extends Context.Service<ListenerServerService, ListenerServer>()(
|
|
53
|
-
"@
|
|
53
|
+
"@anymous/ListenerServer",
|
|
54
54
|
) {}
|
|
55
55
|
|
|
56
56
|
export const Default = lazy(() => {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Database } from "@
|
|
1
|
+
import { Database } from "@anymous-ai/core/database/database"
|
|
2
2
|
import { inArray } from "drizzle-orm"
|
|
3
|
-
import { EventSequenceTable } from "@
|
|
3
|
+
import { EventSequenceTable } from "@anymous-ai/core/event/sql"
|
|
4
4
|
import { Workspace } from "@/control-plane/workspace"
|
|
5
|
-
import type { WorkspaceV2 } from "@
|
|
5
|
+
import type { WorkspaceV2 } from "@anymous-ai/core/workspace"
|
|
6
6
|
import { Effect } from "effect"
|
|
7
7
|
|
|
8
|
-
export const HEADER = "x-
|
|
8
|
+
export const HEADER = "x-anymous-sync"
|
|
9
9
|
export type State = Record<string, number>
|
|
10
10
|
|
|
11
11
|
export function load(db: Database.Interface["db"], ids?: string[]) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export const PTY_CONNECT_TICKET_QUERY = "ticket"
|
|
2
|
-
export const PTY_CONNECT_TOKEN_HEADER = "x-
|
|
2
|
+
export const PTY_CONNECT_TOKEN_HEADER = "x-anymous-ticket"
|
|
3
3
|
export const PTY_CONNECT_TOKEN_HEADER_VALUE = "1"
|
|
4
4
|
|
|
5
5
|
const PTY_CONNECT_PATH = /^\/pty\/[^/]+\/connect$/
|
package/src/server/shared/ui.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FSUtil } from "@
|
|
1
|
+
import { FSUtil } from "@anymous-ai/core/fs-util"
|
|
2
2
|
import { Effect, Stream } from "effect"
|
|
3
3
|
import { HttpBody, HttpClient, HttpClientRequest, HttpServerRequest, HttpServerResponse } from "effect/unstable/http"
|
|
4
4
|
import { createHash } from "node:crypto"
|
|
@@ -6,7 +6,7 @@ import { ProxyUtil } from "../proxy-util"
|
|
|
6
6
|
|
|
7
7
|
let embeddedUIPromise: Promise<Record<string, string> | null> | undefined
|
|
8
8
|
|
|
9
|
-
export const UI_UPSTREAM = new URL("https://app.
|
|
9
|
+
export const UI_UPSTREAM = new URL("https://app.anymous-cli.vercel.app")
|
|
10
10
|
|
|
11
11
|
export const csp = (hash = "") =>
|
|
12
12
|
`default-src 'self'; script-src 'self' 'wasm-unsafe-eval'${hash ? ` 'sha256-${hash}'` : ""}; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; font-src 'self' data:; media-src 'self' data:; connect-src * data:`
|
|
@@ -45,7 +45,7 @@ export function embeddedUI(disableEmbeddedWebUi: boolean) {
|
|
|
45
45
|
if (disableEmbeddedWebUi) return Promise.resolve(null)
|
|
46
46
|
return (embeddedUIPromise ??=
|
|
47
47
|
// @ts-expect-error - generated file at build time
|
|
48
|
-
import("
|
|
48
|
+
import("anymous-web-ui.gen.ts").then((module) => module.default as Record<string, string>).catch(() => null))
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
function notFound() {
|
package/src/server/tui-event.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { TuiEvent } from "@
|
|
1
|
+
export { TuiEvent } from "@anymous-ai/schema/tui-event"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { LayerNode } from "@
|
|
2
|
-
import { SessionV1 } from "@
|
|
3
|
-
import { ConfigV1 } from "@
|
|
1
|
+
import { LayerNode } from "@anymous-ai/core/effect/layer-node"
|
|
2
|
+
import { SessionV1 } from "@anymous-ai/core/v1/session"
|
|
3
|
+
import { ConfigV1 } from "@anymous-ai/core/v1/config/config"
|
|
4
4
|
import { Session } from "./session"
|
|
5
5
|
import { SessionID, MessageID, PartID } from "./schema"
|
|
6
6
|
import { Provider } from "@/provider/provider"
|
|
@@ -15,13 +15,13 @@ import { NotFoundError } from "@/storage/storage"
|
|
|
15
15
|
import { Effect, Layer, Context } from "effect"
|
|
16
16
|
import { InstanceState } from "@/effect/instance-state"
|
|
17
17
|
import { isOverflow as overflow, usable } from "./overflow"
|
|
18
|
-
import { serviceUse } from "@
|
|
18
|
+
import { serviceUse } from "@anymous-ai/core/effect/service-use"
|
|
19
19
|
import { RuntimeFlags } from "@/effect/runtime-flags"
|
|
20
20
|
import { EventV2Bridge } from "@/event-v2-bridge"
|
|
21
|
-
import { ProviderV2 } from "@
|
|
22
|
-
import { ModelV2 } from "@
|
|
23
|
-
import { buildPrompt } from "@
|
|
24
|
-
import { SessionCompactionEvent } from "@
|
|
21
|
+
import { ProviderV2 } from "@anymous-ai/core/provider"
|
|
22
|
+
import { ModelV2 } from "@anymous-ai/core/model"
|
|
23
|
+
import { buildPrompt } from "@anymous-ai/core/session/compaction"
|
|
24
|
+
import { SessionCompactionEvent } from "@anymous-ai/schema/session-compaction-event"
|
|
25
25
|
|
|
26
26
|
export const Event = SessionCompactionEvent
|
|
27
27
|
|
|
@@ -149,7 +149,7 @@ export interface Interface {
|
|
|
149
149
|
}) => Effect.Effect<void>
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
export class Service extends Context.Service<Service, Interface>()("@
|
|
152
|
+
export class Service extends Context.Service<Service, Interface>()("@anymous/SessionCompaction") {}
|
|
153
153
|
|
|
154
154
|
export const use = serviceUse(Service)
|
|
155
155
|
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { LayerNode } from "@
|
|
2
|
-
import { httpClient } from "@
|
|
1
|
+
import { LayerNode } from "@anymous-ai/core/effect/layer-node"
|
|
2
|
+
import { httpClient } from "@anymous-ai/core/effect/app-node-platform"
|
|
3
3
|
import path from "path"
|
|
4
|
-
import { SessionV1 } from "@
|
|
4
|
+
import { SessionV1 } from "@anymous-ai/core/v1/session"
|
|
5
5
|
import { Effect, Layer, Context } from "effect"
|
|
6
6
|
import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/unstable/http"
|
|
7
7
|
import { Config } from "@/config/config"
|
|
8
8
|
import { InstanceState } from "@/effect/instance-state"
|
|
9
9
|
import { RuntimeFlags } from "@/effect/runtime-flags"
|
|
10
|
-
import { Flag } from "@
|
|
11
|
-
import { FSUtil } from "@
|
|
10
|
+
import { Flag } from "@anymous-ai/core/flag/flag"
|
|
11
|
+
import { FSUtil } from "@anymous-ai/core/fs-util"
|
|
12
12
|
import { withTransientReadRetry } from "@/util/effect-http-client"
|
|
13
|
-
import { Global } from "@
|
|
13
|
+
import { Global } from "@anymous-ai/core/global"
|
|
14
14
|
import type { MessageV2 } from "./message-v2"
|
|
15
15
|
import type { MessageID } from "./schema"
|
|
16
16
|
|
|
@@ -43,7 +43,7 @@ export interface Interface {
|
|
|
43
43
|
) => Effect.Effect<{ filepath: string; content: string }[], FSUtil.Error>
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
export class Service extends Context.Service<Service, Interface>()("@
|
|
46
|
+
export class Service extends Context.Service<Service, Interface>()("@anymous/Instruction") {}
|
|
47
47
|
|
|
48
48
|
const layer: Layer.Layer<
|
|
49
49
|
Service,
|
|
@@ -78,7 +78,7 @@ const layer: Layer.Layer<
|
|
|
78
78
|
|
|
79
79
|
const relative = Effect.fnUntraced(function* (instruction: string) {
|
|
80
80
|
const ctx = yield* InstanceState.context
|
|
81
|
-
if (!Flag.
|
|
81
|
+
if (!Flag.ANYMOUS_DISABLE_PROJECT_CONFIG) {
|
|
82
82
|
return yield* fs
|
|
83
83
|
.globUp(instruction, ctx.directory, ctx.worktree)
|
|
84
84
|
.pipe(Effect.catch(() => Effect.succeed([] as string[])))
|
|
@@ -120,7 +120,7 @@ const layer: Layer.Layer<
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
// The first project-level match wins so we don't stack AGENTS.md/CLAUDE.md from every ancestor.
|
|
123
|
-
if (!Flag.
|
|
123
|
+
if (!Flag.ANYMOUS_DISABLE_PROJECT_CONFIG) {
|
|
124
124
|
for (const file of instructionFiles) {
|
|
125
125
|
const matches = yield* fs
|
|
126
126
|
.findUp(file, ctx.directory, ctx.worktree)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Session LLM Runtime Boundaries
|
|
2
2
|
|
|
3
|
-
`../llm.ts` is the
|
|
3
|
+
`../llm.ts` is the anymous session LLM service. It owns anymous concerns: auth, config, model/provider resolution, plugins, permissions, telemetry headers, and runtime selection. It is the only file in this area that should know about the full session request shape.
|
|
4
4
|
|
|
5
5
|
This folder contains adapters behind that service boundary:
|
|
6
6
|
|
|
7
|
-
- `ai-sdk.ts` converts AI SDK `fullStream` parts into `@
|
|
8
|
-
- `native-request.ts` converts
|
|
9
|
-
- `native-runtime.ts` is the opt-in native runtime adapter. It decides whether a selected model is supported, builds the native request, bridges
|
|
7
|
+
- `ai-sdk.ts` converts AI SDK `fullStream` parts into `@anymous-ai/llm` `LLMEvent`s. This is the default runtime path.
|
|
8
|
+
- `native-request.ts` converts anymous's normalized session input into a native `@anymous-ai/llm` `LLMRequest`. It does not execute requests.
|
|
9
|
+
- `native-runtime.ts` is the opt-in native runtime adapter. It decides whether a selected model is supported, builds the native request, bridges anymous tools into native executable tools, and delegates transport to `LLMClient` / `RequestExecutor`.
|
|
10
10
|
|
|
11
11
|
## File Structure
|
|
12
12
|
|
|
@@ -15,19 +15,19 @@ src/session/
|
|
|
15
15
|
llm.ts session-owned orchestration and runtime selection
|
|
16
16
|
llm/
|
|
17
17
|
AGENTS.md boundary notes for the adapter layer
|
|
18
|
-
ai-sdk.ts AI SDK fullStream -> @
|
|
19
|
-
native-request.ts
|
|
18
|
+
ai-sdk.ts AI SDK fullStream -> @anymous-ai/llm LLMEvent adapter
|
|
19
|
+
native-request.ts anymous/AI SDK-shaped input -> @anymous-ai/llm LLMRequest
|
|
20
20
|
native-runtime.ts native runtime gate, tool bridge, and LLMClient handoff
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
Integration points:
|
|
24
24
|
|
|
25
|
-
- `../llm.ts` imports `LLMClient` from `@
|
|
25
|
+
- `../llm.ts` imports `LLMClient` from `@anymous-ai/llm/route`; native execution is the only path that calls it directly.
|
|
26
26
|
- `../llm.ts` imports `LLMAISDK` from `./llm/ai-sdk`; the AI SDK path still calls `streamText(...)` locally, then adapts `result.fullStream` into shared `LLMEvent`s.
|
|
27
27
|
- `../llm.ts` imports `LLMNativeRuntime` from `./llm/native-runtime`; this is the runtime-selection seam. Unsupported native requests return a reason and fall back to AI SDK.
|
|
28
28
|
- `native-runtime.ts` imports `LLMNative` from `./native-request`; this keeps request lowering separate from transport and tool execution.
|
|
29
|
-
- `native-request.ts` is the only adapter file that should construct `LLM.request(...)`, `LLM.model(...)`, `Message.*`, `SystemPart`, `ToolCallPart`, `ToolResultPart`, or `ToolDefinition` values from `@
|
|
30
|
-
- `ai-sdk.ts` and `native-runtime.ts` both emit `@
|
|
29
|
+
- `native-request.ts` is the only adapter file that should construct `LLM.request(...)`, `LLM.model(...)`, `Message.*`, `SystemPart`, `ToolCallPart`, `ToolResultPart`, or `ToolDefinition` values from `@anymous-ai/llm`.
|
|
30
|
+
- `ai-sdk.ts` and `native-runtime.ts` both emit `@anymous-ai/llm` `LLMEvent`s so downstream session processing does not care which runtime handled the request.
|
|
31
31
|
|
|
32
32
|
Keep new integration code on one of these seams. Avoid importing session services into `native-request.ts`; pass normalized data through `RequestInput` instead.
|
|
33
33
|
|
|
@@ -80,11 +80,11 @@ Both runtimes converge on the same `LLMEvent` stream consumed by the session pro
|
|
|
80
80
|
╰─────────────────╯ ╰─────────────────────────────╯
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
`native-runtime.ts` evaluates the gate and either bridges into `@
|
|
83
|
+
`native-runtime.ts` evaluates the gate and either bridges into `@anymous-ai/llm` or returns control so `llm.ts` can take the AI SDK path. Tool execution stays anymous-owned in both branches; only request lowering and transport differ.
|
|
84
84
|
|
|
85
85
|
Safety boundary:
|
|
86
86
|
|
|
87
87
|
- AI SDK remains the default.
|
|
88
|
-
- `
|
|
89
|
-
- Native execution currently supports OpenAI,
|
|
88
|
+
- `ANYMOUS_EXPERIMENTAL_NATIVE_LLM=true` or the umbrella `ANYMOUS_EXPERIMENTAL=true` opts in. Native is not a global replacement.
|
|
89
|
+
- Native execution currently supports OpenAI, anymous-managed OpenAI-compatible, and Anthropic API-key paths backed by `@ai-sdk/openai`, `@ai-sdk/openai-compatible`, or `@ai-sdk/anthropic` catalog entries.
|
|
90
90
|
- Unsupported providers, OpenAI OAuth, and missing API-key cases fall back to AI SDK.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FinishReason, LLMEvent, ProviderMetadata, ToolResultValue } from "@
|
|
1
|
+
import { FinishReason, LLMEvent, ProviderMetadata, ToolResultValue } from "@anymous-ai/llm"
|
|
2
2
|
import { Effect, Schema } from "effect"
|
|
3
3
|
import { type streamText } from "ai"
|
|
4
4
|
import { errorMessage } from "@/util/error"
|
|
@@ -28,7 +28,7 @@ function providerMetadata(value: unknown): ProviderMetadata | undefined {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
// Temporary AI SDK bridge: Copilot billing survives only in raw provider chunks here.
|
|
31
|
-
// Move this extraction into @
|
|
31
|
+
// Move this extraction into @anymous-ai/llm when Copilot is handled by the native runtime.
|
|
32
32
|
function copilotTotalNanoAiu(value: unknown) {
|
|
33
33
|
if (!value || typeof value !== "object") return
|
|
34
34
|
const raw = value as Record<string, unknown>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { JsonSchema, LLMRequest, ProviderMetadata } from "@
|
|
2
|
-
import { LLM, Message, SystemPart, ToolCallPart, ToolDefinition, ToolResultPart } from "@
|
|
1
|
+
import type { JsonSchema, LLMRequest, ProviderMetadata } from "@anymous-ai/llm"
|
|
2
|
+
import { LLM, Message, SystemPart, ToolCallPart, ToolDefinition, ToolResultPart } from "@anymous-ai/llm"
|
|
3
3
|
import {
|
|
4
4
|
AmazonBedrock,
|
|
5
5
|
Anthropic,
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
OpenAI,
|
|
9
9
|
OpenAICompatible,
|
|
10
10
|
OpenRouter,
|
|
11
|
-
} from "@
|
|
11
|
+
} from "@anymous-ai/llm/providers"
|
|
12
12
|
import type { ModelMessage } from "ai"
|
|
13
13
|
import type { Provider } from "@/provider/provider"
|
|
14
14
|
import { isRecord } from "@/util/record"
|
|
@@ -181,7 +181,7 @@ export const model = (input: Provider.Model | RequestInput, headers?: Record<str
|
|
|
181
181
|
export const request = (input: RequestInput) => {
|
|
182
182
|
const converted = messages(input.messages)
|
|
183
183
|
// This is the only native adapter boundary that should construct canonical
|
|
184
|
-
// @
|
|
184
|
+
// @anymous-ai/llm request objects from anymous's session/AI SDK-shaped data.
|
|
185
185
|
return LLM.request({
|
|
186
186
|
model: model(input, input.headers),
|
|
187
187
|
system: [...(input.system ?? []).map(SystemPart.make), ...converted.system],
|
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
toDefinitions,
|
|
16
16
|
type JsonSchema,
|
|
17
17
|
type LLMEvent,
|
|
18
|
-
} from "@
|
|
19
|
-
import type { LLMClientShape } from "@
|
|
18
|
+
} from "@anymous-ai/llm"
|
|
19
|
+
import type { LLMClientShape } from "@anymous-ai/llm/route"
|
|
20
20
|
import { LLMNative } from "./native-request"
|
|
21
21
|
|
|
22
22
|
export type RuntimeStatus =
|
|
@@ -52,8 +52,8 @@ function statusWithFetch(
|
|
|
52
52
|
fetch: typeof globalThis.fetch | undefined,
|
|
53
53
|
): RuntimeStatus {
|
|
54
54
|
const providerID = input.model.providerID
|
|
55
|
-
if (providerID !== "openai" && providerID !== "anthropic" && !providerID.startsWith("
|
|
56
|
-
return { type: "unsupported", reason: "provider is not openai,
|
|
55
|
+
if (providerID !== "openai" && providerID !== "anthropic" && !providerID.startsWith("anymous"))
|
|
56
|
+
return { type: "unsupported", reason: "provider is not openai, anymous, or anthropic" }
|
|
57
57
|
const npm = input.model.api.npm
|
|
58
58
|
if (npm !== "@ai-sdk/openai" && npm !== "@ai-sdk/openai-compatible" && npm !== "@ai-sdk/anthropic")
|
|
59
59
|
return { type: "unsupported", reason: "provider package is not OpenAI, OpenAI-compatible, or Anthropic" }
|
|
@@ -76,7 +76,7 @@ export function stream(input: StreamInput): StreamResult {
|
|
|
76
76
|
const current = statusWithFetch(input, fetch)
|
|
77
77
|
if (current.type === "unsupported") return current
|
|
78
78
|
|
|
79
|
-
// Integration point with @
|
|
79
|
+
// Integration point with @anymous-ai/llm: native-request lowers session data
|
|
80
80
|
// into an LLMRequest, then LLMClient handles route selection and transport.
|
|
81
81
|
//
|
|
82
82
|
// ProviderTransform.providerOptions builds AI-SDK-shaped options for the
|
|
@@ -170,8 +170,8 @@ export function nativeTools(tools: Record<string, Tool>, input: Pick<StreamInput
|
|
|
170
170
|
return Object.fromEntries(
|
|
171
171
|
Object.entries(tools).map(([name, item]) => [
|
|
172
172
|
name,
|
|
173
|
-
// Tool execution remains
|
|
174
|
-
// the @
|
|
173
|
+
// Tool execution remains anymous-owned. The native runtime only adapts
|
|
174
|
+
// the @anymous-ai/llm tool call back into the AI SDK Tool.execute shape.
|
|
175
175
|
NativeTool.make({
|
|
176
176
|
description: item.description ?? "",
|
|
177
177
|
jsonSchema: nativeSchema(item.inputSchema),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PermissionV1 } from "@
|
|
1
|
+
import { PermissionV1 } from "@anymous-ai/core/v1/permission"
|
|
2
2
|
import type { Auth } from "@/auth"
|
|
3
|
-
import { SessionV1 } from "@
|
|
3
|
+
import { SessionV1 } from "@anymous-ai/core/v1/session"
|
|
4
4
|
import type { RuntimeFlags } from "@/effect/runtime-flags"
|
|
5
5
|
import { InstanceState } from "@/effect/instance-state"
|
|
6
6
|
import { Permission } from "@/permission"
|
|
@@ -9,13 +9,13 @@ import type { MessageV2 } from "../message-v2"
|
|
|
9
9
|
import type { Provider } from "@/provider/provider"
|
|
10
10
|
import { ProviderTransform } from "@/provider/transform"
|
|
11
11
|
import { SystemPrompt } from "../system"
|
|
12
|
-
import { InstallationVersion } from "@
|
|
12
|
+
import { InstallationVersion } from "@anymous-ai/core/installation/version"
|
|
13
13
|
import { Effect, Record } from "effect"
|
|
14
14
|
import { jsonSchema, tool as aiTool, type ModelMessage, type Tool } from "ai"
|
|
15
15
|
import type { Plugin } from "@/plugin"
|
|
16
16
|
import { mergeDeep } from "remeda"
|
|
17
17
|
|
|
18
|
-
const USER_AGENT = `
|
|
18
|
+
const USER_AGENT = `anymous/${InstallationVersion}`
|
|
19
19
|
|
|
20
20
|
type PrepareInput = {
|
|
21
21
|
readonly user: SessionV1.User
|
|
@@ -174,7 +174,7 @@ export const prepare = Effect.fn("LLMRequestPrep.prepare")(function* (input: Pre
|
|
|
174
174
|
})
|
|
175
175
|
}
|
|
176
176
|
|
|
177
|
-
const
|
|
177
|
+
const anymousProjectID = input.model.providerID.startsWith("anymous")
|
|
178
178
|
? (yield* InstanceState.context).project.id
|
|
179
179
|
: undefined
|
|
180
180
|
|
|
@@ -185,12 +185,12 @@ export const prepare = Effect.fn("LLMRequestPrep.prepare")(function* (input: Pre
|
|
|
185
185
|
params,
|
|
186
186
|
messageTransformOptions: options,
|
|
187
187
|
headers: {
|
|
188
|
-
...(input.model.providerID.startsWith("
|
|
188
|
+
...(input.model.providerID.startsWith("anymous")
|
|
189
189
|
? {
|
|
190
|
-
...(
|
|
191
|
-
"x-
|
|
192
|
-
"x-
|
|
193
|
-
"x-
|
|
190
|
+
...(anymousProjectID ? { "x-anymous-project": anymousProjectID } : {}),
|
|
191
|
+
"x-anymous-session": input.sessionID,
|
|
192
|
+
"x-anymous-request": input.user.id,
|
|
193
|
+
"x-anymous-client": input.flags.client,
|
|
194
194
|
"User-Agent": USER_AGENT,
|
|
195
195
|
}
|
|
196
196
|
: {
|
package/src/session/llm.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { LayerNode } from "@
|
|
2
|
-
import { llmClient } from "@
|
|
3
|
-
import { PermissionV1 } from "@
|
|
1
|
+
import { LayerNode } from "@anymous-ai/core/effect/layer-node"
|
|
2
|
+
import { llmClient } from "@anymous-ai/core/effect/app-node-platform"
|
|
3
|
+
import { PermissionV1 } from "@anymous-ai/core/v1/permission"
|
|
4
4
|
import { Provider } from "@/provider/provider"
|
|
5
|
-
import { SessionV1 } from "@
|
|
6
|
-
import { serviceUse } from "@
|
|
5
|
+
import { SessionV1 } from "@anymous-ai/core/v1/session"
|
|
6
|
+
import { serviceUse } from "@anymous-ai/core/effect/service-use"
|
|
7
7
|
import { Context, Effect, Layer } from "effect"
|
|
8
8
|
import * as Stream from "effect/Stream"
|
|
9
9
|
import { streamText, wrapLanguageModel, type ModelMessage, type Tool } from "ai"
|
|
10
|
-
import type { LLMEvent } from "@
|
|
11
|
-
import { LLMClient } from "@
|
|
12
|
-
import type { LLMClientService } from "@
|
|
10
|
+
import type { LLMEvent } from "@anymous-ai/llm"
|
|
11
|
+
import { LLMClient } from "@anymous-ai/llm/route"
|
|
12
|
+
import type { LLMClientService } from "@anymous-ai/llm/route"
|
|
13
13
|
import { GitLabWorkflowLanguageModel } from "gitlab-ai-provider"
|
|
14
14
|
import { ProviderTransform } from "@/provider/transform"
|
|
15
15
|
import { Config } from "@/config/config"
|
|
@@ -18,7 +18,7 @@ import type { MessageV2 } from "./message-v2"
|
|
|
18
18
|
import { Plugin } from "@/plugin"
|
|
19
19
|
import { Permission } from "@/permission"
|
|
20
20
|
import { EventV2Bridge } from "@/event-v2-bridge"
|
|
21
|
-
import { EventV2 } from "@
|
|
21
|
+
import { EventV2 } from "@anymous-ai/core/event"
|
|
22
22
|
import { Wildcard } from "@/util/wildcard"
|
|
23
23
|
import { SessionID } from "@/session/schema"
|
|
24
24
|
import { Auth } from "@/auth"
|
|
@@ -55,7 +55,7 @@ export interface Interface {
|
|
|
55
55
|
readonly stream: (input: StreamInput) => Stream.Stream<LLMEvent, unknown>
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
export class Service extends Context.Service<Service, Interface>()("@
|
|
58
|
+
export class Service extends Context.Service<Service, Interface>()("@anymous/LLM") {}
|
|
59
59
|
|
|
60
60
|
export const use = serviceUse(Service)
|
|
61
61
|
|
|
@@ -113,7 +113,7 @@ const live: Layer.Layer<
|
|
|
113
113
|
})
|
|
114
114
|
|
|
115
115
|
// Wire up toolExecutor for DWS workflow models so that tool calls
|
|
116
|
-
// from the workflow service are executed via
|
|
116
|
+
// from the workflow service are executed via anymous's tool system
|
|
117
117
|
// and results sent back over the WebSocket.
|
|
118
118
|
const bridge = yield* EffectBridge.make()
|
|
119
119
|
if (language instanceof GitLabWorkflowLanguageModel) {
|
|
@@ -221,7 +221,7 @@ const live: Layer.Layer<
|
|
|
221
221
|
})
|
|
222
222
|
: undefined
|
|
223
223
|
|
|
224
|
-
// Runtime seam: native is an opt-in adapter over @
|
|
224
|
+
// Runtime seam: native is an opt-in adapter over @anymous-ai/llm. It
|
|
225
225
|
// either returns a ready LLMEvent stream or a concrete fallback reason.
|
|
226
226
|
if (flags.experimentalNativeLlm) {
|
|
227
227
|
const native = LLMNativeRuntime.stream({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SessionID, MessageID } from "./schema"
|
|
2
|
-
import { SessionV1 } from "@
|
|
3
|
-
import { ProviderV2 } from "@
|
|
2
|
+
import { SessionV1 } from "@anymous-ai/core/v1/session"
|
|
3
|
+
import { ProviderV2 } from "@anymous-ai/core/provider"
|
|
4
4
|
import {
|
|
5
5
|
APIError,
|
|
6
6
|
AbortedError,
|
|
@@ -14,12 +14,12 @@ import {
|
|
|
14
14
|
SubtaskPart,
|
|
15
15
|
User,
|
|
16
16
|
WithParts,
|
|
17
|
-
} from "@
|
|
17
|
+
} from "@anymous-ai/core/v1/session"
|
|
18
18
|
|
|
19
|
-
import { NamedError } from "@
|
|
19
|
+
import { NamedError } from "@anymous-ai/core/util/error"
|
|
20
20
|
import { APICallError, convertToModelMessages, LoadAPIKeyError, type ModelMessage, type UIMessage } from "ai"
|
|
21
|
-
import { Database } from "@
|
|
22
|
-
import { LayerNode } from "@
|
|
21
|
+
import { Database } from "@anymous-ai/core/database/database"
|
|
22
|
+
import { LayerNode } from "@anymous-ai/core/effect/layer-node"
|
|
23
23
|
import { NotFoundError } from "@/storage/storage"
|
|
24
24
|
import { and } from "drizzle-orm"
|
|
25
25
|
import { desc } from "drizzle-orm"
|
|
@@ -27,7 +27,7 @@ import { eq } from "drizzle-orm"
|
|
|
27
27
|
import { inArray } from "drizzle-orm"
|
|
28
28
|
import { lt } from "drizzle-orm"
|
|
29
29
|
import { or } from "drizzle-orm"
|
|
30
|
-
import { MessageTable, PartTable, SessionTable } from "@
|
|
30
|
+
import { MessageTable, PartTable, SessionTable } from "@anymous-ai/core/session/sql"
|
|
31
31
|
import { ProviderError } from "@/provider/error"
|
|
32
32
|
import { iife } from "@/util/iife"
|
|
33
33
|
import { errorMessage } from "@/util/error"
|
package/src/session/message.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Schema } from "effect"
|
|
2
2
|
import { SessionID } from "./schema"
|
|
3
3
|
|
|
4
|
-
import { NonNegativeInt } from "@
|
|
4
|
+
import { NonNegativeInt } from "@anymous-ai/core/schema"
|
|
5
5
|
import { MessageError } from "./message-error"
|
|
6
6
|
import { AuthError, OutputLengthError } from "./message-error"
|
|
7
|
-
import { ProviderV2 } from "@
|
|
8
|
-
import { ModelV2 } from "@
|
|
7
|
+
import { ProviderV2 } from "@anymous-ai/core/provider"
|
|
8
|
+
import { ModelV2 } from "@anymous-ai/core/model"
|
|
9
9
|
export { AuthError, OutputLengthError } from "./message-error"
|
|
10
10
|
|
|
11
11
|
export const ToolCall = Schema.Struct({
|
package/src/session/overflow.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Config } from "@/config/config"
|
|
2
|
-
import { ConfigV1 } from "@
|
|
3
|
-
import { SessionV1 } from "@
|
|
2
|
+
import { ConfigV1 } from "@anymous-ai/core/v1/config/config"
|
|
3
|
+
import { SessionV1 } from "@anymous-ai/core/v1/session"
|
|
4
4
|
import type { Provider } from "@/provider/provider"
|
|
5
5
|
import { ProviderTransform } from "@/provider/transform"
|
|
6
6
|
import type { MessageV2 } from "./message-v2"
|