@capybara-hq/testing 0.1.0-rc.11 → 0.1.0-rc.12

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.
@@ -1,4 +1,4 @@
1
- import { defineExtension, EMBED_PROTOCOL, type EmbedClaims } from "@capybara-hq/plugin-sdk";
1
+ import { defineExtension, EMBED_PROTOCOL, type OrgEmbedClaims } from "@capybara-hq/plugin-sdk";
2
2
  import { z } from "zod";
3
3
 
4
4
  /**
@@ -96,14 +96,14 @@ export default defineExtension({
96
96
  {
97
97
  id: "panel",
98
98
  title: { zh: "面板", en: "Panel" },
99
- place: "page",
99
+ slot: "org.page",
100
100
  kind: "embed",
101
101
  path: "/ui/panel",
102
102
  },
103
103
  {
104
104
  id: "panel-conv",
105
105
  title: { zh: "面板", en: "Panel" },
106
- place: "conversation",
106
+ slot: "conversation.panel",
107
107
  kind: "embed",
108
108
  path: "/ui/panel-conv",
109
109
  },
@@ -120,9 +120,11 @@ export default defineExtension({
120
120
  ui: { embeds: ["panel", "panel-conv"] },
121
121
  },
122
122
  setup(ctx) {
123
- const auth = async (req: Request): Promise<EmbedClaims | null> => {
123
+ /** An org-scope token's claims (every contribution here is in an org slot), or null. */
124
+ const auth = async (req: Request): Promise<OrgEmbedClaims | null> => {
124
125
  const m = BEARER_RE.exec(req.headers.get("authorization") ?? "");
125
- return m?.[1] === undefined ? null : ctx.ui.verifyEmbedToken(m[1]);
126
+ const claims = m?.[1] === undefined ? null : await ctx.ui.verifyEmbedToken(m[1]);
127
+ return claims?.scope === "org" ? claims : null;
126
128
  };
127
129
  const page = async () =>
128
130
  new Response(PAGE, { headers: { "content-type": "text/html; charset=utf-8" } });
@@ -104,8 +104,31 @@ export default defineExtension({
104
104
  sdk: "^0.1.0-rc.0",
105
105
  provides: [],
106
106
  migrations: "../migrations",
107
- ui: [{ id: "tasks", title: { zh: "条目", en: "Items" }, place: "conversation", kind: "view" }],
108
- permissions: { tools: ["write"], ui: { views: ["tasks"] } },
107
+ ui: [
108
+ { id: "tasks", title: { zh: "条目", en: "Items" }, slot: "conversation.panel", kind: "view" },
109
+ {
110
+ id: "agent-notes",
111
+ title: { zh: "智能体备注", en: "Agent notes" },
112
+ slot: "agent.detail.section",
113
+ kind: "view",
114
+ },
115
+ {
116
+ id: "org-admin",
117
+ title: { zh: "组织设置扩展", en: "Org admin" },
118
+ slot: "org.settings.section",
119
+ kind: "view",
120
+ },
121
+ {
122
+ id: "platform-home",
123
+ title: { zh: "平台首页", en: "Platform home" },
124
+ slot: "platform.page",
125
+ kind: "view",
126
+ },
127
+ ],
128
+ permissions: {
129
+ tools: ["write"],
130
+ ui: { views: ["tasks", "agent-notes", "org-admin", "platform-home"] },
131
+ },
109
132
  setup(ctx) {
110
133
  ctx.tools.register(WRITE, async (input, tctx) => {
111
134
  const parsed = WriteInput.safeParse(input);
@@ -136,5 +159,21 @@ export default defineExtension({
136
159
  ctx.ui.view("tasks", async ({ conversationId }) =>
137
160
  tasksView(conversationId === undefined ? [] : await readItems(ctx.db, conversationId)),
138
161
  );
162
+ const ping: UiView["blocks"] = [
163
+ { type: "actions", buttons: [{ actionId: "ping", label: "Ping" }] },
164
+ ];
165
+ const done = async () => ({ toast: { zh: "已完成", en: "Done" } });
166
+ ctx.ui.view("agent-notes", async (args) => ({
167
+ blocks: [{ type: "heading", text: `Agent ${args.agentId ?? ""}`.trim() }, ...ping],
168
+ }));
169
+ ctx.ui.action("agent-notes", done);
170
+ ctx.ui.view("org-admin", async () => ({
171
+ blocks: [{ type: "heading", text: "Org settings" }, ...ping],
172
+ }));
173
+ ctx.ui.action("org-admin", done);
174
+ ctx.ui.view("platform-home", async () => ({
175
+ blocks: [{ type: "heading", text: "Platform home" }, ...ping],
176
+ }));
177
+ ctx.ui.action("platform-home", done);
139
178
  },
140
179
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/testing",
3
- "version": "0.1.0-rc.11",
3
+ "version": "0.1.0-rc.12",
4
4
  "description": "Test helpers for Capybara: test containers, dual-replica harness and fake third-party servers",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -47,17 +47,17 @@
47
47
  "tsx": "^4.23.15",
48
48
  "ws": "^8.22.0",
49
49
  "zod": "^4.6.7",
50
- "@capybara-hq/kernel": "^0.1.0-rc.11"
50
+ "@capybara-hq/kernel": "^0.1.0-rc.13"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/pg": "^8.23.1",
54
54
  "@types/ws": "^8.18.2",
55
- "@capybara-hq/plugin-sdk": "^0.1.0-rc.8"
55
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.9"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "vitest": "^5.0.5",
59
- "@capybara-hq/plugin-sdk": "^0.1.0-rc.8",
60
- "@capybara-hq/plugin-tools": "^0.1.0-rc.9"
59
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.9",
60
+ "@capybara-hq/plugin-tools": "^0.1.0-rc.10"
61
61
  },
62
62
  "peerDependenciesMeta": {
63
63
  "@capybara-hq/plugin-tools": {