@capybara-hq/kernel 0.1.0-rc.118 → 0.1.0-rc.119

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/automations/unattended.d.ts +2 -0
  2. package/dist/automations/unattended.js +10 -3
  3. package/dist/catalog/marketplaces.service.d.ts +1 -1
  4. package/dist/channels/cards.d.ts +2 -4
  5. package/dist/channels/cards.js +11 -6
  6. package/dist/channels/phrases.d.ts +4 -0
  7. package/dist/channels/phrases.js +1 -0
  8. package/dist/conversations/conversations.service.js +2 -0
  9. package/dist/conversations/events.d.ts +26 -0
  10. package/dist/conversations/events.js +27 -4
  11. package/dist/ctx/create-ctx.d.ts +1 -1
  12. package/dist/ctx/create-ctx.js +4 -0
  13. package/dist/db/kernel-schema.d.ts +17 -1
  14. package/dist/device-access/device-access.module.js +2 -0
  15. package/dist/device-access/device-access.service.d.ts +16 -2
  16. package/dist/device-access/device-access.service.js +59 -2
  17. package/dist/device-access/site-access-request.d.ts +14 -0
  18. package/dist/device-access/site-access-request.js +35 -0
  19. package/dist/device-access/site-grants.d.ts +53 -0
  20. package/dist/device-access/site-grants.js +268 -0
  21. package/dist/device-access/site-grants.module.d.ts +2 -0
  22. package/dist/device-access/site-grants.module.js +14 -0
  23. package/dist/devices/devices.service.js +2 -0
  24. package/dist/extensions/admin-ops.js +7 -0
  25. package/dist/extensions/org-config.js +4 -0
  26. package/dist/extensions/permission-set.d.ts +3 -0
  27. package/dist/extensions/permission-set.js +5 -0
  28. package/dist/extensions/permission-view.d.ts +1 -1
  29. package/dist/extensions/permission-view.js +7 -1
  30. package/dist/orgs/offboarding.js +2 -0
  31. package/dist/roles/worker.module.js +2 -0
  32. package/dist/sandbox/loopback-expiry.job.d.ts +3 -1
  33. package/dist/sandbox/loopback-expiry.job.js +9 -3
  34. package/dist/sandbox/operation-authority.d.ts +1 -1
  35. package/dist/sandbox/operation-authority.js +14 -6
  36. package/dist/sandbox/permission-call-types.d.ts +2 -2
  37. package/dist/sandbox/review/classifier.d.ts +13 -4
  38. package/dist/sandbox/review/classifier.js +73 -22
  39. package/dist/sandbox/review/permission-candidate.d.ts +3 -3
  40. package/dist/sandbox/review/permission-candidate.js +10 -8
  41. package/dist/sandbox/review/review.service.d.ts +26 -19
  42. package/dist/sandbox/review/review.service.js +69 -15
  43. package/dist/tools/approvals.service.d.ts +30 -4
  44. package/dist/tools/approvals.service.js +143 -12
  45. package/dist/tools/call-scope.d.ts +3 -0
  46. package/dist/tools/call-scope.js +1 -0
  47. package/dist/tools/network-asks.js +7 -0
  48. package/dist/tools/pipeline.d.ts +16 -5
  49. package/dist/tools/pipeline.js +314 -11
  50. package/dist/tools/tools.module.js +2 -0
  51. package/package.json +2 -2
  52. package/src/migrations/0205_device_site_grants.sql +30 -0
@@ -15,24 +15,29 @@ import { normalizeStoredDefinition } from "../agents/definition.js";
15
15
  import { readAutomationSettings } from "../automations/effective-settings.js";
16
16
  import { GIT_GRANT_SPEC_HASH, gitGrantRefusal, gitPushGrantKey, grantRefusalOf, NETWORK_GRANT_PREFIX, NETWORK_GRANT_SPEC_HASH, networkGrantRefusal, normalizeGitRepo, } from "../automations/grant-rules.js";
17
17
  import { AutomationStore } from "../automations/store.js";
18
- import { unattendedTaskRunOf } from "../automations/unattended.js";
18
+ import { unattendedRunOf, unattendedTaskRunOf } from "../automations/unattended.js";
19
19
  import { EventLog } from "../conversations/event-log.js";
