@skaile/forge-layer-workspace-agent 0.0.0-stage → 0.1.0
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 +7 -0
- package/LICENSE +21 -0
- package/README.md +157 -2
- package/app/app.config.ts +5 -0
- package/app/components/WorkspaceAgentRuns.vue +220 -0
- package/app/composables/useWorkspaceAgent.ts +6 -0
- package/app/pages/inbox.vue +290 -0
- package/app/plugins/workspace-agent-settings.ts +15 -0
- package/app/utils/workspaceBackend.ts +82 -0
- package/chat-backend.ts +25 -0
- package/nuxt.config.ts +28 -0
- package/package.json +52 -4
- package/server/api/workspace-agent/threads/[id]/events.get.ts +31 -0
- package/server/middleware/workspace-agent-mcp-log.ts +35 -0
- package/server/plugins/workspace-agent.ts +44 -0
- package/server/utils/workspace-agent/actions.ts +328 -0
- package/server/utils/workspace-agent/availability.ts +285 -0
- package/server/utils/workspace-agent/definition.ts +79 -0
- package/server/utils/workspace-agent/errors.ts +9 -0
- package/server/utils/workspace-agent/inbox.ts +444 -0
- package/server/utils/workspace-agent/role.ts +40 -0
- package/server/utils/workspace-agent/sessions.ts +445 -0
- package/server/utils/workspace-agent/threads.ts +102 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @skaile/forge-layer-workspace-agent
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 064fbe0: New package: the workspace-agent layer of forge-template-app as a versioned Nuxt layer (`extends: ['@skaile/forge-layer-workspace-agent']`) instead of a copy in each app. A SKAILE workspace agent (`skaile serve`) per conversation acting through the app's `/mcp` with a per-run agent token, the Agent Inbox (`inbox.*` actions, `/inbox` page) and the Settings › Agents card; registers the `workspace` chat backend when `@skaile/forge-layer-chat` is present. The agent definition stays in the app (`agents/app-assistant/`). Host contract in the README.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Matthias Ortegro
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,158 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @skaile/forge-layer-workspace-agent
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Nuxt layer for apps built on [forge-template-app](https://github.com/skaile-ai/forge/tree/main/templates/app):
|
|
4
|
+
a SKAILE workspace agent per conversation, plus the Agent Inbox where agents ask their person before anything
|
|
5
|
+
destructive. It ships as source; the app `extends` it and keeps the agent definition in `agents/app-assistant/`.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
bun add @skaile/forge-layer-workspace-agent @skaile/forge-agent-runtime @skaile/forge-agent-inbox @skaile/workspaces
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
// nuxt.config.ts
|
|
15
|
+
export default defineNuxtConfig({
|
|
16
|
+
extends: ['@skaile/forge-layer-workspace-agent'],
|
|
17
|
+
})
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```css
|
|
21
|
+
/* app/assets/css/main.css: Tailwind skips node_modules, so name the layer's sources */
|
|
22
|
+
@source "../../../node_modules/@skaile/forge-layer-workspace-agent/app";
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Remove the `extends` entry (and the `@source` line and `agents/app-assistant/`) to drop it; the app does not import from the layer.
|
|
26
|
+
|
|
27
|
+
## Host contract
|
|
28
|
+
|
|
29
|
+
The layer runs on the core of forge-template-app and uses these parts of it by name. An app copied from the template
|
|
30
|
+
has all of them; an app that renamed or removed one overrides the layer file that uses it.
|
|
31
|
+
|
|
32
|
+
| Kind | Used | Where in the template |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| Server imports (`~~/`) | `server/db/schema` (`apiTokens`, `notifications`, `chatThreads`, `chatMessages`), `server/utils/actions/define` (`defineAppAction`), `server/utils/actions/registry` (`registerActions`, `allActions`, `findAction`, `runAction`), `server/utils/ai/roles` (`registerModelRole`, `resolveRoleModel`, `RoleNotConfigured`, `RoleCheck`), `server/utils/auth` (`requirePrincipal`), `server/utils/db` (`useDb`, `withTx`, `dbReady`, `onBeforeDatabaseClose`), `server/utils/principal` (`requireRole`, `requireScope`, `Principal`), `server/utils/tokens` (`createApiToken`, `hashApiToken`, `revokeApiToken`), `shared/domain` (`SCOPE_PATTERN`) | `server/`, `shared/` |
|
|
35
|
+
| Composables, utils | `useActions`, `actionErrorMessage`, `useDates`, `useMe` | `app/composables/` |
|
|
36
|
+
| Components | `AppHeader` | `app/components/` |
|
|
37
|
+
| Shell | hook `app-shell:extend` (`shell.settingsSections`), `appShell.nav` (adds Inbox, order 55) | `app/types/app-shell.d.ts`, `app/app.config.ts` |
|
|
38
|
+
| Actions | `ai.status` (role `agent`), `tokens.list`, `tokens.revoke` | `server/utils/actions/` |
|
|
39
|
+
| Agent definition | `agents/app-assistant/` (`agent.yaml`, `SOUL.md`, `RULES.md`; `metadata.app_scopes`, `metadata.idle_minutes`) | repo root |
|
|
40
|
+
| Chat backend | `registerAssistantBackend` from `@skaile/forge-layer-chat` (optional: without it no backend plugin is generated) | |
|
|
41
|
+
|
|
42
|
+
Peers: `nuxt ^4`, `@nuxt/ui ^4.11`, `vue ^3.5`, `@skaile/forge-agent-runtime ^1.4`, `@skaile/forge-agent-inbox ^2`,
|
|
43
|
+
`@skaile/forge-app-actions ^0.6`, `@skaile/forge-chat ^0.6`, `@skaile/forge-settings ^2`, `@skaile/workspaces ^10.3`,
|
|
44
|
+
`zod ^4`, `drizzle-orm ^0.45`, `postgres ^4`, `h3 ^1.15`.
|
|
45
|
+
|
|
46
|
+
## What it adds
|
|
47
|
+
|
|
48
|
+
| Piece | Where |
|
|
49
|
+
|---|---|
|
|
50
|
+
| Agent definition (`agent.yaml`, `SOUL.md`, `RULES.md`) | `agents/app-assistant/` (repo root) |
|
|
51
|
+
| Actions `workspaceAgent.*` (status: run token scopes, idle minutes, inbox store; threads, prompt/abort/reply/history, sessions, stop) | `server/utils/workspace-agent/actions.ts` |
|
|
52
|
+
| Actions `inbox.*`: `inbox.ask`, `inbox.status`, `inbox.list` (agents, audience `llm`, also on `/mcp`); `inbox.requests`, `inbox.answer`, `inbox.decline` (people) | same file |
|
|
53
|
+
| Run lifecycle, availability, model role `agent` | `server/utils/workspace-agent/sessions.ts`, `availability.ts`, `role.ts` |
|
|
54
|
+
| Live events (SSE) | `GET /api/workspace-agent/threads/:id/events` |
|
|
55
|
+
| `/mcp` call log per run | `server/middleware/workspace-agent-mcp-log.ts` |
|
|
56
|
+
| Inbox page (nav order 55) | `app/pages/inbox.vue` |
|
|
57
|
+
| Settings › Agents card "Workspace agent" (model and checks of the role `agent`, running sessions with Stop, agent tokens with Revoke); the page is core | `app/plugins/workspace-agent-settings.ts`, `app/components/WorkspaceAgentRuns.vue` |
|
|
58
|
+
| Chat panel backend `workspace` | `app/utils/workspaceBackend.ts`, registered by `chat-backend.ts` |
|
|
59
|
+
|
|
60
|
+
## Overrides
|
|
61
|
+
|
|
62
|
+
A Nuxt layer is overridden piece by piece; the app's piece wins, the rest keeps coming from the package, so fixes in
|
|
63
|
+
the other files still arrive with updates:
|
|
64
|
+
|
|
65
|
+
- a component: a file with the same name in the app's `app/components/` (`WorkspaceAgentRuns` too: the settings plugin
|
|
66
|
+
registers it by name)
|
|
67
|
+
- a page: a page at the same route in the app's `app/pages/`
|
|
68
|
+
- an auto-imported composable or util: an export with the same name in the app's `app/composables/` or `app/utils/`
|
|
69
|
+
(override the whole file: the app's file replaces every export of that name)
|
|
70
|
+
- `app/app.config.ts`: the app's own `app.config.ts` is merged over the layer's, so set only the keys you change.
|
|
71
|
+
Arrays such as `appShell.nav` are joined, the app's entries first; an app entry with the same `to` replaces the
|
|
72
|
+
layer's when the app's `useAppShell` keeps the first entry per route, as forge-template-app's does
|
|
73
|
+
(`firstPerRoute`), e.g. `{ label: 'Inbox', icon: 'i-lucide-inbox', to: '/inbox', order: 20 }`
|
|
74
|
+
|
|
75
|
+
Server code (`server/`) and `shared/` are imported by path inside the package and cannot be overridden this way; a
|
|
76
|
+
change there belongs in the package.
|
|
77
|
+
|
|
78
|
+
## Runtime
|
|
79
|
+
|
|
80
|
+
In-process `createAgentRunner` from `@skaile/forge-agent-runtime/app-runner-host`.
|
|
81
|
+
No extra service is needed:
|
|
82
|
+
|
|
83
|
+
- Each run spawns `skaile serve --harness omp` (the CLI from
|
|
84
|
+
`node_modules/@skaile/workspaces`). It binds to `127.0.0.1` with a fresh
|
|
85
|
+
WebSocket token, runs in a private scratch workspace under
|
|
86
|
+
`.data/workspace-agent/runs/<id>` (`WORKSPACE_AGENT_RUNS_DIR`), and gets its own HOME.
|
|
87
|
+
Its only tools are the app's `/mcp` endpoint: no shell, files or web.
|
|
88
|
+
- Each run mints an `agent`-kind API token for the person who started it. The
|
|
89
|
+
token carries exactly the scopes in `agent.yaml` `metadata.app_scopes`
|
|
90
|
+
(`projects:read`, `tasks:write`, `inbox:write`) and is passed to the run as
|
|
91
|
+
the `/mcp` bearer. The token is revoked when the run stops, ends, fails to
|
|
92
|
+
start or idles out (`metadata.idle_minutes`), and on shutdown
|
|
93
|
+
(`onBeforeDatabaseClose`). Tokens a crashed process left behind are revoked
|
|
94
|
+
on the next boot.
|
|
95
|
+
- The run reaches `/mcp` at `WORKSPACE_AGENT_APP_URL` (set it in Docker or behind
|
|
96
|
+
a proxy). Without it the run uses `http://localhost:$PORT`; `localhost`
|
|
97
|
+
because `nuxt dev` listens on `[::1]` only. The URL never comes from a request.
|
|
98
|
+
- The model is the model role `agent` (`chat`, registered by `server/plugins/workspace-agent.ts`),
|
|
99
|
+
chosen in Settings › Harness like the chat layer's `assistant`. `resolveRoleModel('agent')`
|
|
100
|
+
gives the registry entry assigned there; the runner gets the registry narrowed
|
|
101
|
+
to that entry, and its key reaches the child only through `registryCredentialEnv`
|
|
102
|
+
(`env:AI_PROVIDER_<NAME>`). Unassigned, the `NUXT_AI_BASE_URL`, `NUXT_AI_API_KEY`,
|
|
103
|
+
`NUXT_AI_MODEL` fallback (OpenAI-compatible, all three needed for the child)
|
|
104
|
+
becomes a one-entry registry (`app/<model>`) with `env:NUXT_AI_API_KEY`.
|
|
105
|
+
- The `omp` harness must be on PATH (`@oh-my-pi/pi-coding-agent`, runs under
|
|
106
|
+
Bun ≥ 1.4.4). A production build ships `@skaile/workspaces` traced, without a
|
|
107
|
+
runnable CLI; the runner (`@skaile/forge-agent-runtime` ≥ 1.2.3) then uses
|
|
108
|
+
`skaile` on PATH. The default Docker image has neither; build the `agent`
|
|
109
|
+
target (`docker build --target agent .`, compose: `APP_TARGET=agent`): it adds
|
|
110
|
+
Bun, `omp`, `agents/` and `skaile-cli` at the app's `@skaile/workspaces` version.
|
|
111
|
+
|
|
112
|
+
Disabled cleanly: when the model, `skaile` CLI, `omp`, a valid agent
|
|
113
|
+
definition or the MCP URL is missing, the role `agent` of `ai.status` is
|
|
114
|
+
unavailable and says why. Settings › Agents lists the checks in the agent's card
|
|
115
|
+
(details for owners only), the chat backend shows the reason, a prompt is
|
|
116
|
+
refused with 503, and the rest of the app is unaffected.
|
|
117
|
+
|
|
118
|
+
## Agent Inbox
|
|
119
|
+
|
|
120
|
+
`@skaile/forge-agent-inbox` operations over one store:
|
|
121
|
+
|
|
122
|
+
- `DATABASE_URL` set: the PostgreSQL store in its own schema `agent_inbox`,
|
|
123
|
+
migrated on first use.
|
|
124
|
+
- Local (PGlite): the JSON file store under `.data/agent-inbox`
|
|
125
|
+
(`AGENT_INBOX_DIR`). PGlite is single-process and the package's postgres
|
|
126
|
+
store needs a `pg`-style pool, so local mode uses the file store.
|
|
127
|
+
|
|
128
|
+
Identities: the recipient is the app user behind the calling token, and the
|
|
129
|
+
asking agent is that token (`principal.tokenId`). An agent token therefore sees
|
|
130
|
+
only its own requests. Every new request also writes a notification for the
|
|
131
|
+
person.
|
|
132
|
+
|
|
133
|
+
Approvals: `inbox.ask` may carry a proposed `action` (`id` + `input`). It must
|
|
134
|
+
be an effect action whose input already validates, e.g. `{ id: 'data.delete',
|
|
135
|
+
input: { entity: 'tasks', id } }`. The id may also be the tool name the agent saw
|
|
136
|
+
or guessed (`mcp__app__app_data_delete`). On **Approve** the app runs
|
|
137
|
+
the action with the person's own principal, then reports the result back to the
|
|
138
|
+
agent's conversation as an `[Inbox]` message. On **Decline** nothing runs.
|
|
139
|
+
Destructive actions stay `audience: ['user']`, so the agent can only propose
|
|
140
|
+
them.
|
|
141
|
+
|
|
142
|
+
## Chat integration
|
|
143
|
+
|
|
144
|
+
With `@skaile/forge-layer-chat` present, `nuxt.config.ts` generates a client plugin that
|
|
145
|
+
registers backend `workspace`. Its transport is `createSkaileTransport` over a
|
|
146
|
+
host-written link: SSE for live events, `workspaceAgent.prompt|abort|reply`
|
|
147
|
+
for sending and `workspaceAgent.history` for replay. Events are persisted to the
|
|
148
|
+
thread (`transport: 'workspace'`). Without the chat layer no plugin is
|
|
149
|
+
generated (`chatBackendPlugin` returns `null`).
|
|
150
|
+
|
|
151
|
+
## Tests
|
|
152
|
+
|
|
153
|
+
The layer needs the host's database and actions, so its tests live in the template
|
|
154
|
+
(`templates/app/test/workspace-agent.test.ts`: availability reasons, the run token (exact scopes, revocation on stop,
|
|
155
|
+
end and shutdown), the inbox lifecycle (ask -> answer -> agent reads it, approve/decline of proposals, tool-name
|
|
156
|
+
proposals) and the guarded backend registration; the runner is faked, no model is called) and run against the
|
|
157
|
+
installed package. `bun scripts/check-templates.ts --local app` checks an unpublished change of this package against
|
|
158
|
+
the template.
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { TableColumn } from '@nuxt/ui'
|
|
3
|
+
import { h } from 'vue'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The workspace agent's content in its Settings › Agents card (pushed by this
|
|
7
|
+
* layer's plugin): what each run gets (token scopes, idle stop, Agent Inbox
|
|
8
|
+
* store), the live runs with Stop and the agent tokens with Revoke. The core
|
|
9
|
+
* card shows the model and the checks of the role `agent` above it.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const agent = useWorkspaceAgentActions()
|
|
13
|
+
const core = useActions()
|
|
14
|
+
const toast = useToast()
|
|
15
|
+
const { formatDateTime } = useDates()
|
|
16
|
+
const { data: me } = await useMe()
|
|
17
|
+
const isOwner = computed(() => me.value?.user?.role === 'owner')
|
|
18
|
+
|
|
19
|
+
const { data: status, refresh: refreshStatus } = await useAsyncData('agents:status', () =>
|
|
20
|
+
agent.call('workspaceAgent.status', {}),
|
|
21
|
+
)
|
|
22
|
+
const { data: sessions, refresh: refreshSessions } = await useAsyncData('agents:sessions', () =>
|
|
23
|
+
agent.call('workspaceAgent.sessions.list', { all: isOwner.value }),
|
|
24
|
+
)
|
|
25
|
+
const { data: tokens, refresh: refreshTokens } = await useAsyncData('agents:tokens', () =>
|
|
26
|
+
core.call('tokens.list', { all: isOwner.value }),
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
type SessionRow = NonNullable<typeof sessions.value>['items'][number]
|
|
30
|
+
type TokenRow = NonNullable<typeof tokens.value>['items'][number]
|
|
31
|
+
|
|
32
|
+
const agentTokens = computed(() => (tokens.value?.items ?? []).filter(token => token.kind === 'agent'))
|
|
33
|
+
const liveTokenIds = computed(() => new Set((sessions.value?.items ?? []).map(session => session.tokenId)))
|
|
34
|
+
|
|
35
|
+
function tokenActive(token: TokenRow) {
|
|
36
|
+
return !token.revokedAt && (!token.expiresAt || new Date(token.expiresAt) > new Date())
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function refreshAll() {
|
|
40
|
+
await Promise.all([refreshStatus(), refreshSessions(), refreshTokens()])
|
|
41
|
+
}
|
|
42
|
+
const poll = useIntervalFn(() => void Promise.all([refreshSessions(), refreshTokens()]), 15_000)
|
|
43
|
+
onBeforeUnmount(poll.pause)
|
|
44
|
+
|
|
45
|
+
const busy = ref<string | null>(null)
|
|
46
|
+
|
|
47
|
+
async function stop(sessionId: string) {
|
|
48
|
+
busy.value = sessionId
|
|
49
|
+
try {
|
|
50
|
+
await agent.call('workspaceAgent.sessions.stop', { id: sessionId })
|
|
51
|
+
toast.add({ title: 'Run stopped', description: 'Its token is revoked.', color: 'success' })
|
|
52
|
+
await refreshAll()
|
|
53
|
+
} catch (error) {
|
|
54
|
+
toast.add({ title: 'Could not stop the run', description: actionErrorMessage(error), color: 'error' })
|
|
55
|
+
} finally {
|
|
56
|
+
busy.value = null
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** A token of a live run is revoked by stopping the run (otherwise the run would keep failing); others directly. */
|
|
61
|
+
async function revoke(token: TokenRow) {
|
|
62
|
+
const session = sessions.value?.items.find(item => item.tokenId === token.id)
|
|
63
|
+
if (session) return stop(session.id)
|
|
64
|
+
busy.value = token.id
|
|
65
|
+
try {
|
|
66
|
+
await core.call('tokens.revoke', { id: token.id })
|
|
67
|
+
toast.add({ title: 'Token revoked', description: token.name, color: 'success' })
|
|
68
|
+
await refreshTokens()
|
|
69
|
+
} catch (error) {
|
|
70
|
+
toast.add({ title: 'Could not revoke', description: actionErrorMessage(error), color: 'error' })
|
|
71
|
+
} finally {
|
|
72
|
+
busy.value = null
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const sessionColumns: TableColumn<SessionRow>[] = [
|
|
77
|
+
{ accessorKey: 'threadId', header: 'Conversation' },
|
|
78
|
+
{ accessorKey: 'tokenPrefix', header: 'Token' },
|
|
79
|
+
{ accessorKey: 'startedAt', header: 'Started' },
|
|
80
|
+
{ accessorKey: 'idleUntil', header: 'Stops when idle at' },
|
|
81
|
+
{ id: 'actions', header: () => h('span', { class: 'sr-only' }, 'Actions') },
|
|
82
|
+
]
|
|
83
|
+
const tokenColumns: TableColumn<TokenRow>[] = [
|
|
84
|
+
{ accessorKey: 'name', header: 'Token' },
|
|
85
|
+
{ accessorKey: 'scopes', header: 'Scopes' },
|
|
86
|
+
{ accessorKey: 'lastUsedAt', header: 'Last used' },
|
|
87
|
+
{ id: 'state', header: 'State' },
|
|
88
|
+
{ id: 'actions', header: () => h('span', { class: 'sr-only' }, 'Actions') },
|
|
89
|
+
]
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
<template>
|
|
93
|
+
<div class="flex min-w-0 flex-col gap-5">
|
|
94
|
+
<dl
|
|
95
|
+
v-if="status?.idleMinutes != null || status?.inbox"
|
|
96
|
+
class="grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-1 text-xs"
|
|
97
|
+
>
|
|
98
|
+
<template v-if="status?.idleMinutes != null">
|
|
99
|
+
<dt class="text-muted">
|
|
100
|
+
Run token
|
|
101
|
+
</dt>
|
|
102
|
+
<dd class="truncate font-mono text-default">
|
|
103
|
+
{{ status.scopes.join(', ') }} · stops after {{ status.idleMinutes }} idle min
|
|
104
|
+
</dd>
|
|
105
|
+
</template>
|
|
106
|
+
<template v-if="status?.inbox">
|
|
107
|
+
<dt class="text-muted">
|
|
108
|
+
Agent Inbox
|
|
109
|
+
</dt>
|
|
110
|
+
<dd class="truncate font-mono text-default">
|
|
111
|
+
{{ status.inbox.store }}: {{ status.inbox.location }}
|
|
112
|
+
</dd>
|
|
113
|
+
</template>
|
|
114
|
+
</dl>
|
|
115
|
+
|
|
116
|
+
<section class="flex min-w-0 flex-col gap-2">
|
|
117
|
+
<h3 class="text-sm font-medium text-highlighted">
|
|
118
|
+
{{ isOwner ? 'Running sessions' : 'Your running sessions' }}
|
|
119
|
+
</h3>
|
|
120
|
+
<UTable
|
|
121
|
+
:data="sessions?.items ?? []"
|
|
122
|
+
:columns="sessionColumns"
|
|
123
|
+
empty="No agent is running."
|
|
124
|
+
data-testid="agents-sessions"
|
|
125
|
+
>
|
|
126
|
+
<template #threadId-cell="{ row }">
|
|
127
|
+
<div>
|
|
128
|
+
<p class="font-mono text-xs text-highlighted">
|
|
129
|
+
{{ row.original.threadId.slice(0, 8) }}
|
|
130
|
+
</p>
|
|
131
|
+
<p class="text-xs text-dimmed">
|
|
132
|
+
{{ row.original.userName }} · {{ row.original.busy ? 'working' : row.original.state }}
|
|
133
|
+
</p>
|
|
134
|
+
</div>
|
|
135
|
+
</template>
|
|
136
|
+
<template #tokenPrefix-cell="{ row }">
|
|
137
|
+
<span class="font-mono text-xs">{{ row.original.tokenPrefix }}…</span>
|
|
138
|
+
</template>
|
|
139
|
+
<template #startedAt-cell="{ row }">
|
|
140
|
+
{{ formatDateTime(row.original.startedAt) }}
|
|
141
|
+
</template>
|
|
142
|
+
<template #idleUntil-cell="{ row }">
|
|
143
|
+
{{ formatDateTime(row.original.idleUntil) }}
|
|
144
|
+
</template>
|
|
145
|
+
<template #actions-cell="{ row }">
|
|
146
|
+
<div class="flex justify-end">
|
|
147
|
+
<UButton
|
|
148
|
+
label="Stop"
|
|
149
|
+
icon="i-lucide-square"
|
|
150
|
+
color="error"
|
|
151
|
+
variant="ghost"
|
|
152
|
+
size="sm"
|
|
153
|
+
:loading="busy === row.original.id"
|
|
154
|
+
data-testid="agents-stop"
|
|
155
|
+
@click="stop(row.original.id)"
|
|
156
|
+
/>
|
|
157
|
+
</div>
|
|
158
|
+
</template>
|
|
159
|
+
</UTable>
|
|
160
|
+
</section>
|
|
161
|
+
|
|
162
|
+
<section class="flex min-w-0 flex-col gap-2">
|
|
163
|
+
<h3 class="text-sm font-medium text-highlighted">
|
|
164
|
+
Agent tokens
|
|
165
|
+
</h3>
|
|
166
|
+
<UTable
|
|
167
|
+
:data="agentTokens"
|
|
168
|
+
:columns="tokenColumns"
|
|
169
|
+
empty="No agent tokens yet."
|
|
170
|
+
data-testid="agents-tokens"
|
|
171
|
+
>
|
|
172
|
+
<template #name-cell="{ row }">
|
|
173
|
+
<div>
|
|
174
|
+
<p class="font-medium text-highlighted">
|
|
175
|
+
{{ row.original.name }}
|
|
176
|
+
</p>
|
|
177
|
+
<p class="font-mono text-xs text-dimmed">
|
|
178
|
+
{{ row.original.prefix }}… · {{ formatDateTime(row.original.createdAt) }}
|
|
179
|
+
</p>
|
|
180
|
+
</div>
|
|
181
|
+
</template>
|
|
182
|
+
<template #scopes-cell="{ row }">
|
|
183
|
+
<div class="flex flex-wrap gap-1">
|
|
184
|
+
<UBadge
|
|
185
|
+
v-for="scope in row.original.scopes"
|
|
186
|
+
:key="scope"
|
|
187
|
+
:label="scope"
|
|
188
|
+
variant="subtle"
|
|
189
|
+
size="sm"
|
|
190
|
+
/>
|
|
191
|
+
</div>
|
|
192
|
+
</template>
|
|
193
|
+
<template #lastUsedAt-cell="{ row }">
|
|
194
|
+
{{ formatDateTime(row.original.lastUsedAt) }}
|
|
195
|
+
</template>
|
|
196
|
+
<template #state-cell="{ row }">
|
|
197
|
+
<UBadge
|
|
198
|
+
:label="row.original.revokedAt ? 'revoked' : !tokenActive(row.original) ? 'expired' : liveTokenIds.has(row.original.id) ? 'in use' : 'active'"
|
|
199
|
+
:color="tokenActive(row.original) ? 'success' : 'neutral'"
|
|
200
|
+
variant="outline"
|
|
201
|
+
size="sm"
|
|
202
|
+
/>
|
|
203
|
+
</template>
|
|
204
|
+
<template #actions-cell="{ row }">
|
|
205
|
+
<div class="flex justify-end">
|
|
206
|
+
<UButton
|
|
207
|
+
v-if="tokenActive(row.original)"
|
|
208
|
+
label="Revoke"
|
|
209
|
+
color="error"
|
|
210
|
+
variant="ghost"
|
|
211
|
+
size="sm"
|
|
212
|
+
:loading="busy === row.original.id"
|
|
213
|
+
@click="revoke(row.original)"
|
|
214
|
+
/>
|
|
215
|
+
</div>
|
|
216
|
+
</template>
|
|
217
|
+
</UTable>
|
|
218
|
+
</section>
|
|
219
|
+
</div>
|
|
220
|
+
</template>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { WorkspaceAgentActions } from '../../server/utils/workspace-agent/actions'
|
|
2
|
+
|
|
3
|
+
/** The typed actions client for the layer's catalogue (`workspaceAgent.*`, `inbox.*`). */
|
|
4
|
+
export function useWorkspaceAgentActions() {
|
|
5
|
+
return useActions<WorkspaceAgentActions>()
|
|
6
|
+
}
|