@ai-ecoverse/slicc-agent 7.31.0 → 7.32.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 (60) hide show
  1. package/README.md +14 -4
  2. package/dist/agent.js +4 -0
  3. package/dist/agent.js.map +2 -2
  4. package/dist/approvals/policy.js +27 -5
  5. package/dist/approvals/policy.js.map +2 -2
  6. package/dist/approvals/published.js +18 -0
  7. package/dist/approvals/published.js.map +7 -0
  8. package/dist/approvals/record.js +4 -1
  9. package/dist/approvals/record.js.map +2 -2
  10. package/dist/approvals/run-licks.js +137 -0
  11. package/dist/approvals/run-licks.js.map +7 -0
  12. package/dist/approvals/run-procs.js +127 -0
  13. package/dist/approvals/run-procs.js.map +7 -0
  14. package/dist/approvals/run.js +468 -0
  15. package/dist/approvals/run.js.map +7 -0
  16. package/dist/approvals/runnable.js +125 -0
  17. package/dist/approvals/runnable.js.map +7 -0
  18. package/dist/approvals/sudo.js +29 -1
  19. package/dist/approvals/sudo.js.map +2 -2
  20. package/dist/client.js +1 -0
  21. package/dist/client.js.map +2 -2
  22. package/dist/control.js +7 -1
  23. package/dist/control.js.map +2 -2
  24. package/dist/host.js +69 -16
  25. package/dist/host.js.map +2 -2
  26. package/dist/index.js +14 -0
  27. package/dist/index.js.map +2 -2
  28. package/dist/licks/extension.js +1 -0
  29. package/dist/licks/extension.js.map +2 -2
  30. package/dist/licks/lick.js +1 -0
  31. package/dist/licks/lick.js.map +2 -2
  32. package/dist/main.js +1 -0
  33. package/dist/main.js.map +2 -2
  34. package/dist/services.js +7 -2
  35. package/dist/services.js.map +2 -2
  36. package/dist/spectrum/approvals-port.js +69 -0
  37. package/dist/spectrum/approvals-port.js.map +2 -2
  38. package/dist/spectrum/messages.js +2 -1
  39. package/dist/spectrum/messages.js.map +2 -2
  40. package/dist/spectrum/monitor-port.js +2 -1
  41. package/dist/spectrum/monitor-port.js.map +2 -2
  42. package/dist/types/agent.d.ts +2 -0
  43. package/dist/types/approvals/policy.d.ts +10 -1
  44. package/dist/types/approvals/published.d.ts +3 -0
  45. package/dist/types/approvals/record.d.ts +44 -1
  46. package/dist/types/approvals/run-licks.d.ts +18 -0
  47. package/dist/types/approvals/run-procs.d.ts +40 -0
  48. package/dist/types/approvals/run.d.ts +60 -0
  49. package/dist/types/approvals/runnable.d.ts +55 -0
  50. package/dist/types/approvals/sudo.d.ts +3 -1
  51. package/dist/types/client.d.ts +2 -0
  52. package/dist/types/host.d.ts +10 -0
  53. package/dist/types/index.d.ts +4 -1
  54. package/dist/types/kernel/client.d.ts +35 -0
  55. package/dist/types/licks/lick.d.ts +1 -1
  56. package/dist/types/licks/triage.d.ts +1 -1
  57. package/dist/types/main.d.ts +2 -1
  58. package/dist/types/services.d.ts +7 -2
  59. package/dist/types/spectrum/approvals-port.d.ts +10 -2
  60. package/package.json +3 -3
@@ -2,6 +2,7 @@ import type { Context } from '@earendil-works/chord';
2
2
  import type { Models } from '@earendil-works/pi-ai/models';
3
3
  import { type Conversation, Harness, type HarnessOptions, type ModelRef, type Registry, type Storage } from '@earendil-works/pi-durable';
4
4
  import { type Agents } from './agents.ts';
5
+ import { type SudoRuns } from './approvals/run.ts';
5
6
  import type { Clock } from './clock.ts';
6
7
  import type { Cones } from './cone.ts';
7
8
  import { type GuestToolGate } from './guests/guard.ts';
