@ai-ecoverse/slicc-agent 7.26.0 → 7.28.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 +9 -6
- package/dist/approvals/index.js +74 -17
- package/dist/approvals/index.js.map +2 -2
- package/dist/approvals/people.js +5 -0
- package/dist/approvals/people.js.map +7 -0
- package/dist/approvals/reasons.js +19 -0
- package/dist/approvals/reasons.js.map +7 -0
- package/dist/approvals/record.js +19 -18
- package/dist/approvals/record.js.map +2 -2
- package/dist/approvals/stoppable.js +5 -0
- package/dist/approvals/stoppable.js.map +7 -0
- package/dist/approvals/sudo-client.js +16 -4
- package/dist/approvals/sudo-client.js.map +2 -2
- package/dist/approvals/sudo.js +13 -5
- package/dist/approvals/sudo.js.map +2 -2
- package/dist/host.js +1 -0
- package/dist/host.js.map +2 -2
- package/dist/index.js.map +2 -2
- package/dist/page.js +6 -1
- package/dist/page.js.map +2 -2
- package/dist/services.js.map +1 -1
- package/dist/spectrum/approvals-port.js +2 -0
- package/dist/spectrum/approvals-port.js.map +2 -2
- package/dist/types/approvals/index.d.ts +2 -0
- package/dist/types/approvals/people.d.ts +2 -0
- package/dist/types/approvals/reasons.d.ts +15 -0
- package/dist/types/approvals/record.d.ts +10 -18
- package/dist/types/approvals/stoppable.d.ts +2 -0
- package/dist/types/approvals/sudo-client.d.ts +2 -1
- package/dist/types/approvals/sudo.d.ts +9 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/page.d.ts +2 -2
- package/dist/types/services.d.ts +2 -2
- package/package.json +4 -4
package/dist/services.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/services.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Context, JsonValue, RemoteContract, ReplicatedState } from '@earendil-works/chord';\nimport type { BlockedReason, ConversationView } from '@earendil-works/pi-durable';\nimport type { Approval, ApprovalAnswer, ApprovalDecided } from './approvals/index.ts';\nimport type {\n ApprovalPolicy,\n ApprovalPolicyChange,\n ApprovalPolicySet,\n} from './approvals/policy.ts';\nimport type { AgentSudo } from './approvals/sudo.ts';\nimport type { SendAttachment, ShownAttachment } from './attachments.ts';\nimport type { ChangesView } from './changes/git.ts';\nimport type { FrozenCone } from './freezer/index.ts';\nimport type { ImportProgress, ImportResult } from './freezer/v6.ts';\nimport type { GuestOpened, Proposed, ProposeRequest } from './guests/index.ts';\nimport type { GuestDraft, GuestGates, GuestSeat } from './guests/seats.ts';\nimport type { MemoryEntry, MemoryScope, MemoryTag } from './memory/format.ts';\nimport type { EntriesPage, EntriesRequest } from './remote/history.ts';\nimport type { AgentRemote } from './remote/host.ts';\nimport type { AgentPages } from './remote/pages.ts';\nimport type { VaultState } from './secrets/vault.ts';\nimport { contract } from './serving.ts';\nimport type { DeviceSignIn } from './sign-ins.ts';\nimport type { SkillPackage, SkillSource } from './skills/skills.ts';\nimport type { Sprinkle } from './sprinkles/kind.ts';\n\nexport type SendMode = 'steer' | 'followUp' | 'reject';\n\nexport interface SendRequest {\n text: string;\n whenBusy: SendMode;\n requestId: string | null;\n agentId?: string | null;\n attachments?: SendAttachment[];\n}\n\nexport interface OperationError {\n code: string;\n message: string;\n}\n\nexport type SendResponse =\n | { accepted: true; submissionId: string; error: null }\n | { accepted: false; submissionId: null; error: OperationError };\n\nexport type PromptResult =\n | { status: 'done'; text: string; reason: null }\n | { status: 'unanswered'; text: null; reason: string };\n\nexport interface AgentControl {\n send(request: SendRequest, context: Context): Promise<SendResponse>;\n wait(submissionId: string, context: Context): Promise<PromptResult>;\n withdraw(\n submissionId: string,\n context: Context\n ): Promise<{ outcome: 'withdrawn' | 'already_placed' | 'not_found' }>;\n abort(context: Context): Promise<void>;\n compact(instructions: string | null, context: Context): Promise<SendResponse>;\n compactAgent(\n agentId: string,\n instructions: string | null,\n context: Context\n ): Promise<SendResponse>;\n reset(handoff: string | null, context: Context): Promise<void>;\n configure(change: AgentSettingsChange, context: Context): Promise<void>;\n rewind(messageId: string | null, context: Context): Promise<Rewound>;\n rewindAgent(agentId: string, messageId: string | null, context: Context): Promise<Rewound>;\n resolveLick(\n lickId: string,\n state: 'confirmed' | 'dismissed',\n context: Context\n ): Promise<LickResolved>;\n resolveAgentLick(\n agentId: string,\n lickId: string,\n state: 'confirmed' | 'dismissed',\n context: Context\n ): Promise<LickResolved>;\n webhook(\n name: string,\n delivery: WebhookRequest,\n context: Context\n ): Promise<{ delivered: boolean }>;\n stopAgent(agentId: string, context: Context): Promise<void>;\n selectCone(agentId: string, context: Context): Promise<void>;\n createCone(name: string, context: Context): Promise<Created>;\n createScoop(parentId: string, name: string, context: Context): Promise<Created>;\n drop(agentId: string, context: Context): Promise<Created>;\n unqueue(\n agentId: string | null,\n submissionId: string,\n context: Context\n ): Promise<{ outcome: 'withdrawn' | 'already_placed' | 'not_found' }>;\n sprinkleSend(\n sprinkleId: string,\n payload: { action: string; data: JsonValue | null; target: string | null },\n context: Context\n ): Promise<{ delivered: boolean }>;\n sprinkleCall(\n sprinkleId: string,\n method: string,\n args: JsonValue[],\n context: Context\n ): Promise<JsonValue>;\n memorySave(draft: MemoryDraft, context: Context): Promise<MemoryEntry>;\n memoryRemove(id: string, context: Context): Promise<{ removed: boolean }>;\n freeze(agentId: string, context: Context): Promise<Created>;\n newChat(agentId: string, context: Context): Promise<Created>;\n thaw(frozenId: string, context: Context): Promise<Created>;\n discard(frozenId: string, context: Context): Promise<Created>;\n importProfile(request: ImportRequest, context: Context): Promise<ImportResult>;\n importCancel(context: Context): Promise<void>;\n changesOpen(context: Context): Promise<void>;\n changeAccept(path: string, context: Context): Promise<Created>;\n changeRevert(path: string, context: Context): Promise<Created>;\n monitorOpen(lease: string | null, resync: boolean, context: Context): Promise<MonitorLease>;\n monitorClose(lease: string, context: Context): Promise<void>;\n image(ref: ImageRef, context: Context): Promise<StoredImage>;\n agentCommands(agentId: string, context: Context): Promise<Command[]>;\n toolLabel(agentId: string, callIds: string[], context: Context): Promise<string | null>;\n entries(request: EntriesRequest, context: Context): Promise<EntriesPage>;\n guestOpen(draft: GuestDraft, context: Context): Promise<GuestOpened>;\n guestRevoke(id: string, context: Context): Promise<{ revoked: boolean }>;\n guestAlwaysForget(\n seat: string,\n approval: string,\n context: Context\n ): Promise<{ removed: boolean }>;\n approvalPolicySet(change: ApprovalPolicyChange, context: Context): Promise<ApprovalPolicySet>;\n decide(\n id: string,\n decision: ApprovalAnswer,\n reason: string | null,\n context: Context\n ): Promise<ApprovalDecided>;\n}\n\nexport interface ImportRequest {\n upload: string | null;\n data: string | null;\n inPlace?: string | null;\n again: boolean;\n preview: boolean;\n}\n\nexport interface ImageRef {\n entry: number;\n message: number;\n part: number;\n}\n\nexport type StoredImage = { data: string; mimeType: string } | { data: null; mimeType: null };\n\nexport interface MonitorLease {\n lease: string;\n ttlMs: number;\n}\n\nexport interface MonitorAgent {\n id: string;\n name: string;\n kind: 'cone' | 'scoop';\n parentId: string | null;\n model: string | null;\n running: boolean;\n queued: number;\n tool: string | null;\n retry: { attempt: number; since: number; error: string } | null;\n failed: string | null;\n context: number | null;\n cpu?: number | null;\n}\n\nexport interface MonitorTask {\n id: string;\n kind: string;\n detail: string | null;\n agentId: string | null;\n owner: string | null;\n status: 'pending' | 'running' | 'waiting' | 'sleeping' | 'completing';\n phase: string;\n background: boolean;\n aborting: number | null;\n since: number;\n waits: number;\n until: number | null;\n blocked: BlockedReason | null;\n}\n\nexport interface MonitorProcess {\n pid: number;\n ppid: number;\n pgid: number;\n user: string | null;\n agentId: string | null;\n command: string;\n state: 'S' | 'Z';\n started: number;\n zombie: number | null;\n tty: boolean;\n rss: number | null;\n utime?: number;\n stime?: number;\n cpu?: number | null;\n}\n\nexport interface MonitorProblem {\n id: string;\n at: number;\n agentId: string | null;\n kind: 'task' | 'retry' | 'turn' | 'report';\n message: string;\n report?: { type: string; source: string | null };\n taskId?: string;\n}\n\nexport interface MonitorFeed {\n open: boolean;\n at: number;\n usage: { tokens: number; cost: number; free: boolean } | null;\n agents: MonitorAgent[];\n tasks: MonitorTask[];\n processes: MonitorProcess[] | null;\n kernel: 'checking' | 'ok' | 'unreachable';\n problems: MonitorProblem[];\n paused: boolean;\n latency?: MonitorLatency | null;\n}\n\nexport interface MonitorLatency {\n requests: number;\n medianMs: number;\n firstChunkMedianMs: number | null;\n errors: number;\n series: number[];\n models: { model: string; requests: number; medianMs: number }[];\n}\n\nexport interface MemoryDraft {\n id: string | null;\n scope: string;\n section: string;\n title: string;\n body: string;\n tag: MemoryTag | null;\n}\n\nexport type Created = { id: string; error: null } | { id: null; error: string };\n\nexport interface AgentSummary {\n id: string;\n name: string;\n kind: 'cone' | 'scoop';\n parentId: string | null;\n role: string | null;\n}\n\nexport interface AgentsSummary {\n active: string;\n agents: AgentSummary[];\n}\n\nexport type LickResolved =\n | { done: true; text: string; error: null }\n | { done: false; text: null; error: string };\n\nexport interface WebhookRequest {\n id: string | null;\n headers: Record<string, string>;\n body: string;\n}\n\nexport type Rewound =\n | { done: true; text: string; reason: null; attachments?: ShownAttachment[] }\n | { done: false; text: null; reason: 'busy' | 'no-turn' };\n\nexport interface AgentSettingsChange {\n model: { provider: string; modelId: string } | null;\n thinkingLevel: 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | null;\n agentId?: string | null;\n}\n\nconst keys = <T>(record: Record<keyof T, true>) => Object.keys(record) as (keyof T & string)[];\n\nexport const CONTROL_METHODS = keys<AgentControl>({\n send: true,\n wait: true,\n withdraw: true,\n abort: true,\n compact: true,\n compactAgent: true,\n reset: true,\n configure: true,\n rewind: true,\n rewindAgent: true,\n resolveLick: true,\n resolveAgentLick: true,\n webhook: true,\n stopAgent: true,\n selectCone: true,\n createCone: true,\n createScoop: true,\n drop: true,\n unqueue: true,\n sprinkleSend: true,\n sprinkleCall: true,\n memorySave: true,\n memoryRemove: true,\n freeze: true,\n newChat: true,\n thaw: true,\n discard: true,\n importProfile: true,\n importCancel: true,\n changesOpen: true,\n changeAccept: true,\n changeRevert: true,\n monitorOpen: true,\n monitorClose: true,\n image: true,\n agentCommands: true,\n toolLabel: true,\n entries: true,\n guestOpen: true,\n guestRevoke: true,\n guestAlwaysForget: true,\n approvalPolicySet: true,\n decide: true,\n});\n\nexport const OWNER_DEVICE_METHODS: readonly (keyof AgentControl & string)[] = [\n 'decide',\n 'guestOpen',\n 'guestRevoke',\n 'guestAlwaysForget',\n 'approvalPolicySet',\n];\n\nexport const CONTROL_READS: readonly (keyof AgentControl & string)[] = [\n 'wait',\n 'changesOpen',\n 'monitorOpen',\n 'monitorClose',\n 'image',\n 'toolLabel',\n 'entries',\n];\n\nexport const AgentControl: RemoteContract = contract('slicc.agent.control', {\n control: { methods: CONTROL_METHODS },\n view: { methods: [...CONTROL_READS, ...OWNER_DEVICE_METHODS] },\n});\n\nexport type Delivered = 'run' | 'steer' | 'follow-up';\n\nexport interface AgentTranscript {\n readonly state: ReplicatedState<ConversationView>;\n readonly deliveries: ReplicatedState<Record<string, Delivered>>;\n readonly agents: ReplicatedState<AgentsSummary>;\n readonly views: ReplicatedState<Record<string, ConversationView>>;\n readonly commands: ReplicatedState<Command[]>;\n readonly privateRevision: ReplicatedState<PrivateRevision>;\n readonly sprinkles: ReplicatedState<Sprinkle[]>;\n readonly memories: ReplicatedState<MemoryEntry[]>;\n readonly memoryScopes: ReplicatedState<MemoryScope[]>;\n readonly frozen: ReplicatedState<FrozenCone[]>;\n readonly importing: ReplicatedState<ImportProgress>;\n readonly changes: ReplicatedState<ChangesView>;\n readonly monitor: ReplicatedState<MonitorFeed>;\n readonly vault: ReplicatedState<VaultState>;\n readonly labels: ReplicatedState<Record<string, string>>;\n readonly guests: ReplicatedState<GuestSeat[]>;\n readonly approvals: ReplicatedState<Approval[]>;\n readonly approvalPolicy: ReplicatedState<ApprovalPolicy>;\n}\n\nexport interface PrivateRevision {\n revision: number;\n}\n\nexport interface Command {\n name: string;\n description: string;\n kind: 'prompt' | 'skill' | 'action';\n source?: SkillSource;\n package?: SkillPackage;\n}\n\nexport const TRANSCRIPT_STATES = keys<AgentTranscript>({\n state: true,\n deliveries: true,\n agents: true,\n views: true,\n commands: true,\n privateRevision: true,\n sprinkles: true,\n memories: true,\n memoryScopes: true,\n frozen: true,\n importing: true,\n changes: true,\n monitor: true,\n vault: true,\n labels: true,\n guests: true,\n approvals: true,\n approvalPolicy: true,\n});\n\nexport const AgentTranscript: RemoteContract = contract('slicc.agent.transcript', {\n transcript: { state: TRANSCRIPT_STATES },\n});\n\nexport const REMOTE_METHODS = keys<AgentRemote>({\n prompt: true,\n watch: true,\n history: true,\n next: true,\n close: true,\n abort: true,\n});\n\nexport const REMOTE_READS: readonly (keyof AgentRemote & string)[] = [\n 'watch',\n 'history',\n 'next',\n 'close',\n];\n\nexport interface GuestShown {\n id: string;\n label: string;\n agentId: string;\n name: string;\n expiresAt: number | null;\n gates: GuestGates;\n}\n\nexport interface GuestProposal {\n id: string;\n text: string;\n state: 'queued' | 'pending' | 'approved' | 'rejected' | 'unanswered' | 'withdrawn';\n reason: string | null;\n createdAt: number;\n decidedAt: number | null;\n}\n\nexport interface AgentGuest {\n readonly transcript: ReplicatedState<ConversationView>;\n readonly seat: ReplicatedState<GuestShown>;\n readonly proposals: ReplicatedState<GuestProposal[]>;\n propose(request: ProposeRequest, context: Context): Promise<Proposed>;\n guestOpen(draft: GuestDraft, context: Context): Promise<GuestOpened>;\n guestRevoke(id: string, context: Context): Promise<{ revoked: boolean }>;\n}\n\nexport const GUEST_STATES = ['transcript', 'seat', 'proposals'] as const;\n\nexport const GUEST_METHODS = ['propose', 'guestOpen', 'guestRevoke'] as const;\n\nexport const AgentGuestService: RemoteContract = contract('slicc.agent.guest', {\n guest: { state: GUEST_STATES, methods: GUEST_METHODS },\n none: {},\n});\n\nexport const AgentRemoteService: RemoteContract = contract('slicc.agent.remote', {\n remote: { methods: REMOTE_METHODS },\n watch: { methods: REMOTE_READS },\n});\n\nexport const PAGE_METHODS = keys<AgentPages>({\n open: true,\n report: true,\n next: true,\n answer: true,\n close: true,\n});\n\nexport const AgentPagesService: RemoteContract = contract('slicc.agent.pages', {\n pages: { methods: PAGE_METHODS },\n none: {},\n});\n\nexport const SUDO_METHODS = keys<Omit<AgentSudo, 'approvals'>>({\n request: true,\n withdraw: true,\n capture: true,\n});\n\nexport const AgentSudoService: RemoteContract = contract('slicc.agent.sudo', {\n sudo: { state: ['approvals'], methods: SUDO_METHODS },\n none: {},\n});\n\nexport interface ModelChoice {\n id: string;\n label: string;\n provider: string;\n kind: 'chat' | 'classifier';\n reasoning: boolean;\n images?: boolean;\n contextWindow: number;\n}\n\nexport interface AccountState {\n id: string;\n provider: string;\n identity: string;\n status: 'connected' | 'disconnected' | 'expired';\n auth: 'api-key' | 'oauth' | 'local';\n needs: 'cors-free-transport' | null;\n blocked?: 'cors-free-transport';\n group?: 'providers' | 'mcp';\n secret?: 'api-key' | 'token';\n store?: 'vault';\n fields?: AccountField[];\n description?: string;\n keyUrl?: string;\n vaultName?: string;\n state?: McpServerState;\n}\n\nexport type McpServerState =\n | 'connecting'\n | 'connected'\n | 'needs-secret'\n | 'needs-auth'\n | 'failed'\n | 'disabled'\n | 'refused';\n\nexport type McpRefusalCode =\n | 'bad-name'\n | 'duplicate'\n | 'not-found'\n | 'not-object'\n | 'bad-token'\n | 'token-conflict'\n | 'url-secret'\n | 'header-secret'\n | 'stdio'\n | 'sse'\n | 'bad-url'\n | 'insecure-url'\n | 'file-invalid'\n | 'file-unreadable'\n | 'file-unwritable'\n | 'not-owner'\n | 'invalid';\n\nexport interface McpRefusal {\n code: McpRefusalCode;\n reason: string;\n}\n\nexport type McpRefusals = Record<string, McpRefusal>;\n\nexport type McpEdit = { ok: true } | ({ ok: false } & McpRefusal);\n\nexport interface AccountField {\n name: string;\n label: string;\n required?: boolean;\n placeholder?: string;\n help?: string;\n customBase?: true;\n vaultSetting?: string;\n options?: readonly { value: string; label: string }[];\n value?: string;\n}\n\nexport interface ProviderOption {\n id: string;\n name: string;\n description?: string;\n auth: 'api-key' | 'oauth' | 'fields' | 'local';\n fields?: AccountField[];\n keyUrl?: string;\n needs?: 'cors-free-transport';\n blocked?: 'cors-free-transport';\n vaultName?: string;\n}\n\nexport interface BudgetState {\n provider: string;\n percent: number;\n window: 'weekly';\n resets: string;\n}\n\nexport interface SignIn {\n clientId: string;\n scopes: string;\n imsEnvironment: string;\n}\n\nexport interface McpSignIn {\n url: string;\n state: string;\n}\n\nexport interface SettingsState {\n models: ModelChoice[];\n accounts: AccountState[];\n providers?: ProviderOption[];\n budget?: BudgetState | null;\n budgets?: BudgetState[];\n moved?: { kind: 'model' | 'mcp'; label: string }[];\n labels?: Record<string, string>;\n}\n\nexport interface AgentSettings {\n readonly state: ReplicatedState<SettingsState>;\n connect(\n providerId: string,\n secret: string | null,\n fields: Record<string, string> | null,\n context: Context\n ): Promise<void>;\n disconnect(providerId: string, context: Context): Promise<void>;\n remove(providerId: string, context: Context): Promise<void>;\n serverUrl(providerId: string, context: Context): Promise<string | null>;\n signIn(providerId: string, context: Context): Promise<SignIn | McpSignIn | DeviceSignIn | null>;\n dismissMoved(context: Context): Promise<void>;\n addServer(name: string, entry: unknown, context: Context): Promise<McpEdit>;\n removeServer(id: string, context: Context): Promise<McpEdit>;\n refusals(context: Context): Promise<McpRefusals>;\n}\n\nexport const SETTINGS_METHODS = keys<\n Omit<AgentSettings, 'state' | 'addServer' | 'removeServer' | 'refusals'>\n>({\n connect: true,\n disconnect: true,\n remove: true,\n serverUrl: true,\n signIn: true,\n dismissMoved: true,\n});\n\nexport const OWNER_SETTINGS_METHODS: readonly (keyof Omit<AgentSettings, 'state'> & string)[] = [\n ...SETTINGS_METHODS,\n 'addServer',\n 'removeServer',\n 'refusals',\n];\n\nexport const AgentSettings: RemoteContract = contract('slicc.agent.settings', {\n owner: { state: ['state'], methods: OWNER_SETTINGS_METHODS },\n settings: { state: ['state'], methods: SETTINGS_METHODS },\n view: { state: ['state'] },\n});\n\nexport type InventoryStatus = 'running' | 'queued' | 'waiting' | 'error' | 'idle';\n\nexport const INVENTORY_STATUSES: readonly InventoryStatus[] = [\n 'running',\n 'queued',\n 'waiting',\n 'error',\n 'idle',\n];\n\nexport interface InventoryAgent {\n id: string;\n kind: 'cone' | 'scoop';\n parent?: string;\n status: InventoryStatus;\n queued: number;\n provider?: string;\n model?: string;\n since: number;\n}\n\nexport interface InventoryRow extends InventoryAgent {\n cone: string;\n}\n\nexport interface InventoryState {\n seq: number;\n changedAt: number;\n active: string;\n agents: InventoryRow[];\n}\n\nexport interface InventorySnapshot {\n seq: number;\n changedAt: number;\n counts: Record<InventoryStatus, number>;\n agents: InventoryAgent[];\n}\n\nexport interface AgentInventory {\n readonly inventory: ReplicatedState<InventoryState>;\n}\n\nexport const AgentInventoryService: RemoteContract = contract('slicc.agent.inventory', {\n owner: { state: ['inventory'] },\n none: {},\n});\n"],
|
|
4
|
+
"sourcesContent": ["import type { Context, JsonValue, RemoteContract, ReplicatedState } from '@earendil-works/chord';\nimport type { BlockedReason, ConversationView } from '@earendil-works/pi-durable';\nimport type { Approval, ApprovalDecided, ApprovalDecision } from './approvals/index.ts';\nimport type {\n ApprovalPolicy,\n ApprovalPolicyChange,\n ApprovalPolicySet,\n} from './approvals/policy.ts';\nimport type { AgentSudo } from './approvals/sudo.ts';\nimport type { SendAttachment, ShownAttachment } from './attachments.ts';\nimport type { ChangesView } from './changes/git.ts';\nimport type { FrozenCone } from './freezer/index.ts';\nimport type { ImportProgress, ImportResult } from './freezer/v6.ts';\nimport type { GuestOpened, Proposed, ProposeRequest } from './guests/index.ts';\nimport type { GuestDraft, GuestGates, GuestSeat } from './guests/seats.ts';\nimport type { MemoryEntry, MemoryScope, MemoryTag } from './memory/format.ts';\nimport type { EntriesPage, EntriesRequest } from './remote/history.ts';\nimport type { AgentRemote } from './remote/host.ts';\nimport type { AgentPages } from './remote/pages.ts';\nimport type { VaultState } from './secrets/vault.ts';\nimport { contract } from './serving.ts';\nimport type { DeviceSignIn } from './sign-ins.ts';\nimport type { SkillPackage, SkillSource } from './skills/skills.ts';\nimport type { Sprinkle } from './sprinkles/kind.ts';\n\nexport type SendMode = 'steer' | 'followUp' | 'reject';\n\nexport interface SendRequest {\n text: string;\n whenBusy: SendMode;\n requestId: string | null;\n agentId?: string | null;\n attachments?: SendAttachment[];\n}\n\nexport interface OperationError {\n code: string;\n message: string;\n}\n\nexport type SendResponse =\n | { accepted: true; submissionId: string; error: null }\n | { accepted: false; submissionId: null; error: OperationError };\n\nexport type PromptResult =\n | { status: 'done'; text: string; reason: null }\n | { status: 'unanswered'; text: null; reason: string };\n\nexport interface AgentControl {\n send(request: SendRequest, context: Context): Promise<SendResponse>;\n wait(submissionId: string, context: Context): Promise<PromptResult>;\n withdraw(\n submissionId: string,\n context: Context\n ): Promise<{ outcome: 'withdrawn' | 'already_placed' | 'not_found' }>;\n abort(context: Context): Promise<void>;\n compact(instructions: string | null, context: Context): Promise<SendResponse>;\n compactAgent(\n agentId: string,\n instructions: string | null,\n context: Context\n ): Promise<SendResponse>;\n reset(handoff: string | null, context: Context): Promise<void>;\n configure(change: AgentSettingsChange, context: Context): Promise<void>;\n rewind(messageId: string | null, context: Context): Promise<Rewound>;\n rewindAgent(agentId: string, messageId: string | null, context: Context): Promise<Rewound>;\n resolveLick(\n lickId: string,\n state: 'confirmed' | 'dismissed',\n context: Context\n ): Promise<LickResolved>;\n resolveAgentLick(\n agentId: string,\n lickId: string,\n state: 'confirmed' | 'dismissed',\n context: Context\n ): Promise<LickResolved>;\n webhook(\n name: string,\n delivery: WebhookRequest,\n context: Context\n ): Promise<{ delivered: boolean }>;\n stopAgent(agentId: string, context: Context): Promise<void>;\n selectCone(agentId: string, context: Context): Promise<void>;\n createCone(name: string, context: Context): Promise<Created>;\n createScoop(parentId: string, name: string, context: Context): Promise<Created>;\n drop(agentId: string, context: Context): Promise<Created>;\n unqueue(\n agentId: string | null,\n submissionId: string,\n context: Context\n ): Promise<{ outcome: 'withdrawn' | 'already_placed' | 'not_found' }>;\n sprinkleSend(\n sprinkleId: string,\n payload: { action: string; data: JsonValue | null; target: string | null },\n context: Context\n ): Promise<{ delivered: boolean }>;\n sprinkleCall(\n sprinkleId: string,\n method: string,\n args: JsonValue[],\n context: Context\n ): Promise<JsonValue>;\n memorySave(draft: MemoryDraft, context: Context): Promise<MemoryEntry>;\n memoryRemove(id: string, context: Context): Promise<{ removed: boolean }>;\n freeze(agentId: string, context: Context): Promise<Created>;\n newChat(agentId: string, context: Context): Promise<Created>;\n thaw(frozenId: string, context: Context): Promise<Created>;\n discard(frozenId: string, context: Context): Promise<Created>;\n importProfile(request: ImportRequest, context: Context): Promise<ImportResult>;\n importCancel(context: Context): Promise<void>;\n changesOpen(context: Context): Promise<void>;\n changeAccept(path: string, context: Context): Promise<Created>;\n changeRevert(path: string, context: Context): Promise<Created>;\n monitorOpen(lease: string | null, resync: boolean, context: Context): Promise<MonitorLease>;\n monitorClose(lease: string, context: Context): Promise<void>;\n image(ref: ImageRef, context: Context): Promise<StoredImage>;\n agentCommands(agentId: string, context: Context): Promise<Command[]>;\n toolLabel(agentId: string, callIds: string[], context: Context): Promise<string | null>;\n entries(request: EntriesRequest, context: Context): Promise<EntriesPage>;\n guestOpen(draft: GuestDraft, context: Context): Promise<GuestOpened>;\n guestRevoke(id: string, context: Context): Promise<{ revoked: boolean }>;\n guestAlwaysForget(\n seat: string,\n approval: string,\n context: Context\n ): Promise<{ removed: boolean }>;\n approvalPolicySet(change: ApprovalPolicyChange, context: Context): Promise<ApprovalPolicySet>;\n decide(\n id: string,\n decision: ApprovalDecision,\n reason: string | null,\n context: Context\n ): Promise<ApprovalDecided>;\n}\n\nexport interface ImportRequest {\n upload: string | null;\n data: string | null;\n inPlace?: string | null;\n again: boolean;\n preview: boolean;\n}\n\nexport interface ImageRef {\n entry: number;\n message: number;\n part: number;\n}\n\nexport type StoredImage = { data: string; mimeType: string } | { data: null; mimeType: null };\n\nexport interface MonitorLease {\n lease: string;\n ttlMs: number;\n}\n\nexport interface MonitorAgent {\n id: string;\n name: string;\n kind: 'cone' | 'scoop';\n parentId: string | null;\n model: string | null;\n running: boolean;\n queued: number;\n tool: string | null;\n retry: { attempt: number; since: number; error: string } | null;\n failed: string | null;\n context: number | null;\n cpu?: number | null;\n}\n\nexport interface MonitorTask {\n id: string;\n kind: string;\n detail: string | null;\n agentId: string | null;\n owner: string | null;\n status: 'pending' | 'running' | 'waiting' | 'sleeping' | 'completing';\n phase: string;\n background: boolean;\n aborting: number | null;\n since: number;\n waits: number;\n until: number | null;\n blocked: BlockedReason | null;\n}\n\nexport interface MonitorProcess {\n pid: number;\n ppid: number;\n pgid: number;\n user: string | null;\n agentId: string | null;\n command: string;\n state: 'S' | 'Z';\n started: number;\n zombie: number | null;\n tty: boolean;\n rss: number | null;\n utime?: number;\n stime?: number;\n cpu?: number | null;\n}\n\nexport interface MonitorProblem {\n id: string;\n at: number;\n agentId: string | null;\n kind: 'task' | 'retry' | 'turn' | 'report';\n message: string;\n report?: { type: string; source: string | null };\n taskId?: string;\n}\n\nexport interface MonitorFeed {\n open: boolean;\n at: number;\n usage: { tokens: number; cost: number; free: boolean } | null;\n agents: MonitorAgent[];\n tasks: MonitorTask[];\n processes: MonitorProcess[] | null;\n kernel: 'checking' | 'ok' | 'unreachable';\n problems: MonitorProblem[];\n paused: boolean;\n latency?: MonitorLatency | null;\n}\n\nexport interface MonitorLatency {\n requests: number;\n medianMs: number;\n firstChunkMedianMs: number | null;\n errors: number;\n series: number[];\n models: { model: string; requests: number; medianMs: number }[];\n}\n\nexport interface MemoryDraft {\n id: string | null;\n scope: string;\n section: string;\n title: string;\n body: string;\n tag: MemoryTag | null;\n}\n\nexport type Created = { id: string; error: null } | { id: null; error: string };\n\nexport interface AgentSummary {\n id: string;\n name: string;\n kind: 'cone' | 'scoop';\n parentId: string | null;\n role: string | null;\n}\n\nexport interface AgentsSummary {\n active: string;\n agents: AgentSummary[];\n}\n\nexport type LickResolved =\n | { done: true; text: string; error: null }\n | { done: false; text: null; error: string };\n\nexport interface WebhookRequest {\n id: string | null;\n headers: Record<string, string>;\n body: string;\n}\n\nexport type Rewound =\n | { done: true; text: string; reason: null; attachments?: ShownAttachment[] }\n | { done: false; text: null; reason: 'busy' | 'no-turn' };\n\nexport interface AgentSettingsChange {\n model: { provider: string; modelId: string } | null;\n thinkingLevel: 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | null;\n agentId?: string | null;\n}\n\nconst keys = <T>(record: Record<keyof T, true>) => Object.keys(record) as (keyof T & string)[];\n\nexport const CONTROL_METHODS = keys<AgentControl>({\n send: true,\n wait: true,\n withdraw: true,\n abort: true,\n compact: true,\n compactAgent: true,\n reset: true,\n configure: true,\n rewind: true,\n rewindAgent: true,\n resolveLick: true,\n resolveAgentLick: true,\n webhook: true,\n stopAgent: true,\n selectCone: true,\n createCone: true,\n createScoop: true,\n drop: true,\n unqueue: true,\n sprinkleSend: true,\n sprinkleCall: true,\n memorySave: true,\n memoryRemove: true,\n freeze: true,\n newChat: true,\n thaw: true,\n discard: true,\n importProfile: true,\n importCancel: true,\n changesOpen: true,\n changeAccept: true,\n changeRevert: true,\n monitorOpen: true,\n monitorClose: true,\n image: true,\n agentCommands: true,\n toolLabel: true,\n entries: true,\n guestOpen: true,\n guestRevoke: true,\n guestAlwaysForget: true,\n approvalPolicySet: true,\n decide: true,\n});\n\nexport const OWNER_DEVICE_METHODS: readonly (keyof AgentControl & string)[] = [\n 'decide',\n 'guestOpen',\n 'guestRevoke',\n 'guestAlwaysForget',\n 'approvalPolicySet',\n];\n\nexport const CONTROL_READS: readonly (keyof AgentControl & string)[] = [\n 'wait',\n 'changesOpen',\n 'monitorOpen',\n 'monitorClose',\n 'image',\n 'toolLabel',\n 'entries',\n];\n\nexport const AgentControl: RemoteContract = contract('slicc.agent.control', {\n control: { methods: CONTROL_METHODS },\n view: { methods: [...CONTROL_READS, ...OWNER_DEVICE_METHODS] },\n});\n\nexport type Delivered = 'run' | 'steer' | 'follow-up';\n\nexport interface AgentTranscript {\n readonly state: ReplicatedState<ConversationView>;\n readonly deliveries: ReplicatedState<Record<string, Delivered>>;\n readonly agents: ReplicatedState<AgentsSummary>;\n readonly views: ReplicatedState<Record<string, ConversationView>>;\n readonly commands: ReplicatedState<Command[]>;\n readonly privateRevision: ReplicatedState<PrivateRevision>;\n readonly sprinkles: ReplicatedState<Sprinkle[]>;\n readonly memories: ReplicatedState<MemoryEntry[]>;\n readonly memoryScopes: ReplicatedState<MemoryScope[]>;\n readonly frozen: ReplicatedState<FrozenCone[]>;\n readonly importing: ReplicatedState<ImportProgress>;\n readonly changes: ReplicatedState<ChangesView>;\n readonly monitor: ReplicatedState<MonitorFeed>;\n readonly vault: ReplicatedState<VaultState>;\n readonly labels: ReplicatedState<Record<string, string>>;\n readonly guests: ReplicatedState<GuestSeat[]>;\n readonly approvals: ReplicatedState<Approval[]>;\n readonly approvalPolicy: ReplicatedState<ApprovalPolicy>;\n}\n\nexport interface PrivateRevision {\n revision: number;\n}\n\nexport interface Command {\n name: string;\n description: string;\n kind: 'prompt' | 'skill' | 'action';\n source?: SkillSource;\n package?: SkillPackage;\n}\n\nexport const TRANSCRIPT_STATES = keys<AgentTranscript>({\n state: true,\n deliveries: true,\n agents: true,\n views: true,\n commands: true,\n privateRevision: true,\n sprinkles: true,\n memories: true,\n memoryScopes: true,\n frozen: true,\n importing: true,\n changes: true,\n monitor: true,\n vault: true,\n labels: true,\n guests: true,\n approvals: true,\n approvalPolicy: true,\n});\n\nexport const AgentTranscript: RemoteContract = contract('slicc.agent.transcript', {\n transcript: { state: TRANSCRIPT_STATES },\n});\n\nexport const REMOTE_METHODS = keys<AgentRemote>({\n prompt: true,\n watch: true,\n history: true,\n next: true,\n close: true,\n abort: true,\n});\n\nexport const REMOTE_READS: readonly (keyof AgentRemote & string)[] = [\n 'watch',\n 'history',\n 'next',\n 'close',\n];\n\nexport interface GuestShown {\n id: string;\n label: string;\n agentId: string;\n name: string;\n expiresAt: number | null;\n gates: GuestGates;\n}\n\nexport interface GuestProposal {\n id: string;\n text: string;\n state: 'queued' | 'pending' | 'approved' | 'rejected' | 'unanswered' | 'withdrawn';\n reason: string | null;\n createdAt: number;\n decidedAt: number | null;\n}\n\nexport interface AgentGuest {\n readonly transcript: ReplicatedState<ConversationView>;\n readonly seat: ReplicatedState<GuestShown>;\n readonly proposals: ReplicatedState<GuestProposal[]>;\n propose(request: ProposeRequest, context: Context): Promise<Proposed>;\n guestOpen(draft: GuestDraft, context: Context): Promise<GuestOpened>;\n guestRevoke(id: string, context: Context): Promise<{ revoked: boolean }>;\n}\n\nexport const GUEST_STATES = ['transcript', 'seat', 'proposals'] as const;\n\nexport const GUEST_METHODS = ['propose', 'guestOpen', 'guestRevoke'] as const;\n\nexport const AgentGuestService: RemoteContract = contract('slicc.agent.guest', {\n guest: { state: GUEST_STATES, methods: GUEST_METHODS },\n none: {},\n});\n\nexport const AgentRemoteService: RemoteContract = contract('slicc.agent.remote', {\n remote: { methods: REMOTE_METHODS },\n watch: { methods: REMOTE_READS },\n});\n\nexport const PAGE_METHODS = keys<AgentPages>({\n open: true,\n report: true,\n next: true,\n answer: true,\n close: true,\n});\n\nexport const AgentPagesService: RemoteContract = contract('slicc.agent.pages', {\n pages: { methods: PAGE_METHODS },\n none: {},\n});\n\nexport const SUDO_METHODS = keys<Omit<AgentSudo, 'approvals'>>({\n request: true,\n withdraw: true,\n capture: true,\n});\n\nexport const AgentSudoService: RemoteContract = contract('slicc.agent.sudo', {\n sudo: { state: ['approvals'], methods: SUDO_METHODS },\n none: {},\n});\n\nexport interface ModelChoice {\n id: string;\n label: string;\n provider: string;\n kind: 'chat' | 'classifier';\n reasoning: boolean;\n images?: boolean;\n contextWindow: number;\n}\n\nexport interface AccountState {\n id: string;\n provider: string;\n identity: string;\n status: 'connected' | 'disconnected' | 'expired';\n auth: 'api-key' | 'oauth' | 'local';\n needs: 'cors-free-transport' | null;\n blocked?: 'cors-free-transport';\n group?: 'providers' | 'mcp';\n secret?: 'api-key' | 'token';\n store?: 'vault';\n fields?: AccountField[];\n description?: string;\n keyUrl?: string;\n vaultName?: string;\n state?: McpServerState;\n}\n\nexport type McpServerState =\n | 'connecting'\n | 'connected'\n | 'needs-secret'\n | 'needs-auth'\n | 'failed'\n | 'disabled'\n | 'refused';\n\nexport type McpRefusalCode =\n | 'bad-name'\n | 'duplicate'\n | 'not-found'\n | 'not-object'\n | 'bad-token'\n | 'token-conflict'\n | 'url-secret'\n | 'header-secret'\n | 'stdio'\n | 'sse'\n | 'bad-url'\n | 'insecure-url'\n | 'file-invalid'\n | 'file-unreadable'\n | 'file-unwritable'\n | 'not-owner'\n | 'invalid';\n\nexport interface McpRefusal {\n code: McpRefusalCode;\n reason: string;\n}\n\nexport type McpRefusals = Record<string, McpRefusal>;\n\nexport type McpEdit = { ok: true } | ({ ok: false } & McpRefusal);\n\nexport interface AccountField {\n name: string;\n label: string;\n required?: boolean;\n placeholder?: string;\n help?: string;\n customBase?: true;\n vaultSetting?: string;\n options?: readonly { value: string; label: string }[];\n value?: string;\n}\n\nexport interface ProviderOption {\n id: string;\n name: string;\n description?: string;\n auth: 'api-key' | 'oauth' | 'fields' | 'local';\n fields?: AccountField[];\n keyUrl?: string;\n needs?: 'cors-free-transport';\n blocked?: 'cors-free-transport';\n vaultName?: string;\n}\n\nexport interface BudgetState {\n provider: string;\n percent: number;\n window: 'weekly';\n resets: string;\n}\n\nexport interface SignIn {\n clientId: string;\n scopes: string;\n imsEnvironment: string;\n}\n\nexport interface McpSignIn {\n url: string;\n state: string;\n}\n\nexport interface SettingsState {\n models: ModelChoice[];\n accounts: AccountState[];\n providers?: ProviderOption[];\n budget?: BudgetState | null;\n budgets?: BudgetState[];\n moved?: { kind: 'model' | 'mcp'; label: string }[];\n labels?: Record<string, string>;\n}\n\nexport interface AgentSettings {\n readonly state: ReplicatedState<SettingsState>;\n connect(\n providerId: string,\n secret: string | null,\n fields: Record<string, string> | null,\n context: Context\n ): Promise<void>;\n disconnect(providerId: string, context: Context): Promise<void>;\n remove(providerId: string, context: Context): Promise<void>;\n serverUrl(providerId: string, context: Context): Promise<string | null>;\n signIn(providerId: string, context: Context): Promise<SignIn | McpSignIn | DeviceSignIn | null>;\n dismissMoved(context: Context): Promise<void>;\n addServer(name: string, entry: unknown, context: Context): Promise<McpEdit>;\n removeServer(id: string, context: Context): Promise<McpEdit>;\n refusals(context: Context): Promise<McpRefusals>;\n}\n\nexport const SETTINGS_METHODS = keys<\n Omit<AgentSettings, 'state' | 'addServer' | 'removeServer' | 'refusals'>\n>({\n connect: true,\n disconnect: true,\n remove: true,\n serverUrl: true,\n signIn: true,\n dismissMoved: true,\n});\n\nexport const OWNER_SETTINGS_METHODS: readonly (keyof Omit<AgentSettings, 'state'> & string)[] = [\n ...SETTINGS_METHODS,\n 'addServer',\n 'removeServer',\n 'refusals',\n];\n\nexport const AgentSettings: RemoteContract = contract('slicc.agent.settings', {\n owner: { state: ['state'], methods: OWNER_SETTINGS_METHODS },\n settings: { state: ['state'], methods: SETTINGS_METHODS },\n view: { state: ['state'] },\n});\n\nexport type InventoryStatus = 'running' | 'queued' | 'waiting' | 'error' | 'idle';\n\nexport const INVENTORY_STATUSES: readonly InventoryStatus[] = [\n 'running',\n 'queued',\n 'waiting',\n 'error',\n 'idle',\n];\n\nexport interface InventoryAgent {\n id: string;\n kind: 'cone' | 'scoop';\n parent?: string;\n status: InventoryStatus;\n queued: number;\n provider?: string;\n model?: string;\n since: number;\n}\n\nexport interface InventoryRow extends InventoryAgent {\n cone: string;\n}\n\nexport interface InventoryState {\n seq: number;\n changedAt: number;\n active: string;\n agents: InventoryRow[];\n}\n\nexport interface InventorySnapshot {\n seq: number;\n changedAt: number;\n counts: Record<InventoryStatus, number>;\n agents: InventoryAgent[];\n}\n\nexport interface AgentInventory {\n readonly inventory: ReplicatedState<InventoryState>;\n}\n\nexport const AgentInventoryService: RemoteContract = contract('slicc.agent.inventory', {\n owner: { state: ['inventory'] },\n none: {},\n});\n"],
|
|
5
5
|
"mappings": "AAoBA,SAAS,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AAAA,EACV,SAAS;AACX,CAAC;AAEM,MAAM,mBAAmC,SAAS,oBAAoB;AAAA,EAC3E,MAAM,EAAE,OAAO,CAAC,WAAW,GAAG,SAAS,aAAa;AAAA,EACpD,MAAM,CAAC;AACT,CAAC;AAyIM,MAAM,mBAAmB,KAE9B;AAAA,EACA,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,cAAc;AAChB,CAAC;AAEM,MAAM,yBAAmF;AAAA,EAC9F,GAAG;AAAA,EACH;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,gBAAgC,SAAS,wBAAwB;AAAA,EAC5E,OAAO,EAAE,OAAO,CAAC,OAAO,GAAG,SAAS,uBAAuB;AAAA,EAC3D,UAAU,EAAE,OAAO,CAAC,OAAO,GAAG,SAAS,iBAAiB;AAAA,EACxD,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE;AAC3B,CAAC;AAIM,MAAM,qBAAiD;AAAA,EAC5D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAmCO,MAAM,wBAAwC,SAAS,yBAAyB;AAAA,EACrF,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE;AAAA,EAC9B,MAAM,CAAC;AACT,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BACKGROUND_CONTEXT } from "@earendil-works/chord/context";
|
|
2
2
|
import { fits } from "../approvals/aligned.js";
|
|
3
|
+
import { stoppable } from "../approvals/stoppable.js";
|
|
3
4
|
import { Emitter } from "./emitter.js";
|
|
4
5
|
const ENDS = {
|
|
5
6
|
approved: "answered",
|
|
@@ -62,6 +63,7 @@ function shown(item, agentName) {
|
|
|
62
63
|
...cwd ? { cwd } : {},
|
|
63
64
|
always: item.always,
|
|
64
65
|
...alwaysScope ? { alwaysScope } : {},
|
|
66
|
+
...stoppable(item) ? { stoppable: true } : {},
|
|
65
67
|
...verdictOf(item)
|
|
66
68
|
};
|
|
67
69
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/spectrum/approvals-port.ts"],
|
|
4
|
-
"sourcesContent": ["import type {\n Approval,\n ApprovalDecision,\n ApprovalEnd,\n ApprovalRequester,\n ApprovalsEvents,\n ApprovalsPort,\n GuestToolApproval,\n} from '@ai-ecoverse/slicc-spectrum/ui';\nimport { BACKGROUND_CONTEXT } from '@earendil-works/chord/context';\nimport { fits } from '../approvals/aligned.ts';\nimport type { Approval as Item } from '../approvals/record.ts';\nimport type { AgentConnection } from '../client.ts';\nimport { Emitter } from './emitter.ts';\n\nconst ENDS: Record<string, ApprovalEnd> = {\n approved: 'answered',\n rejected: 'answered',\n unanswered: 'expired',\n withdrawn: 'withdrawn',\n};\n\nexport const ARGS_LENGTH = 65_536;\n\nfunction pretty(text: string): string {\n try {\n return JSON.stringify(JSON.parse(text), null, 2);\n } catch {\n return text;\n }\n}\n\nfunction argsOf(text: string | undefined): Pick<GuestToolApproval, 'args' | 'argsTruncated'> {\n if (text === undefined) return {};\n const args = pretty(text);\n if (args.length <= ARGS_LENGTH) return { args };\n const end = /[\\uD800-\\uDBFF]/.test(args[ARGS_LENGTH - 1] as string)\n ? ARGS_LENGTH - 1\n : ARGS_LENGTH;\n return { args: args.slice(0, end), argsTruncated: true };\n}\n\nfunction requesterOf(item: Item): ApprovalRequester {\n const { kind, name, agentId, where } = item.requester;\n return {\n kind,\n name,\n ...(agentId ? { agentId } : {}),\n ...(where ? { where } : {}),\n };\n}\n\nfunction verdictOf(item: Item) {\n const { verdict, judging, verdictError } = item;\n return {\n ...(verdict\n ? {\n verdict: {\n ...(verdict.level ? { level: verdict.level } : {}),\n ...(verdict.aligned === undefined ? {} : { aligned: fits(verdict.aligned) }),\n reason: verdict.reason,\n },\n }\n : {}),\n ...(judging ? { judging: true } : {}),\n ...(verdictError ? { verdictError } : {}),\n };\n}\n\nexport function shown(item: Item, agentName: string | undefined): Approval {\n const base = {\n id: item.id,\n requester: requesterOf(item),\n createdAt: item.createdAt,\n expiresAt: item.expiresAt,\n };\n if (item.kind === 'sudo') {\n const { command, target, cwd, alwaysScope } = item.detail;\n return {\n ...base,\n kind: 'sudo',\n command,\n ...(target ? { target } : {}),\n ...(cwd ? { cwd } : {}),\n always: item.always,\n ...(alwaysScope ? { alwaysScope } : {}),\n ...verdictOf(item),\n };\n }\n const guest = {\n ...base,\n agentId: item.agentId,\n ...(agentName ? { agentName } : {}),\n always: item.always,\n ...verdictOf(item),\n };\n if (item.kind === 'capture') return { ...guest, kind: 'capture', detail: { ...item.detail } };\n if (item.kind === 'guest-tool')\n return {\n ...guest,\n kind: 'guest-tool',\n tool: item.detail.tool,\n summary: item.detail.summary,\n ...argsOf(item.detail.arguments),\n };\n return {\n ...guest,\n kind: 'guest-message',\n text: item.detail.text,\n ...(item.detail.attachments.length\n ? { attachments: item.detail.attachments.map((file) => ({ ...file })) }\n : {}),\n };\n}\n\nexport type HostApprovals = ApprovalsPort;\n\nexport const NOT_HERE = \"This request can't be answered in this tab.\";\n\nconst asked = (item: Item) => item.state === 'pending' && item.tier === 'user';\n\nexport class ApprovalsAdapter extends Emitter<ApprovalsEvents> implements ApprovalsPort {\n readonly #connection: AgentConnection;\n readonly #host: HostApprovals | undefined;\n readonly #ours: boolean;\n readonly #mine = new Set<string>();\n readonly #deciding = new Set<string>();\n #listed = new Set<string>();\n readonly decide?: (id: string, decision: ApprovalDecision, reason?: string) => Promise<void>;\n\n constructor(connection: AgentConnection, host?: HostApprovals) {\n super();\n this.#connection = connection;\n this.#host = host;\n this.#ours = !connection.guest;\n if (this.#ours || host?.decide) this.decide = (...args) => this.#route(...args);\n this.#listed = new Set(this.#agent().map((approval) => approval.id));\n connection.approvals?.subscribe(() => this.#changed());\n host?.on('approvals', () => this.emit('approvals', this.list()));\n host?.on('ended', (detail) => this.emit('ended', detail));\n }\n\n #items(): readonly Item[] {\n return this.#connection.approvals?.value ?? [];\n }\n\n list(): readonly Approval[] {\n return [...(this.#host?.list() ?? []), ...this.#agent()].sort(\n (a, b) => a.createdAt - b.createdAt\n );\n }\n\n #agent(): readonly Approval[] {\n const names = new Map(\n (this.#connection.agents?.value?.agents ?? []).map((agent) => [agent.id, agent.name])\n );\n return this.#items()\n .filter((item) => asked(item) && !this.#mine.has(item.id))\n .sort((a, b) => a.createdAt - b.createdAt)\n .map((item) => shown(item, names.get(item.agentId)));\n }\n\n #changed(): void {\n const items = new Map(this.#items().map((item) => [item.id, item]));\n const listed = this.#agent();\n const now = new Set(listed.map((approval) => approval.id));\n for (const id of this.#listed) {\n if (now.has(id) || this.#mine.has(id) || this.#deciding.has(id)) continue;\n const state = items.get(id)?.state;\n this.emit('ended', { id, reason: (state && ENDS[state]) || 'answered' });\n }\n for (const id of this.#mine) {\n const item = items.get(id);\n if (!item || !asked(item)) this.#mine.delete(id);\n }\n this.#listed = now;\n this.emit('approvals', this.list());\n }\n\n #route(id: string, decision: ApprovalDecision, reason?: string): Promise<void> {\n const host = this.#host;\n if (host?.list().some((approval) => approval.id === id)) {\n if (!host.decide) return Promise.reject(new Error(NOT_HERE));\n return host.decide(id, decision, reason);\n }\n if (!this.#ours) return Promise.reject(new Error(NOT_HERE));\n return this.#decide(id, decision, reason);\n }\n\n async #decide(id: string, decision: ApprovalDecision, reason?: string): Promise<void> {\n this.#deciding.add(id);\n try {\n const answer = await this.#connection.control.decide(\n id,\n decision,\n reason ?? null,\n BACKGROUND_CONTEXT\n );\n if (!answer.done) throw new Error(answer.error);\n this.#mine.add(id);\n } finally {\n this.#deciding.delete(id);\n }\n this.#changed();\n }\n}\n"],
|
|
5
|
-
"mappings": "AASA,SAAS,0BAA0B;AACnC,SAAS,YAAY;
|
|
4
|
+
"sourcesContent": ["import type {\n Approval,\n ApprovalDecision,\n ApprovalEnd,\n ApprovalRequester,\n ApprovalsEvents,\n ApprovalsPort,\n GuestToolApproval,\n} from '@ai-ecoverse/slicc-spectrum/ui';\nimport { BACKGROUND_CONTEXT } from '@earendil-works/chord/context';\nimport { fits } from '../approvals/aligned.ts';\nimport type { Approval as Item } from '../approvals/record.ts';\nimport { stoppable } from '../approvals/stoppable.ts';\nimport type { AgentConnection } from '../client.ts';\nimport { Emitter } from './emitter.ts';\n\nconst ENDS: Record<string, ApprovalEnd> = {\n approved: 'answered',\n rejected: 'answered',\n unanswered: 'expired',\n withdrawn: 'withdrawn',\n};\n\nexport const ARGS_LENGTH = 65_536;\n\nfunction pretty(text: string): string {\n try {\n return JSON.stringify(JSON.parse(text), null, 2);\n } catch {\n return text;\n }\n}\n\nfunction argsOf(text: string | undefined): Pick<GuestToolApproval, 'args' | 'argsTruncated'> {\n if (text === undefined) return {};\n const args = pretty(text);\n if (args.length <= ARGS_LENGTH) return { args };\n const end = /[\\uD800-\\uDBFF]/.test(args[ARGS_LENGTH - 1] as string)\n ? ARGS_LENGTH - 1\n : ARGS_LENGTH;\n return { args: args.slice(0, end), argsTruncated: true };\n}\n\nfunction requesterOf(item: Item): ApprovalRequester {\n const { kind, name, agentId, where } = item.requester;\n return {\n kind,\n name,\n ...(agentId ? { agentId } : {}),\n ...(where ? { where } : {}),\n };\n}\n\nfunction verdictOf(item: Item) {\n const { verdict, judging, verdictError } = item;\n return {\n ...(verdict\n ? {\n verdict: {\n ...(verdict.level ? { level: verdict.level } : {}),\n ...(verdict.aligned === undefined ? {} : { aligned: fits(verdict.aligned) }),\n reason: verdict.reason,\n },\n }\n : {}),\n ...(judging ? { judging: true } : {}),\n ...(verdictError ? { verdictError } : {}),\n };\n}\n\nexport function shown(item: Item, agentName: string | undefined): Approval {\n const base = {\n id: item.id,\n requester: requesterOf(item),\n createdAt: item.createdAt,\n expiresAt: item.expiresAt,\n };\n if (item.kind === 'sudo') {\n const { command, target, cwd, alwaysScope } = item.detail;\n return {\n ...base,\n kind: 'sudo',\n command,\n ...(target ? { target } : {}),\n ...(cwd ? { cwd } : {}),\n always: item.always,\n ...(alwaysScope ? { alwaysScope } : {}),\n ...(stoppable(item) ? { stoppable: true } : {}),\n ...verdictOf(item),\n };\n }\n const guest = {\n ...base,\n agentId: item.agentId,\n ...(agentName ? { agentName } : {}),\n always: item.always,\n ...verdictOf(item),\n };\n if (item.kind === 'capture') return { ...guest, kind: 'capture', detail: { ...item.detail } };\n if (item.kind === 'guest-tool')\n return {\n ...guest,\n kind: 'guest-tool',\n tool: item.detail.tool,\n summary: item.detail.summary,\n ...argsOf(item.detail.arguments),\n };\n return {\n ...guest,\n kind: 'guest-message',\n text: item.detail.text,\n ...(item.detail.attachments.length\n ? { attachments: item.detail.attachments.map((file) => ({ ...file })) }\n : {}),\n };\n}\n\nexport type HostApprovals = ApprovalsPort;\n\nexport const NOT_HERE = \"This request can't be answered in this tab.\";\n\nconst asked = (item: Item) => item.state === 'pending' && item.tier === 'user';\n\nexport class ApprovalsAdapter extends Emitter<ApprovalsEvents> implements ApprovalsPort {\n readonly #connection: AgentConnection;\n readonly #host: HostApprovals | undefined;\n readonly #ours: boolean;\n readonly #mine = new Set<string>();\n readonly #deciding = new Set<string>();\n #listed = new Set<string>();\n readonly decide?: (id: string, decision: ApprovalDecision, reason?: string) => Promise<void>;\n\n constructor(connection: AgentConnection, host?: HostApprovals) {\n super();\n this.#connection = connection;\n this.#host = host;\n this.#ours = !connection.guest;\n if (this.#ours || host?.decide) this.decide = (...args) => this.#route(...args);\n this.#listed = new Set(this.#agent().map((approval) => approval.id));\n connection.approvals?.subscribe(() => this.#changed());\n host?.on('approvals', () => this.emit('approvals', this.list()));\n host?.on('ended', (detail) => this.emit('ended', detail));\n }\n\n #items(): readonly Item[] {\n return this.#connection.approvals?.value ?? [];\n }\n\n list(): readonly Approval[] {\n return [...(this.#host?.list() ?? []), ...this.#agent()].sort(\n (a, b) => a.createdAt - b.createdAt\n );\n }\n\n #agent(): readonly Approval[] {\n const names = new Map(\n (this.#connection.agents?.value?.agents ?? []).map((agent) => [agent.id, agent.name])\n );\n return this.#items()\n .filter((item) => asked(item) && !this.#mine.has(item.id))\n .sort((a, b) => a.createdAt - b.createdAt)\n .map((item) => shown(item, names.get(item.agentId)));\n }\n\n #changed(): void {\n const items = new Map(this.#items().map((item) => [item.id, item]));\n const listed = this.#agent();\n const now = new Set(listed.map((approval) => approval.id));\n for (const id of this.#listed) {\n if (now.has(id) || this.#mine.has(id) || this.#deciding.has(id)) continue;\n const state = items.get(id)?.state;\n this.emit('ended', { id, reason: (state && ENDS[state]) || 'answered' });\n }\n for (const id of this.#mine) {\n const item = items.get(id);\n if (!item || !asked(item)) this.#mine.delete(id);\n }\n this.#listed = now;\n this.emit('approvals', this.list());\n }\n\n #route(id: string, decision: ApprovalDecision, reason?: string): Promise<void> {\n const host = this.#host;\n if (host?.list().some((approval) => approval.id === id)) {\n if (!host.decide) return Promise.reject(new Error(NOT_HERE));\n return host.decide(id, decision, reason);\n }\n if (!this.#ours) return Promise.reject(new Error(NOT_HERE));\n return this.#decide(id, decision, reason);\n }\n\n async #decide(id: string, decision: ApprovalDecision, reason?: string): Promise<void> {\n this.#deciding.add(id);\n try {\n const answer = await this.#connection.control.decide(\n id,\n decision,\n reason ?? null,\n BACKGROUND_CONTEXT\n );\n if (!answer.done) throw new Error(answer.error);\n this.#mine.add(id);\n } finally {\n this.#deciding.delete(id);\n }\n this.#changed();\n }\n}\n"],
|
|
5
|
+
"mappings": "AASA,SAAS,0BAA0B;AACnC,SAAS,YAAY;AAErB,SAAS,iBAAiB;AAE1B,SAAS,eAAe;AAExB,MAAM,OAAoC;AAAA,EACxC,UAAU;AAAA,EACV,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,WAAW;AACb;AAEO,MAAM,cAAc;AAE3B,SAAS,OAAO,MAAsB;AACpC,MAAI;AACF,WAAO,KAAK,UAAU,KAAK,MAAM,IAAI,GAAG,MAAM,CAAC;AAAA,EACjD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,SAAS,OAAO,MAA6E;AAC3F,MA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OAAO,KAAM,OAAM,IAAI,MAAM,OAAO,KAAK;AAC9C,WAAK,MAAM,IAAI,EAAE;AAAA,IACnB,UAAE;AACA,WAAK,UAAU,OAAO,EAAE;AAAA,IAC1B;AACA,SAAK,SAAS;AAAA,EAChB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -46,5 +46,7 @@ export interface ApprovalsAttach {
|
|
|
46
46
|
guestAlways?: (kind: ApprovalKind) => boolean;
|
|
47
47
|
sudoApprover?: () => unknown;
|
|
48
48
|
present?: (item: Approval, context: Context) => Promise<boolean>;
|
|
49
|
+
stop?: (agentId: string, context: Context) => Promise<void>;
|
|
49
50
|
}
|
|
51
|
+
export declare const NO_STOP = "This agent can't stop a turn.";
|
|
50
52
|
export declare function attachApprovals(options: ApprovalsAttach, context?: Context): Promise<Approvals>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const REASONS: {
|
|
2
|
+
readonly timeout: 'timeout';
|
|
3
|
+
readonly unknownTier: 'unknown-tier';
|
|
4
|
+
readonly unroutable: 'unroutable';
|
|
5
|
+
readonly unknownAnswer: 'unknown-answer';
|
|
6
|
+
readonly restart: 'restart';
|
|
7
|
+
readonly revoked: 'revoked';
|
|
8
|
+
readonly aborted: 'aborted';
|
|
9
|
+
readonly disconnected: 'disconnected';
|
|
10
|
+
readonly noScoop: 'no-scoop';
|
|
11
|
+
readonly scoopStopped: 'scoop-stopped';
|
|
12
|
+
readonly scoopAsked: 'scoop-asked';
|
|
13
|
+
readonly scoopUndecided: 'scoop-undecided';
|
|
14
|
+
readonly stopped: 'stopped';
|
|
15
|
+
};
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { fits, JUDGE_ALLOW } from './aligned.ts';
|
|
2
|
-
|
|
2
|
+
import { personal } from './people.ts';
|
|
3
|
+
import { REASONS } from './reasons.ts';
|
|
4
|
+
import { stoppable } from './stoppable.ts';
|
|
5
|
+
export { fits, JUDGE_ALLOW, personal, REASONS, stoppable };
|
|
3
6
|
export type ApprovalKind = 'guest-message' | 'guest-tool' | 'sudo' | 'capture';
|
|
4
7
|
export type ApprovalState = 'pending' | 'approved' | 'rejected' | 'unanswered' | 'withdrawn';
|
|
5
8
|
export type ApprovalTier = 'user' | 'agent' | 'cone' | `scoop:${string}`;
|
|
6
9
|
export type ApprovalAnswer = 'once' | 'always' | 'deny';
|
|
10
|
+
export type ApprovalDecision = ApprovalAnswer | 'stop';
|
|
7
11
|
export type DecidedBy = 'owner' | 'follower' | 'judge' | 'host' | `scoop:${string}`;
|
|
8
12
|
export type ApprovalRequester = {
|
|
9
13
|
kind: 'guest' | 'agent' | 'user';
|
|
@@ -51,6 +55,7 @@ export type SudoDetail = {
|
|
|
51
55
|
stdin?: SudoStdin;
|
|
52
56
|
rootOnly?: Record<string, boolean>;
|
|
53
57
|
writable?: boolean;
|
|
58
|
+
validate?: true;
|
|
54
59
|
};
|
|
55
60
|
export type CaptureWhat = 'screen' | 'camera' | 'microphone';
|
|
56
61
|
export type CaptureMode = 'still' | 'video' | 'audio';
|
|
@@ -115,31 +120,17 @@ export declare const APPROVAL_MS = 300000;
|
|
|
115
120
|
export declare const APPROVALS_KEPT = 100;
|
|
116
121
|
export declare const MAX_DELAY = 2147483647;
|
|
117
122
|
export declare const REASON_LENGTH = 500;
|
|
118
|
-
export declare const REASONS: {
|
|
119
|
-
readonly timeout: 'timeout';
|
|
120
|
-
readonly unknownTier: 'unknown-tier';
|
|
121
|
-
readonly unroutable: 'unroutable';
|
|
122
|
-
readonly unknownAnswer: 'unknown-answer';
|
|
123
|
-
readonly restart: 'restart';
|
|
124
|
-
readonly revoked: 'revoked';
|
|
125
|
-
readonly aborted: 'aborted';
|
|
126
|
-
readonly disconnected: 'disconnected';
|
|
127
|
-
readonly noScoop: 'no-scoop';
|
|
128
|
-
readonly scoopStopped: 'scoop-stopped';
|
|
129
|
-
readonly scoopAsked: 'scoop-asked';
|
|
130
|
-
readonly scoopUndecided: 'scoop-undecided';
|
|
131
|
-
};
|
|
132
123
|
export declare const guestKind: (kind: ApprovalKind) => boolean;
|
|
133
124
|
export declare const scoopTier: (tier: unknown) => tier is `scoop:${string}`;
|
|
134
125
|
export declare function knownTier(tier: unknown): tier is ApprovalTier;
|
|
135
126
|
export declare const heldKind: (kind: ApprovalKind) => boolean;
|
|
136
127
|
export declare function routable(kind: ApprovalKind, tier: ApprovalTier): boolean;
|
|
137
|
-
export declare function answerOf(value: unknown):
|
|
138
|
-
export declare const personal: (by: DecidedBy) => boolean;
|
|
128
|
+
export declare function answerOf(value: unknown): ApprovalDecision | null;
|
|
139
129
|
export declare function answerer(by: DecidedBy, item: Pick<Approval, 'tier' | 'reviewer'>): boolean;
|
|
140
130
|
export type SudoApprover = 'user' | 'agent';
|
|
141
131
|
export declare const sudoApprover: (value: unknown) => SudoApprover;
|
|
142
|
-
export declare const
|
|
132
|
+
export declare const personOnly: (item: Pick<ApprovalDraft, 'kind' | 'detail'>) => boolean;
|
|
133
|
+
export declare const tierOf: (draft: Pick<ApprovalDraft, 'kind' | 'detail' | 'tier'>, sudo: SudoApprover) => string;
|
|
143
134
|
export type Gate = 'person' | 'judge';
|
|
144
135
|
export type Routed = 'approve' | 'deny' | 'ask';
|
|
145
136
|
export declare const gateOf: (tier: string) => Gate;
|
|
@@ -159,5 +150,6 @@ export type Ruling = {
|
|
|
159
150
|
error?: string;
|
|
160
151
|
settle?: Settle;
|
|
161
152
|
answer?: 'once' | 'always';
|
|
153
|
+
stop?: string;
|
|
162
154
|
};
|
|
163
155
|
export declare function ruled(item: Approval, answer: unknown, reason: unknown, by: DecidedBy, at: number): Ruling;
|
|
@@ -10,7 +10,8 @@ export declare const UNAVAILABLE = "The agent can't take this sudo request.";
|
|
|
10
10
|
export declare const unavailable: (cause?: unknown) => Error;
|
|
11
11
|
export declare function answerOf(item: Approval | undefined): SudoAnswer | null;
|
|
12
12
|
export declare const JUDGE_DENIED = "sudo: denied by the approval judge";
|
|
13
|
-
export declare
|
|
13
|
+
export declare const STOPPED = "sudo: denied, and the owner stopped this turn";
|
|
14
|
+
export declare function replyOf(item: Approval | undefined, stamps?: boolean): SudoReply | null;
|
|
14
15
|
export declare const WITHDRAW_MS = 5000;
|
|
15
16
|
export interface CaptureAsk {
|
|
16
17
|
kind: string;
|
|
@@ -9,7 +9,11 @@ export type SudoDenial = {
|
|
|
9
9
|
answer: 'deny';
|
|
10
10
|
message: string;
|
|
11
11
|
};
|
|
12
|
-
export type
|
|
12
|
+
export type SudoTimestamp = {
|
|
13
|
+
answer: 'once' | 'always';
|
|
14
|
+
timestamp: true;
|
|
15
|
+
};
|
|
16
|
+
export type SudoReply = SudoAnswer | SudoDenial | SudoTimestamp;
|
|
13
17
|
export interface SudoRequest {
|
|
14
18
|
id: string;
|
|
15
19
|
kind: 'sudo';
|
|
@@ -28,6 +32,8 @@ export interface SudoRequest {
|
|
|
28
32
|
always?: boolean;
|
|
29
33
|
stdin?: SudoStdin;
|
|
30
34
|
rootOnly?: Record<string, boolean>;
|
|
35
|
+
timestamp?: boolean;
|
|
36
|
+
validate?: boolean;
|
|
31
37
|
}
|
|
32
38
|
export type SudoAsked = {
|
|
33
39
|
id: string;
|
|
@@ -47,6 +53,8 @@ export declare function sudoRequester(request: SudoRequest, agents: Readonly<Age
|
|
|
47
53
|
requester: ApprovalRequester;
|
|
48
54
|
agentId: string;
|
|
49
55
|
};
|
|
56
|
+
export declare const validating: (request: Pick<SudoRequest, 'validate'>) => boolean;
|
|
57
|
+
export declare const timestampFor: (user: string) => string;
|
|
50
58
|
export declare function sudoDetail(request: SudoRequest): SudoDetail;
|
|
51
59
|
export interface SudoAttach {
|
|
52
60
|
approvals: Approvals;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { ADOBE, ADOBE_PROXY, type AdobeConfig, type AdobeModelInfo, adobeClassifiers, adobeConfig, adobeIdentity, adobeModel, adobeProvider, adobeUsage, type Budget, SESSION_HEADER, VERSION_HEADER, withAdobeIdentity, } from './adobe.ts';
|
|
2
2
|
export { type Agent, type AgentOptions, answerText, openAgent } from './agent.ts';
|
|
3
|
-
export { APPROVAL_MS, type Approval, type ApprovalAnswer, type ApprovalDecided, type ApprovalDraft, type ApprovalJudge, type ApprovalKind, type ApprovalRequester, type ApprovalState, type Approvals, ApprovalsDoc, type ApprovalTier, type ApprovalVerdict, 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';
|
|
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
4
|
export { type ApprovalPolicy, type ApprovalPolicyChange, type ApprovalPolicySet, DEFAULT_APPROVAL_POLICY, type SudoPolicy, } from './approvals/policy.ts';
|
|
5
|
-
export type { AgentSudo, SudoAnswer, SudoDenial, SudoReply, SudoRequest, } from './approvals/sudo.ts';
|
|
5
|
+
export type { AgentSudo, SudoAnswer, SudoDenial, SudoReply, SudoRequest, SudoTimestamp, } from './approvals/sudo.ts';
|
|
6
6
|
export type { CaptureAsk } from './approvals/sudo-client.ts';
|
|
7
7
|
export { FILE_LIMIT, IMAGE_LIMIT, type SendAttachment, type ShownAttachment, splitUser, TOTAL_LIMIT, userParts, } from './attachments.ts';
|
|
8
8
|
export { type AgentConnection, connectAgent } from './client.ts';
|
package/dist/types/page.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type { SudoAnswer, SudoDenial, SudoReply, SudoRequest } from './approvals/sudo.ts';
|
|
2
|
-
export { type ApproveOptions, JUDGE_DENIED, UNAVAILABLE } from './approvals/sudo-client.ts';
|
|
1
|
+
export type { SudoAnswer, SudoDenial, SudoReply, SudoRequest, SudoTimestamp, } from './approvals/sudo.ts';
|
|
2
|
+
export { type ApproveOptions, JUDGE_DENIED, STOPPED, UNAVAILABLE, } from './approvals/sudo-client.ts';
|
|
3
3
|
export { type AgentConnection, connectAgent } from './client.ts';
|
|
4
4
|
export { connectGuest, GUEST_ONLY, type GuestConnection, SEAT_REFUSED, } from './guests/client.ts';
|
|
5
5
|
export { type ByteSink, bridgePort, encodeFrame, FrameReader, type LinkEnd, linkEndpoint, MAX_FRAME, } from './link.ts';
|
package/dist/types/services.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Context, JsonValue, RemoteContract, ReplicatedState } from '@earendil-works/chord';
|
|
2
2
|
import type { BlockedReason, ConversationView } from '@earendil-works/pi-durable';
|
|
3
|
-
import type { Approval,
|
|
3
|
+
import type { Approval, ApprovalDecided, ApprovalDecision } from './approvals/index.ts';
|
|
4
4
|
import type { ApprovalPolicy, ApprovalPolicyChange, ApprovalPolicySet } from './approvals/policy.ts';
|
|
5
5
|
import type { SendAttachment, ShownAttachment } from './attachments.ts';
|
|
6
6
|
import type { ChangesView } from './changes/git.ts';
|
|
@@ -106,7 +106,7 @@ export interface AgentControl {
|
|
|
106
106
|
removed: boolean;
|
|
107
107
|
}>;
|
|
108
108
|
approvalPolicySet(change: ApprovalPolicyChange, context: Context): Promise<ApprovalPolicySet>;
|
|
109
|
-
decide(id: string, decision:
|
|
109
|
+
decide(id: string, decision: ApprovalDecision, reason: string | null, context: Context): Promise<ApprovalDecided>;
|
|
110
110
|
}
|
|
111
111
|
export interface ImportRequest {
|
|
112
112
|
upload: string | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/slicc-agent",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.28.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",
|
|
@@ -73,11 +73,11 @@
|
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@ai-ecoverse/slicc-jsh": "0.64.0",
|
|
76
|
-
"@ai-ecoverse/slicc-kernel": "1.
|
|
76
|
+
"@ai-ecoverse/slicc-kernel": "1.177.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": "2.
|
|
80
|
-
"@ai-ecoverse/wasi-fnox": "1.
|
|
79
|
+
"@ai-ecoverse/slicc-spectrum": "2.9.2",
|
|
80
|
+
"@ai-ecoverse/wasi-fnox": "1.46.0-2",
|
|
81
81
|
"@ai-ecoverse/wasm-bash": "5.3.0-23",
|
|
82
82
|
"@ai-ecoverse/wasm-coreutils": "9.12.0-15",
|
|
83
83
|
"@ai-ecoverse/wasm-git": "2.55.0-22",
|