@capybara-hq/kernel 0.1.0-rc.11 → 0.1.0-rc.13
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/admin.schemas.d.ts +13 -0
- package/dist/agents/agent-lookup.d.ts +5 -0
- package/dist/agents/agent-lookup.js +15 -0
- package/dist/agents/agents.schemas.d.ts +3 -0
- package/dist/agents/agents.service.js +11 -1
- package/dist/agents/definition.d.ts +1 -0
- package/dist/agents/definition.js +7 -3
- package/dist/agents/org-templates.js +4 -0
- package/dist/agents/pending-connectors.service.js +1 -1
- package/dist/background/background.module.js +2 -2
- package/dist/background/launch-lock.d.ts +1 -1
- package/dist/background/launch-lock.js +1 -1
- package/dist/background/poll.job.d.ts +2 -2
- package/dist/background/poll.job.js +10 -10
- package/dist/background/stop.d.ts +1 -1
- package/dist/background/stop.js +3 -3
- package/dist/background/store.d.ts +5 -5
- package/dist/background/store.js +5 -5
- package/dist/background/tasks.service.d.ts +6 -6
- package/dist/background/tasks.service.js +13 -13
- package/dist/catalog/component-scope.controller.d.ts +18 -6
- package/dist/catalog/component-scope.controller.js +36 -13
- package/dist/catalog/component-scope.service.d.ts +11 -0
- package/dist/catalog/component-scope.service.js +4 -0
- package/dist/catalog/component-state.d.ts +8 -0
- package/dist/catalog/component-state.js +19 -11
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/plugin-import.js +4 -1
- package/dist/channels/channels.module.js +2 -2
- package/dist/channels/inbound.d.ts +8 -8
- package/dist/channels/inbound.js +31 -31
- package/dist/channels/phrases.d.ts +27 -27
- package/dist/channels/phrases.js +27 -27
- package/dist/config/docs.js +1 -1
- package/dist/config/schema.d.ts +2 -2
- package/dist/config/schema.js +21 -21
- package/dist/conversations/conversations.controller.d.ts +11 -11
- package/dist/conversations/conversations.controller.js +15 -15
- package/dist/conversations/conversations.module.d.ts +1 -1
- package/dist/conversations/conversations.module.js +7 -7
- package/dist/conversations/conversations.schemas.js +1 -1
- package/dist/conversations/conversations.service.d.ts +23 -14
- package/dist/conversations/conversations.service.js +28 -21
- package/dist/conversations/{environment-status.d.ts → device-status.d.ts} +9 -9
- package/dist/conversations/{environment-status.js → device-status.js} +18 -18
- package/dist/conversations/event-log.d.ts +1 -1
- package/dist/conversations/event-log.js +1 -1
- package/dist/conversations/events.d.ts +2 -1
- package/dist/conversations/events.js +2 -2
- package/dist/ctx/create-ctx.d.ts +10 -1
- package/dist/ctx/create-ctx.js +86 -25
- package/dist/db/kernel-schema.d.ts +39 -23
- package/dist/{environments → devices}/access.d.ts +19 -19
- package/dist/{environments → devices}/access.js +28 -28
- package/dist/devices/conversation-devices.d.ts +75 -0
- package/dist/{environments/conversation-environments.js → devices/conversation-devices.js} +71 -72
- package/dist/devices/devices.controller.d.ts +36 -0
- package/dist/{environments/environments.controller.js → devices/devices.controller.js} +37 -37
- package/dist/devices/devices.module.d.ts +5 -13
- package/dist/devices/devices.module.js +16 -29
- package/dist/devices/devices.schemas.d.ts +3 -0
- package/dist/devices/devices.schemas.js +14 -0
- package/dist/{environments/environments.service.d.ts → devices/devices.service.d.ts} +70 -70
- package/dist/{environments/environments.service.js → devices/devices.service.js} +122 -122
- package/dist/devices/dto.d.ts +13 -54
- package/dist/devices/dto.js +7 -39
- package/dist/devices/label.d.ts +11 -0
- package/dist/{environments → devices}/label.js +7 -7
- package/dist/{environments → devices}/legacy-cleanup.job.d.ts +3 -3
- package/dist/{environments → devices}/legacy-cleanup.job.js +3 -3
- package/dist/errors.d.ts +27 -25
- package/dist/errors.js +27 -25
- package/dist/evals/recorded-tools.d.ts +2 -2
- package/dist/evals/recorded-tools.js +6 -6
- package/dist/extensions/admin-ops.js +1 -0
- package/dist/extensions/admin-view.js +2 -0
- package/dist/extensions/effective-config.d.ts +6 -0
- package/dist/extensions/effective-config.js +18 -7
- package/dist/extensions/host.d.ts +13 -2
- package/dist/extensions/host.js +24 -3
- package/dist/extensions/instance.d.ts +12 -1
- package/dist/extensions/instance.js +13 -0
- package/dist/extensions/permission-view.d.ts +10 -1
- package/dist/files/previewers.d.ts +1 -1
- package/dist/files/previewers.js +1 -1
- package/dist/http/api.module.js +10 -6
- package/dist/http/gateway-routes.d.ts +1 -1
- package/dist/http/gateway-routes.js +1 -1
- package/dist/identity/settings.d.ts +32 -0
- package/dist/identity/settings.js +26 -2
- package/dist/infra/config/kernel-config.service.js +4 -4
- package/dist/kernel.module.js +3 -3
- package/dist/{devices → local-devices}/device-auth.controller.d.ts +6 -6
- package/dist/{devices → local-devices}/device-auth.controller.js +5 -5
- package/dist/{devices → local-devices}/device-auth.d.ts +20 -20
- package/dist/{devices → local-devices}/device-auth.js +51 -53
- package/dist/local-devices/device-auth.module.d.ts +7 -0
- package/dist/{devices → local-devices}/device-auth.module.js +5 -5
- package/dist/{devices → local-devices}/device-routes.d.ts +3 -3
- package/dist/{devices → local-devices}/device-routes.js +2 -2
- package/dist/local-devices/dto.d.ts +66 -0
- package/dist/local-devices/dto.js +44 -0
- package/dist/{devices → local-devices}/keys.d.ts +11 -11
- package/dist/{devices → local-devices}/keys.js +11 -11
- package/dist/{devices/device-gateway.d.ts → local-devices/local-device-gateway.d.ts} +14 -14
- package/dist/{devices/device-gateway.js → local-devices/local-device-gateway.js} +44 -44
- package/dist/{devices/device-provider.d.ts → local-devices/local-device-provider.d.ts} +15 -15
- package/dist/{devices/device-provider.js → local-devices/local-device-provider.js} +23 -23
- package/dist/local-devices/local-devices.module.d.ts +16 -0
- package/dist/local-devices/local-devices.module.js +44 -0
- package/dist/{devices → local-devices}/machines.d.ts +26 -26
- package/dist/{devices → local-devices}/machines.js +71 -71
- package/dist/{devices → local-devices}/relay.d.ts +15 -15
- package/dist/{devices → local-devices}/relay.js +55 -55
- package/dist/{devices → local-devices}/targets.d.ts +8 -8
- package/dist/{devices → local-devices}/targets.js +14 -14
- package/dist/orgs/offboarding.d.ts +6 -6
- package/dist/orgs/offboarding.js +12 -12
- package/dist/orgs/settings.service.d.ts +28 -0
- package/dist/orgs/settings.service.js +20 -1
- package/dist/platform/exclusions.js +48 -3
- package/dist/platform/operation.js +6 -2
- package/dist/platform/ops/admin.ops.js +8 -2
- package/dist/platform/ops/agents.ops.js +19 -6
- package/dist/platform/ops/conversations.ops.d.ts +3 -3
- package/dist/platform/ops/conversations.ops.js +9 -9
- package/dist/platform/ops/devices.ops.d.ts +26 -0
- package/dist/platform/ops/devices.ops.js +311 -0
- package/dist/platform/ops/org-settings.ops.js +2 -2
- package/dist/platform/ops/orgs.ops.js +1 -0
- package/dist/platform/ops/ui.ops.d.ts +8 -0
- package/dist/platform/ops/ui.ops.js +41 -0
- package/dist/platform/platform-ops.module.d.ts +3 -2
- package/dist/platform/platform-ops.module.js +8 -5
- package/dist/platform/route-schemas.js +6 -3
- package/dist/roles/gateway-role.d.ts +3 -3
- package/dist/roles/gateway-role.js +4 -4
- package/dist/roles/gateway.module.d.ts +1 -1
- package/dist/roles/gateway.module.js +5 -5
- package/dist/roles/worker.module.js +1 -1
- package/dist/runtime/context/build.d.ts +1 -1
- package/dist/runtime/context/build.js +6 -6
- package/dist/runtime/context/compaction.js +1 -1
- package/dist/runtime/context/{environment-paths.d.ts → device-paths.d.ts} +11 -11
- package/dist/runtime/context/{environment-paths.js → device-paths.js} +13 -13
- package/dist/runtime/maintenance.d.ts +1 -1
- package/dist/runtime/subagents/definition.d.ts +3 -2
- package/dist/runtime/subagents/definition.js +2 -1
- package/dist/sandbox/jobs.d.ts +13 -13
- package/dist/sandbox/jobs.js +20 -20
- package/dist/sandbox/leases.d.ts +9 -9
- package/dist/sandbox/leases.js +14 -14
- package/dist/sandbox/providers.d.ts +8 -8
- package/dist/sandbox/providers.js +8 -8
- package/dist/sandbox/sandbox.module.d.ts +1 -1
- package/dist/sandbox/sandbox.module.js +1 -1
- package/dist/sandbox/sandbox.service.d.ts +76 -76
- package/dist/sandbox/sandbox.service.js +230 -230
- package/dist/tools/builtins/builtin-tools.d.ts +2 -2
- package/dist/tools/builtins/builtin-tools.js +5 -5
- package/dist/tools/builtins/platform.js +1 -1
- package/dist/tools/builtins/sandbox/bash.js +6 -6
- package/dist/tools/builtins/sandbox/common.d.ts +25 -25
- package/dist/tools/builtins/sandbox/common.js +51 -51
- package/dist/tools/builtins/sandbox/edit.js +2 -2
- package/dist/tools/builtins/sandbox/index.d.ts +1 -1
- package/dist/tools/builtins/sandbox/index.js +1 -1
- package/dist/tools/builtins/sandbox/task-output.d.ts +6 -6
- package/dist/tools/builtins/sandbox/task-output.js +10 -10
- package/dist/tools/builtins/sandbox/task-stop.js +2 -2
- package/dist/tools/builtins/sandbox/write.js +2 -2
- package/dist/tools/builtins/skill-load.d.ts +1 -1
- package/dist/tools/builtins/skill-load.js +2 -2
- package/dist/tools/connector-account-policies.d.ts +51 -0
- package/dist/tools/connector-account-policies.js +165 -0
- package/dist/tools/connectors.controller.d.ts +35 -4
- package/dist/tools/connectors.controller.js +66 -7
- package/dist/tools/connectors.schemas.d.ts +11 -0
- package/dist/tools/connectors.schemas.js +11 -0
- package/dist/tools/connectors.service.d.ts +2 -0
- package/dist/tools/connectors.service.js +1 -0
- package/dist/tools/pipeline.d.ts +1 -1
- package/dist/tools/pipeline.js +4 -3
- package/dist/tools/policy.d.ts +23 -1
- package/dist/tools/policy.js +99 -24
- package/dist/tools/registry.d.ts +2 -2
- package/dist/tools/tools.module.js +6 -3
- package/dist/ui/admin-ui.controller.d.ts +56 -0
- package/dist/ui/admin-ui.controller.js +192 -0
- package/dist/ui/arrangement.d.ts +74 -0
- package/dist/ui/arrangement.js +98 -0
- package/dist/ui/embed-token.d.ts +2 -2
- package/dist/ui/embed-token.js +30 -5
- package/dist/ui/registry.d.ts +29 -14
- package/dist/ui/registry.js +31 -10
- package/dist/ui/slots.controller.d.ts +11 -0
- package/dist/ui/slots.controller.js +25 -0
- package/dist/ui/ui-stream.d.ts +20 -3
- package/dist/ui/ui-stream.js +25 -7
- package/dist/ui/ui.schemas.d.ts +66 -0
- package/dist/ui/ui.schemas.js +65 -0
- package/dist/ui/views.controller.d.ts +35 -49
- package/dist/ui/views.controller.js +48 -70
- package/dist/ui/views.d.ts +84 -18
- package/dist/ui/views.js +201 -38
- package/package.json +3 -3
- package/src/migrations/0104_connector_tool_account_policies.sql +16 -0
- package/src/migrations/0105_devices_rename.sql +136 -0
- package/dist/devices/device-auth.module.d.ts +0 -7
- package/dist/environments/conversation-environments.d.ts +0 -75
- package/dist/environments/dto.d.ts +0 -25
- package/dist/environments/dto.js +0 -12
- package/dist/environments/environments.controller.d.ts +0 -36
- package/dist/environments/environments.module.d.ts +0 -8
- package/dist/environments/environments.module.js +0 -31
- package/dist/environments/environments.schemas.d.ts +0 -3
- package/dist/environments/environments.schemas.js +0 -14
- package/dist/environments/label.d.ts +0 -11
- package/dist/platform/ops/environments.ops.d.ts +0 -26
- package/dist/platform/ops/environments.ops.js +0 -311
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
/** An environment's name: trimmed, 1-64 characters (unique per person, case-insensitive). */
|
|
3
|
-
export declare const EnvironmentName: z.ZodString;
|
|
4
|
-
export declare const EnvironmentNameBody: z.ZodObject<{
|
|
5
|
-
name: z.ZodString;
|
|
6
|
-
}, z.core.$strict>;
|
|
7
|
-
export declare const EnvironmentParams: z.ZodObject<{
|
|
8
|
-
id: z.ZodString;
|
|
9
|
-
}, z.core.$strip>;
|
|
10
|
-
declare const EnvironmentCreateBodyDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
11
|
-
name: z.ZodString;
|
|
12
|
-
}, z.core.$strict>>;
|
|
13
|
-
export declare class EnvironmentCreateBodyDto extends EnvironmentCreateBodyDto_base {
|
|
14
|
-
}
|
|
15
|
-
declare const EnvironmentRenameBodyDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
16
|
-
name: z.ZodString;
|
|
17
|
-
}, z.core.$strict>>;
|
|
18
|
-
export declare class EnvironmentRenameBodyDto extends EnvironmentRenameBodyDto_base {
|
|
19
|
-
}
|
|
20
|
-
declare const EnvironmentParamsDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
21
|
-
id: z.ZodString;
|
|
22
|
-
}, z.core.$strip>>;
|
|
23
|
-
export declare class EnvironmentParamsDto extends EnvironmentParamsDto_base {
|
|
24
|
-
}
|
|
25
|
-
export {};
|
package/dist/environments/dto.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
3
|
-
/** An environment's name: trimmed, 1-64 characters (unique per person, case-insensitive). */
|
|
4
|
-
export const EnvironmentName = z.string().trim().min(1).max(64);
|
|
5
|
-
export const EnvironmentNameBody = z.object({ name: EnvironmentName }).strict();
|
|
6
|
-
export const EnvironmentParams = z.object({ id: z.string().min(1).max(100) });
|
|
7
|
-
export class EnvironmentCreateBodyDto extends createZodDto(EnvironmentNameBody, "EnvironmentCreateBody") {
|
|
8
|
-
}
|
|
9
|
-
export class EnvironmentRenameBodyDto extends createZodDto(EnvironmentNameBody, "EnvironmentRenameBody") {
|
|
10
|
-
}
|
|
11
|
-
export class EnvironmentParamsDto extends createZodDto(EnvironmentParams, "EnvironmentParams") {
|
|
12
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { z } from "zod";
|
|
2
|
-
import { type Principal } from "../identity/principal.js";
|
|
3
|
-
import { type OrgContext } from "../orgs/org.guard.js";
|
|
4
|
-
import { type EnvironmentNameBody, type EnvironmentParams } from "./dto.js";
|
|
5
|
-
import { type EnvironmentList, EnvironmentsService, type EnvironmentView } from "./environments.service.js";
|
|
6
|
-
/**
|
|
7
|
-
* A person's environments in an org (`/api/v1/orgs/:orgId/environments`, spec
|
|
8
|
-
* 2026-11-07-environments-design §9; `agents.use`, human users only: a service token gets 403).
|
|
9
|
-
* Phase 1 has personal cloud environments only, each visible to its owner alone: another member
|
|
10
|
-
* gets 404 `environment.not_found`.
|
|
11
|
-
* - `GET /` → `{ items, defaultId, lastUsedId, cloudAvailable }` (`cloudAvailable`: there is a
|
|
12
|
-
* current sandbox provider; ruling R4);
|
|
13
|
-
* - `POST / { name }` → 201 `{ environment }`; `GET /:id`, `PATCH /:id { name }` → `{ environment }`;
|
|
14
|
-
* - `DELETE /:id` → 202 (destroyed by a job after the response);
|
|
15
|
-
* - `POST /:id/files/reset` → 202 (the reset is enqueued: a worker empties the files, the next use
|
|
16
|
-
* starts empty);
|
|
17
|
-
* - `DELETE /:id/machine` → 204: a device environment's machine is disconnected (its credential
|
|
18
|
-
* revoked; it must sign in again).
|
|
19
|
-
*/
|
|
20
|
-
export declare class EnvironmentsController {
|
|
21
|
-
private readonly environments;
|
|
22
|
-
constructor(environments: EnvironmentsService);
|
|
23
|
-
list(principal: Principal, org: OrgContext): Promise<EnvironmentList>;
|
|
24
|
-
create(principal: Principal, org: OrgContext, body: z.infer<typeof EnvironmentNameBody>): Promise<{
|
|
25
|
-
environment: EnvironmentView;
|
|
26
|
-
}>;
|
|
27
|
-
get(principal: Principal, org: OrgContext, params: z.infer<typeof EnvironmentParams>): Promise<{
|
|
28
|
-
environment: EnvironmentView;
|
|
29
|
-
}>;
|
|
30
|
-
rename(principal: Principal, org: OrgContext, params: z.infer<typeof EnvironmentParams>, body: z.infer<typeof EnvironmentNameBody>): Promise<{
|
|
31
|
-
environment: EnvironmentView;
|
|
32
|
-
}>;
|
|
33
|
-
remove(principal: Principal, org: OrgContext, params: z.infer<typeof EnvironmentParams>): Promise<void>;
|
|
34
|
-
resetFiles(principal: Principal, org: OrgContext, params: z.infer<typeof EnvironmentParams>): Promise<void>;
|
|
35
|
-
revokeMachine(principal: Principal, org: OrgContext, params: z.infer<typeof EnvironmentParams>): Promise<void>;
|
|
36
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Environments (spec 2026-11-07-environments-design): a person's environments
|
|
3
|
-
* ({@link EnvironmentsService}), who may use one ({@link EnvironmentAccess}) and the one a
|
|
4
|
-
* conversation works in ({@link ConversationEnvironments}). The instances and file systems are the
|
|
5
|
-
* {@link SandboxModule}'s.
|
|
6
|
-
*/
|
|
7
|
-
export declare class EnvironmentsModule {
|
|
8
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { Module } from "@nestjs/common";
|
|
8
|
-
import { DevicesModule } from "../devices/devices.module.js";
|
|
9
|
-
import { ExtensionsModule } from "../extensions/extensions.module.js";
|
|
10
|
-
import { SandboxModule } from "../sandbox/sandbox.module.js";
|
|
11
|
-
import { EnvironmentAccess } from "./access.js";
|
|
12
|
-
import { ConversationEnvironments } from "./conversation-environments.js";
|
|
13
|
-
import { EnvironmentsService } from "./environments.service.js";
|
|
14
|
-
/**
|
|
15
|
-
* Environments (spec 2026-11-07-environments-design): a person's environments
|
|
16
|
-
* ({@link EnvironmentsService}), who may use one ({@link EnvironmentAccess}) and the one a
|
|
17
|
-
* conversation works in ({@link ConversationEnvironments}). The instances and file systems are the
|
|
18
|
-
* {@link SandboxModule}'s.
|
|
19
|
-
*/
|
|
20
|
-
let EnvironmentsModule = class EnvironmentsModule {
|
|
21
|
-
};
|
|
22
|
-
EnvironmentsModule = __decorate([
|
|
23
|
-
Module({
|
|
24
|
-
// ExtensionsModule: the provider display names of demoted defaults; DevicesModule: deleting a
|
|
25
|
-
// device environment revokes its machine
|
|
26
|
-
imports: [SandboxModule, ExtensionsModule, DevicesModule],
|
|
27
|
-
providers: [EnvironmentAccess, EnvironmentsService, ConversationEnvironments],
|
|
28
|
-
exports: [EnvironmentAccess, EnvironmentsService, ConversationEnvironments],
|
|
29
|
-
})
|
|
30
|
-
], EnvironmentsModule);
|
|
31
|
-
export { EnvironmentsModule };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { EnvironmentNameBody, EnvironmentParams } from "./dto.js";
|
|
2
|
-
/** The environments routes the Platform operations mirror (`check:platform-ops` keys). */
|
|
3
|
-
export const ENVIRONMENT_ROUTES = [
|
|
4
|
-
{ route: "GET /api/v1/orgs/:orgId/environments" },
|
|
5
|
-
{ route: "POST /api/v1/orgs/:orgId/environments", body: EnvironmentNameBody },
|
|
6
|
-
{ route: "GET /api/v1/orgs/:orgId/environments/:id", params: EnvironmentParams },
|
|
7
|
-
{
|
|
8
|
-
route: "PATCH /api/v1/orgs/:orgId/environments/:id",
|
|
9
|
-
params: EnvironmentParams,
|
|
10
|
-
body: EnvironmentNameBody,
|
|
11
|
-
},
|
|
12
|
-
{ route: "DELETE /api/v1/orgs/:orgId/environments/:id", params: EnvironmentParams },
|
|
13
|
-
{ route: "POST /api/v1/orgs/:orgId/environments/:id/files/reset", params: EnvironmentParams },
|
|
14
|
-
];
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { EnvironmentView } from "./environments.service.js";
|
|
2
|
-
/**
|
|
3
|
-
* An environment's name for people outside the web (the IM `/env` list, the `Platform` tool): its
|
|
4
|
-
* own name, else 「个人环境」 / "Personal" for the default, else for a default demoted by a provider
|
|
5
|
-
* switch the default's name plus the provider's display name (its plugin id when it has none),
|
|
6
|
-
* e.g. 「个人环境(Docker 沙箱)」 / "Personal (Docker sandbox)", with " 2", " 3", … after the
|
|
7
|
-
* first of the same provider. The web builds the same label from its own messages.
|
|
8
|
-
*/
|
|
9
|
-
export declare function environmentLabel(v: Pick<EnvironmentView, "name" | "demotedFrom">, locale: "zh" | "en"): string;
|
|
10
|
-
/** The words the default environment answers to in `/env <name>` besides its label. */
|
|
11
|
-
export declare const DEFAULT_ENVIRONMENT_ALIASES: readonly string[];
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type OnModuleInit } from "@nestjs/common";
|
|
2
|
-
import { EnvironmentsService } from "../../environments/environments.service.js";
|
|
3
|
-
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
4
|
-
import { PlatformOperations } from "../registry.js";
|
|
5
|
-
/**
|
|
6
|
-
* Environment operations of the `Platform` tool (environments design, phase 1): a person's own
|
|
7
|
-
* cloud environments. Phase 1 has personal environments only, visible to their owner alone, so
|
|
8
|
-
* these are `personal` writes. A cloud environment carries no credentials or device connection;
|
|
9
|
-
* deleting one and wiping its files are `personal` writes that are never remembered.
|
|
10
|
-
*/
|
|
11
|
-
export declare class EnvironmentsOperations implements OnModuleInit {
|
|
12
|
-
private readonly registry;
|
|
13
|
-
private readonly environments;
|
|
14
|
-
private readonly kdb;
|
|
15
|
-
constructor(registry: PlatformOperations, environments: EnvironmentsService, kdb: KernelDb);
|
|
16
|
-
/**
|
|
17
|
-
* Whether `id` is the environment the run works in: the one its root conversation is bound to
|
|
18
|
-
* (sub-agents use the root's). Deleting or wiping it would pull the sandbox from under the run.
|
|
19
|
-
*/
|
|
20
|
-
private isRunsEnvironment;
|
|
21
|
-
/** The precheck of a destructive write: never the run's own environment, then the service's. */
|
|
22
|
-
private precheckDestructive;
|
|
23
|
-
/** The environment's name for a card; its id when it cannot be read. */
|
|
24
|
-
private label;
|
|
25
|
-
onModuleInit(): void;
|
|
26
|
-
}
|
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
-
};
|
|
10
|
-
import { Inject, Injectable } from "@nestjs/common";
|
|
11
|
-
import { z } from "zod";
|
|
12
|
-
import { EnvironmentNameBody, EnvironmentParams } from "../../environments/dto.js";
|
|
13
|
-
import { EnvironmentsService, } from "../../environments/environments.service.js";
|
|
14
|
-
import { environmentLabel } from "../../environments/label.js";
|
|
15
|
-
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
16
|
-
import { rootConversationOf } from "../../runtime/subagents/child.js";
|
|
17
|
-
import { defineOperation } from "../operation.js";
|
|
18
|
-
import { PlatformOperations } from "../registry.js";
|
|
19
|
-
import { precheckBy, viaAgent } from "./errors.js";
|
|
20
|
-
import { named, orElse } from "./summary.js";
|
|
21
|
-
const EnvironmentId = z.object({ environmentId: EnvironmentParams.shape.id }).strict();
|
|
22
|
-
const Name = z.object({ name: EnvironmentNameBody.shape.name }).strict();
|
|
23
|
-
/**
|
|
24
|
-
* Model-facing names are English: the default is "Personal", a default demoted by a provider
|
|
25
|
-
* switch "Personal (Docker sandbox)" (the web shows 「个人环境」 / 「个人环境(Docker 沙箱)」).
|
|
26
|
-
*/
|
|
27
|
-
const labelOf = (e) => environmentLabel(e, "en");
|
|
28
|
-
/** A row's state: why it cannot be used now, else whether its instance runs. */
|
|
29
|
-
function stateOf(e) {
|
|
30
|
-
if (!e.available) {
|
|
31
|
-
return {
|
|
32
|
-
state: "unavailable",
|
|
33
|
-
reason: "Its sandbox provider is no longer the deployment's current one.",
|
|
34
|
-
next: "Ask an org admin; use another environment meanwhile.",
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
if (e.filesLost && e.source === "device") {
|
|
38
|
-
return {
|
|
39
|
-
state: "files_lost",
|
|
40
|
-
reason: "Its directory is gone from the connected machine.",
|
|
41
|
-
next: "Ask the person to run capybara-device logout, then capybara-device login into this environment, on that machine.",
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
if (e.filesLost) {
|
|
45
|
-
return {
|
|
46
|
-
state: "files_lost",
|
|
47
|
-
reason: "Its file system is gone at the provider.",
|
|
48
|
-
next: "Wipe its files with environments.reset-files to use it again.",
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
return { state: e.instance?.status ?? "ready" };
|
|
52
|
-
}
|
|
53
|
-
const row = (e) => ({
|
|
54
|
-
id: e.id,
|
|
55
|
-
name: labelOf(e),
|
|
56
|
-
...stateOf(e),
|
|
57
|
-
isDefault: e.isDefault,
|
|
58
|
-
source: e.source,
|
|
59
|
-
provider: e.provider,
|
|
60
|
-
online: e.online,
|
|
61
|
-
machine: e.machine && {
|
|
62
|
-
name: e.machine.name,
|
|
63
|
-
os: e.machine.os,
|
|
64
|
-
lastSeenAt: e.machine.lastSeenAt,
|
|
65
|
-
},
|
|
66
|
-
lastUsedAt: e.instance?.lastUsedAt ?? null,
|
|
67
|
-
});
|
|
68
|
-
/**
|
|
69
|
-
* Environment operations of the `Platform` tool (environments design, phase 1): a person's own
|
|
70
|
-
* cloud environments. Phase 1 has personal environments only, visible to their owner alone, so
|
|
71
|
-
* these are `personal` writes. A cloud environment carries no credentials or device connection;
|
|
72
|
-
* deleting one and wiping its files are `personal` writes that are never remembered.
|
|
73
|
-
*/
|
|
74
|
-
let EnvironmentsOperations = class EnvironmentsOperations {
|
|
75
|
-
registry;
|
|
76
|
-
environments;
|
|
77
|
-
kdb;
|
|
78
|
-
constructor(registry, environments, kdb) {
|
|
79
|
-
this.registry = registry;
|
|
80
|
-
this.environments = environments;
|
|
81
|
-
this.kdb = kdb;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Whether `id` is the environment the run works in: the one its root conversation is bound to
|
|
85
|
-
* (sub-agents use the root's). Deleting or wiping it would pull the sandbox from under the run.
|
|
86
|
-
*/
|
|
87
|
-
async isRunsEnvironment(id, ctx) {
|
|
88
|
-
const root = await rootConversationOf(this.kdb.db, ctx.conversationId);
|
|
89
|
-
const row = await this.kdb.db
|
|
90
|
-
.selectFrom("conversations")
|
|
91
|
-
.select("environment_id")
|
|
92
|
-
.where("id", "=", root)
|
|
93
|
-
.where("org_id", "=", ctx.orgId)
|
|
94
|
-
.executeTakeFirst();
|
|
95
|
-
return row?.environment_id === id;
|
|
96
|
-
}
|
|
97
|
-
/** The precheck of a destructive write: never the run's own environment, then the service's. */
|
|
98
|
-
async precheckDestructive(id, ctx, verb, read) {
|
|
99
|
-
if (await this.isRunsEnvironment(id, ctx)) {
|
|
100
|
-
return {
|
|
101
|
-
ok: false,
|
|
102
|
-
code: "environment.current",
|
|
103
|
-
message: `The environment you are running in cannot be ${verb} from here.`,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
return precheckBy(read);
|
|
107
|
-
}
|
|
108
|
-
/** The environment's name for a card; its id when it cannot be read. */
|
|
109
|
-
label(ctx, id) {
|
|
110
|
-
return orElse(async () => named(labelOf(await this.environments.get(ctx.orgId, ctx.actorAccountId, id))), id);
|
|
111
|
-
}
|
|
112
|
-
onModuleInit() {
|
|
113
|
-
this.registry.register([
|
|
114
|
-
defineOperation({
|
|
115
|
-
id: "environments.list",
|
|
116
|
-
description: "List your own environments in this org: one compact row each (name, state, whether it is the default, source: cloud or device for a connected machine, provider, whether a device one is online and its machine, last use), plus the default and last used ids and whether new cloud environments can be made. The default environment is shown as Personal; a former default left behind by a sandbox provider switch is shown as Personal (<provider>) and becomes the default again when that provider is back.",
|
|
117
|
-
input: z.object({}).strict(),
|
|
118
|
-
example: {},
|
|
119
|
-
authz: { orgAction: "agents.use" },
|
|
120
|
-
mirrors: ["GET /api/v1/orgs/:orgId/environments"],
|
|
121
|
-
confirm: "read",
|
|
122
|
-
run: async (_input, ctx) => {
|
|
123
|
-
const l = await this.environments.list(ctx.orgId, ctx.actorAccountId);
|
|
124
|
-
return {
|
|
125
|
-
items: l.items.map(row),
|
|
126
|
-
defaultId: l.defaultId,
|
|
127
|
-
lastUsedId: l.lastUsedId,
|
|
128
|
-
cloudAvailable: l.cloudAvailable,
|
|
129
|
-
};
|
|
130
|
-
},
|
|
131
|
-
}),
|
|
132
|
-
defineOperation({
|
|
133
|
-
id: "environments.get",
|
|
134
|
-
description: "Read one of your environments with its source (cloud or device), provider, state, instance, connected machine and whether it is online, limits and creation time. Takes the id from environments.list.",
|
|
135
|
-
input: EnvironmentId,
|
|
136
|
-
example: { environmentId: "4e8a0c1d-6b2f-4a37-8d19-3c5e7f9a1b20" },
|
|
137
|
-
authz: { orgAction: "agents.use" },
|
|
138
|
-
mirrors: ["GET /api/v1/orgs/:orgId/environments/:id"],
|
|
139
|
-
renames: { environmentId: "id" },
|
|
140
|
-
confirm: "read",
|
|
141
|
-
errors: [
|
|
142
|
-
{
|
|
143
|
-
code: "environment.not_found",
|
|
144
|
-
next: "Check the id with environments.list: you only see your own environments.",
|
|
145
|
-
},
|
|
146
|
-
],
|
|
147
|
-
run: async (input, ctx) => {
|
|
148
|
-
const e = await this.environments.get(ctx.orgId, ctx.actorAccountId, input.environmentId);
|
|
149
|
-
return { environment: { ...e, name: labelOf(e), ...stateOf(e) } };
|
|
150
|
-
},
|
|
151
|
-
}),
|
|
152
|
-
defineOperation({
|
|
153
|
-
id: "environments.create",
|
|
154
|
-
description: "Create a personal cloud environment with a name (1-64 characters, unique among yours, case-insensitive). It is ready at once; its instance and files are made on first use. It needs a sandbox provider and is limited per person.",
|
|
155
|
-
input: Name,
|
|
156
|
-
example: { name: "Data analysis" },
|
|
157
|
-
authz: { orgAction: "agents.use" },
|
|
158
|
-
mirrors: ["POST /api/v1/orgs/:orgId/environments"],
|
|
159
|
-
confirm: "personal",
|
|
160
|
-
errors: [
|
|
161
|
-
{
|
|
162
|
-
code: "environment.name_taken",
|
|
163
|
-
next: "You have an environment with this name: pick another name, or read yours with environments.list.",
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
code: "environment.limit_reached",
|
|
167
|
-
next: "You are at the limit: delete an environment you no longer need with environments.delete, or use an existing one.",
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
code: "environment.current",
|
|
171
|
-
next: "This conversation works in it: ask the person to wipe it on the web, or wipe a different one.",
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
code: "environment.unavailable",
|
|
175
|
-
next: {
|
|
176
|
-
superAdmin: "No sandbox provider is current: set one up in the admin console under extensions, then call again.",
|
|
177
|
-
orgAdmin: "No sandbox provider is set up; ask the super admin.",
|
|
178
|
-
member: "No sandbox provider is set up in this deployment; ask an org admin.",
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
],
|
|
182
|
-
precheck: (i, ctx) => precheckBy(() => this.environments.checkCreate(ctx.orgId, ctx.actorAccountId, i.name)),
|
|
183
|
-
summary: (i) => ({
|
|
184
|
-
zh: `新建个人云环境「${named(i.name)}」`,
|
|
185
|
-
en: `Create personal cloud environment "${named(i.name)}"`,
|
|
186
|
-
}),
|
|
187
|
-
run: async (input, ctx) => {
|
|
188
|
-
const e = await this.environments.create(ctx.orgId, ctx.actorAccountId, { name: input.name }, undefined, viaAgent("environments.create", ctx));
|
|
189
|
-
return { environment: row(e) };
|
|
190
|
-
},
|
|
191
|
-
}),
|
|
192
|
-
defineOperation({
|
|
193
|
-
id: "environments.delete",
|
|
194
|
-
description: "Delete one of your environments, the default one included: its instance and ALL its files are destroyed after the response and cannot be recovered. Conversations bound to it keep pointing at it and their sandbox tools then fail. The person confirms every delete; it is never remembered. The environment this conversation works in cannot be deleted. Takes the id from environments.list.",
|
|
195
|
-
input: EnvironmentId,
|
|
196
|
-
example: { environmentId: "4e8a0c1d-6b2f-4a37-8d19-3c5e7f9a1b20" },
|
|
197
|
-
authz: { orgAction: "agents.use" },
|
|
198
|
-
mirrors: ["DELETE /api/v1/orgs/:orgId/environments/:id"],
|
|
199
|
-
renames: { environmentId: "id" },
|
|
200
|
-
confirm: "personal",
|
|
201
|
-
// destructive: asked every time and never remembered
|
|
202
|
-
rememberable: false,
|
|
203
|
-
errors: [
|
|
204
|
-
{
|
|
205
|
-
code: "environment.not_found",
|
|
206
|
-
next: "Check the id with environments.list: you only see your own environments.",
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
code: "environment.current",
|
|
210
|
-
next: "This conversation works in it: ask the person to delete it on the web, or delete a different one.",
|
|
211
|
-
},
|
|
212
|
-
],
|
|
213
|
-
precheck: (i, ctx) => this.precheckDestructive(i.environmentId, ctx, "deleted", () => this.environments.get(ctx.orgId, ctx.actorAccountId, i.environmentId)),
|
|
214
|
-
summary: async (i, ctx) => {
|
|
215
|
-
const n = await this.label(ctx, i.environmentId);
|
|
216
|
-
const c = await orElse(() => this.environments.boundConversations(ctx.orgId, ctx.actorAccountId, i.environmentId), 0);
|
|
217
|
-
return {
|
|
218
|
-
zh: `删除环境「${n}」:其中所有文件将被销毁且无法恢复;使用它的 ${c} 个对话将失去沙箱(沙箱工具会失败)`,
|
|
219
|
-
en: `Delete environment "${n}": all its files are destroyed and cannot be recovered; the ${c} conversations using it lose their sandbox (their sandbox tools fail)`,
|
|
220
|
-
};
|
|
221
|
-
},
|
|
222
|
-
run: async (input, ctx) => {
|
|
223
|
-
await this.environments.remove(ctx.orgId, ctx.actorAccountId, input.environmentId, undefined, viaAgent("environments.delete", ctx));
|
|
224
|
-
return { id: input.environmentId, deleted: true };
|
|
225
|
-
},
|
|
226
|
-
}),
|
|
227
|
-
defineOperation({
|
|
228
|
-
id: "environments.reset-files",
|
|
229
|
-
description: "Wipe one of your environments' files so it starts empty: ALL its files are destroyed (after running commands finish) and cannot be recovered; the next use creates a fresh workspace. Use it when an environment reports its files are lost (not for a connected machine's environment: its files are on the machine). The person confirms every reset; it is never remembered. The environment this conversation works in cannot be wiped. Takes the id from environments.list.",
|
|
230
|
-
input: EnvironmentId,
|
|
231
|
-
example: { environmentId: "4e8a0c1d-6b2f-4a37-8d19-3c5e7f9a1b20" },
|
|
232
|
-
authz: { orgAction: "agents.use" },
|
|
233
|
-
mirrors: ["POST /api/v1/orgs/:orgId/environments/:id/files/reset"],
|
|
234
|
-
renames: { environmentId: "id" },
|
|
235
|
-
confirm: "personal",
|
|
236
|
-
rememberable: false,
|
|
237
|
-
errors: [
|
|
238
|
-
{
|
|
239
|
-
code: "environment.not_found",
|
|
240
|
-
next: "Check the id with environments.list: you only see your own environments.",
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
code: "environment.current",
|
|
244
|
-
next: "This conversation works in it: ask the person to wipe it on the web, or wipe a different one.",
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
code: "environment.files_on_device",
|
|
248
|
-
next: "Its files are on its connected machine: ask the person to run capybara-device logout, then capybara-device login into this environment, on that machine.",
|
|
249
|
-
},
|
|
250
|
-
{
|
|
251
|
-
code: "environment.unavailable",
|
|
252
|
-
next: {
|
|
253
|
-
orgAdmin: "Its sandbox provider is no longer the current one: use another environment, or ask the super admin about the provider.",
|
|
254
|
-
member: "Its sandbox provider is no longer the current one: use another environment, or ask an org admin.",
|
|
255
|
-
},
|
|
256
|
-
},
|
|
257
|
-
],
|
|
258
|
-
precheck: (i, ctx) => this.precheckDestructive(i.environmentId, ctx, "wiped", () => this.environments.checkReset(ctx.orgId, ctx.actorAccountId, i.environmentId)),
|
|
259
|
-
summary: async (i, ctx) => {
|
|
260
|
-
const n = await this.label(ctx, i.environmentId);
|
|
261
|
-
return {
|
|
262
|
-
zh: `清空环境「${n}」的文件:所有文件将被销毁且无法恢复`,
|
|
263
|
-
en: `Wipe the files of environment "${n}": all files are destroyed and cannot be recovered`,
|
|
264
|
-
};
|
|
265
|
-
},
|
|
266
|
-
run: async (input, ctx) => {
|
|
267
|
-
await this.environments.resetFiles(ctx.orgId, ctx.actorAccountId, input.environmentId, undefined, viaAgent("environments.reset-files", ctx));
|
|
268
|
-
return { id: input.environmentId, reset: true };
|
|
269
|
-
},
|
|
270
|
-
}),
|
|
271
|
-
defineOperation({
|
|
272
|
-
id: "environments.rename",
|
|
273
|
-
description: "Rename one of your environments, the default one included (it then has a name). The new name is 1-64 characters and unique among yours, case-insensitive. Takes the id from environments.list.",
|
|
274
|
-
input: EnvironmentId.extend({ name: EnvironmentNameBody.shape.name }).strict(),
|
|
275
|
-
example: { environmentId: "4e8a0c1d-6b2f-4a37-8d19-3c5e7f9a1b20", name: "Reports" },
|
|
276
|
-
authz: { orgAction: "agents.use" },
|
|
277
|
-
mirrors: ["PATCH /api/v1/orgs/:orgId/environments/:id"],
|
|
278
|
-
renames: { environmentId: "id" },
|
|
279
|
-
confirm: "personal",
|
|
280
|
-
errors: [
|
|
281
|
-
{
|
|
282
|
-
code: "environment.not_found",
|
|
283
|
-
next: "Check the id with environments.list: you only see your own environments.",
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
code: "environment.name_taken",
|
|
287
|
-
next: "You have an environment with this name: pick another name.",
|
|
288
|
-
},
|
|
289
|
-
],
|
|
290
|
-
precheck: (i, ctx) => precheckBy(() => this.environments.checkRename(ctx.orgId, ctx.actorAccountId, i.environmentId, i.name)),
|
|
291
|
-
summary: async (i, ctx) => {
|
|
292
|
-
const from = await orElse(async () => named(labelOf(await this.environments.get(ctx.orgId, ctx.actorAccountId, i.environmentId))), i.environmentId);
|
|
293
|
-
return {
|
|
294
|
-
zh: `将环境「${from}」重命名为「${named(i.name)}」`,
|
|
295
|
-
en: `Rename environment "${from}" to "${named(i.name)}"`,
|
|
296
|
-
};
|
|
297
|
-
},
|
|
298
|
-
run: async (input, ctx) => ({
|
|
299
|
-
environment: row(await this.environments.rename(ctx.orgId, ctx.actorAccountId, input.environmentId, input.name, undefined, viaAgent("environments.rename", ctx))),
|
|
300
|
-
}),
|
|
301
|
-
}),
|
|
302
|
-
]);
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
EnvironmentsOperations = __decorate([
|
|
306
|
-
Injectable(),
|
|
307
|
-
__param(0, Inject(PlatformOperations)),
|
|
308
|
-
__param(1, Inject(EnvironmentsService)),
|
|
309
|
-
__param(2, Inject(KernelDb))
|
|
310
|
-
], EnvironmentsOperations);
|
|
311
|
-
export { EnvironmentsOperations };
|