20
20
  import { COMMAND_ASK_TEXT_MAX_CHARS, GIT_ASK_MAX_REFS, GIT_REF_MAX_CHARS, NETWORK_ASK_MAX_HOSTS, NETWORK_HOST_MAX_CHARS, SECURE_INPUT_MAX_FIELDS, } from "../conversations/events.js";
21
21
  import { ConversationLeakCheck } from "../conversations/leak-check.js";
22
22
  import { conversationSourceOf } from "../conversations/source.js";
23
+ import { siteAccessDetailHash, siteAccessInstallActive, } from "../device-access/site-access-request.js";
24
+ import { DeviceSiteGrants } from "../device-access/site-grants.js";
23
25
  import { DevicesService } from "../devices/devices.service.js";
24
26
  import { ApiError } from "../errors.js";
27
+ import { isExtensionEnabled } from "../extensions/enabled.js";
25
28
  import { clipText } from "../extensions/hooks.js";
29
+ import { ExtensionRegistry } from "../extensions/registry.js";
26
30
  import { loadPeople } from "../identity/account-avatar.js";
27
31
  import { audit } from "../identity/audit.js";
28
32
  import { sha256Hex } from "../identity/hash.js";
29
33
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
30
34
  import { KernelDb } from "../infra/database/kernel-db.js";
31
- import { TransactionHost, withOrderedLocks, withTransactionFencePrelude, } from "../infra/database/transaction-host.js";
35
+ import { queueAfterCommit, TransactionHost, withOrderedLocks, withTransactionFencePrelude, } from "../infra/database/transaction-host.js";
32
36
  import { Transactional } from "../infra/database/transactional.decorator.js";
33
37
  import { KernelEvents } from "../infra/events/kernel-events.js";
34
38
  import { LockService } from "../infra/lock/lock.service.js";
35
39
  import { WithLock } from "../infra/lock/with-lock.decorator.js";
40
+ import { OrgLock } from "../orgs/org-lock.js";
36
41
  import { ORG_ROLES, roleAtLeast } from "../orgs/roles.js";
37
42
  import { checkPersonValue } from "../platform/person-fields.js";
38
43
  import { SealedInputs } from "../platform/sealed-inputs.js";
@@ -51,7 +56,7 @@ export { APPROVAL_DENY_REASON_MAX_CHARS } from "../conversations/events.js";
51
56
  export const APPROVALS_LIST_MAX = 100;
52
57
  /** The hosts a network ask asked about, whichever kind it is (a loopback port ask: none). */
