@ai-ecoverse/slicc-agent 7.16.1 → 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 +16 -14
- 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/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 +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/approvals/record.ts"],
|
|
4
|
-
"sourcesContent": ["import { defineDoc } from '@earendil-works/pi-durable';\nimport { boundedDeltas } from '../checkpoints.ts';\n\nexport type ApprovalKind = 'guest-message' | 'guest-tool' | 'sudo';\n\nexport type ApprovalState = 'pending' | 'approved' | 'rejected' | 'unanswered' | 'withdrawn';\n\nexport type ApprovalTier = 'user' | 'agent' | 'cone' | `scoop:${string}`;\n\nexport type ApprovalAnswer = 'once' | 'always' | 'deny';\n\nexport type DecidedBy = 'owner' | 'follower' | 'judge' | 'host' | `scoop:${string}`;\n\nexport type ApprovalRequester = {\n kind: 'guest' | 'agent' | 'user';\n name: string;\n seat?: string;\n agentId?: string;\n where?: string;\n device?: string;\n};\n\nexport type ApprovalVerdict = {\n decision: 'allow' | 'deny' | 'unsure';\n
|
|
5
|
-
"mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;
|
|
4
|
+
"sourcesContent": ["import { defineDoc } from '@earendil-works/pi-durable';\nimport { boundedDeltas } from '../checkpoints.ts';\n\nexport type ApprovalKind = 'guest-message' | 'guest-tool' | 'sudo';\n\nexport type ApprovalState = 'pending' | 'approved' | 'rejected' | 'unanswered' | 'withdrawn';\n\nexport type ApprovalTier = 'user' | 'agent' | 'cone' | `scoop:${string}`;\n\nexport type ApprovalAnswer = 'once' | 'always' | 'deny';\n\nexport type DecidedBy = 'owner' | 'follower' | 'judge' | 'host' | `scoop:${string}`;\n\nexport type ApprovalRequester = {\n kind: 'guest' | 'agent' | 'user';\n name: string;\n seat?: string;\n agentId?: string;\n where?: string;\n device?: string;\n};\n\nexport type ApprovalLevel = 1 | 2 | 3;\n\nexport type ApprovalVerdict = {\n level?: ApprovalLevel;\n routine?: number;\n aligned?: number | boolean;\n always?: boolean;\n reason: string;\n via?: 'classifier' | 'chat';\n decision: 'allow' | 'deny' | 'unsure';\n risk?: number;\n model?: string;\n};\n\nexport type ApprovalAttachment = { name: string; mimeType: string; size: number };\n\nexport type GuestMessageDetail = { text: string; attachments: ApprovalAttachment[] };\n\nexport type GuestToolDetail = { tool: string; summary: string; arguments?: string; task?: number };\n\nexport type SudoStdin = 'tty' | 'none' | 'pipe' | 'file';\n\nexport type SudoDetail = {\n command: string;\n target?: string;\n cwd?: string;\n alwaysScope?: 'cwd';\n stdin?: SudoStdin;\n rootOnly?: Record<string, boolean>;\n writable?: boolean;\n};\n\ntype Base = {\n id: string;\n seat?: string;\n agentId: string;\n requester: ApprovalRequester;\n tier: string;\n state: ApprovalState;\n decidedBy: DecidedBy | null;\n device?: string;\n answer?: 'once' | 'always';\n reviewer?: string;\n reason?: string;\n verdict?: ApprovalVerdict;\n judging?: boolean;\n verdictError?: string;\n always: boolean;\n createdAt: number;\n expiresAt: number;\n decidedAt?: number;\n};\n\nexport type GuestMessageApproval = Base & { kind: 'guest-message'; detail: GuestMessageDetail };\nexport type GuestToolApproval = Base & { kind: 'guest-tool'; detail: GuestToolDetail };\nexport type SudoApproval = Base & { kind: 'sudo'; detail: SudoDetail };\n\nexport type Approval = GuestMessageApproval | GuestToolApproval | SudoApproval;\n\ntype DraftOf<T extends Approval> = Pick<T, 'kind' | 'detail' | 'agentId' | 'requester'> & {\n seat?: string;\n tier: string;\n always?: boolean;\n expiresAt?: number;\n};\n\nexport type ApprovalDraft =\n | DraftOf<GuestMessageApproval>\n | DraftOf<GuestToolApproval>\n | DraftOf<SudoApproval>;\n\nexport type ApprovalsState = { items: Approval[] };\n\nexport const ApprovalsDoc = defineDoc<ApprovalsState>({\n kind: 'slicc.approvals',\n checkpointWhen: boundedDeltas,\n version: 1,\n scope: 'session',\n initial: () => ({ items: [] }),\n});\n\nexport const APPROVAL_MS = 300_000;\nexport const APPROVALS_KEPT = 100;\nexport const MAX_DELAY = 2_147_483_647;\nexport const REASON_LENGTH = 500;\n\nexport const REASONS = {\n timeout: 'timeout',\n unknownTier: 'unknown-tier',\n unroutable: 'unroutable',\n unknownAnswer: 'unknown-answer',\n restart: 'restart',\n revoked: 'revoked',\n aborted: 'aborted',\n disconnected: 'disconnected',\n noScoop: 'no-scoop',\n scoopStopped: 'scoop-stopped',\n scoopAsked: 'scoop-asked',\n scoopUndecided: 'scoop-undecided',\n} as const;\n\nexport const guestKind = (kind: ApprovalKind): boolean => kind !== 'sudo';\n\nexport const scoopTier = (tier: unknown): tier is `scoop:${string}` =>\n typeof tier === 'string' && /^scoop:\\S+$/.test(tier);\n\nexport function knownTier(tier: unknown): tier is ApprovalTier {\n if (tier === 'user' || tier === 'agent' || tier === 'cone') return true;\n return scoopTier(tier);\n}\n\nexport function routable(kind: ApprovalKind, tier: ApprovalTier): boolean {\n return !(kind === 'guest-tool' && tier === 'cone');\n}\n\nexport function answerOf(value: unknown): ApprovalAnswer | null {\n return value === 'once' || value === 'always' || value === 'deny' ? value : null;\n}\n\nexport const personal = (by: DecidedBy): boolean => by === 'owner' || by === 'follower';\n\nexport function answerer(by: DecidedBy, item: Pick<Approval, 'tier' | 'reviewer'>): boolean {\n if (personal(by)) return item.tier === 'user';\n if (by === 'judge') return item.tier === 'agent';\n if (scoopTier(by)) return scoopTier(item.tier) && item.reviewer === by;\n return true;\n}\n\nexport type SudoApprover = 'user' | 'agent';\n\nexport const sudoApprover = (value: unknown): SudoApprover =>\n value === 'agent' ? 'agent' : 'user';\n\nexport const tierOf = (kind: ApprovalKind, tier: string, sudo: SudoApprover): string =>\n kind === 'sudo' ? sudo : tier;\n\nexport const JUDGE_ALLOW = 0.8;\n\nexport type Gate = 'person' | 'judge';\n\nexport type Routed = 'approve' | 'deny' | 'ask';\n\nexport const gateOf = (tier: string): Gate => (tier === 'agent' ? 'judge' : 'person');\n\nexport const fits = (aligned: ApprovalVerdict['aligned']): boolean =>\n aligned === true || (typeof aligned === 'number' && aligned >= JUDGE_ALLOW);\n\nexport function route(\n verdict: ApprovalVerdict | undefined,\n requester: Pick<ApprovalRequester, 'kind'>,\n gate: Gate,\n present: boolean\n): Routed {\n if (gate !== 'judge' || !verdict?.level) return 'ask';\n const sure = verdict.via === 'chat' || (verdict.routine ?? 0) >= JUDGE_ALLOW;\n if (verdict.level === 1 && sure && fits(verdict.aligned)) return 'approve';\n if (verdict.level === 3 && requester.kind !== 'user' && !present) return 'deny';\n return 'ask';\n}\n\nexport function alwaysOffered(item: Approval): boolean {\n if (item.kind !== 'sudo' || item.tier !== 'user') return false;\n const { verdict, detail } = item;\n return verdict?.level === 1 && verdict.always === true && detail.writable !== false;\n}\n\nexport function gone(state: ApprovalState): string {\n if (state === 'unanswered') return 'This request timed out.';\n if (state === 'withdrawn') return 'This request was withdrawn.';\n return 'Someone else already answered this.';\n}\n\nexport function cleanReason(reason: unknown): string | undefined {\n if (typeof reason !== 'string') return undefined;\n const text = reason.trim().slice(0, REASON_LENGTH);\n return text || undefined;\n}\n\nconst decided = (item: Approval) => item.decidedAt ?? item.createdAt;\n\nexport function prune(items: Approval[], kept = APPROVALS_KEPT): Approval[] {\n const settled = items.filter((item) => item.state !== 'pending');\n settled.sort((a, b) => decided(a) - decided(b));\n const drop = new Set(settled.slice(0, Math.max(0, settled.length - kept)));\n return items.filter((item) => !drop.has(item));\n}\n\nexport type Settle = { state: Exclude<ApprovalState, 'pending'>; by: DecidedBy; reason?: string };\n\nexport type Ruling = { error?: string; settle?: Settle; answer?: 'once' | 'always' };\n\nconst why = (reason: string | undefined) => (reason ? { reason } : {});\n\nexport function ruled(\n item: Approval,\n answer: unknown,\n reason: unknown,\n by: DecidedBy,\n at: number\n): Ruling {\n if (item.state !== 'pending') return { error: gone(item.state) };\n if (item.expiresAt <= at)\n return {\n error: gone('unanswered'),\n settle: { state: 'unanswered', by: 'host', reason: REASONS.timeout },\n };\n if (!answerer(by, item)) return { error: \"This request isn't yours to answer.\" };\n const known = answerOf(answer);\n if (known === 'always' && scoopTier(by)) return { error: 'A scoop answers once or deny.' };\n if (known === 'always' && !personal(by))\n return { error: 'Always can only be answered by a person.' };\n if (known === 'always' && !item.always)\n return { error: \"Always isn't offered for this request.\" };\n if (!known) return { settle: { state: 'rejected', by, reason: REASONS.unknownAnswer } };\n const given = why(cleanReason(reason));\n if (known === 'deny') return { settle: { state: 'rejected', by, ...given } };\n return { settle: { state: 'approved', by, ...given }, answer: known };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AA8FvB,MAAM,eAAe,UAA0B;AAAA,EACpD,MAAM;AAAA,EACN,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,OAAO;AAAA,EACP,SAAS,OAAO,EAAE,OAAO,CAAC,EAAE;AAC9B,CAAC;AAEM,MAAM,cAAc;AACpB,MAAM,iBAAiB;AACvB,MAAM,YAAY;AAClB,MAAM,gBAAgB;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,WAAO;AAAA,MACL,OAAO,KAAK,YAAY;AAAA,MACxB,QAAQ,EAAE,OAAO,cAAc,IAAI,QAAQ,QAAQ,QAAQ,QAAQ;AAAA,IACrE;AACF,MAAI,CAAC,SAAS,IAAI,IAAI,EAAG,QAAO,EAAE,OAAO,sCAAsC;AAC/E,QAAM,QAAQ,SAAS,MAAM;AAC7B,MAAI,UAAU,YAAY,UAAU,EAAE,EAAG,QAAO,EAAE,OAAO,gCAAgC;AACzF,MAAI,UAAU,YAAY,CAAC,SAAS,EAAE;AACpC,WAAO,EAAE,OAAO,2CAA2C;AAC7D,MAAI,UAAU,YAAY,CAAC,KAAK;AAC9B,WAAO,EAAE,OAAO,yCAAyC;AAC3D,MAAI,CAAC,MAAO,QAAO,EAAE,QAAQ,EAAE,OAAO,YAAY,IAAI,QAAQ,QAAQ,cAAc,EAAE;AACtF,QAAM,QAAQ,IAAI,YAAY,MAAM,CAAC;AACrC,MAAI,UAAU,OAAQ,QAAO,EAAE,QAAQ,EAAE,OAAO,YAAY,IAAI,GAAG,MAAM,EAAE;AAC3E,SAAO,EAAE,QAAQ,EAAE,OAAO,YAAY,IAAI,GAAG,MAAM,GAAG,QAAQ,MAAM;AACtE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/approvals/sudo.js
CHANGED
|
@@ -58,13 +58,30 @@ function sudoRequester(request, agents, where) {
|
|
|
58
58
|
}
|
|
59
59
|
return { requester: { kind: "user", name }, agentId: "" };
|
|
60
60
|
}
|
|
61
|
+
const STDIN = ["tty", "none", "pipe", "file"];
|
|
62
|
+
function rootOnlyOf(value) {
|
|
63
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
64
|
+
const kept = Object.entries(value).filter(
|
|
65
|
+
(entry) => typeof entry[1] === "boolean"
|
|
66
|
+
);
|
|
67
|
+
return Object.fromEntries(kept);
|
|
68
|
+
}
|
|
69
|
+
function kernelFacts(request) {
|
|
70
|
+
const rootOnly = rootOnlyOf(request.rootOnly);
|
|
71
|
+
return {
|
|
72
|
+
...STDIN.includes(request.stdin) ? { stdin: request.stdin } : {},
|
|
73
|
+
...rootOnly ? { rootOnly } : {},
|
|
74
|
+
...typeof request.always === "boolean" ? { writable: request.always } : {}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
61
77
|
function sudoDetail(request) {
|
|
62
78
|
const command = [request.path || request.argv[0], ...request.argv.slice(1)].map((word) => shellWord(String(word))).join(" ");
|
|
63
79
|
return {
|
|
64
80
|
command,
|
|
65
81
|
...text(request.target) ? { target: request.target } : {},
|
|
66
82
|
...text(request.cwd) ? { cwd: request.cwd } : {},
|
|
67
|
-
...request.always === true ? { alwaysScope: "cwd" } : {}
|
|
83
|
+
...request.always === true ? { alwaysScope: "cwd" } : {},
|
|
84
|
+
...kernelFacts(request)
|
|
68
85
|
};
|
|
69
86
|
}
|
|
70
87
|
function scoopLick(id, agentId, detail, agents) {
|
|
@@ -109,7 +126,7 @@ function createSudo(options) {
|
|
|
109
126
|
agentId,
|
|
110
127
|
requester,
|
|
111
128
|
tier: "user",
|
|
112
|
-
always: request.always
|
|
129
|
+
always: request.always !== false,
|
|
113
130
|
expiresAt: request.expiresAt,
|
|
114
131
|
detail
|
|
115
132
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/approvals/sudo.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Context, ReplicatedState } from '@earendil-works/chord';\nimport { BACKGROUND_CONTEXT } from '@earendil-works/chord/context';\nimport type { AgentsState } from '../agents.ts';\nimport type { Licks } from '../licks/licks.ts';\nimport { sprinklesOf } from '../sprinkles/cgi.ts';\nimport type { Approvals } from './index.ts';\nimport {\n type Approval,\n type ApprovalRequester,\n cleanReason,\n REASONS,\n type SudoDetail,\n} from './record.ts';\n\nexport type SudoAnswer = 'once' | 'always' | 'deny';\n\nexport type SudoDenial = { answer: 'deny'; message: string };\n\nexport type SudoReply = SudoAnswer | SudoDenial;\n\nexport interface SudoRequest {\n id: string;\n kind: 'sudo';\n user: string;\n uid?: number;\n target?: string;\n argv: string[];\n path?: string;\n cwd?: string;\n pid?: number;\n tag?: string;\n tags?: string[];\n tty?: string;\n createdAt?: number;\n expiresAt: number;\n always?: boolean;\n}\n\nexport type SudoAsked = { id: string; error: null } | { id: null; error: string };\n\nexport interface AgentSudo {\n readonly approvals: ReplicatedState<Approval[]>;\n request(request: SudoRequest, where: string | null, context: Context): Promise<SudoAsked>;\n withdraw(id: string, reason: string | null, context: Context): Promise<void>;\n}\n\nconst SAFE = /^[\\w@%+=:,./-]+$/;\n\nexport const shellWord = (word: string): string =>\n SAFE.test(word) ? word : `'${word.replaceAll(\"'\", `'\\\\''`)}'`;\n\nconst text = (value: unknown): value is string => typeof value === 'string';\n\nexport function sudoRequest(value: unknown): SudoRequest | null {\n const request = value as Partial<SudoRequest> | null;\n if (typeof request !== 'object' || request === null) return null;\n const { argv, user, expiresAt } = request;\n if (!Array.isArray(argv) || !argv.length || !argv.every(text)) return null;\n if (!text(user) || typeof expiresAt !== 'number' || !Number.isFinite(expiresAt)) return null;\n return request as SudoRequest;\n}\n\nfunction tagOf(tag: unknown): { kind?: unknown; agentId?: unknown; where?: unknown } | null {\n if (!text(tag)) return null;\n try {\n const parsed = JSON.parse(tag);\n return typeof parsed === 'object' && parsed !== null ? parsed : null;\n } catch {\n return null;\n }\n}\n\nconst TERMINAL = 'terminal:';\nconst FOLLOWER = 'follower:';\n\nfunction shownWhere(where: string, given: string | undefined): string {\n if (given) return given;\n if (where.startsWith(TERMINAL)) return 'a terminal';\n if (where.startsWith(FOLLOWER)) return 'a linked device';\n return where;\n}\n\nexport function sudoRequester(\n request: SudoRequest,\n agents: Readonly<AgentsState> | undefined,\n where?: string | null\n): { requester: ApprovalRequester; agentId: string } {\n const tag = tagOf(request.tag);\n const name = request.user;\n const sprinkle = sprinklesOf(Array.isArray(request.tags) ? request.tags.filter(text) : [])[0];\n if (sprinkle)\n return { requester: { kind: 'user', name, where: `the ${sprinkle} sprinkle` }, agentId: '' };\n if (tag?.kind === 'agent' && text(tag.agentId)) {\n const id = tag.agentId.startsWith('cone:') ? tag.agentId.slice('cone:'.length) : tag.agentId;\n const known = agents?.cones[id]?.name ?? agents?.scoops[id]?.name ?? name;\n return { requester: { kind: 'agent', name: known, agentId: id }, agentId: id };\n }\n if (tag?.kind === 'user' && text(tag.where)) {\n const given = cleanReason(where);\n const device = tag.where.startsWith(FOLLOWER) ? tag.where.slice(FOLLOWER.length) : '';\n return {\n requester: {\n kind: 'user',\n name,\n where: shownWhere(tag.where, given),\n ...(device ? { device } : {}),\n },\n agentId: '',\n };\n }\n return { requester: { kind: 'user', name }, agentId: '' };\n}\n\nexport function sudoDetail(request: SudoRequest): SudoDetail {\n const command = [request.path || request.argv[0], ...request.argv.slice(1)]\n .map((word) => shellWord(String(word)))\n .join(' ');\n return {\n command,\n ...(text(request.target) ? { target: request.target } : {}),\n ...(text(request.cwd) ? { cwd: request.cwd } : {}),\n ...(request.always === true ? { alwaysScope: 'cwd' as const } : {}),\n };\n}\n\nfunction scoopLick(\n id: string,\n agentId: string,\n detail: SudoDetail,\n agents: Readonly<AgentsState> | undefined\n) {\n const scoop = agents?.scoops[agentId];\n if (!scoop) return undefined;\n const { command, target, cwd } = detail;\n const as = target ? ` as ${target}` : '';\n const at = cwd ? ` in ${cwd}` : '';\n return {\n channel: 'sudo-request' as const,\n source: id,\n title: `${scoop.name} waits for sudo`,\n text: `[scoop ${scoop.name} waits for a person to approve sudo]`,\n body: `${scoop.name} asked to run ${command}${as}${at}. A person answers it in the approvals dialog; you can't approve it. It ends when someone answers or it times out.`,\n target: `cone:${scoop.cone}` as const,\n };\n}\n\nexport interface SudoAttach {\n approvals: Approvals;\n agents?: () => Readonly<AgentsState> | undefined;\n licks?: Pick<Licks, 'deliver'>;\n}\n\ntype SudoLick = NonNullable<ReturnType<typeof scoopLick>>;\n\nexport function createSudo(options: SudoAttach): AgentSudo & { close(): void } {\n const { approvals } = options;\n const agents = () => options.agents?.();\n const waiting = new Map<string, SudoLick>();\n const send = (lick: SudoLick) =>\n void options.licks?.deliver(lick, BACKGROUND_CONTEXT).catch(() => undefined);\n const watch = (items: readonly Approval[]) => {\n for (const [id, lick] of waiting) {\n const item = items.find((entry) => entry.id === id);\n if (item?.state === 'pending' && item.tier !== 'user') continue;\n waiting.delete(id);\n if (item?.state === 'pending') send(lick);\n }\n };\n const off = approvals.state.subscribe((items) => watch(items));\n return {\n approvals: approvals.state,\n async request(value, where, context) {\n const request = sudoRequest(value);\n if (!request) return { id: null, error: 'This is not a sudo request.' };\n const { requester, agentId } = sudoRequester(request, agents(), where);\n const detail = sudoDetail(request);\n const item = await approvals.request(\n {\n kind: 'sudo',\n agentId,\n requester,\n tier: 'user',\n always: request.always
|
|
5
|
-
"mappings": "AACA,SAAS,0BAA0B;AAGnC,SAAS,mBAAmB;AAE5B;AAAA,EAGE;AAAA,EACA;AAAA,
|
|
4
|
+
"sourcesContent": ["import type { Context, ReplicatedState } from '@earendil-works/chord';\nimport { BACKGROUND_CONTEXT } from '@earendil-works/chord/context';\nimport type { AgentsState } from '../agents.ts';\nimport type { Licks } from '../licks/licks.ts';\nimport { sprinklesOf } from '../sprinkles/cgi.ts';\nimport type { Approvals } from './index.ts';\nimport {\n type Approval,\n type ApprovalRequester,\n cleanReason,\n REASONS,\n type SudoDetail,\n type SudoStdin,\n} from './record.ts';\n\nexport type SudoAnswer = 'once' | 'always' | 'deny';\n\nexport type SudoDenial = { answer: 'deny'; message: string };\n\nexport type SudoReply = SudoAnswer | SudoDenial;\n\nexport interface SudoRequest {\n id: string;\n kind: 'sudo';\n user: string;\n uid?: number;\n target?: string;\n argv: string[];\n path?: string;\n cwd?: string;\n pid?: number;\n tag?: string;\n tags?: string[];\n tty?: string;\n createdAt?: number;\n expiresAt: number;\n always?: boolean;\n stdin?: SudoStdin;\n rootOnly?: Record<string, boolean>;\n}\n\nexport type SudoAsked = { id: string; error: null } | { id: null; error: string };\n\nexport interface AgentSudo {\n readonly approvals: ReplicatedState<Approval[]>;\n request(request: SudoRequest, where: string | null, context: Context): Promise<SudoAsked>;\n withdraw(id: string, reason: string | null, context: Context): Promise<void>;\n}\n\nconst SAFE = /^[\\w@%+=:,./-]+$/;\n\nexport const shellWord = (word: string): string =>\n SAFE.test(word) ? word : `'${word.replaceAll(\"'\", `'\\\\''`)}'`;\n\nconst text = (value: unknown): value is string => typeof value === 'string';\n\nexport function sudoRequest(value: unknown): SudoRequest | null {\n const request = value as Partial<SudoRequest> | null;\n if (typeof request !== 'object' || request === null) return null;\n const { argv, user, expiresAt } = request;\n if (!Array.isArray(argv) || !argv.length || !argv.every(text)) return null;\n if (!text(user) || typeof expiresAt !== 'number' || !Number.isFinite(expiresAt)) return null;\n return request as SudoRequest;\n}\n\nfunction tagOf(tag: unknown): { kind?: unknown; agentId?: unknown; where?: unknown } | null {\n if (!text(tag)) return null;\n try {\n const parsed = JSON.parse(tag);\n return typeof parsed === 'object' && parsed !== null ? parsed : null;\n } catch {\n return null;\n }\n}\n\nconst TERMINAL = 'terminal:';\nconst FOLLOWER = 'follower:';\n\nfunction shownWhere(where: string, given: string | undefined): string {\n if (given) return given;\n if (where.startsWith(TERMINAL)) return 'a terminal';\n if (where.startsWith(FOLLOWER)) return 'a linked device';\n return where;\n}\n\nexport function sudoRequester(\n request: SudoRequest,\n agents: Readonly<AgentsState> | undefined,\n where?: string | null\n): { requester: ApprovalRequester; agentId: string } {\n const tag = tagOf(request.tag);\n const name = request.user;\n const sprinkle = sprinklesOf(Array.isArray(request.tags) ? request.tags.filter(text) : [])[0];\n if (sprinkle)\n return { requester: { kind: 'user', name, where: `the ${sprinkle} sprinkle` }, agentId: '' };\n if (tag?.kind === 'agent' && text(tag.agentId)) {\n const id = tag.agentId.startsWith('cone:') ? tag.agentId.slice('cone:'.length) : tag.agentId;\n const known = agents?.cones[id]?.name ?? agents?.scoops[id]?.name ?? name;\n return { requester: { kind: 'agent', name: known, agentId: id }, agentId: id };\n }\n if (tag?.kind === 'user' && text(tag.where)) {\n const given = cleanReason(where);\n const device = tag.where.startsWith(FOLLOWER) ? tag.where.slice(FOLLOWER.length) : '';\n return {\n requester: {\n kind: 'user',\n name,\n where: shownWhere(tag.where, given),\n ...(device ? { device } : {}),\n },\n agentId: '',\n };\n }\n return { requester: { kind: 'user', name }, agentId: '' };\n}\n\nconst STDIN: readonly unknown[] = ['tty', 'none', 'pipe', 'file'];\n\nfunction rootOnlyOf(value: unknown): Record<string, boolean> | undefined {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) return undefined;\n const kept = Object.entries(value).filter(\n (entry): entry is [string, boolean] => typeof entry[1] === 'boolean'\n );\n return Object.fromEntries(kept);\n}\n\nfunction kernelFacts(request: SudoRequest): Partial<SudoDetail> {\n const rootOnly = rootOnlyOf(request.rootOnly);\n return {\n ...(STDIN.includes(request.stdin) ? { stdin: request.stdin } : {}),\n ...(rootOnly ? { rootOnly } : {}),\n ...(typeof request.always === 'boolean' ? { writable: request.always } : {}),\n };\n}\n\nexport function sudoDetail(request: SudoRequest): SudoDetail {\n const command = [request.path || request.argv[0], ...request.argv.slice(1)]\n .map((word) => shellWord(String(word)))\n .join(' ');\n return {\n command,\n ...(text(request.target) ? { target: request.target } : {}),\n ...(text(request.cwd) ? { cwd: request.cwd } : {}),\n ...(request.always === true ? { alwaysScope: 'cwd' as const } : {}),\n ...kernelFacts(request),\n };\n}\n\nfunction scoopLick(\n id: string,\n agentId: string,\n detail: SudoDetail,\n agents: Readonly<AgentsState> | undefined\n) {\n const scoop = agents?.scoops[agentId];\n if (!scoop) return undefined;\n const { command, target, cwd } = detail;\n const as = target ? ` as ${target}` : '';\n const at = cwd ? ` in ${cwd}` : '';\n return {\n channel: 'sudo-request' as const,\n source: id,\n title: `${scoop.name} waits for sudo`,\n text: `[scoop ${scoop.name} waits for a person to approve sudo]`,\n body: `${scoop.name} asked to run ${command}${as}${at}. A person answers it in the approvals dialog; you can't approve it. It ends when someone answers or it times out.`,\n target: `cone:${scoop.cone}` as const,\n };\n}\n\nexport interface SudoAttach {\n approvals: Approvals;\n agents?: () => Readonly<AgentsState> | undefined;\n licks?: Pick<Licks, 'deliver'>;\n}\n\ntype SudoLick = NonNullable<ReturnType<typeof scoopLick>>;\n\nexport function createSudo(options: SudoAttach): AgentSudo & { close(): void } {\n const { approvals } = options;\n const agents = () => options.agents?.();\n const waiting = new Map<string, SudoLick>();\n const send = (lick: SudoLick) =>\n void options.licks?.deliver(lick, BACKGROUND_CONTEXT).catch(() => undefined);\n const watch = (items: readonly Approval[]) => {\n for (const [id, lick] of waiting) {\n const item = items.find((entry) => entry.id === id);\n if (item?.state === 'pending' && item.tier !== 'user') continue;\n waiting.delete(id);\n if (item?.state === 'pending') send(lick);\n }\n };\n const off = approvals.state.subscribe((items) => watch(items));\n return {\n approvals: approvals.state,\n async request(value, where, context) {\n const request = sudoRequest(value);\n if (!request) return { id: null, error: 'This is not a sudo request.' };\n const { requester, agentId } = sudoRequester(request, agents(), where);\n const detail = sudoDetail(request);\n const item = await approvals.request(\n {\n kind: 'sudo',\n agentId,\n requester,\n tier: 'user',\n always: request.always !== false,\n expiresAt: request.expiresAt,\n detail,\n },\n context\n );\n const lick = scoopLick(item.id, agentId, detail, agents());\n if (lick) {\n waiting.set(item.id, lick);\n watch(approvals.state.value as Approval[]);\n }\n return { id: item.id, error: null };\n },\n async withdraw(id, reason, context) {\n await approvals.withdraw(id, reason, context);\n },\n close() {\n off();\n waiting.clear();\n },\n };\n}\n\nexport function ownedSudo(sudo: AgentSudo): AgentSudo & { release(): void } {\n const mine = new Set<string>();\n const forget = () => {\n const open = new Set(\n (sudo.approvals.value as Approval[])\n .filter((item) => item.state === 'pending')\n .map(({ id }) => id)\n );\n for (const id of mine) if (!open.has(id)) mine.delete(id);\n };\n return {\n approvals: sudo.approvals,\n async request(request, where, context) {\n forget();\n const asked = await sudo.request(request, where, context);\n if (asked.id) mine.add(asked.id);\n return asked;\n },\n async withdraw(id, reason, context) {\n if (!mine.delete(id)) return;\n await sudo.withdraw(id, reason, context);\n },\n release() {\n forget();\n for (const id of mine)\n void sudo.withdraw(id, REASONS.disconnected, BACKGROUND_CONTEXT).catch(() => undefined);\n mine.clear();\n },\n };\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,0BAA0B;AAGnC,SAAS,mBAAmB;AAE5B;AAAA,EAGE;AAAA,EACA;AAAA,OAGK;AAoCP,MAAM,OAAO;AAEN,MAAM,YAAY,CAAC,SACxB,KAAK,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,WAAW,KAAK,OAAO,CAAC;AAE5D,MAAM,OAAO,CAAC,UAAoC,OAAO,UAAU;AAE5D,SAAS,YAAY,OAAoC;AAC9D,QAAM,UAAU;AAChB,MAAI,OAAO,YAAY,YAAY,YAAY,KAAM,QAAO;AAC5D,QAAM,EAAE,MAAM,MAAM,UAAU,IAAI;AAClC,MAAI,CAAC,MAAM,QAAQ,IAAI,KAAK,CAAC,KAAK,UAAU,CAAC,KAAK,MAAM,IAAI,EAAG,QAAO;AACtE,MAAI,CAAC,KAAK,IAAI,KAAK,OAAO,cAAc,YAAY,CAAC,OAAO,SAAS,SAAS,EAAG,QAAO;AACxF,SAAO;AACT;AAEA,SAAS,MAAM,KAA6E;AAC1F,MAAI,CAAC,KAAK,GAAG,EAAG,QAAO;AACvB,MAAI;AACF,UAAM,SAAS,KAAK,MAAM,GAAG;AAC7B,WAAO,OAAO,WAAW,YAAY,WAAW,OAAO,SAAS;AAAA,EAClE,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,MAAM,WAAW;AACjB,MAAM,WAAW;AAEjB,SAAS,WAAW,OAAe,OAAmC;AACpE,MAAI,MAAO,QAAO;AAClB,MAAI,MAAM,WAAW,QAAQ,EAAG,QAAO;AACvC,MAAI,MAAM,WAAW,QAAQ,EAAG,QAAO;AACvC,SAAO;AACT;AAEO,SAAS,cACd,SACA,QACA,OACmD;AACnD,QAAM,MAAM,MAAM,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CHANGED
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
attachApprovals,
|
|
21
21
|
DEFAULT_POLICY,
|
|
22
22
|
JUDGE_ALLOW,
|
|
23
|
-
JUDGE_DENY,
|
|
24
23
|
JUDGE_KIND,
|
|
25
24
|
JUDGE_MODEL,
|
|
26
25
|
JUDGE_QUESTIONS,
|
|
@@ -30,7 +29,7 @@ import {
|
|
|
30
29
|
ownerIntent,
|
|
31
30
|
POLICY_FILE,
|
|
32
31
|
REASONS,
|
|
33
|
-
|
|
32
|
+
route,
|
|
34
33
|
seedPolicy,
|
|
35
34
|
VERDICT_REASONS,
|
|
36
35
|
verdictOf,
|
|
@@ -132,7 +131,6 @@ export {
|
|
|
132
131
|
IMAGE_LIMIT,
|
|
133
132
|
INVENTORY_STATUSES,
|
|
134
133
|
JUDGE_ALLOW,
|
|
135
|
-
JUDGE_DENY,
|
|
136
134
|
JUDGE_KIND,
|
|
137
135
|
JUDGE_MODEL,
|
|
138
136
|
JUDGE_QUESTIONS,
|
|
@@ -178,7 +176,7 @@ export {
|
|
|
178
176
|
ownerIntent,
|
|
179
177
|
preferredModel,
|
|
180
178
|
resolveDefaultModel,
|
|
181
|
-
|
|
179
|
+
route,
|
|
182
180
|
runAgentWorker,
|
|
183
181
|
seedPolicy,
|
|
184
182
|
serveAdmin,
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export {\n ADOBE,\n ADOBE_PROXY,\n type AdobeConfig,\n type AdobeModelInfo,\n adobeClassifiers,\n adobeConfig,\n adobeIdentity,\n adobeModel,\n adobeProvider,\n adobeUsage,\n type Budget,\n SESSION_HEADER,\n VERSION_HEADER,\n withAdobeIdentity,\n} from './adobe.ts';\nexport { type Agent, type AgentOptions, answerText, openAgent } from './agent.ts';\nexport {\n APPROVAL_MS,\n type Approval,\n type ApprovalAnswer,\n type ApprovalDecided,\n type ApprovalDraft,\n type ApprovalJudge,\n type ApprovalKind,\n type ApprovalRequester,\n type ApprovalState,\n type Approvals,\n ApprovalsDoc,\n type ApprovalTier,\n type ApprovalVerdict,\n ASK_MIN_MS,\n approvalJudge,\n attachApprovals,\n DEFAULT_POLICY,\n type DecidedBy,\n type Decider,\n JUDGE_ALLOW,\n
|
|
5
|
-
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAwC,YAAY,iBAAiB;AACrE;AAAA,EACE;AAAA,EAUA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,
|
|
4
|
+
"sourcesContent": ["export {\n ADOBE,\n ADOBE_PROXY,\n type AdobeConfig,\n type AdobeModelInfo,\n adobeClassifiers,\n adobeConfig,\n adobeIdentity,\n adobeModel,\n adobeProvider,\n adobeUsage,\n type Budget,\n SESSION_HEADER,\n VERSION_HEADER,\n withAdobeIdentity,\n} from './adobe.ts';\nexport { type Agent, type AgentOptions, answerText, openAgent } from './agent.ts';\nexport {\n APPROVAL_MS,\n type Approval,\n type ApprovalAnswer,\n type ApprovalDecided,\n type ApprovalDraft,\n type ApprovalJudge,\n type ApprovalKind,\n type ApprovalRequester,\n type ApprovalState,\n type Approvals,\n ApprovalsDoc,\n type ApprovalTier,\n type ApprovalVerdict,\n ASK_MIN_MS,\n approvalJudge,\n attachApprovals,\n DEFAULT_POLICY,\n type DecidedBy,\n type Decider,\n JUDGE_ALLOW,\n JUDGE_KIND,\n JUDGE_MODEL,\n JUDGE_QUESTIONS,\n type Judgement,\n judgeModelOf,\n judgeSpender,\n judgeState,\n type OwnerIntent,\n ownerIntent,\n POLICY_FILE,\n REASONS,\n route,\n seedPolicy,\n VERDICT_REASONS,\n verdictOf,\n verdictRecorder,\n} from './approvals/index.ts';\nexport {\n type ApprovalPolicy,\n type ApprovalPolicyChange,\n type ApprovalPolicySet,\n DEFAULT_APPROVAL_POLICY,\n type SudoPolicy,\n} from './approvals/policy.ts';\nexport type {\n AgentSudo,\n SudoAnswer,\n SudoDenial,\n SudoReply,\n SudoRequest,\n} from './approvals/sudo.ts';\nexport {\n FILE_LIMIT,\n IMAGE_LIMIT,\n type SendAttachment,\n type ShownAttachment,\n splitUser,\n TOTAL_LIMIT,\n userParts,\n} from './attachments.ts';\nexport { type AgentConnection, connectAgent } from './client.ts';\nexport type { Clock } from './clock.ts';\nexport { createAgentControl } from './control.ts';\nexport {\n connectGuest,\n GUEST_ONLY,\n type GuestConnection,\n SEAT_REFUSED,\n} from './guests/client.ts';\nexport type { GuestOpened, Proposed, ProposeRequest } from './guests/index.ts';\nexport type { GateKind, GuestPolicy } from './guests/policy.ts';\nexport type { GuestDraft, GuestGate, GuestGates, GuestSeat } from './guests/seats.ts';\nexport { type AgentHost, type ConnectOptions, hostAgent } from './host.ts';\nexport type {\n KernelClient,\n KernelFs,\n KernelProcess,\n KernelStat,\n SpawnOptions,\n} from './kernel/client.ts';\nexport { HOME, type KernelEnvOptions, kernelEnvironment, SliccKernelEnv } from './kernel/env.ts';\nexport {\n adminOver,\n type KernelAdmin,\n type KernelGroup,\n type KernelGroups,\n type KernelUser,\n type KernelUsers,\n serveAdmin,\n type UserClient,\n type UserClients,\n type UserConnect,\n type UserSpec,\n userClients,\n} from './kernel/users.ts';\nexport {\n type AgentWorkerOptions,\n type AgentWorkerScope,\n type KernelAttach,\n runAgentWorker,\n} from './main.ts';\nexport {\n type Loopback,\n type Transport,\n type TransportResponse,\n transportFetch,\n} from './net.ts';\nexport {\n AGENT_LOCK,\n type AgentOwner,\n type AgentWorker,\n type KernelSource,\n type OwnerOptions,\n startAgent,\n} from './owner.ts';\nexport { SliccPrompt, sliccPrompt } from './prompt.ts';\nexport {\n type AgentPages,\n createPages,\n type PageBatch,\n type PageCaller,\n type PageRequest,\n type PageResult,\n type Pages,\n type PagesOpened,\n type PageTab,\n} from './remote/pages.ts';\nexport {\n type AccountState,\n AgentControl,\n type AgentInventory,\n AgentInventoryService,\n AgentPagesService,\n AgentSettings,\n type AgentSettingsChange,\n AgentTranscript,\n type BudgetState,\n INVENTORY_STATUSES,\n type InventoryAgent,\n type InventoryRow,\n type InventorySnapshot,\n type InventoryState,\n type InventoryStatus,\n type McpEdit,\n type McpRefusal,\n type McpRefusalCode,\n type McpRefusals,\n type ModelChoice,\n type OperationError,\n type PromptResult,\n type SendMode,\n type SendRequest,\n type SendResponse,\n type SettingsState,\n type SignIn,\n} from './services.ts';\nexport {\n BEDROCK,\n createAgentSettings,\n createSliccModels,\n DEFAULT_MODEL,\n DEFAULT_REGIONS,\n PREFERRED_MODELS,\n preferredModel,\n resolveDefaultModel,\n sliccProviders,\n withDefaultRegions,\n} from './settings.ts';\nexport {\n AGENT_DIRECTORY,\n type OpfsSqliteOptions,\n openMemorySqliteStorage,\n openOpfsSqliteStorage,\n WasmSqliteDatabase,\n} from './sqlite.ts';\nexport { type SystemFacts, systemSection } from './system.ts';\nexport { UPLOADS, type Uploads, upload } from './uploads.ts';\nexport { type PortEndpoint, PortLink } from './wire.ts';\nexport {\n type KernelPorts,\n kernelPort,\n kernelPorts,\n serveConnections,\n type WorkerScope,\n} from './worker.ts';\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAwC,YAAY,iBAAiB;AACrE;AAAA,EACE;AAAA,EAUA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EAIE;AAAA,OAEK;AAQP;AAAA,EACE;AAAA,EACA;AAAA,EAGA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAA+B,oBAAoB;AAEnD,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,OACK;AAIP,SAA8C,iBAAiB;AAQ/D,SAAS,MAA6B,mBAAmB,sBAAsB;AAC/E;AAAA,EACE;AAAA,EAMA;AAAA,EAKA;AAAA,OACK;AACP;AAAA,EAIE;AAAA,OACK;AACP;AAAA,EAIE;AAAA,OACK;AACP;AAAA,EACE;AAAA,EAKA;AAAA,OACK;AACP,SAAS,aAAa,mBAAmB;AACzC;AAAA,EAEE;AAAA,OAQK;AACP;AAAA,EAEE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAEA;AAAA,OAkBK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAA2B,qBAAqB;AAChD,SAAS,SAAuB,cAAc;AAC9C,SAA4B,gBAAgB;AAC5C;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/titles/generate.js
CHANGED
|
@@ -30,13 +30,27 @@ function textOf(entry) {
|
|
|
30
30
|
function transcriptOf(entries) {
|
|
31
31
|
return entries.filter((entry) => entry.kind === "pi.user" || entry.kind === "pi.assistant").map((entry) => `${entry.kind === "pi.user" ? "User" : "Agent"}: ${textOf(entry)}`).join("\n");
|
|
32
32
|
}
|
|
33
|
-
async function scrubbed(raw) {
|
|
33
|
+
async function scrubbed(raw, limit = TRANSCRIPT_LENGTH) {
|
|
34
34
|
const redacted = redactSecrets(raw).text;
|
|
35
|
-
return (await scrubText(redacted)).slice(0,
|
|
35
|
+
return (await scrubText(redacted)).slice(0, limit);
|
|
36
36
|
}
|
|
37
37
|
function scrubTranscript(entries) {
|
|
38
38
|
return scrubbed(transcriptOf(entries));
|
|
39
39
|
}
|
|
40
|
+
async function completeText(models, found, text, max, options = {}) {
|
|
41
|
+
const message = await models.completeSimple(
|
|
42
|
+
found,
|
|
43
|
+
{
|
|
44
|
+
messages: [
|
|
45
|
+
{ role: "user", content: [{ type: "text", text }], timestamp: Date.now() }
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{ maxTokens: max, ...options.signal ? { signal: options.signal } : {} }
|
|
49
|
+
);
|
|
50
|
+
if (message.stopReason === "error") return void 0;
|
|
51
|
+
const said = message.content.map((part) => part.type === "text" ? part.text : "").join("").trim();
|
|
52
|
+
return { text: said, answer: message };
|
|
53
|
+
}
|
|
40
54
|
function smallModel(models, settings, key, prompt, max) {
|
|
41
55
|
return async (transcript, model, context, admit = () => true) => {
|
|
42
56
|
const text = await settings(context);
|
|
@@ -46,24 +60,9 @@ function smallModel(models, settings, key, prompt, max) {
|
|
|
46
60
|
const ref = chosen ?? (provider && rest.length ? { provider, modelId: rest.join("/") } : null);
|
|
47
61
|
const found = ref ? models.getModel(ref.provider, ref.modelId) : void 0;
|
|
48
62
|
if (!found || !transcript || !admit()) return void 0;
|
|
49
|
-
|
|
50
|
-
found,
|
|
51
|
-
{
|
|
52
|
-
messages: [
|
|
53
|
-
{
|
|
54
|
-
role: "user",
|
|
55
|
-
content: [{ type: "text", text: `${prompt}
|
|
63
|
+
return completeText(models, found, `${prompt}
|
|
56
64
|
|
|
57
|
-
${transcript}
|
|
58
|
-
timestamp: Date.now()
|
|
59
|
-
}
|
|
60
|
-
]
|
|
61
|
-
},
|
|
62
|
-
{ maxTokens: max }
|
|
63
|
-
);
|
|
64
|
-
if (message.stopReason === "error") return void 0;
|
|
65
|
-
const said = message.content.map((part) => part.type === "text" ? part.text : "").join("").trim();
|
|
66
|
-
return { text: said, answer: message };
|
|
65
|
+
${transcript}`, max);
|
|
67
66
|
};
|
|
68
67
|
}
|
|
69
68
|
function titler(models, settings) {
|
|
@@ -77,6 +76,7 @@ export {
|
|
|
77
76
|
LABEL_PROMPT,
|
|
78
77
|
TITLE_PROMPT,
|
|
79
78
|
TRANSCRIPT_LENGTH,
|
|
79
|
+
completeText,
|
|
80
80
|
labeler,
|
|
81
81
|
labelsOn,
|
|
82
82
|
scrubTranscript,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/titles/generate.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Context } from '@earendil-works/chord';\nimport type { AssistantMessage, Message } from '@earendil-works/pi-ai';\nimport type { Models } from '@earendil-works/pi-ai/models';\nimport type { EntryRecord } from '@earendil-works/pi-durable';\nimport type { ExecutionEnv } from '@earendil-works/pi-durable/env';\nimport { answerText } from '../agent.ts';\nimport { extractSettings } from '../memory/extract.ts';\nimport { redactSecrets } from '../memory/format.ts';\nimport { scrubText } from '../secrets/scrub.ts';\n\nexport const TITLE_PROMPT =\n 'Give this chat a title of three to six words that says what it is about, in the language the user writes in. Answer with the title only, without quotes.';\n\nexport const LABEL_PROMPT =\n 'Label this group of tool runs in three to eight words, as an imperative that says what they do, such as \"Check the failing build logs\". Answer with the label only, without quotes.';\n\nexport const TRANSCRIPT_LENGTH = 4000;\n\ntype Switch = 'titles' | 'toolLabels';\n\nfunction settingOn(text: string | undefined, key: Switch): boolean {\n try {\n return (JSON.parse(text ?? '{}') as Record<string, unknown>)[key] !== false;\n } catch {\n return true;\n }\n}\n\nexport function titlesOn(text: string | undefined): boolean {\n return settingOn(text, 'titles');\n}\n\nexport function labelsOn(text: string | undefined): boolean {\n return settingOn(text, 'toolLabels');\n}\n\nexport function settingsText(\n env: Pick<ExecutionEnv, 'readTextFile'>,\n home: string,\n dir = `${home}/.pi/agent`\n): (context: Context) => Promise<string | undefined> {\n return async (context) => {\n const read = await env.readTextFile(`${dir}/settings.json`, context);\n return read.ok ? read.value : undefined;\n };\n}\n\nfunction textOf(entry: EntryRecord): string {\n return answerText(entry.model?.[0]?.content).trim();\n}\n\nexport function transcriptOf(entries: readonly EntryRecord[]): string {\n return entries\n .filter((entry) => entry.kind === 'pi.user' || entry.kind === 'pi.assistant')\n .map((entry) => `${entry.kind === 'pi.user' ? 'User' : 'Agent'}: ${textOf(entry)}`)\n .join('\\n');\n}\n\nexport async function scrubbed(raw: string): Promise<string> {\n const redacted = redactSecrets(raw).text;\n return (await scrubText(redacted)).slice(0,
|
|
5
|
-
"mappings": "AAKA,SAAS,kBAAkB;AAC3B,SAAS,uBAAuB;AAChC,SAAS,qBAAqB;AAC9B,SAAS,iBAAiB;AAEnB,MAAM,eACX;AAEK,MAAM,eACX;AAEK,MAAM,oBAAoB;AAIjC,SAAS,UAAU,MAA0B,KAAsB;AACjE,MAAI;AACF,WAAQ,KAAK,MAAM,QAAQ,IAAI,EAA8B,GAAG,MAAM;AAAA,EACxE,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEO,SAAS,SAAS,MAAmC;AAC1D,SAAO,UAAU,MAAM,QAAQ;AACjC;AAEO,SAAS,SAAS,MAAmC;AAC1D,SAAO,UAAU,MAAM,YAAY;AACrC;AAEO,SAAS,aACd,KACA,MACA,MAAM,GAAG,IAAI,cACsC;AACnD,SAAO,OAAO,YAAY;AACxB,UAAM,OAAO,MAAM,IAAI,aAAa,GAAG,GAAG,kBAAkB,OAAO;AACnE,WAAO,KAAK,KAAK,KAAK,QAAQ;AAAA,EAChC;AACF;AAEA,SAAS,OAAO,OAA4B;AAC1C,SAAO,WAAW,MAAM,QAAQ,CAAC,GAAG,OAAO,EAAE,KAAK;AACpD;AAEO,SAAS,aAAa,SAAyC;AACpE,SAAO,QACJ,OAAO,CAAC,UAAU,MAAM,SAAS,aAAa,MAAM,SAAS,cAAc,EAC3E,IAAI,CAAC,UAAU,GAAG,MAAM,SAAS,YAAY,SAAS,OAAO,KAAK,OAAO,KAAK,CAAC,EAAE,EACjF,KAAK,IAAI;AACd;AAEA,eAAsB,SAAS,
|
|
4
|
+
"sourcesContent": ["import type { Context } from '@earendil-works/chord';\nimport type { Api, AssistantMessage, Message, Model } from '@earendil-works/pi-ai';\nimport type { Models } from '@earendil-works/pi-ai/models';\nimport type { EntryRecord } from '@earendil-works/pi-durable';\nimport type { ExecutionEnv } from '@earendil-works/pi-durable/env';\nimport { answerText } from '../agent.ts';\nimport { extractSettings } from '../memory/extract.ts';\nimport { redactSecrets } from '../memory/format.ts';\nimport { scrubText } from '../secrets/scrub.ts';\n\nexport const TITLE_PROMPT =\n 'Give this chat a title of three to six words that says what it is about, in the language the user writes in. Answer with the title only, without quotes.';\n\nexport const LABEL_PROMPT =\n 'Label this group of tool runs in three to eight words, as an imperative that says what they do, such as \"Check the failing build logs\". Answer with the label only, without quotes.';\n\nexport const TRANSCRIPT_LENGTH = 4000;\n\ntype Switch = 'titles' | 'toolLabels';\n\nfunction settingOn(text: string | undefined, key: Switch): boolean {\n try {\n return (JSON.parse(text ?? '{}') as Record<string, unknown>)[key] !== false;\n } catch {\n return true;\n }\n}\n\nexport function titlesOn(text: string | undefined): boolean {\n return settingOn(text, 'titles');\n}\n\nexport function labelsOn(text: string | undefined): boolean {\n return settingOn(text, 'toolLabels');\n}\n\nexport function settingsText(\n env: Pick<ExecutionEnv, 'readTextFile'>,\n home: string,\n dir = `${home}/.pi/agent`\n): (context: Context) => Promise<string | undefined> {\n return async (context) => {\n const read = await env.readTextFile(`${dir}/settings.json`, context);\n return read.ok ? read.value : undefined;\n };\n}\n\nfunction textOf(entry: EntryRecord): string {\n return answerText(entry.model?.[0]?.content).trim();\n}\n\nexport function transcriptOf(entries: readonly EntryRecord[]): string {\n return entries\n .filter((entry) => entry.kind === 'pi.user' || entry.kind === 'pi.assistant')\n .map((entry) => `${entry.kind === 'pi.user' ? 'User' : 'Agent'}: ${textOf(entry)}`)\n .join('\\n');\n}\n\nexport async function scrubbed(raw: string, limit = TRANSCRIPT_LENGTH): Promise<string> {\n const redacted = redactSecrets(raw).text;\n return (await scrubText(redacted)).slice(0, limit);\n}\n\nexport function scrubTranscript(entries: readonly EntryRecord[]): Promise<string> {\n return scrubbed(transcriptOf(entries));\n}\n\ntype Settings = (context: Context) => Promise<string | undefined>;\n\nexport type Asked = { text: string; answer: AssistantMessage };\n\nexport async function completeText(\n models: Pick<Models, 'completeSimple'>,\n found: Model<Api>,\n text: string,\n max: number,\n options: { signal?: AbortSignal } = {}\n): Promise<Asked | undefined> {\n const message = await models.completeSimple(\n found,\n {\n messages: [\n { role: 'user', content: [{ type: 'text', text }], timestamp: Date.now() } as Message,\n ],\n },\n { maxTokens: max, ...(options.signal ? { signal: options.signal } : {}) }\n );\n if (message.stopReason === 'error') return undefined;\n const said = message.content\n .map((part) => (part.type === 'text' ? part.text : ''))\n .join('')\n .trim();\n return { text: said, answer: message };\n}\n\nfunction smallModel(models: Models, settings: Settings, key: Switch, prompt: string, max: number) {\n return async (\n transcript: string,\n model: string,\n context: Context,\n admit: () => boolean = () => true\n ): Promise<Asked | undefined> => {\n const text = await settings(context);\n if (!settingOn(text, key)) return undefined;\n const chosen = extractSettings(text).model;\n const [provider, ...rest] = model.split('/');\n const ref = chosen ?? (provider && rest.length ? { provider, modelId: rest.join('/') } : null);\n const found = ref ? models.getModel(ref.provider, ref.modelId) : undefined;\n if (!found || !transcript || !admit()) return undefined;\n return completeText(models, found, `${prompt}\\n\\n${transcript}`, max);\n };\n}\n\nexport function titler(models: Models, settings: Settings) {\n const ask = smallModel(models, settings, 'titles', TITLE_PROMPT, 40);\n return async (transcript: string, model: string, context: Context) =>\n (await ask(transcript, model, context))?.text;\n}\n\nexport function labeler(models: Models, settings: Settings) {\n return smallModel(models, settings, 'toolLabels', LABEL_PROMPT, 40);\n}\n\nexport type Labe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AI,YAAY,OAAO,OAAO,IAAI;AAC7C;AAEO,SAAS,QAAQ,QAAgB,UAAoB;AAC1D,SAAO,WAAW,QAAQ,UAAU,cAAc,cAAc,EAAE;AACpE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Context } from '@earendil-works/chord';
|
|
2
|
-
import type { EntryRecord } from '@earendil-works/pi-durable';
|
|
2
|
+
import type { EntryRecord, ModelRef } from '@earendil-works/pi-durable';
|
|
3
3
|
import type { ExecutionEnv } from '@earendil-works/pi-durable/env';
|
|
4
4
|
import type { AgentsState } from '../agents.ts';
|
|
5
5
|
import type { MemoryEntry } from '../memory/format.ts';
|
|
@@ -25,6 +25,9 @@ export interface IntentSources {
|
|
|
25
25
|
context(context: Context): Promise<{
|
|
26
26
|
entries: readonly EntryRecord[];
|
|
27
27
|
}>;
|
|
28
|
+
agent?(context: Context): Promise<{
|
|
29
|
+
model?: ModelRef | null;
|
|
30
|
+
}>;
|
|
28
31
|
} | undefined>;
|
|
29
32
|
};
|
|
30
33
|
memories?: () => readonly MemoryEntry[] | undefined;
|
|
@@ -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>;
|