@skillcdn/console 0.5.0 → 0.5.1
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/README.md +68 -11
- package/SKILLCDN.md +3 -3
- package/dist/agent-page.d.ts.map +1 -1
- package/dist/agent-page.js +3 -2
- package/dist/agent-page.js.map +1 -1
- package/dist/api.d.ts +7 -6
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +6 -5
- package/dist/api.js.map +1 -1
- package/dist/charts.d.ts +103 -0
- package/dist/charts.d.ts.map +1 -0
- package/dist/charts.js +182 -0
- package/dist/charts.js.map +1 -0
- package/dist/cli/cli.d.ts +26 -2
- package/dist/cli/cli.d.ts.map +1 -1
- package/dist/cli/cli.js +1304 -383
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/command-words.d.ts +20 -0
- package/dist/cli/command-words.d.ts.map +1 -0
- package/dist/cli/command-words.js +51 -0
- package/dist/cli/command-words.js.map +1 -0
- package/dist/cli/credentials.d.ts +54 -5
- package/dist/cli/credentials.d.ts.map +1 -1
- package/dist/cli/credentials.js +126 -20
- package/dist/cli/credentials.js.map +1 -1
- package/dist/cli/directory.d.ts +19 -4
- package/dist/cli/directory.d.ts.map +1 -1
- package/dist/cli/directory.js +16 -8
- package/dist/cli/directory.js.map +1 -1
- package/dist/cli/format.d.ts +65 -8
- package/dist/cli/format.d.ts.map +1 -1
- package/dist/cli/format.js +242 -37
- package/dist/cli/format.js.map +1 -1
- package/dist/cli/help.d.ts +13 -4
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +92 -54
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/main.js +76 -2
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/pack.d.ts +69 -60
- package/dist/cli/pack.d.ts.map +1 -1
- package/dist/cli/pack.js +241 -270
- package/dist/cli/pack.js.map +1 -1
- package/dist/cli/plugin-check.d.ts +42 -0
- package/dist/cli/plugin-check.d.ts.map +1 -1
- package/dist/cli/plugin-check.js +221 -36
- package/dist/cli/plugin-check.js.map +1 -1
- package/dist/cli/plugin-cli.d.ts +6 -1
- package/dist/cli/plugin-cli.d.ts.map +1 -1
- package/dist/cli/plugin-cli.js +21 -4
- package/dist/cli/plugin-cli.js.map +1 -1
- package/dist/cli/plugin-main.js +1 -0
- package/dist/cli/plugin-main.js.map +1 -1
- package/dist/cli/serve.d.ts +33 -1
- package/dist/cli/serve.d.ts.map +1 -1
- package/dist/cli/serve.js +252 -3
- package/dist/cli/serve.js.map +1 -1
- package/dist/client.d.ts +48 -9
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +72 -80
- package/dist/client.js.map +1 -1
- package/dist/components/agent-page.d.ts +64 -1
- package/dist/components/agent-page.d.ts.map +1 -1
- package/dist/components/agent-page.js +244 -96
- package/dist/components/agent-page.js.map +1 -1
- package/dist/components/charts.d.ts +157 -0
- package/dist/components/charts.d.ts.map +1 -0
- package/dist/components/charts.js +182 -0
- package/dist/components/charts.js.map +1 -0
- package/dist/components/desk-records.d.ts +102 -0
- package/dist/components/desk-records.d.ts.map +1 -0
- package/dist/components/desk-records.js +221 -0
- package/dist/components/desk-records.js.map +1 -0
- package/dist/components/desk.d.ts +85 -0
- package/dist/components/desk.d.ts.map +1 -0
- package/dist/components/desk.js +135 -0
- package/dist/components/desk.js.map +1 -0
- package/dist/components/event-feed.d.ts.map +1 -1
- package/dist/components/event-feed.js +4 -1
- package/dist/components/event-feed.js.map +1 -1
- package/dist/components/home.d.ts.map +1 -1
- package/dist/components/home.js +4 -2
- package/dist/components/home.js.map +1 -1
- package/dist/components/plugin-settings.d.ts.map +1 -1
- package/dist/components/plugin-settings.js +54 -3
- package/dist/components/plugin-settings.js.map +1 -1
- package/dist/components/projects.d.ts.map +1 -1
- package/dist/components/projects.js +27 -7
- package/dist/components/projects.js.map +1 -1
- package/dist/components/rules.d.ts +8 -10
- package/dist/components/rules.d.ts.map +1 -1
- package/dist/components/rules.js +35 -13
- package/dist/components/rules.js.map +1 -1
- package/dist/components/setup.d.ts +9 -3
- package/dist/components/setup.d.ts.map +1 -1
- package/dist/components/setup.js +10 -4
- package/dist/components/setup.js.map +1 -1
- package/dist/console.css +677 -7
- package/dist/console.d.ts +5 -0
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +14 -8
- package/dist/console.js.map +1 -1
- package/dist/data.d.ts.map +1 -1
- package/dist/data.js +32 -33
- package/dist/data.js.map +1 -1
- package/dist/desk-page.d.ts +38 -0
- package/dist/desk-page.d.ts.map +1 -0
- package/dist/desk-page.js +184 -0
- package/dist/desk-page.js.map +1 -0
- package/dist/desk-records-page.d.ts +18 -0
- package/dist/desk-records-page.d.ts.map +1 -0
- package/dist/desk-records-page.js +130 -0
- package/dist/desk-records-page.js.map +1 -0
- package/dist/desk-records.d.ts +247 -0
- package/dist/desk-records.d.ts.map +1 -0
- package/dist/desk-records.js +543 -0
- package/dist/desk-records.js.map +1 -0
- package/dist/desk.d.ts +122 -0
- package/dist/desk.d.ts.map +1 -0
- package/dist/desk.js +211 -0
- package/dist/desk.js.map +1 -0
- package/dist/feed-stream.d.ts +39 -0
- package/dist/feed-stream.d.ts.map +1 -0
- package/dist/feed-stream.js +117 -0
- package/dist/feed-stream.js.map +1 -0
- package/dist/home-tiles.d.ts +10 -3
- package/dist/home-tiles.d.ts.map +1 -1
- package/dist/home-tiles.js +54 -31
- package/dist/home-tiles.js.map +1 -1
- package/dist/i18n/en.d.ts +180 -5
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +184 -7
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/ko.js +169 -6
- package/dist/i18n/ko.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/limits.d.ts +11 -0
- package/dist/limits.d.ts.map +1 -1
- package/dist/limits.js +11 -0
- package/dist/limits.js.map +1 -1
- package/dist/onboarding.d.ts +6 -0
- package/dist/onboarding.d.ts.map +1 -1
- package/dist/onboarding.js +3 -3
- package/dist/onboarding.js.map +1 -1
- package/dist/plugin/context.d.ts +42 -11
- package/dist/plugin/context.d.ts.map +1 -1
- package/dist/plugin/limits.d.ts +2 -0
- package/dist/plugin/limits.d.ts.map +1 -1
- package/dist/plugin/limits.js +2 -0
- package/dist/plugin/limits.js.map +1 -1
- package/dist/plugin/manifest.d.ts +13 -0
- package/dist/plugin/manifest.d.ts.map +1 -1
- package/dist/plugin/manifest.js +30 -3
- package/dist/plugin/manifest.js.map +1 -1
- package/dist/plugin/rest-schemas.d.ts +55 -0
- package/dist/plugin/rest-schemas.d.ts.map +1 -1
- package/dist/plugin/rest-schemas.js +37 -0
- package/dist/plugin/rest-schemas.js.map +1 -1
- package/dist/plugin/sandbox.d.ts.map +1 -1
- package/dist/plugin/sandbox.js +4 -1
- package/dist/plugin/sandbox.js.map +1 -1
- package/dist/plugin/testing.d.ts +6 -2
- package/dist/plugin/testing.d.ts.map +1 -1
- package/dist/plugin/testing.js +52 -10
- package/dist/plugin/testing.js.map +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +1 -1
- package/dist/plugin.js.map +1 -1
- package/dist/records.d.ts +283 -0
- package/dist/records.d.ts.map +1 -0
- package/dist/records.js +543 -0
- package/dist/records.js.map +1 -0
- package/dist/routes.d.ts +3 -1
- package/dist/routes.d.ts.map +1 -1
- package/dist/routes.js +3 -1
- package/dist/routes.js.map +1 -1
- package/dist/rules.d.ts +30 -11
- package/dist/rules.d.ts.map +1 -1
- package/dist/rules.js +98 -45
- package/dist/rules.js.map +1 -1
- package/dist/runner/acp.d.ts +1 -1
- package/dist/runner/acp.d.ts.map +1 -1
- package/dist/runner/acp.js +31 -20
- package/dist/runner/acp.js.map +1 -1
- package/dist/runner/claude.d.ts +1 -1
- package/dist/runner/claude.d.ts.map +1 -1
- package/dist/runner/claude.js +85 -15
- package/dist/runner/claude.js.map +1 -1
- package/dist/runner/codex.d.ts +1 -1
- package/dist/runner/codex.d.ts.map +1 -1
- package/dist/runner/codex.js +19 -16
- package/dist/runner/codex.js.map +1 -1
- package/dist/runner/desk.d.ts +43 -2
- package/dist/runner/desk.d.ts.map +1 -1
- package/dist/runner/desk.js +166 -10
- package/dist/runner/desk.js.map +1 -1
- package/dist/runner/process.d.ts.map +1 -1
- package/dist/runner/process.js +11 -4
- package/dist/runner/process.js.map +1 -1
- package/dist/runner/redact.d.ts +39 -4
- package/dist/runner/redact.d.ts.map +1 -1
- package/dist/runner/redact.js +81 -5
- package/dist/runner/redact.js.map +1 -1
- package/dist/runner/runner.d.ts +15 -1
- package/dist/runner/runner.d.ts.map +1 -1
- package/dist/runner/runner.js +231 -33
- package/dist/runner/runner.js.map +1 -1
- package/dist/runner/task-scheduler.d.ts +20 -0
- package/dist/runner/task-scheduler.d.ts.map +1 -1
- package/dist/runner/task-scheduler.js +34 -4
- package/dist/runner/task-scheduler.js.map +1 -1
- package/dist/runner/types.d.ts +36 -1
- package/dist/runner/types.d.ts.map +1 -1
- package/dist/runner/types.js +17 -0
- package/dist/runner/types.js.map +1 -1
- package/dist/runner.d.ts +6 -6
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +5 -5
- package/dist/runner.js.map +1 -1
- package/dist/schemas.d.ts +509 -5
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +76 -16
- package/dist/schemas.js.map +1 -1
- package/dist/services.d.ts +22 -5
- package/dist/services.d.ts.map +1 -1
- package/dist/services.js +35 -15
- package/dist/services.js.map +1 -1
- package/dist/setup-guide.d.ts +3 -1
- package/dist/setup-guide.d.ts.map +1 -1
- package/dist/setup-guide.js +7 -4
- package/dist/setup-guide.js.map +1 -1
- package/dist/vocabulary.d.ts +14 -3
- package/dist/vocabulary.d.ts.map +1 -1
- package/dist/vocabulary.js +13 -3
- package/dist/vocabulary.js.map +1 -1
- package/docs/specs/cli.md +64 -38
- package/docs/specs/plugins.md +27 -20
- package/docs/specs/records.md +113 -0
- package/docs/specs/rest.md +20 -13
- package/docs/specs/runner.md +23 -17
- package/package.json +7 -2
- package/skills/building-a-console/SKILL.md +4 -4
- package/skills/building-a-plugin/SKILL.md +6 -6
- package/skills/deploying-a-console/SKILL.md +4 -4
- package/skills/deploying-a-console/references/resources.md +41 -4
- package/skills/deploying-a-console/references/running-it-again.md +3 -2
- package/skills/keeping-a-desk/SKILL.md +133 -0
- package/skills/keeping-a-desk/collections.md +96 -0
- package/skills/planning-the-board/SKILL.md +14 -18
- package/skills/planning-the-board/references/a-task.md +2 -2
- package/skills/planning-the-board/references/project-rules.md +13 -14
- package/skills/planning-the-board/references/setting-up.md +15 -13
- package/skills/running-an-agent/SKILL.md +10 -9
- package/skills/working-the-board/SKILL.md +62 -44
- package/skills/working-the-board/references/terms.md +9 -5
- package/skills/working-the-board/references/the-pack.md +12 -10
- package/skills/working-the-board/references/the-sentence.md +2 -2
- package/src/agent-page.tsx +3 -1
- package/src/api.ts +77 -2
- package/src/charts.ts +250 -0
- package/src/cli/cli.ts +1698 -476
- package/src/cli/command-words.ts +56 -0
- package/src/cli/credentials.ts +181 -20
- package/src/cli/directory.ts +28 -10
- package/src/cli/format.ts +301 -46
- package/src/cli/help.ts +102 -54
- package/src/cli/main.ts +72 -2
- package/src/cli/pack.ts +333 -372
- package/src/cli/plugin-check.ts +275 -34
- package/src/cli/plugin-cli.ts +28 -4
- package/src/cli/plugin-main.ts +1 -0
- package/src/cli/serve.ts +295 -2
- package/src/client.ts +192 -177
- package/src/components/agent-page.tsx +489 -243
- package/src/components/charts.tsx +680 -0
- package/src/components/desk-records.tsx +724 -0
- package/src/components/desk.tsx +471 -0
- package/src/components/event-feed.tsx +5 -1
- package/src/components/home.tsx +12 -0
- package/src/components/plugin-settings.tsx +171 -12
- package/src/components/projects.tsx +29 -12
- package/src/components/rules.tsx +94 -34
- package/src/components/setup.tsx +18 -3
- package/src/console.tsx +17 -9
- package/src/data.ts +37 -34
- package/src/desk-page.tsx +332 -0
- package/src/desk-records-page.tsx +256 -0
- package/src/desk-records.ts +808 -0
- package/src/desk.ts +329 -0
- package/src/feed-stream.ts +144 -0
- package/src/home-tiles.ts +55 -35
- package/src/i18n/en.ts +196 -9
- package/src/i18n/ko.ts +178 -8
- package/src/index.ts +118 -0
- package/src/limits.ts +11 -0
- package/src/onboarding.ts +12 -4
- package/src/plugin/context.ts +55 -12
- package/src/plugin/limits.ts +2 -0
- package/src/plugin/manifest.ts +38 -2
- package/src/plugin/rest-schemas.ts +41 -0
- package/src/plugin/sandbox.ts +4 -1
- package/src/plugin/testing.ts +63 -12
- package/src/plugin.ts +2 -0
- package/src/records.ts +702 -0
- package/src/routes.ts +3 -1
- package/src/rules.ts +108 -47
- package/src/runner/acp.ts +47 -29
- package/src/runner/claude.ts +113 -23
- package/src/runner/codex.ts +35 -25
- package/src/runner/desk.ts +198 -12
- package/src/runner/process.ts +11 -4
- package/src/runner/redact.ts +92 -6
- package/src/runner/runner.ts +275 -34
- package/src/runner/task-scheduler.ts +36 -4
- package/src/runner/types.ts +47 -1
- package/src/runner.ts +27 -2
- package/src/schemas.ts +83 -15
- package/src/services.ts +49 -14
- package/src/setup-guide.ts +6 -2
- package/src/styles/README.md +11 -1
- package/src/styles/console.css +9 -0
- package/src/styles/pages/desk.css +126 -0
- package/src/styles/pages/documents.css +5 -0
- package/src/styles/parts/bars.css +80 -0
- package/src/styles/parts/chart.css +173 -0
- package/src/styles/parts/figures.css +65 -0
- package/src/styles/parts/legend.css +48 -0
- package/src/styles/parts/series.css +32 -0
- package/src/styles/parts/share.css +25 -0
- package/src/styles/parts/spark.css +23 -0
- package/src/styles/parts/stat.css +69 -0
- package/src/styles/tokens.css +13 -7
- package/src/vocabulary.ts +16 -3
- package/template/desk-web/README.md +8 -0
- package/template/desk-web/index.html +13 -0
- package/template/desk-web/package.json +25 -0
- package/template/desk-web/src/main.tsx +24 -0
- package/template/desk-web/src/page.tsx +51 -0
- package/template/desk-web/tsconfig.json +16 -0
- package/template/desk-web/vite.config.ts +15 -0
package/src/index.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// a script that wants none of the pages. The styles are `@skillcdn/console/console.css`.
|
|
5
5
|
|
|
6
6
|
export * from "./api.js";
|
|
7
|
+
export * from "./charts.js";
|
|
7
8
|
export {
|
|
8
9
|
AgentAccountForm,
|
|
9
10
|
type AgentAccountFormProps,
|
|
@@ -38,6 +39,29 @@ export {
|
|
|
38
39
|
workloadOf,
|
|
39
40
|
} from "./components/calendar.js";
|
|
40
41
|
export { CategoryList, type CategoryListProps } from "./components/categories.js";
|
|
42
|
+
export {
|
|
43
|
+
BarList,
|
|
44
|
+
type BarListProps,
|
|
45
|
+
type BarRow,
|
|
46
|
+
Chart,
|
|
47
|
+
type ChartProps,
|
|
48
|
+
type ChartSeries,
|
|
49
|
+
type FigureRow,
|
|
50
|
+
FigureTable,
|
|
51
|
+
type FigureTableProps,
|
|
52
|
+
Legend,
|
|
53
|
+
type LegendItem,
|
|
54
|
+
type LegendProps,
|
|
55
|
+
ShareBar,
|
|
56
|
+
type ShareBarProps,
|
|
57
|
+
type SharePartItem,
|
|
58
|
+
Sparkline,
|
|
59
|
+
type SparklineProps,
|
|
60
|
+
Stat,
|
|
61
|
+
type StatChange,
|
|
62
|
+
type StatProps,
|
|
63
|
+
Stats,
|
|
64
|
+
} from "./components/charts.js";
|
|
41
65
|
export {
|
|
42
66
|
CommentCard,
|
|
43
67
|
type CommentCardProps,
|
|
@@ -67,6 +91,35 @@ export {
|
|
|
67
91
|
DecisionLog,
|
|
68
92
|
type DecisionLogProps,
|
|
69
93
|
} from "./components/decision-list.js";
|
|
94
|
+
export {
|
|
95
|
+
DESK_VIEWS,
|
|
96
|
+
DeskArchive,
|
|
97
|
+
type DeskArchiveProps,
|
|
98
|
+
DeskFiguresView,
|
|
99
|
+
type DeskFiguresViewProps,
|
|
100
|
+
DeskStanding,
|
|
101
|
+
type DeskStandingProps,
|
|
102
|
+
type DeskView,
|
|
103
|
+
DeskViews,
|
|
104
|
+
DeskWords,
|
|
105
|
+
type DeskWordsProps,
|
|
106
|
+
} from "./components/desk.js";
|
|
107
|
+
export {
|
|
108
|
+
DeskCollectionResults,
|
|
109
|
+
type DeskCollectionResultsProps,
|
|
110
|
+
DeskCollections,
|
|
111
|
+
type DeskCollectionsProps,
|
|
112
|
+
DeskCollectionView,
|
|
113
|
+
type DeskCollectionViewProps,
|
|
114
|
+
type DeskFile,
|
|
115
|
+
DeskItemView,
|
|
116
|
+
type DeskItemViewProps,
|
|
117
|
+
DeskNoRecords,
|
|
118
|
+
DeskRecordCrumbs,
|
|
119
|
+
DeskRecordProblems,
|
|
120
|
+
metricWords,
|
|
121
|
+
ratioWords,
|
|
122
|
+
} from "./components/desk-records.js";
|
|
70
123
|
export {
|
|
71
124
|
DocumentCrumbs,
|
|
72
125
|
DocumentFiles,
|
|
@@ -319,6 +372,71 @@ export {
|
|
|
319
372
|
weekdays,
|
|
320
373
|
weekOf,
|
|
321
374
|
} from "./dates.js";
|
|
375
|
+
export {
|
|
376
|
+
DESK_ENDINGS,
|
|
377
|
+
DESK_PROJECTS,
|
|
378
|
+
DESK_RUNS,
|
|
379
|
+
DESK_STATES,
|
|
380
|
+
DESK_TASKS,
|
|
381
|
+
DESK_WEEKS,
|
|
382
|
+
type DeskCategory,
|
|
383
|
+
type DeskEnding,
|
|
384
|
+
type DeskFigures,
|
|
385
|
+
type DeskHistory,
|
|
386
|
+
type DeskProject,
|
|
387
|
+
type DeskReader,
|
|
388
|
+
type DeskRun,
|
|
389
|
+
type DeskTask,
|
|
390
|
+
type DeskWeek,
|
|
391
|
+
figuresOf,
|
|
392
|
+
readHistory,
|
|
393
|
+
readOpenRuns,
|
|
394
|
+
standingOf,
|
|
395
|
+
withHistory,
|
|
396
|
+
} from "./desk.js";
|
|
397
|
+
export {
|
|
398
|
+
DESK_PAGE_KEY,
|
|
399
|
+
DeskPage,
|
|
400
|
+
type DeskPageProps,
|
|
401
|
+
deskHref,
|
|
402
|
+
deskPage,
|
|
403
|
+
deskViewOf,
|
|
404
|
+
} from "./desk-page.js";
|
|
405
|
+
export {
|
|
406
|
+
bestItems,
|
|
407
|
+
type CollectionRecords,
|
|
408
|
+
type CollectionResults,
|
|
409
|
+
type CollectionSummary,
|
|
410
|
+
type FieldValue,
|
|
411
|
+
fieldsOf,
|
|
412
|
+
figuresOfRows,
|
|
413
|
+
filePath,
|
|
414
|
+
fileSrc,
|
|
415
|
+
httpsLink,
|
|
416
|
+
itemResults,
|
|
417
|
+
lastMadeOn,
|
|
418
|
+
type MetricFigure,
|
|
419
|
+
previewPath,
|
|
420
|
+
previewSrc,
|
|
421
|
+
probeFile,
|
|
422
|
+
type RatioFigure,
|
|
423
|
+
RECORD_BEST,
|
|
424
|
+
RECORD_PREVIEW_KINDS,
|
|
425
|
+
RECORD_WEEKS,
|
|
426
|
+
RECORDS_BASE,
|
|
427
|
+
type RecordFileState,
|
|
428
|
+
type RecordProblem,
|
|
429
|
+
type RecordsAddress,
|
|
430
|
+
type RecordsOverview,
|
|
431
|
+
type RecordsReader,
|
|
432
|
+
readCollection,
|
|
433
|
+
readDeskRecords,
|
|
434
|
+
recordsAddressOf,
|
|
435
|
+
recordsQuery,
|
|
436
|
+
resultsOf,
|
|
437
|
+
statusCounts,
|
|
438
|
+
} from "./desk-records.js";
|
|
439
|
+
export { DeskRecords, type DeskRecordsProps } from "./desk-records-page.js";
|
|
322
440
|
export { DocsPage, type DocsPageProps } from "./docs-page.js";
|
|
323
441
|
export {
|
|
324
442
|
createGlanceReader,
|
package/src/limits.ts
CHANGED
|
@@ -86,6 +86,17 @@ export const MAX_TRANSCRIPT_FACT_LENGTH = 1000;
|
|
|
86
86
|
/** How many pictures one event carries, and how many a session hands in within a minute. */
|
|
87
87
|
export const MAX_TRANSCRIPT_ATTACHMENTS = 8;
|
|
88
88
|
export const MAX_TRANSCRIPT_FILES_PER_MINUTE = 60;
|
|
89
|
+
/**
|
|
90
|
+
* What an agent account's runner writes in an hour, counted over the hour before each write
|
|
91
|
+
* (ADR-0132): the events one session's transcript takes, the sessions an account begins, the
|
|
92
|
+
* wakes its runner raises itself, and the changes of its state the workspace's feed is told
|
|
93
|
+
* by its runner. Each far above what work is, and what a product that fails again and again,
|
|
94
|
+
* or a wake source that repeats itself, meets.
|
|
95
|
+
*/
|
|
96
|
+
export const MAX_TRANSCRIPT_EVENTS_PER_HOUR = 60_000;
|
|
97
|
+
export const MAX_AGENT_SESSIONS_PER_HOUR = 60;
|
|
98
|
+
export const MAX_RUNNER_WAKES_PER_HOUR = 600;
|
|
99
|
+
export const MAX_AGENT_STATE_CHANGES_PER_HOUR = 20;
|
|
89
100
|
/** How many events one page of a session carries when none is asked for, and the most it may. */
|
|
90
101
|
export const TRANSCRIPT_PAGE_LIMIT = 100;
|
|
91
102
|
export const MAX_TRANSCRIPT_PAGE_LIMIT = 500;
|
package/src/onboarding.ts
CHANGED
|
@@ -5,7 +5,9 @@ import { guideServicesOf } from "./setup-guide.js";
|
|
|
5
5
|
// console makes when the account is made, with the agent as its worker. The agent works it as
|
|
6
6
|
// any task, with a run, reports and decisions; what only a person can do it asks for as a
|
|
7
7
|
// decision, of whoever can do it; the board wakes the agent with it as with any ready task it
|
|
8
|
-
// is at work on, which is its first wake.
|
|
8
|
+
// is at work on, which is its first wake. Its run stays open while a decision of it waits, which
|
|
9
|
+
// the console never ends, and the task is finished when nothing of it waits on anyone: a run
|
|
10
|
+
// finished with decisions waiting could ask no more. The task's words are made here, for one account and the
|
|
9
11
|
// services of its workspace, in the words of their modules: English, as a skill is, for the
|
|
10
12
|
// agent to read as they are.
|
|
11
13
|
|
|
@@ -14,6 +16,12 @@ export interface OnboardingInput {
|
|
|
14
16
|
readonly handle: string;
|
|
15
17
|
/** The workspace's names and services (ADR-0089). */
|
|
16
18
|
readonly workspace: Pick<RestWorkspace, "handle" | "domain" | "services">;
|
|
19
|
+
/**
|
|
20
|
+
* The login the account signs in to the console with, where whoever makes the task knows it:
|
|
21
|
+
* an address there is the account's own address, which the task then names. Left out, what
|
|
22
|
+
* the workspace's identity service makes of its names.
|
|
23
|
+
*/
|
|
24
|
+
readonly login?: string | undefined;
|
|
17
25
|
}
|
|
18
26
|
|
|
19
27
|
/** What the onboarding task of an account is called. */
|
|
@@ -29,7 +37,7 @@ export function onboardingOf(input: OnboardingInput): {
|
|
|
29
37
|
readonly body: string;
|
|
30
38
|
} {
|
|
31
39
|
const { handle } = input;
|
|
32
|
-
const services = guideServicesOf(input.workspace, handle);
|
|
40
|
+
const services = guideServicesOf(input.workspace, handle, input.login);
|
|
33
41
|
const own = [
|
|
34
42
|
...services.flatMap((one) => one.onboarding.map((step) => item(step.title, step.body))),
|
|
35
43
|
item(
|
|
@@ -51,7 +59,7 @@ export function onboardingOf(input: OnboardingInput): {
|
|
|
51
59
|
];
|
|
52
60
|
const asked = services.flatMap((one) => one.asks.map((ask) => item(ask.title, ask.body)));
|
|
53
61
|
const body = [
|
|
54
|
-
`This is your first task, @${handle}: making your account ready to work. Work it as any task: take it, report as you go, and
|
|
62
|
+
`This is your first task, @${handle}: making your account ready to work. Work it as any task: take it, and report as you go. What waits on a person you ask for as a decision, and a run that waits for a decision stays open: the answer wakes you, and you go on with that run (\`--run <id>\`). The task is finished when nothing of it waits on anyone. \`console help\` and the skill \`working-the-board\` say how.`,
|
|
55
63
|
"",
|
|
56
64
|
"## What you do yourself",
|
|
57
65
|
"",
|
|
@@ -69,7 +77,7 @@ export function onboardingOf(input: OnboardingInput): {
|
|
|
69
77
|
"",
|
|
70
78
|
"## When you are done",
|
|
71
79
|
"",
|
|
72
|
-
"
|
|
80
|
+
"You are done when nothing of this task waits on anyone: every item above is set up, or was answered as not to be done now, and every decision you raised is answered and acted on. Until then the run stays open and waits, since a decision is asked on a run and a run that is finished asks none. Then report what is set up and, item by item, what is not done and who said so, and finish the task.",
|
|
73
81
|
"",
|
|
74
82
|
].join("\n");
|
|
75
83
|
return { title: onboardingTitle(handle), body };
|
package/src/plugin/context.ts
CHANGED
|
@@ -441,9 +441,11 @@ export type SecretPlacement =
|
|
|
441
441
|
| "basic"
|
|
442
442
|
| `body:${string}`;
|
|
443
443
|
|
|
444
|
-
/** One secret setting and where it goes. */
|
|
444
|
+
/** One secret setting and where it goes; for a keyed one (ADR-0111), the key whose value goes. */
|
|
445
445
|
export interface SecretUse {
|
|
446
446
|
readonly name: string;
|
|
447
|
+
/** The key of a keyed secret, and of no other. */
|
|
448
|
+
readonly key?: string | undefined;
|
|
447
449
|
readonly as: SecretPlacement;
|
|
448
450
|
}
|
|
449
451
|
|
|
@@ -451,22 +453,40 @@ export interface SecretUse {
|
|
|
451
453
|
* A value of the answer to seal as a secret setting (ADR-0070): the path to it in the answer's
|
|
452
454
|
* JSON (`$.access_token`, `$.credentials.signing_secret`, `$.items.0.token`), and, where it
|
|
453
455
|
* expires, how long it lasts, in seconds or as a path to the seconds (`$.expires_in`). The
|
|
454
|
-
* console seals the value and hands the plugin the answer with `"[sealed]"` in its place.
|
|
456
|
+
* console seals the value and hands the plugin the answer with `"[sealed]"` in its place. A
|
|
457
|
+
* keyed secret (ADR-0111) is sealed under `key`: a path into the same answer (`$.team.id`), or
|
|
458
|
+
* the key itself.
|
|
455
459
|
*/
|
|
456
460
|
export type SecretSeal =
|
|
457
461
|
| string
|
|
458
|
-
| {
|
|
462
|
+
| {
|
|
463
|
+
readonly path: string;
|
|
464
|
+
readonly expiresIn?: number | string | undefined;
|
|
465
|
+
/** For a keyed secret, and no other: the key, or the path to it in the answer. */
|
|
466
|
+
readonly key?: string | undefined;
|
|
467
|
+
};
|
|
459
468
|
|
|
460
469
|
/**
|
|
461
470
|
* What became of a value `seal` named (ADR-0070). `sealed`: sealed as the setting, the answer
|
|
462
471
|
* saying `"[sealed]"` in its place. `absent`: nothing at the path (no such key, `null` or an
|
|
463
472
|
* empty string); nothing sealed, nothing taken out. `not_a_string`, `too_long` and `echoed`: a
|
|
464
473
|
* value that is no string, is over the bound of a secret (4,096 characters), or holds a secret
|
|
465
|
-
* the request carried from another setting;
|
|
466
|
-
*
|
|
467
|
-
*
|
|
474
|
+
* the request carried from another setting or key; `no_key`, for a keyed secret (ADR-0111), a
|
|
475
|
+
* key the answer does not hold where the seal names a path, or holds not as a key is spelled;
|
|
476
|
+
* `too_many`, a key the secret does not keep yet, where it keeps as many as its `max`: never
|
|
477
|
+
* sealed and never handed over, the answer saying `"[withheld]"` in its place. `not_json`: an
|
|
478
|
+
* answer that is no JSON object or array, whose body is withheld whole. Only `sealed` changed the
|
|
479
|
+
* setting.
|
|
468
480
|
*/
|
|
469
|
-
export type SealOutcome =
|
|
481
|
+
export type SealOutcome =
|
|
482
|
+
| "sealed"
|
|
483
|
+
| "absent"
|
|
484
|
+
| "not_a_string"
|
|
485
|
+
| "too_long"
|
|
486
|
+
| "echoed"
|
|
487
|
+
| "no_key"
|
|
488
|
+
| "too_many"
|
|
489
|
+
| "not_json";
|
|
470
490
|
|
|
471
491
|
export interface PluginFetchInit {
|
|
472
492
|
/** `GET` unless said; `HEAD`, `POST`, `PUT`, `PATCH`, `DELETE` or `OPTIONS`, and no other. */
|
|
@@ -507,12 +527,35 @@ export interface SecretStatus {
|
|
|
507
527
|
readonly source: string | null;
|
|
508
528
|
}
|
|
509
529
|
|
|
530
|
+
/** How the value of a keyed secret under one key stands (ADR-0111). */
|
|
531
|
+
export interface SecretKeyStatus extends SecretStatus {
|
|
532
|
+
readonly key: string;
|
|
533
|
+
}
|
|
534
|
+
|
|
510
535
|
export interface PluginSecrets {
|
|
511
|
-
/**
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
536
|
+
/**
|
|
537
|
+
* Whether the secret is set and not past its expiry; for a keyed one, its value under `key`,
|
|
538
|
+
* and without a key the value it kept from before it was keyed, which `move` puts under one.
|
|
539
|
+
*/
|
|
540
|
+
has(name: string, key?: string): Promise<boolean>;
|
|
541
|
+
/**
|
|
542
|
+
* How the secret stands, for a settings page to say and a job to decide whether to renew it;
|
|
543
|
+
* for a keyed one, its value under `key`, or without a key the value of before it was keyed.
|
|
544
|
+
*/
|
|
545
|
+
status(name: string, key?: string): Promise<SecretStatus>;
|
|
546
|
+
/** The keys a keyed secret keeps a value under, each with how it stands, in the order of the keys. */
|
|
547
|
+
keys(name: string): Promise<readonly SecretKeyStatus[]>;
|
|
548
|
+
/**
|
|
549
|
+
* Forgets the value of a keyed secret under `key`, where what the key stood for is gone: an
|
|
550
|
+
* installation removed at the service, say. Answers whether there was one.
|
|
551
|
+
*/
|
|
552
|
+
forget(name: string, key: string): Promise<boolean>;
|
|
553
|
+
/**
|
|
554
|
+
* Puts the value a keyed secret kept from before it was keyed under `key`, in place of what the
|
|
555
|
+
* key held: an upgrade's way to keep a token through the change. Answers whether there was one.
|
|
556
|
+
*/
|
|
557
|
+
move(name: string, key: string): Promise<boolean>;
|
|
558
|
+
/** Signs with the secret; refused for a secret declared `use: "verify"`, which signs nothing, and for a keyed one. */
|
|
516
559
|
sign(name: string, payload: string | Uint8Array, algorithm: "hmac-sha256"): Promise<string>;
|
|
517
560
|
verify(
|
|
518
561
|
name: string,
|
package/src/plugin/limits.ts
CHANGED
|
@@ -27,6 +27,8 @@ export const MAX_PLUGIN_INDEXES = 8;
|
|
|
27
27
|
export const MAX_PLUGIN_ABOUT_LENGTH = 200;
|
|
28
28
|
/** The options of an `enum` setting or argument. */
|
|
29
29
|
export const MAX_PLUGIN_OPTIONS = 50;
|
|
30
|
+
/** The most keys a keyed secret setting may keep a value under, whatever its `max` says (ADR-0111). */
|
|
31
|
+
export const MAX_PLUGIN_SECRET_KEYS = 1000;
|
|
30
32
|
/** A record, how many a plugin keeps, and how many versions one record keeps. */
|
|
31
33
|
export const MAX_PLUGIN_RECORD_BYTES = 64 * 1024;
|
|
32
34
|
export const MAX_PLUGIN_RECORDS = 100_000;
|
package/src/plugin/manifest.ts
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
MAX_PLUGIN_OPTIONS,
|
|
20
20
|
MAX_PLUGIN_PAGES,
|
|
21
21
|
MAX_PLUGIN_ROLES,
|
|
22
|
+
MAX_PLUGIN_SECRET_KEYS,
|
|
22
23
|
MAX_PLUGIN_SETTING_GROUPS,
|
|
23
24
|
MAX_PLUGIN_SETTINGS,
|
|
24
25
|
MAX_PLUGIN_WIDGETS,
|
|
@@ -109,10 +110,12 @@ export const RESERVED_ARG_NAMES: readonly string[] = [
|
|
|
109
110
|
export const RESERVED_COMMAND_NAMES: readonly string[] = [
|
|
110
111
|
"help",
|
|
111
112
|
"records",
|
|
113
|
+
"events",
|
|
112
114
|
"skills",
|
|
113
115
|
"skill",
|
|
114
116
|
"enable",
|
|
115
117
|
"disable",
|
|
118
|
+
"capabilities",
|
|
116
119
|
"settings",
|
|
117
120
|
"secret",
|
|
118
121
|
"grant",
|
|
@@ -284,6 +287,17 @@ const settingItemType = z.enum(
|
|
|
284
287
|
PLUGIN_SETTING_TYPES.filter((type) => type !== "secret" && type !== "list"),
|
|
285
288
|
);
|
|
286
289
|
|
|
290
|
+
/**
|
|
291
|
+
* A key a keyed secret keeps a value under (ADR-0111): letters, digits, `_` and `-`, up to 64, a
|
|
292
|
+
* workspace's id at a service, say. It is no secret, and a path into an answer (`$.team.id`)
|
|
293
|
+
* never reads as one.
|
|
294
|
+
*/
|
|
295
|
+
export const PLUGIN_SECRET_KEY_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
|
|
296
|
+
|
|
297
|
+
export function isPluginSecretKey(value: unknown): value is string {
|
|
298
|
+
return typeof value === "string" && PLUGIN_SECRET_KEY_PATTERN.test(value);
|
|
299
|
+
}
|
|
300
|
+
|
|
287
301
|
/** A setting's key, as code and `--set` name it: a lowercase letter, then letters and digits. */
|
|
288
302
|
export const SETTING_KEY_PATTERN = /^[a-z][a-zA-Z0-9]{0,31}$/;
|
|
289
303
|
|
|
@@ -316,6 +330,15 @@ const pluginSettingSchema = z
|
|
|
316
330
|
hosts: z.optional(z.array(z.string().check(z.maxLength(300))).check(z.maxLength(20))),
|
|
317
331
|
/** For a `secret`: `verify`, a secret that verifies signatures and signs nothing, so that a request cannot be forged with it. */
|
|
318
332
|
use: z.optional(z.literal("verify")),
|
|
333
|
+
/**
|
|
334
|
+
* For a `secret`: one value per key, up to `max` keys (ADR-0111), each key named by the
|
|
335
|
+
* plugin or read from the answer it was sealed from, a workspace's id elsewhere, say.
|
|
336
|
+
*/
|
|
337
|
+
keyed: z.optional(
|
|
338
|
+
z.strictObject({
|
|
339
|
+
max: z.int().check(z.minimum(1), z.maximum(MAX_PLUGIN_SECRET_KEYS)),
|
|
340
|
+
}),
|
|
341
|
+
),
|
|
319
342
|
})
|
|
320
343
|
.check(
|
|
321
344
|
z.superRefine((setting, ctx) => {
|
|
@@ -373,10 +396,23 @@ function settingProblems(setting: {
|
|
|
373
396
|
of?: Exclude<PluginSettingType, "secret" | "list">;
|
|
374
397
|
hosts?: readonly string[];
|
|
375
398
|
use?: "verify";
|
|
399
|
+
keyed?: { max: number };
|
|
400
|
+
required?: boolean;
|
|
376
401
|
}): string[] {
|
|
377
402
|
const problems: string[] = [];
|
|
378
|
-
if (
|
|
379
|
-
|
|
403
|
+
if (
|
|
404
|
+
setting.type !== "secret" &&
|
|
405
|
+
(setting.hosts !== undefined || setting.use !== undefined || setting.keyed !== undefined)
|
|
406
|
+
) {
|
|
407
|
+
problems.push(`only a secret takes hosts, use or keyed`);
|
|
408
|
+
}
|
|
409
|
+
// A keyed secret's values come and go with what each key stands for, so that none is required
|
|
410
|
+
// to enable the plugin; and it goes into requests alone, never verifying a signature.
|
|
411
|
+
if (setting.keyed !== undefined && setting.use !== undefined) {
|
|
412
|
+
problems.push("a keyed secret takes no use");
|
|
413
|
+
}
|
|
414
|
+
if (setting.keyed !== undefined && setting.required === true) {
|
|
415
|
+
problems.push("a keyed secret is not required");
|
|
380
416
|
}
|
|
381
417
|
for (const host of setting.hosts ?? []) {
|
|
382
418
|
if (!isPluginCapability(`outbound:${host}`) || host === "webrtc") {
|
|
@@ -160,6 +160,17 @@ export const restPluginsSchema = z.object({
|
|
|
160
160
|
});
|
|
161
161
|
export type RestPlugins = z.infer<typeof restPluginsSchema>;
|
|
162
162
|
|
|
163
|
+
/** The value of a keyed secret under one key (ADR-0111), as the pages show it: never the value. */
|
|
164
|
+
export const restPluginSecretKeySchema = z.object({
|
|
165
|
+
key: z.string(),
|
|
166
|
+
setAt: instant,
|
|
167
|
+
/** When it expires, or `null`. */
|
|
168
|
+
expiresAt: z.nullable(instant),
|
|
169
|
+
/** `administrator`, or the host of the answer it was sealed from. */
|
|
170
|
+
source: z.string(),
|
|
171
|
+
});
|
|
172
|
+
export type RestPluginSecretKey = z.infer<typeof restPluginSecretKeySchema>;
|
|
173
|
+
|
|
163
174
|
/** A setting as the pages draw its form: the manifest's declaration, and whether and what it holds. */
|
|
164
175
|
export const restPluginSettingSchema = z.object({
|
|
165
176
|
key: z.string(),
|
|
@@ -187,6 +198,13 @@ export const restPluginSettingSchema = z.object({
|
|
|
187
198
|
hosts: z.optional(z.nullable(z.array(z.string()))),
|
|
188
199
|
/** `verify` for a secret that verifies and signs nothing, or `null`. */
|
|
189
200
|
use: z.optional(z.nullable(z.literal("verify"))),
|
|
201
|
+
/** For a secret that keeps a value per key (ADR-0111), how many keys it may keep; `null` otherwise. Answered from 0.5.1 and read as optional. */
|
|
202
|
+
keyed: z.optional(z.nullable(z.object({ max: z.int() }))),
|
|
203
|
+
/**
|
|
204
|
+
* For a keyed secret, the keys it keeps a value under, each with when and from where it was set
|
|
205
|
+
* and when it expires, never the value; `null` otherwise. Answered from 0.5.1 and read as optional.
|
|
206
|
+
*/
|
|
207
|
+
keys: z.optional(z.nullable(z.array(restPluginSecretKeySchema))),
|
|
190
208
|
});
|
|
191
209
|
export type RestPluginSetting = z.infer<typeof restPluginSettingSchema>;
|
|
192
210
|
|
|
@@ -208,6 +226,27 @@ export type RestPluginGrant = z.infer<typeof restPluginGrantSchema>;
|
|
|
208
226
|
export const restPluginGrantsSchema = z.object({ items: z.array(restPluginGrantSchema) });
|
|
209
227
|
export type RestPluginGrants = z.infer<typeof restPluginGrantsSchema>;
|
|
210
228
|
|
|
229
|
+
/**
|
|
230
|
+
* A job of a plugin as its scheduler keeps it (ADR-0128): how often it runs, how its last run
|
|
231
|
+
* went, when it runs next, and since when it has failed where it failed run after run.
|
|
232
|
+
*/
|
|
233
|
+
export const restPluginJobSchema = z.object({
|
|
234
|
+
name: z.string(),
|
|
235
|
+
/** How often it runs, an ISO 8601 duration. */
|
|
236
|
+
every: z.string(),
|
|
237
|
+
/** The time of day it runs at, `HH:MM` in the workspace's time zone, or `null`. */
|
|
238
|
+
at: z.nullable(z.string()),
|
|
239
|
+
/** When it last ran, or `null` before its first run. */
|
|
240
|
+
lastRunAt: z.nullable(instant),
|
|
241
|
+
/** How its last run went, or `null` before its first run. */
|
|
242
|
+
lastOutcome: z.nullable(z.enum(["ok", "failed"])),
|
|
243
|
+
/** When it runs next; `null` where the plugin is not enabled with its `jobs` capability, or the scheduler has not seen the job yet. */
|
|
244
|
+
nextAt: z.nullable(instant),
|
|
245
|
+
/** Its first failure since it last went well, or `null` while it goes well: a job that failed twice running is among the plugin's `problems`. */
|
|
246
|
+
failedSince: z.nullable(instant),
|
|
247
|
+
});
|
|
248
|
+
export type RestPluginJob = z.infer<typeof restPluginJobSchema>;
|
|
249
|
+
|
|
211
250
|
/** One plugin whole, for `GET /api/v1/plugins/<key>`: the listing's fields, and what agents and administrators need. */
|
|
212
251
|
export const restPluginDetailSchema = z.extend(restPluginSchema, {
|
|
213
252
|
operations: z.array(restPluginOperationSchema),
|
|
@@ -246,6 +285,8 @@ export const restPluginDetailSchema = z.extend(restPluginSchema, {
|
|
|
246
285
|
}),
|
|
247
286
|
),
|
|
248
287
|
),
|
|
288
|
+
/** The jobs the plugin's module declares, each as its scheduler keeps it (ADR-0128); answered from 0.5.1 and read as optional. */
|
|
289
|
+
jobs: z.optional(z.array(restPluginJobSchema)),
|
|
249
290
|
});
|
|
250
291
|
export type RestPluginDetail = z.infer<typeof restPluginDetailSchema>;
|
|
251
292
|
|
package/src/plugin/sandbox.ts
CHANGED
|
@@ -43,8 +43,11 @@ export function isForbiddenBuiltin(specifier: string): boolean {
|
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
// The blanks around an import's bracket are taken in one way only, `\s*(?:\(\s*)?`: written as
|
|
47
|
+
// `\s*\(?\s*`, a run of blanks with no bracket in it is divided between the two in every way
|
|
48
|
+
// before the expression gives up, the square of its length, and a bundle is megabytes.
|
|
46
49
|
const IMPORT_OR_REQUIRE =
|
|
47
|
-
/(?:\bfrom\s*|\bimport\s
|
|
50
|
+
/(?:\bfrom\s*|\bimport\s*(?:\(\s*)?|\brequire\s*\(\s*|\bprocess\.getBuiltinModule\s*\(\s*)["'`](node:)?([a-z_/]+)["'`]/g;
|
|
48
51
|
|
|
49
52
|
/** The built-ins a bundle's text imports or requires that the host refuses, each once, as written. */
|
|
50
53
|
export function forbiddenImportsIn(source: string): string[] {
|
package/src/plugin/testing.ts
CHANGED
|
@@ -65,8 +65,12 @@ export interface TestContextOptions {
|
|
|
65
65
|
readonly console?: TestConsoleOptions;
|
|
66
66
|
readonly sql?: PluginSql;
|
|
67
67
|
readonly fetch?: (url: string, init?: PluginFetchInit) => Promise<PluginFetchResponse>;
|
|
68
|
-
/**
|
|
69
|
-
|
|
68
|
+
/**
|
|
69
|
+
* The secrets by name; `sign` and `verify` use them, and never hand them over. A keyed secret
|
|
70
|
+
* (ADR-0111) is given its values by key; one given a single value stands as a keyed secret kept
|
|
71
|
+
* from before it was keyed, which `move` puts under a key.
|
|
72
|
+
*/
|
|
73
|
+
readonly secrets?: Readonly<Record<string, string | Readonly<Record<string, string>>>>;
|
|
70
74
|
readonly plugins?: Readonly<Record<string, TestOtherPlugin>>;
|
|
71
75
|
/** The console's public origin, from which `ctx.endpoints.url` is answered; left out, it is `plugin.unavailable`. */
|
|
72
76
|
readonly publicUrl?: string;
|
|
@@ -579,7 +583,41 @@ function build(store: Store, options: TestContextOptions, caller: PluginCaller):
|
|
|
579
583
|
grants: [],
|
|
580
584
|
...options.plugin,
|
|
581
585
|
};
|
|
582
|
-
|
|
586
|
+
// A copy, so that `forget` and `move` change what the context answers and nothing of the test's.
|
|
587
|
+
const secrets = new Map<string, string | Map<string, string>>(
|
|
588
|
+
Object.entries(options.secrets ?? {}).map(([name, value]) => [
|
|
589
|
+
name,
|
|
590
|
+
typeof value === "string" ? value : new Map(Object.entries(value)),
|
|
591
|
+
]),
|
|
592
|
+
);
|
|
593
|
+
const secretValue = (name: string, key: string | undefined): string | undefined => {
|
|
594
|
+
const held = secrets.get(name);
|
|
595
|
+
return typeof held === "string"
|
|
596
|
+
? key === undefined
|
|
597
|
+
? held
|
|
598
|
+
: undefined
|
|
599
|
+
: key === undefined
|
|
600
|
+
? undefined
|
|
601
|
+
: held?.get(key);
|
|
602
|
+
};
|
|
603
|
+
const secretStatus = (name: string, key: string | undefined) => {
|
|
604
|
+
const set = secretValue(name, key) !== undefined;
|
|
605
|
+
return {
|
|
606
|
+
set,
|
|
607
|
+
setAt: set ? now().toISOString() : null,
|
|
608
|
+
expiresAt: null,
|
|
609
|
+
source: set ? "administrator" : null,
|
|
610
|
+
};
|
|
611
|
+
};
|
|
612
|
+
const signingSecret = (name: string): string | undefined => {
|
|
613
|
+
if (secrets.get(name) instanceof Map) {
|
|
614
|
+
throw new PluginRefusal(
|
|
615
|
+
"plugin.forbidden",
|
|
616
|
+
`the secret ${name} is kept per key and signs nothing`,
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
return secretValue(name, undefined);
|
|
620
|
+
};
|
|
583
621
|
const records = ((collection: CollectionDefinition | string) => {
|
|
584
622
|
const name = typeof collection === "string" ? collection : collection.name;
|
|
585
623
|
const definition = typeof collection === "string" ? collections.get(collection) : collection;
|
|
@@ -606,22 +644,35 @@ function build(store: Store, options: TestContextOptions, caller: PluginCaller):
|
|
|
606
644
|
},
|
|
607
645
|
fetch: options.fetch ?? (async () => forbidden("fetch", "fetch")),
|
|
608
646
|
secrets: {
|
|
609
|
-
has: async (name) => name
|
|
610
|
-
status: async (name) => (
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
647
|
+
has: async (name, key) => secretValue(name, key) !== undefined,
|
|
648
|
+
status: async (name, key) => secretStatus(name, key),
|
|
649
|
+
keys: async (name) => {
|
|
650
|
+
const held = secrets.get(name);
|
|
651
|
+
return held instanceof Map
|
|
652
|
+
? [...held.keys()].sort().map((key) => ({ key, ...secretStatus(name, key) }))
|
|
653
|
+
: [];
|
|
654
|
+
},
|
|
655
|
+
forget: async (name, key) => {
|
|
656
|
+
const held = secrets.get(name);
|
|
657
|
+
return held instanceof Map && held.delete(key);
|
|
658
|
+
},
|
|
659
|
+
move: async (name, key) => {
|
|
660
|
+
const held = secrets.get(name);
|
|
661
|
+
if (typeof held !== "string") {
|
|
662
|
+
return false;
|
|
663
|
+
}
|
|
664
|
+
secrets.set(name, new Map([[key, held]]));
|
|
665
|
+
return true;
|
|
666
|
+
},
|
|
616
667
|
sign: async (name, payload) => {
|
|
617
|
-
const secret =
|
|
668
|
+
const secret = signingSecret(name);
|
|
618
669
|
if (secret === undefined) {
|
|
619
670
|
throw new PluginRefusal("plugin.forbidden", `the secret ${name} is not set`);
|
|
620
671
|
}
|
|
621
672
|
return hmacSha256(secret, payload);
|
|
622
673
|
},
|
|
623
674
|
verify: async (name, payload, signature) => {
|
|
624
|
-
const secret =
|
|
675
|
+
const secret = signingSecret(name);
|
|
625
676
|
return (
|
|
626
677
|
secret !== undefined && (await hmacSha256(secret, payload)) === signature.toLowerCase()
|
|
627
678
|
);
|
package/src/plugin.ts
CHANGED
|
@@ -76,6 +76,7 @@ export {
|
|
|
76
76
|
capabilitiesAsked,
|
|
77
77
|
isCalendarDay,
|
|
78
78
|
isPluginKey,
|
|
79
|
+
isPluginSecretKey,
|
|
79
80
|
type Localized,
|
|
80
81
|
legacyWidgetSize,
|
|
81
82
|
localizedText,
|
|
@@ -85,6 +86,7 @@ export {
|
|
|
85
86
|
PLUGIN_KEY_PATTERN,
|
|
86
87
|
PLUGIN_MENU_GROUPS,
|
|
87
88
|
PLUGIN_PAGE_LEVELS,
|
|
89
|
+
PLUGIN_SECRET_KEY_PATTERN,
|
|
88
90
|
PLUGIN_SETTING_TYPES,
|
|
89
91
|
PLUGIN_WIDGET_PLACES,
|
|
90
92
|
PLUGIN_WIDGET_SIZE_CELLS,
|