53
58
  export function networkAskHosts(detail) {
54
- if (detail.kind === "loopback")
59
+ if (detail.kind === "loopback" || detail.kind === "site")
55
60
  return [];
56
61
  return detail.kind === "service"
57
62
  ? [...detail.hosts]
@@ -232,6 +237,9 @@ let ApprovalsService = class ApprovalsService {
232
237
  permissionLocks;
233
238
  permissionGrants;
234
239
  loopback;
240
+ site;
241
+ orgLock;
242
+ extensions;
235
243
  constructor(db, config, eventLog, events, txHost, automations,
236
244
  /** A trial approval is kept only for a tool the task may hold as a grant (its agent's tools). */
237
245
  registry,
@@ -248,7 +256,7 @@ let ApprovalsService = class ApprovalsService {
248
256
  /** A network ask's "add to this device's list" writes the device's own network list. */
249
257
  devices, permissionLocks, permissionGrants,
250
258
  /** A loopback port ask's approval writes the root conversation's grant (absent: refused). */
251
- loopback) {
259
+ loopback, site, orgLock, extensions) {
252
260
  this.db = db;
253
261
  this.config = config;
254
262
  this.eventLog = eventLog;
@@ -265,6 +273,9 @@ let ApprovalsService = class ApprovalsService {
265
273
  this.permissionLocks = permissionLocks;
266
274
  this.permissionGrants = permissionGrants;
267
275
  this.loopback = loopback;
276
+ this.site = site;
277
+ this.orgLock = orgLock;
278
+ this.extensions = extensions;
268
279
  }
269
280
  /**
270
281
  * 新建 pending 审批(`expires_at` = 现在 + `tools.approvalTimeoutHours`)并写 `approval_requested`,同一事务。
@@ -492,6 +503,13 @@ let ApprovalsService = class ApprovalsService {
492
503
  await this.eventLog.notify(record.conversationId, toSeq);
493
504
  return record;
494
505
  }
506
+ async requestSiteAccess(input, recordReview) {
507
+ await recordReview();
508
+ const { record, toSeq } = await this.requestNetworkIn(input);
509
+ if (toSeq !== null)
510
+ queueAfterCommit(() => this.eventLog.notify(record.conversationId, toSeq));
511
+ return record;
512
+ }
495
513
  async requestNetworkIn(input) {
496
514
  const hours = this.config.get().tools.approvalTimeoutHours;
497
515
  const t = this.db.db;
@@ -562,7 +580,15 @@ let ApprovalsService = class ApprovalsService {
562
580
  database: input.detail.database,
563
581
  },
564
582
  }
565
- : { network: { hosts: networkAskHosts(input.detail) } }),
583
+ : input.detail.kind === "site"
584
+ ? {
585
+ site: {
586
+ service: input.detail.service,
587
+ action: input.detail.action,
588
+ origin: input.detail.origin,
589
+ },
590
+ }
591
+ : { network: { hosts: networkAskHosts(input.detail) } }),
566
592
  requestedFor: rec.requestedFor,
567
593
  approverRole: null,
568
594
  },
@@ -974,6 +1000,21 @@ let ApprovalsService = class ApprovalsService {
974
1000
  throw new ApiError("approval.already_decided", "Approval has expired");
975
1001
  if (detail.kind === "loopback")
976
1002
  return this.decideLoopback(orgId, ask, detail, accountId, body, via, opts.panelGrantOnly);
1003
+ if (detail.kind === "site") {
1004
+ if (via !== "web") {
1005
+ throw new ApiError("auth.session_required", "Review this site action in the signed-in web app.");
1006
+ }
1007
+ const decided = await withOrderedLocks(async () => {
1008
+ if (body.decision === "approve") {
1009
+ if (!this.orgLock)
1010
+ throw new ApiError("conflict", "Site approval is unavailable");
1011
+ await this.orgLock.lock(orgId);
1012
+ await this.devices.lockNetworkAddSubject(orgId, accountId, detail.deviceId);
1013
+ }
1014
+ }, () => this.decideSiteIn(orgId, ask, detail, accountId, body, via));
1015
+ await this.announceDecided(decided.record, decided.toSeq);
1016
+ return decided.record;
1017
+ }
977
1018
  const asked = [...new Set(networkAskHosts(detail))];
978
1019
  let network;
979
1020
  if (body.decision === "approve") {
@@ -1024,6 +1065,61 @@ let ApprovalsService = class ApprovalsService {
1024
1065
  await this.announceDecided(decided.record, decided.toSeq);
1025
1066
  return decided.record;
1026
1067
  }
1068
+ async decideSiteIn(orgId, ask, detail, accountId, body, via) {
1069
+ if (body.hosts !== undefined) {
1070
+ throw new ApiError("validation_failed", "A site action takes no hosts");
1071
+ }
1072
+ const approved = body.decision === "approve";
1073
+ let scope = approved ? (body.scope ?? "once") : null;
1074
+ if (scope !== null &&
1075
+ ((scope !== "once" && scope !== "session") || !ask.scopes.includes(scope))) {
1076
+ throw new ApiError("approval.scope_not_allowed", "This site action does not offer that scope");
1077
+ }
1078
+ if (approved) {
1079
+ if (!this.site || !this.orgLock || !this.extensions) {
1080
+ throw new ApiError("conflict", "Site approval is unavailable");
1081
+ }
1082
+ const instance = this.extensions.current(detail.extension);
1083
+ const permissions = instance?.manifest.permissions?.deviceAccess;
1084
+ const active = instance !== undefined &&
1085
+ (await siteAccessInstallActive(this.db.db, detail.extension, instance.sha256, true));
1086
+ const root = await this.db
1087
+ .selectFrom("conversations")
1088
+ .select(["device_id", "account_id", "automation_id"])
1089
+ .where("org_id", "=", orgId)
1090
+ .where("id", "=", detail.rootConversationId)
1091
+ .where("deleted_at", "is", null)
1092
+ .forNoKeyUpdate()
1093
+ .executeTakeFirst();
1094
+ const unattended = await unattendedRunOf(this.db.db, this.config, orgId, ask.runId);
1095
+ if (root?.device_id !== detail.deviceId ||
1096
+ root.account_id !== accountId ||
1097
+ root.automation_id !== null ||
1098
+ (unattended !== null && !unattended.trial) ||
1099
+ !active ||
1100
+ permissions?.siteAccess !== true ||
1101
+ !permissions.services.some((name) => `${detail.extension}.${name}` === detail.service) ||
1102
+ !(await isExtensionEnabled(this.db.db, orgId, detail.extension))) {
1103
+ throw new ApiError("conflict", "This site action is no longer available");
1104
+ }
1105
+ if (scope === "session") {
1106
+ const granted = await this.site.grantIn({
1107
+ orgId,
1108
+ deviceId: detail.deviceId,
1109
+ serviceId: detail.service,
1110
+ rootConversationId: detail.rootConversationId,
1111
+ origin: detail.origin,
1112
+ action: detail.action,
1113
+ }, { approvalId: ask.id, actorAccountId: accountId });
1114
+ if (granted === null)
1115
+ scope = "once";
1116
+ }
1117
+ }
1118
+ const decision = await this.decideTx(orgId, ask.id, accountId, scope === null ? body : { ...body, scope }, undefined, { wanted: [], granted: [], outcome: scope, via });
1119
+ if ("leaked" in decision)
1120
+ throw new Error("Unexpected site approval leak outcome");
1121
+ return decision;
1122
+ }
1027
1123
  /**
1028
1124
  * A loopback port ask's decision (browser loopback port grants), under {@link decideNetwork}'s
1029
1125
  * lock and checks (the device owner, a signed-in session, still pending): an approval takes
@@ -1478,11 +1574,16 @@ let ApprovalsService = class ApprovalsService {
1478
1574
  // what took effect; run grants read grantedHosts (a loopback port ask: its grant row)
1479
1575
  detail: JSON.stringify((before.detail.kind === "loopback"
1480
1576
  ? { ...before.detail, outcome: "session" }
1481
- : {
1482
- ...before.detail,
1483
- grantedHosts: network.granted,
1484
- outcome: network.outcome === "always" ? "always" : "once",
1485
- })),
1577
+ : before.detail.kind === "site"
1578
+ ? {
1579
+ ...before.detail,
1580
+ outcome: network.outcome === "session" ? "session" : "once",
1581
+ }
1582
+ : {
1583
+ ...before.detail,
1584
+ grantedHosts: network.granted,
1585
+ outcome: network.outcome === "always" ? "always" : "once",
1586
+ })),
1486
1587
  }),
1487
1588
  ...(git?.outcome != null &&
1488
1589
  before.git !== null && {
@@ -1566,7 +1667,7 @@ let ApprovalsService = class ApprovalsService {
1566
1667
  if (git?.outcome === "once")
1567
1668
  await this.keepTrialGitGrant(before, accountId);
1568
1669
  // "Allow once" in a trial run: the task's grants (network ask-to-allow spec §8.1)
1569
- if (network?.outcome === "once") {
1670
+ if (network?.outcome === "once" && before.detail?.kind !== "site") {
1570
1671
  await this.keepTrialNetworkGrant(before, accountId, network.granted);
1571
1672
  }
1572
1673
  const written = await this.eventLog.appendIn(before.conversationId, [
@@ -1610,6 +1711,24 @@ let ApprovalsService = class ApprovalsService {
1610
1711
  await this.resumes.resumeIn(before.runId, id);
1611
1712
  return { record: toRecord(updated), toSeq: Math.max(...written.map((e) => e.seq)) };
1612
1713
  }
1714
+ if (network !== undefined && before.detail?.kind === "site") {
1715
+ await audit(t, {
1716
+ actorAccountId: accountId,
1717
+ orgId,
1718
+ action: "device.site_access_decided",
1719
+ target: before.detail.deviceId,
1720
+ detail: {
1721
+ approvalId: id,
1722
+ action: before.detail.action,
1723
+ origin: before.detail.origin,
1724
+ detailSha256: siteAccessDetailHash(before.detail.detail),
1725
+ outcome: approved ? network.outcome : "denied",
1726
+ source: "human",
1727
+ },
1728
+ });
1729
+ await this.resumes.resumeIn(before.runId, id);
1730
+ return { record: toRecord(updated), toSeq: Math.max(...written.map((e) => e.seq)) };
1731
+ }
1613
1732
  if (network !== undefined && before.detail !== null) {
1614
1733
  const asked = [...new Set(networkAskHosts(before.detail))];
1615
1734
  const refused = asked.filter((h) => !network.wanted.includes(h));
@@ -2351,6 +2470,9 @@ __decorate([
2351
2470
  __decorate([
2352
2471
  Transactional()
2353
2472
  ], ApprovalsService.prototype, "requestSecureInputIn", null);
2473
+ __decorate([
2474
+ Transactional()
2475
+ ], ApprovalsService.prototype, "requestSiteAccess", null);
2354
2476
  __decorate([
2355
2477
  Transactional()
2356
2478
  ], ApprovalsService.prototype, "requestNetworkIn", null);
@@ -2363,6 +2485,9 @@ __decorate([
2363
2485
  __decorate([
2364
2486
  WithLock({ key: "network-ask-#{1}", ttl: 60_000, waitTimeout: 45_000 })
2365
2487
  ], ApprovalsService.prototype, "decideNetwork", null);
2488
+ __decorate([
2489
+ Transactional({ propagation: "requires_new" })
2490
+ ], ApprovalsService.prototype, "decideSiteIn", null);
2366
2491
  __decorate([
2367
2492
  Transactional({ propagation: "requires_new" })
2368
2493
  ], ApprovalsService.prototype, "decideLoopbackIn", null);
@@ -2422,6 +2547,12 @@ ApprovalsService = __decorate([
2422
2547
  __param(14, Optional()),
2423
2548
  __param(14, Inject(PermissionCallGrants)),
2424
2549
  __param(15, Optional()),
2425
- __param(15, Inject(LoopbackGrants))
2550
+ __param(15, Inject(LoopbackGrants)),
2551
+ __param(16, Optional()),
2552
+ __param(16, Inject(DeviceSiteGrants)),
2553
+ __param(17, Optional()),
2554
+ __param(17, Inject(OrgLock)),
2555
+ __param(18, Optional()),
2556
+ __param(18, Inject(ExtensionRegistry))
2426
2557
  ], ApprovalsService);
2427
2558
  export { ApprovalsService };
@@ -1,5 +1,6 @@
1
1
  import type { NetworkBlockLayer, ServiceBlockedHost, ToolCallContext } from "@capybara-hq/plugin-sdk";
2
2
  import type { ReviewRecord } from "../conversations/events.js";
3
+ import type { ReportedSiteAccess } from "../device-access/site-access-request.js";
3
4
  import type { ConversationKindForHooks } from "../runtime/hook-calls.js";
4
5
  /**
5
6
  * The call scope (browser use spec §7.1): what a tool handler's kernel services report about one
@@ -74,6 +75,8 @@ export interface CallScope {
74
75
  * says the device was still starting, not that the target failed.
75
76
  */
76
77
  starting: number;
78
+ /** The last bounded device service site action reported by the handler. */
79
+ siteAccess: ReportedSiteAccess | null;
77
80
  /**
78
81
  * Whether this call sent a request to a device service (`ctx.deviceAccess.request`): its target
79
82
  * may have acted, so a timeout never claims otherwise.
@@ -16,6 +16,7 @@ export function attachCallScope(ctx, facts, opts = {}) {
16
16
  review: null,
17
17
  blocked: null,
18
18
  starting: 0,
19
+ siteAccess: null,
19
20
  reached: false,
20
21
  ...(facts !== undefined && { facts }),
21
22
  ...(opts.watch === true && { watch: true }),
@@ -366,6 +366,13 @@ const NO_OFFER_WHY = "the device's owner changes the device's network on its pag
366
366
  export function settledNetworkNotes(a, hours) {
367
367
  if (a.detail?.kind === "loopback")
368
368
  return settledLoopbackNotes(a, hours);
369
+ if (a.detail?.kind === "site") {
370
+ if (a.status === "pending")
371
+ return null;
372
+ if (a.status === "approved")
373
+ return [];
374
+ return [`The site action on ${a.detail.origin} was not approved. It did not run.`];
375
+ }
369
376
  const detail = a.detail;
370
377
  const asked = detail === null ? [] : networkAskHosts(detail);
371
378
  switch (a.status) {
@@ -1,4 +1,4 @@
1
- import { type ConversationSource, type FormAnswer, type InputForm, type Logger, type ServiceBlockedHost, type ToolCallContext, type ToolDisplay } from "@capybara-hq/plugin-sdk";
1
+ import { type ConversationSource, type FormAnswer, type InputForm, type Logger, type ServiceBlockedHost, type SiteAccessApproval, type ToolCallContext, type ToolDisplay } from "@capybara-hq/plugin-sdk";
2
2
  import type { AgentDefinition } from "../agents/definition.js";
3
3
  import { type UnattendedRun } from "../automations/unattended.js";
4
4
  import { ConversationApprovalProfile } from "../conversations/approval-profile.js";
@@ -6,9 +6,12 @@ import { AttachmentsService } from "../conversations/attachments.service.js";
6
6
  import { EventLog } from "../conversations/event-log.js";
7
7
  import { type ReviewRecord } from "../conversations/events.js";
8
8
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
9
+ import { type ReportedSiteAccess } from "../device-access/site-access-request.js";
10
+ import { DeviceSiteGrants } from "../device-access/site-grants.js";
9
11
  import { ConversationDevices } from "../devices/conversation-devices.js";
10
12
  import { EffectiveConfigs } from "../extensions/effective-config.js";
11
13
  import { ExtensionHost } from "../extensions/host.js";
14
+ import { ExtensionRegistry } from "../extensions/registry.js";
12
15
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
13
16
  import { KernelDb } from "../infra/database/kernel-db.js";
14
17
  import { TransactionHost } from "../infra/database/transaction-host.js";
@@ -245,7 +248,7 @@ interface PipelineDeps {
245
248
  readonly breaker: Pick<Breaker, "check" | "failure" | "success">;
246
249
  readonly outputs: Pick<ToolOutputs, "save" | "load">;
247
250
  /** 策略为 `ask` 时建审批;续跑时读该调用的审批结果。 A refused network host: a network ask. */
248
- readonly approvals: Pick<ApprovalsService, "request" | "forCall" | "networkForCall" | "requestNetwork" | "requestLoopback" | "commandForCall" | "requestCommand" | "requestSecureInput" | "secureInputForCall">;
251
+ readonly approvals: Pick<ApprovalsService, "request" | "forCall" | "networkForCall" | "requestNetwork" | "requestLoopback" | "requestSiteAccess" | "commandForCall" | "requestCommand" | "requestSecureInput" | "secureInputForCall">;
249
252
  /** 处理函数返回 `input_required` 时建输入请求;续跑时读该调用的各轮输入请求。 */
250
253
  readonly questions: Pick<QuestionsService, "ask" | "forCall">;
251
254
  readonly log: Logger;
@@ -402,6 +405,7 @@ export type ExecOutcome =
402
405
  result: unknown;
403
406
  blocked?: ServiceBlocked;
404
407
  review?: ReviewRecord;
408
+ siteAccess?: ReportedSiteAccess;
405
409
  }
406
410
  /**
407
411
  * The handler needs the user's input (the form is not validated yet). `review` and `blocked`:
@@ -424,6 +428,7 @@ export type ExecOutcome =
424
428
  message: string;
425
429
  blocked?: ServiceBlocked;
426
430
  review?: ReviewRecord;
431
+ siteAccess?: ReportedSiteAccess;
427
432
  }
428
433
  /** 发起人未连接个人凭据:除错误结果外再写 `connection_required`。 */
429
434
  | {
@@ -605,13 +610,15 @@ export declare class ToolPipeline {
605
610
  private readonly loopbackGrants?;
606
611
  /** The device's sandbox and its provider's support a loopback grant is checked against. */
607
612
  private readonly permissionFacts?;
613
+ private readonly siteGrants?;
614
+ private readonly extensions?;
608
615
  private readonly decide;
609
616
  private readonly deps;
610
617
  constructor(kdb: KernelDb, eventLog: EventLog,
611
618
  /** The `Agent` tool's sub-agent dispatch; absent (tests): `Agent` calls are refused. */
612
619
  subagents: Pick<SubagentsService, "dispatch"> | undefined,
613
620
  /** The message tools between agents; absent (tests): their calls are refused. */
614
- messages: Pick<SubagentMessages, "toChild" | "toParent"> | undefined, registry: Pick<ToolRegistry, "forAgent" | "findConnector" | "handler" | "watcher">, credentials: Pick<Credentials, "injection" | "onUnauthorized">, breaker: Pick<Breaker, "check" | "failure" | "success">, outputs: Pick<ToolOutputs, "save" | "load">, approvals: Pick<ApprovalsService, "request" | "forCall" | "networkForCall" | "requestNetwork" | "requestLoopback" | "commandForCall" | "requestCommand" | "requestSecureInput" | "secureInputForCall">, questions: Pick<QuestionsService, "ask" | "forCall">, config: Pick<KernelConfigService, "get">, log: Logger & Partial<Pick<KernelLogger, "debug">>,
621
+ messages: Pick<SubagentMessages, "toChild" | "toParent"> | undefined, registry: Pick<ToolRegistry, "forAgent" | "findConnector" | "handler" | "watcher">, credentials: Pick<Credentials, "injection" | "onUnauthorized">, breaker: Pick<Breaker, "check" | "failure" | "success">, outputs: Pick<ToolOutputs, "save" | "load">, approvals: Pick<ApprovalsService, "request" | "forCall" | "networkForCall" | "requestNetwork" | "requestLoopback" | "requestSiteAccess" | "commandForCall" | "requestCommand" | "requestSecureInput" | "secureInputForCall">, questions: Pick<QuestionsService, "ask" | "forCall">, config: Pick<KernelConfigService, "get">, log: Logger & Partial<Pick<KernelLogger, "debug">>,
615
622
  /** Plugin hooks and inline ui contributions; absent (tests): no hooks, cards dropped. */
616
623
  host: Pick<ExtensionHost, "hooks" | "current"> | undefined, drift: Pick<ToolDrift, "onToolsChanged"> | undefined, effective: Pick<EffectiveConfigs, "get">, switches: Pick<OrgToolSwitches, "isToolOff">, txHost: TransactionHost, hooks?: ToolPipelineHooks, networkGrants?: {
617
624
  runState(runId: string, deviceId?: string): Promise<NetworkRunState>;
@@ -642,7 +649,7 @@ export declare class ToolPipeline {
642
649
  */
643
650
  loopbackGrants?: Pick<LoopbackGrants, "grantIn" | "forCall" | "liveForRoot"> | undefined,
644
651
  /** The device's sandbox and its provider's support a loopback grant is checked against. */
645
- permissionFacts?: Pick<PermissionFacts, "deviceSandboxFacts"> | undefined);
652
+ permissionFacts?: Pick<PermissionFacts, "deviceSandboxFacts"> | undefined, siteGrants?: DeviceSiteGrants | undefined, extensions?: Pick<ExtensionRegistry, "current"> | undefined);
646
653
  /**
647
654
  * tools 节点:按顺序处理本步 assistant 消息里的全部 `tool_call`,每个调用都以一条 `tool_result` 结束
648
655
  * (之后才回到 prepare 构建下一次请求,保持「已记录调用、未记录结果之间不构建请求」的不变式)。
@@ -758,6 +765,10 @@ export declare class ToolPipeline {
758
765
  * pipeline, no facts): the host stays an address host with its note.
759
766
  */
760
767
  private loopbackBlocked;
768
+ private siteRetryAllowed;
769
+ private siteReviewFacts;
770
+ private siteRerunOf;
771
+ private handleSiteAccess;
761
772
  /**
762
773
  * A loopback port grant to this call's attempt and what goes with it, in one transaction: the
763
774
  * grant first (it reads the root conversation `FOR SHARE`, before the conversation row the
@@ -831,7 +842,7 @@ export declare class ToolPipeline {
831
842
  /** The automatic decision the call runs under instead of an approval (builtins only, R2). */
832
843
  decision?: BuiltinCallContext["decision"],
833
844
  /** The submitted secure input request of this call (builtins only, R4). */
834
- secureInputId?: string): Promise<ExecOutcome>;
845
+ secureInputId?: string, siteAccess?: SiteAccessApproval): Promise<ExecOutcome>;
835
846
  private executeConnector;
836
847
  /** 抛出的错误 → 给模型的结果:ToolError 的消息原样(插件约定为英文、可操作),其他只给错误类名。 */
837
848
  private thrown;