evolcore 0.0.43-test.6 → 0.0.43-test.8
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/CHANGELOG.md +95 -0
- package/bin/ecmsg.js +188 -58
- package/dist/agent-template/jobs.js +62 -0
- package/dist/agent-template/runtime.js +214 -0
- package/dist/agent-template/service.js +465 -0
- package/dist/agent-template/tool-runner.js +45 -0
- package/dist/agent-template/types.js +5 -0
- package/dist/agents/baseagent-availability.js +1 -1
- package/dist/agents/claude-runner.js +1 -1
- package/dist/agents/codex/app-server-client.js +22 -0
- package/dist/agents/codex-runner.js +69 -2
- package/dist/aun/aid/agentmd.js +56 -1
- package/dist/aun/aid/client.js +3 -1
- package/dist/aun/menu/client.js +3 -2
- package/dist/aun/msg/p2p.js +6 -1
- package/dist/channels/aun.js +277 -49
- package/dist/cli/agent-command.js +5 -0
- package/dist/cli/agent-create.js +7 -3
- package/dist/cli/agent-template.js +124 -0
- package/dist/cli/aun-commands.js +2 -2
- package/dist/cli/ctl-command.js +2 -1
- package/dist/cli/daemon-commands.js +11 -66
- package/dist/cli/daemon-lifecycle-client.js +61 -0
- package/dist/cli/ecmsg-gateway.js +35 -2
- package/dist/cli/events-command.js +109 -0
- package/dist/cli/index.js +60 -14
- package/dist/cli/invoke-command.js +182 -0
- package/dist/cli/managed-command-guard.js +6 -1
- package/dist/cli/net-check.js +1 -1
- package/dist/cli/restart-monitor.js +160 -83
- package/dist/cli/services-command.js +137 -0
- package/dist/cli/team-workspace-command.js +134 -0
- package/dist/cli/thread-command.js +103 -13
- package/dist/cli/watch-msg.js +1 -1
- package/dist/config/boot-log.js +8 -8
- package/dist/config/config-field-policy.js +2 -2
- package/dist/config/config-manager.js +0 -7
- package/dist/config/invoke-ipc-service.js +118 -0
- package/dist/config/schema-migration.js +45 -15
- package/dist/config-store.js +2 -1
- package/dist/core/agent-ipc-registration.js +25 -4
- package/dist/core/agent-reload-coordinator.js +6 -4
- package/dist/core/agent-runtime.js +106 -10
- package/dist/core/auth/delegation-authorization.js +66 -0
- package/dist/core/auth/operation-authorizer.js +2 -0
- package/dist/core/auth/operation-catalog.js +29 -0
- package/dist/core/baseagent-loader.js +60 -130
- package/dist/core/channel-loader.js +10 -1
- package/dist/core/channel-runtime.js +20 -12
- package/dist/core/command/agent-control.js +12 -2
- package/dist/core/command/agent-storage-menu.js +1 -1
- package/dist/core/command/agent-template-menu.js +147 -0
- package/dist/core/command/chatmode-config.js +2 -36
- package/dist/core/command/command-handler.js +80 -17
- package/dist/core/command/data-root-resolver.js +32 -23
- package/dist/core/command/eventcenter-menu.js +468 -0
- package/dist/core/command/menu-catalog.js +15 -0
- package/dist/core/command/menu-handler.js +216 -90
- package/dist/core/command/menu-protocol.js +71 -13
- package/dist/core/command/menu-query-batch.js +194 -0
- package/dist/core/command/slash-gate.js +1 -1
- package/dist/core/command/slash-handler.js +34 -42
- package/dist/core/command/team-workspace-bootstrap.js +350 -0
- package/dist/core/command/{pa-workspace-calendar.js → team-workspace-calendar.js} +7 -7
- package/dist/core/command/team-workspace-initializer.js +2 -0
- package/dist/core/command/{pa-workspace-items.js → team-workspace-items.js} +83 -68
- package/dist/core/command/team-workspace-job-store.js +88 -0
- package/dist/core/command/team-workspace-management-service.js +2 -0
- package/dist/core/command/team-workspace-management-store.js +96 -0
- package/dist/core/command/team-workspace-management.js +265 -0
- package/dist/core/command/team-workspace-members-menu.js +88 -0
- package/dist/core/command/team-workspace-store.js +612 -0
- package/dist/core/command/team-workspace-team.js +193 -0
- package/dist/core/daemon-control.js +22 -5
- package/dist/core/daemon-lifecycle.js +323 -191
- package/dist/core/handoff/runtime.js +45 -13
- package/dist/core/invoke/executors/index.js +13 -0
- package/dist/core/invoke/executors/media.js +283 -0
- package/dist/core/invoke/executors/text.js +198 -0
- package/dist/core/invoke/invoke-service.js +157 -0
- package/dist/core/invoke/style-router.js +48 -0
- package/dist/core/invoke/types.js +19 -0
- package/dist/core/ipc-registration.js +50 -7
- package/dist/core/legacy-rename.js +41 -0
- package/dist/core/memory/consolidation.js +7 -5
- package/dist/core/message/aun-ipc-sender.js +252 -17
- package/dist/core/message/im-renderer.js +116 -85
- package/dist/core/message/message-bridge.js +4 -0
- package/dist/core/message/message-queue.js +66 -15
- package/dist/core/message/message-utils.js +10 -2
- package/dist/core/message/peer-mode.js +7 -34
- package/dist/core/message/pending-hints.js +29 -5
- package/dist/core/message/response-engine.js +194 -61
- package/dist/core/message/send-options.js +7 -4
- package/dist/core/message/send-routing.js +50 -5
- package/dist/core/ownership/owner-resolver.js +7 -0
- package/dist/core/pack-auth.js +94 -0
- package/dist/core/pack-install.js +194 -0
- package/dist/core/permission/ec-command-parser.js +51 -17
- package/dist/core/permission/protected-paths.js +12 -2
- package/dist/core/permission/shell-environment.js +9 -0
- package/dist/core/rate-window.js +48 -0
- package/dist/core/relation/peer-identity.js +28 -0
- package/dist/core/session/session-file-health.js +243 -0
- package/dist/core/session/session-fs-store.js +67 -28
- package/dist/core/session/session-idle-monitor.js +59 -19
- package/dist/core/session/session-manager.js +13 -4
- package/dist/core/task/task-recovery-service.js +13 -2
- package/dist/core/thread/command-parser.js +9 -2
- package/dist/core/thread/thread-operation.js +21 -2
- package/dist/core/thread/thread-route.js +13 -2
- package/dist/core/thread/thread-service.js +52 -3
- package/dist/directory/owner-directory-admission.js +40 -53
- package/dist/directory/owner-directory-cache.js +89 -113
- package/dist/directory/owner-directory-query-operation.js +8 -10
- package/dist/eck/kit-renderer.js +7 -5
- package/dist/eck/message-renderer.js +2 -0
- package/dist/ecweb/basic-settings-service.js +1 -1
- package/dist/ecweb/message-context-service.js +0 -4
- package/dist/ecweb/runtime/lifecycle.js +6 -2
- package/dist/ecweb/runtime/supervisor.js +19 -4
- package/dist/event-center/admission-materializer.js +124 -0
- package/dist/event-center/bus-gate.js +154 -0
- package/dist/event-center/bus-host.js +307 -0
- package/dist/event-center/bus-resolver.js +120 -0
- package/dist/event-center/center-config.js +127 -0
- package/dist/event-center/daemon.js +44 -0
- package/dist/event-center/directory-source.js +55 -0
- package/dist/event-center/dispatcher.js +157 -0
- package/dist/event-center/event-log.js +110 -0
- package/dist/event-center/index-generator.js +73 -0
- package/dist/event-center/ipc-operation.js +423 -0
- package/dist/event-center/ledger.js +52 -0
- package/dist/event-center/pack-loader.js +207 -0
- package/dist/event-center/pack-manager.js +85 -0
- package/dist/event-center/registry.js +463 -0
- package/dist/event-center/runtime.js +837 -0
- package/dist/event-center/script-runner.js +356 -0
- package/dist/event-center/types.js +51 -0
- package/dist/event-center/validation.js +435 -0
- package/dist/index.js +424 -135
- package/dist/ipc.js +106 -12
- package/dist/paths.js +20 -0
- package/dist/product.js +14 -0
- package/dist/proxy/manager.js +5 -1
- package/dist/proxy/service-supervisor.js +13 -4
- package/dist/response-system/engines/v1/index.js +0 -1
- package/dist/response-system/engines/v1/proactive-flow.js +4 -2
- package/dist/response-system/modes/single-session/index.js +1 -1
- package/dist/services/dispatcher.js +100 -0
- package/dist/services/idempotency.js +90 -0
- package/dist/services/identity.js +52 -0
- package/dist/services/index-generator.js +70 -0
- package/dist/services/index.js +449 -0
- package/dist/services/ipc-operation.js +550 -0
- package/dist/services/ledger.js +52 -0
- package/dist/services/message-log.js +112 -0
- package/dist/services/pack-manager.js +215 -0
- package/dist/services/reply.js +55 -0
- package/dist/services/router.js +98 -0
- package/dist/services/script-runner.js +422 -0
- package/dist/services/service-payload.js +70 -0
- package/dist/services/types.js +18 -0
- package/dist/services/validation.js +297 -0
- package/dist/trigger/application-service.js +18 -0
- package/dist/trigger/event-source.js +1 -1
- package/dist/trigger/ipc-service.js +3 -1
- package/dist/trigger/scheduler.js +38 -0
- package/dist/trigger/script-sandbox.js +170 -24
- package/dist/utils/cross-platform.js +24 -10
- package/dist/utils/evolcore-version.js +69 -27
- package/dist/utils/instance-registry.js +19 -13
- package/dist/utils/npm-ops.js +2 -1
- package/dist/utils/package-version-info.js +6 -3
- package/dist/utils/process-introspect.js +45 -9
- package/dist/utils/startup-trace.js +74 -37
- package/dist/utils/windows-shell-trust.js +80 -6
- package/kits/docs/INDEX.md +2 -2
- package/kits/docs/aun/ABILITY_CALLING.md +9 -15
- package/kits/docs/context-assembly.md +1 -1
- package/kits/docs/evolcore/INDEX.md +3 -1
- package/kits/docs/evolcore/ability.md +4 -0
- package/kits/docs/evolcore/agent.md +22 -1
- package/kits/docs/evolcore/aid.md +1 -1
- package/kits/docs/evolcore/event-center.md +227 -0
- package/kits/docs/evolcore/file-navigation.md +10 -264
- package/kits/docs/evolcore/fs.md +5 -3
- package/kits/docs/evolcore/group.md +1 -1
- package/kits/docs/evolcore/memory-architecture.md +2 -0
- package/kits/docs/evolcore/menu-protocol.md +28 -1
- package/kits/docs/evolcore/msg.md +21 -9
- package/kits/docs/evolcore/provider.md +3 -1
- package/kits/docs/evolcore/response.md +5 -5
- package/kits/docs/evolcore/services.md +294 -0
- package/kits/docs/evolcore/task.md +2 -0
- package/kits/docs/evolcore/team-workspace.md +41 -0
- package/kits/docs/evolcore/thread-chain.md +15 -3
- package/kits/eck_manifest.json +26 -0
- package/kits/rules/02-navigation.md +10 -1
- package/kits/rules/06-channel.md +1 -0
- package/kits/schemas/_meta.json +17 -6
- package/kits/schemas/agent-config.schema.19.json +5 -7
- package/kits/schemas/agent-config.schema.20.json +936 -0
- package/kits/schemas/relation-config.schema.12.json +2 -3
- package/kits/schemas/role-config.schema.2.json +4 -4
- package/kits/skills/.switches.json +1 -5
- package/kits/skills/ability/SKILL.md +56 -0
- package/kits/skills/ability/references/calling.md +56 -0
- package/kits/skills/{ec-ability → ability}/references/contract-checklist.md +1 -1
- package/kits/skills/{ec-ability → ability}/references/development.md +9 -33
- package/kits/skills/{ec-ability → ability}/references/management.md +2 -2
- package/kits/skills/{ec-ability → ability}/references/recovery.md +1 -1
- package/kits/skills/{ec-ability → ability}/references/runtime-protocol.md +2 -0
- package/kits/skills/ec-agent-create/SKILL.md +0 -1
- package/kits/skills/ec-group/SKILL.md +5 -8
- package/kits/skills/ec-group-collaboration/SKILL.md +7 -7
- package/kits/skills/ec-service-proxy/SKILL.md +34 -5
- package/kits/skills/ec-trigger/SKILL.md +4 -4
- package/kits/skills/personal-assistant/SKILL.md +6 -6
- package/kits/skills/personal-assistant/references/02-bootstrap.md +4 -4
- package/kits/skills/personal-assistant/scripts/clean.mjs +4 -4
- package/kits/skills/personal-assistant/scripts/init.mjs +2 -2
- package/kits/skills/personal-assistant/scripts/pa.mjs +4 -4
- package/kits/skills/thread-ops/SKILL.md +10 -10
- package/kits/templates/message-fragments/item.md +1 -1
- package/kits/templates/system-fragments/channel.md +3 -3
- package/kits/templates/system-fragments/commands.md +5 -3
- package/kits/templates/system-fragments/reply.md +1 -5
- package/kits/templates/system-fragments/thread.md +13 -10
- package/package.json +5 -6
- package/scripts/agent-template/index.mjs +40 -0
- package/scripts/agent-template/inspect.mjs +240 -0
- package/scripts/agent-template/overlay.mjs +71 -0
- package/scripts/agent-template/pack.mjs +169 -0
- package/scripts/agent-template/shared/common.mjs +235 -0
- package/scripts/agent-template/shared/evolcore.mjs +75 -0
- package/scripts/agent-template/shared/plan.mjs +129 -0
- package/scripts/agent-template/shared/team-schema.json +70 -0
- package/scripts/agent-template/shared/template-contract.mjs +154 -0
- package/scripts/agent-template/shared/template-package.mjs +265 -0
- package/scripts/agent-template/shared/template-runtime.mjs +80 -0
- package/scripts/agent-template/shared/template.mjs +142 -0
- package/dist/cli/pa-workspace-command.js +0 -225
- package/dist/core/command/pa-workspace-store.js +0 -468
- package/dist/core/relation/pa-team.js +0 -132
- package/kits/docs/evolcore/pa-workspace.md +0 -51
- package/kits/skills/aid-ability/SKILL.md +0 -244
- package/kits/skills/ec-ability/SKILL.md +0 -67
- package/kits/skills/ec-ability/references/workflows.md +0 -15
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
-
import { DataRootError,
|
|
3
|
+
import { DataRootError, isTeamHiddenPath, teamWorkspaceStore } from './team-workspace-store.js';
|
|
4
4
|
const MAX_RANGE_DAYS = 62;
|
|
5
5
|
const MAX_FILES = 500;
|
|
6
6
|
const MAX_RUNS_PER_TRIGGER = 200;
|
|
@@ -91,12 +91,12 @@ function collectFiles(state, navigation) {
|
|
|
91
91
|
truncated = true;
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
|
-
if (seen.has(relativePath) ||
|
|
94
|
+
if (seen.has(relativePath) || isTeamHiddenPath(relativePath))
|
|
95
95
|
return;
|
|
96
96
|
seen.add(relativePath);
|
|
97
97
|
let resolved;
|
|
98
98
|
try {
|
|
99
|
-
resolved =
|
|
99
|
+
resolved = teamWorkspaceStore.resolvePath(state, relativePath);
|
|
100
100
|
}
|
|
101
101
|
catch {
|
|
102
102
|
return;
|
|
@@ -120,7 +120,7 @@ function collectFiles(state, navigation) {
|
|
|
120
120
|
return;
|
|
121
121
|
}
|
|
122
122
|
for (const name of names) {
|
|
123
|
-
if (
|
|
123
|
+
if (isTeamHiddenPath(relativeChild(resolved.relativePath, name)))
|
|
124
124
|
continue;
|
|
125
125
|
const childPath = relativeChild(resolved.relativePath, name);
|
|
126
126
|
visit({ ...entry, title: name, path: childPath, kind: 'file' }, childPath, rootEntryId);
|
|
@@ -131,7 +131,7 @@ function collectFiles(state, navigation) {
|
|
|
131
131
|
}
|
|
132
132
|
};
|
|
133
133
|
for (const entry of navigation.entries) {
|
|
134
|
-
if (entry.availability === 'unavailable' ||
|
|
134
|
+
if (entry.availability === 'unavailable' || isTeamHiddenPath(entry.path))
|
|
135
135
|
continue;
|
|
136
136
|
visit(entry, entry.path, entry.id);
|
|
137
137
|
if (files.length >= MAX_FILES) {
|
|
@@ -141,7 +141,7 @@ function collectFiles(state, navigation) {
|
|
|
141
141
|
}
|
|
142
142
|
return { files, truncated };
|
|
143
143
|
}
|
|
144
|
-
export function
|
|
144
|
+
export function queryTeamWorkspaceCalendar({ state, navigation, scheduler, args }) {
|
|
145
145
|
const timezone = resolveTimezone(args?.timezone);
|
|
146
146
|
const range = resolveRange(args, timezone);
|
|
147
147
|
const byDate = new Map();
|
|
@@ -207,7 +207,7 @@ export function queryPaWorkspaceCalendar({ state, navigation, scheduler, args })
|
|
|
207
207
|
items: items.sort((a, b) => a.at - b.at || a.title.localeCompare(b.title)),
|
|
208
208
|
}));
|
|
209
209
|
return {
|
|
210
|
-
protocol: 'evol.
|
|
210
|
+
protocol: 'evol.team-workspace',
|
|
211
211
|
protocolVersion: 1,
|
|
212
212
|
view: 'calendar',
|
|
213
213
|
timezone,
|
|
@@ -5,7 +5,7 @@ import { watch } from 'chokidar';
|
|
|
5
5
|
import { parseDocument } from 'yaml';
|
|
6
6
|
import { agentDataDir } from '../../paths.js';
|
|
7
7
|
import { atomicWriteText } from '../../utils/atomic-write.js';
|
|
8
|
-
import { DataRootError,
|
|
8
|
+
import { DataRootError, isTeamHiddenPath, teamWorkspaceStore } from './team-workspace-store.js';
|
|
9
9
|
const MAX_FILES = 10_000;
|
|
10
10
|
const MAX_VISITED = 20_000;
|
|
11
11
|
const MAX_PREVIEW_BYTES = 4096;
|
|
@@ -17,10 +17,10 @@ const IDLE_MS = 10 * 60_000;
|
|
|
17
17
|
const FIELDS = ['title', 'summary', 'type', 'id', 'status', 'horizon', 'priority', 'date',
|
|
18
18
|
'period', 'report_type', 'due_at', 'completed_at', 'owner_note', 'source', 'stale_checks',
|
|
19
19
|
'memory_kind', 'superseded_by', 'url', 'peer', 'thread_id', 'count', 'tags'];
|
|
20
|
-
export function
|
|
20
|
+
export function validateTeamWorkspaceItemsArgs(args) {
|
|
21
21
|
if (typeof args.path !== 'string' || !args.path || args.path.length > 2048
|
|
22
22
|
|| args.path.includes('\\') || args.path.includes(':') || /[\x00-\x1f\x7f]/.test(args.path)
|
|
23
|
-
|| args.path.split('/').some(part => !part || part.startsWith('.')) ||
|
|
23
|
+
|| args.path.split('/').some(part => !part || part.startsWith('.')) || isTeamHiddenPath(args.path)) {
|
|
24
24
|
throw new DataRootError('INVALID_ARGUMENT', 'items requires a user-facing relative path');
|
|
25
25
|
}
|
|
26
26
|
for (const [key, min, max] of [['offset', 0, MAX_FILES], ['limit', 1, 20]]) {
|
|
@@ -44,7 +44,7 @@ function within(parent, child) {
|
|
|
44
44
|
}
|
|
45
45
|
function published(state, relative) {
|
|
46
46
|
return relative.length <= 2048 && !/[\\:\x00-\x1f\x7f]/.test(relative)
|
|
47
|
-
&& !
|
|
47
|
+
&& !isTeamHiddenPath(relative) && state.entries.some(entry => entry.availability !== 'unavailable'
|
|
48
48
|
&& (entry.path === relative || entry.kind === 'directory' && within(entry.path, relative)));
|
|
49
49
|
}
|
|
50
50
|
function clip(value, bytes) {
|
|
@@ -103,18 +103,18 @@ async function preview(realPath, size) {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
/** Derived private cache. No Skill files, workspace content or directory layouts are modified. */
|
|
106
|
-
export class
|
|
106
|
+
export class TeamWorkspaceItemsIndex {
|
|
107
107
|
store;
|
|
108
108
|
indexes = new Map();
|
|
109
|
-
constructor(store =
|
|
109
|
+
constructor(store = teamWorkspaceStore) {
|
|
110
110
|
this.store = store;
|
|
111
111
|
}
|
|
112
|
-
warm(
|
|
112
|
+
warm(agentAid, state) {
|
|
113
113
|
// Navigation must not wait for cache JSON parsing or filesystem discovery.
|
|
114
114
|
setImmediate(() => {
|
|
115
115
|
try {
|
|
116
|
-
this.assertCurrent(
|
|
117
|
-
const index = this.get(
|
|
116
|
+
this.assertCurrent(agentAid, state);
|
|
117
|
+
const index = this.get(agentAid, state);
|
|
118
118
|
void this.refresh(index).then(async () => {
|
|
119
119
|
// Only the first page of each entry needs to be ready before a click.
|
|
120
120
|
const firstPages = state.entries.flatMap(entry => index.sorted.filter(item => within(entry.path, item.path)).slice(0, 20));
|
|
@@ -125,25 +125,26 @@ export class PaWorkspaceItemsIndex {
|
|
|
125
125
|
catch { /* Binding may have changed since the navigation response. */ }
|
|
126
126
|
}).unref();
|
|
127
127
|
}
|
|
128
|
-
assertCurrent(
|
|
129
|
-
const current = this.store.require(
|
|
128
|
+
assertCurrent(agentAid, state) {
|
|
129
|
+
const current = this.store.require(agentAid);
|
|
130
130
|
if (current.workspaceId !== state.workspaceId || current.ownerAid !== state.ownerAid
|
|
131
|
-
|| current.rootPath !== state.rootPath || current.
|
|
132
|
-
|
|
131
|
+
|| current.rootPath !== state.rootPath || current.outputRootPath !== state.outputRootPath
|
|
132
|
+
|| current.navigationRevision !== state.navigationRevision) {
|
|
133
|
+
throw new DataRootError('WORKSPACE_CHANGED', 'Team workspace changed during query');
|
|
133
134
|
}
|
|
134
135
|
}
|
|
135
|
-
async query(
|
|
136
|
-
|
|
137
|
-
this.assertCurrent(
|
|
136
|
+
async query(agentAid, state, args) {
|
|
137
|
+
validateTeamWorkspaceItemsArgs(args);
|
|
138
|
+
this.assertCurrent(agentAid, state);
|
|
138
139
|
const requestedPath = args.path;
|
|
139
140
|
if (!published(state, requestedPath))
|
|
140
|
-
throw new DataRootError('FORBIDDEN', 'Path is not published in
|
|
141
|
+
throw new DataRootError('FORBIDDEN', 'Path is not published in Team navigation');
|
|
141
142
|
this.store.resolvePath(state, requestedPath);
|
|
142
|
-
const index = this.get(
|
|
143
|
+
const index = this.get(agentAid, state);
|
|
143
144
|
await this.refresh(index);
|
|
144
|
-
this.assertCurrent(
|
|
145
|
+
this.assertCurrent(agentAid, state);
|
|
145
146
|
if (args.indexRevision !== undefined && args.indexRevision !== index.revision) {
|
|
146
|
-
throw new DataRootError('INDEX_CHANGED', '
|
|
147
|
+
throw new DataRootError('INDEX_CHANGED', 'Team workspace items changed; restart pagination');
|
|
147
148
|
}
|
|
148
149
|
const snapshotRevision = index.revision;
|
|
149
150
|
const matching = index.sorted.filter(item => within(requestedPath, item.path));
|
|
@@ -151,9 +152,9 @@ export class PaWorkspaceItemsIndex {
|
|
|
151
152
|
const limit = Number(args.limit ?? 20);
|
|
152
153
|
const window = matching.slice(offset, offset + limit);
|
|
153
154
|
const parsed = await this.prepare(index, window);
|
|
154
|
-
this.assertCurrent(
|
|
155
|
+
this.assertCurrent(agentAid, state);
|
|
155
156
|
if (index.closed || snapshotRevision !== index.revision) {
|
|
156
|
-
throw new DataRootError('INDEX_CHANGED', '
|
|
157
|
+
throw new DataRootError('INDEX_CHANGED', 'Team workspace items changed; restart pagination');
|
|
157
158
|
}
|
|
158
159
|
// Revalidate only the returned page, including canonical paths, before any
|
|
159
160
|
// cached private text leaves Core. A missed watcher event cannot leak it.
|
|
@@ -166,7 +167,7 @@ export class PaWorkspaceItemsIndex {
|
|
|
166
167
|
catch {
|
|
167
168
|
index.dirty.add(item.path);
|
|
168
169
|
await this.refresh(index);
|
|
169
|
-
throw new DataRootError('INDEX_CHANGED', '
|
|
170
|
+
throw new DataRootError('INDEX_CHANGED', 'Team workspace items changed; restart pagination');
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
173
|
if (offset > matching.length)
|
|
@@ -175,7 +176,7 @@ export class PaWorkspaceItemsIndex {
|
|
|
175
176
|
this.persist(index);
|
|
176
177
|
const next = offset + window.length;
|
|
177
178
|
const response = {
|
|
178
|
-
protocol: 'evol.
|
|
179
|
+
protocol: 'evol.team-workspace', protocolVersion: 1, view: 'items',
|
|
179
180
|
workspaceId: state.workspaceId, navigationRevision: state.navigationRevision,
|
|
180
181
|
indexRevision: index.revision, path: requestedPath, offset,
|
|
181
182
|
total: matching.length, nextOffset: next < matching.length ? next : null,
|
|
@@ -191,17 +192,17 @@ export class PaWorkspaceItemsIndex {
|
|
|
191
192
|
}
|
|
192
193
|
return response;
|
|
193
194
|
}
|
|
194
|
-
get(
|
|
195
|
-
const key = crypto.createHash('sha256').update(JSON.stringify([
|
|
196
|
-
state.workspaceId, this.store.root(state), state.navigationRevision, state.entries])).digest('hex');
|
|
197
|
-
let index = this.indexes.get(
|
|
195
|
+
get(agentAid, state) {
|
|
196
|
+
const key = crypto.createHash('sha256').update(JSON.stringify([agentAid, state.ownerAid,
|
|
197
|
+
state.workspaceId, this.store.root(state), this.store.outputRoot(state), state.navigationRevision, state.entries])).digest('hex');
|
|
198
|
+
let index = this.indexes.get(agentAid);
|
|
198
199
|
if (!index || index.key !== key) {
|
|
199
200
|
if (index)
|
|
200
201
|
this.release(index);
|
|
201
|
-
index = { key,
|
|
202
|
+
index = { key, agentAid, state, revision: crypto.randomBytes(12).toString('hex'), items: new Map(),
|
|
202
203
|
sorted: [], truncated: false, scannedAt: 0, dirty: new Set(), rescan: true, closed: false,
|
|
203
204
|
previewRequests: new Map(), previewQueue: [], activePreviews: 0 };
|
|
204
|
-
this.indexes.set(
|
|
205
|
+
this.indexes.set(agentAid, index);
|
|
205
206
|
// Disk is only a parse memo. Always reconcile directories before serving
|
|
206
207
|
// it after restart; navigationRevision does not version file contents.
|
|
207
208
|
try {
|
|
@@ -230,8 +231,8 @@ export class PaWorkspaceItemsIndex {
|
|
|
230
231
|
clearTimeout(index.idle);
|
|
231
232
|
index.idle = setTimeout(() => {
|
|
232
233
|
this.release(index);
|
|
233
|
-
if (this.indexes.get(
|
|
234
|
-
this.indexes.delete(
|
|
234
|
+
if (this.indexes.get(agentAid) === index)
|
|
235
|
+
this.indexes.delete(agentAid);
|
|
235
236
|
}, IDLE_MS);
|
|
236
237
|
index.idle.unref();
|
|
237
238
|
// Bound watcher count even on a host with many PAs.
|
|
@@ -239,14 +240,14 @@ export class PaWorkspaceItemsIndex {
|
|
|
239
240
|
const oldest = [...this.indexes.values()].find(candidate => candidate !== index && !candidate.pending);
|
|
240
241
|
if (oldest) {
|
|
241
242
|
this.release(oldest);
|
|
242
|
-
this.indexes.delete(oldest.
|
|
243
|
+
this.indexes.delete(oldest.agentAid);
|
|
243
244
|
}
|
|
244
245
|
}
|
|
245
246
|
return index;
|
|
246
247
|
}
|
|
247
|
-
cachePath(index) { return path.join(agentDataDir(index.
|
|
248
|
+
cachePath(index) { return path.join(agentDataDir(index.agentAid), 'team-workspace-items-v1.json'); }
|
|
248
249
|
persist(index) {
|
|
249
|
-
if (index.closed || this.indexes.get(index.
|
|
250
|
+
if (index.closed || this.indexes.get(index.agentAid) !== index)
|
|
250
251
|
return;
|
|
251
252
|
try {
|
|
252
253
|
atomicWriteText(this.cachePath(index), JSON.stringify({ version: 1, key: index.key, items: index.sorted }));
|
|
@@ -265,18 +266,18 @@ export class PaWorkspaceItemsIndex {
|
|
|
265
266
|
index.activePreviews++;
|
|
266
267
|
void (async () => {
|
|
267
268
|
if (index.closed)
|
|
268
|
-
throw new DataRootError('WORKSPACE_CHANGED', '
|
|
269
|
+
throw new DataRootError('WORKSPACE_CHANGED', 'Team workspace index was replaced');
|
|
269
270
|
let resolved;
|
|
270
271
|
try {
|
|
271
272
|
resolved = this.store.resolvePath(index.state, item.path);
|
|
272
273
|
}
|
|
273
274
|
catch {
|
|
274
275
|
index.dirty.add(item.path);
|
|
275
|
-
throw new DataRootError('INDEX_CHANGED', '
|
|
276
|
+
throw new DataRootError('INDEX_CHANGED', 'Team workspace file changed during preview read');
|
|
276
277
|
}
|
|
277
278
|
if (resolved.realPath !== item.realPath || signature(resolved.stat) !== item.signature) {
|
|
278
279
|
index.dirty.add(item.path);
|
|
279
|
-
throw new DataRootError('INDEX_CHANGED', '
|
|
280
|
+
throw new DataRootError('INDEX_CHANGED', 'Team workspace file changed during preview read');
|
|
280
281
|
}
|
|
281
282
|
try {
|
|
282
283
|
item.previewSource = await preview(resolved.realPath, item.size);
|
|
@@ -304,41 +305,54 @@ export class PaWorkspaceItemsIndex {
|
|
|
304
305
|
index.previewQueue.shift()();
|
|
305
306
|
}
|
|
306
307
|
observe(index) {
|
|
307
|
-
const
|
|
308
|
-
const
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
|
|
308
|
+
const workspaceRoot = this.store.root(index.state);
|
|
309
|
+
const outputRoot = this.store.outputRoot(index.state);
|
|
310
|
+
const roots = [
|
|
311
|
+
{ root: workspaceRoot, output: false },
|
|
312
|
+
...(outputRoot && outputRoot !== workspaceRoot ? [{ root: outputRoot, output: true }] : []),
|
|
313
|
+
];
|
|
314
|
+
index.watchers = roots.map(({ root, output }) => {
|
|
315
|
+
const allowed = index.state.entries.filter(entry => entry.availability !== 'unavailable'
|
|
316
|
+
&& (output ? entry.path === 'output' || entry.path.startsWith('output/') : !outputRoot || entry.path !== 'output' && !entry.path.startsWith('output/')));
|
|
317
|
+
const logicalPath = (relative) => output
|
|
318
|
+
? relative ? `output/${relative}` : 'output'
|
|
319
|
+
: relative;
|
|
320
|
+
const watcher = watch(root, {
|
|
321
|
+
persistent: false, ignoreInitial: true, followSymlinks: false,
|
|
322
|
+
ignored: absolute => {
|
|
323
|
+
const relative = path.relative(root, absolute).split(path.sep).join('/');
|
|
324
|
+
const logical = logicalPath(relative);
|
|
325
|
+
return relative !== '' && (isTeamHiddenPath(logical) || !allowed.some(entry => within(logical, entry.path) || entry.kind === 'directory' && within(entry.path, logical)));
|
|
326
|
+
},
|
|
327
|
+
});
|
|
328
|
+
watcher.on('all', (event, absolute) => {
|
|
329
|
+
if (index.closed)
|
|
330
|
+
return;
|
|
312
331
|
const relative = path.relative(root, absolute).split(path.sep).join('/');
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
clearTimeout(index.timer);
|
|
326
|
-
index.timer = setTimeout(() => { void this.refresh(index).catch(() => { index.rescan = true; }); }, 75);
|
|
327
|
-
index.timer.unref();
|
|
332
|
+
const logical = logicalPath(relative);
|
|
333
|
+
if (event === 'addDir' || event === 'unlinkDir')
|
|
334
|
+
index.rescan = true;
|
|
335
|
+
else if (published(index.state, logical))
|
|
336
|
+
index.dirty.add(logical);
|
|
337
|
+
clearTimeout(index.timer);
|
|
338
|
+
index.timer = setTimeout(() => { void this.refresh(index).catch(() => { index.rescan = true; }); }, 75);
|
|
339
|
+
index.timer.unref();
|
|
340
|
+
});
|
|
341
|
+
watcher.on('ready', () => { index.rescan = true; });
|
|
342
|
+
watcher.on('error', () => { index.rescan = true; });
|
|
343
|
+
return watcher;
|
|
328
344
|
});
|
|
329
|
-
watcher.on('ready', () => { index.rescan = true; });
|
|
330
|
-
watcher.on('error', () => { index.rescan = true; });
|
|
331
345
|
}
|
|
332
346
|
refresh(index) {
|
|
333
347
|
try {
|
|
334
348
|
if (index.closed)
|
|
335
|
-
throw new DataRootError('WORKSPACE_CHANGED', '
|
|
336
|
-
this.assertCurrent(index.
|
|
349
|
+
throw new DataRootError('WORKSPACE_CHANGED', 'Team workspace index was replaced');
|
|
350
|
+
this.assertCurrent(index.agentAid, index.state);
|
|
337
351
|
}
|
|
338
352
|
catch (error) {
|
|
339
353
|
this.release(index);
|
|
340
|
-
if (this.indexes.get(index.
|
|
341
|
-
this.indexes.delete(index.
|
|
354
|
+
if (this.indexes.get(index.agentAid) === index)
|
|
355
|
+
this.indexes.delete(index.agentAid);
|
|
342
356
|
return Promise.reject(error);
|
|
343
357
|
}
|
|
344
358
|
if (index.pending)
|
|
@@ -352,7 +366,7 @@ export class PaWorkspaceItemsIndex {
|
|
|
352
366
|
if (!index.rescan && !index.dirty.size)
|
|
353
367
|
return;
|
|
354
368
|
}
|
|
355
|
-
throw new DataRootError('INDEX_CHANGED', '
|
|
369
|
+
throw new DataRootError('INDEX_CHANGED', 'Team workspace items are changing; retry the first page');
|
|
356
370
|
})().catch(error => { index.rescan = true; throw error; })
|
|
357
371
|
.finally(() => { index.pending = undefined; });
|
|
358
372
|
return index.pending;
|
|
@@ -471,7 +485,8 @@ export class PaWorkspaceItemsIndex {
|
|
|
471
485
|
index.closed = true;
|
|
472
486
|
clearTimeout(index.timer);
|
|
473
487
|
clearTimeout(index.idle);
|
|
474
|
-
|
|
488
|
+
for (const watcher of index.watchers ?? [])
|
|
489
|
+
void watcher.close();
|
|
475
490
|
}
|
|
476
491
|
async close() {
|
|
477
492
|
const indexes = [...this.indexes.values()];
|
|
@@ -480,7 +495,7 @@ export class PaWorkspaceItemsIndex {
|
|
|
480
495
|
this.indexes.clear();
|
|
481
496
|
await Promise.all(indexes.map(index => index.pending?.catch(() => { })));
|
|
482
497
|
await Promise.all(indexes.flatMap(index => [...index.previewRequests.values()].map(request => request.catch(() => { }))));
|
|
483
|
-
await Promise.all(indexes.
|
|
498
|
+
await Promise.all(indexes.flatMap(index => (index.watchers ?? []).map(watcher => watcher.close())));
|
|
484
499
|
}
|
|
485
500
|
}
|
|
486
|
-
export const
|
|
501
|
+
export const teamWorkspaceItemsIndex = new TeamWorkspaceItemsIndex();
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import crypto from 'node:crypto';
|
|
3
|
+
import { agentDataDir } from '../../paths.js';
|
|
4
|
+
import { atomicReadJson, atomicWriteJson } from '../../utils/atomic-write.js';
|
|
5
|
+
import { isValidAid } from '../../aun/aid/validation.js';
|
|
6
|
+
export class TeamWorkspaceJobError extends Error {
|
|
7
|
+
code;
|
|
8
|
+
constructor(code, message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.name = 'TeamWorkspaceJobError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const JOB_FILE = 'team-workspace-jobs-v1.json';
|
|
15
|
+
const JOB_TTL_MS = 24 * 60 * 60 * 1000;
|
|
16
|
+
function jobPath(agentAid) { return path.join(agentDataDir(agentAid), JOB_FILE); }
|
|
17
|
+
export class TeamWorkspaceJobStore {
|
|
18
|
+
now;
|
|
19
|
+
constructor(now = () => Date.now()) {
|
|
20
|
+
this.now = now;
|
|
21
|
+
}
|
|
22
|
+
create(input) {
|
|
23
|
+
if (!isValidAid(input.agentAid) || !isValidAid(input.ownerAid) || !isValidAid(input.principalId)) {
|
|
24
|
+
throw new TeamWorkspaceJobError('INVALID_ARGUMENT', 'Invalid Team workspace job identity');
|
|
25
|
+
}
|
|
26
|
+
const now = this.now();
|
|
27
|
+
const jobs = this.readAll(input.agentAid).filter(job => job.expiresAt > now);
|
|
28
|
+
const existing = jobs.find(job => job.operationId === input.operationId);
|
|
29
|
+
if (existing) {
|
|
30
|
+
if (existing.fingerprint !== input.fingerprint || existing.principalId !== input.principalId) {
|
|
31
|
+
throw new TeamWorkspaceJobError('OPERATION_ID_REUSED', 'operationId was already used with different arguments');
|
|
32
|
+
}
|
|
33
|
+
return existing;
|
|
34
|
+
}
|
|
35
|
+
const job = {
|
|
36
|
+
...input,
|
|
37
|
+
jobId: `teamj_${crypto.randomBytes(18).toString('base64url')}`,
|
|
38
|
+
status: 'accepted', progress: 0, createdAt: now, updatedAt: now, expiresAt: now + JOB_TTL_MS,
|
|
39
|
+
};
|
|
40
|
+
this.writeAll(input.agentAid, [...jobs, job]);
|
|
41
|
+
return job;
|
|
42
|
+
}
|
|
43
|
+
update(agentAid, jobId, patch) {
|
|
44
|
+
const jobs = this.readAll(agentAid);
|
|
45
|
+
const index = jobs.findIndex(job => job.jobId === jobId);
|
|
46
|
+
if (index < 0)
|
|
47
|
+
throw new TeamWorkspaceJobError('JOB_EXPIRED', 'Team workspace job is no longer available');
|
|
48
|
+
const job = { ...jobs[index], ...patch, updatedAt: this.now() };
|
|
49
|
+
jobs[index] = job;
|
|
50
|
+
this.writeAll(agentAid, jobs);
|
|
51
|
+
return job;
|
|
52
|
+
}
|
|
53
|
+
get(agentAid, jobId, principalId) {
|
|
54
|
+
const job = this.readAll(agentAid).find(candidate => candidate.jobId === jobId);
|
|
55
|
+
if (!job || job.expiresAt <= this.now())
|
|
56
|
+
throw new TeamWorkspaceJobError('JOB_EXPIRED', 'Team workspace job is no longer available');
|
|
57
|
+
if (job.principalId !== principalId)
|
|
58
|
+
throw new TeamWorkspaceJobError('FORBIDDEN', 'Team workspace job belongs to another principal');
|
|
59
|
+
return job;
|
|
60
|
+
}
|
|
61
|
+
readAll(agentAid) {
|
|
62
|
+
try {
|
|
63
|
+
const value = atomicReadJson(jobPath(agentAid));
|
|
64
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
65
|
+
return [];
|
|
66
|
+
const jobs = value.jobs;
|
|
67
|
+
return Array.isArray(jobs) ? jobs.filter(job => this.validJob(job)) : [];
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
writeAll(agentAid, jobs) {
|
|
74
|
+
atomicWriteJson(jobPath(agentAid), { version: 1, jobs: jobs.slice(-100) });
|
|
75
|
+
}
|
|
76
|
+
validJob(value) {
|
|
77
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
78
|
+
return false;
|
|
79
|
+
const job = value;
|
|
80
|
+
return typeof job.jobId === 'string' && typeof job.operationId === 'string'
|
|
81
|
+
&& typeof job.fingerprint === 'string' && isValidAid(String(job.agentAid))
|
|
82
|
+
&& isValidAid(String(job.ownerAid)) && isValidAid(String(job.principalId))
|
|
83
|
+
&& job.type === 'initialize'
|
|
84
|
+
&& ['accepted', 'running', 'succeeded', 'failed', 'expired'].includes(String(job.status))
|
|
85
|
+
&& Number.isFinite(job.createdAt) && Number.isFinite(job.updatedAt) && Number.isFinite(job.expiresAt);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export const teamWorkspaceJobStore = new TeamWorkspaceJobStore();
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Public Phase 2 entry point; kept separate for App/Core integration imports. */
|
|
2
|
+
export { TeamWorkspaceManagementService, TEAM_WORKSPACE_MANAGEMENT_PROTOCOL, TEAM_WORKSPACE_MANAGEMENT_VERSION, scanWorkspaceStatistics, teamWorkspaceManagementService, } from './team-workspace-management.js';
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import crypto from 'node:crypto';
|
|
4
|
+
import { agentDataDir } from '../../paths.js';
|
|
5
|
+
import { atomicReadJson, atomicWriteJson } from '../../utils/atomic-write.js';
|
|
6
|
+
import { isValidAid } from '../../aun/aid/validation.js';
|
|
7
|
+
const STATE_FILE = 'team-workspace-management-v1.json';
|
|
8
|
+
function statePath(agentAid) {
|
|
9
|
+
return path.join(agentDataDir(agentAid), STATE_FILE);
|
|
10
|
+
}
|
|
11
|
+
export class TeamWorkspaceManagementStore {
|
|
12
|
+
read(agentAid) {
|
|
13
|
+
if (!isValidAid(agentAid))
|
|
14
|
+
return null;
|
|
15
|
+
let value;
|
|
16
|
+
try {
|
|
17
|
+
value = atomicReadJson(statePath(agentAid));
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
23
|
+
return null;
|
|
24
|
+
const record = value;
|
|
25
|
+
if (record.version !== 1 || record.agentAid !== agentAid || typeof record.ownerAid !== 'string'
|
|
26
|
+
|| !['unconfigured', 'initializing', 'ready', 'failed', 'unavailable'].includes(String(record.status))
|
|
27
|
+
|| !Number.isSafeInteger(record.attempts) || !Number.isFinite(record.updatedAt))
|
|
28
|
+
return null;
|
|
29
|
+
return {
|
|
30
|
+
version: 1,
|
|
31
|
+
agentAid,
|
|
32
|
+
ownerAid: record.ownerAid,
|
|
33
|
+
status: record.status,
|
|
34
|
+
attempts: Number(record.attempts),
|
|
35
|
+
...(Number.isFinite(record.createdAt) ? { createdAt: Number(record.createdAt) } : {}),
|
|
36
|
+
...(Number.isFinite(record.boundAt) ? { boundAt: Number(record.boundAt) } : {}),
|
|
37
|
+
updatedAt: Number(record.updatedAt),
|
|
38
|
+
...(typeof record.activeJobId === 'string' ? { activeJobId: record.activeJobId } : {}),
|
|
39
|
+
...(record.lastError && typeof record.lastError === 'object' && !Array.isArray(record.lastError)
|
|
40
|
+
? { lastError: {
|
|
41
|
+
code: String(record.lastError.code || 'INITIALIZE_FAILED'),
|
|
42
|
+
message: String(record.lastError.message || 'Workspace initialization failed'),
|
|
43
|
+
retryable: record.lastError.retryable !== false,
|
|
44
|
+
} }
|
|
45
|
+
: {}),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
ensure(agentAid, ownerAid, now = Date.now()) {
|
|
49
|
+
const current = this.read(agentAid);
|
|
50
|
+
if (current && current.ownerAid === ownerAid)
|
|
51
|
+
return current;
|
|
52
|
+
const next = {
|
|
53
|
+
version: 1, agentAid, ownerAid, status: 'unconfigured', attempts: 0, updatedAt: now,
|
|
54
|
+
};
|
|
55
|
+
this.write(agentAid, next);
|
|
56
|
+
return next;
|
|
57
|
+
}
|
|
58
|
+
update(agentAid, patch, now = Date.now()) {
|
|
59
|
+
const current = this.read(agentAid);
|
|
60
|
+
if (!current)
|
|
61
|
+
throw new Error(`Team workspace management state is unavailable: ${agentAid}`);
|
|
62
|
+
const next = { ...current, ...patch, updatedAt: now, version: 1, agentAid };
|
|
63
|
+
this.write(agentAid, next);
|
|
64
|
+
return next;
|
|
65
|
+
}
|
|
66
|
+
write(agentAid, value) {
|
|
67
|
+
atomicWriteJson(statePath(agentAid), value);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export const teamWorkspaceManagementStore = new TeamWorkspaceManagementStore();
|
|
71
|
+
export function workspaceMarkerPath(rootPath) {
|
|
72
|
+
return path.join(rootPath, '.workspace', 'marker.json');
|
|
73
|
+
}
|
|
74
|
+
export function readWorkspaceMarker(rootPath) {
|
|
75
|
+
try {
|
|
76
|
+
const value = JSON.parse(fs.readFileSync(workspaceMarkerPath(rootPath), 'utf8'));
|
|
77
|
+
if (value.schemaVersion !== 1 || !isValidAid(String(value.agentAid)) || !isValidAid(String(value.ownerAid))
|
|
78
|
+
|| value.workspaceVersion !== 1 || !Number.isFinite(value.createdAt) || value.initializedBy !== 'evolcore')
|
|
79
|
+
return null;
|
|
80
|
+
return {
|
|
81
|
+
schemaVersion: 1,
|
|
82
|
+
agentAid: String(value.agentAid),
|
|
83
|
+
ownerAid: String(value.ownerAid),
|
|
84
|
+
workspaceVersion: 1,
|
|
85
|
+
createdAt: Number(value.createdAt),
|
|
86
|
+
initializedBy: 'evolcore',
|
|
87
|
+
...(typeof value.workspaceId === 'string' ? { workspaceId: value.workspaceId } : {}),
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export function newOpaqueWorkspaceId() {
|
|
95
|
+
return `tw1_${crypto.randomBytes(18).toString('base64url')}`;
|
|
96
|
+
}
|