@ai-ecoverse/slicc-agent 7.16.0 → 7.17.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 +17 -15
- package/dist/approvals/index.js +88 -42
- package/dist/approvals/index.js.map +2 -2
- package/dist/approvals/intent.js +6 -2
- package/dist/approvals/intent.js.map +2 -2
- package/dist/approvals/judge.js +257 -83
- package/dist/approvals/judge.js.map +2 -2
- package/dist/approvals/present.js +1 -6
- package/dist/approvals/present.js.map +2 -2
- package/dist/approvals/record.js +20 -0
- package/dist/approvals/record.js.map +2 -2
- package/dist/approvals/sudo.js +19 -2
- package/dist/approvals/sudo.js.map +2 -2
- package/dist/index.js +2 -4
- package/dist/index.js.map +2 -2
- package/dist/sprinkles/cgi-run.js +3 -5
- package/dist/sprinkles/cgi-run.js.map +2 -2
- package/dist/titles/generate.js +19 -19
- package/dist/titles/generate.js.map +2 -2
- package/dist/types/approvals/intent.d.ts +4 -1
- package/dist/types/approvals/judge.d.ts +52 -25
- package/dist/types/approvals/present.d.ts +2 -2
- package/dist/types/approvals/record.d.ts +20 -2
- package/dist/types/approvals/sudo.d.ts +3 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/titles/generate.d.ts +5 -2
- package/package.json +6 -6
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import type { Context } from '@earendil-works/chord';
|
|
2
|
-
import type { ClassifierQuestion, ClassifierResult } from '@earendil-works/pi-ai';
|
|
2
|
+
import type { AssistantMessage, ClassifierQuestion, ClassifierResult } from '@earendil-works/pi-ai';
|
|
3
3
|
import type { Models } from '@earendil-works/pi-ai/models';
|
|
4
4
|
import type { Conversation, ModelRef } from '@earendil-works/pi-durable';
|
|
5
|
-
import type
|
|
5
|
+
import { type Approval, type ApprovalLevel, type ApprovalVerdict } from './record.ts';
|
|
6
6
|
export declare const JUDGE_KIND = "slicc.approval-verdict";
|
|
7
7
|
export declare const JUDGE_MODEL: ModelRef;
|
|
8
|
-
export declare const
|
|
9
|
-
export declare const
|
|
8
|
+
export declare const JUDGE_ALWAYS = 0.8;
|
|
9
|
+
export declare const JUDGE_SURE = 0.6;
|
|
10
10
|
export declare const JUDGE_TIMEOUT = 15000;
|
|
11
11
|
export declare const ASK_MIN_MS = 30000;
|
|
12
12
|
export declare const UNTRUSTED_LIMIT = 4000;
|
|
13
|
-
export
|
|
13
|
+
export declare const VERDICT_REASON_LENGTH = 300;
|
|
14
|
+
export declare const JUDGE_TOKENS = 300;
|
|
15
|
+
export declare const JUDGE_LATE = "the check didn't answer in time";
|
|
16
|
+
export declare const JUDGE_RESTARTED = "the agent restarted before the check answered";
|
|
17
|
+
export type Reasoned = {
|
|
18
|
+
reason?: string;
|
|
19
|
+
cost?: number | null;
|
|
20
|
+
};
|
|
14
21
|
export interface Judgement {
|
|
15
|
-
outcome: JudgeOutcome;
|
|
16
22
|
verdict?: ApprovalVerdict;
|
|
17
23
|
error?: string;
|
|
18
24
|
cost?: number | null;
|
|
25
|
+
reason?: Promise<Reasoned>;
|
|
19
26
|
}
|
|
20
27
|
export interface ApprovalJudge {
|
|
21
28
|
judge(item: Approval, context: Context): Promise<Judgement>;
|
|
@@ -25,38 +32,43 @@ export type OwnerIntent = {
|
|
|
25
32
|
policy: string;
|
|
26
33
|
messages: string[];
|
|
27
34
|
memory: string[];
|
|
35
|
+
model?: ModelRef;
|
|
28
36
|
};
|
|
37
|
+
export type Spent = Pick<ClassifierResult | AssistantMessage, 'provider' | 'model' | 'usage'>;
|
|
29
38
|
export interface JudgeOptions {
|
|
30
|
-
models: Pick<Models, 'getModelOfType' | 'classify'>;
|
|
39
|
+
models: Pick<Models, 'getModelOfType' | 'classify' | 'getModel' | 'completeSimple'>;
|
|
31
40
|
model(context: Context): Promise<ModelRef | null>;
|
|
32
41
|
intent(item: Approval, context: Context): Promise<OwnerIntent | null>;
|
|
33
42
|
nonce?: () => string;
|
|
34
43
|
timeoutMs?: number;
|
|
35
|
-
spend?(item: Approval, result:
|
|
44
|
+
spend?(item: Approval, result: Spent, context: Context): Promise<void>;
|
|
36
45
|
}
|
|
37
46
|
export declare const VERDICT_REASONS: {
|
|
38
|
-
readonly
|
|
39
|
-
readonly
|
|
40
|
-
readonly
|
|
41
|
-
readonly
|
|
42
|
-
|
|
43
|
-
|
|
47
|
+
readonly routine: 'it looks like routine work that fits what the owner asked for.';
|
|
48
|
+
readonly routineUnaligned: "it looks like routine work, but it isn't clear it serves what the owner asked for.";
|
|
49
|
+
readonly permissions: 'it changes who may do what.';
|
|
50
|
+
readonly harm: 'it could harm the system or the work in a way that is hard to undo.';
|
|
51
|
+
};
|
|
52
|
+
export declare const LEVELS: {
|
|
53
|
+
readonly routine: "a sysadmin would approve this as normal work: it reads, builds, installs, or changes files and services in the course of the work, including reaching outside the session (push, publish, post, message someone), and it doesn't change who may do what; whether the owner wanted that is the aligned question, not the level";
|
|
54
|
+
readonly permissions: 'it changes who may do what: sudoers, users and groups, ownership or modes of system files, secret rules (/etc/fnox, /etc/slicc/secrets-policy.toml), the approvals policy, guest seats, credentials and tokens';
|
|
55
|
+
readonly harm: "it would damage the system or the work in a way that is hard to undo: delete or overwrite system files or others' work, lock the owner out, or expose secrets or private work to anyone but the owner";
|
|
44
56
|
};
|
|
45
57
|
export declare const JUDGE_QUESTIONS: Record<string, ClassifierQuestion>;
|
|
58
|
+
export declare function questionsOf(item: Approval): Record<string, ClassifierQuestion>;
|
|
46
59
|
export declare function fenced(text: string, nonce: string): string;
|
|
47
60
|
export declare function untrustedOf(item: Approval): string;
|
|
61
|
+
export type SudoFacts = {
|
|
62
|
+
stdin: string | null;
|
|
63
|
+
writable: boolean | null;
|
|
64
|
+
rootOnly: boolean | null;
|
|
65
|
+
};
|
|
48
66
|
export declare function sudoContext(item: Approval): {
|
|
49
|
-
sudo?:
|
|
50
|
-
target: string;
|
|
51
|
-
cwd: string | null;
|
|
52
|
-
};
|
|
67
|
+
sudo?: SudoFacts;
|
|
53
68
|
};
|
|
54
69
|
export declare function judgeState(item: Approval, intent: OwnerIntent, nonce: string): {
|
|
55
70
|
request: {
|
|
56
|
-
sudo?:
|
|
57
|
-
target: string;
|
|
58
|
-
cwd: string | null;
|
|
59
|
-
};
|
|
71
|
+
sudo?: SudoFacts;
|
|
60
72
|
kind: "guest-message" | "guest-tool" | "sudo";
|
|
61
73
|
requester: {
|
|
62
74
|
kind: "agent" | "guest" | "user";
|
|
@@ -70,8 +82,19 @@ export declare function judgeState(item: Approval, intent: OwnerIntent, nonce: s
|
|
|
70
82
|
memory: string[];
|
|
71
83
|
};
|
|
72
84
|
};
|
|
85
|
+
export declare function levelOf(probabilities: Record<string, number>): ApprovalLevel | undefined;
|
|
86
|
+
export declare function fallbackReason(level: ApprovalLevel, aligned: ApprovalVerdict['aligned']): string;
|
|
87
|
+
export declare function decisionOf(verdict: Omit<ApprovalVerdict, 'decision' | 'reason'>): ApprovalVerdict['decision'];
|
|
73
88
|
export declare function verdictOf(result: ClassifierResult, model: string): Judgement;
|
|
74
|
-
export declare
|
|
89
|
+
export declare function cleanVerdictReason(text: string): Promise<string | undefined>;
|
|
90
|
+
export declare function judgePrompt(item: Approval, chat: boolean): string;
|
|
91
|
+
export declare function chatAnswer(text: string): {
|
|
92
|
+
level: ApprovalLevel;
|
|
93
|
+
aligned: boolean;
|
|
94
|
+
always: boolean;
|
|
95
|
+
reason: string;
|
|
96
|
+
} | undefined;
|
|
97
|
+
export declare function chatVerdict(item: Approval, text: string, model: string): Promise<ApprovalVerdict | undefined>;
|
|
75
98
|
export declare function judgeModelOf(text: string | undefined): ModelRef | null;
|
|
76
99
|
export declare function approvalJudge(options: JudgeOptions): ApprovalJudge['judge'];
|
|
77
100
|
export declare function verdictEntry(item: Approval, judgement: Judgement, at: number): {
|
|
@@ -80,10 +103,14 @@ export declare function verdictEntry(item: Approval, judgement: Judgement, at: n
|
|
|
80
103
|
entry: {
|
|
81
104
|
kind: string;
|
|
82
105
|
data: {
|
|
83
|
-
|
|
106
|
+
level?: ApprovalLevel;
|
|
107
|
+
routine?: number;
|
|
108
|
+
aligned?: number | boolean;
|
|
109
|
+
always?: boolean;
|
|
84
110
|
reason?: string | undefined;
|
|
111
|
+
via?: 'classifier' | 'chat';
|
|
112
|
+
decision?: "allow" | "deny" | "unsure" | undefined;
|
|
85
113
|
risk?: number;
|
|
86
|
-
aligned?: number;
|
|
87
114
|
model?: string;
|
|
88
115
|
approval: string;
|
|
89
116
|
kind: "guest-message" | "guest-tool" | "sudo";
|
|
@@ -8,6 +8,6 @@ export interface Attendance {
|
|
|
8
8
|
export declare function attendance(): Attendance;
|
|
9
9
|
export interface PresenceSources {
|
|
10
10
|
attended(): boolean;
|
|
11
|
-
agents
|
|
11
|
+
agents?: Pick<IntentSources['agents'], 'state'>;
|
|
12
12
|
}
|
|
13
|
-
export declare function ownerPresent(sources: PresenceSources): (
|
|
13
|
+
export declare function ownerPresent(sources: PresenceSources): (_item: Approval, _context: Context) => Promise<boolean>;
|
|
@@ -11,11 +11,16 @@ export type ApprovalRequester = {
|
|
|
11
11
|
where?: string;
|
|
12
12
|
device?: string;
|
|
13
13
|
};
|
|
14
|
+
export type ApprovalLevel = 1 | 2 | 3;
|
|
14
15
|
export type ApprovalVerdict = {
|
|
15
|
-
|
|
16
|
+
level?: ApprovalLevel;
|
|
17
|
+
routine?: number;
|
|
18
|
+
aligned?: number | boolean;
|
|
19
|
+
always?: boolean;
|
|
16
20
|
reason: string;
|
|
21
|
+
via?: 'classifier' | 'chat';
|
|
22
|
+
decision: 'allow' | 'deny' | 'unsure';
|
|
17
23
|
risk?: number;
|
|
18
|
-
aligned?: number;
|
|
19
24
|
model?: string;
|
|
20
25
|
};
|
|
21
26
|
export type ApprovalAttachment = {
|
|
@@ -33,11 +38,15 @@ export type GuestToolDetail = {
|
|
|
33
38
|
arguments?: string;
|
|
34
39
|
task?: number;
|
|
35
40
|
};
|
|
41
|
+
export type SudoStdin = 'tty' | 'none' | 'pipe' | 'file';
|
|
36
42
|
export type SudoDetail = {
|
|
37
43
|
command: string;
|
|
38
44
|
target?: string;
|
|
39
45
|
cwd?: string;
|
|
40
46
|
alwaysScope?: 'cwd';
|
|
47
|
+
stdin?: SudoStdin;
|
|
48
|
+
rootOnly?: Record<string, boolean>;
|
|
49
|
+
writable?: boolean;
|
|
41
50
|
};
|
|
42
51
|
type Base = {
|
|
43
52
|
id: string;
|
|
@@ -52,6 +61,8 @@ type Base = {
|
|
|
52
61
|
reviewer?: string;
|
|
53
62
|
reason?: string;
|
|
54
63
|
verdict?: ApprovalVerdict;
|
|
64
|
+
judging?: boolean;
|
|
65
|
+
verdictError?: string;
|
|
55
66
|
always: boolean;
|
|
56
67
|
createdAt: number;
|
|
57
68
|
expiresAt: number;
|
|
@@ -109,6 +120,13 @@ export declare function answerer(by: DecidedBy, item: Pick<Approval, 'tier' | 'r
|
|
|
109
120
|
export type SudoApprover = 'user' | 'agent';
|
|
110
121
|
export declare const sudoApprover: (value: unknown) => SudoApprover;
|
|
111
122
|
export declare const tierOf: (kind: ApprovalKind, tier: string, sudo: SudoApprover) => string;
|
|
123
|
+
export declare const JUDGE_ALLOW = 0.8;
|
|
124
|
+
export type Gate = 'person' | 'judge';
|
|
125
|
+
export type Routed = 'approve' | 'deny' | 'ask';
|
|
126
|
+
export declare const gateOf: (tier: string) => Gate;
|
|
127
|
+
export declare const fits: (aligned: ApprovalVerdict['aligned']) => boolean;
|
|
128
|
+
export declare function route(verdict: ApprovalVerdict | undefined, requester: Pick<ApprovalRequester, 'kind'>, gate: Gate, present: boolean): Routed;
|
|
129
|
+
export declare function alwaysOffered(item: Approval): boolean;
|
|
112
130
|
export declare function gone(state: ApprovalState): string;
|
|
113
131
|
export declare function cleanReason(reason: unknown): string | undefined;
|
|
114
132
|
export declare function prune(items: Approval[], kept?: number): Approval[];
|
|
@@ -2,7 +2,7 @@ import type { Context, ReplicatedState } from '@earendil-works/chord';
|
|
|
2
2
|
import type { AgentsState } from '../agents.ts';
|
|
3
3
|
import type { Licks } from '../licks/licks.ts';
|
|
4
4
|
import type { Approvals } from './index.ts';
|
|
5
|
-
import { type Approval, type ApprovalRequester, type SudoDetail } from './record.ts';
|
|
5
|
+
import { type Approval, type ApprovalRequester, type SudoDetail, type SudoStdin } from './record.ts';
|
|
6
6
|
export type SudoAnswer = 'once' | 'always' | 'deny';
|
|
7
7
|
export type SudoDenial = {
|
|
8
8
|
answer: 'deny';
|
|
@@ -25,6 +25,8 @@ export interface SudoRequest {
|
|
|
25
25
|
createdAt?: number;
|
|
26
26
|
expiresAt: number;
|
|
27
27
|
always?: boolean;
|
|
28
|
+
stdin?: SudoStdin;
|
|
29
|
+
rootOnly?: Record<string, boolean>;
|
|
28
30
|
}
|
|
29
31
|
export type SudoAsked = {
|
|
30
32
|
id: string;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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, ASK_MIN_MS, approvalJudge, attachApprovals, DEFAULT_POLICY, type DecidedBy, type Decider, JUDGE_ALLOW,
|
|
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, ASK_MIN_MS, approvalJudge, attachApprovals, 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
4
|
export { type ApprovalPolicy, type ApprovalPolicyChange, type ApprovalPolicySet, DEFAULT_APPROVAL_POLICY, type SudoPolicy, } from './approvals/policy.ts';
|
|
5
5
|
export type { AgentSudo, SudoAnswer, SudoDenial, SudoReply, SudoRequest, } from './approvals/sudo.ts';
|
|
6
6
|
export { FILE_LIMIT, IMAGE_LIMIT, type SendAttachment, type ShownAttachment, splitUser, TOTAL_LIMIT, userParts, } from './attachments.ts';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Context } from '@earendil-works/chord';
|
|
2
|
-
import type { AssistantMessage } from '@earendil-works/pi-ai';
|
|
2
|
+
import type { Api, AssistantMessage, Model } from '@earendil-works/pi-ai';
|
|
3
3
|
import type { Models } from '@earendil-works/pi-ai/models';
|
|
4
4
|
import type { EntryRecord } from '@earendil-works/pi-durable';
|
|
5
5
|
import type { ExecutionEnv } from '@earendil-works/pi-durable/env';
|
|
@@ -10,13 +10,16 @@ export declare function titlesOn(text: string | undefined): boolean;
|
|
|
10
10
|
export declare function labelsOn(text: string | undefined): boolean;
|
|
11
11
|
export declare function settingsText(env: Pick<ExecutionEnv, 'readTextFile'>, home: string, dir?: string): (context: Context) => Promise<string | undefined>;
|
|
12
12
|
export declare function transcriptOf(entries: readonly EntryRecord[]): string;
|
|
13
|
-
export declare function scrubbed(raw: string): Promise<string>;
|
|
13
|
+
export declare function scrubbed(raw: string, limit?: number): Promise<string>;
|
|
14
14
|
export declare function scrubTranscript(entries: readonly EntryRecord[]): Promise<string>;
|
|
15
15
|
type Settings = (context: Context) => Promise<string | undefined>;
|
|
16
16
|
export type Asked = {
|
|
17
17
|
text: string;
|
|
18
18
|
answer: AssistantMessage;
|
|
19
19
|
};
|
|
20
|
+
export declare function completeText(models: Pick<Models, 'completeSimple'>, found: Model<Api>, text: string, max: number, options?: {
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
}): Promise<Asked | undefined>;
|
|
20
23
|
export declare function titler(models: Models, settings: Settings): (transcript: string, model: string, context: Context) => Promise<string | undefined>;
|
|
21
24
|
export declare function labeler(models: Models, settings: Settings): (transcript: string, model: string, context: Context, admit?: () => boolean) => Promise<Asked | undefined>;
|
|
22
25
|
export type Labeler = ReturnType<typeof labeler>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/slicc-agent",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.17.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",
|
|
@@ -72,11 +72,11 @@
|
|
|
72
72
|
"release": "semantic-release"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@ai-ecoverse/slicc-jsh": "0.
|
|
76
|
-
"@ai-ecoverse/slicc-kernel": "1.
|
|
75
|
+
"@ai-ecoverse/slicc-jsh": "0.64.0",
|
|
76
|
+
"@ai-ecoverse/slicc-kernel": "1.174.0",
|
|
77
77
|
"@ai-ecoverse/slicc-scrub": "1.1.0",
|
|
78
78
|
"@ai-ecoverse/slicc-shared-web": "2.13.10",
|
|
79
|
-
"@ai-ecoverse/slicc-spectrum": "1.
|
|
79
|
+
"@ai-ecoverse/slicc-spectrum": "1.112.0",
|
|
80
80
|
"@ai-ecoverse/wasi-fnox": "1.43.0-1",
|
|
81
81
|
"@ai-ecoverse/wasm-bash": "5.3.0-23",
|
|
82
82
|
"@ai-ecoverse/wasm-coreutils": "9.12.0-15",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"esbuild": "0.28.2",
|
|
87
87
|
"fake-indexeddb": "6.2.6",
|
|
88
88
|
"lefthook": "2.2.2",
|
|
89
|
-
"monocart-coverage-reports": "3.
|
|
89
|
+
"monocart-coverage-reports": "3.2.0",
|
|
90
90
|
"playwright-core": "1.64.1",
|
|
91
91
|
"semantic-release": "25.0.9",
|
|
92
92
|
"slicc-agent-5": "npm:@ai-ecoverse/slicc-agent@5.10.1",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"yaml": "2.9.1"
|
|
107
107
|
},
|
|
108
108
|
"peerDependencies": {
|
|
109
|
-
"@ai-ecoverse/slicc-kernel": ">=1.
|
|
109
|
+
"@ai-ecoverse/slicc-kernel": ">=1.172.2 <2",
|
|
110
110
|
"@ai-ecoverse/slicc-spectrum": "^1.103.0"
|
|
111
111
|
},
|
|
112
112
|
"peerDependenciesMeta": {
|