@@ -29,6 +30,7 @@ export interface Agent extends Cones {
29
30
  readonly reviews: GuestReviews;
30
31
  readonly gate: GuestToolGate;
31
32
  readonly scoopReviews: ScoopReviews;
33
+ readonly sudoRuns: SudoRuns;
32
34
  readonly reports: Reports;
33
35
  readonly timings: Timings;
34
36
  onCone(listener: (conversation: Conversation) => void | Promise<void>): () => void;
@@ -2,16 +2,24 @@ import { type Context, type ReplicatedState } from '@earendil-works/chord';
2
2
  import { type Harness, type JsonObject } from '@earendil-works/pi-durable';
3
3
  import { type GuestPolicy, type GuestPolicyChange } from '../guests/policy.ts';
4
4
  import type { ApprovalKind } from './record.ts';
5
+ export type RunLatePolicy = {
6
+ maxAgeMinutes: number;
7
+ };
5
8
  export type SudoPolicy = {
6
9
  approver: 'user' | 'agent';
10
+ runLate: RunLatePolicy;
7
11
  };
8
12
  export type ApprovalPolicy = {
9
13
  guests: GuestPolicy;
10
14
  sudo: SudoPolicy;
11
15
  };
16
+ export type SudoPolicyChange = {
17
+ approver?: SudoPolicy['approver'];
18
+ runLate?: Partial<RunLatePolicy>;
19
+ };
12
20
  export type ApprovalPolicyChange = {
13
21
  guests?: GuestPolicyChange;
14
- sudo?: Partial<SudoPolicy>;
22
+ sudo?: SudoPolicyChange;
15
23
  };
16
24
  export type ApprovalPolicySet = {
17
25
  policy: ApprovalPolicy;
@@ -21,6 +29,7 @@ export type ApprovalPolicySet = {
21
29
  error: string;
22
30
  };
23
31
  export declare const DEFAULT_APPROVAL_POLICY: ApprovalPolicy;
32
+ export declare const MAX_RUN_LATE_MINUTES = 10080;
24
33
  type Overrides = Partial<Record<keyof ApprovalPolicy, JsonObject>>;
25
34
  export declare const ApprovalPolicyDoc: import("@earendil-works/pi-durable").SessionDocToken<{
26
35
  overrides: Overrides;
@@ -0,0 +1,3 @@
1
+ import { type ReplicatedState } from '@earendil-works/chord';
2
+ import type { Approval } from './record.ts';
3
+ export declare function publishedApprovals(state: ReplicatedState<Approval[]>, view: boolean): ReplicatedState<Approval[]>;
@@ -57,6 +57,44 @@ export type SudoDetail = {
57
57
  writable?: boolean;
58
58
  validate?: true;
59
59
  };
60
+ export type SudoFile = {
61
+ path: string;
62
+ sha256: string;
63
+ };
64
+ export type SudoReplay = {
65
+ id: string;
66
+ user: string;
67
+ uid?: number;
68
+ target?: string;
69
+ argv: string[];
70
+ path?: string;
71
+ cwd?: string;
72
+ stdin?: SudoStdin;
73
+ rootOnly?: Record<string, boolean>;
74
+ userWritable?: SudoFile[];
75
+ tag?: string;
76
+ tags?: string[];
77
+ validate?: boolean;
78
+ };
79
+ export type SudoRunState = 'starting' | 'running' | 'done' | 'failed' | 'stopped';
80
+ export type SudoRun = {
81
+ state: SudoRunState;
82
+ by: DecidedBy;
83
+ device?: string;
84
+ at: number;
85
+ pid?: number;
86
+ pgid?: number;
87
+ status?: number;
88
+ signal?: string;
89
+ endedAt?: number;
90
+ error?: string;
91
+ stdout?: string;
92
+ stderr?: string;
93
+ stopBy?: DecidedBy;
94
+ survivors?: number[];
95
+ capped?: number;
96
+ removed?: true;
97
+ };
60
98
  export type CaptureWhat = 'screen' | 'camera' | 'microphone';
61
99
  export type CaptureMode = 'still' | 'video' | 'audio';
62
100
  export type CaptureDetail = {
@@ -99,6 +137,8 @@ export type GuestToolApproval = Base & {
99
137
  export type SudoApproval = Base & {
100
138
  kind: 'sudo';
101
139
  detail: SudoDetail;
140
+ replay?: SudoReplay;
141
+ run?: SudoRun;
102
142
  };
103
143
  export type CaptureApproval = Base & {
104
144
  kind: 'capture';
@@ -111,7 +151,9 @@ type DraftOf<T extends Approval> = Pick<T, 'kind' | 'detail' | 'agentId' | 'requ
111
151
  always?: boolean;
112
152
  expiresAt?: number;
113
153
  };
114
- export type ApprovalDraft = DraftOf<GuestMessageApproval> | DraftOf<GuestToolApproval> | DraftOf<SudoApproval> | DraftOf<CaptureApproval>;
154
+ export type ApprovalDraft = DraftOf<GuestMessageApproval> | DraftOf<GuestToolApproval> | (DraftOf<SudoApproval> & {
155
+ replay?: SudoReplay;
156
+ }) | DraftOf<CaptureApproval>;
115
157
  export type ApprovalsState = {
116
158
  items: Approval[];
117
159
  };
@@ -140,6 +182,7 @@ export declare function route(verdict: ApprovalVerdict | undefined, requester: P
140
182
  export declare function alwaysOffered(item: Approval): boolean;
141
183
  export declare function gone(state: ApprovalState): string;
142
184
  export declare function cleanReason(reason: unknown): string | undefined;
185
+ export declare const runLive: (item: Approval) => boolean;
143
186
  export declare function prune(items: Approval[], kept?: number): Approval[];
144
187
  export type Settle = {
145
188
  state: Exclude<ApprovalState, 'pending'>;
@@ -0,0 +1,18 @@
1
+ import type { Harness } from '@earendil-works/pi-durable';
2
+ import { type AgentsState } from '../agents.ts';
3
+ import type { LickEvent } from '../licks/licks.ts';
4
+ import type { SudoApproval } from './record.ts';
5
+ export declare const KEEP_HOURS = 24;
6
+ export declare const MIB: number;
7
+ export type LickHost = {
8
+ harness: Pick<Harness, 'commit' | 'snapshot'>;
9
+ agents: {
10
+ state(): Readonly<AgentsState>;
11
+ };
12
+ now?: () => number;
13
+ };
14
+ export declare const sized: (bytes: number) => string;
15
+ export declare function clock(at: number, now: number): string;
16
+ export declare function duration(ms: number): string;
17
+ export declare function startLick(host: LickHost, item: SudoApproval): Promise<LickEvent>;
18
+ export declare function endLick(host: LickHost, item: SudoApproval): Promise<LickEvent>;
@@ -0,0 +1,40 @@
1
+ import type { KernelClient } from '../kernel/client.ts';
2
+ export type RunKernel = Pick<KernelClient, 'fs' | 'spawn' | 'ps' | 'kill' | 'sudoRun' | 'trace'>;
3
+ export type Exit = {
4
+ status?: number;
5
+ signal?: string;
6
+ };
7
+ export declare const RUN_TAG = "sudo-run:";
8
+ export declare const RUNS_DIR = ".slicc/sudo-runs";
9
+ export declare const GRACE_MS = 1000;
10
+ export declare const runTag: (id: string) => string;
11
+ type Row = NonNullable<Awaited<ReturnType<NonNullable<RunKernel['ps']>>>>[number];
12
+ export declare function uidOf(kernel: RunKernel, user: string): Promise<number | undefined>;
13
+ export declare function aborted(signal: AbortSignal | undefined): Promise<never>;
14
+ export declare function outputOf(kernel: RunKernel, user: string, id: string, signal?: AbortSignal): Promise<{
15
+ stdout: string;
16
+ stderr: string;
17
+ }>;
18
+ export declare function removeOutput(kernel: RunKernel, user: string, paths: string[]): Promise<void>;
19
+ export declare function outputSize(kernel: RunKernel, paths: string[]): Promise<number>;
20
+ export type Watcher = {
21
+ waitFor(pid: number): Promise<Exit>;
22
+ close(): void;
23
+ };
24
+ export declare function watchExits(kernel: RunKernel, tag: string): Promise<Watcher>;
25
+ export declare const sleep: (ms: number, signal?: AbortSignal) => Promise<void>;
26
+ export declare function gone(kernel: RunKernel, pid: number, ms: number, signal: AbortSignal): Promise<Exit>;
27
+ export declare function tagged(kernel: RunKernel, tag: string): Promise<Row[] | null>;
28
+ export type Signalled = 'sent' | 'none' | 'unknown';
29
+ export declare function signalTree(kernel: RunKernel, tag: string, killMs: number): Promise<Signalled>;
30
+ export declare function adoptable(kernel: RunKernel, tag: string, target: string): Promise<{
31
+ pid: number;
32
+ ppid?: number;
33
+ pgid?: number;
34
+ state?: string;
35
+ argv?: readonly string[];
36
+ uid?: number;
37
+ tag?: string;
38
+ tags?: readonly string[];
39
+ }>;
40
+ export {};
@@ -0,0 +1,60 @@
1
+ import type { Context } from '@earendil-works/chord';
2
+ import { type Extension, type Harness } from '@earendil-works/pi-durable';
3
+ import type { AgentsState } from '../agents.ts';
4
+ import type { Licks } from '../licks/licks.ts';
5
+ import { type DecidedBy } from './record.ts';
6
+ import { type RunKernel } from './run-procs.ts';
7
+ import { type RunGates } from './runnable.ts';
8
+ export { clock, duration, endLick, startLick } from './run-licks.ts';
9
+ export { outputOf, RUN_TAG, RUNS_DIR, type RunKernel, runTag } from './run-procs.ts';
10
+ export declare const SUDO_RUN_TASK = "slicc.sudo-run";
11
+ export declare const SUDO_RUNS = "slicc-sudo-runs";
12
+ export declare const POLL_MS = 5000;
13
+ export declare const KILL_MS = 5000;
14
+ export declare const ADOPT_MS = 250;
15
+ export declare const ADOPT_TRIES = 5;
16
+ export declare const OUTPUT_CAP: number;
17
+ export declare const KEEP_MS: number;
18
+ export declare const RUN_ERRORS: {
19
+ readonly interrupted: 'interrupted before it started';
20
+ readonly reloaded: 'the page reloaded while it ran';
21
+ readonly idle: "This request isn't running.";
22
+ readonly gone: 'Its processes are already gone.';
23
+ readonly unseen: "The kernel's process list isn't available, so it can't be stopped.";
24
+ };
25
+ export interface SudoRunHost {
26
+ kernel: RunKernel;
27
+ harness: Pick<Harness, 'commit' | 'snapshot'>;
28
+ agents: {
29
+ state(): Readonly<AgentsState>;
30
+ };
31
+ licks?: Pick<Licks, 'deliver'>;
32
+ boot: string | null;
33
+ server: string;
34
+ conversation: number;
35
+ now?: () => number;
36
+ pollMs?: number;
37
+ killMs?: number;
38
+ adoptMs?: number;
39
+ outputCap?: number;
40
+ keepMs?: number;
41
+ }
42
+ export type RunAnswer = {
43
+ done: true;
44
+ error: null;
45
+ } | {
46
+ done: false;
47
+ error: string;
48
+ };
49
+ export type Runner = {
50
+ by: DecidedBy;
51
+ device?: string;
52
+ };
53
+ export interface SudoRuns {
54
+ readonly extension: Extension;
55
+ bind(host: SudoRunHost): void;
56
+ claim(id: string, runner: Runner, gates: RunGates, context: Context): Promise<RunAnswer>;
57
+ stop(id: string, runner: Runner, context: Context): Promise<RunAnswer>;
58
+ }
59
+ export declare function messageOf(error: unknown): string;
60
+ export declare function sudoRuns(): SudoRuns;
@@ -0,0 +1,55 @@
1
+ import { type ReplicatedState } from '@earendil-works/chord';
2
+ import { type AgentsState } from '../agents.ts';
3
+ import type { LickTarget } from '../licks/lick.ts';
4
+ import { type Approval } from './record.ts';
5
+ export type Runnable = true | {
6
+ reason: string;
7
+ };
8
+ export type RunGates = {
9
+ maxAgeMinutes: number;
10
+ kernel: true | string;
11
+ frozen?: (agentId: string) => string | undefined;
12
+ gone?: (agentId: string) => boolean;
13
+ };
14
+ export declare const SUDO_RUN_PROTOCOL: readonly [number, number];
15
+ export declare const RUN_REASONS: {
16
+ readonly kind: 'Only a sudo request can run now.';
17
+ readonly open: 'This request is still open: answer it instead.';
18
+ readonly untimed: 'Only a request that timed out can run now.';
19
+ readonly running: 'This request is already running.';
20
+ readonly ran: 'This request already ran.';
21
+ readonly terminal: 'Run it again in the terminal.';
22
+ readonly validate: 'sudo -v has no command to run.';
23
+ readonly stdin: 'Its input is gone, so it must be asked again.';
24
+ readonly old: 'This request is from before Run now, so it must be asked again.';
25
+ readonly off: 'Run now is off in the approval policy.';
26
+ readonly gone: 'The agent that asked is gone, so it must be asked again.';
27
+ readonly kernel: `Needs slicc-kernel protocol ${string} or later.`;
28
+ };
29
+ export declare function tooOld(minutes: number): string;
30
+ export declare const thawFirst: (cone: string) => string;
31
+ export declare function runnable(item: Approval, now: number, gates: RunGates): Runnable;
32
+ export declare function runEnds(item: Approval, maxAgeMinutes: number): number | undefined;
33
+ export declare function agentTarget(state: Readonly<AgentsState>, agentId: string): LickTarget;
34
+ export declare const frozenOf: (state: () => Readonly<AgentsState>) => (agentId: string) => string | undefined;
35
+ export declare const goneOf: (state: () => Readonly<AgentsState>) => (agentId: string) => boolean;
36
+ type Protocol = {
37
+ protocol?: readonly number[];
38
+ sudoRun?: unknown;
39
+ };
40
+ export declare function kernelGate(client: Protocol | undefined): true | string;
41
+ type Watched = {
42
+ subscribe(listener: () => void): () => void;
43
+ };
44
+ export interface RunnableWatch {
45
+ readonly state: ReplicatedState<Record<string, Runnable>>;
46
+ refresh(): void;
47
+ dispose(): void;
48
+ }
49
+ export declare function watchRunnable(approvals: Watched & {
50
+ readonly value: readonly Approval[] | undefined;
51
+ }, changes: readonly Watched[], gates: () => RunGates, clock?: {
52
+ now?: () => number;
53
+ setTimer?: (callback: () => void, ms: number) => () => void;
54
+ }): RunnableWatch;
55
+ export {};
@@ -3,7 +3,7 @@ import type { AgentsState } from '../agents.ts';
3
3
  import type { AgentCapture } from '../guests/capture.ts';
4
4
  import type { Licks } from '../licks/licks.ts';
5
5
  import type { Approvals } from './index.ts';
6
- import { type Approval, type ApprovalRequester, type SudoDetail, type SudoStdin } from './record.ts';
6
+ import { type Approval, type ApprovalRequester, type SudoDetail, type SudoFile, type SudoReplay, type SudoStdin } from './record.ts';
7
7
  export type SudoAnswer = 'once' | 'always' | 'deny';
8
8
  export type SudoDenial = {
9
9
  answer: 'deny';
@@ -32,6 +32,7 @@ export interface SudoRequest {
32
32
  always?: boolean;
33
33
  stdin?: SudoStdin;
34
34
  rootOnly?: Record<string, boolean>;
35
+ userWritable?: SudoFile[];
35
36
  timestamp?: boolean;
36
37
  validate?: boolean;
37
38
  }
@@ -56,6 +57,7 @@ export declare function sudoRequester(request: SudoRequest, agents: Readonly<Age
56
57
  export declare const validating: (request: Pick<SudoRequest, 'validate'>) => boolean;
57
58
  export declare const timestampFor: (user: string) => string;
58
59
  export declare function sudoDetail(request: SudoRequest): SudoDetail;
60
+ export declare function sudoReplay(request: SudoRequest): SudoReplay;
59
61
  export interface SudoAttach {
60
62
  approvals: Approvals;
61
63
  capture: AgentCapture;
@@ -2,6 +2,7 @@ import { type Context, type Host, type ReplicatedState } from '@earendil-works/c
2
2
  import type { ConversationView } from '@earendil-works/pi-durable';
3
3
  import type { ApprovalPolicy } from './approvals/policy.ts';
4
4
  import type { Approval } from './approvals/record.ts';
5
+ import type { Runnable } from './approvals/runnable.ts';
5
6
  import type { ChangesView } from './changes/git.ts';
6
7
  import type { FrozenCone } from './freezer/index.ts';
7
8
  import type { ImportProgress } from './freezer/v6.ts';
@@ -39,6 +40,7 @@ export interface AgentConnection {
39
40
  readonly owner?: boolean;
40
41
  readonly approvals?: ReplicatedState<Approval[]>;
41
42
  readonly approvalPolicy?: ReplicatedState<ApprovalPolicy>;
43
+ readonly approvalRunnable?: ReplicatedState<Record<string, Runnable>>;
42
44
  readonly settings: AgentSettings;
43
45
  readonly remote?: AgentRemote;
44
46
  readonly history?: boolean;
@@ -3,6 +3,7 @@ import type { ConversationView } from '@earendil-works/pi-durable';
3
3
  import type { Agent } from './agent.ts';
4
4
  import { type ApprovalJudge, type Approvals, type Attendance, type Decider } from './approvals/index.ts';
5
5
  import { type ApprovalPolicies } from './approvals/policy.ts';
6
+ import type { RunKernel, Runner, SudoRunHost } from './approvals/run.ts';
6
7
  import { type AgentSudo } from './approvals/sudo.ts';
7
8
  import type { ChangesRuntime } from './changes/index.ts';
8
9
  import { type HostLicks, type HostScoops } from './control.ts';
@@ -95,13 +96,21 @@ export type HostOptions = {
95
96
  uploads?: Uploads;
96
97
  thumbnail?: Thumbnail;
97
98
  labels?: LabelsRuntime;
99
+ runs?: {
100
+ kernel: RunKernel & {
101
+ protocol?: readonly number[];
102
+ };
103
+ boot: string | null;
104
+ } & RunTimes;
98
105
  } & ApprovalOptions;
106
+ export type RunTimes = Partial<Pick<SudoRunHost, 'pollMs' | 'killMs' | 'adoptMs' | 'outputCap' | 'keepMs'>>;
99
107
  export declare function hostAgent(agent: Agent, options?: HostOptions): Promise<AgentHost>;
100
108
  interface Served {
101
109
  trusted: AgentControl;
102
110
  viewed: () => AgentControl;
103
111
  transcript: Record<keyof AgentTranscript, ReplicatedState<unknown>>;
104
112
  viewMonitor: ReplicatedState<unknown>;
113
+ viewApprovals: ReplicatedState<unknown>;
105
114
  sudo?: AgentSudo;
106
115
  settings: AgentSettings;
107
116
  remote: AgentRemote;
@@ -112,6 +121,7 @@ interface Served {
112
121
  dispose(): void;
113
122
  } | undefined;
114
123
  decide: (by: Decider) => AgentControl['decide'];
124
+ runs: (runner: Runner) => Pick<AgentControl, 'approvalRun' | 'approvalRunStop'>;
115
125
  owners?: Attendance;
116
126
  }
117
127
  export declare const CLOSED_TO_GUESTS = "a guest seat has only its transcript and propose";
@@ -1,7 +1,10 @@
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
3
  export { APPROVAL_MS, type Approval, type ApprovalAnswer, type ApprovalDecided, type ApprovalDecision, type ApprovalDraft, type ApprovalJudge, type ApprovalKind, type ApprovalRequester, type ApprovalState, type Approvals, ApprovalsDoc, type ApprovalTier, type ApprovalVerdict, ASK_MIN_MS, approvalJudge, attachApprovals, type CaptureApproval, type CaptureDetail, DEFAULT_POLICY, type DecidedBy, type Decider, JUDGE_ALLOW, JUDGE_KIND, JUDGE_MODEL, JUDGE_QUESTIONS, type Judgement, judgeModelOf, judgeSpender, judgeState, type OwnerIntent, ownerIntent, POLICY_FILE, REASONS, route, seedPolicy, VERDICT_REASONS, verdictOf, verdictRecorder, } from './approvals/index.ts';
4
- export { type ApprovalPolicy, type ApprovalPolicyChange, type ApprovalPolicySet, DEFAULT_APPROVAL_POLICY, type SudoPolicy, } from './approvals/policy.ts';
4
+ export { type ApprovalPolicy, type ApprovalPolicyChange, type ApprovalPolicySet, DEFAULT_APPROVAL_POLICY, type RunLatePolicy, type SudoPolicy, type SudoPolicyChange, } from './approvals/policy.ts';
5
+ export type { SudoFile, SudoReplay, SudoRun, SudoRunState } from './approvals/record.ts';
6
+ export { RUN_ERRORS, type RunAnswer, SUDO_RUN_TASK, } from './approvals/run.ts';
7
+ export { RUN_REASONS, type RunGates, type Runnable, runnable, SUDO_RUN_PROTOCOL, } from './approvals/runnable.ts';
5
8
  export type { AgentSudo, SudoAnswer, SudoDenial, SudoReply, SudoRequest, SudoTimestamp, } from './approvals/sudo.ts';
6
9
  export type { CaptureAsk } from './approvals/sudo-client.ts';
7
10
  export { FILE_LIMIT, IMAGE_LIMIT, type SendAttachment, type ShownAttachment, splitUser, TOTAL_LIMIT, userParts, } from './attachments.ts';
@@ -40,6 +40,7 @@ export interface KernelProcess {
40
40
  }
41
41
  export interface SpawnOptions {
42
42
  cwd?: string;
43
+ user?: string | number;
43
44
  env?: Record<string, string>;
44
45
  pgid?: number;
45
46
  tag?: string;
@@ -47,8 +48,42 @@ export interface SpawnOptions {
47
48
  onStdout?(bytes: Uint8Array): void;
48
49
  onStderr?(bytes: Uint8Array): void;
49
50
  }
51
+ export interface TraceExit {
52
+ type: 'exit';
53
+ pid: number;
54
+ status: number;
55
+ signal?: string;
56
+ at?: number;
57
+ }
58
+ export type TraceEvent = TraceExit | {
59
+ type: 'exec' | 'fork';
60
+ pid: number;
61
+ };
62
+ export interface SudoRunOptions {
63
+ stdout?: string;
64
+ stderr?: string;
65
+ tag?: string | string[];
66
+ }
67
+ export interface SudoRunning {
68
+ pid: number;
69
+ pgid: number;
70
+ ended: Promise<{
71
+ status: number;
72
+ signal?: string;
73
+ }>;
74
+ }
50
75
  export interface KernelClient {
51
76
  fs: KernelFs;
77
+ protocol?: readonly number[];
78
+ sudoRun?(request: object, options: SudoRunOptions): Promise<SudoRunning>;
79
+ trace?(tag: string, onEvents: (batch: {
80
+ events: TraceEvent[];
81
+ dropped: number;
82
+ }) => void | Promise<unknown>, options?: {
83
+ limit?: number;
84
+ }): Promise<{
85
+ close(): void;
86
+ }>;
52
87
  spawn(argv: readonly string[], options: SpawnOptions): Promise<KernelProcess>;
53
88
  kill?(pid: number, signal?: string): Promise<void>;
54
89
  ps?(): Promise<readonly {
@@ -1,4 +1,4 @@
1
- export declare const LICK_CHANNELS: readonly ['webhook', 'cron', 'sprinkle', 'fswatch', 'session-reload', 'navigate', 'discovery', 'upgrade', 'workflow', 'bash', 'jshd', 'preview', 'cherry', 'scoop-notify', 'scoop-idle', 'scoop-wait', 'sudo-request', 'cone-message'];
1
+ export declare const LICK_CHANNELS: readonly ['webhook', 'cron', 'sprinkle', 'fswatch', 'session-reload', 'navigate', 'discovery', 'upgrade', 'workflow', 'bash', 'jshd', 'preview', 'cherry', 'scoop-notify', 'scoop-idle', 'scoop-wait', 'sudo-request', 'sudo-run', 'cone-message'];
2
2
  export type LickChannel = (typeof LICK_CHANNELS)[number];
3
3
  export type LickAction = 'confirm' | 'dismiss';
4
4
  export type LickSeverity = 'warn' | 'error';
@@ -27,7 +27,7 @@ export declare function skipEntry(event: LickEvent, verdict: Verdict, now: numbe
27
27
  probabilities: Record<string, number>;
28
28
  model: string;
29
29
  cost: number | null;
30
- channel: "bash" | "cherry" | "cone-message" | "cron" | "discovery" | "fswatch" | "jshd" | "navigate" | "preview" | "scoop-idle" | "scoop-notify" | "scoop-wait" | "session-reload" | "sprinkle" | "sudo-request" | "upgrade" | "webhook" | "workflow";
30
+ channel: "bash" | "cherry" | "cone-message" | "cron" | "discovery" | "fswatch" | "jshd" | "navigate" | "preview" | "scoop-idle" | "scoop-notify" | "scoop-wait" | "session-reload" | "sprinkle" | "sudo-request" | "sudo-run" | "upgrade" | "webhook" | "workflow";
31
31
  source: string;
32
32
  title: string;
33
33
  text: string;
@@ -2,7 +2,7 @@ import type { Provider } from '@earendil-works/pi-ai';
2
2
  import type { Models } from '@earendil-works/pi-ai/models';
3
3
  import { type ModelRef, type Storage, type ToolRegistration } from '@earendil-works/pi-durable';
4
4
  import { codemodeTool } from './codemode/index.ts';
5
- import { type AgentHost } from './host.ts';
5
+ import { type AgentHost, type RunTimes } from './host.ts';
6
6
  import type { KernelClient } from './kernel/client.ts';
7
7
  import { type UserClients } from './kernel/users.ts';
8
8
  import { type Transport } from './net.ts';
@@ -36,6 +36,7 @@ export interface AgentWorkerOptions {
36
36
  mcpRedirect?: string;
37
37
  approvalMs?: number;
38
38
  stagedMs?: number;
39
+ runTimes?: RunTimes;
39
40
  }
40
41
  export declare function usersOf(admin: MessagePort | undefined, wanted: boolean | undefined, attach: KernelAttach): UserClients | undefined;
41
42
  export declare const STORE_DIR = "/.slicc";
@@ -2,6 +2,8 @@ import type { Context, JsonValue, RemoteContract, ReplicatedState } from '@earen
2
2
  import type { BlockedReason, ConversationView } from '@earendil-works/pi-durable';
3
3
  import type { Approval, ApprovalDecided, ApprovalDecision } from './approvals/index.ts';
4
4
  import type { ApprovalPolicy, ApprovalPolicyChange, ApprovalPolicySet } from './approvals/policy.ts';
5
+ import type { RunAnswer } from './approvals/run.ts';
6
+ import type { Runnable } from './approvals/runnable.ts';
5
7
  import type { SendAttachment, ShownAttachment } from './attachments.ts';
6
8
  import type { ChangesView } from './changes/git.ts';
7
9
  import type { FrozenCone } from './freezer/index.ts';
@@ -108,6 +110,8 @@ export interface AgentControl {
108
110
  }>;
109
111
  approvalPolicySet(change: ApprovalPolicyChange, context: Context): Promise<ApprovalPolicySet>;
110
112
  decide(id: string, decision: ApprovalDecision, reason: string | null, context: Context): Promise<ApprovalDecided>;
113
+ approvalRun(id: string, context: Context): Promise<RunAnswer>;
114
+ approvalRunStop(id: string, context: Context): Promise<RunAnswer>;
111
115
  }
112
116
  export interface ImportRequest {
113
117
  upload: string | null;
@@ -279,7 +283,7 @@ export interface AgentSettingsChange {
279
283
  thinkingLevel: 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | null;
280
284
  agentId?: string | null;
281
285
  }
282
- export declare const CONTROL_METHODS: ("abort" | "agentCommands" | "approvalPolicySet" | "changeAccept" | "changeRevert" | "changesOpen" | "compact" | "compactAgent" | "configure" | "createCone" | "createScoop" | "decide" | "discard" | "drop" | "entries" | "freeze" | "guestAlwaysForget" | "guestOpen" | "guestRevoke" | "image" | "importCancel" | "importProfile" | "memoryRemove" | "memorySave" | "monitorClose" | "monitorOpen" | "newChat" | "reset" | "resolveAgentLick" | "resolveLick" | "rewind" | "rewindAgent" | "selectCone" | "send" | "sprinkleCall" | "sprinkleSend" | "stepLabel" | "stopAgent" | "thaw" | "toolLabel" | "unqueue" | "wait" | "webhook" | "withdraw")[];
286
+ export declare const CONTROL_METHODS: ("abort" | "agentCommands" | "approvalPolicySet" | "approvalRun" | "approvalRunStop" | "changeAccept" | "changeRevert" | "changesOpen" | "compact" | "compactAgent" | "configure" | "createCone" | "createScoop" | "decide" | "discard" | "drop" | "entries" | "freeze" | "guestAlwaysForget" | "guestOpen" | "guestRevoke" | "image" | "importCancel" | "importProfile" | "memoryRemove" | "memorySave" | "monitorClose" | "monitorOpen" | "newChat" | "reset" | "resolveAgentLick" | "resolveLick" | "rewind" | "rewindAgent" | "selectCone" | "send" | "sprinkleCall" | "sprinkleSend" | "stepLabel" | "stopAgent" | "thaw" | "toolLabel" | "unqueue" | "wait" | "webhook" | "withdraw")[];
283
287
  export declare const OWNER_DEVICE_METHODS: readonly (keyof AgentControl & string)[];
284
288
  export declare const CONTROL_READS: readonly (keyof AgentControl & string)[];
285
289
  export declare const AgentControl: RemoteContract;
@@ -303,6 +307,7 @@ export interface AgentTranscript {
303
307
  readonly guests: ReplicatedState<GuestSeat[]>;
304
308
  readonly approvals: ReplicatedState<Approval[]>;
305
309
  readonly approvalPolicy: ReplicatedState<ApprovalPolicy>;
310
+ readonly approvalRunnable: ReplicatedState<Record<string, Runnable>>;
306
311
  }
307
312
  export interface PrivateRevision {
308
313
  revision: number;
@@ -314,7 +319,7 @@ export interface Command {
314
319
  source?: SkillSource;
315
320
  package?: SkillPackage;
316
321
  }
317
- export declare const TRANSCRIPT_STATES: ("agents" | "approvalPolicy" | "approvals" | "changes" | "commands" | "deliveries" | "frozen" | "guests" | "importing" | "labels" | "memories" | "memoryScopes" | "monitor" | "privateRevision" | "sprinkles" | "state" | "vault" | "views")[];
322
+ export declare const TRANSCRIPT_STATES: ("agents" | "approvalPolicy" | "approvalRunnable" | "approvals" | "changes" | "commands" | "deliveries" | "frozen" | "guests" | "importing" | "labels" | "memories" | "memoryScopes" | "monitor" | "privateRevision" | "sprinkles" | "state" | "vault" | "views")[];
318
323
  export declare const AgentTranscript: RemoteContract;
319
324
  export declare const REMOTE_METHODS: ("abort" | "close" | "history" | "next" | "prompt" | "watch")[];
320
325
  export declare const REMOTE_READS: readonly (keyof AgentRemote & string)[];
@@ -1,14 +1,22 @@
1
- import type { Approval, ApprovalDecision, ApprovalsEvents, ApprovalsPort } from '@ai-ecoverse/slicc-spectrum/ui';
2
- import type { Approval as Item } from '../approvals/record.ts';
1
+ import type { Approval, ApprovalDecision, ApprovalRecord, ApprovalRun, ApprovalsEvents, ApprovalsPort } from '@ai-ecoverse/slicc-spectrum/ui';
2
+ import type { Approval as Item, SudoRun } from '../approvals/record.ts';
3
+ import type { Runnable } from '../approvals/runnable.ts';
3
4
  import type { AgentConnection } from '../client.ts';
4
5
  import { Emitter } from './emitter.ts';
5
6
  export declare const ARGS_LENGTH = 65536;
6
7
  export declare function shown(item: Item, agentName: string | undefined): Approval;
7
8
  export type HostApprovals = ApprovalsPort;
9
+ export declare function runShown(run: SudoRun): ApprovalRun & {
10
+ survivors?: number[];
11
+ };
12
+ export declare function recordOf(item: Item, agentName: string | undefined, runnable: Runnable | undefined): ApprovalRecord;
8
13
  export declare const NOT_HERE = "This request can't be answered in this tab.";
9
14
  export declare class ApprovalsAdapter extends Emitter<ApprovalsEvents> implements ApprovalsPort {
10
15
  #private;
11
16
  readonly decide?: (id: string, decision: ApprovalDecision, reason?: string) => Promise<void>;
17
+ readonly history?: () => readonly ApprovalRecord[];
18
+ readonly run?: (id: string) => Promise<void>;
19
+ readonly stopRun?: (id: string) => Promise<void>;
12
20
  constructor(connection: AgentConnection, host?: HostApprovals);
13
21
  list(): readonly Approval[];
14
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-agent",
3
- "version": "7.31.0",
3
+ "version": "7.32.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",
@@ -76,7 +76,7 @@
76
76
  "@ai-ecoverse/slicc-kernel": "1.181.0",
77
77
  "@ai-ecoverse/slicc-scrub": "1.1.0",
78
78
  "@ai-ecoverse/slicc-shared-web": "2.14.2",
79
- "@ai-ecoverse/slicc-spectrum": "2.12.0",
79
+ "@ai-ecoverse/slicc-spectrum": "2.14.0",
80
80
  "@ai-ecoverse/wasi-fnox": "1.47.0-1",
81
81
  "@ai-ecoverse/wasm-bash": "5.3.0-23",
82
82
  "@ai-ecoverse/wasm-coreutils": "9.12.0-15",
@@ -112,7 +112,7 @@
112
112
  },
113
113
  "peerDependencies": {
114
114
  "@ai-ecoverse/slicc-kernel": ">=1.172.2 <2",
115
- "@ai-ecoverse/slicc-spectrum": "^2.4.1"
115
+ "@ai-ecoverse/slicc-spectrum": "^2.14.0"
116
116
  },
117
117
  "peerDependenciesMeta": {
118
118
  "@ai-ecoverse/slicc-spectrum": {