@capybara-hq/kernel 0.1.0-rc.57 → 0.1.0-rc.59
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/dist/admin/extensions.controller.d.ts +2 -10
- package/dist/admin/extensions.controller.js +2 -24
- package/dist/admin/extensions.schemas.d.ts +21 -0
- package/dist/admin/extensions.schemas.js +37 -0
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.controller.d.ts +0 -5
- package/dist/catalog/org-catalog.controller.js +3 -17
- package/dist/catalog/org-catalog.schemas.d.ts +43 -0
- package/dist/catalog/org-catalog.schemas.js +43 -2
- package/dist/catalog/org-extension-switch.d.ts +3 -1
- package/dist/catalog/org-extension-switch.js +12 -5
- package/dist/catalog/org-extension.controller.d.ts +2 -21
- package/dist/catalog/org-extension.controller.js +1 -38
- package/dist/catalog/org-extension.schemas.d.ts +31 -0
- package/dist/catalog/org-extension.schemas.js +65 -0
- package/dist/catalog/plugin-install.d.ts +2 -0
- package/dist/catalog/plugin-install.js +3 -3
- package/dist/channels/actions.js +2 -0
- package/dist/channels/cards.d.ts +8 -0
- package/dist/channels/cards.js +18 -0
- package/dist/channels/channels.schemas.d.ts +3 -0
- package/dist/channels/channels.schemas.js +8 -0
- package/dist/channels/connections.service.d.ts +17 -2
- package/dist/channels/connections.service.js +30 -5
- package/dist/channels/outbound.js +25 -1
- package/dist/channels/phrases.d.ts +10 -0
- package/dist/channels/phrases.js +10 -0
- package/dist/conversations/conversations.module.js +4 -0
- package/dist/conversations/events.d.ts +35 -0
- package/dist/conversations/events.js +29 -0
- package/dist/conversations/leak-check.d.ts +26 -0
- package/dist/conversations/leak-check.js +69 -0
- package/dist/ctx/secrets.d.ts +13 -1
- package/dist/ctx/secrets.js +19 -1
- package/dist/db/kernel-schema.d.ts +34 -0
- package/dist/devices/working-root.d.ts +2 -3
- package/dist/errors.d.ts +19 -0
- package/dist/errors.js +19 -0
- package/dist/extensions/deployment-config.d.ts +6 -2
- package/dist/extensions/deployment-config.js +35 -23
- package/dist/extensions/org-config.d.ts +2 -0
- package/dist/extensions/org-config.js +1 -0
- package/dist/extensions/org-overrides.d.ts +2 -0
- package/dist/extensions/org-overrides.js +3 -2
- package/dist/http/api.module.js +6 -0
- package/dist/identity/initial-passwords.job.d.ts +3 -2
- package/dist/identity/initial-passwords.job.js +11 -5
- package/dist/orgs/invitations.controller.d.ts +3 -11
- package/dist/orgs/invitations.controller.js +9 -10
- package/dist/orgs/invitations.service.d.ts +12 -2
- package/dist/orgs/invitations.service.js +14 -7
- package/dist/orgs/members.service.d.ts +12 -2
- package/dist/orgs/members.service.js +10 -8
- package/dist/orgs/orgs.controller.d.ts +4 -12
- package/dist/orgs/orgs.controller.js +10 -10
- package/dist/orgs/orgs.schemas.d.ts +26 -0
- package/dist/orgs/orgs.schemas.js +22 -0
- package/dist/platform/connector-person-fields.d.ts +67 -0
- package/dist/platform/connector-person-fields.js +129 -0
- package/dist/platform/exclusions.js +6 -141
- package/dist/platform/method.js +1 -0
- package/dist/platform/operation.d.ts +61 -2
- package/dist/platform/operation.js +4 -4
- package/dist/platform/ops/accounts.ops.js +1 -0
- package/dist/platform/ops/channels.ops.d.ts +10 -3
- package/dist/platform/ops/channels.ops.js +223 -5
- package/dist/platform/ops/connectors.ops.d.ts +22 -4
- package/dist/platform/ops/connectors.ops.js +664 -13
- package/dist/platform/ops/extensions-admin.ops.d.ts +15 -2
- package/dist/platform/ops/extensions-admin.ops.js +153 -5
- package/dist/platform/ops/extensions.ops.d.ts +19 -5
- package/dist/platform/ops/extensions.ops.js +285 -10
- package/dist/platform/ops/org-plugins.ops.d.ts +15 -2
- package/dist/platform/ops/org-plugins.ops.js +323 -4
- package/dist/platform/ops/orgs.ops.d.ts +40 -3
- package/dist/platform/ops/orgs.ops.js +293 -12
- package/dist/platform/ops/person-inputs.d.ts +65 -0
- package/dist/platform/ops/person-inputs.js +129 -0
- package/dist/platform/ops/plugins.ops.d.ts +3 -1
- package/dist/platform/ops/plugins.ops.js +33 -20
- package/dist/platform/parity.d.ts +7 -2
- package/dist/platform/parity.js +75 -13
- package/dist/platform/person-fields.d.ts +119 -0
- package/dist/platform/person-fields.js +403 -0
- package/dist/platform/platform.module.d.ts +4 -3
- package/dist/platform/platform.module.js +8 -5
- package/dist/platform/route-schemas.js +2 -0
- package/dist/platform/sealed-inputs.d.ts +44 -0
- package/dist/platform/sealed-inputs.js +116 -0
- package/dist/platform/sealed-reveals.controller.d.ts +20 -0
- package/dist/platform/sealed-reveals.controller.js +48 -0
- package/dist/platform/sealed-reveals.d.ts +52 -0
- package/dist/platform/sealed-reveals.js +153 -0
- package/dist/runtime/project/knowledge.js +24 -19
- package/dist/runtime/waits.js +8 -2
- package/dist/sandbox/permission-facts.d.ts +5 -1
- package/dist/sandbox/permission-facts.js +8 -2
- package/dist/setup/setup-guides.service.d.ts +5 -0
- package/dist/setup/setup-guides.service.js +2 -1
- package/dist/tools/approvals.controller.d.ts +1 -0
- package/dist/tools/approvals.controller.js +19 -0
- package/dist/tools/approvals.service.d.ts +50 -1
- package/dist/tools/approvals.service.js +118 -10
- package/dist/tools/builtins/builtin-tools.d.ts +3 -0
- package/dist/tools/builtins/builtin-tools.js +31 -9
- package/dist/tools/builtins/platform.d.ts +20 -0
- package/dist/tools/builtins/platform.js +214 -15
- package/dist/tools/connectors.controller.d.ts +6 -7
- package/dist/tools/connectors.controller.js +4 -44
- package/dist/tools/connectors.schemas.d.ts +170 -1
- package/dist/tools/connectors.schemas.js +82 -3
- package/dist/tools/connectors.service.d.ts +16 -6
- package/dist/tools/connectors.service.js +39 -24
- package/dist/tools/oauth/oauth.controller.d.ts +3 -6
- package/dist/tools/oauth/oauth.controller.js +3 -12
- package/dist/tools/oauth/oauth.schemas.d.ts +14 -0
- package/dist/tools/oauth/oauth.schemas.js +27 -0
- package/dist/tools/pipeline.d.ts +31 -2
- package/dist/tools/pipeline.js +89 -17
- package/dist/tools/policy.d.ts +4 -0
- package/dist/tools/policy.js +8 -0
- package/dist/tools/registry.d.ts +29 -0
- package/dist/tools/tools.module.js +3 -0
- package/package.json +3 -3
- package/src/migrations/0169_platform_sealed_inputs.sql +23 -0
- package/src/migrations/0170_platform_sealed_reveals.sql +27 -0
|
@@ -14,6 +14,7 @@ import { sql } from "kysely";
|
|
|
14
14
|
import { normalizeStoredDefinition } from "../agents/definition.js";
|
|
15
15
|
import { EventLog } from "../conversations/event-log.js";
|
|
16
16
|
import { COMMAND_ASK_TEXT_MAX_CHARS, GIT_ASK_MAX_REFS, GIT_REF_MAX_CHARS, NETWORK_ASK_MAX_HOSTS, NETWORK_HOST_MAX_CHARS, } from "../conversations/events.js";
|
|
17
|
+
import { ConversationLeakCheck } from "../conversations/leak-check.js";
|
|
17
18
|
import { conversationSourceOf } from "../conversations/source.js";
|
|
18
19
|
import { ApiError } from "../errors.js";
|
|
19
20
|
import { clipText } from "../extensions/hooks.js";
|
|
@@ -27,6 +28,8 @@ import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
|
27
28
|
import { LockService } from "../infra/lock/lock.service.js";
|
|
28
29
|
import { WithLock } from "../infra/lock/with-lock.decorator.js";
|
|
29
30
|
import { ORG_ROLES, roleAtLeast } from "../orgs/roles.js";
|
|
31
|
+
import { checkPersonValue } from "../platform/person-fields.js";
|
|
32
|
+
import { SealedInputs } from "../platform/sealed-inputs.js";
|
|
30
33
|
import { RunResume } from "../runtime/run-jobs.js";
|
|
31
34
|
import { rootConversationOf } from "../runtime/subagents/child.js";
|
|
32
35
|
import { PermissionAuthorityLock } from "../sandbox/permission-authority-lock.js";
|
|
@@ -69,6 +72,21 @@ export function publicRecord(r) {
|
|
|
69
72
|
git: strip(r.git),
|
|
70
73
|
};
|
|
71
74
|
}
|
|
75
|
+
/** A tool ask's person fields from its stored `detail` (none: an ordinary tool ask). */
|
|
76
|
+
function personFieldsOf(detail) {
|
|
77
|
+
if (typeof detail !== "object" || detail === null)
|
|
78
|
+
return null;
|
|
79
|
+
const d = detail;
|
|
80
|
+
if (!Array.isArray(d.personFields) || d.personFields.length === 0 || d.target === undefined) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
personFields: d.personFields,
|
|
85
|
+
personTarget: d.target,
|
|
86
|
+
...(Array.isArray(d.leakedFields) &&
|
|
87
|
+
d.leakedFields.length > 0 && { leakedFields: d.leakedFields }),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
72
90
|
/** The tool key a network ask is recorded under (the command ran in `Bash`). */
|
|
73
91
|
export const NETWORK_ASK_TOOL_KEY = "Bash";
|
|
74
92
|
/** The spec hash of a network ask (no tool definition is approved). */
|
|
@@ -95,6 +113,7 @@ const commandAskToolKey = (kind) => kind === "write"
|
|
|
95
113
|
? COMMAND_READ_TOOL_KEY
|
|
96
114
|
: COMMAND_ASK_TOOL_KEY;
|
|
97
115
|
const notFound = () => new ApiError("approval.not_found", "Approval not found");
|
|
116
|
+
const inputsNotExpected = () => new ApiError("approval.inputs_not_expected", "The inputs name fields this approval does not ask for.");
|
|
98
117
|
const iso = (v) => new Date(v).toISOString();
|
|
99
118
|
const isRole = (v) => v !== null && ORG_ROLES.includes(v);
|
|
100
119
|
/** The scopes of an approval without stored ones: a role escalation is approved only once. */
|
|
@@ -111,6 +130,7 @@ function toRecord(r) {
|
|
|
111
130
|
detail: r.kind === "network" ? (r.detail ?? null) : null,
|
|
112
131
|
git: r.kind === "git" ? (r.detail ?? null) : null,
|
|
113
132
|
command: r.kind === "command" ? (r.detail ?? null) : null,
|
|
133
|
+
...(r.kind === "tool" && personFieldsOf(r.detail)),
|
|
114
134
|
toolKey: r.tool_key,
|
|
115
135
|
specHash: r.spec_hash,
|
|
116
136
|
connectorId: r.connector_id,
|
|
@@ -166,6 +186,8 @@ let ApprovalsService = class ApprovalsService {
|
|
|
166
186
|
lockService;
|
|
167
187
|
sandbox;
|
|
168
188
|
resumes;
|
|
189
|
+
leakCheck;
|
|
190
|
+
sealed;
|
|
169
191
|
permissionLocks;
|
|
170
192
|
permissionGrants;
|
|
171
193
|
constructor(db, config, eventLog, events, txHost, schedules,
|
|
@@ -176,7 +198,11 @@ let ApprovalsService = class ApprovalsService {
|
|
|
176
198
|
/** A trial run's 「这次允许」 becomes a task grant only within the org's egress. */
|
|
177
199
|
sandbox,
|
|
178
200
|
/** A decision resumes its waiting run in the decision's transaction. */
|
|
179
|
-
resumes,
|
|
201
|
+
resumes,
|
|
202
|
+
/** An entered person value seen in the conversation is refused (§4.5). */
|
|
203
|
+
leakCheck,
|
|
204
|
+
/** A person's entered values are sealed in the decision's transaction (§4.3). */
|
|
205
|
+
sealed, permissionLocks, permissionGrants) {
|
|
180
206
|
this.db = db;
|
|
181
207
|
this.config = config;
|
|
182
208
|
this.eventLog = eventLog;
|
|
@@ -187,6 +213,8 @@ let ApprovalsService = class ApprovalsService {
|
|
|
187
213
|
this.lockService = lockService;
|
|
188
214
|
this.sandbox = sandbox;
|
|
189
215
|
this.resumes = resumes;
|
|
216
|
+
this.leakCheck = leakCheck;
|
|
217
|
+
this.sealed = sealed;
|
|
190
218
|
this.permissionLocks = permissionLocks;
|
|
191
219
|
this.permissionGrants = permissionGrants;
|
|
192
220
|
}
|
|
@@ -231,6 +259,7 @@ let ApprovalsService = class ApprovalsService {
|
|
|
231
259
|
approver_role: input.approverRole,
|
|
232
260
|
summary: input.summary === undefined ? null : JSON.stringify(input.summary),
|
|
233
261
|
scopes: input.scopes ?? null,
|
|
262
|
+
...(input.detail !== undefined && { detail: JSON.stringify(input.detail) }),
|
|
234
263
|
scope: null,
|
|
235
264
|
decided_by: null,
|
|
236
265
|
expires_at: sql `now() + ${hours}::integer * interval '1 hour'`,
|
|
@@ -692,9 +721,13 @@ let ApprovalsService = class ApprovalsService {
|
|
|
692
721
|
if (kind.kind === "command") {
|
|
693
722
|
return this.decideCommand(orgId, id, accountId, body, actorTokenId, via);
|
|
694
723
|
}
|
|
695
|
-
const
|
|
696
|
-
|
|
697
|
-
|
|
724
|
+
const outcome = await this.decideToolIn(orgId, id, accountId, body, actorTokenId, via);
|
|
725
|
+
// a leak refusal committed only the leaked paths (the approval stays pending), then refuses
|
|
726
|
+
if ("leaked" in outcome) {
|
|
727
|
+
throw new ApiError("approval.input_leaked", "This value appeared in the conversation, so it counts as leaked. Create a new one at the provider and enter that.", [{ fields: outcome.leaked }]);
|
|
728
|
+
}
|
|
729
|
+
await this.announceDecided(outcome.record, outcome.toSeq);
|
|
730
|
+
return outcome.record;
|
|
698
731
|
}
|
|
699
732
|
/**
|
|
700
733
|
* A network ask's decision (network ask-to-allow spec §5.2), one at a time per ask across
|
|
@@ -919,13 +952,26 @@ let ApprovalsService = class ApprovalsService {
|
|
|
919
952
|
// its own transaction (as the legacy one was): `approval.decided` is emitted only after the
|
|
920
953
|
// decision committed, even when a caller has a transaction open
|
|
921
954
|
decideIn(orgId, id, accountId, body, actorTokenId, network, git, command) {
|
|
922
|
-
return this.decideTx(orgId, id, accountId, body, actorTokenId, network, git, command)
|
|
955
|
+
return this.decideTx(orgId, id, accountId, body, actorTokenId, network, git, command).then((o) => {
|
|
956
|
+
// only a tool ask takes inputs (refused for every other kind before)
|
|
957
|
+
if ("leaked" in o)
|
|
958
|
+
throw new Error(`approval ${id}: a leak outcome outside a tool ask`);
|
|
959
|
+
return o;
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
/**
|
|
963
|
+
* A tool ask's decision in its own transaction. With person fields, a leak refusal commits the
|
|
964
|
+
* leaked paths in `detail.leakedFields` and returns them (the caller refuses after the commit,
|
|
965
|
+
* the approval still pending); the same transaction cannot both keep that write and throw.
|
|
966
|
+
*/
|
|
967
|
+
decideToolIn(orgId, id, accountId, body, actorTokenId, via) {
|
|
968
|
+
return this.decideTx(orgId, id, accountId, body, actorTokenId, undefined, undefined, undefined, via);
|
|
923
969
|
}
|
|
924
970
|
/**
|
|
925
971
|
* A decision in the caller's transaction: lock order conversation → approval → run (the resume).
|
|
926
972
|
* Refuses (`approval.already_decided`, `approval.not_found`, …) before any write.
|
|
927
973
|
*/
|
|
928
|
-
async decideTx(orgId, id, accountId, body, actorTokenId, network, git, command) {
|
|
974
|
+
async decideTx(orgId, id, accountId, body, actorTokenId, network, git, command, via = "web") {
|
|
929
975
|
const t = this.db.db;
|
|
930
976
|
// lock order: the conversation, the approval, then the run (as a stop of the waiting run)
|
|
931
977
|
if (!(await this.lockConversationOf(id, orgId)))
|
|
@@ -973,6 +1019,61 @@ let ApprovalsService = class ApprovalsService {
|
|
|
973
1019
|
await this.permissionGrants.assertCurrent(before.command.permissionCandidate.binding);
|
|
974
1020
|
}
|
|
975
1021
|
const approved = body.decision === "approve";
|
|
1022
|
+
const person = before.kind === "tool" ? before.personFields : undefined;
|
|
1023
|
+
if (body.inputs !== undefined && (person === undefined || !approved)) {
|
|
1024
|
+
throw inputsNotExpected();
|
|
1025
|
+
}
|
|
1026
|
+
// an approval with person fields (platform web parity spec §4.2, §4.3, R5): approved only by
|
|
1027
|
+
// its person, in a web session, with every asked value, valid and never seen in the
|
|
1028
|
+
// conversation; the values are sealed before the status changes. A deny takes no values.
|
|
1029
|
+
let inputsProvided;
|
|
1030
|
+
if (person !== undefined && approved) {
|
|
1031
|
+
if (actorTokenId !== undefined) {
|
|
1032
|
+
throw new ApiError("auth.session_required", "Values for this approval are entered in a signed-in web session, not with a personal access token.");
|
|
1033
|
+
}
|
|
1034
|
+
if (via === "im") {
|
|
1035
|
+
throw new ApiError("auth.session_required", "This approval asks for values entered on the web; it cannot be approved from IM.");
|
|
1036
|
+
}
|
|
1037
|
+
if (before.requestedFor !== accountId)
|
|
1038
|
+
throw notFound();
|
|
1039
|
+
const inputs = body.inputs ?? {};
|
|
1040
|
+
const asked = new Set(person.map((f) => f.path));
|
|
1041
|
+
if (Object.keys(inputs).some((p) => !asked.has(p)))
|
|
1042
|
+
throw inputsNotExpected();
|
|
1043
|
+
const problems = person.flatMap((f) => {
|
|
1044
|
+
const v = Object.hasOwn(inputs, f.path) ? inputs[f.path] : undefined;
|
|
1045
|
+
const problem = v === undefined ? `${f.label.en} is required.` : checkPersonValue(f, v);
|
|
1046
|
+
return problem === null ? [] : [{ path: f.path, problem }];
|
|
1047
|
+
});
|
|
1048
|
+
if (problems.length > 0) {
|
|
1049
|
+
throw new ApiError("approval.inputs_invalid", "Some entered values are not valid.", [
|
|
1050
|
+
{ fields: problems },
|
|
1051
|
+
]);
|
|
1052
|
+
}
|
|
1053
|
+
// a read in the decision's transaction: one indexed scan of the conversation tree per value
|
|
1054
|
+
const leaked = await this.leakCheck.leaked(before.conversationId, inputs);
|
|
1055
|
+
if (leaked.length > 0) {
|
|
1056
|
+
await t
|
|
1057
|
+
.updateTable("approvals")
|
|
1058
|
+
.set({
|
|
1059
|
+
detail: JSON.stringify({
|
|
1060
|
+
...locked.detail,
|
|
1061
|
+
leakedFields: [...new Set([...(before.leakedFields ?? []), ...leaked])],
|
|
1062
|
+
}),
|
|
1063
|
+
})
|
|
1064
|
+
.where("id", "=", id)
|
|
1065
|
+
.execute();
|
|
1066
|
+
return { leaked };
|
|
1067
|
+
}
|
|
1068
|
+
await this.sealed.sealIn({
|
|
1069
|
+
approvalId: id,
|
|
1070
|
+
recipientAccountId: accountId,
|
|
1071
|
+
conversationId: before.conversationId,
|
|
1072
|
+
runId: before.runId,
|
|
1073
|
+
callId: before.callId,
|
|
1074
|
+
}, inputs);
|
|
1075
|
+
inputsProvided = person.map((f) => f.path);
|
|
1076
|
+
}
|
|
976
1077
|
const reason = approved ? undefined : body.reason?.trim() || undefined;
|
|
977
1078
|
const scope = !approved
|
|
978
1079
|
? null
|
|
@@ -1111,6 +1212,7 @@ let ApprovalsService = class ApprovalsService {
|
|
|
1111
1212
|
...(scope !== null && { scope }),
|
|
1112
1213
|
byAccountId: accountId,
|
|
1113
1214
|
...(reason !== undefined && { reason }),
|
|
1215
|
+
...(inputsProvided !== undefined && { inputsProvided }),
|
|
1114
1216
|
},
|
|
1115
1217
|
},
|
|
1116
1218
|
]);
|
|
@@ -1192,6 +1294,7 @@ let ApprovalsService = class ApprovalsService {
|
|
|
1192
1294
|
scope,
|
|
1193
1295
|
...(body.note !== undefined && { note: body.note }),
|
|
1194
1296
|
...(reason !== undefined && { reason }),
|
|
1297
|
+
...(inputsProvided !== undefined && { inputsProvided }),
|
|
1195
1298
|
},
|
|
1196
1299
|
});
|
|
1197
1300
|
// the run last (lock order: the decided row, then `runs`); a still-running run is resumed by
|
|
@@ -1822,6 +1925,9 @@ __decorate([
|
|
|
1822
1925
|
__decorate([
|
|
1823
1926
|
Transactional({ propagation: "requires_new" })
|
|
1824
1927
|
], ApprovalsService.prototype, "decideIn", null);
|
|
1928
|
+
__decorate([
|
|
1929
|
+
Transactional({ propagation: "requires_new" })
|
|
1930
|
+
], ApprovalsService.prototype, "decideToolIn", null);
|
|
1825
1931
|
__decorate([
|
|
1826
1932
|
Transactional({ propagation: "mandatory" })
|
|
1827
1933
|
], ApprovalsService.prototype, "decideTx", null);
|
|
@@ -1864,9 +1970,11 @@ ApprovalsService = __decorate([
|
|
|
1864
1970
|
__param(7, Inject(LockService)),
|
|
1865
1971
|
__param(8, Inject(SandboxService)),
|
|
1866
1972
|
__param(9, Inject(RunResume)),
|
|
1867
|
-
__param(10,
|
|
1868
|
-
__param(
|
|
1869
|
-
__param(
|
|
1870
|
-
__param(
|
|
1973
|
+
__param(10, Inject(ConversationLeakCheck)),
|
|
1974
|
+
__param(11, Inject(SealedInputs)),
|
|
1975
|
+
__param(12, Optional()),
|
|
1976
|
+
__param(12, Inject(PermissionAuthorityLock)),
|
|
1977
|
+
__param(13, Optional()),
|
|
1978
|
+
__param(13, Inject(PermissionCallGrants))
|
|
1871
1979
|
], ApprovalsService);
|
|
1872
1980
|
export { ApprovalsService };
|
|
@@ -13,6 +13,7 @@ import { ModelPurposesService } from "../../models/purposes.js";
|
|
|
13
13
|
import { PlatformActor } from "../../platform/actor.js";
|
|
14
14
|
import { AgentDocs } from "../../platform/agent-docs.js";
|
|
15
15
|
import { PlatformOperations } from "../../platform/registry.js";
|
|
16
|
+
import { SealedInputs } from "../../platform/sealed-inputs.js";
|
|
16
17
|
import type { HookRunner } from "../../runtime/hook-calls.js";
|
|
17
18
|
import { ProviderRegistry } from "../../runtime/providers.js";
|
|
18
19
|
import { StepLog } from "../../runtime/step-log.js";
|
|
@@ -38,6 +39,8 @@ export declare class BuiltinTools {
|
|
|
38
39
|
purposes: ModelPurposesService, host: {
|
|
39
40
|
readonly hooks?: HookRunner;
|
|
40
41
|
} | undefined, stepLog: StepLog, log: Logger, background: BackgroundTaskStore, finisher: BackgroundTaskFinisher, stopper: BackgroundTaskStopper, platformOps: PlatformOperations, platformActor: PlatformActor, agentDocs: AgentDocs,
|
|
42
|
+
/** The person's sealed approval card values a Platform write with person fields reads. */
|
|
43
|
+
sealedInputs: SealedInputs,
|
|
41
44
|
/** The schedule tools read tasks and grants; their writes go through the task service. */
|
|
42
45
|
scheduleStore: ScheduledTaskStore,
|
|
43
46
|
/** `ScheduleUpdate`'s write: its field change and grant changes in one transaction. */
|
|
@@ -28,6 +28,7 @@ import { readOrgSettings } from "../../orgs/settings.service.js";
|
|
|
28
28
|
import { PlatformActor } from "../../platform/actor.js";
|
|
29
29
|
import { AgentDocs } from "../../platform/agent-docs.js";
|
|
30
30
|
import { PlatformOperations } from "../../platform/registry.js";
|
|
31
|
+
import { SealedInputs } from "../../platform/sealed-inputs.js";
|
|
31
32
|
import { ProviderListError, ProviderRegistry } from "../../runtime/providers.js";
|
|
32
33
|
import { conversationTimeZone, RUN_CONTEXT_CLOCK } from "../../runtime/run-context.service.js";
|
|
33
34
|
import { StepLog } from "../../runtime/step-log.js";
|
|
@@ -61,6 +62,8 @@ let BuiltinTools = class BuiltinTools {
|
|
|
61
62
|
constructor(db, config, outputs, storage, attachments, eventLog, sandbox, devices, points, webPages,
|
|
62
63
|
/** The WebFetch extraction call: the `web_fetch` purpose, its hooks, usage and denials. */
|
|
63
64
|
purposes, host, stepLog, log, background, finisher, stopper, platformOps, platformActor, agentDocs,
|
|
65
|
+
/** The person's sealed approval card values a Platform write with person fields reads. */
|
|
66
|
+
sealedInputs,
|
|
64
67
|
/** The schedule tools read tasks and grants; their writes go through the task service. */
|
|
65
68
|
scheduleStore,
|
|
66
69
|
/** `ScheduleUpdate`'s write: its field change and grant changes in one transaction. */
|
|
@@ -165,6 +168,24 @@ let BuiltinTools = class BuiltinTools {
|
|
|
165
168
|
docs: agentDocs,
|
|
166
169
|
setting: async (orgId) => (await readOrgSettings(db.db, orgId)).platformTool,
|
|
167
170
|
log,
|
|
171
|
+
sealed: sealedInputs,
|
|
172
|
+
approvalPersonPaths: async (approvalId, call) => {
|
|
173
|
+
// only this call's own approved approval in this org (anything else: none, fails closed)
|
|
174
|
+
const row = await db.db
|
|
175
|
+
.selectFrom("approvals")
|
|
176
|
+
.select(["kind", "detail"])
|
|
177
|
+
.where("id", "=", approvalId)
|
|
178
|
+
.where("org_id", "=", call.orgId)
|
|
179
|
+
.where("run_id", "=", call.runId)
|
|
180
|
+
.where("call_id", "=", call.callId)
|
|
181
|
+
.where("status", "=", "approved")
|
|
182
|
+
.executeTakeFirst();
|
|
183
|
+
const fields = row?.detail
|
|
184
|
+
?.personFields;
|
|
185
|
+
if (row?.kind !== "tool" || !Array.isArray(fields) || fields.length === 0)
|
|
186
|
+
return null;
|
|
187
|
+
return fields.map((f) => String(f.path));
|
|
188
|
+
},
|
|
168
189
|
}),
|
|
169
190
|
// the clock in the run context's time zone (the run context carries only the date)
|
|
170
191
|
currentTimeTool({
|
|
@@ -210,16 +231,17 @@ BuiltinTools = __decorate([
|
|
|
210
231
|
__param(17, Inject(PlatformOperations)),
|
|
211
232
|
__param(18, Inject(PlatformActor)),
|
|
212
233
|
__param(19, Inject(AgentDocs)),
|
|
213
|
-
__param(20, Inject(
|
|
214
|
-
__param(21, Inject(
|
|
215
|
-
__param(22, Inject(
|
|
216
|
-
__param(23, Inject(
|
|
217
|
-
__param(24, Inject(
|
|
218
|
-
__param(25, Inject(
|
|
219
|
-
__param(26,
|
|
220
|
-
__param(26, Inject(RUN_CONTEXT_CLOCK)),
|
|
234
|
+
__param(20, Inject(SealedInputs)),
|
|
235
|
+
__param(21, Inject(ScheduledTaskStore)),
|
|
236
|
+
__param(22, Inject(ScheduleUpdates)),
|
|
237
|
+
__param(23, Inject(ScheduleToolsPort)),
|
|
238
|
+
__param(24, Inject(ModelImages)),
|
|
239
|
+
__param(25, Inject(ProviderRegistry)),
|
|
240
|
+
__param(26, Inject(ManagedDeviceContextRecorder)),
|
|
221
241
|
__param(27, Optional()),
|
|
222
|
-
__param(27, Inject(
|
|
242
|
+
__param(27, Inject(RUN_CONTEXT_CLOCK)),
|
|
243
|
+
__param(28, Optional()),
|
|
244
|
+
__param(28, Inject(PERMISSION_CONTEXT_ACTIVATION))
|
|
223
245
|
], BuiltinTools);
|
|
224
246
|
export { BuiltinTools };
|
|
225
247
|
/**
|
|
@@ -4,6 +4,7 @@ import type { ActorFacts } from "../../platform/actor.js";
|
|
|
4
4
|
import type { AgentDocTopic } from "../../platform/agent-docs.js";
|
|
5
5
|
import { type PlatformOperation } from "../../platform/operation.js";
|
|
6
6
|
import type { PlatformOperations } from "../../platform/registry.js";
|
|
7
|
+
import { type SealedInputs } from "../../platform/sealed-inputs.js";
|
|
7
8
|
import type { BuiltinTool, CallPolicyContext } from "../registry.js";
|
|
8
9
|
/**
|
|
9
10
|
* The `Platform` builtin (Platform tool spec §3–§6): one tool through which an agent discovers and
|
|
@@ -18,6 +19,11 @@ import type { BuiltinTool, CallPolicyContext } from "../registry.js";
|
|
|
18
19
|
* waited).
|
|
19
20
|
* - An `ApiError` gets the next step the operation declares for its code and the actor's role.
|
|
20
21
|
* - The actor, the agent and the conversation come from the runtime context, never from input.
|
|
22
|
+
* - A write with person fields (platform web parity spec §4: `op.personFields`) is planned at the
|
|
23
|
+
* policy step: a secret in `values` is denied before the card, and the asked fields go to the
|
|
24
|
+
* card through {@link CallPolicy.personFields} (never remembered). The approved call reads the
|
|
25
|
+
* person's sealed values through `personInputs` and its result names each entered path, never a
|
|
26
|
+
* value.
|
|
21
27
|
* - Results are JSON text; a list an operation returns is capped at {@link LIST_MAX} entries.
|
|
22
28
|
*/
|
|
23
29
|
/** The most entries of a list in one result (operations that page return `next`). */
|
|
@@ -38,6 +44,18 @@ export interface PlatformToolDeps {
|
|
|
38
44
|
precheckTimeoutMs?: number;
|
|
39
45
|
/** A precheck that throws is logged (warn) and one that times out (debug), with the op id. */
|
|
40
46
|
log?: Pick<KernelLogger, "warn"> & Partial<Pick<KernelLogger, "debug">>;
|
|
47
|
+
/** The person's sealed card values (`personInputs`); absent: no write has person fields. */
|
|
48
|
+
sealed?: Pick<SealedInputs, "consume">;
|
|
49
|
+
/**
|
|
50
|
+
* The person field paths an approval's card showed (its stored `detail.personFields`), or null
|
|
51
|
+
* when it has none or is not this call's approved approval in the org: what an approved call's
|
|
52
|
+
* values are bound to.
|
|
53
|
+
*/
|
|
54
|
+
approvalPersonPaths?(approvalId: string, call: {
|
|
55
|
+
orgId: string;
|
|
56
|
+
runId: string;
|
|
57
|
+
callId: string;
|
|
58
|
+
}): Promise<string[] | null>;
|
|
41
59
|
}
|
|
42
60
|
/**
|
|
43
61
|
* An operation's input keys as `browse` and `search` show them, so a call needs no guess:
|
|
@@ -46,4 +64,6 @@ export interface PlatformToolDeps {
|
|
|
46
64
|
* it. Types, bounds and an example stay in `describe`.
|
|
47
65
|
*/
|
|
48
66
|
export declare function paramsLine(op: PlatformOperation): string;
|
|
67
|
+
/** Model-visible: the person's values expired before the approved call ran (spec §4.3). */
|
|
68
|
+
export declare const PERSON_INPUTS_EXPIRED_TEXT = "The values the person entered expired before they were applied; call the operation again.";
|
|
49
69
|
export declare function platformTool(deps: PlatformToolDeps): BuiltinTool;
|