@ai-ecoverse/slicc-agent 5.5.3 → 5.6.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 +10 -4
- package/dist/agent.js +2 -1
- package/dist/agent.js.map +2 -2
- package/dist/approvals/index.js +26 -17
- package/dist/approvals/index.js.map +2 -2
- package/dist/approvals/judge.js +7 -1
- package/dist/approvals/judge.js.map +2 -2
- package/dist/approvals/record.js +7 -2
- package/dist/approvals/record.js.map +2 -2
- package/dist/approvals/sudo-client.js +112 -0
- package/dist/approvals/sudo-client.js.map +7 -0
- package/dist/approvals/sudo.js +166 -0
- package/dist/approvals/sudo.js.map +7 -0
- package/dist/control.js +4 -11
- package/dist/control.js.map +2 -2
- package/dist/freezer/index.js +7 -22
- package/dist/freezer/index.js.map +2 -2
- package/dist/host.js +46 -13
- package/dist/host.js.map +2 -2
- package/dist/index.js.map +2 -2
- package/dist/main.js +6 -4
- package/dist/main.js.map +2 -2
- package/dist/owner.js +22 -1
- package/dist/owner.js.map +2 -2
- package/dist/page.js +2 -0
- package/dist/page.js.map +2 -2
- package/dist/scoops/index.js +2 -1
- package/dist/scoops/index.js.map +2 -2
- package/dist/scoops/service.js +5 -0
- package/dist/scoops/service.js.map +2 -2
- package/dist/secrets/extension.js +0 -30
- package/dist/secrets/extension.js.map +2 -2
- package/dist/selection.js +74 -0
- package/dist/selection.js.map +7 -0
- package/dist/services.js +10 -0
- package/dist/services.js.map +2 -2
- package/dist/serving.js +2 -0
- package/dist/serving.js.map +2 -2
- package/dist/types/agent.d.ts +1 -0
- package/dist/types/approvals/index.d.ts +6 -1
- package/dist/types/approvals/judge.d.ts +10 -0
- package/dist/types/approvals/record.d.ts +6 -0
- package/dist/types/approvals/sudo-client.d.ts +12 -0
- package/dist/types/approvals/sudo.d.ts +52 -0
- package/dist/types/host.d.ts +5 -2
- package/dist/types/index.d.ts +2 -1
- package/dist/types/owner.d.ts +4 -0
- package/dist/types/page.d.ts +2 -0
- package/dist/types/scoops/index.d.ts +2 -0
- package/dist/types/scoops/service.d.ts +2 -0
- package/dist/types/secrets/extension.d.ts +2 -4
- package/dist/types/selection.d.ts +15 -0
- package/dist/types/services.d.ts +2 -0
- package/dist/types/serving.d.ts +2 -0
- package/dist/worker.js +7 -1
- package/dist/worker.js.map +2 -2
- package/package.json +1 -1
|
@@ -14,10 +14,14 @@ export type ApprovalDecided = {
|
|
|
14
14
|
state: null;
|
|
15
15
|
error: string;
|
|
16
16
|
};
|
|
17
|
+
export type Decider = DecidedBy | {
|
|
18
|
+
by: DecidedBy;
|
|
19
|
+
device?: string;
|
|
20
|
+
};
|
|
17
21
|
export interface Approvals {
|
|
18
22
|
readonly state: ReplicatedState<Approval[]>;
|
|
19
23
|
request(draft: ApprovalDraft, context: Context): Promise<Approval>;
|
|
20
|
-
decide(id: string, answer: unknown, reason: string | null, by:
|
|
24
|
+
decide(id: string, answer: unknown, reason: string | null, by: Decider, context: Context): Promise<ApprovalDecided>;
|
|
21
25
|
settled(id: string, context: Context): Promise<Approval>;
|
|
22
26
|
withdraw(id: string, reason: string | null, context: Context): Promise<Approval | undefined>;
|
|
23
27
|
withdrawSeat(seat: string, context: Context): Promise<number>;
|
|
@@ -29,5 +33,6 @@ export interface ApprovalsAttach {
|
|
|
29
33
|
ttlMs?: number;
|
|
30
34
|
judge?: ApprovalJudge;
|
|
31
35
|
guestAlways?: (kind: ApprovalKind) => boolean;
|
|
36
|
+
sudoApprover?: () => unknown;
|
|
32
37
|
}
|
|
33
38
|
export declare function attachApprovals(options: ApprovalsAttach, context?: Context): Promise<Approvals>;
|
|
@@ -44,8 +44,18 @@ export declare const VERDICT_REASONS: {
|
|
|
44
44
|
export declare const JUDGE_QUESTIONS: Record<string, ClassifierQuestion>;
|
|
45
45
|
export declare function fenced(text: string, nonce: string): string;
|
|
46
46
|
export declare function untrustedOf(item: Approval): string;
|
|
47
|
+
export declare function sudoContext(item: Approval): {
|
|
48
|
+
sudo?: {
|
|
49
|
+
target: string;
|
|
50
|
+
cwd: string | null;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
47
53
|
export declare function judgeState(item: Approval, intent: OwnerIntent, nonce: string): {
|
|
48
54
|
request: {
|
|
55
|
+
sudo?: {
|
|
56
|
+
target: string;
|
|
57
|
+
cwd: string | null;
|
|
58
|
+
};
|
|
49
59
|
kind: "guest-message" | "guest-tool" | "sudo";
|
|
50
60
|
requester: {
|
|
51
61
|
kind: "agent" | "guest" | "user";
|
|
@@ -9,6 +9,7 @@ export type ApprovalRequester = {
|
|
|
9
9
|
seat?: string;
|
|
10
10
|
agentId?: string;
|
|
11
11
|
where?: string;
|
|
12
|
+
device?: string;
|
|
12
13
|
};
|
|
13
14
|
export type ApprovalVerdict = {
|
|
14
15
|
decision: 'allow' | 'deny' | 'unsure';
|
|
@@ -44,6 +45,7 @@ type Base = {
|
|
|
44
45
|
tier: string;
|
|
45
46
|
state: ApprovalState;
|
|
46
47
|
decidedBy: DecidedBy | null;
|
|
48
|
+
device?: string;
|
|
47
49
|
answer?: 'once' | 'always';
|
|
48
50
|
reason?: string;
|
|
49
51
|
verdict?: ApprovalVerdict;
|
|
@@ -88,6 +90,7 @@ export declare const REASONS: {
|
|
|
88
90
|
readonly restart: 'restart';
|
|
89
91
|
readonly revoked: 'revoked';
|
|
90
92
|
readonly aborted: 'aborted';
|
|
93
|
+
readonly disconnected: 'disconnected';
|
|
91
94
|
};
|
|
92
95
|
export declare const guestKind: (kind: ApprovalKind) => boolean;
|
|
93
96
|
export declare function knownTier(tier: unknown): tier is ApprovalTier;
|
|
@@ -95,6 +98,9 @@ export declare function routable(kind: ApprovalKind, tier: ApprovalTier): boolea
|
|
|
95
98
|
export declare function answerOf(value: unknown): ApprovalAnswer | null;
|
|
96
99
|
export declare const personal: (by: DecidedBy) => boolean;
|
|
97
100
|
export declare function answerer(by: DecidedBy, tier: string): boolean;
|
|
101
|
+
export type SudoApprover = 'user' | 'agent';
|
|
102
|
+
export declare const sudoApprover: (value: unknown) => SudoApprover;
|
|
103
|
+
export declare const tierOf: (kind: ApprovalKind, tier: string, sudo: SudoApprover) => string;
|
|
98
104
|
export declare function gone(state: ApprovalState): string;
|
|
99
105
|
export declare function cleanReason(reason: unknown): string | undefined;
|
|
100
106
|
export declare function prune(items: Approval[], kept?: number): Approval[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type PortEndpoint } from '../wire.ts';
|
|
2
|
+
import type { Approval } from './record.ts';
|
|
3
|
+
import type { SudoAnswer, SudoRequest } from './sudo.ts';
|
|
4
|
+
export interface ApproveOptions {
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
where?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const UNAVAILABLE = "The agent can't take this sudo request.";
|
|
9
|
+
export declare const unavailable: (cause?: unknown) => Error;
|
|
10
|
+
export declare function answerOf(item: Approval | undefined): SudoAnswer | null;
|
|
11
|
+
export declare const WITHDRAW_MS = 5000;
|
|
12
|
+
export declare function askSudo(endpoint: PortEndpoint, request: SudoRequest, options?: ApproveOptions, stop?: AbortSignal): Promise<SudoAnswer>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Context, ReplicatedState } from '@earendil-works/chord';
|
|
2
|
+
import type { AgentsState } from '../agents.ts';
|
|
3
|
+
import type { Licks } from '../licks/licks.ts';
|
|
4
|
+
import type { Approvals } from './index.ts';
|
|
5
|
+
import { type Approval, type ApprovalRequester, type SudoDetail } from './record.ts';
|
|
6
|
+
export type SudoAnswer = 'once' | 'always' | 'deny';
|
|
7
|
+
export interface SudoRequest {
|
|
8
|
+
id: string;
|
|
9
|
+
kind: 'sudo';
|
|
10
|
+
user: string;
|
|
11
|
+
uid?: number;
|
|
12
|
+
target?: string;
|
|
13
|
+
argv: string[];
|
|
14
|
+
path?: string;
|
|
15
|
+
cwd?: string;
|
|
16
|
+
pid?: number;
|
|
17
|
+
tag?: string;
|
|
18
|
+
tty?: string;
|
|
19
|
+
createdAt?: number;
|
|
20
|
+
expiresAt: number;
|
|
21
|
+
always?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export type SudoAsked = {
|
|
24
|
+
id: string;
|
|
25
|
+
error: null;
|
|
26
|
+
} | {
|
|
27
|
+
id: null;
|
|
28
|
+
error: string;
|
|
29
|
+
};
|
|
30
|
+
export interface AgentSudo {
|
|
31
|
+
readonly approvals: ReplicatedState<Approval[]>;
|
|
32
|
+
request(request: SudoRequest, where: string | null, context: Context): Promise<SudoAsked>;
|
|
33
|
+
withdraw(id: string, reason: string | null, context: Context): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export declare const shellWord: (word: string) => string;
|
|
36
|
+
export declare function sudoRequest(value: unknown): SudoRequest | null;
|
|
37
|
+
export declare function sudoRequester(request: SudoRequest, agents: Readonly<AgentsState> | undefined, where?: string | null): {
|
|
38
|
+
requester: ApprovalRequester;
|
|
39
|
+
agentId: string;
|
|
40
|
+
};
|
|
41
|
+
export declare function sudoDetail(request: SudoRequest): SudoDetail;
|
|
42
|
+
export interface SudoAttach {
|
|
43
|
+
approvals: Approvals;
|
|
44
|
+
agents?: () => Readonly<AgentsState> | undefined;
|
|
45
|
+
licks?: Pick<Licks, 'deliver'>;
|
|
46
|
+
}
|
|
47
|
+
export declare function createSudo(options: SudoAttach): AgentSudo & {
|
|
48
|
+
close(): void;
|
|
49
|
+
};
|
|
50
|
+
export declare function ownedSudo(sudo: AgentSudo): AgentSudo & {
|
|
51
|
+
release(): void;
|
|
52
|
+
};
|
package/dist/types/host.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Context, type Host, type Readable, type ReplicatedState } from '@earendil-works/chord';
|
|
2
2
|
import type { Agent } from './agent.ts';
|
|
3
|
-
import { type ApprovalJudge, type Approvals, type
|
|
3
|
+
import { type ApprovalJudge, type Approvals, type Decider } from './approvals/index.ts';
|
|
4
|
+
import { type AgentSudo } from './approvals/sudo.ts';
|
|
4
5
|
import type { ChangesRuntime } from './changes/index.ts';
|
|
5
6
|
import { type HostLicks, type HostScoops } from './control.ts';
|
|
6
7
|
import type { FreezerRuntime } from './freezer/index.ts';
|
|
@@ -28,6 +29,7 @@ export interface ConnectOptions {
|
|
|
28
29
|
id: string;
|
|
29
30
|
label: string;
|
|
30
31
|
};
|
|
32
|
+
device?: string;
|
|
31
33
|
}
|
|
32
34
|
export interface AgentHost {
|
|
33
35
|
readonly serverId: string;
|
|
@@ -71,6 +73,7 @@ interface Served {
|
|
|
71
73
|
viewed: AgentControl;
|
|
72
74
|
transcript: Record<keyof AgentTranscript, ReplicatedState<unknown>>;
|
|
73
75
|
viewMonitor: ReplicatedState<unknown>;
|
|
76
|
+
sudo?: AgentSudo;
|
|
74
77
|
settings: AgentSettings;
|
|
75
78
|
remote: AgentRemote;
|
|
76
79
|
pages: Pages;
|
|
@@ -78,7 +81,7 @@ interface Served {
|
|
|
78
81
|
value: AgentGuest;
|
|
79
82
|
dispose(): void;
|
|
80
83
|
} | undefined;
|
|
81
|
-
decide: (by:
|
|
84
|
+
decide: (by: Decider) => AgentControl['decide'];
|
|
82
85
|
}
|
|
83
86
|
export declare const CLOSED_TO_GUESTS = "a guest seat has only its transcript and propose";
|
|
84
87
|
export declare const openToGuests: <F extends object>(factory: F) => F;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export { ADOBE, ADOBE_PROXY, type AdobeConfig, type AdobeModelInfo, adobeClassifiers, adobeConfig, adobeIdentity, adobeModel, adobeProvider, adobeUsage, type Budget, SESSION_HEADER, VERSION_HEADER, withAdobeIdentity, } from './adobe.ts';
|
|
2
2
|
export { type Agent, type AgentOptions, answerText, openAgent } from './agent.ts';
|
|
3
|
-
export { APPROVAL_MS, type Approval, type ApprovalAnswer, type ApprovalDecided, type ApprovalDraft, type ApprovalJudge, type ApprovalKind, type ApprovalRequester, type ApprovalState, type Approvals, ApprovalsDoc, type ApprovalTier, type ApprovalVerdict, approvalJudge, attachApprovals, DEFAULT_POLICY, type DecidedBy, JUDGE_ALLOW, JUDGE_DENY, JUDGE_KIND, JUDGE_MODEL, JUDGE_QUESTIONS, type Judgement, judgeModelOf, judgeSpender, judgeState, type OwnerIntent, ownerIntent, POLICY_FILE, REASONS, seedPolicy, VERDICT_REASONS, verdictOf, verdictRecorder, } from './approvals/index.ts';
|
|
3
|
+
export { APPROVAL_MS, type Approval, type ApprovalAnswer, type ApprovalDecided, type ApprovalDraft, type ApprovalJudge, type ApprovalKind, type ApprovalRequester, type ApprovalState, type Approvals, ApprovalsDoc, type ApprovalTier, type ApprovalVerdict, approvalJudge, attachApprovals, DEFAULT_POLICY, type DecidedBy, type Decider, JUDGE_ALLOW, JUDGE_DENY, JUDGE_KIND, JUDGE_MODEL, JUDGE_QUESTIONS, type Judgement, judgeModelOf, judgeSpender, judgeState, type OwnerIntent, ownerIntent, POLICY_FILE, REASONS, seedPolicy, VERDICT_REASONS, verdictOf, verdictRecorder, } from './approvals/index.ts';
|
|
4
4
|
export { type ApprovalPolicy, type ApprovalPolicyChange, type ApprovalPolicySet, DEFAULT_APPROVAL_POLICY, type SudoPolicy, } from './approvals/policy.ts';
|
|
5
|
+
export type { AgentSudo, SudoAnswer, SudoRequest } from './approvals/sudo.ts';
|
|
5
6
|
export { FILE_LIMIT, IMAGE_LIMIT, type SendAttachment, type ShownAttachment, splitUser, TOTAL_LIMIT, userParts, } from './attachments.ts';
|
|
6
7
|
export { type AgentConnection, connectAgent } from './client.ts';
|
|
7
8
|
export { createAgentControl } from './control.ts';
|
package/dist/types/owner.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { SudoAnswer, SudoRequest } from './approvals/sudo.ts';
|
|
2
|
+
import { type ApproveOptions } from './approvals/sudo-client.ts';
|
|
1
3
|
import { type AgentConnection } from './client.ts';
|
|
2
4
|
import { type KernelSource } from './kernel/users.ts';
|
|
3
5
|
import type { PortEndpoint } from './wire.ts';
|
|
@@ -13,10 +15,12 @@ export interface PortOptions {
|
|
|
13
15
|
id: string;
|
|
14
16
|
label: string;
|
|
15
17
|
};
|
|
18
|
+
device?: string;
|
|
16
19
|
}
|
|
17
20
|
export interface AgentOwner {
|
|
18
21
|
connect(options?: PortOptions): Promise<AgentConnection>;
|
|
19
22
|
port(options?: PortOptions): Promise<PortEndpoint & Transferable>;
|
|
23
|
+
approve(request: SudoRequest, options?: ApproveOptions): Promise<SudoAnswer>;
|
|
20
24
|
restart(): Promise<void>;
|
|
21
25
|
release(): Promise<void>;
|
|
22
26
|
}
|
package/dist/types/page.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export type { SudoAnswer, SudoRequest } from './approvals/sudo.ts';
|
|
2
|
+
export { type ApproveOptions, UNAVAILABLE } from './approvals/sudo-client.ts';
|
|
1
3
|
export { type AgentConnection, connectAgent } from './client.ts';
|
|
2
4
|
export { connectGuest, GUEST_ONLY, type GuestConnection, SEAT_REFUSED, } from './guests/client.ts';
|
|
3
5
|
export { type ByteSink, bridgePort, encodeFrame, FrameReader, type LinkEnd, linkEndpoint, MAX_FRAME, } from './link.ts';
|
|
@@ -6,6 +6,7 @@ import type { ProcessGroups } from '../kernel/groups.ts';
|
|
|
6
6
|
import { type Layout } from '../layout.ts';
|
|
7
7
|
import type { Licks } from '../licks/licks.ts';
|
|
8
8
|
import { type Roles } from '../roles/roles.ts';
|
|
9
|
+
import type { Choosable } from '../selection.ts';
|
|
9
10
|
import { type CliOptions } from './cli.ts';
|
|
10
11
|
import { type ControlPlane } from './requests.ts';
|
|
11
12
|
import { type EnvOf, type Scoops } from './service.ts';
|
|
@@ -49,6 +50,7 @@ export interface ScoopsRuntime {
|
|
|
49
50
|
}
|
|
50
51
|
export interface ScoopsSetup {
|
|
51
52
|
scoops: Scoops;
|
|
53
|
+
choosable: Choosable;
|
|
52
54
|
attach(options: AttachOptions, context: Context): Promise<ScoopsRuntime>;
|
|
53
55
|
}
|
|
54
56
|
export declare const COMMANDS: string[];
|
|
@@ -6,6 +6,7 @@ import type { ProcessGroups } from '../kernel/groups.ts';
|
|
|
6
6
|
import { type Layout } from '../layout.ts';
|
|
7
7
|
import type { Licks } from '../licks/licks.ts';
|
|
8
8
|
import type { Role } from '../roles/roles.ts';
|
|
9
|
+
import type { Choosable } from '../selection.ts';
|
|
9
10
|
export { SCOOPS_ROOT } from '../layout.ts';
|
|
10
11
|
export declare const LEDGER_SIZE = 512;
|
|
11
12
|
export type Feed = {
|
|
@@ -104,6 +105,7 @@ export declare function tail(conversation: Conversation, context: Context): Prom
|
|
|
104
105
|
export declare function turnStart(conversation: Conversation, context: Context): Promise<number>;
|
|
105
106
|
export declare function coneOf(state: Readonly<AgentsState>, conversation: number): string | undefined;
|
|
106
107
|
export declare function findScoop(state: Readonly<AgentsState>, handle: string, cone: string | null): [string, ScoopRecord] | undefined;
|
|
108
|
+
export declare function choosable(tools: readonly ToolRegistration[]): Choosable;
|
|
107
109
|
export declare function askerName(state: Readonly<AgentsState>, asker: string | null): string;
|
|
108
110
|
export declare function createScoops(host: Promise<ScoopsHost>, tasks: () => ScoopTasks): {
|
|
109
111
|
detach: (made: readonly number[], target: string, context: Context) => Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { type
|
|
1
|
+
import type { JsonValue } from '@earendil-works/chord';
|
|
2
|
+
import { type Extension, type ToolExecutionResult } from '@earendil-works/pi-durable';
|
|
3
3
|
import type { Names, SecretName } from './names.ts';
|
|
4
4
|
import type { Scrub } from './scrub.ts';
|
|
5
5
|
import type { Vault } from './vault.ts';
|
|
@@ -23,8 +23,6 @@ export declare function secretsEntry(names: readonly SecretName[]): {
|
|
|
23
23
|
}[];
|
|
24
24
|
};
|
|
25
25
|
export declare function shellGrants(names: Pick<Names, 'state'>): (argv: readonly string[]) => readonly string[];
|
|
26
|
-
export declare function pinned<T extends AgentChange>(change: T): T;
|
|
27
|
-
export declare function repin(harness: Pick<Harness, 'conversation'>, storage: Pick<Storage, 'scanConversations'>, context: Context): Promise<number>;
|
|
28
26
|
export declare function secretsExtension(deps: {
|
|
29
27
|
names: Pick<Names, 'state'>;
|
|
30
28
|
vault: Pick<Vault, 'ready' | 'texts'>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Context } from '@earendil-works/chord';
|
|
2
|
+
import { type AgentState, type ConversationId, type ConversationInit, type Harness, type HarnessOptions, type Storage } from '@earendil-works/pi-durable';
|
|
3
|
+
export type Choosable = (tool: string) => boolean;
|
|
4
|
+
type Field = keyof AgentState;
|
|
5
|
+
export declare const SELECTION: readonly Field[];
|
|
6
|
+
export declare const SelectionDoc: import("@earendil-works/pi-durable").SessionDocToken<{
|
|
7
|
+
version: number;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const SELECTION_VERSION = 1;
|
|
10
|
+
export declare function storedAgent(harness: Pick<Harness, 'snapshot'>, conversationId: ConversationId, context: Context): Promise<AgentState>;
|
|
11
|
+
export declare function copyAgent(from: AgentState, fields?: readonly Field[]): ConversationInit;
|
|
12
|
+
export declare function unfrozen(agent: AgentState, choosable: Choosable): boolean;
|
|
13
|
+
export declare function unfreezeCreated(choosable: Choosable): HarnessOptions['conversationCreated'];
|
|
14
|
+
export declare function unfreeze(harness: Pick<Harness, 'snapshot' | 'commit'>, storage: Pick<Storage, 'scanConversations'>, choosable: Choosable, context: Context): Promise<number>;
|
|
15
|
+
export {};
|
package/dist/types/services.d.ts
CHANGED
|
@@ -309,6 +309,8 @@ export declare const AgentGuestService: RemoteContract;
|
|
|
309
309
|
export declare const AgentRemoteService: RemoteContract;
|
|
310
310
|
export declare const PAGE_METHODS: ("answer" | "close" | "next" | "open" | "report")[];
|
|
311
311
|
export declare const AgentPagesService: RemoteContract;
|
|
312
|
+
export declare const SUDO_METHODS: ("request" | "withdraw")[];
|
|
313
|
+
export declare const AgentSudoService: RemoteContract;
|
|
312
314
|
export interface ModelChoice {
|
|
313
315
|
id: string;
|
|
314
316
|
label: string;
|
package/dist/types/serving.d.ts
CHANGED
|
@@ -11,9 +11,11 @@ export interface AgentPrincipal {
|
|
|
11
11
|
seat: Seat;
|
|
12
12
|
link: number;
|
|
13
13
|
guest?: GuestPrincipal;
|
|
14
|
+
device?: string;
|
|
14
15
|
}
|
|
15
16
|
export declare const seatOf: (principal: Principal) => Seat;
|
|
16
17
|
export declare const guestOf: (principal: Principal) => GuestPrincipal | undefined;
|
|
18
|
+
export declare const deviceOf: (principal: Principal) => string | undefined;
|
|
17
19
|
export declare const principalKey: (principal: Principal) => string;
|
|
18
20
|
export interface Members {
|
|
19
21
|
methods?: readonly string[];
|
package/dist/worker.js
CHANGED
|
@@ -5,8 +5,14 @@ function serveConnections(scope, host) {
|
|
|
5
5
|
if (!port) return;
|
|
6
6
|
const pages = message?.pages === false ? { pages: false } : {};
|
|
7
7
|
const guest = message?.guest ? { guest: message.guest } : {};
|
|
8
|
+
const device = typeof message?.device === "string" && message.device ? { device: message.device } : {};
|
|
8
9
|
host.then(
|
|
9
|
-
(ready) => ready.connect(port, {
|
|
10
|
+
(ready) => ready.connect(port, {
|
|
11
|
+
readOnly: message?.readOnly === true,
|
|
12
|
+
...pages,
|
|
13
|
+
...guest,
|
|
14
|
+
...device
|
|
15
|
+
}),
|
|
10
16
|
() => port.close?.()
|
|
11
17
|
);
|
|
12
18
|
});
|
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 {\n connect?: PortEndpoint;\n readOnly?: boolean;\n pages?: boolean;\n guest?: { id: string; label: string };\n } | null;\n const port = message?.connect;\n if (!port) return;\n const pages = message?.pages === false ? { pages: false } : {};\n const guest = message?.guest ? { guest: message.guest } : {};\n host.then(\n (ready)
|
|
5
|
-
"mappings": "AAOO,SAAS,iBAAiB,OAAoB,MAAgC;AACnF,QAAM,iBAAiB,WAAW,CAAC,EAAE,KAAK,MAAM;AAC9C,UAAM,UAAU;
|
|
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 {\n connect?: PortEndpoint;\n readOnly?: boolean;\n pages?: boolean;\n guest?: { id: string; label: string };\n device?: unknown;\n } | null;\n const port = message?.connect;\n if (!port) return;\n const pages = message?.pages === false ? { pages: false } : {};\n const guest = message?.guest ? { guest: message.guest } : {};\n const device =\n typeof message?.device === 'string' && message.device ? { device: message.device } : {};\n host.then(\n (ready) =>\n ready.connect(port, {\n readOnly: message?.readOnly === true,\n ...pages,\n ...guest,\n ...device,\n }),\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;AAOhB,UAAM,OAAO,SAAS;AACtB,QAAI,CAAC,KAAM;AACX,UAAM,QAAQ,SAAS,UAAU,QAAQ,EAAE,OAAO,MAAM,IAAI,CAAC;AAC7D,UAAM,QAAQ,SAAS,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,CAAC;AAC3D,UAAM,SACJ,OAAO,SAAS,WAAW,YAAY,QAAQ,SAAS,EAAE,QAAQ,QAAQ,OAAO,IAAI,CAAC;AACxF,SAAK;AAAA,MACH,CAAC,UACC,MAAM,QAAQ,MAAM;AAAA,QAClB,UAAU,SAAS,aAAa;AAAA,QAChC,GAAG;AAAA,QACH,GAAG;AAAA,QACH,GAAG;AAAA,MACL,CAAC;AAAA,MACH,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