@ai-ecoverse/slicc-agent 3.34.0 → 3.36.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/README.md +22 -3
- package/dist/host.js +2 -0
- package/dist/host.js.map +2 -2
- package/dist/index.js +14 -1
- package/dist/index.js.map +2 -2
- package/dist/kernel/users.js +113 -0
- package/dist/kernel/users.js.map +7 -0
- package/dist/main.js +34 -9
- package/dist/main.js.map +2 -2
- package/dist/mcp/accounts.js +79 -0
- package/dist/mcp/accounts.js.map +7 -0
- package/dist/mcp/config.js +40 -5
- package/dist/mcp/config.js.map +2 -2
- package/dist/mcp/connection.js +11 -5
- package/dist/mcp/connection.js.map +2 -2
- package/dist/mcp/index.js +3 -0
- package/dist/mcp/index.js.map +2 -2
- package/dist/mcp/oauth.js +260 -0
- package/dist/mcp/oauth.js.map +7 -0
- package/dist/mcp/runtime.js +25 -60
- package/dist/mcp/runtime.js.map +2 -2
- package/dist/oauth/mcp-callback.html +109 -0
- package/dist/owner.js +19 -2
- package/dist/owner.js.map +2 -2
- package/dist/scoops/index.js +28 -8
- package/dist/scoops/index.js.map +2 -2
- package/dist/services.js.map +2 -2
- package/dist/settings.js +15 -2
- package/dist/settings.js.map +2 -2
- package/dist/spectrum/mcp-login.js +73 -0
- package/dist/spectrum/mcp-login.js.map +7 -0
- package/dist/spectrum/settings-port.js +12 -5
- package/dist/spectrum/settings-port.js.map +2 -2
- package/dist/types/host.d.ts +3 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/kernel/users.d.ts +53 -0
- package/dist/types/main.d.ts +6 -0
- package/dist/types/mcp/accounts.d.ts +20 -0
- package/dist/types/mcp/config.d.ts +8 -0
- package/dist/types/mcp/connection.d.ts +1 -0
- package/dist/types/mcp/oauth.d.ts +57 -0
- package/dist/types/mcp/runtime.d.ts +3 -8
- package/dist/types/owner.d.ts +2 -3
- package/dist/types/scoops/index.d.ts +4 -1
- package/dist/types/services.d.ts +5 -1
- package/dist/types/settings.d.ts +1 -0
- package/dist/types/spectrum/mcp-login.d.ts +26 -0
- package/dist/types/spectrum/settings-port.d.ts +1 -1
- package/dist/types/worker.d.ts +5 -0
- package/dist/worker.js +9 -3
- package/dist/worker.js.map +2 -2
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { PortEndpoint } from '../wire.ts';
|
|
2
|
+
import type { KernelClient } from './client.ts';
|
|
3
|
+
export interface KernelUser {
|
|
4
|
+
name: string;
|
|
5
|
+
uid: number;
|
|
6
|
+
gid: number;
|
|
7
|
+
home: string;
|
|
8
|
+
shell: string;
|
|
9
|
+
groups: number[];
|
|
10
|
+
umask?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface UserSpec {
|
|
13
|
+
name: string;
|
|
14
|
+
home?: string;
|
|
15
|
+
groups?: string[];
|
|
16
|
+
umask?: number;
|
|
17
|
+
homeGroup?: string;
|
|
18
|
+
}
|
|
19
|
+
export interface KernelUsers {
|
|
20
|
+
add(spec: UserSpec): Promise<KernelUser>;
|
|
21
|
+
remove(name: string, options?: {
|
|
22
|
+
keepHome?: boolean;
|
|
23
|
+
}): Promise<boolean>;
|
|
24
|
+
list(): Promise<KernelUser[]>;
|
|
25
|
+
}
|
|
26
|
+
export interface UserConnect {
|
|
27
|
+
user?: string;
|
|
28
|
+
agentId?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface KernelSource {
|
|
31
|
+
connect(options?: UserConnect): Promise<Transferable>;
|
|
32
|
+
users?: KernelUsers;
|
|
33
|
+
}
|
|
34
|
+
export interface KernelAdmin {
|
|
35
|
+
connect(options: UserConnect): Promise<MessagePort>;
|
|
36
|
+
users: KernelUsers;
|
|
37
|
+
close(): void;
|
|
38
|
+
}
|
|
39
|
+
export declare function serveAdmin(port: PortEndpoint, source: KernelSource): void;
|
|
40
|
+
export declare function adminOver(port: PortEndpoint): KernelAdmin;
|
|
41
|
+
export type UserClient = KernelClient & {
|
|
42
|
+
close?(options?: {
|
|
43
|
+
kill?: boolean;
|
|
44
|
+
}): unknown;
|
|
45
|
+
closed?: Promise<unknown>;
|
|
46
|
+
};
|
|
47
|
+
export interface UserClients {
|
|
48
|
+
readonly users: KernelUsers;
|
|
49
|
+
client(agentId: string, user: string): Promise<UserClient>;
|
|
50
|
+
drop(agentId: string): Promise<void>;
|
|
51
|
+
close(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
export declare function userClients(admin: KernelAdmin, attach: (port: MessagePort) => Promise<UserClient>): UserClients;
|
package/dist/types/main.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { CredentialStore, Provider } from '@earendil-works/pi-ai';
|
|
|
2
2
|
import { type ModelRef, type Storage } from '@earendil-works/pi-durable';
|
|
3
3
|
import { type AgentHost } from './host.ts';
|
|
4
4
|
import type { KernelClient } from './kernel/client.ts';
|
|
5
|
+
import { type UserClients } from './kernel/users.ts';
|
|
5
6
|
import { type Transport } from './net.ts';
|
|
6
7
|
import { type Assets } from './scoops/index.ts';
|
|
7
8
|
import { type WorkerScope } from './worker.ts';
|
|
@@ -24,6 +25,11 @@ export interface AgentWorkerOptions {
|
|
|
24
25
|
codemodeWasm?: () => Promise<WebAssembly.Module | undefined>;
|
|
25
26
|
codemodeWorker?: string | URL;
|
|
26
27
|
catalog?: string;
|
|
28
|
+
users?: boolean;
|
|
29
|
+
mcpRedirect?: string;
|
|
27
30
|
}
|
|
31
|
+
export declare function usersOf(admin: MessagePort | undefined, wanted: boolean | undefined, attach: KernelAttach): UserClients | undefined;
|
|
32
|
+
export declare const STORE_DIR = "/.slicc";
|
|
33
|
+
export declare const MCP_CALLBACK = "/oauth/mcp-callback";
|
|
28
34
|
export declare function alive(client: KernelClient): (pid: number) => Promise<boolean>;
|
|
29
35
|
export declare function runAgentWorker(scope: AgentWorkerScope, options?: AgentWorkerOptions): Promise<AgentHost>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CredentialStore } from '@earendil-works/pi-ai';
|
|
2
|
+
import type { McpFetch } from '@earendil-works/pi-mcp';
|
|
3
|
+
import type { AccountState } from '../services.ts';
|
|
4
|
+
import type { McpCatalog } from './catalog.ts';
|
|
5
|
+
import type { McpServerEntry } from './config.ts';
|
|
6
|
+
import type { McpServerConnection } from './connection.ts';
|
|
7
|
+
import { type McpSignIn, type StoredOAuth } from './oauth.ts';
|
|
8
|
+
export interface McpAccounts {
|
|
9
|
+
accounts(): Promise<AccountState[]>;
|
|
10
|
+
signIn(id: string): Promise<McpSignIn>;
|
|
11
|
+
connect(id: string, secret: string): Promise<void>;
|
|
12
|
+
disconnect(id: string): Promise<void>;
|
|
13
|
+
onChange(listener: () => void): () => void;
|
|
14
|
+
}
|
|
15
|
+
export interface AccountSources {
|
|
16
|
+
credentials: CredentialStore;
|
|
17
|
+
oauth: (entry: McpServerEntry) => StoredOAuth;
|
|
18
|
+
fetch: McpFetch;
|
|
19
|
+
}
|
|
20
|
+
export declare function mcpAccounts(catalog: McpCatalog, sources: AccountSources, restart: (connection: McpServerConnection) => void, listeners: Set<() => void>): McpAccounts;
|
|
@@ -7,6 +7,13 @@ export interface McpServerConfig {
|
|
|
7
7
|
enabled?: boolean;
|
|
8
8
|
timeout?: number;
|
|
9
9
|
description?: string;
|
|
10
|
+
oauth?: McpOAuthConfig;
|
|
11
|
+
}
|
|
12
|
+
export interface McpOAuthConfig {
|
|
13
|
+
clientId?: string;
|
|
14
|
+
clientName?: string;
|
|
15
|
+
scope?: string;
|
|
16
|
+
authServerMetadataUrl?: string;
|
|
10
17
|
}
|
|
11
18
|
export interface McpServerEntry {
|
|
12
19
|
name: string;
|
|
@@ -25,6 +32,7 @@ export declare const DEFAULT_TIMEOUT_SECONDS = 60;
|
|
|
25
32
|
export declare function placeholders(value: string): string[];
|
|
26
33
|
export declare function literalSecret(header: string, value: string): boolean;
|
|
27
34
|
type Checked = McpServerConfig | McpConfigProblem;
|
|
35
|
+
export declare function usesOAuth(config: McpServerConfig): boolean;
|
|
28
36
|
export declare function validateServer(name: string, raw: unknown): Checked;
|
|
29
37
|
export declare function parseMcpConfig(text: string | undefined): McpConfig;
|
|
30
38
|
export declare function nameMatcher(entries: readonly string[]): (name: string) => boolean;
|
|
@@ -9,6 +9,7 @@ export type TransportFactory = (entry: McpServerEntry) => Promise<{
|
|
|
9
9
|
}>;
|
|
10
10
|
export declare const CONNECT_RETRY_DELAYS_MS: number[];
|
|
11
11
|
export declare const CLIENT_NAME = "slicc";
|
|
12
|
+
export declare function signInNeeded(error: unknown): boolean;
|
|
12
13
|
export declare function errorMessage(error: unknown): string;
|
|
13
14
|
export declare function isTransient(error: unknown): boolean;
|
|
14
15
|
export declare function isMcpApp(item: {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { CredentialStore } from '@earendil-works/pi-ai';
|
|
2
|
+
import type { AuthProvider, McpFetch } from '@earendil-works/pi-mcp';
|
|
3
|
+
import { authorizeMcp, McpOAuthAuthorizationRequiredError, type McpOAuthState } from '@earendil-works/pi-mcp/oauth';
|
|
4
|
+
import type { McpSignIn } from '../services.ts';
|
|
5
|
+
import type { McpServerConfig } from './config.ts';
|
|
6
|
+
type Provider = Parameters<typeof authorizeMcp>[0];
|
|
7
|
+
type Tokens = Awaited<ReturnType<Provider['tokens']>>;
|
|
8
|
+
type Client = Awaited<ReturnType<Provider['clientInformation']>>;
|
|
9
|
+
type Discovery = NonNullable<McpOAuthState['discovery']>;
|
|
10
|
+
export declare const CLIENT_NAME = "SLICC";
|
|
11
|
+
export declare function secureUrl(url: URL): boolean;
|
|
12
|
+
export declare function signInRequired(cause?: unknown): McpOAuthAuthorizationRequiredError;
|
|
13
|
+
export declare function authProvider(provider: StoredOAuth, server: OAuthServer): AuthProvider;
|
|
14
|
+
export declare function pkce(): Promise<{
|
|
15
|
+
verifier: string;
|
|
16
|
+
challenge: string;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function randomState(): string;
|
|
19
|
+
export interface OAuthServer {
|
|
20
|
+
name: string;
|
|
21
|
+
config: McpServerConfig;
|
|
22
|
+
}
|
|
23
|
+
export declare class StoredOAuth implements Provider {
|
|
24
|
+
#private;
|
|
25
|
+
readonly redirectUrl: string;
|
|
26
|
+
readonly clientMetadata: Provider['clientMetadata'];
|
|
27
|
+
constructor(server: OAuthServer, credentials: CredentialStore, redirectUrl: string);
|
|
28
|
+
get serverUrl(): string;
|
|
29
|
+
load(): Promise<McpOAuthState>;
|
|
30
|
+
update(change: (state: McpOAuthState) => McpOAuthState): Promise<void>;
|
|
31
|
+
signedIn(): Promise<boolean>;
|
|
32
|
+
state(): string;
|
|
33
|
+
clientInformation(): Promise<Client>;
|
|
34
|
+
saveClientInformation(information: NonNullable<Client>): Promise<void>;
|
|
35
|
+
tokens(): Promise<Tokens>;
|
|
36
|
+
saveTokens(tokens: NonNullable<Tokens>): Promise<void>;
|
|
37
|
+
redirectToAuthorization(): void;
|
|
38
|
+
saveCodeVerifier(verifier: string): Promise<void>;
|
|
39
|
+
codeVerifier(): Promise<string>;
|
|
40
|
+
invalidateCredentials(kind: 'all' | 'client' | 'tokens' | 'verifier' | 'discovery'): Promise<void>;
|
|
41
|
+
saveDiscoveryState(discovery: Discovery): Promise<void>;
|
|
42
|
+
discoveryState(): Promise<Discovery | undefined>;
|
|
43
|
+
forget(): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
export type { McpSignIn } from '../services.ts';
|
|
46
|
+
export declare function beginSignIn(provider: StoredOAuth, server: OAuthServer, options: {
|
|
47
|
+
fetch: McpFetch;
|
|
48
|
+
resourceMetadataUrl?: URL;
|
|
49
|
+
}): Promise<McpSignIn>;
|
|
50
|
+
export interface Callback {
|
|
51
|
+
code?: string;
|
|
52
|
+
state?: string;
|
|
53
|
+
iss?: string;
|
|
54
|
+
error?: string;
|
|
55
|
+
error_description?: string;
|
|
56
|
+
}
|
|
57
|
+
export declare function finishSignIn(provider: StoredOAuth, server: OAuthServer, answer: string, fetch: McpFetch): Promise<void>;
|
|
@@ -3,7 +3,7 @@ import type { CredentialStore } from '@earendil-works/pi-ai';
|
|
|
3
3
|
import type { Registry } from '@earendil-works/pi-durable';
|
|
4
4
|
import type { ExecutionEnv } from '@earendil-works/pi-durable/env';
|
|
5
5
|
import type { LickEvent, Licks } from '../licks/licks.ts';
|
|
6
|
-
import type
|
|
6
|
+
import { type McpAccounts } from './accounts.ts';
|
|
7
7
|
import { McpCatalog } from './catalog.ts';
|
|
8
8
|
import { type McpConfigProblem } from './config.ts';
|
|
9
9
|
import { McpServerConnection } from './connection.ts';
|
|
@@ -20,6 +20,7 @@ export interface McpAttach {
|
|
|
20
20
|
reloadMs: number;
|
|
21
21
|
codemode: boolean;
|
|
22
22
|
cors: boolean;
|
|
23
|
+
redirect: string;
|
|
23
24
|
}
|
|
24
25
|
export interface ServerStatus {
|
|
25
26
|
name: string;
|
|
@@ -27,12 +28,7 @@ export interface ServerStatus {
|
|
|
27
28
|
tools: number;
|
|
28
29
|
error?: string;
|
|
29
30
|
}
|
|
30
|
-
export
|
|
31
|
-
accounts(): Promise<AccountState[]>;
|
|
32
|
-
connect(id: string, secret: string): Promise<void>;
|
|
33
|
-
disconnect(id: string): Promise<void>;
|
|
34
|
-
onChange(listener: () => void): () => void;
|
|
35
|
-
}
|
|
31
|
+
export type { McpAccounts } from './accounts.ts';
|
|
36
32
|
export interface McpRuntime extends McpAccounts {
|
|
37
33
|
status(): ServerStatus[];
|
|
38
34
|
reload(context: Context): Promise<void>;
|
|
@@ -42,7 +38,6 @@ export declare function problemLick(problem: McpConfigProblem, home: string): Li
|
|
|
42
38
|
export declare function stateLick(connection: McpServerConnection, cors: boolean): LickEvent | undefined;
|
|
43
39
|
export declare function connectedLick(connection: McpServerConnection): LickEvent;
|
|
44
40
|
export declare function logLine(server: string, params: unknown, secrets: readonly string[], at: Date): string;
|
|
45
|
-
export declare function mcpAccounts(catalog: McpCatalog, credentials: CredentialStore, restart: (connection: McpServerConnection) => void, listeners: Set<() => void>): McpAccounts;
|
|
46
41
|
export declare function attachMcp(catalog: McpCatalog, options: McpAttach, context: Context): Promise<McpRuntime>;
|
|
47
42
|
export declare function startMcp(registry: Registry, options: McpAttach, context: Context): Promise<{
|
|
48
43
|
catalog: McpCatalog;
|
package/dist/types/owner.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type AgentConnection } from './client.ts';
|
|
2
|
+
import { type KernelSource } from './kernel/users.ts';
|
|
2
3
|
import type { PortEndpoint } from './wire.ts';
|
|
3
4
|
export declare const AGENT_LOCK = "slicc-agent";
|
|
4
5
|
export interface AgentWorker {
|
|
@@ -14,9 +15,7 @@ export interface AgentOwner {
|
|
|
14
15
|
restart(): Promise<void>;
|
|
15
16
|
release(): Promise<void>;
|
|
16
17
|
}
|
|
17
|
-
export
|
|
18
|
-
connect(): Promise<Transferable>;
|
|
19
|
-
}
|
|
18
|
+
export type { KernelSource } from './kernel/users.ts';
|
|
20
19
|
export interface OwnerOptions {
|
|
21
20
|
worker: () => AgentWorker;
|
|
22
21
|
kernel?: KernelSource;
|
|
@@ -10,6 +10,7 @@ import { type ControlPlane } from './requests.ts';
|
|
|
10
10
|
import { type Scoops } from './service.ts';
|
|
11
11
|
export declare const BUILTIN_ROLES: string[];
|
|
12
12
|
export declare const PNPM_HOME = "/home/.local/share/pnpm";
|
|
13
|
+
export declare const BIN_DIR = "/usr/local/bin";
|
|
13
14
|
export type Assets = (path: string) => Promise<string>;
|
|
14
15
|
export declare function packageAssets(base?: URL): Assets;
|
|
15
16
|
export interface AttachOptions {
|
|
@@ -19,7 +20,7 @@ export interface AttachOptions {
|
|
|
19
20
|
env: ExecutionEnv;
|
|
20
21
|
home: string;
|
|
21
22
|
assets?: Assets;
|
|
22
|
-
|
|
23
|
+
binDir?: string;
|
|
23
24
|
controlDir?: string;
|
|
24
25
|
sweepEvery?: number;
|
|
25
26
|
alive?: (pid: number) => Promise<boolean>;
|
|
@@ -42,5 +43,7 @@ export interface ScoopsSetup {
|
|
|
42
43
|
}
|
|
43
44
|
export declare const COMMANDS: string[];
|
|
44
45
|
export declare function pnpmHomeOf(env: ExecutionEnv, context: Context): Promise<string>;
|
|
46
|
+
export declare function installCommands(env: ExecutionEnv, script: string, binDir: string, context: Context): Promise<boolean>;
|
|
47
|
+
export declare function retire(env: ExecutionEnv, binDir: string, context: Context): Promise<void>;
|
|
45
48
|
export declare function setupScoops(registry: Registry, licks: Licks, fileTools?: readonly ToolRegistration[]): ScoopsSetup;
|
|
46
49
|
export type { Rewound, Scoops } from './service.ts';
|
package/dist/types/services.d.ts
CHANGED
|
@@ -194,6 +194,10 @@ export interface SignIn {
|
|
|
194
194
|
scopes: string;
|
|
195
195
|
imsEnvironment: string;
|
|
196
196
|
}
|
|
197
|
+
export interface McpSignIn {
|
|
198
|
+
url: string;
|
|
199
|
+
state: string;
|
|
200
|
+
}
|
|
197
201
|
export interface SettingsState {
|
|
198
202
|
models: ModelChoice[];
|
|
199
203
|
accounts: AccountState[];
|
|
@@ -203,6 +207,6 @@ export interface AgentSettings {
|
|
|
203
207
|
readonly state: ReplicatedState<SettingsState>;
|
|
204
208
|
connect(providerId: string, secret: string, region: string | null, context: Context): Promise<void>;
|
|
205
209
|
disconnect(providerId: string, context: Context): Promise<void>;
|
|
206
|
-
signIn(providerId: string, context: Context): Promise<SignIn | null>;
|
|
210
|
+
signIn(providerId: string, context: Context): Promise<SignIn | McpSignIn | null>;
|
|
207
211
|
}
|
|
208
212
|
export declare const AgentSettings: import("@earendil-works/chord").Service<AgentSettings>;
|
package/dist/types/settings.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare const DEFAULT_REGIONS: Readonly<Record<string, string>>;
|
|
|
12
12
|
export declare function sliccProviders(): Provider[];
|
|
13
13
|
export declare function withDefaultRegions(credentials: CredentialStore): CredentialStore;
|
|
14
14
|
export declare function createSliccModels(credentials: CredentialStore, providers?: Provider<import("@earendil-works/pi-ai").Api>[]): MutableModels;
|
|
15
|
+
export declare function shown<T>(run: () => Promise<T>): Promise<T>;
|
|
15
16
|
export type UsageReader = (token: string) => Promise<Budget | null>;
|
|
16
17
|
export declare function createAgentSettings(models: MutableModels, credentials: CredentialStore, providers?: Provider<import("@earendil-works/pi-ai").Api>[], options?: {
|
|
17
18
|
usage?: UsageReader;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { McpSignIn, SignIn } from '../services.ts';
|
|
2
|
+
export declare const MCP_CHANNEL = "slicc-mcp-oauth";
|
|
3
|
+
export declare const MCP_NAME_KEY = "slicc-mcp-oauth:";
|
|
4
|
+
export declare const SIGN_IN_TIMEOUT_MS: number;
|
|
5
|
+
export interface Popup {
|
|
6
|
+
location: {
|
|
7
|
+
href: string;
|
|
8
|
+
};
|
|
9
|
+
close(): void;
|
|
10
|
+
}
|
|
11
|
+
export interface Channel {
|
|
12
|
+
onmessage: ((event: {
|
|
13
|
+
data: unknown;
|
|
14
|
+
}) => void) | null;
|
|
15
|
+
close(): void;
|
|
16
|
+
}
|
|
17
|
+
export interface McpLoginHost {
|
|
18
|
+
open(): Popup | null;
|
|
19
|
+
channel(): Channel;
|
|
20
|
+
remember?(state: string, name: string | null): void;
|
|
21
|
+
timeoutMs?: number;
|
|
22
|
+
}
|
|
23
|
+
export declare function safeAuthorizationUrl(value: string): boolean;
|
|
24
|
+
export declare function mcpLogin(host?: McpLoginHost): (providerId: string, signIn: () => Promise<SignIn | McpSignIn | null>, options: {
|
|
25
|
+
signal: AbortSignal;
|
|
26
|
+
}) => Promise<string>;
|
|
@@ -8,7 +8,7 @@ export type Login = (providerId: string, signIn: () => Promise<SignIn | null>, o
|
|
|
8
8
|
}) => Promise<string>;
|
|
9
9
|
export declare class SettingsAdapter extends Emitter<SettingsEvents> implements SettingsPort {
|
|
10
10
|
#private;
|
|
11
|
-
constructor(settings: AgentSettings, agent: AgentAdapter, storage: Pick<Storage, 'getItem' | 'setItem'> | null, login?: Login | null);
|
|
11
|
+
constructor(settings: AgentSettings, agent: AgentAdapter, storage: Pick<Storage, 'getItem' | 'setItem'> | null, login?: Login | null, mcp?: Login);
|
|
12
12
|
get(): Settings;
|
|
13
13
|
update(patch: Partial<Settings>): void;
|
|
14
14
|
models(): readonly ModelOption[];
|
package/dist/types/worker.d.ts
CHANGED
|
@@ -3,4 +3,9 @@ export interface WorkerScope {
|
|
|
3
3
|
addEventListener(type: 'message', listener: (event: MessageEvent) => void): void;
|
|
4
4
|
}
|
|
5
5
|
export declare function serveConnections(scope: WorkerScope, host: Promise<AgentHost>): void;
|
|
6
|
+
export interface KernelPorts {
|
|
7
|
+
kernel: MessagePort;
|
|
8
|
+
admin?: MessagePort;
|
|
9
|
+
}
|
|
10
|
+
export declare function kernelPorts(scope: WorkerScope): Promise<KernelPorts>;
|
|
6
11
|
export declare function kernelPort(scope: WorkerScope): Promise<MessagePort>;
|
package/dist/worker.js
CHANGED
|
@@ -9,16 +9,22 @@ function serveConnections(scope, host) {
|
|
|
9
9
|
);
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function kernelPorts(scope) {
|
|
13
13
|
return new Promise((resolve) => {
|
|
14
14
|
scope.addEventListener("message", ({ data }) => {
|
|
15
|
-
const
|
|
16
|
-
|
|
15
|
+
const message = data;
|
|
16
|
+
const kernel = message?.kernel;
|
|
17
|
+
if (!kernel) return;
|
|
18
|
+
resolve(message.admin ? { kernel, admin: message.admin } : { kernel });
|
|
17
19
|
});
|
|
18
20
|
});
|
|
19
21
|
}
|
|
22
|
+
function kernelPort(scope) {
|
|
23
|
+
return kernelPorts(scope).then((ports) => ports.kernel);
|
|
24
|
+
}
|
|
20
25
|
export {
|
|
21
26
|
kernelPort,
|
|
27
|
+
kernelPorts,
|
|
22
28
|
serveConnections
|
|
23
29
|
};
|
|
24
30
|
//# sourceMappingURL=worker.js.map
|
package/dist/worker.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/worker.ts"],
|
|
4
|
-
"sourcesContent": ["import type { AgentHost } from './host.ts';\nimport type { PortEndpoint } from './wire.ts';\n\nexport interface WorkerScope {\n addEventListener(type: 'message', listener: (event: MessageEvent) => void): void;\n}\n\nexport function serveConnections(scope: WorkerScope, host: Promise<AgentHost>): void {\n scope.addEventListener('message', ({ data }) => {\n const message = data as { connect?: PortEndpoint; readOnly?: boolean } | null;\n const port = message?.connect;\n if (!port) return;\n host.then(\n (ready) => ready.connect(port, { readOnly: message?.readOnly === true }),\n () => port.close?.()\n );\n });\n}\n\nexport function
|
|
5
|
-
"mappings": "AAOO,SAAS,iBAAiB,OAAoB,MAAgC;AACnF,QAAM,iBAAiB,WAAW,CAAC,EAAE,KAAK,MAAM;AAC9C,UAAM,UAAU;AAChB,UAAM,OAAO,SAAS;AACtB,QAAI,CAAC,KAAM;AACX,SAAK;AAAA,MACH,CAAC,UAAU,MAAM,QAAQ,MAAM,EAAE,UAAU,SAAS,aAAa,KAAK,CAAC;AAAA,MACvE,MAAM,KAAK,QAAQ;AAAA,IACrB;AAAA,EACF,CAAC;AACH;
|
|
4
|
+
"sourcesContent": ["import type { AgentHost } from './host.ts';\nimport type { PortEndpoint } from './wire.ts';\n\nexport interface WorkerScope {\n addEventListener(type: 'message', listener: (event: MessageEvent) => void): void;\n}\n\nexport function serveConnections(scope: WorkerScope, host: Promise<AgentHost>): void {\n scope.addEventListener('message', ({ data }) => {\n const message = data as { connect?: PortEndpoint; readOnly?: boolean } | null;\n const port = message?.connect;\n if (!port) return;\n host.then(\n (ready) => ready.connect(port, { readOnly: message?.readOnly === true }),\n () => port.close?.()\n );\n });\n}\n\nexport interface KernelPorts {\n kernel: MessagePort;\n admin?: MessagePort;\n}\n\nexport function kernelPorts(scope: WorkerScope): Promise<KernelPorts> {\n return new Promise((resolve) => {\n scope.addEventListener('message', ({ data }) => {\n const message = data as { kernel?: MessagePort; admin?: MessagePort } | null;\n const kernel = message?.kernel;\n if (!kernel) return;\n resolve(message.admin ? { kernel, admin: message.admin } : { kernel });\n });\n });\n}\n\nexport function kernelPort(scope: WorkerScope): Promise<MessagePort> {\n return kernelPorts(scope).then((ports) => ports.kernel);\n}\n"],
|
|
5
|
+
"mappings": "AAOO,SAAS,iBAAiB,OAAoB,MAAgC;AACnF,QAAM,iBAAiB,WAAW,CAAC,EAAE,KAAK,MAAM;AAC9C,UAAM,UAAU;AAChB,UAAM,OAAO,SAAS;AACtB,QAAI,CAAC,KAAM;AACX,SAAK;AAAA,MACH,CAAC,UAAU,MAAM,QAAQ,MAAM,EAAE,UAAU,SAAS,aAAa,KAAK,CAAC;AAAA,MACvE,MAAM,KAAK,QAAQ;AAAA,IACrB;AAAA,EACF,CAAC;AACH;AAOO,SAAS,YAAY,OAA0C;AACpE,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,iBAAiB,WAAW,CAAC,EAAE,KAAK,MAAM;AAC9C,YAAM,UAAU;AAChB,YAAM,SAAS,SAAS;AACxB,UAAI,CAAC,OAAQ;AACb,cAAQ,QAAQ,QAAQ,EAAE,QAAQ,OAAO,QAAQ,MAAM,IAAI,EAAE,OAAO,CAAC;AAAA,IACvE,CAAC;AAAA,EACH,CAAC;AACH;AAEO,SAAS,WAAW,OAA0C;AACnE,SAAO,YAAY,KAAK,EAAE,KAAK,CAAC,UAAU,MAAM,MAAM;AACxD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED