@capybara-hq/kernel 0.1.0-rc.105 → 0.1.0-rc.106
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/agents/agents.schemas.d.ts +9 -9
- package/dist/{schedules/schedules.controller.d.ts → automations/automations.controller.d.ts} +37 -32
- package/dist/{schedules/schedules.controller.js → automations/automations.controller.js} +68 -57
- package/dist/automations/automations.module.d.ts +16 -0
- package/dist/{schedules/schedules.module.js → automations/automations.module.js} +18 -15
- package/dist/{schedules/schedules.schemas.d.ts → automations/automations.schemas.d.ts} +151 -50
- package/dist/automations/automations.schemas.js +253 -0
- package/dist/{schedules/scheduled-tasks.service.d.ts → automations/automations.service.d.ts} +99 -52
- package/dist/{schedules/scheduled-tasks.service.js → automations/automations.service.js} +303 -134
- package/dist/{schedules → automations}/calendar.d.ts +8 -8
- package/dist/{schedules → automations}/calendar.js +2 -2
- package/dist/automations/effective-settings.d.ts +28 -0
- package/dist/automations/effective-settings.js +25 -0
- package/dist/automations/errors.d.ts +19 -0
- package/dist/automations/errors.js +19 -0
- package/dist/automations/events/coalesce.d.ts +28 -0
- package/dist/automations/events/coalesce.js +131 -0
- package/dist/automations/events/deadline.d.ts +10 -0
- package/dist/automations/events/deadline.js +24 -0
- package/dist/automations/events/dispatcher.d.ts +74 -0
- package/dist/automations/events/dispatcher.js +353 -0
- package/dist/automations/events/events.module.d.ts +7 -0
- package/dist/automations/events/events.module.js +26 -0
- package/dist/automations/events/guards.d.ts +32 -0
- package/dist/automations/events/guards.js +87 -0
- package/dist/automations/events/sweep.job.d.ts +49 -0
- package/dist/automations/events/sweep.job.js +202 -0
- package/dist/automations/events/token.d.ts +5 -0
- package/dist/automations/events/token.js +5 -0
- package/dist/automations/events/trigger-events.service.d.ts +47 -0
- package/dist/automations/events/trigger-events.service.js +254 -0
- package/dist/{schedules → automations}/fire.d.ts +57 -17
- package/dist/{schedules → automations}/fire.js +311 -79
- package/dist/{schedules → automations}/grant-rules.d.ts +1 -1
- package/dist/{schedules → automations}/grant-rules.js +5 -5
- package/dist/automations/job-ids.d.ts +113 -0
- package/dist/automations/job-ids.js +117 -0
- package/dist/{schedules → automations}/pause.d.ts +3 -3
- package/dist/{schedules → automations}/pause.js +3 -3
- package/dist/{schedules → automations}/run-tracker.d.ts +21 -10
- package/dist/{schedules → automations}/run-tracker.js +68 -56
- package/dist/{schedules → automations}/scan.job.d.ts +12 -8
- package/dist/{schedules → automations}/scan.job.js +39 -23
- package/dist/{schedules → automations}/schedule-math.d.ts +19 -12
- package/dist/{schedules → automations}/schedule-math.js +17 -7
- package/dist/{schedules → automations}/store.d.ts +57 -27
- package/dist/{schedules → automations}/store.js +102 -52
- package/dist/automations/store.module.d.ts +6 -0
- package/dist/{schedules → automations}/store.module.js +9 -9
- package/dist/automations/types.d.ts +178 -0
- package/dist/{schedules → automations}/unattended.d.ts +22 -11
- package/dist/{schedules → automations}/unattended.js +53 -30
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/channels/channels.module.js +3 -3
- package/dist/channels/outbound.d.ts +5 -5
- package/dist/channels/outbound.js +17 -17
- package/dist/channels/threads.d.ts +1 -1
- package/dist/channels/threads.js +1 -1
- package/dist/config/schema.d.ts +5 -1
- package/dist/config/schema.js +44 -6
- package/dist/conversations/approval-profile.d.ts +2 -2
- package/dist/conversations/approval-profile.js +3 -3
- package/dist/conversations/conversations.controller.d.ts +7 -1
- package/dist/conversations/conversations.controller.js +26 -10
- package/dist/conversations/conversations.service.d.ts +101 -25
- package/dist/conversations/conversations.service.js +132 -32
- package/dist/conversations/events.d.ts +46 -0
- package/dist/conversations/events.js +54 -3
- package/dist/conversations/message-context.d.ts +2 -2
- package/dist/conversations/message-context.js +1 -1
- package/dist/conversations/permission-profile-store.d.ts +2 -1
- package/dist/conversations/permission-profiles.controller.d.ts +3 -0
- package/dist/conversations/permission-profiles.service.js +1 -1
- package/dist/conversations/prompt-suggestion-request.d.ts +1 -1
- package/dist/conversations/prompt-suggestion-request.js +2 -1
- package/dist/conversations/queue.d.ts +7 -4
- package/dist/conversations/queue.js +6 -2
- package/dist/conversations/queue.service.d.ts +5 -5
- package/dist/conversations/queue.service.js +20 -14
- package/dist/ctx/create-ctx.d.ts +20 -1
- package/dist/ctx/create-ctx.js +59 -2
- package/dist/db/kernel-schema.d.ts +104 -25
- package/dist/devices/device-project-files.service.d.ts +88 -0
- package/dist/devices/device-project-files.service.js +249 -0
- package/dist/devices/device-projects.service.d.ts +40 -0
- package/dist/devices/device-projects.service.js +16 -13
- package/dist/devices/devices.controller.d.ts +9 -3
- package/dist/devices/devices.controller.js +27 -5
- package/dist/devices/devices.module.js +9 -1
- package/dist/devices/devices.schemas.js +6 -1
- package/dist/devices/dto.d.ts +15 -0
- package/dist/devices/dto.js +11 -0
- package/dist/devices/project-paths.d.ts +29 -0
- package/dist/devices/project-paths.js +66 -0
- package/dist/devices/project-rules.d.ts +5 -1
- package/dist/devices/project-rules.js +5 -1
- package/dist/errors.d.ts +34 -13
- package/dist/errors.js +34 -13
- package/dist/evals/reconstruct.d.ts +10 -1
- package/dist/evals/reconstruct.js +7 -0
- package/dist/extensions/host.d.ts +6 -1
- package/dist/extensions/host.js +10 -0
- package/dist/extensions/permission-set.d.ts +17 -1
- package/dist/extensions/permission-set.js +13 -1
- package/dist/extensions/permission-view.d.ts +1 -1
- package/dist/extensions/permission-view.js +4 -1
- package/dist/git/gateway.js +2 -2
- package/dist/http/api.module.js +5 -5
- package/dist/http/request-signal.d.ts +8 -0
- package/dist/http/request-signal.js +14 -0
- package/dist/inbox/inbox.module.js +2 -2
- package/dist/inbox/inbox.service.d.ts +8 -8
- package/dist/inbox/inbox.service.js +7 -7
- package/dist/infra/config/kernel-config.service.js +10 -5
- package/dist/infra/outbox/registry.d.ts +29 -2
- package/dist/infra/outbox/registry.js +30 -7
- package/dist/kernel.module.js +3 -0
- package/dist/orgs/roles.d.ts +1 -1
- package/dist/orgs/roles.js +3 -3
- package/dist/orgs/settings.controller.d.ts +1 -1
- package/dist/orgs/settings.service.d.ts +27 -11
- package/dist/orgs/settings.service.js +42 -24
- package/dist/platform/operation.js +2 -2
- package/dist/platform/ops/{schedules.ops.d.ts → automations.ops.d.ts} +4 -4
- package/dist/platform/ops/automations.ops.js +560 -0
- package/dist/platform/ops/devices.ops.d.ts +3 -1
- package/dist/platform/ops/devices.ops.js +77 -3
- package/dist/platform/ops/inbox.ops.js +4 -4
- package/dist/platform/ops/orgs.ops.js +1 -1
- package/dist/platform/ops/platform.ops.js +4 -4
- package/dist/platform/platform-ops.module.d.ts +2 -2
- package/dist/platform/platform-ops.module.js +5 -5
- package/dist/platform/route-schemas.js +3 -3
- package/dist/push/jobs.d.ts +3 -3
- package/dist/push/jobs.js +2 -2
- package/dist/push/preferences.service.js +1 -1
- package/dist/push/push-owed.d.ts +3 -3
- package/dist/push/push-owed.js +6 -6
- package/dist/push/push.schemas.d.ts +4 -4
- package/dist/push/push.schemas.js +3 -3
- package/dist/push/recipients.d.ts +4 -4
- package/dist/push/recipients.js +23 -23
- package/dist/push/texts.d.ts +3 -3
- package/dist/push/texts.js +2 -2
- package/dist/push/triggers.d.ts +1 -1
- package/dist/roles/worker.module.js +3 -3
- package/dist/runtime/context/build.d.ts +6 -0
- package/dist/runtime/context/build.js +14 -3
- package/dist/runtime/context/compaction.js +15 -5
- package/dist/runtime/context/run-context.d.ts +38 -0
- package/dist/runtime/context/run-context.js +54 -0
- package/dist/runtime/maintenance.d.ts +8 -4
- package/dist/runtime/maintenance.js +37 -16
- package/dist/runtime/run-finish.d.ts +4 -4
- package/dist/runtime/run-finish.js +3 -3
- package/dist/runtime/run-queue.js +12 -7
- package/dist/runtime/run-worker.js +7 -1
- package/dist/runtime/runtime.module.js +3 -3
- package/dist/runtime/subagents/dispatch.js +11 -3
- package/dist/sandbox/browse-roots.d.ts +8 -0
- package/dist/sandbox/browse-roots.js +22 -0
- package/dist/sandbox/network-grants.d.ts +4 -4
- package/dist/sandbox/network-grants.js +7 -7
- package/dist/sandbox/operation-authority.d.ts +10 -3
- package/dist/sandbox/operation-authority.js +20 -10
- package/dist/sandbox/operation-intents.d.ts +3 -1
- package/dist/sandbox/operation-intents.js +11 -4
- package/dist/sandbox/permission-call-grants.js +2 -2
- package/dist/sandbox/permission-facts.js +1 -1
- package/dist/sandbox/review/classifier.d.ts +2 -2
- package/dist/sandbox/review/classifier.js +22 -11
- package/dist/sandbox/review/permission-candidate.d.ts +1 -1
- package/dist/sandbox/review/permission-candidate.js +1 -1
- package/dist/sandbox/sandbox.service.d.ts +15 -5
- package/dist/sandbox/sandbox.service.js +14 -8
- package/dist/storage/purge.d.ts +1 -1
- package/dist/storage/purge.js +2 -2
- package/dist/tools/approvals.service.d.ts +6 -6
- package/dist/tools/approvals.service.js +19 -19
- package/dist/tools/builtin-names.d.ts +12 -12
- package/dist/tools/builtin-names.js +29 -29
- package/dist/tools/builtins/{schedules.d.ts → automations.d.ts} +35 -33
- package/dist/tools/builtins/{schedules.js → automations.js} +236 -105
- package/dist/tools/builtins/builtin-tools.d.ts +8 -8
- package/dist/tools/builtins/builtin-tools.js +16 -16
- package/dist/tools/call-scope.d.ts +1 -1
- package/dist/tools/git-asks.js +1 -1
- package/dist/tools/git-push-policy.d.ts +3 -3
- package/dist/tools/git-push-policy.js +6 -6
- package/dist/tools/network-asks.d.ts +3 -3
- package/dist/tools/network-asks.js +3 -3
- package/dist/tools/pipeline.d.ts +4 -4
- package/dist/tools/pipeline.js +2 -2
- package/dist/tools/policy.d.ts +3 -3
- package/dist/tools/policy.js +3 -3
- package/dist/tools/tools.module.js +9 -9
- package/package.json +3 -3
- package/src/migrations/0188_automations_rename.sql +309 -0
- package/src/migrations/0189_event_automations.sql +136 -0
- package/dist/platform/ops/schedules.ops.js +0 -509
- package/dist/schedules/effective-settings.d.ts +0 -22
- package/dist/schedules/effective-settings.js +0 -18
- package/dist/schedules/errors.d.ts +0 -8
- package/dist/schedules/errors.js +0 -8
- package/dist/schedules/job-ids.d.ts +0 -81
- package/dist/schedules/job-ids.js +0 -95
- package/dist/schedules/schedules.module.d.ts +0 -16
- package/dist/schedules/schedules.schemas.js +0 -213
- package/dist/schedules/store.module.d.ts +0 -6
- package/dist/schedules/types.d.ts +0 -110
- /package/dist/{schedules → automations}/types.js +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Logger } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { AutomationStore } from "../../automations/store.js";
|
|
2
3
|
import { BackgroundTaskFinisher } from "../../background/finish.js";
|
|
3
4
|
import { BackgroundTaskStopper } from "../../background/stop.js";
|
|
4
5
|
import { BackgroundTaskStore } from "../../background/store.js";
|
|
@@ -20,11 +21,10 @@ import { ProviderRegistry } from "../../runtime/providers.js";
|
|
|
20
21
|
import { StepLog } from "../../runtime/step-log.js";
|
|
21
22
|
import { ManagedDeviceContextRecorder } from "../../sandbox/managed-device-context.js";
|
|
22
23
|
import { SandboxService } from "../../sandbox/sandbox.service.js";
|
|
23
|
-
import { ScheduledTaskStore } from "../../schedules/store.js";
|
|
24
24
|
import { StorageService } from "../../storage/storage.service.js";
|
|
25
25
|
import { ToolOutputs } from "../outputs.js";
|
|
26
26
|
import type { BuiltinCallContext, BuiltinTool } from "../registry.js";
|
|
27
|
-
import {
|
|
27
|
+
import { AutomationToolsPort, AutomationUpdates } from "./automations.js";
|
|
28
28
|
import { WebPages } from "./web/index.js";
|
|
29
29
|
/**
|
|
30
30
|
* The kernel's builtin tools, built once from the injected services (their specs: names,
|
|
@@ -43,12 +43,12 @@ export declare class BuiltinTools {
|
|
|
43
43
|
sealedInputs: SealedInputs,
|
|
44
44
|
/** A Platform write's file reference: a conversation file (spec §5). */
|
|
45
45
|
fileRefs: FileRefs,
|
|
46
|
-
/** The
|
|
47
|
-
|
|
48
|
-
/** `
|
|
49
|
-
|
|
50
|
-
/** The task service, bound by `
|
|
51
|
-
|
|
46
|
+
/** The automation tools read tasks and grants; their writes go through the task service. */
|
|
47
|
+
automationStore: AutomationStore,
|
|
48
|
+
/** `AutomationUpdate`'s write: its field change and grant changes in one transaction. */
|
|
49
|
+
automationUpdates: AutomationUpdates,
|
|
50
|
+
/** The task service, bound by `AutomationsModule` at start (a registration port: no cycle). */
|
|
51
|
+
automationPort: AutomationToolsPort,
|
|
52
52
|
/** `GenerateImage`: the image calls, and the image model's availability per listing. */
|
|
53
53
|
images: ModelImages, providers: ProviderRegistry,
|
|
54
54
|
/** The clock `CurrentTime` reads (the run context's clock seam; `Date.now` by default). */
|
|
@@ -8,6 +8,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
11
|
+
import { AutomationStore } from "../../automations/store.js";
|
|
11
12
|
import { BackgroundTaskFinisher } from "../../background/finish.js";
|
|
12
13
|
import { BackgroundTaskStopper } from "../../background/stop.js";
|
|
13
14
|
import { BackgroundTaskStore } from "../../background/store.js";
|
|
@@ -35,18 +36,17 @@ import { conversationTimeZone, RUN_CONTEXT_CLOCK } from "../../runtime/run-conte
|
|
|
35
36
|
import { StepLog } from "../../runtime/step-log.js";
|
|
36
37
|
import { ManagedDeviceContextRecorder } from "../../sandbox/managed-device-context.js";
|
|
37
38
|
import { SandboxService } from "../../sandbox/sandbox.service.js";
|
|
38
|
-
import { ScheduledTaskStore } from "../../schedules/store.js";
|
|
39
39
|
import { StorageService } from "../../storage/storage.service.js";
|
|
40
40
|
import { ToolOutputs } from "../outputs.js";
|
|
41
41
|
import { agentTool } from "./agent.js";
|
|
42
42
|
import { askUserTool } from "./ask-user.js";
|
|
43
|
+
import { AutomationToolsPort, AutomationUpdates, automationTools } from "./automations.js";
|
|
43
44
|
import { currentTimeTool } from "./current-time.js";
|
|
44
45
|
import { handbackTool } from "./handback.js";
|
|
45
46
|
import { generateImageTool } from "./image/index.js";
|
|
46
47
|
import { platformTool } from "./platform.js";
|
|
47
48
|
import { readToolOutputTool } from "./read-tool-output.js";
|
|
48
49
|
import { sandboxTools } from "./sandbox/index.js";
|
|
49
|
-
import { ScheduleToolsPort, ScheduleUpdates, scheduleTools } from "./schedules.js";
|
|
50
50
|
import { sendMessageTool } from "./send-message.js";
|
|
51
51
|
import { skillLoadTool } from "./skill-load.js";
|
|
52
52
|
import { toolSearchTool } from "./tool-search.js";
|
|
@@ -66,12 +66,12 @@ let BuiltinTools = class BuiltinTools {
|
|
|
66
66
|
sealedInputs,
|
|
67
67
|
/** A Platform write's file reference: a conversation file (spec §5). */
|
|
68
68
|
fileRefs,
|
|
69
|
-
/** The
|
|
70
|
-
|
|
71
|
-
/** `
|
|
72
|
-
|
|
73
|
-
/** The task service, bound by `
|
|
74
|
-
|
|
69
|
+
/** The automation tools read tasks and grants; their writes go through the task service. */
|
|
70
|
+
automationStore,
|
|
71
|
+
/** `AutomationUpdate`'s write: its field change and grant changes in one transaction. */
|
|
72
|
+
automationUpdates,
|
|
73
|
+
/** The task service, bound by `AutomationsModule` at start (a registration port: no cycle). */
|
|
74
|
+
automationPort,
|
|
75
75
|
/** `GenerateImage`: the image calls, and the image model's availability per listing. */
|
|
76
76
|
images, providers,
|
|
77
77
|
/** The clock `CurrentTime` reads (the run context's clock seam; `Date.now` by default). */
|
|
@@ -211,13 +211,13 @@ let BuiltinTools = class BuiltinTools {
|
|
|
211
211
|
now: now ?? Date.now,
|
|
212
212
|
timeZoneOf: ({ orgId, conversationId }) => conversationTimeZone(db.db, orgId, conversationId),
|
|
213
213
|
}),
|
|
214
|
-
// the person's
|
|
215
|
-
...
|
|
214
|
+
// the person's automations (scheduled tasks spec §11)
|
|
215
|
+
...automationTools({
|
|
216
216
|
db: () => db.db,
|
|
217
217
|
config,
|
|
218
|
-
store:
|
|
219
|
-
service: () =>
|
|
220
|
-
updates:
|
|
218
|
+
store: automationStore,
|
|
219
|
+
service: () => automationPort.get(),
|
|
220
|
+
updates: automationUpdates,
|
|
221
221
|
timeZoneOf: (orgId, conversationId) => conversationTimeZone(db.db, orgId, conversationId),
|
|
222
222
|
now: now ?? Date.now,
|
|
223
223
|
}),
|
|
@@ -252,9 +252,9 @@ BuiltinTools = __decorate([
|
|
|
252
252
|
__param(19, Inject(AgentDocs)),
|
|
253
253
|
__param(20, Inject(SealedInputs)),
|
|
254
254
|
__param(21, Inject(FileRefs)),
|
|
255
|
-
__param(22, Inject(
|
|
256
|
-
__param(23, Inject(
|
|
257
|
-
__param(24, Inject(
|
|
255
|
+
__param(22, Inject(AutomationStore)),
|
|
256
|
+
__param(23, Inject(AutomationUpdates)),
|
|
257
|
+
__param(24, Inject(AutomationToolsPort)),
|
|
258
258
|
__param(25, Inject(ModelImages)),
|
|
259
259
|
__param(26, Inject(ProviderRegistry)),
|
|
260
260
|
__param(27, Inject(ManagedDeviceContextRecorder)),
|
|
@@ -15,7 +15,7 @@ export interface CallFacts {
|
|
|
15
15
|
step: number;
|
|
16
16
|
/** The root conversation of the run's tree (a sub-agent works in its root's device). */
|
|
17
17
|
rootConversationId: string;
|
|
18
|
-
/** An unattended run (
|
|
18
|
+
/** An unattended run (an automation): nobody is there to answer an ask. */
|
|
19
19
|
unattended: boolean;
|
|
20
20
|
agentVersion: number;
|
|
21
21
|
conversationKind?: ConversationKindForHooks;
|
package/dist/tools/git-asks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { gitPushGrantKey, normalizeGitRepo } from "../automations/grant-rules.js";
|
|
1
2
|
import { GIT_ASK_MAX_REFS, GIT_REF_MAX_CHARS } from "../conversations/events.js";
|
|
2
|
-
import { gitPushGrantKey, normalizeGitRepo } from "../schedules/grant-rules.js";
|
|
3
3
|
import { GIT_ASK_CANCELLED_NOTE } from "./approvals.service.js";
|
|
4
4
|
import { clipKeptWith } from "./network-asks.js";
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { type UnattendedRun } from "../automations/unattended.js";
|
|
1
2
|
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
2
3
|
import type { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
3
|
-
import { type UnattendedRun } from "../schedules/unattended.js";
|
|
4
4
|
import { type GitRunState } from "./git-asks.js";
|
|
5
5
|
import type { ToolPolicy } from "./registry.js";
|
|
6
6
|
/** Why {@link decideGitPush} decided as it did. */
|
|
@@ -11,7 +11,7 @@ export type GitPushReason =
|
|
|
11
11
|
| "member_allow"
|
|
12
12
|
/** An approved 「这次允许」 of the run tree for the repository. */
|
|
13
13
|
| "run_grant"
|
|
14
|
-
/** The
|
|
14
|
+
/** The automation's `git:push` / `git:push:<owner>/<repo>` grant (unattended run). */
|
|
15
15
|
| "task_grant"
|
|
16
16
|
/** The policy asks the actor. */
|
|
17
17
|
| "ask"
|
|
@@ -55,7 +55,7 @@ export interface GitPushInput {
|
|
|
55
55
|
/** `<owner>/<repo>` (a trailing `.git` and case are normalized here). */
|
|
56
56
|
repo: string;
|
|
57
57
|
/**
|
|
58
|
-
* The
|
|
58
|
+
* The automation context of the run, when the caller has it (`unattendedRunOf`); undefined:
|
|
59
59
|
* read here. Null: an attended run.
|
|
60
60
|
*/
|
|
61
61
|
unattended?: UnattendedRun | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { sql } from "kysely";
|
|
2
|
+
import { GIT_PUSH_GRANT, gitPushForbidden, gitPushGrantKey, normalizeGitRepo, } from "../automations/grant-rules.js";
|
|
3
|
+
import { unattendedRules, unattendedRunOf } from "../automations/unattended.js";
|
|
2
4
|
import { budgetRunOf } from "../runtime/subagents/limits.js";
|
|
3
|
-
import { GIT_PUSH_GRANT, gitPushForbidden, gitPushGrantKey, normalizeGitRepo, } from "../schedules/grant-rules.js";
|
|
4
|
-
import { unattendedRules, unattendedRunOf } from "../schedules/unattended.js";
|
|
5
5
|
import { gitPushPolicyName, personalAuth } from "./connector-account-policies.js";
|
|
6
6
|
import { gitRepoKey } from "./git-asks.js";
|
|
7
7
|
import { connectorPolicy } from "./policy.js";
|
|
@@ -13,8 +13,8 @@ import { connectorPolicy } from "./policy.js";
|
|
|
13
13
|
* Storage (no new table): the org's default is `connectors.git_push_policy` (default `ask`); a
|
|
14
14
|
* member's standing allow (or deny) for one repository is their `connector_tool_account_policies`
|
|
15
15
|
* row `git_push:<host>/<owner>/<repo>` (a personal connector only: an org connector's push acts as the
|
|
16
|
-
* org); a run grant is an approved `once` git ask of the run tree;
|
|
17
|
-
* `git:push` and `git:push:<owner>/<repo>` in `
|
|
16
|
+
* org); a run grant is an approved `once` git ask of the run tree; an automation's grants are
|
|
17
|
+
* `git:push` and `git:push:<owner>/<repo>` in `automation_grants`.
|
|
18
18
|
*/
|
|
19
19
|
/** The statuses of a run that has not ended: its run grants still apply. */
|
|
20
20
|
const LIVE_RUN = ["queued", "running", "waiting"];
|
|
@@ -92,9 +92,9 @@ export async function decideGitPush(db, config, input) {
|
|
|
92
92
|
}
|
|
93
93
|
if (rules !== null) {
|
|
94
94
|
const granted = await db
|
|
95
|
-
.selectFrom("
|
|
95
|
+
.selectFrom("automation_grants")
|
|
96
96
|
.select("tool_key")
|
|
97
|
-
.where("
|
|
97
|
+
.where("automation_id", "=", rules.taskId)
|
|
98
98
|
.where("tool_key", "in", [GIT_PUSH_GRANT, key])
|
|
99
99
|
.executeTakeFirst();
|
|
100
100
|
if (granted !== undefined)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type NetworkBlockedHost } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { type UnattendedRun } from "../automations/unattended.js";
|
|
2
3
|
import type { NetworkRunState } from "../sandbox/network-grants.js";
|
|
3
|
-
import { type UnattendedRun } from "../schedules/unattended.js";
|
|
4
4
|
import { type ApprovalRecord, type NetworkAppliesAt } from "./approvals.service.js";
|
|
5
5
|
/**
|
|
6
6
|
* Network asks in the tool pipeline (network ask-to-allow spec §6.2, §6.6–§6.9, §8.3): what a
|
|
@@ -154,7 +154,7 @@ export interface NetworkPlanContext {
|
|
|
154
154
|
* is never asked about.
|
|
155
155
|
*/
|
|
156
156
|
offer?: (hosts: string[]) => NetworkAskOffer | null;
|
|
157
|
-
/** The
|
|
157
|
+
/** The automation run the run serves (null / undefined: attended). */
|
|
158
158
|
unattended: UnattendedRun | null | undefined;
|
|
159
159
|
/**
|
|
160
160
|
* Whether a host is beyond the platform's ceiling (`sandbox.limits.orgHosts: within`, org egress
|
|
@@ -245,7 +245,7 @@ export declare function blockedEventHosts(blocked: readonly NetworkBlockedHost[]
|
|
|
245
245
|
* carried that list (`ctx.deviceBlocks`): a note saying so, never asked;
|
|
246
246
|
* - a `device` host the device's settings already allow (`ctx.onList`: not yet applied to the
|
|
247
247
|
* instance): a note saying when it applies, never asked again;
|
|
248
|
-
* - approved by the
|
|
248
|
+
* - approved by the automation the run serves (`run.taskGranted`) yet refused: a note that
|
|
249
249
|
* the device ignores the task's grants (never asked, never a missing grant);
|
|
250
250
|
* - refused earlier in the run tree: the denied note; an unattended run in `fail` mode: its note
|
|
251
251
|
* and a missing grant;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { validateAllowHost } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { networkGrantKey, unattendedFails, unattendedRules, } from "../automations/unattended.js";
|
|
2
3
|
import { NETWORK_ASK_MAX_HOSTS, NETWORK_HOST_MAX_CHARS } from "../conversations/events.js";
|
|
3
4
|
import { coversHost } from "../sandbox/modes.js";
|
|
4
5
|
import { ESCALATION_UNATTENDED_WHY } from "../sandbox/review/permission-candidate.js";
|
|
5
|
-
import { networkGrantKey, unattendedFails, unattendedRules, } from "../schedules/unattended.js";
|
|
6
6
|
import { NETWORK_ASK_CANCELLED_NOTE, networkAskHosts, } from "./approvals.service.js";
|
|
7
7
|
/**
|
|
8
8
|
* Network asks in the tool pipeline (network ask-to-allow spec §6.2, §6.6–§6.9, §8.3): what a
|
|
@@ -191,7 +191,7 @@ export const unavailableHostNote = (host, why) => `[network] ${host} was blocked
|
|
|
191
191
|
* provider did not apply the task's network grant. Not asked, not a missing grant: the device's
|
|
192
192
|
* owner adds the host to the device's network list on its page.
|
|
193
193
|
*/
|
|
194
|
-
export const taskGrantIgnoredNote = (hosts) => `${blockedLead(hosts)} The
|
|
194
|
+
export const taskGrantIgnoredNote = (hosts) => `${blockedLead(hosts)} The automation approves ${pron(hosts)}, but this device did not apply the task's network grant. The device owner can add ${pron(hosts)} to the device's network list on its page. Continue without ${pron(hosts)}.`;
|
|
195
195
|
/** An unattended run in `fail` mode (spec §8.3): no ask, the creator can add a task grant. */
|
|
196
196
|
export const unattendedNetworkNote = (hosts) => `[network] ${list(hosts)} ${one(hosts) ? "is" : "are"} blocked on this device and this scheduled run cannot ask for network access. The task's owner can add ${pron(hosts)} to the task's approved domains. Continue without ${pron(hosts)}.`;
|
|
197
197
|
/**
|
|
@@ -239,7 +239,7 @@ export function blockedEventHosts(blocked) {
|
|
|
239
239
|
* carried that list (`ctx.deviceBlocks`): a note saying so, never asked;
|
|
240
240
|
* - a `device` host the device's settings already allow (`ctx.onList`: not yet applied to the
|
|
241
241
|
* instance): a note saying when it applies, never asked again;
|
|
242
|
-
* - approved by the
|
|
242
|
+
* - approved by the automation the run serves (`run.taskGranted`) yet refused: a note that
|
|
243
243
|
* the device ignores the task's grants (never asked, never a missing grant);
|
|
244
244
|
* - refused earlier in the run tree: the denied note; an unattended run in `fail` mode: its note
|
|
245
245
|
* and a missing grant;
|
package/dist/tools/pipeline.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ConversationSource, type FormAnswer, type InputForm, type Logger, type ServiceBlockedHost, type ToolCallContext, type ToolDisplay } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import type { AgentDefinition } from "../agents/definition.js";
|
|
3
|
+
import { type UnattendedRun } from "../automations/unattended.js";
|
|
3
4
|
import { ConversationApprovalProfile } from "../conversations/approval-profile.js";
|
|
4
5
|
import { AttachmentsService } from "../conversations/attachments.service.js";
|
|
5
6
|
import { EventLog } from "../conversations/event-log.js";
|
|
@@ -25,7 +26,6 @@ import { PermissionAutoGrants } from "../sandbox/permission-auto-grants.js";
|
|
|
25
26
|
import { PermissionCallGrants } from "../sandbox/permission-call-grants.js";
|
|
26
27
|
import { type CommandReview } from "../sandbox/review/index.js";
|
|
27
28
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
28
|
-
import { type UnattendedRun } from "../schedules/unattended.js";
|
|
29
29
|
import { ApprovalsService, type NetworkAskDetail } from "./approvals.service.js";
|
|
30
30
|
import { Breaker } from "./breaker.js";
|
|
31
31
|
import { Credentials } from "./credentials.js";
|
|
@@ -90,7 +90,7 @@ export declare const INPUT_SKIPPED_TEXT = "The user did not provide the requeste
|
|
|
90
90
|
*/
|
|
91
91
|
export declare const WAIT_SKIPPED_TEXT = "The user sent a message while this wait was running, which ended it; read the message below and continue. Call the tool again only if the wait is still needed.";
|
|
92
92
|
/** A watched ask over `tools.maxWatchedWaitsPerAccount` (spec §5.2). */
|
|
93
|
-
export declare const TOO_MANY_WATCHED_WAITS_TEXT = "Too many waits are running for this user; end one, or finish and let
|
|
93
|
+
export declare const TOO_MANY_WATCHED_WAITS_TEXT = "Too many waits are running for this user; end one, or finish and let an automation check later.";
|
|
94
94
|
/** A tool asked for a watched wait without a registered watcher (spec §5.2). */
|
|
95
95
|
export declare const watchWithoutWatcherText: (key: string) => string;
|
|
96
96
|
/** 同一调用连续请求输入超过上限。 */
|
|
@@ -208,7 +208,7 @@ export interface PolicyContext {
|
|
|
208
208
|
*/
|
|
209
209
|
callPolicy?: CallPolicy | null;
|
|
210
210
|
/**
|
|
211
|
-
* The
|
|
211
|
+
* The automation run the run serves, unattended or trial (scheduled tasks spec §7); unset or
|
|
212
212
|
* null: an attended run.
|
|
213
213
|
*/
|
|
214
214
|
unattended?: UnattendedRun | null;
|
|
@@ -344,7 +344,7 @@ export interface ToolStepContext {
|
|
|
344
344
|
*/
|
|
345
345
|
parent?: SubagentParent;
|
|
346
346
|
/**
|
|
347
|
-
* The
|
|
347
|
+
* The automation run this run serves (scheduled tasks spec §7); filled by `runStep` once per
|
|
348
348
|
* step from PG (`unattendedRunOf`), null when attended. Callers leave it unset.
|
|
349
349
|
*/
|
|
350
350
|
unattended?: UnattendedRun | null;
|
package/dist/tools/pipeline.js
CHANGED
|
@@ -10,6 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { CARD_BADGE_MAX, CARD_TEXT_MAX, DeviceAccessError, ToolError, validateInputForm, validateToolDisplay, } from "@capybara-hq/plugin-sdk";
|
|
11
11
|
import { Inject, Injectable, Optional } from "@nestjs/common";
|
|
12
12
|
import { sql } from "kysely";
|
|
13
|
+
import { appendMissingGrant, connectionGrantKey, UNATTENDED_CONNECTION_ERROR, UNATTENDED_ELICITATION_NOTE, UNATTENDED_QUESTION_ERROR, unattendedFails, unattendedRules, unattendedRunOf, } from "../automations/unattended.js";
|
|
13
14
|
import { backgroundMaxSeconds } from "../background/launch.js";
|
|
14
15
|
import { ConversationApprovalProfile } from "../conversations/approval-profile.js";
|
|
15
16
|
import { AttachmentsService } from "../conversations/attachments.service.js";
|
|
@@ -49,7 +50,6 @@ import { isSessionGrantableRule, } from "../sandbox/review/index.js";
|
|
|
49
50
|
import { approverForCrossing, buildPermissionCandidate, crossingOfCandidate, ESCALATION_RETRY_HINT, ESCALATION_UNATTENDED_WHY, escalationRefusedText, isEscalatedCall, } from "../sandbox/review/permission-candidate.js";
|
|
50
51
|
import { CommandReviewService } from "../sandbox/review/review.service.js";
|
|
51
52
|
import { SandboxService } from "../sandbox/sandbox.service.js";
|
|
52
|
-
import { appendMissingGrant, connectionGrantKey, UNATTENDED_CONNECTION_ERROR, UNATTENDED_ELICITATION_NOTE, UNATTENDED_QUESTION_ERROR, unattendedFails, unattendedRules, unattendedRunOf, } from "../schedules/unattended.js";
|
|
53
53
|
import { skillLoadOfferedIn } from "../skills/catalog.js";
|
|
54
54
|
import { ApprovalsService, } from "./approvals.service.js";
|
|
55
55
|
import { Breaker, breakerOpenMessage } from "./breaker.js";
|
|
@@ -144,7 +144,7 @@ export const INPUT_SKIPPED_TEXT = "The user did not provide the requested input
|
|
|
144
144
|
*/
|
|
145
145
|
export const WAIT_SKIPPED_TEXT = "The user sent a message while this wait was running, which ended it; read the message below and continue. Call the tool again only if the wait is still needed.";
|
|
146
146
|
/** A watched ask over `tools.maxWatchedWaitsPerAccount` (spec §5.2). */
|
|
147
|
-
export const TOO_MANY_WATCHED_WAITS_TEXT = "Too many waits are running for this user; end one, or finish and let
|
|
147
|
+
export const TOO_MANY_WATCHED_WAITS_TEXT = "Too many waits are running for this user; end one, or finish and let an automation check later.";
|
|
148
148
|
/** A tool asked for a watched wait without a registered watcher (spec §5.2). */
|
|
149
149
|
export const watchWithoutWatcherText = (key) => `Tool ${key} asked for a watched wait but registers no watcher.`;
|
|
150
150
|
/** 同一调用连续请求输入超过上限。 */
|
package/dist/tools/policy.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { R3_FIXED_ASK_TOOL_KEYS } from "./builtin-names.js";
|
|
|
6
6
|
export { isFixedAsk } from "./fixed-ask.js";
|
|
7
7
|
/**
|
|
8
8
|
* What allowed an ask without an approval: this conversation's grant, an "always" grant, or a
|
|
9
|
-
*
|
|
9
|
+
* automation's grant (its unattended runs, scheduled tasks spec §7).
|
|
10
10
|
*/
|
|
11
11
|
export type GrantKind = "session" | "always" | "task";
|
|
12
12
|
/** 取更严的策略(`allow < ask < deny`)。 */
|
|
@@ -16,10 +16,10 @@ export interface PolicyInput {
|
|
|
16
16
|
connectorDefault: ToolPolicy;
|
|
17
17
|
/** agent 负责人的收紧(`definition.toolPolicies[key]`)。 */
|
|
18
18
|
agentOverride?: "ask" | "deny";
|
|
19
|
-
/** `requiresUserInteraction
|
|
19
|
+
/** `requiresUserInteraction`. */
|
|
20
20
|
fixedAsk: boolean;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* A remembered grant whose specHash matches the current one; `task`: an automation's grant in its unattended run.
|
|
23
23
|
*/
|
|
24
24
|
grant: GrantKind | null;
|
|
25
25
|
}
|
package/dist/tools/policy.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { sql } from "kysely";
|
|
2
2
|
import { normalizeStoredDefinition } from "../agents/definition.js";
|
|
3
|
+
import { grantRefusalOf } from "../automations/grant-rules.js";
|
|
4
|
+
import { findTaskGrant } from "../automations/store.js";
|
|
5
|
+
import { changesAgentSkills, UNATTENDED_ASK_ERROR, UNATTENDED_FIXED_ASK_ERROR, UNATTENDED_QUESTION_ERROR, unattendedRules, } from "../automations/unattended.js";
|
|
3
6
|
import { roleAtLeast } from "../orgs/roles.js";
|
|
4
7
|
import { FORBIDDEN_TOOLS_UNREADABLE_ERROR, readOrgSettings } from "../orgs/settings.service.js";
|
|
5
|
-
import { grantRefusalOf } from "../schedules/grant-rules.js";
|
|
6
|
-
import { findTaskGrant } from "../schedules/store.js";
|
|
7
|
-
import { changesAgentSkills, UNATTENDED_ASK_ERROR, UNATTENDED_FIXED_ASK_ERROR, UNATTENDED_QUESTION_ERROR, unattendedRules, } from "../schedules/unattended.js";
|
|
8
8
|
import { BUILTIN, SANDBOX_ASK_TOOL_NAMES } from "./builtin-names.js";
|
|
9
9
|
import { personalAuth } from "./connector-account-policies.js";
|
|
10
10
|
import { isFixedAsk } from "./fixed-ask.js";
|
|
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { Module } from "@nestjs/common";
|
|
8
|
+
import { AutomationStoreModule } from "../automations/store.module.js";
|
|
8
9
|
import { BackgroundModule } from "../background/background.module.js";
|
|
9
10
|
import { ConversationAccessModule } from "../conversations/access.js";
|
|
10
11
|
import { ConversationApprovalProfileModule } from "../conversations/approval-profile.js";
|
|
@@ -29,14 +30,13 @@ import { OperationAuthorityModule } from "../sandbox/operation-authority.module.
|
|
|
29
30
|
import { PermissionAuthorityModule } from "../sandbox/permission-authority.module.js";
|
|
30
31
|
import { PermissionCallGrantsModule } from "../sandbox/permission-call-grants.module.js";
|
|
31
32
|
import { SandboxModule } from "../sandbox/sandbox.module.js";
|
|
32
|
-
import { ScheduledTaskStoreModule } from "../schedules/store.module.js";
|
|
33
33
|
import { SkillsModule } from "../skills/skills.module.js";
|
|
34
34
|
import { StorageModule } from "../storage/storage.module.js";
|
|
35
35
|
import { AdminConnectors } from "./admin-connectors.js";
|
|
36
36
|
import { ApprovalsService } from "./approvals.service.js";
|
|
37
37
|
import { Breaker } from "./breaker.js";
|
|
38
|
+
import { AutomationToolsPort, AutomationUpdates } from "./builtins/automations.js";
|
|
38
39
|
import { BuiltinTools } from "./builtins/builtin-tools.js";
|
|
39
|
-
import { ScheduleToolsPort, ScheduleUpdates } from "./builtins/schedules.js";
|
|
40
40
|
import { WebPages } from "./builtins/web/page-cache.js";
|
|
41
41
|
import { ConnectorAccountPolicies } from "./connector-account-policies.js";
|
|
42
42
|
import { ConnectorContent } from "./connector-content.js";
|
|
@@ -108,8 +108,8 @@ ToolsModule = __decorate([
|
|
|
108
108
|
// ConnectorToolsProcessor)
|
|
109
109
|
ConnectorToolsQueueModule,
|
|
110
110
|
ToolWatchQueueModule,
|
|
111
|
-
// a trial run's approvals become its
|
|
112
|
-
|
|
111
|
+
// a trial run's approvals become its automation's grants (scheduled tasks spec §7)
|
|
112
|
+
AutomationStoreModule,
|
|
113
113
|
// connector credentials (also the git gateway's, without importing this module)
|
|
114
114
|
CredentialsModule,
|
|
115
115
|
],
|
|
@@ -119,10 +119,10 @@ ToolsModule = __decorate([
|
|
|
119
119
|
BuiltinTools,
|
|
120
120
|
// a Platform write's file reference (a conversation file)
|
|
121
121
|
FileRefs,
|
|
122
|
-
// `
|
|
123
|
-
|
|
124
|
-
// where `
|
|
125
|
-
|
|
122
|
+
// `AutomationUpdate`'s write in one transaction (scheduled tasks spec §11)
|
|
123
|
+
AutomationUpdates,
|
|
124
|
+
// where `AutomationsModule` binds the task service for the automation tools (no provider cycle)
|
|
125
|
+
AutomationToolsPort,
|
|
126
126
|
WebPages,
|
|
127
127
|
ToolRegistry,
|
|
128
128
|
ApprovalsService,
|
|
@@ -144,7 +144,7 @@ ToolsModule = __decorate([
|
|
|
144
144
|
],
|
|
145
145
|
exports: [
|
|
146
146
|
PermissionApprovalJobs,
|
|
147
|
-
|
|
147
|
+
AutomationToolsPort,
|
|
148
148
|
CredentialsModule,
|
|
149
149
|
ToolOutputs,
|
|
150
150
|
BuiltinTools,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/kernel",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.106",
|
|
4
4
|
"description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"yaml": "^2.9.1",
|
|
67
67
|
"yauzl": "3.4.0",
|
|
68
68
|
"zod": "^4.6.7",
|
|
69
|
-
"@capybara-hq/plugin-sdk": "^0.1.0-rc.
|
|
69
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.85"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@langchain/langgraph-checkpoint-validation": "^1.2.0",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@types/ws": "^8.18.2",
|
|
76
76
|
"@types/yauzl": "3.4.0",
|
|
77
77
|
"ws": "^8.22.0",
|
|
78
|
-
"@capybara-hq/testing": "0.1.0-rc.
|
|
78
|
+
"@capybara-hq/testing": "0.1.0-rc.47"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"build": "tsc -b"
|