@capybara-hq/kernel 0.1.0-rc.121 → 0.1.0-rc.123
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/bootstrap.json +3 -3
- package/dist/background/finish.d.ts +5 -1
- package/dist/background/finish.js +29 -18
- package/dist/background/launch.d.ts +0 -5
- package/dist/background/launch.js +1 -6
- package/dist/background/managed.js +1 -4
- package/dist/background/poll.job.d.ts +3 -25
- package/dist/background/poll.job.js +20 -112
- package/dist/background/render.d.ts +2 -8
- package/dist/background/render.js +3 -17
- package/dist/background/stop.d.ts +15 -16
- package/dist/background/stop.js +39 -76
- package/dist/background/store.d.ts +17 -45
- package/dist/background/store.js +60 -94
- package/dist/background/tasks.service.d.ts +2 -5
- package/dist/background/tasks.service.js +9 -20
- package/dist/background/wake.js +3 -2
- package/dist/catalog/admin-catalog.controller.d.ts +2 -18
- package/dist/catalog/admin-catalog.controller.js +2 -28
- package/dist/catalog/catalog-content.d.ts +1 -5
- package/dist/catalog/catalog-items.d.ts +2 -6
- package/dist/catalog/catalog-items.js +5 -26
- package/dist/catalog/catalog-scope.service.d.ts +1 -121
- package/dist/catalog/catalog-scope.service.js +12 -552
- package/dist/catalog/catalog.service.d.ts +4 -15
- package/dist/catalog/catalog.service.js +7 -35
- package/dist/catalog/job-ids.d.ts +0 -18
- package/dist/catalog/job-ids.js +0 -20
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.service.js +6 -20
- package/dist/catalog/org-plugin-uploads.controller.d.ts +4 -19
- package/dist/catalog/org-plugin-uploads.controller.js +6 -34
- package/dist/catalog/org-plugin-uploads.d.ts +3 -10
- package/dist/catalog/org-plugin-uploads.js +4 -18
- package/dist/catalog/org-plugin-uploads.schemas.js +0 -1
- package/dist/catalog/owned-items.d.ts +6 -11
- package/dist/catalog/owned-items.js +10 -20
- package/dist/catalog/ownership.d.ts +3 -29
- package/dist/catalog/ownership.js +4 -54
- package/dist/catalog/platform-components.d.ts +5 -11
- package/dist/catalog/platform-components.js +8 -15
- package/dist/catalog/plugin-import.d.ts +3 -42
- package/dist/catalog/plugin-import.js +26 -195
- package/dist/catalog/plugin-install.js +1 -6
- package/dist/catalog/plugin-package.d.ts +1 -0
- package/dist/catalog/plugin-package.js +5 -0
- package/dist/catalog/plugin-upgrade.d.ts +3 -26
- package/dist/catalog/plugin-upgrade.js +20 -103
- package/dist/catalog/request-rules.js +4 -6
- package/dist/catalog/scope-sync.js +2 -4
- package/dist/catalog/scope.d.ts +2 -5
- package/dist/channels/jobs.d.ts +3 -3
- package/dist/channels/jobs.js +4 -3
- package/dist/channels/outbound.d.ts +1 -0
- package/dist/channels/outbound.js +32 -8
- package/dist/config/load.d.ts +0 -25
- package/dist/config/load.js +0 -57
- package/dist/config/schema.js +2 -3
- package/dist/conversations/attachments.service.js +3 -5
- package/dist/conversations/conversations.service.d.ts +3 -3
- package/dist/conversations/conversations.service.js +3 -3
- package/dist/conversations/job-org.d.ts +3 -0
- package/dist/conversations/job-org.js +11 -0
- package/dist/conversations/prompt-suggestions.d.ts +2 -7
- package/dist/conversations/prompt-suggestions.js +29 -27
- package/dist/conversations/titles.d.ts +3 -4
- package/dist/conversations/titles.js +19 -30
- package/dist/db/kernel-schema.d.ts +6 -16
- package/dist/db/pool.js +7 -2
- package/dist/devices/devices.controller.d.ts +0 -5
- package/dist/devices/devices.controller.js +2 -20
- package/dist/devices/devices.service.d.ts +1 -17
- package/dist/devices/devices.service.js +0 -22
- package/dist/errors.d.ts +1 -5
- package/dist/errors.js +1 -5
- package/dist/evals/judge.d.ts +3 -0
- package/dist/evals/judge.js +1 -1
- package/dist/evals/run-replay.d.ts +1 -1
- package/dist/evals/run-replay.js +26 -29
- package/dist/evals/step-replay.d.ts +3 -1
- package/dist/evals/step-replay.js +10 -1
- package/dist/evals/worker.d.ts +3 -1
- package/dist/evals/worker.js +53 -21
- package/dist/extensions/deployment-config-store.js +18 -14
- package/dist/extensions/effective-config.d.ts +1 -5
- package/dist/extensions/effective-config.js +1 -5
- package/dist/extensions/hooks.d.ts +3 -1
- package/dist/extensions/hooks.js +7 -2
- package/dist/extensions/installs.d.ts +2 -14
- package/dist/extensions/installs.js +10 -32
- package/dist/extensions/org-config.d.ts +3 -4
- package/dist/extensions/org-config.js +3 -4
- package/dist/extensions/plugin-guides.d.ts +0 -1
- package/dist/extensions/plugin-guides.js +0 -1
- package/dist/extensions/plugin-icons.d.ts +0 -1
- package/dist/extensions/plugin-icons.js +0 -3
- package/dist/files/blob-sweep.job.d.ts +2 -11
- package/dist/files/blob-sweep.job.js +7 -21
- package/dist/files/hash-job.d.ts +5 -15
- package/dist/files/hash-job.js +14 -33
- package/dist/files/library-jobs.module.d.ts +1 -6
- package/dist/files/library-jobs.module.js +3 -9
- package/dist/identity/api-tokens.js +54 -40
- package/dist/identity/auth.guard.js +2 -2
- package/dist/identity/sessions.js +7 -3
- package/dist/identity/settings.js +5 -21
- package/dist/inbox/inbox.service.d.ts +2 -3
- package/dist/inbox/org-notices.d.ts +0 -14
- package/dist/inbox/platform-inbox.service.d.ts +1 -8
- package/dist/inbox/platform-inbox.service.js +2 -6
- package/dist/inbox/platform-notices.d.ts +3 -3
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -3
- package/dist/infra/database/database.module.js +2 -1
- package/dist/infra/database/org-scope.d.ts +5 -3
- package/dist/infra/database/org-scope.js +7 -1
- package/dist/infra/database/scoped-dialect.d.ts +3 -1
- package/dist/infra/database/scoped-dialect.js +17 -5
- package/dist/infra/events/kernel-events.d.ts +2 -0
- package/dist/infra/outbox/outbox.service.d.ts +2 -0
- package/dist/infra/outbox/outbox.service.js +10 -0
- package/dist/infra/outbox/registry.d.ts +0 -41
- package/dist/infra/outbox/registry.js +0 -37
- package/dist/models/embeddings.d.ts +0 -5
- package/dist/models/embeddings.js +28 -35
- package/dist/models/images.d.ts +3 -8
- package/dist/models/images.js +19 -37
- package/dist/models/purposes.d.ts +7 -2
- package/dist/models/purposes.js +16 -3
- package/dist/orgs/device-network-setting.d.ts +0 -44
- package/dist/orgs/device-network-setting.js +0 -83
- package/dist/orgs/invitations.service.js +34 -30
- package/dist/orgs/offboarding.d.ts +2 -2
- package/dist/orgs/offboarding.js +2 -2
- package/dist/orgs/orgs.service.d.ts +1 -1
- package/dist/orgs/orgs.service.js +19 -15
- package/dist/orgs/settings.service.d.ts +19 -14
- package/dist/orgs/settings.service.js +12 -37
- package/dist/platform/exclusions.js +0 -11
- package/dist/platform/ops/catalog-admin.ops.js +0 -8
- package/dist/platform/ops/devices.ops.js +0 -28
- package/dist/platform/ops/extensions-admin.ops.js +3 -3
- package/dist/platform/ops/inbox.ops.js +5 -22
- package/dist/platform/ops/org-plugins.ops.d.ts +1 -3
- package/dist/platform/ops/org-plugins.ops.js +11 -67
- package/dist/roles/worker.module.js +0 -9
- package/dist/runtime/hook-calls.d.ts +13 -6
- package/dist/runtime/hook-calls.js +26 -4
- package/dist/runtime/maintenance.d.ts +3 -12
- package/dist/runtime/maintenance.js +25 -55
- package/dist/runtime/model-call.d.ts +4 -2
- package/dist/runtime/model-call.js +59 -58
- package/dist/runtime/providers.d.ts +27 -1
- package/dist/runtime/providers.js +57 -0
- package/dist/runtime/run-jobs.d.ts +1 -1
- package/dist/runtime/run-processors.d.ts +3 -9
- package/dist/runtime/run-worker.d.ts +2 -0
- package/dist/runtime/run-worker.js +23 -8
- package/dist/runtime/subagents/deliveries.js +6 -1
- package/dist/runtime/subagents/dispatch.d.ts +3 -3
- package/dist/runtime/write-base.service.d.ts +2 -3
- package/dist/runtime/write-base.service.js +3 -5
- package/dist/sandbox/device-sandbox-settings.d.ts +38 -92
- package/dist/sandbox/device-sandbox-settings.js +19 -325
- package/dist/sandbox/jobs.d.ts +3 -14
- package/dist/sandbox/jobs.js +2 -20
- package/dist/sandbox/modes.d.ts +5 -45
- package/dist/sandbox/modes.js +3 -60
- package/dist/sandbox/operation-authority.js +0 -11
- package/dist/sandbox/operation-intents.d.ts +32 -9
- package/dist/sandbox/operation-intents.js +241 -32
- package/dist/sandbox/operation-intents.module.js +2 -1
- package/dist/sandbox/operation-reconcile.job.d.ts +9 -11
- package/dist/sandbox/operation-reconcile.job.js +119 -33
- package/dist/sandbox/operation-revoke.d.ts +20 -0
- package/dist/sandbox/operation-revoke.js +3 -0
- package/dist/sandbox/permission-ceiling-writes.d.ts +1 -2
- package/dist/sandbox/permission-ceiling-writes.js +3 -6
- package/dist/sandbox/permission-config-publication.d.ts +1 -28
- package/dist/sandbox/permission-config-publication.js +14 -211
- package/dist/sandbox/permission-facts.d.ts +4 -15
- package/dist/sandbox/permission-facts.js +7 -29
- package/dist/sandbox/permission-instance-writes.d.ts +1 -4
- package/dist/sandbox/permission-instance-writes.js +1 -55
- package/dist/sandbox/providers.d.ts +1 -6
- package/dist/sandbox/providers.js +1 -15
- package/dist/sandbox/review/classifier.js +12 -13
- package/dist/sandbox/sandbox.module.js +3 -6
- package/dist/sandbox/sandbox.service.d.ts +17 -123
- package/dist/sandbox/sandbox.service.js +239 -998
- package/dist/shares/liveness.d.ts +1 -2
- package/dist/shares/liveness.js +1 -2
- package/dist/shares/shares.module.d.ts +1 -2
- package/dist/shares/shares.module.js +2 -5
- package/dist/shares/shares.service.js +1 -2
- package/dist/tools/builtins/image/generate.js +7 -15
- package/dist/tools/builtins/sandbox/common.d.ts +0 -2
- package/dist/tools/builtins/sandbox/common.js +1 -27
- package/dist/tools/builtins/sandbox/task-list.js +10 -10
- package/dist/tools/builtins/sandbox/task-output.d.ts +3 -10
- package/dist/tools/builtins/sandbox/task-output.js +13 -83
- package/dist/tools/builtins/sandbox/task-stop.js +18 -22
- package/dist/tools/builtins/vision/read-image.js +9 -10
- package/dist/tools/builtins/web/extract.js +9 -10
- package/package.json +3 -3
- package/src/migrations/0206_retire_org_extension_uploads.sql +125 -0
- package/src/migrations/0207_confirm_device_instance_destruction.sql +25 -0
- package/src/migrations/0208_convert_stored_permission_settings.sql +189 -0
- package/dist/background/retire-legacy-tasks.job.d.ts +0 -57
- package/dist/background/retire-legacy-tasks.job.js +0 -149
- package/dist/catalog/owned-plugin-cleanup.d.ts +0 -47
- package/dist/catalog/owned-plugin-cleanup.js +0 -140
- package/dist/config/permission-migration.d.ts +0 -34
- package/dist/config/permission-migration.js +0 -115
- package/dist/devices/legacy-cleanup.job.d.ts +0 -34
- package/dist/devices/legacy-cleanup.job.js +0 -147
- package/dist/files/library-backfill.d.ts +0 -63
- package/dist/files/library-backfill.js +0 -143
- package/dist/infra/cli/permission-cutover.d.ts +0 -59
- package/dist/infra/cli/permission-cutover.js +0 -107
- package/dist/sandbox/cloud-permission-snapshot.d.ts +0 -159
- package/dist/sandbox/cloud-permission-snapshot.js +0 -430
- package/dist/sandbox/cloud-permission-snapshot.module.d.ts +0 -8
- package/dist/sandbox/cloud-permission-snapshot.module.js +0 -34
- package/dist/sandbox/legacy-retirement.d.ts +0 -284
- package/dist/sandbox/legacy-retirement.js +0 -1165
- package/dist/sandbox/legacy-retirement.module.d.ts +0 -8
- package/dist/sandbox/legacy-retirement.module.js +0 -25
- package/dist/shares/share-objects.d.ts +0 -47
- package/dist/shares/share-objects.js +0 -93
|
@@ -35,8 +35,7 @@ export declare const creatorStillHasAccess: (eb: ExpressionBuilder<KernelDatabas
|
|
|
35
35
|
* org that is `ready`, and the library file it was made from is not deleted and is still its
|
|
36
36
|
* creator's. Only a conversation's share may name no file (`source_file_id` is set null when the
|
|
37
37
|
* file row is purged; the conversation checks still hold it); a library share whose file row is
|
|
38
|
-
* gone never serves again, whether or not its revoke landed.
|
|
39
|
-
* during a rolling deploy.
|
|
38
|
+
* gone never serves again, whether or not its revoke landed.
|
|
40
39
|
*/
|
|
41
40
|
export declare const shareSourceOk: (eb: ExpressionBuilder<KernelDatabase, "file_shares">) => import("kysely").ExpressionWrapper<KernelDatabase, "file_shares", import("kysely").SqlBool>;
|
|
42
41
|
/**
|
package/dist/shares/liveness.js
CHANGED
|
@@ -51,8 +51,7 @@ export const creatorStillHasAccess = (eb) => eb.or([
|
|
|
51
51
|
* org that is `ready`, and the library file it was made from is not deleted and is still its
|
|
52
52
|
* creator's. Only a conversation's share may name no file (`source_file_id` is set null when the
|
|
53
53
|
* file row is purged; the conversation checks still hold it); a library share whose file row is
|
|
54
|
-
* gone never serves again, whether or not its revoke landed.
|
|
55
|
-
* during a rolling deploy.
|
|
54
|
+
* gone never serves again, whether or not its revoke landed.
|
|
56
55
|
*/
|
|
57
56
|
export const shareSourceOk = (eb) => eb.and([
|
|
58
57
|
eb.exists(eb
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* File sharing (file sharing spec, file library spec §6): creating, refreshing, revoking and listing
|
|
3
3
|
* shares ({@link SharesService}), the live check the open routes use (`ShareLiveness`), the public
|
|
4
|
-
* open routes' service (`ShareOpenService`, streaming the share's blob)
|
|
5
|
-
* deletion the maintenance worker runs (`ShareObjects`).
|
|
4
|
+
* open routes' service (`ShareOpenService`, streaming the share's blob).
|
|
6
5
|
*/
|
|
7
6
|
export declare class SharesModule {
|
|
8
7
|
}
|
|
@@ -11,14 +11,12 @@ import { LibraryReadModule } from "../files/library-read.module.js";
|
|
|
11
11
|
import { HtmlTokensModule } from "../html/html-token.js";
|
|
12
12
|
import { OrgLockModule } from "../orgs/org-lock.js";
|
|
13
13
|
import { ShareLivenessModule } from "./liveness.js";
|
|
14
|
-
import { ShareObjectsModule } from "./share-objects.js";
|
|
15
14
|
import { ShareOpenService } from "./share-open.service.js";
|
|
16
15
|
import { SharesService } from "./shares.service.js";
|
|
17
16
|
/**
|
|
18
17
|
* File sharing (file sharing spec, file library spec §6): creating, refreshing, revoking and listing
|
|
19
18
|
* shares ({@link SharesService}), the live check the open routes use (`ShareLiveness`), the public
|
|
20
|
-
* open routes' service (`ShareOpenService`, streaming the share's blob)
|
|
21
|
-
* deletion the maintenance worker runs (`ShareObjects`).
|
|
19
|
+
* open routes' service (`ShareOpenService`, streaming the share's blob).
|
|
22
20
|
*/
|
|
23
21
|
let SharesModule = class SharesModule {
|
|
24
22
|
};
|
|
@@ -30,13 +28,12 @@ SharesModule = __decorate([
|
|
|
30
28
|
LibraryReadModule,
|
|
31
29
|
OrgLockModule,
|
|
32
30
|
ShareLivenessModule,
|
|
33
|
-
ShareObjectsModule,
|
|
34
31
|
HtmlTokensModule,
|
|
35
32
|
// the share page's extension previewers (file sharing spec §7)
|
|
36
33
|
FilesModule,
|
|
37
34
|
],
|
|
38
35
|
providers: [SharesService, ShareOpenService],
|
|
39
|
-
exports: [SharesService, ShareOpenService, ShareLivenessModule
|
|
36
|
+
exports: [SharesService, ShareOpenService, ShareLivenessModule],
|
|
40
37
|
})
|
|
41
38
|
], SharesModule);
|
|
42
39
|
export { SharesModule };
|
|
@@ -31,7 +31,6 @@ import { UUID_RE } from "../ui/registry.js";
|
|
|
31
31
|
import { creatorStillHasAccess, shareSourceOk } from "./liveness.js";
|
|
32
32
|
import { effectiveExternalSharing, readExternalSharing, readShareMaxExpiry, } from "./settings.js";
|
|
33
33
|
import { newShareCode } from "./share-code.js";
|
|
34
|
-
import { shareRefreshLockKey } from "./share-objects.js";
|
|
35
34
|
/** Revoked or expired shares stay in the lists this long (the "recent" section). */
|
|
36
35
|
export const SHARE_RECENT_DAYS = 7;
|
|
37
36
|
/** The most shares one list returns (newest first). */
|
|
@@ -230,7 +229,7 @@ let SharesService = class SharesService {
|
|
|
230
229
|
async refresh(orgId, accountId, shareId, actor = {}) {
|
|
231
230
|
if (!UUID_RE.test(shareId))
|
|
232
231
|
throw notFound();
|
|
233
|
-
await this.locks.run(
|
|
232
|
+
await this.locks.run(`share-refresh-${shareId}`, { ttlMs: REFRESH_LOCK_TTL_MS, waitMs: REFRESH_LOCK_WAIT_MS }, async () => {
|
|
234
233
|
const s = await this.db
|
|
235
234
|
.selectFrom("file_shares")
|
|
236
235
|
.select([
|
|
@@ -2,10 +2,10 @@ import { IMAGE_ASPECT_RATIOS, IMAGE_MEDIA_TYPES, isModelError, MEDIA_LIMITS, Too
|
|
|
2
2
|
import { isValidArtifactName } from "../../../conversations/events.js";
|
|
3
3
|
import { ApiError } from "../../../errors.js";
|
|
4
4
|
import { IMAGE_PURPOSE, imagePurposeState, } from "../../../models/image-usable.js";
|
|
5
|
-
import { billedImages,
|
|
5
|
+
import { billedImages, } from "../../../models/images.js";
|
|
6
6
|
import { hookDeniedAudit, hookDeniedEvent, hookScope, } from "../../../runtime/hook-calls.js";
|
|
7
7
|
import { appendCounted } from "../../../runtime/model-call.js";
|
|
8
|
-
import { ProviderListError } from "../../../runtime/providers.js";
|
|
8
|
+
import { ModelRequestDenied, ProviderListError, } from "../../../runtime/providers.js";
|
|
9
9
|
import { NO_STORAGE, NO_STORAGE_REASON, REPEAT_CLAUSE, storeArtifacts, } from "../artifacts.js";
|
|
10
10
|
import { findConversationFile } from "../conversation-files.js";
|
|
11
11
|
import { checkFilePathShape, checkToolWritable, clip, display, inToolSandbox, sandboxConversationOf, sandboxUnusableReason, withNotices, withPathLease, } from "../sandbox/common.js";
|
|
@@ -329,8 +329,8 @@ async function resolveReferences(deps, ctx, ids) {
|
|
|
329
329
|
return out;
|
|
330
330
|
}
|
|
331
331
|
/**
|
|
332
|
-
* Runs the prepared call
|
|
333
|
-
* denial
|
|
332
|
+
* Runs the prepared call through model policy. Conversation identity is included when available.
|
|
333
|
+
* A denial writes `hook_denied` with its audit row and becomes the denial tool error.
|
|
334
334
|
*/
|
|
335
335
|
async function generate(deps, ctx, prepared) {
|
|
336
336
|
const runId = ctx.runId ?? "";
|
|
@@ -347,21 +347,13 @@ async function generate(deps, ctx, prepared) {
|
|
|
347
347
|
try {
|
|
348
348
|
return await deps.images.run(ctx.orgId, prepared, {
|
|
349
349
|
kind: "conversation",
|
|
350
|
-
|
|
351
|
-
scope: scope ?? {
|
|
352
|
-
orgId: ctx.orgId,
|
|
353
|
-
accountId: ctx.accountId,
|
|
354
|
-
agentId: ctx.agentId,
|
|
355
|
-
agentVersion: ctx.agentVersion ?? 1,
|
|
356
|
-
conversationId: ctx.conversationId,
|
|
357
|
-
runId,
|
|
358
|
-
},
|
|
350
|
+
scope,
|
|
359
351
|
step: ctx.step ?? 0,
|
|
360
352
|
callId: ctx.callId,
|
|
361
|
-
}, ctx.signal,
|
|
353
|
+
}, ctx.signal, deps.hooks);
|
|
362
354
|
}
|
|
363
355
|
catch (e) {
|
|
364
|
-
if (e instanceof
|
|
356
|
+
if (e instanceof ModelRequestDenied) {
|
|
365
357
|
await recordDenial(deps, ctx, runId, e.verdict);
|
|
366
358
|
throw new ToolError(GENERATE_IMAGE_DENIED_TEXT);
|
|
367
359
|
}
|
|
@@ -254,8 +254,6 @@ export declare const PLATFORM_OUTSIDE_SANDBOX_OFF_TOOL_TEXT = "Running commands
|
|
|
254
254
|
* The device does not allow running outside the sandbox (`device.outside_sandbox_not_allowed`).
|
|
255
255
|
*/
|
|
256
256
|
export declare const OUTSIDE_SANDBOX_CEILING_TOOL_TEXT = "This device does not allow running commands outside the sandbox, so nothing ran. Run the command inside the sandbox, or ask the device's owner whether its provider can allow it.";
|
|
257
|
-
export declare const RETIREMENT_PENDING_TOOL_TEXT = "This device is unavailable: background work started by an earlier version may still run on its previous instance, which has not been confirmed destroyed yet, so nothing ran. Retry later (a cloud device becomes usable once its provider confirms the old instance destroyed), continue without the device, or ask the user to start a new conversation on another device. Attachments and artifacts of this conversation can still be read without the device: if Read is available to you, Read with file_id.";
|
|
258
|
-
export declare const RETIREMENT_RECREATE_TOOL_TEXT = "Background work started by an earlier version may still be running on an earlier instance of this device, which can no longer be verified as destroyed, so nothing ran. Ask the device's owner to delete the device and create it again, or ask the user to start a new conversation on another device. Attachments and artifacts of this conversation can still be read without the device: if Read is available to you, Read with file_id.";
|
|
259
257
|
/**
|
|
260
258
|
* A managed operation outside the admitted scope (`SandboxScopeDeniedError`): fixed text, never
|
|
261
259
|
* the refusal's own message (a provider may write it).
|
|
@@ -9,7 +9,7 @@ import { MANAGED_DEVICE_CONTEXT_FAILED_TEXT, MANAGED_DEVICE_CONTEXT_STALE_TEXT,
|
|
|
9
9
|
import { isEscalationGrantMissing } from "../../../sandbox/operation-authority-types.js";
|
|
10
10
|
import { PermissionAdmissionUnavailable, } from "../../../sandbox/permission-availability.js";
|
|
11
11
|
import { isDeviceProgramRestarted } from "../../../sandbox/request-not-sent.js";
|
|
12
|
-
import {
|
|
12
|
+
import { SandboxLockLostError, } from "../../../sandbox/sandbox.service.js";
|
|
13
13
|
import { providerConnectionFailure, SandboxProviderUnreachableError, } from "../../../sandbox/unreachable.js";
|
|
14
14
|
import { assertDeviceOfRunAccount } from "./device-owner.js";
|
|
15
15
|
// ---- 模型可见文案(英文) ----
|
|
@@ -271,25 +271,6 @@ export const PLATFORM_OUTSIDE_SANDBOX_OFF_TOOL_TEXT = "Running commands outside
|
|
|
271
271
|
* The device does not allow running outside the sandbox (`device.outside_sandbox_not_allowed`).
|
|
272
272
|
*/
|
|
273
273
|
export const OUTSIDE_SANDBOX_CEILING_TOOL_TEXT = "This device does not allow running commands outside the sandbox, so nothing ran. Run the command inside the sandbox, or ask the device's owner whether its provider can allow it.";
|
|
274
|
-
/**
|
|
275
|
-
* The legacy retirement gate's refusals (`RetirementPendingError`, permission runtime cutover
|
|
276
|
-
* 8.5): the device's earlier instance may still run background work an earlier version started.
|
|
277
|
-
* Each says what clears it; the generic `device.unavailable` text would name an inactive provider.
|
|
278
|
-
*/
|
|
279
|
-
/** What still works without the device: attachments and artifacts are read from file storage. */
|
|
280
|
-
const READ_BY_ID_HINT = "Attachments and artifacts of this conversation can still be read without the device: if Read is available to you, Read with file_id.";
|
|
281
|
-
export const RETIREMENT_PENDING_TOOL_TEXT = `This device is unavailable: background work started by an earlier version may still run on its previous instance, which has not been confirmed destroyed yet, so nothing ran. Retry later (a cloud device becomes usable once its provider confirms the old instance destroyed), continue without the device, or ask the user to start a new conversation on another device. ${READ_BY_ID_HINT}`;
|
|
282
|
-
export const RETIREMENT_RECREATE_TOOL_TEXT = `Background work started by an earlier version may still be running on an earlier instance of this device, which can no longer be verified as destroyed, so nothing ran. Ask the device's owner to delete the device and create it again, or ask the user to start a new conversation on another device. ${READ_BY_ID_HINT}`;
|
|
283
|
-
const RETIREMENT_LOCAL_TOOL_TEXT = `Earlier background work on this device's connected machine has not been confirmed stopped, so nothing ran. Ask the device's owner to open the device page and choose Check again, or use another device. ${READ_BY_ID_HINT}`;
|
|
284
|
-
/** The model-facing text of a retirement refusal. */
|
|
285
|
-
function retirementToolText(error) {
|
|
286
|
-
if (error.code !== "device.recreate_required")
|
|
287
|
-
return RETIREMENT_PENDING_TOOL_TEXT;
|
|
288
|
-
const reason = error.details?.[0]?.reason;
|
|
289
|
-
if (reason === "local_retirement")
|
|
290
|
-
return RETIREMENT_LOCAL_TOOL_TEXT;
|
|
291
|
-
return RETIREMENT_RECREATE_TOOL_TEXT;
|
|
292
|
-
}
|
|
293
274
|
/**
|
|
294
275
|
* A managed operation outside the admitted scope (`SandboxScopeDeniedError`): fixed text, never
|
|
295
276
|
* the refusal's own message (a provider may write it).
|
|
@@ -335,7 +316,6 @@ export const OUTCOME_UNKNOWN_TOOL_TEXT = "The device may or may not have run thi
|
|
|
335
316
|
* error is logged to `log` as a warning (the pipeline logs only errors it did not get as a
|
|
336
317
|
* `ToolError`).
|
|
337
318
|
*/
|
|
338
|
-
const RECONCILE_REQUIRED_TEXT = "This device's sandbox limits must be established again before it runs anything, so nothing ran. Ask the person to reset the device's files on the devices page, then retry, or to start a new conversation on another device.";
|
|
339
319
|
/** The provider connection failure behind an unknown outcome, with the raw error to log. */
|
|
340
320
|
function unreachableCause(cause) {
|
|
341
321
|
if (cause instanceof SandboxProviderUnreachableError)
|
|
@@ -418,9 +398,6 @@ export function mapSandboxError(e, log) {
|
|
|
418
398
|
}
|
|
419
399
|
return new ToolError(SANDBOX_CONNECTION_DROPPED_TEXT, { kind: "unavailable" });
|
|
420
400
|
}
|
|
421
|
-
if (e instanceof RetirementPendingError) {
|
|
422
|
-
return new ToolError(retirementToolText(e));
|
|
423
|
-
}
|
|
424
401
|
if (e instanceof ApiError) {
|
|
425
402
|
if (e.code === "sandbox.busy")
|
|
426
403
|
return new ToolError(BUSY_TEXT);
|
|
@@ -454,9 +431,6 @@ export function mapSandboxError(e, log) {
|
|
|
454
431
|
return new ToolError(ORG_OUTSIDE_SANDBOX_OFF_TOOL_TEXT);
|
|
455
432
|
if (e.code === "deployment.outside_sandbox_not_allowed")
|
|
456
433
|
return new ToolError(PLATFORM_OUTSIDE_SANDBOX_OFF_TOOL_TEXT);
|
|
457
|
-
if (e.code === "device.permission_reconcile_required") {
|
|
458
|
-
return new ToolError(RECONCILE_REQUIRED_TEXT, { kind: "unavailable" });
|
|
459
|
-
}
|
|
460
434
|
if (e.code === "sandbox.open_network_refused") {
|
|
461
435
|
return new ToolError(SANDBOX_OPEN_NETWORK_REFUSED_TEXT);
|
|
462
436
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { formatElapsed, taskReasonText } from "../../../background/render.js";
|
|
2
|
-
import { isManagedTask } from "../../../background/store.js";
|
|
3
2
|
import { clip, display, sandboxBaseTimeoutMs, unavailableWhenNoSandbox, } from "./common.js";
|
|
4
|
-
import {
|
|
3
|
+
import { taskEnv } from "./task-output.js";
|
|
5
4
|
/** How many finished background tasks (and finished sub-agents) `TaskList` lists at most. */
|
|
6
5
|
export const TASK_LIST_FINISHED_LIMIT = 20;
|
|
7
6
|
const SPEC = {
|
|
@@ -44,14 +43,15 @@ function taskState(task, now) {
|
|
|
44
43
|
return `${s}, after ${elapsed}`;
|
|
45
44
|
}
|
|
46
45
|
function taskEntry(task, now) {
|
|
47
|
-
|
|
48
|
-
?
|
|
49
|
-
:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
const output = task.executionRef !== null
|
|
47
|
+
? task.outputPath
|
|
48
|
+
: task.status === "running"
|
|
49
|
+
? "none yet (the task is still starting)"
|
|
50
|
+
: task.lostReason === "stop_unconfirmed"
|
|
51
|
+
? "unavailable (final state unknown)"
|
|
52
|
+
: task.lostReason === "stop_confirmed"
|
|
53
|
+
? "unavailable (command ended)"
|
|
54
|
+
: "none (not started)";
|
|
55
55
|
return `- ${task.id} ${taskState(task, now)}: ${JSON.stringify(task.description)}\n Output: ${output}`;
|
|
56
56
|
}
|
|
57
57
|
const ACTIVE_AGENT = new Set(["queued", "running", "waiting"]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { BackgroundTaskRow } from "../../../background/store.js";
|
|
2
|
+
import type { IfRunningResult, SandboxService } from "../../../sandbox/sandbox.service.js";
|
|
3
3
|
import type { BuiltinCallContext, BuiltinTool } from "../../registry.js";
|
|
4
4
|
import { type SandboxToolDeps } from "./common.js";
|
|
5
5
|
/** How long `TaskOutput` waits with `block` when `timeout` is not given (ms). */
|
|
@@ -45,8 +45,6 @@ export declare function recheckDevice(env: TaskEnv, ctx: BuiltinCallContext): Pr
|
|
|
45
45
|
* `Status: stopped after 1m00s`, `Status: lost (the sandbox was suspended) after 3s`.
|
|
46
46
|
*/
|
|
47
47
|
export declare function statusLine(task: BackgroundTaskRow, now?: Date): string;
|
|
48
|
-
/** The absolute path of the task's output file, as the model sees it. */
|
|
49
|
-
export declare const outputFile: (task: BackgroundTaskRow) => string;
|
|
50
48
|
/** Why the output cannot be read: the task's sandbox instance is not running. */
|
|
51
49
|
export declare function unavailableText(task: BackgroundTaskRow, r: IfRunningResult<unknown>): string;
|
|
52
50
|
/**
|
|
@@ -57,11 +55,6 @@ export declare function unavailableText(task: BackgroundTaskRow, r: IfRunningRes
|
|
|
57
55
|
* unavailable). With `block`, checks every {@link TASK_CHECK_INTERVAL_MS}, each under a lease of
|
|
58
56
|
* its own, until the task ends or the wait (at most `timeout` and the run's time left) is over.
|
|
59
57
|
* The output read is capped at `tools.outputSpillChars` bytes; the pipeline spills the result
|
|
60
|
-
* beyond that.
|
|
58
|
+
* beyond that.
|
|
61
59
|
*/
|
|
62
60
|
export declare function taskOutputTool(deps: SandboxToolDeps): BuiltinTool;
|
|
63
|
-
/**
|
|
64
|
-
* The retirement gate's refusal as the tool's error (the generic `device.unavailable` text would
|
|
65
|
-
* name an inactive provider); anything else mapped as usual.
|
|
66
|
-
*/
|
|
67
|
-
export declare function retirementRefusal(e: unknown, env: Pick<TaskEnv, "log">): unknown;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
2
2
|
import { isSandboxGoneError, ToolError } from "@capybara-hq/plugin-sdk";
|
|
3
3
|
import { finishedEventKey } from "../../../background/finish.js";
|
|
4
|
-
import { TASK_ID_RE
|
|
4
|
+
import { TASK_ID_RE } from "../../../background/launch.js";
|
|
5
5
|
import { exactRefOf, lastLinesByRef, ManagedRefError, onManagedInstance, readerOf, statusEnd, summaryLines, } from "../../../background/managed.js";
|
|
6
6
|
import { assembleTaskOutput, ManagedOutputCapacityError, ManagedOutputUnavailableError, } from "../../../background/managed-output.js";
|
|
7
7
|
import { formatElapsed, taskReasonText } from "../../../background/render.js";
|
|
8
8
|
import { notRunningAs, RECREATED } from "../../../background/stop.js";
|
|
9
|
-
import { isManagedTask } from "../../../background/store.js";
|
|
10
|
-
import { RetirementPendingError, retirementPending, } from "../../../sandbox/sandbox.service.js";
|
|
11
9
|
import { clip, display, mapSandboxError, runTimeLeftMs, sandboxBaseTimeoutMs, sandboxConversationOf, sandboxUnusableError, unavailableWhenNoSandbox, } from "./common.js";
|
|
12
10
|
import { parseDeviceCode } from "./device-code.js";
|
|
13
11
|
import { assertDeviceOfRunAccount } from "./device-owner.js";
|
|
@@ -140,12 +138,10 @@ export function statusLine(task, now = new Date()) {
|
|
|
140
138
|
return `${s}, exit code ${task.exitCode}, after ${elapsed}`;
|
|
141
139
|
return `${s} after ${elapsed}`;
|
|
142
140
|
}
|
|
143
|
-
/** The absolute path of the task's output file, as the model sees it. */
|
|
144
|
-
export const outputFile = (task) => taskOutputFile(task.outputPath);
|
|
145
141
|
/** Why the output cannot be read: the task's sandbox instance is not running. */
|
|
146
142
|
export function unavailableText(task, r) {
|
|
147
143
|
if (r.kind === "not_running" && r.status === "suspended") {
|
|
148
|
-
return `[Output unavailable: the sandbox is suspended. Read ${
|
|
144
|
+
return `[Output unavailable: the sandbox is suspended. Read ${task.outputPath} resumes it and reads what the task wrote.]`;
|
|
149
145
|
}
|
|
150
146
|
return "[Output unavailable: the sandbox that ran this task is gone, and its output with it.]";
|
|
151
147
|
}
|
|
@@ -168,7 +164,7 @@ async function settle(env, task, end) {
|
|
|
168
164
|
* unavailable). With `block`, checks every {@link TASK_CHECK_INTERVAL_MS}, each under a lease of
|
|
169
165
|
* its own, until the task ends or the wait (at most `timeout` and the run's time left) is over.
|
|
170
166
|
* The output read is capped at `tools.outputSpillChars` bytes; the pipeline spills the result
|
|
171
|
-
* beyond that.
|
|
167
|
+
* beyond that.
|
|
172
168
|
*/
|
|
173
169
|
export function taskOutputTool(deps) {
|
|
174
170
|
return {
|
|
@@ -200,86 +196,14 @@ export function taskOutputTool(deps) {
|
|
|
200
196
|
}
|
|
201
197
|
const task = await ownedTask(env, ctx, task_id);
|
|
202
198
|
await recheckDevice(env, ctx);
|
|
203
|
-
|
|
204
|
-
return managedTaskOutput(deps, env, ctx, task, block, timeout);
|
|
205
|
-
return legacyTaskOutput(deps, env, task);
|
|
199
|
+
return managedTaskOutput(deps, env, ctx, task, block, timeout);
|
|
206
200
|
},
|
|
207
201
|
};
|
|
208
202
|
}
|
|
209
|
-
/**
|
|
210
|
-
* A legacy task's own instance, never signalled or read (as `BackgroundTaskStopper` checks it):
|
|
211
|
-
* a running one refuses with the retirement gate's own text before any provider call; one that is
|
|
212
|
-
* not running or was replaced is returned. A task from before devices has none.
|
|
213
|
-
*/
|
|
214
|
-
async function legacyInstance(env, task) {
|
|
215
|
-
if (task.deviceId === null || task.sandboxCreatedAt === null)
|
|
216
|
-
return { kind: "not_running", status: "gone" };
|
|
217
|
-
let r;
|
|
218
|
-
try {
|
|
219
|
-
r = await env.ifRunning(task.deviceId, { createdAt: task.sandboxCreatedAt }, async () => {
|
|
220
|
-
throw retirementPending();
|
|
221
|
-
}, AbortSignal.timeout(30_000));
|
|
222
|
-
}
|
|
223
|
-
catch (e) {
|
|
224
|
-
throw retirementRefusal(e, env);
|
|
225
|
-
}
|
|
226
|
-
if (r.kind === "ran")
|
|
227
|
-
throw retirementRefusal(retirementPending(), env);
|
|
228
|
-
return r;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* The retirement gate's refusal as the tool's error (the generic `device.unavailable` text would
|
|
232
|
-
* name an inactive provider); anything else mapped as usual.
|
|
233
|
-
*/
|
|
234
|
-
export function retirementRefusal(e, env) {
|
|
235
|
-
if (e instanceof RetirementPendingError) {
|
|
236
|
-
return new ToolError("This task's device is unavailable: background work started by an earlier version may still run on its previous instance, which has not been confirmed destroyed yet (for a local device, restarting its computer confirms it). The task cannot be read or stopped until then; continue without it, or start the work again with Bash on another device.");
|
|
237
|
-
}
|
|
238
|
-
return mapSandboxError(e, env.log);
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* `TaskOutput` of a legacy (SID) task: never read by an exec (permission activation W5-P2). A
|
|
242
|
-
* running one whose instance still runs belongs to the retirement gate, so the call is refused
|
|
243
|
-
* with its actionable text; one whose instance is gone, suspended or replaced is settled lost; a
|
|
244
|
-
* finished one answers with its status and the last lines its finish kept.
|
|
245
|
-
*/
|
|
246
|
-
async function legacyTaskOutput(deps, env, task) {
|
|
247
|
-
if (task.sandboxCreatedAt === null) {
|
|
248
|
-
// a reservation that never started: nothing ran
|
|
249
|
-
return result(task, [
|
|
250
|
-
statusLine(task),
|
|
251
|
-
task.status === "running"
|
|
252
|
-
? "[The task is still starting; no output yet.]"
|
|
253
|
-
: "[No output: the command never started.]",
|
|
254
|
-
]);
|
|
255
|
-
}
|
|
256
|
-
if (task.status === "running") {
|
|
257
|
-
// the instance first: only a running one belongs to the retirement gate; a gone, suspended
|
|
258
|
-
// or replaced one settles the task lost (its processes went with it, or wait for retirement)
|
|
259
|
-
const seen = await legacyInstance(env, task);
|
|
260
|
-
const end = {
|
|
261
|
-
to: seen.kind === "not_running"
|
|
262
|
-
? notRunningAs(seen.status, seen.status === "suspended")
|
|
263
|
-
: RECREATED,
|
|
264
|
-
lastLines: "",
|
|
265
|
-
};
|
|
266
|
-
const after = await settle(env, task, end);
|
|
267
|
-
return result(after, [statusLine(after), unavailableText(after, seen)]);
|
|
268
|
-
}
|
|
269
|
-
const lines = [
|
|
270
|
-
statusLine(task),
|
|
271
|
-
"[Output unavailable: this task was started by an earlier version of the device runtime, whose output is not read live.]",
|
|
272
|
-
];
|
|
273
|
-
const summary = await finishSummary(deps, task);
|
|
274
|
-
if (summary !== null) {
|
|
275
|
-
lines.push(`Last lines recorded when the task finished (not new output):\n${summary}`);
|
|
276
|
-
}
|
|
277
|
-
return result(task, lines);
|
|
278
|
-
}
|
|
279
203
|
/** A managed task's ref or provider failure as the tool's error (never a fallback read). */
|
|
280
204
|
function managedReadError(env, task, e) {
|
|
281
205
|
if (e instanceof ManagedRefError) {
|
|
282
|
-
return new ToolError(`Background task ${task.id}'s recorded execution reference is malformed or inconsistent, so its output cannot be read; call TaskList to see its status, or Read ${
|
|
206
|
+
return new ToolError(`Background task ${task.id}'s recorded execution reference is malformed or inconsistent, so its output cannot be read; call TaskList to see its status, or Read ${task.outputPath}.`);
|
|
283
207
|
}
|
|
284
208
|
if (e instanceof ManagedOutputCapacityError) {
|
|
285
209
|
return new ToolError(`Background task ${task.id}'s output could not be read: ${e.message}.`);
|
|
@@ -321,6 +245,12 @@ async function managedTaskOutput(deps, env, ctx, first, block, timeout) {
|
|
|
321
245
|
? "[No output: the task was stopped while it was starting.]"
|
|
322
246
|
: "[The task is still starting; no output yet.]";
|
|
323
247
|
}
|
|
248
|
+
else if (task.lostReason === "stop_unconfirmed") {
|
|
249
|
+
why = "[No output: the device did not confirm the command's final state.]";
|
|
250
|
+
}
|
|
251
|
+
else if (task.lostReason === "stop_confirmed") {
|
|
252
|
+
why = "[No output: the device confirmed the command ended.]";
|
|
253
|
+
}
|
|
324
254
|
else if (task.lostReason === "launch_unknown") {
|
|
325
255
|
why = "[No output: whether the command started could not be confirmed.]";
|
|
326
256
|
}
|
|
@@ -411,7 +341,7 @@ async function managedTaskOutput(deps, env, ctx, first, block, timeout) {
|
|
|
411
341
|
}
|
|
412
342
|
if (seen.kind !== "ran") {
|
|
413
343
|
if (task.status === "running") {
|
|
414
|
-
const to = seen.kind === "not_running" ? notRunningAs(seen.status
|
|
344
|
+
const to = seen.kind === "not_running" ? notRunningAs(seen.status) : RECREATED;
|
|
415
345
|
task = await settleEnd(task, { to, lastLines: "" });
|
|
416
346
|
}
|
|
417
347
|
return result(task, [statusLine(task), unavailableText(task, seen)]);
|
|
@@ -432,7 +362,7 @@ async function managedTaskOutput(deps, env, ctx, first, block, timeout) {
|
|
|
432
362
|
task = await settleEnd(task, end === null ? null : { to: end, lastLines });
|
|
433
363
|
const parts = [];
|
|
434
364
|
if (read.remaining > 0) {
|
|
435
|
-
parts.push(`[${read.remaining} more bytes of output after this; call TaskOutput again to read them, or Read ${
|
|
365
|
+
parts.push(`[${read.remaining} more bytes of output after this; call TaskOutput again to read them, or Read ${task.outputPath}.]`);
|
|
436
366
|
}
|
|
437
367
|
parts.push(used === 0 ? "[No new output.]" : read.text);
|
|
438
368
|
// the parser sees the re-read history plus the new bytes, so a prompt split across reads matches
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ToolError } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { LAST_LINES_UNAVAILABLE, lastLinesByRef, onManagedInstance, } from "../../../background/managed.js";
|
|
3
|
-
import { isManagedTask } from "../../../background/store.js";
|
|
4
3
|
import { clip, display, mapSandboxError, sandboxBaseTimeoutMs, unavailableWhenNoSandbox, } from "./common.js";
|
|
5
4
|
import { assertDeviceOfRunAccount } from "./device-owner.js";
|
|
6
|
-
import { ownedTask, recheckDevice,
|
|
5
|
+
import { ownedTask, recheckDevice, statusLine, taskEnv } from "./task-output.js";
|
|
7
6
|
const SPEC = {
|
|
8
7
|
name: "TaskStop",
|
|
9
8
|
// Display only (the tool row; not in the fingerprint, never sent to the model).
|
|
@@ -32,29 +31,29 @@ const SPEC = {
|
|
|
32
31
|
async function lastLinesOf(env, task, signal) {
|
|
33
32
|
if (task.sandboxCreatedAt === null)
|
|
34
33
|
return null;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
// by the exact ref only: never an exec or a file read after a stop
|
|
35
|
+
if (task.executionRef === null)
|
|
36
|
+
return null;
|
|
37
|
+
try {
|
|
38
|
+
const r = await onManagedInstance(env.ifRunning, task, (bg, h, ref, sig) => lastLinesByRef(bg, h, ref, sig), signal);
|
|
39
|
+
if (r.kind !== "ran")
|
|
38
40
|
return null;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return r.value ?? LAST_LINES_UNAVAILABLE;
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
return LAST_LINES_UNAVAILABLE;
|
|
48
|
-
}
|
|
41
|
+
// retained output that cannot be read is labelled, never shown as no output
|
|
42
|
+
return r.value ?? LAST_LINES_UNAVAILABLE;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return LAST_LINES_UNAVAILABLE;
|
|
49
46
|
}
|
|
50
|
-
// a legacy (SID) task's output is never read by an exec: its lines are labelled unavailable
|
|
51
|
-
return LAST_LINES_UNAVAILABLE;
|
|
52
47
|
}
|
|
53
48
|
/** The result text: what happened, the status line and the last lines. */
|
|
54
49
|
async function ended(env, task, what, signal) {
|
|
55
50
|
const lines = await lastLinesOf(env, task, signal);
|
|
56
51
|
const tail = task.sandboxCreatedAt === null
|
|
57
|
-
?
|
|
52
|
+
? task.lostReason === "stop_unconfirmed"
|
|
53
|
+
? "[No output: the device did not confirm the command's final state.]"
|
|
54
|
+
: task.lostReason === "stop_confirmed"
|
|
55
|
+
? "[No output: the device confirmed the command ended.]"
|
|
56
|
+
: "[No output: the command never started.]"
|
|
58
57
|
: lines === null
|
|
59
58
|
? "[Last lines unavailable: the sandbox that ran this task is not running.]"
|
|
60
59
|
: lines === LAST_LINES_UNAVAILABLE
|
|
@@ -116,10 +115,7 @@ export function taskStopTool(deps) {
|
|
|
116
115
|
after = await env.tasks.stopper.stop(task, "tool", ctx.signal);
|
|
117
116
|
}
|
|
118
117
|
catch (e) {
|
|
119
|
-
|
|
120
|
-
// running legacy task's retirement refusal, in its own words, a malformed recorded ref or
|
|
121
|
-
// a failed write that recorded nothing
|
|
122
|
-
const mapped = retirementRefusal(e, env);
|
|
118
|
+
const mapped = mapSandboxError(e, env.log);
|
|
123
119
|
if (mapped instanceof ToolError)
|
|
124
120
|
throw mapped;
|
|
125
121
|
const why = e instanceof Error ? e.message : String(e);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IMAGE_MEDIA_TYPES, isModelError, ToolError, } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { ApiError } from "../../../errors.js";
|
|
3
3
|
import { PurposeAttemptError } from "../../../models/purposes.js";
|
|
4
|
-
import { fireObserve, hookDeniedAudit, hookDeniedEvent,
|
|
4
|
+
import { fireObserve, hookDeniedAudit, hookDeniedEvent, hookScope, } from "../../../runtime/hook-calls.js";
|
|
5
5
|
import { appendCounted } from "../../../runtime/model-call.js";
|
|
6
6
|
/**
|
|
7
7
|
* The vision read (vision read spec §2.3): an image read for a model that cannot view images goes
|
|
@@ -93,15 +93,14 @@ export async function readImageWithVisionModel(deps, ctx, img) {
|
|
|
93
93
|
toolChoice: "none",
|
|
94
94
|
maxOutputTokens: visionMaxOutputTokens,
|
|
95
95
|
}, signal, {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
96
|
+
hooks: deps.hooks,
|
|
97
|
+
scope,
|
|
98
|
+
step,
|
|
99
|
+
onDenied: async (verdict) => {
|
|
100
|
+
await recordDenial(deps, ctx, runId, step, verdict);
|
|
101
|
+
throw new VisionDenied();
|
|
102
|
+
},
|
|
103
|
+
beforeSend: async (target) => {
|
|
105
104
|
sent = { ...target, at: Date.now() };
|
|
106
105
|
},
|
|
107
106
|
});
|
|
@@ -2,7 +2,7 @@ import { randomBytes } from "node:crypto";
|
|
|
2
2
|
import { isModelError, ToolError, } from "@capybara-hq/plugin-sdk";
|
|
3
3
|
import { PurposeAttemptError } from "../../../models/purposes.js";
|
|
4
4
|
import { estimateTokens } from "../../../runtime/context/tokens.js";
|
|
5
|
-
import { fireObserve, hookDeniedAudit, hookDeniedEvent,
|
|
5
|
+
import { fireObserve, hookDeniedAudit, hookDeniedEvent, hookScope, } from "../../../runtime/hook-calls.js";
|
|
6
6
|
import { appendCounted } from "../../../runtime/model-call.js";
|
|
7
7
|
import { TRUNCATED_MARKER } from "./fetch.js";
|
|
8
8
|
/**
|
|
@@ -146,15 +146,14 @@ export async function extractAnswer(deps, ctx, page, prompt) {
|
|
|
146
146
|
maxOutputTokens: maxAnswerTokens,
|
|
147
147
|
}, ctx.signal, {
|
|
148
148
|
...target,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
149
|
+
hooks: deps.hooks,
|
|
150
|
+
scope,
|
|
151
|
+
step,
|
|
152
|
+
onDenied: async (verdict) => {
|
|
153
|
+
await recordDenial(deps, ctx, runId, step, verdict);
|
|
154
|
+
throw new ExtractionDenied();
|
|
155
|
+
},
|
|
156
|
+
beforeSend: async (target) => {
|
|
158
157
|
sent = { ...target, at: Date.now() };
|
|
159
158
|
},
|
|
160
159
|
});
|
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.123",
|
|
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.96"
|
|
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.52"
|
|
79
79
|
},
|
|
80
80
|
"scripts": {
|
|
81
81
|
"build": "tsc -b"
|