@ai-ecoverse/slicc-agent 3.27.1 → 3.29.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.
Files changed (61) hide show
  1. package/README.md +46 -4
  2. package/dist/codemode/index.js +10 -4
  3. package/dist/codemode/index.js.map +2 -2
  4. package/dist/control.js +33 -30
  5. package/dist/control.js.map +2 -2
  6. package/dist/host.js +1 -0
  7. package/dist/host.js.map +2 -2
  8. package/dist/main.js +21 -2
  9. package/dist/main.js.map +2 -2
  10. package/dist/mcp/allow.js +39 -0
  11. package/dist/mcp/allow.js.map +7 -0
  12. package/dist/mcp/catalog.js +182 -0
  13. package/dist/mcp/catalog.js.map +7 -0
  14. package/dist/mcp/config.js +201 -0
  15. package/dist/mcp/config.js.map +7 -0
  16. package/dist/mcp/connection.js +296 -0
  17. package/dist/mcp/connection.js.map +7 -0
  18. package/dist/mcp/content.js +139 -0
  19. package/dist/mcp/content.js.map +7 -0
  20. package/dist/mcp/credentials.js +45 -0
  21. package/dist/mcp/credentials.js.map +7 -0
  22. package/dist/mcp/index.js +54 -0
  23. package/dist/mcp/index.js.map +7 -0
  24. package/dist/mcp/runtime.js +209 -0
  25. package/dist/mcp/runtime.js.map +7 -0
  26. package/dist/mcp/section.js +35 -0
  27. package/dist/mcp/section.js.map +7 -0
  28. package/dist/mcp/sse.js +112 -0
  29. package/dist/mcp/sse.js.map +7 -0
  30. package/dist/mcp/tools.js +413 -0
  31. package/dist/mcp/tools.js.map +7 -0
  32. package/dist/patches.js +2 -0
  33. package/dist/patches.js.map +2 -2
  34. package/dist/roles/roles.js +10 -1
  35. package/dist/roles/roles.js.map +2 -2
  36. package/dist/scoops/index.js +2 -1
  37. package/dist/scoops/index.js.map +2 -2
  38. package/dist/scoops/service.js +21 -6
  39. package/dist/scoops/service.js.map +2 -2
  40. package/dist/services.js.map +2 -2
  41. package/dist/spectrum/agent-port.js +5 -3
  42. package/dist/spectrum/agent-port.js.map +2 -2
  43. package/dist/types/codemode/index.d.ts +8 -3
  44. package/dist/types/host.d.ts +2 -0
  45. package/dist/types/mcp/allow.d.ts +12 -0
  46. package/dist/types/mcp/catalog.d.ts +29 -0
  47. package/dist/types/mcp/config.d.ts +35 -0
  48. package/dist/types/mcp/connection.d.ts +57 -0
  49. package/dist/types/mcp/content.d.ts +27 -0
  50. package/dist/types/mcp/credentials.d.ts +15 -0
  51. package/dist/types/mcp/index.d.ts +16 -0
  52. package/dist/types/mcp/runtime.d.ts +42 -0
  53. package/dist/types/mcp/section.d.ts +7 -0
  54. package/dist/types/mcp/sse.d.ts +16 -0
  55. package/dist/types/mcp/tools.d.ts +44 -0
  56. package/dist/types/patches.d.ts +1 -0
  57. package/dist/types/scoops/index.d.ts +1 -0
  58. package/dist/types/scoops/service.d.ts +1 -0
  59. package/dist/types/services.d.ts +2 -0
  60. package/dist/types/spectrum/agent-port.d.ts +1 -1
  61. package/package.json +6 -5
