@lapis-notes/ai 0.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/CHANGELOG.md +6 -0
- package/LICENSE.md +8 -0
- package/README.md +20 -0
- package/dist/ai-plugin.d.ts +88 -0
- package/dist/ai-plugin.js +742 -0
- package/dist/bootstrap/build.d.ts +15 -0
- package/dist/bootstrap/build.js +28 -0
- package/dist/bootstrap/folder-instructions.d.ts +4 -0
- package/dist/bootstrap/folder-instructions.js +49 -0
- package/dist/bootstrap/format.d.ts +2 -0
- package/dist/bootstrap/format.js +46 -0
- package/dist/bootstrap/instructions.d.ts +1 -0
- package/dist/bootstrap/instructions.js +8 -0
- package/dist/bootstrap/types.d.ts +36 -0
- package/dist/bootstrap/types.js +3 -0
- package/dist/catalog/ai-catalog-panel.svelte +742 -0
- package/dist/catalog/ai-catalog-panel.svelte.d.ts +13 -0
- package/dist/catalog/ai-catalog-view-type.d.ts +1 -0
- package/dist/catalog/ai-catalog-view-type.js +1 -0
- package/dist/catalog/ai-catalog-view.d.ts +22 -0
- package/dist/catalog/ai-catalog-view.js +48 -0
- package/dist/catalog/filter.d.ts +3 -0
- package/dist/catalog/filter.js +24 -0
- package/dist/catalog/inventory.d.ts +21 -0
- package/dist/catalog/inventory.js +255 -0
- package/dist/catalog/tree.d.ts +12 -0
- package/dist/catalog/tree.js +60 -0
- package/dist/catalog/types.d.ts +44 -0
- package/dist/catalog/types.js +1 -0
- package/dist/chat/ai-approval-card.svelte +54 -0
- package/dist/chat/ai-approval-card.svelte.d.ts +9 -0
- package/dist/chat/ai-chat-panel.svelte +1288 -0
- package/dist/chat/ai-chat-panel.svelte.d.ts +50 -0
- package/dist/chat/ai-inventory-result.css +55 -0
- package/dist/chat/ai-inventory-result.svelte +63 -0
- package/dist/chat/ai-inventory-result.svelte.d.ts +5 -0
- package/dist/chat/ai-question-card.svelte +132 -0
- package/dist/chat/ai-question-card.svelte.d.ts +9 -0
- package/dist/chat/ai-view-bootstrap.d.ts +13 -0
- package/dist/chat/ai-view-bootstrap.js +86 -0
- package/dist/chat/ai-view-panel.svelte +89 -0
- package/dist/chat/ai-view-panel.svelte.d.ts +13 -0
- package/dist/chat/ai-view-type.d.ts +1 -0
- package/dist/chat/ai-view-type.js +1 -0
- package/dist/chat/ai-view.d.ts +60 -0
- package/dist/chat/ai-view.js +121 -0
- package/dist/chat/chat-controller.svelte.d.ts +82 -0
- package/dist/chat/chat-controller.svelte.js +1926 -0
- package/dist/chat/chat-items.d.ts +88 -0
- package/dist/chat/chat-items.js +9 -0
- package/dist/chat/chat-mentions.d.ts +15 -0
- package/dist/chat/chat-mentions.js +77 -0
- package/dist/chat/chat-result-views.d.ts +5 -0
- package/dist/chat/chat-result-views.js +15 -0
- package/dist/chat/chat-session.d.ts +28 -0
- package/dist/chat/chat-session.js +50 -0
- package/dist/chat/chat-status.d.ts +1 -0
- package/dist/chat/chat-status.js +3 -0
- package/dist/chat/chat-time.d.ts +18 -0
- package/dist/chat/chat-time.js +90 -0
- package/dist/chat/chat-tool-display.d.ts +17 -0
- package/dist/chat/chat-tool-display.js +213 -0
- package/dist/chat/chat-tool-identity.d.ts +4 -0
- package/dist/chat/chat-tool-identity.js +42 -0
- package/dist/chat/chat-trace.d.ts +6 -0
- package/dist/chat/chat-trace.js +256 -0
- package/dist/chat/live-runtime-unavailable.d.ts +1 -0
- package/dist/chat/live-runtime-unavailable.js +1 -0
- package/dist/commands/agent.d.ts +8 -0
- package/dist/commands/agent.js +38 -0
- package/dist/commands/catalog.d.ts +18 -0
- package/dist/commands/catalog.js +115 -0
- package/dist/commands/discovery.d.ts +36 -0
- package/dist/commands/discovery.js +151 -0
- package/dist/commands/groups.d.ts +16 -0
- package/dist/commands/groups.js +121 -0
- package/dist/commands/inspect.d.ts +18 -0
- package/dist/commands/inspect.js +29 -0
- package/dist/commands/markdown.d.ts +21 -0
- package/dist/commands/markdown.js +117 -0
- package/dist/commands/parser.d.ts +4 -0
- package/dist/commands/parser.js +24 -0
- package/dist/commands/reserved.d.ts +4 -0
- package/dist/commands/reserved.js +107 -0
- package/dist/commands/router.d.ts +17 -0
- package/dist/commands/router.js +170 -0
- package/dist/commands/seed.d.ts +4 -0
- package/dist/commands/seed.js +8 -0
- package/dist/commands/types.d.ts +54 -0
- package/dist/commands/types.js +1 -0
- package/dist/commands/user-agents-node.d.ts +3 -0
- package/dist/commands/user-agents-node.js +52 -0
- package/dist/commands/user-agents.d.ts +22 -0
- package/dist/commands/user-agents.js +40 -0
- package/dist/conversations/approval-grants.d.ts +20 -0
- package/dist/conversations/approval-grants.js +75 -0
- package/dist/conversations/binding-state.d.ts +6 -0
- package/dist/conversations/binding-state.js +35 -0
- package/dist/conversations/context-handoff.d.ts +25 -0
- package/dist/conversations/context-handoff.js +207 -0
- package/dist/conversations/conversation-index-coordinator.d.ts +18 -0
- package/dist/conversations/conversation-index-coordinator.js +81 -0
- package/dist/conversations/conversation-index.d.ts +16 -0
- package/dist/conversations/conversation-index.js +125 -0
- package/dist/conversations/conversation-locator.d.ts +2 -0
- package/dist/conversations/conversation-locator.js +20 -0
- package/dist/conversations/conversation-palette.d.ts +18 -0
- package/dist/conversations/conversation-palette.js +29 -0
- package/dist/conversations/conversation-repository.d.ts +39 -0
- package/dist/conversations/conversation-repository.js +213 -0
- package/dist/conversations/handoff-summary.d.ts +48 -0
- package/dist/conversations/handoff-summary.js +269 -0
- package/dist/conversations/hashes.d.ts +5 -0
- package/dist/conversations/hashes.js +40 -0
- package/dist/conversations/history-creation-scope.d.ts +12 -0
- package/dist/conversations/history-creation-scope.js +44 -0
- package/dist/conversations/jsonl.d.ts +10 -0
- package/dist/conversations/jsonl.js +41 -0
- package/dist/conversations/memory-transcript-store.d.ts +15 -0
- package/dist/conversations/memory-transcript-store.js +119 -0
- package/dist/conversations/paths.d.ts +14 -0
- package/dist/conversations/paths.js +92 -0
- package/dist/conversations/redaction.d.ts +13 -0
- package/dist/conversations/redaction.js +94 -0
- package/dist/conversations/reveal-scope.d.ts +3 -0
- package/dist/conversations/reveal-scope.js +8 -0
- package/dist/conversations/scope-resolver.d.ts +11 -0
- package/dist/conversations/scope-resolver.js +18 -0
- package/dist/conversations/scope-tree.d.ts +10 -0
- package/dist/conversations/scope-tree.js +71 -0
- package/dist/conversations/transcript-projection.d.ts +9 -0
- package/dist/conversations/transcript-projection.js +409 -0
- package/dist/conversations/transcript-store.d.ts +24 -0
- package/dist/conversations/transcript-store.js +27 -0
- package/dist/conversations/types.d.ts +224 -0
- package/dist/conversations/types.js +12 -0
- package/dist/conversations/validation.d.ts +4 -0
- package/dist/conversations/validation.js +383 -0
- package/dist/conversations/vault-transcript-store.d.ts +22 -0
- package/dist/conversations/vault-transcript-store.js +219 -0
- package/dist/core/event-queue.d.ts +6 -0
- package/dist/core/event-queue.js +39 -0
- package/dist/core/types.d.ts +241 -0
- package/dist/core/types.js +50 -0
- package/dist/history/ai-history-panel.svelte +937 -0
- package/dist/history/ai-history-panel.svelte.d.ts +17 -0
- package/dist/history/ai-history-view-type.d.ts +1 -0
- package/dist/history/ai-history-view-type.js +1 -0
- package/dist/history/ai-history-view.d.ts +26 -0
- package/dist/history/ai-history-view.js +51 -0
- package/dist/history/conversation-history-tree.d.ts +15 -0
- package/dist/history/conversation-history-tree.js +71 -0
- package/dist/host/agent-workspace.d.ts +6 -0
- package/dist/host/agent-workspace.js +16 -0
- package/dist/host/create-host-runtimes.d.ts +2 -0
- package/dist/host/create-host-runtimes.js +14 -0
- package/dist/host/desktop-process-host.d.ts +6 -0
- package/dist/host/desktop-process-host.js +74 -0
- package/dist/host/host-runtime-availability.d.ts +1 -0
- package/dist/host/host-runtime-availability.js +3 -0
- package/dist/host/process-host.d.ts +31 -0
- package/dist/host/process-host.js +6 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.js +49 -0
- package/dist/jsonl/ai-jsonl-preview.d.ts +27 -0
- package/dist/jsonl/ai-jsonl-preview.js +68 -0
- package/dist/jsonl/ai-jsonl-view-type.d.ts +1 -0
- package/dist/jsonl/ai-jsonl-view-type.js +1 -0
- package/dist/jsonl/ai-jsonl-view.d.ts +16 -0
- package/dist/jsonl/ai-jsonl-view.js +57 -0
- package/dist/jsonl/ai-jsonl-view.svelte +260 -0
- package/dist/jsonl/ai-jsonl-view.svelte.d.ts +9 -0
- package/dist/memory/candidate-extractor.d.ts +25 -0
- package/dist/memory/candidate-extractor.js +191 -0
- package/dist/memory/forget-confirmation.d.ts +3 -0
- package/dist/memory/forget-confirmation.js +45 -0
- package/dist/memory/hashes.d.ts +5 -0
- package/dist/memory/hashes.js +37 -0
- package/dist/memory/memory-ingestion-coordinator.d.ts +19 -0
- package/dist/memory/memory-ingestion-coordinator.js +108 -0
- package/dist/memory/memory-record-store.d.ts +62 -0
- package/dist/memory/memory-record-store.js +369 -0
- package/dist/memory/memory-scheduler.d.ts +21 -0
- package/dist/memory/memory-scheduler.js +143 -0
- package/dist/memory/memory-tools.d.ts +61 -0
- package/dist/memory/memory-tools.js +99 -0
- package/dist/memory/native-memory-service.d.ts +72 -0
- package/dist/memory/native-memory-service.js +1256 -0
- package/dist/memory/paths.d.ts +13 -0
- package/dist/memory/paths.js +60 -0
- package/dist/memory/runtime-consolidation-provider.d.ts +18 -0
- package/dist/memory/runtime-consolidation-provider.js +154 -0
- package/dist/memory/types.d.ts +139 -0
- package/dist/memory/types.js +1 -0
- package/dist/providers/acp-model-provider.d.ts +11 -0
- package/dist/providers/acp-model-provider.js +99 -0
- package/dist/providers/codex-model-catalog.d.ts +7 -0
- package/dist/providers/codex-model-catalog.js +179 -0
- package/dist/providers/codex-model-provider.d.ts +12 -0
- package/dist/providers/codex-model-provider.js +42 -0
- package/dist/providers/model-provider.d.ts +26 -0
- package/dist/providers/model-provider.js +26 -0
- package/dist/public-components.d.ts +3 -0
- package/dist/public-components.js +3 -0
- package/dist/registry/runtime-registry.d.ts +11 -0
- package/dist/registry/runtime-registry.js +71 -0
- package/dist/registry/select-runtime.d.ts +9 -0
- package/dist/registry/select-runtime.js +31 -0
- package/dist/runtime-adapters.d.ts +16 -0
- package/dist/runtime-adapters.js +9 -0
- package/dist/runtimes/acp/acp-event-mapper.d.ts +56 -0
- package/dist/runtimes/acp/acp-event-mapper.js +237 -0
- package/dist/runtimes/acp/acp-runtime.d.ts +46 -0
- package/dist/runtimes/acp/acp-runtime.js +165 -0
- package/dist/runtimes/acp/desktop-acp-backend.d.ts +16 -0
- package/dist/runtimes/acp/desktop-acp-backend.js +243 -0
- package/dist/runtimes/codex/app-server-protocol.d.ts +28 -0
- package/dist/runtimes/codex/app-server-protocol.js +274 -0
- package/dist/runtimes/codex/codex-runtime.d.ts +24 -0
- package/dist/runtimes/codex/codex-runtime.js +318 -0
- package/dist/runtimes/fake/fake-runtime.d.ts +51 -0
- package/dist/runtimes/fake/fake-runtime.js +257 -0
- package/dist/sessions/plugin-data.d.ts +8 -0
- package/dist/sessions/plugin-data.js +29 -0
- package/dist/sessions/session-store.d.ts +47 -0
- package/dist/sessions/session-store.js +117 -0
- package/dist/settings/acp-agents.d.ts +8 -0
- package/dist/settings/acp-agents.js +11 -0
- package/dist/settings/ai-settings-tab.d.ts +8 -0
- package/dist/settings/ai-settings-tab.js +249 -0
- package/dist/settings/ai-settings.d.ts +43 -0
- package/dist/settings/ai-settings.js +147 -0
- package/dist/settings/app-tool-setting-rows.d.ts +16 -0
- package/dist/settings/app-tool-setting-rows.js +30 -0
- package/dist/settings/register-ai-settings.d.ts +3 -0
- package/dist/settings/register-ai-settings.js +393 -0
- package/dist/skills/activation.d.ts +2 -0
- package/dist/skills/activation.js +20 -0
- package/dist/skills/bundled/lapis-notes.d.ts +3 -0
- package/dist/skills/bundled/lapis-notes.js +52 -0
- package/dist/skills/bundled/research.d.ts +6 -0
- package/dist/skills/bundled/research.js +29 -0
- package/dist/skills/discovery.d.ts +21 -0
- package/dist/skills/discovery.js +227 -0
- package/dist/skills/manifest.d.ts +3 -0
- package/dist/skills/manifest.js +39 -0
- package/dist/skills/parser.d.ts +12 -0
- package/dist/skills/parser.js +124 -0
- package/dist/skills/registry.d.ts +21 -0
- package/dist/skills/registry.js +89 -0
- package/dist/skills/seed.d.ts +5 -0
- package/dist/skills/seed.js +18 -0
- package/dist/skills/skill-tools.d.ts +8 -0
- package/dist/skills/skill-tools.js +113 -0
- package/dist/skills/types.d.ts +67 -0
- package/dist/skills/types.js +1 -0
- package/dist/styles.css +514 -0
- package/dist/tools/app-tool-host.d.ts +47 -0
- package/dist/tools/app-tool-host.js +419 -0
- package/dist/tools/desktop-app-tool-bridge.d.ts +23 -0
- package/dist/tools/desktop-app-tool-bridge.js +223 -0
- package/dist/tools/mcp-server-registry.d.ts +7 -0
- package/dist/tools/mcp-server-registry.js +30 -0
- package/manifest.json +34 -0
- package/package.json +83 -0
- package/styles.css +1 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { AgentProcessHost } from "../host/process-host";
|
|
2
|
+
import type { ModelRef } from "../core/types";
|
|
3
|
+
import type { ModelProvider, ProviderAuthStatus } from "./model-provider";
|
|
4
|
+
export declare class CodexModelProvider implements ModelProvider {
|
|
5
|
+
#private;
|
|
6
|
+
readonly id = "codex";
|
|
7
|
+
constructor(host: AgentProcessHost, options?: {
|
|
8
|
+
cwd?: string;
|
|
9
|
+
});
|
|
10
|
+
listModels(): Promise<ModelRef[]>;
|
|
11
|
+
authStatus(): Promise<ProviderAuthStatus>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { listCodexModelsFromHost } from "./codex-model-catalog";
|
|
2
|
+
export class CodexModelProvider {
|
|
3
|
+
id = "codex";
|
|
4
|
+
#host;
|
|
5
|
+
#cwd;
|
|
6
|
+
constructor(host, options = {}) {
|
|
7
|
+
this.#host = host;
|
|
8
|
+
this.#cwd = options.cwd;
|
|
9
|
+
}
|
|
10
|
+
async listModels() {
|
|
11
|
+
if (!this.#host.available)
|
|
12
|
+
return [];
|
|
13
|
+
return listCodexModelsFromHost(this.#host, { cwd: this.#cwd });
|
|
14
|
+
}
|
|
15
|
+
async authStatus() {
|
|
16
|
+
if (!this.#host.available) {
|
|
17
|
+
return {
|
|
18
|
+
authenticated: false,
|
|
19
|
+
label: "Codex",
|
|
20
|
+
detail: "Live model listing requires the desktop agent-runtime capability.",
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
let models;
|
|
24
|
+
try {
|
|
25
|
+
models = await this.listModels();
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
return {
|
|
29
|
+
authenticated: false,
|
|
30
|
+
label: "Codex",
|
|
31
|
+
detail: error instanceof Error ? error.message : String(error),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return models.length > 0
|
|
35
|
+
? { authenticated: true, label: "Codex" }
|
|
36
|
+
: {
|
|
37
|
+
authenticated: false,
|
|
38
|
+
label: "Codex",
|
|
39
|
+
detail: "Codex did not return a model catalog.",
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ModelRef } from "../core/types";
|
|
2
|
+
export type ProviderAuthStatus = {
|
|
3
|
+
authenticated: boolean;
|
|
4
|
+
label?: string;
|
|
5
|
+
detail?: string;
|
|
6
|
+
};
|
|
7
|
+
export interface ModelProvider {
|
|
8
|
+
readonly id: string;
|
|
9
|
+
listModels(): Promise<ModelRef[]>;
|
|
10
|
+
authStatus(): Promise<ProviderAuthStatus>;
|
|
11
|
+
}
|
|
12
|
+
export interface AgentModelCatalog {
|
|
13
|
+
listModels(provider: string): Promise<ModelRef[]>;
|
|
14
|
+
}
|
|
15
|
+
export declare class ModelProviderRegistry implements AgentModelCatalog {
|
|
16
|
+
#private;
|
|
17
|
+
constructor(providers?: ModelProvider[]);
|
|
18
|
+
listModels(provider: string): Promise<ModelRef[]>;
|
|
19
|
+
}
|
|
20
|
+
export declare class StaticModelProvider implements ModelProvider {
|
|
21
|
+
#private;
|
|
22
|
+
readonly id: string;
|
|
23
|
+
constructor(id: string, models: ModelRef[], auth?: ProviderAuthStatus);
|
|
24
|
+
listModels(): Promise<ModelRef[]>;
|
|
25
|
+
authStatus(): Promise<ProviderAuthStatus>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export class ModelProviderRegistry {
|
|
2
|
+
#providers = new Map();
|
|
3
|
+
constructor(providers = []) {
|
|
4
|
+
for (const provider of providers)
|
|
5
|
+
this.#providers.set(provider.id, provider);
|
|
6
|
+
}
|
|
7
|
+
async listModels(provider) {
|
|
8
|
+
return (await this.#providers.get(provider)?.listModels()) ?? [];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export class StaticModelProvider {
|
|
12
|
+
id;
|
|
13
|
+
#models;
|
|
14
|
+
#auth;
|
|
15
|
+
constructor(id, models, auth = { authenticated: true, label: "Local" }) {
|
|
16
|
+
this.id = id;
|
|
17
|
+
this.#models = models;
|
|
18
|
+
this.#auth = auth;
|
|
19
|
+
}
|
|
20
|
+
async listModels() {
|
|
21
|
+
return [...this.#models];
|
|
22
|
+
}
|
|
23
|
+
async authStatus() {
|
|
24
|
+
return { ...this.#auth };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AgentRequest, AgentRuntime } from "../core/types";
|
|
2
|
+
export declare class AgentRuntimeNotFoundError extends Error {
|
|
3
|
+
constructor(message?: string);
|
|
4
|
+
}
|
|
5
|
+
export interface AgentRuntimeRegistry {
|
|
6
|
+
register(runtime: AgentRuntime): void;
|
|
7
|
+
get(id: string): AgentRuntime | undefined;
|
|
8
|
+
list(): AgentRuntime[];
|
|
9
|
+
select(request: AgentRequest): Promise<AgentRuntime>;
|
|
10
|
+
}
|
|
11
|
+
export declare function createAgentRuntimeRegistry(runtimes?: AgentRuntime[]): AgentRuntimeRegistry;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export class AgentRuntimeNotFoundError extends Error {
|
|
2
|
+
constructor(message = "No compatible agent runtime is registered.") {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = "AgentRuntimeNotFoundError";
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export function createAgentRuntimeRegistry(runtimes = []) {
|
|
8
|
+
const registered = new Map();
|
|
9
|
+
for (const runtime of runtimes)
|
|
10
|
+
registered.set(runtime.id, runtime);
|
|
11
|
+
return {
|
|
12
|
+
register(runtime) {
|
|
13
|
+
registered.set(runtime.id, runtime);
|
|
14
|
+
},
|
|
15
|
+
get(id) {
|
|
16
|
+
return registered.get(id);
|
|
17
|
+
},
|
|
18
|
+
list() {
|
|
19
|
+
return [...registered.values()];
|
|
20
|
+
},
|
|
21
|
+
async select(request) {
|
|
22
|
+
const preferredId = typeof request.metadata?.runtime === "string"
|
|
23
|
+
? request.metadata.runtime
|
|
24
|
+
: undefined;
|
|
25
|
+
if (preferredId) {
|
|
26
|
+
const preferred = registered.get(preferredId);
|
|
27
|
+
if (preferred && (await preferred.supports(request)))
|
|
28
|
+
return preferred;
|
|
29
|
+
}
|
|
30
|
+
const candidates = [];
|
|
31
|
+
for (const runtime of registered.values()) {
|
|
32
|
+
if (await runtime.supports(request))
|
|
33
|
+
candidates.push(runtime);
|
|
34
|
+
}
|
|
35
|
+
if (candidates.length === 0)
|
|
36
|
+
throw new AgentRuntimeNotFoundError();
|
|
37
|
+
return candidates.sort(compareRuntimes)[0];
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
function compareRuntimes(left, right) {
|
|
42
|
+
const leftScore = scoreRuntime(left);
|
|
43
|
+
const rightScore = scoreRuntime(right);
|
|
44
|
+
if (leftScore !== rightScore)
|
|
45
|
+
return rightScore - leftScore;
|
|
46
|
+
return left.id.localeCompare(right.id);
|
|
47
|
+
}
|
|
48
|
+
function scoreRuntime(runtime) {
|
|
49
|
+
const capabilities = runtime.capabilities();
|
|
50
|
+
const approvals = capabilities.approvals;
|
|
51
|
+
let score = 0;
|
|
52
|
+
if (approvals.supported)
|
|
53
|
+
score += 4;
|
|
54
|
+
if (approvals.interactive)
|
|
55
|
+
score += 4;
|
|
56
|
+
if (approvals.persistentDecisions)
|
|
57
|
+
score += 2;
|
|
58
|
+
if (approvals.granularPermissions)
|
|
59
|
+
score += 2;
|
|
60
|
+
if (capabilities.mcpTools)
|
|
61
|
+
score += 2;
|
|
62
|
+
if (capabilities.nativeTools)
|
|
63
|
+
score += 2;
|
|
64
|
+
if (capabilities.steer)
|
|
65
|
+
score += 1;
|
|
66
|
+
if (capabilities.modelSelection)
|
|
67
|
+
score += 1;
|
|
68
|
+
if (approvals.policyAmendments)
|
|
69
|
+
score -= 1;
|
|
70
|
+
return score;
|
|
71
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AgentRequest, AgentRuntime } from "../core/types";
|
|
2
|
+
import type { AiPluginSettings } from "../settings/ai-settings";
|
|
3
|
+
import { type AgentRuntimeRegistry } from "./runtime-registry";
|
|
4
|
+
export declare function selectAgentRuntime(options: {
|
|
5
|
+
registry: AgentRuntimeRegistry;
|
|
6
|
+
settings: Pick<AiPluginSettings, "defaultRuntime" | "acpAgent">;
|
|
7
|
+
request: AgentRequest;
|
|
8
|
+
fake: AgentRuntime;
|
|
9
|
+
}): Promise<AgentRuntime>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { normalizeAcpAgent } from "../settings/acp-agents";
|
|
2
|
+
import { AgentRuntimeNotFoundError, } from "./runtime-registry";
|
|
3
|
+
export async function selectAgentRuntime(options) {
|
|
4
|
+
const { registry, settings, fake } = options;
|
|
5
|
+
const agent = normalizeAcpAgent(options.request.agent ?? settings.acpAgent);
|
|
6
|
+
const request = {
|
|
7
|
+
...options.request,
|
|
8
|
+
agent,
|
|
9
|
+
metadata: {
|
|
10
|
+
...options.request.metadata,
|
|
11
|
+
acpAgent: agent,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
if (settings.defaultRuntime === "fake")
|
|
15
|
+
return fake;
|
|
16
|
+
if (settings.defaultRuntime !== "auto") {
|
|
17
|
+
const pinned = registry.get(settings.defaultRuntime);
|
|
18
|
+
if (pinned && (await pinned.supports(request)))
|
|
19
|
+
return pinned;
|
|
20
|
+
throw new AgentRuntimeNotFoundError(`Pinned runtime ${settings.defaultRuntime} is unavailable.`);
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
return await registry.select(request);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
if (error instanceof AgentRuntimeNotFoundError && (await fake.supports(request))) {
|
|
27
|
+
return fake;
|
|
28
|
+
}
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { createAgentProcessHost } from "./host/desktop-process-host";
|
|
2
|
+
export { UnavailableAgentProcessHost } from "./host/process-host";
|
|
3
|
+
export type { AgentProcessHandle, AgentProcessHost, AgentProcessMessage, } from "./host/process-host";
|
|
4
|
+
export { AcpAgentRuntime } from "./runtimes/acp/acp-runtime";
|
|
5
|
+
export type { AcpRuntimeBackend } from "./runtimes/acp/acp-runtime";
|
|
6
|
+
export { DesktopAcpRuntimeBackend } from "./runtimes/acp/desktop-acp-backend";
|
|
7
|
+
export { buildConversationContextHandoff } from "./conversations/context-handoff";
|
|
8
|
+
export type { AgentSession } from "./core/types";
|
|
9
|
+
export type { AgentBindingCreatedRecord, TranscriptEntry, } from "./conversations/types";
|
|
10
|
+
export { mapAcpPermissionRequest, mapAcpRuntimeEvent, mapApprovalOptionToAcpDecision, } from "./runtimes/acp/acp-event-mapper";
|
|
11
|
+
export type { AcpPermissionDecision } from "./runtimes/acp/acp-event-mapper";
|
|
12
|
+
export { CodexNativeRuntime } from "./runtimes/codex/codex-runtime";
|
|
13
|
+
export { AppToolApprovalBroker, AppToolExecutionError, AppToolHost, } from "./tools/app-tool-host";
|
|
14
|
+
export type { AppToolCall, AppToolExecutionErrorCode, AppToolPolicySettings, CreateAppToolSessionInput, } from "./tools/app-tool-host";
|
|
15
|
+
export { DesktopAppToolBridge } from "./tools/desktop-app-tool-bridge";
|
|
16
|
+
export type { AppToolBridgeCoordinator, AppToolBridgeEvent, } from "./tools/desktop-app-tool-bridge";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { createAgentProcessHost } from "./host/desktop-process-host";
|
|
2
|
+
export { UnavailableAgentProcessHost } from "./host/process-host";
|
|
3
|
+
export { AcpAgentRuntime } from "./runtimes/acp/acp-runtime";
|
|
4
|
+
export { DesktopAcpRuntimeBackend } from "./runtimes/acp/desktop-acp-backend";
|
|
5
|
+
export { buildConversationContextHandoff } from "./conversations/context-handoff";
|
|
6
|
+
export { mapAcpPermissionRequest, mapAcpRuntimeEvent, mapApprovalOptionToAcpDecision, } from "./runtimes/acp/acp-event-mapper";
|
|
7
|
+
export { CodexNativeRuntime } from "./runtimes/codex/codex-runtime";
|
|
8
|
+
export { AppToolApprovalBroker, AppToolExecutionError, AppToolHost, } from "./tools/app-tool-host";
|
|
9
|
+
export { DesktopAppToolBridge } from "./tools/desktop-app-tool-bridge";
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type AgentEvent, type AgentEventSource, type ApprovalRequest } from "../../core/types";
|
|
2
|
+
export type AcpRuntimeEventLike = {
|
|
3
|
+
type: string;
|
|
4
|
+
text?: string;
|
|
5
|
+
tag?: string;
|
|
6
|
+
used?: number;
|
|
7
|
+
size?: number;
|
|
8
|
+
stream?: "output" | "thought";
|
|
9
|
+
toolCallId?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
status?: string;
|
|
12
|
+
kind?: string;
|
|
13
|
+
rawInput?: unknown;
|
|
14
|
+
rawOutput?: unknown;
|
|
15
|
+
locations?: unknown[];
|
|
16
|
+
content?: unknown[];
|
|
17
|
+
message?: string;
|
|
18
|
+
stopReason?: string;
|
|
19
|
+
commands?: Array<{
|
|
20
|
+
name?: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
argumentHint?: string;
|
|
23
|
+
hint?: string;
|
|
24
|
+
}>;
|
|
25
|
+
__source?: AgentEventSource;
|
|
26
|
+
};
|
|
27
|
+
export type AcpPermissionRequestLike = {
|
|
28
|
+
requestId?: string;
|
|
29
|
+
id?: string;
|
|
30
|
+
sessionId?: string;
|
|
31
|
+
title?: string;
|
|
32
|
+
kind?: string;
|
|
33
|
+
inferredKind?: string;
|
|
34
|
+
toolName?: string;
|
|
35
|
+
tool?: {
|
|
36
|
+
name?: string;
|
|
37
|
+
input?: unknown;
|
|
38
|
+
};
|
|
39
|
+
input?: unknown;
|
|
40
|
+
raw?: Record<string, unknown>;
|
|
41
|
+
options?: Array<{
|
|
42
|
+
optionId?: string;
|
|
43
|
+
id?: string;
|
|
44
|
+
name?: string;
|
|
45
|
+
label?: string;
|
|
46
|
+
kind?: string;
|
|
47
|
+
}>;
|
|
48
|
+
__source?: AgentEventSource;
|
|
49
|
+
[key: string]: unknown;
|
|
50
|
+
};
|
|
51
|
+
export type AcpPermissionDecision = {
|
|
52
|
+
outcome: "allow_once" | "allow_always" | "reject_once" | "reject_always" | "cancel";
|
|
53
|
+
};
|
|
54
|
+
export declare function mapAcpRuntimeEvent(event: AcpRuntimeEventLike): AgentEvent | null;
|
|
55
|
+
export declare function mapAcpPermissionRequest(request: AcpPermissionRequestLike): ApprovalRequest;
|
|
56
|
+
export declare function mapApprovalOptionToAcpDecision(optionId: string): AcpPermissionDecision;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { isEmptyToolInput, isGenericToolName, toolNameFromInput, } from "../../chat/chat-tool-identity";
|
|
2
|
+
import { DEFAULT_APPROVAL_OPTIONS, } from "../../core/types";
|
|
3
|
+
export function mapAcpRuntimeEvent(event) {
|
|
4
|
+
if (event.type === "text_delta") {
|
|
5
|
+
if (event.stream === "thought") {
|
|
6
|
+
return withSource(event, {
|
|
7
|
+
type: "thinking",
|
|
8
|
+
text: event.text ?? "",
|
|
9
|
+
kind: "reasoning",
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return withSource(event, { type: "text", text: event.text ?? "" });
|
|
13
|
+
}
|
|
14
|
+
if (event.type === "available_commands_update") {
|
|
15
|
+
return withSource(event, {
|
|
16
|
+
type: "commands.update",
|
|
17
|
+
commands: nativeCommandsFromAcp(event),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (event.type === "status") {
|
|
21
|
+
const usage = usageFromAcpStatus(event);
|
|
22
|
+
if (usage)
|
|
23
|
+
return withSource(event, { type: "usage", usage });
|
|
24
|
+
if (event.commands) {
|
|
25
|
+
return withSource(event, {
|
|
26
|
+
type: "commands.update",
|
|
27
|
+
commands: nativeCommandsFromAcp(event),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return withSource(event, {
|
|
31
|
+
type: "status",
|
|
32
|
+
status: event.text ?? event.status ?? "status",
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (event.type === "tool_call") {
|
|
36
|
+
const id = event.toolCallId ?? event.title ?? "acp-tool";
|
|
37
|
+
const name = acpToolName(event);
|
|
38
|
+
if (event.status === "completed" || event.status === "failed") {
|
|
39
|
+
return withSource(event, {
|
|
40
|
+
type: "tool.end",
|
|
41
|
+
id,
|
|
42
|
+
name,
|
|
43
|
+
input: acpToolInput(event),
|
|
44
|
+
output: event.rawOutput ?? event.content ?? event.text,
|
|
45
|
+
error: event.status === "failed"
|
|
46
|
+
? (event.rawOutput ?? event.content ?? event.text)
|
|
47
|
+
: undefined,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return withSource(event, {
|
|
51
|
+
type: "tool.start",
|
|
52
|
+
id,
|
|
53
|
+
name,
|
|
54
|
+
input: acpToolInput(event),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (event.type === "done") {
|
|
58
|
+
return withSource(event, {
|
|
59
|
+
type: "completed",
|
|
60
|
+
result: { stopReason: event.stopReason },
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
if (event.type === "error") {
|
|
64
|
+
return withSource(event, {
|
|
65
|
+
type: "error",
|
|
66
|
+
error: new Error(event.message ?? "ACP runtime error"),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
function withSource(event, mapped) {
|
|
72
|
+
return event.__source ? { ...mapped, source: { ...event.__source } } : mapped;
|
|
73
|
+
}
|
|
74
|
+
function usageFromAcpStatus(event) {
|
|
75
|
+
if (event.tag === "usage_update" &&
|
|
76
|
+
isFiniteNonNegative(event.used) &&
|
|
77
|
+
isFinitePositive(event.size)) {
|
|
78
|
+
return { used: event.used, limit: event.size };
|
|
79
|
+
}
|
|
80
|
+
const match = event.text?.match(/^usage updated:\s*([\d,]+)\s*\/\s*([\d,]+)$/i);
|
|
81
|
+
if (!match)
|
|
82
|
+
return null;
|
|
83
|
+
const used = Number(match[1]?.replaceAll(",", ""));
|
|
84
|
+
const limit = Number(match[2]?.replaceAll(",", ""));
|
|
85
|
+
return isFiniteNonNegative(used) && isFinitePositive(limit)
|
|
86
|
+
? { used, limit }
|
|
87
|
+
: null;
|
|
88
|
+
}
|
|
89
|
+
function nativeCommandsFromAcp(event) {
|
|
90
|
+
return (event.commands ?? [])
|
|
91
|
+
.map((command) => ({
|
|
92
|
+
name: (command.name ?? "").trim(),
|
|
93
|
+
description: command.description,
|
|
94
|
+
argumentHint: command.argumentHint ?? command.hint,
|
|
95
|
+
}))
|
|
96
|
+
.filter((command) => command.name.length > 0);
|
|
97
|
+
}
|
|
98
|
+
function isFiniteNonNegative(value) {
|
|
99
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
100
|
+
}
|
|
101
|
+
function isFinitePositive(value) {
|
|
102
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
103
|
+
}
|
|
104
|
+
export function mapAcpPermissionRequest(request) {
|
|
105
|
+
const raw = isRecord(request.raw) ? request.raw : {};
|
|
106
|
+
const toolCall = isRecord(raw.toolCall) ? raw.toolCall : {};
|
|
107
|
+
const id = String(request.requestId ??
|
|
108
|
+
request.id ??
|
|
109
|
+
toolCall.toolCallId ??
|
|
110
|
+
raw.toolCallId ??
|
|
111
|
+
cryptoRandomId());
|
|
112
|
+
const options = mapApprovalOptions(request.options ??
|
|
113
|
+
(Array.isArray(raw.options)
|
|
114
|
+
? raw.options
|
|
115
|
+
: undefined));
|
|
116
|
+
const toolName = request.tool?.name ??
|
|
117
|
+
request.toolName ??
|
|
118
|
+
stringValue(toolCall.title) ??
|
|
119
|
+
stringValue(toolCall.kind);
|
|
120
|
+
const input = request.tool?.input ?? request.input ?? toolCall.rawInput;
|
|
121
|
+
return {
|
|
122
|
+
id,
|
|
123
|
+
origin: "runtime",
|
|
124
|
+
kind: mapApprovalKind(request.kind ?? request.inferredKind ?? stringValue(toolCall.kind)),
|
|
125
|
+
title: request.title ??
|
|
126
|
+
stringValue(toolCall.title) ??
|
|
127
|
+
(toolName ? `Allow ${toolName}?` : "Allow this agent action?"),
|
|
128
|
+
tool: toolName
|
|
129
|
+
? {
|
|
130
|
+
name: String(toolName),
|
|
131
|
+
input,
|
|
132
|
+
}
|
|
133
|
+
: undefined,
|
|
134
|
+
options: options.length > 0 ? options : DEFAULT_APPROVAL_OPTIONS,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
export function mapApprovalOptionToAcpDecision(optionId) {
|
|
138
|
+
switch (optionId) {
|
|
139
|
+
case "allow-always":
|
|
140
|
+
case "allow_always":
|
|
141
|
+
return { outcome: "allow_always" };
|
|
142
|
+
case "deny-once":
|
|
143
|
+
case "deny_once":
|
|
144
|
+
case "reject-once":
|
|
145
|
+
case "reject_once":
|
|
146
|
+
return { outcome: "reject_once" };
|
|
147
|
+
case "deny-always":
|
|
148
|
+
case "deny_always":
|
|
149
|
+
case "reject-always":
|
|
150
|
+
case "reject_always":
|
|
151
|
+
return { outcome: "reject_always" };
|
|
152
|
+
case "cancel":
|
|
153
|
+
return { outcome: "cancel" };
|
|
154
|
+
default:
|
|
155
|
+
return { outcome: "allow_once" };
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function acpToolName(event) {
|
|
159
|
+
const title = stringValue(event.title);
|
|
160
|
+
if (title && !isGenericToolName(title))
|
|
161
|
+
return title;
|
|
162
|
+
return (toolNameFromInput(event.rawInput) ?? stringValue(event.kind) ?? "acp_tool");
|
|
163
|
+
}
|
|
164
|
+
function acpToolInput(event) {
|
|
165
|
+
if (!isEmptyToolInput(event.rawInput))
|
|
166
|
+
return event.rawInput;
|
|
167
|
+
if (Array.isArray(event.locations) && event.locations.length > 0) {
|
|
168
|
+
return { locations: event.locations };
|
|
169
|
+
}
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
function isRecord(value) {
|
|
173
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
174
|
+
}
|
|
175
|
+
function stringValue(value) {
|
|
176
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
177
|
+
}
|
|
178
|
+
function mapApprovalOptions(options) {
|
|
179
|
+
if (!options?.length)
|
|
180
|
+
return [];
|
|
181
|
+
return options.map((option, index) => {
|
|
182
|
+
const id = String(option.optionId ?? option.id ?? `option-${index}`);
|
|
183
|
+
const kind = normalizeOptionKind(option.kind ?? id);
|
|
184
|
+
return {
|
|
185
|
+
id,
|
|
186
|
+
label: option.label ?? option.name ?? labelForKind(kind),
|
|
187
|
+
kind,
|
|
188
|
+
};
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function mapApprovalKind(kind) {
|
|
192
|
+
if (kind === "read" || kind === "search")
|
|
193
|
+
return "read";
|
|
194
|
+
if (kind === "write" ||
|
|
195
|
+
kind === "edit" ||
|
|
196
|
+
kind === "delete" ||
|
|
197
|
+
kind === "move") {
|
|
198
|
+
return "write";
|
|
199
|
+
}
|
|
200
|
+
if (kind === "execute")
|
|
201
|
+
return "execute";
|
|
202
|
+
if (kind === "network" || kind === "fetch")
|
|
203
|
+
return "network";
|
|
204
|
+
return "other";
|
|
205
|
+
}
|
|
206
|
+
function normalizeOptionKind(value) {
|
|
207
|
+
const normalized = value.replaceAll("_", "-");
|
|
208
|
+
if (normalized === "allow-once" ||
|
|
209
|
+
normalized === "allow-always" ||
|
|
210
|
+
normalized === "deny-once" ||
|
|
211
|
+
normalized === "deny-always") {
|
|
212
|
+
return normalized;
|
|
213
|
+
}
|
|
214
|
+
if (normalized.includes("always") && normalized.includes("deny")) {
|
|
215
|
+
return "deny-always";
|
|
216
|
+
}
|
|
217
|
+
if (normalized.includes("always"))
|
|
218
|
+
return "allow-always";
|
|
219
|
+
if (normalized.includes("deny"))
|
|
220
|
+
return "deny-once";
|
|
221
|
+
return "allow-once";
|
|
222
|
+
}
|
|
223
|
+
function labelForKind(kind) {
|
|
224
|
+
switch (kind) {
|
|
225
|
+
case "allow-always":
|
|
226
|
+
return "Allow always";
|
|
227
|
+
case "deny-once":
|
|
228
|
+
return "Deny once";
|
|
229
|
+
case "deny-always":
|
|
230
|
+
return "Deny always";
|
|
231
|
+
default:
|
|
232
|
+
return "Allow once";
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function cryptoRandomId() {
|
|
236
|
+
return `acp-${Math.random().toString(36).slice(2, 10)}`;
|
|
237
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type AgentCapabilities, type AgentEvent, type AgentRequest, type AgentRuntime, type AgentSession, type AgentSessionConfiguration, type AgentSessionConfigurationResult, type AgentTurnOptions } from "../../core/types";
|
|
2
|
+
import { type AcpPermissionDecision, type AcpPermissionRequestLike, type AcpRuntimeEventLike } from "./acp-event-mapper";
|
|
3
|
+
import type { SkillActivation } from "../../skills/types";
|
|
4
|
+
export type AcpBackendSession = {
|
|
5
|
+
id: string;
|
|
6
|
+
events(): AsyncIterable<AcpRuntimeEventLike>;
|
|
7
|
+
prompt(text: string): Promise<void>;
|
|
8
|
+
configure?(input: AgentSessionConfiguration): Promise<AgentSessionConfigurationResult>;
|
|
9
|
+
cancel(): Promise<void>;
|
|
10
|
+
detach?(): Promise<void>;
|
|
11
|
+
close(): Promise<void>;
|
|
12
|
+
};
|
|
13
|
+
export type AcpRuntimeBackend = {
|
|
14
|
+
available(): Promise<boolean>;
|
|
15
|
+
start(input: {
|
|
16
|
+
request: AgentRequest;
|
|
17
|
+
onPermissionRequest(request: AcpPermissionRequestLike): Promise<AcpPermissionDecision>;
|
|
18
|
+
}): Promise<AcpBackendSession>;
|
|
19
|
+
resume?(input: {
|
|
20
|
+
sessionId: string;
|
|
21
|
+
request?: Omit<AgentRequest, "prompt">;
|
|
22
|
+
onPermissionRequest(request: AcpPermissionRequestLike): Promise<AcpPermissionDecision>;
|
|
23
|
+
}): Promise<AcpBackendSession>;
|
|
24
|
+
};
|
|
25
|
+
export declare class AcpAgentSession implements AgentSession {
|
|
26
|
+
#private;
|
|
27
|
+
readonly id: string;
|
|
28
|
+
constructor(backend: AcpBackendSession, activations?: readonly SkillActivation[]);
|
|
29
|
+
events(): AsyncIterable<AgentEvent>;
|
|
30
|
+
send(input: string, options?: AgentTurnOptions): Promise<void>;
|
|
31
|
+
configure(input: AgentSessionConfiguration): Promise<AgentSessionConfigurationResult>;
|
|
32
|
+
respondToApproval(requestId: string, optionId: string): Promise<void>;
|
|
33
|
+
cancel(): Promise<void>;
|
|
34
|
+
detach(): Promise<void>;
|
|
35
|
+
close(): Promise<void>;
|
|
36
|
+
handlePermissionRequest(request: AcpPermissionRequestLike): Promise<AcpPermissionDecision>;
|
|
37
|
+
}
|
|
38
|
+
export declare class AcpAgentRuntime implements AgentRuntime {
|
|
39
|
+
#private;
|
|
40
|
+
readonly id = "acp";
|
|
41
|
+
constructor(backend: AcpRuntimeBackend);
|
|
42
|
+
capabilities(): AgentCapabilities;
|
|
43
|
+
supports(request: AgentRequest): Promise<boolean>;
|
|
44
|
+
start(request: AgentRequest): Promise<AgentSession>;
|
|
45
|
+
resume(sessionId: string, request?: Omit<AgentRequest, "prompt">): Promise<AgentSession>;
|
|
46
|
+
}
|