@@ -0,0 +1,57 @@
1
+ import { type CallToolResult, type ListResourcesResult, type ListResourceTemplatesResult, McpClient, type McpRequestOptions, type Tool as McpTool, type McpTransport, type ReadResourceResult, type Resource, type ResourceTemplate } from '@earendil-works/pi-mcp';
2
+ import { type McpServerEntry } from './config.ts';
3
+ export type ServerState = 'connecting' | 'connected' | 'needs-auth' | 'needs-secret' | 'failed' | 'closed';
4
+ export type TransportFactory = (entry: McpServerEntry) => Promise<{
5
+ transport: McpTransport;
6
+ secrets: string[];
7
+ } | {
8
+ missing: string[];
9
+ }>;
10
+ export declare const CONNECT_RETRY_DELAYS_MS: number[];
11
+ export declare const CLIENT_NAME = "slicc";
12
+ export declare function errorMessage(error: unknown): string;
13
+ export declare function isTransient(error: unknown): boolean;
14
+ export declare function isMcpApp(item: {
15
+ uri?: string;
16
+ uriTemplate?: string;
17
+ mimeType?: string;
18
+ }): boolean;
19
+ export interface ConnectionOptions {
20
+ entry: McpServerEntry;
21
+ version: string;
22
+ transport: TransportFactory;
23
+ onTools: (connection: McpServerConnection) => void;
24
+ onChange?: (connection: McpServerConnection) => void;
25
+ onLog?: (connection: McpServerConnection, params: unknown) => void;
26
+ }
27
+ export declare class McpServerConnection {
28
+ #private;
29
+ readonly entry: McpServerEntry;
30
+ state: ServerState;
31
+ error: string | undefined;
32
+ missing: string[];
33
+ tools: McpTool[];
34
+ hasResources: boolean;
35
+ resources: Resource[];
36
+ resourceTemplates: ResourceTemplate[];
37
+ instructions: string | undefined;
38
+ secrets: string[];
39
+ constructor(options: ConnectionOptions);
40
+ get name(): string;
41
+ get timeoutMs(): number;
42
+ get live(): boolean;
43
+ get closed(): boolean;
44
+ getClient(): Promise<McpClient>;
45
+ callTool(name: string, args: Record<string, unknown>, options: McpRequestOptions): Promise<CallToolResult>;
46
+ readResource(uri: string, options: McpRequestOptions): Promise<ReadResourceResult>;
47
+ resourcesPage(cursor: string | undefined, options: McpRequestOptions): Promise<ListResourcesResult>;
48
+ resourceTemplatesPage(cursor: string | undefined, options: McpRequestOptions): Promise<ListResourceTemplatesResult>;
49
+ allResources(options: McpRequestOptions): Promise<Resource[]>;
50
+ allResourceTemplates(options: McpRequestOptions): Promise<ResourceTemplate[]>;
51
+ signInMessage(): string;
52
+ close(): Promise<void>;
53
+ }
54
+ export declare class MissingSecret extends Error {
55
+ readonly names: string[];
56
+ constructor(names: string[]);
57
+ }
@@ -0,0 +1,27 @@
1
+ import type { Context } from '@earendil-works/chord';
2
+ import type { ImageContent, TextContent } from '@earendil-works/pi-ai';
3
+ import { type CallToolResult, type ContentBlock } from '@earendil-works/pi-mcp';
4
+ export declare const MCP_OUTPUT_MAX_BYTES: number;
5
+ export declare const READ_MCP_RESOURCE = "read_mcp_resource";
6
+ export type Content = TextContent | ImageContent;
7
+ export type Saver = (data: string | Uint8Array, extension: string) => Promise<string>;
8
+ export interface Truncation {
9
+ content: string;
10
+ truncated: boolean;
11
+ totalBytes: number;
12
+ totalLines: number;
13
+ }
14
+ export declare function formatSize(bytes: number): string;
15
+ export declare function truncateMiddle(content: string, maxBytes: number): Truncation;
16
+ export declare function limitContent(content: Content[], save: Saver): Promise<{
17
+ content: Content[];
18
+ fullOutputPath?: string;
19
+ }>;
20
+ export declare function modelContent(server: string, blocks: readonly ContentBlock[], save: Saver, readable?: boolean): Promise<Content[]>;
21
+ export declare function convertResult(server: string, tool: string, result: CallToolResult, save: Saver, readable?: boolean): Promise<{
22
+ content: Content[];
23
+ isError: boolean;
24
+ fullOutputPath?: string;
25
+ }>;
26
+ export declare function scriptResult(result: CallToolResult): Record<string, unknown>;
27
+ export declare function spiller(write: (path: string, data: string | Uint8Array, context: Context) => Promise<boolean>, id: () => string, context: Context): Saver;
@@ -0,0 +1,15 @@
1
+ import type { CredentialStore } from '@earendil-works/pi-ai';
2
+ import { type McpServerConfig } from './config.ts';
3
+ export declare const MCP_CREDENTIAL_PREFIX = "mcp:";
4
+ export declare function credentialKey(server: string, url: string): Promise<string>;
5
+ export declare function secretNames(config: McpServerConfig): string[];
6
+ export type Resolved = {
7
+ ok: true;
8
+ headers: Record<string, string>;
9
+ secrets: string[];
10
+ } | {
11
+ ok: false;
12
+ missing: string[];
13
+ };
14
+ export declare function resolveHeaders(server: string, config: McpServerConfig, credentials: CredentialStore): Promise<Resolved>;
15
+ export declare function scrub(text: string, secrets: readonly string[]): string;
@@ -0,0 +1,16 @@
1
+ import type { Context } from '@earendil-works/chord';
2
+ import type { Agent, Registry, ToolExecutionApi, ToolRegistration } from '@earendil-works/pi-durable';
3
+ import type { CodemodeExtra } from './allow.ts';
4
+ import type { McpCatalog } from './catalog.ts';
5
+ import type { McpAttach, McpRuntime } from './runtime.ts';
6
+ export { allows, type CodemodeExtra, McpAllowDoc, mcpEntries, serverAllowed } from './allow.ts';
7
+ export type { McpAttach, McpRuntime, ServerStatus } from './runtime.ts';
8
+ export type McpLoader = () => Promise<typeof import('./runtime.ts')>;
9
+ export declare const loadRuntime: McpLoader;
10
+ export interface McpSetup {
11
+ catalog(): McpCatalog | undefined;
12
+ direct(names: readonly string[]): ToolRegistration[];
13
+ codemode(api: ToolExecutionApi, agent: Agent, context: Context): Promise<CodemodeExtra>;
14
+ attach(options: McpAttach, context: Context): Promise<McpRuntime>;
15
+ }
16
+ export declare function setupMcp(registry: Registry, load?: McpLoader): McpSetup;
@@ -0,0 +1,42 @@
1
+ import type { Context } from '@earendil-works/chord';
2
+ import type { CredentialStore } from '@earendil-works/pi-ai';
3
+ import type { Registry } from '@earendil-works/pi-durable';
4
+ import type { ExecutionEnv } from '@earendil-works/pi-durable/env';
5
+ import type { LickEvent, Licks } from '../licks/licks.ts';
6
+ import { McpCatalog } from './catalog.ts';
7
+ import { type McpConfigProblem } from './config.ts';
8
+ import { McpServerConnection } from './connection.ts';
9
+ export declare const MCP_LOG_MAX_BYTES: number;
10
+ export declare function configPath(home: string): string;
11
+ export declare function logPath(home: string): string;
12
+ export interface McpAttach {
13
+ licks: Licks;
14
+ env: ExecutionEnv;
15
+ home: string;
16
+ credentials: CredentialStore;
17
+ fetch: typeof fetch;
18
+ version: string;
19
+ reloadMs: number;
20
+ codemode: boolean;
21
+ cors: boolean;
22
+ }
23
+ export interface ServerStatus {
24
+ name: string;
25
+ state: string;
26
+ tools: number;
27
+ error?: string;
28
+ }
29
+ export interface McpRuntime {
30
+ status(): ServerStatus[];
31
+ reload(context: Context): Promise<void>;
32
+ close(context: Context): Promise<void>;
33
+ }
34
+ export declare function problemLick(problem: McpConfigProblem, home: string): LickEvent;
35
+ export declare function stateLick(connection: McpServerConnection, cors: boolean): LickEvent | undefined;
36
+ export declare function connectedLick(connection: McpServerConnection): LickEvent;
37
+ export declare function logLine(server: string, params: unknown, secrets: readonly string[], at: Date): string;
38
+ export declare function attachMcp(catalog: McpCatalog, options: McpAttach, context: Context): Promise<McpRuntime>;
39
+ export declare function startMcp(registry: Registry, options: McpAttach, context: Context): Promise<{
40
+ catalog: McpCatalog;
41
+ runtime: McpRuntime;
42
+ }>;
@@ -0,0 +1,7 @@
1
+ export interface Listing {
2
+ name: string;
3
+ description?: string;
4
+ instructions?: string;
5
+ }
6
+ export declare const SECTION_INTRO: string;
7
+ export declare function renderSection(listed: readonly Listing[]): string | undefined;
@@ -0,0 +1,16 @@
1
+ export interface SseEvent {
2
+ event?: string;
3
+ data: string;
4
+ id?: string;
5
+ }
6
+ export interface SseOptions {
7
+ maxEventBytes?: number;
8
+ onEvent(event: SseEvent): void;
9
+ onId?(id: string): void;
10
+ onRetry?(ms: number): void;
11
+ }
12
+ export declare function sseField(raw: string): [string, string] | undefined;
13
+ export declare function readSse(stream: ReadableStream<Uint8Array>, options: SseOptions): Promise<void>;
14
+ export declare function patchSse(target?: {
15
+ prototype: object;
16
+ }): void;
@@ -0,0 +1,44 @@
1
+ import type { Context } from '@earendil-works/chord';
2
+ import { type CodemodeJsonSchema, type CodemodeTool } from '@earendil-works/pi-codemode';
3
+ import { type ToolExecutionApi, type ToolRegistration } from '@earendil-works/pi-durable';
4
+ import type { Tool as McpTool } from '@earendil-works/pi-mcp';
5
+ import type { McpExposure } from './config.ts';
6
+ import { type McpServerConnection } from './connection.ts';
7
+ import { READ_MCP_RESOURCE, type Saver } from './content.ts';
8
+ export declare const LIST_MCP_RESOURCES = "list_mcp_resources";
9
+ export declare const LIST_MCP_RESOURCE_TEMPLATES = "list_mcp_resource_templates";
10
+ export { READ_MCP_RESOURCE };
11
+ export interface McpToolEntry {
12
+ server: string;
13
+ name: string;
14
+ exposure: McpExposure;
15
+ tool: McpTool;
16
+ connection: McpServerConnection;
17
+ }
18
+ export type McpDetails = {
19
+ server: string;
20
+ tool: string;
21
+ fullOutputPath?: string;
22
+ };
23
+ export declare function resultSchema(structured: Record<string, unknown> | undefined): CodemodeJsonSchema;
24
+ export declare function apiSaver(api: ToolExecutionApi, prefix: string, context: Context): Saver;
25
+ export declare function directTool(entry: McpToolEntry, readable: () => boolean): ToolRegistration;
26
+ export declare function scriptTool(entry: McpToolEntry, signal: AbortSignal | undefined): CodemodeTool;
27
+ export interface ResourceServer {
28
+ name: string;
29
+ connection: McpServerConnection;
30
+ }
31
+ export type ServersFor = (api: ToolExecutionApi, context: Context) => Promise<readonly ResourceServer[]>;
32
+ export declare function resourceTools(servers: ServersFor): ToolRegistration[];
33
+ export declare function resourceScriptTools(servers: () => readonly ResourceServer[], signal: AbortSignal | undefined, save: Saver): CodemodeTool[];
34
+ export interface Namespace {
35
+ name: string;
36
+ description?: string;
37
+ instructions?: string;
38
+ }
39
+ export declare function rank(query: string, documents: readonly {
40
+ name: string;
41
+ text: string;
42
+ }[], limit: number): string[];
43
+ export declare const DEFAULT_SEARCH_LIMIT = 8;
44
+ export declare function discoveryGlobals(tools: readonly CodemodeTool[], namespaceOf: (tool: string) => Namespace | undefined): CodemodeTool[];
@@ -1,4 +1,5 @@
1
1
  declare const applied: unique symbol;
2
+ export declare const MCP_SSE_PATCH = "pi-mcp-sse-buffer";
2
3
  interface Patchable {
3
4
  prototype: {
4
5
  accept: (...args: unknown[]) => unknown;
@@ -28,6 +28,7 @@ export interface AttachOptions {
28
28
  memory?: CliOptions['memory'];
29
29
  gelatiere?: CliOptions['gelatiere'];
30
30
  freezer?: CliOptions['freezer'];
31
+ mcp?: (names: readonly string[]) => ToolRegistration[];
31
32
  }
32
33
  export interface ScoopsRuntime {
33
34
  roles(context: Context): Promise<Roles>;
@@ -49,6 +49,7 @@ export interface ScoopsHost {
49
49
  tools?: readonly ToolRegistration[];
50
50
  reads?: () => readonly string[];
51
51
  files?: Pick<ExecutionEnv, 'remove' | 'createDir'>;
52
+ mcp?: (names: readonly string[]) => ToolRegistration[];
52
53
  }
53
54
  export interface Rewound {
54
55
  stopped: string[];
@@ -41,11 +41,13 @@ export interface AgentControl {
41
41
  }>;
42
42
  abort(context: Context): Promise<void>;
43
43
  compact(instructions: string | null, context: Context): Promise<SendResponse>;
44
+ compactAgent(agentId: string, instructions: string | null, context: Context): Promise<SendResponse>;
44
45
  reset(handoff: string | null, context: Context): Promise<void>;
45
46
  configure(change: AgentSettingsChange, context: Context): Promise<void>;
46
47
  rewind(messageId: string | null, context: Context): Promise<Rewound>;
47
48
  rewindAgent(agentId: string, messageId: string | null, context: Context): Promise<Rewound>;
48
49
  resolveLick(lickId: string, state: 'confirmed' | 'dismissed', context: Context): Promise<LickResolved>;
50
+ resolveAgentLick(agentId: string, lickId: string, state: 'confirmed' | 'dismissed', context: Context): Promise<LickResolved>;
49
51
  webhook(name: string, delivery: WebhookRequest, context: Context): Promise<{
50
52
  delivered: boolean;
51
53
  }>;
@@ -19,7 +19,7 @@ export declare class AgentAdapter extends Emitter<AgentEvents> implements AgentP
19
19
  suggestion(): string | null;
20
20
  answer(): void;
21
21
  resolveLick(agentId: string, messageId: string, state: 'confirmed' | 'dismissed'): void;
22
- compact(): void;
22
+ compact(agentId?: string): void;
23
23
  clear(agentId?: string): void;
24
24
  freeze(agentId?: string): void;
25
25
  setModel(agentId: string, model: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-agent",
3
- "version": "3.27.1",
3
+ "version": "3.29.0",
4
4
  "description": "SLICC's agent core on pi durable: an agent worker, session storage, remoting and pi extensions",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -62,11 +62,11 @@
62
62
  },
63
63
  "devDependencies": {
64
64
  "@ai-ecoverse/slicc-kernel": "1.26.3",
65
- "@ai-ecoverse/slicc-shared-web": "1.11.0",
66
- "@ai-ecoverse/slicc-spectrum": "1.44.0",
67
- "@ai-ecoverse/wasm-bash": "5.3.0-10",
65
+ "@ai-ecoverse/slicc-shared-web": "1.12.0",
66
+ "@ai-ecoverse/slicc-spectrum": "1.46.0",
67
+ "@ai-ecoverse/wasm-bash": "5.3.0-11",
68
68
  "@ai-ecoverse/wasm-coreutils": "9.7.0-3",
69
- "@ai-ecoverse/wasm-git": "2.55.0-11",
69
+ "@ai-ecoverse/wasm-git": "2.55.0-12",
70
70
  "@biomejs/biome": "2.5.15",
71
71
  "@types/node": "24.19.1",
72
72
  "esbuild": "0.28.2",
@@ -83,6 +83,7 @@
83
83
  "@earendil-works/pi-client": "1.0.4",
84
84
  "@earendil-works/pi-codemode": "1.1.0",
85
85
  "@earendil-works/pi-durable": "1.0.4",
86
+ "@earendil-works/pi-mcp": "1.1.0",
86
87
  "@earendil-works/pi-protocol": "1.0.4",
87
88
  "@earendil-works/pi-server": "1.0.4",
88
89
  "@sqlite.org/sqlite-wasm": "3.53.4-build2"