@capybara-hq/plugin-sdk 0.1.0-rc.7 → 0.1.0-rc.70

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.
Files changed (146) hide show
  1. package/README.md +1 -1
  2. package/agent-docs/agent-templates.md +14 -2
  3. package/agent-docs/concepts.md +14 -5
  4. package/agent-docs/connector-templates.md +11 -3
  5. package/agent-docs/extension-points/channel.md +1 -1
  6. package/agent-docs/extension-points/context.md +15 -0
  7. package/agent-docs/extension-points/device-provider.md +15 -0
  8. package/agent-docs/extension-points/file-preview.md +2 -0
  9. package/agent-docs/extension-points/model-provider.md +3 -1
  10. package/agent-docs/extension-points/object-store.md +2 -0
  11. package/agent-docs/extension-points/push-provider.md +17 -0
  12. package/agent-docs/extensions.md +76 -3
  13. package/agent-docs/plugin-format.md +51 -12
  14. package/agent-docs/setup.md +54 -0
  15. package/dist/agent-template.d.ts +15 -6
  16. package/dist/agent-template.js +32 -13
  17. package/dist/avatar-presets.d.ts +8 -0
  18. package/dist/avatar-presets.js +17 -0
  19. package/dist/bootstrap.d.ts +109 -1
  20. package/dist/bootstrap.js +185 -2
  21. package/dist/cards.d.ts +60 -13
  22. package/dist/cards.js +88 -18
  23. package/dist/channel.d.ts +128 -47
  24. package/dist/channel.js +10 -5
  25. package/dist/client-css.d.ts +36 -0
  26. package/dist/client-css.js +326 -0
  27. package/dist/client-section.d.ts +35 -0
  28. package/dist/client-section.js +133 -0
  29. package/dist/config-ui.d.ts +28 -6
  30. package/dist/config-ui.js +88 -25
  31. package/dist/config-url-fetch.d.ts +19 -0
  32. package/dist/config-url-fetch.js +43 -0
  33. package/dist/connector-auth.d.ts +13 -2
  34. package/dist/connector-auth.js +82 -8
  35. package/dist/connector.d.ts +74 -32
  36. package/dist/context.d.ts +40 -0
  37. package/dist/context.js +2 -0
  38. package/dist/ctx.d.ts +210 -30
  39. package/dist/ctx.js +9 -1
  40. package/dist/define-extension.d.ts +23 -13
  41. package/dist/define-extension.js +19 -5
  42. package/dist/device-denied-paths.d.ts +20 -0
  43. package/dist/device-denied-paths.js +118 -0
  44. package/dist/device-operation.d.ts +339 -0
  45. package/dist/device-operation.js +312 -0
  46. package/dist/device-protocol.d.ts +285 -50
  47. package/dist/device-protocol.js +755 -90
  48. package/dist/device-provider.d.ts +708 -0
  49. package/dist/device-provider.js +325 -0
  50. package/dist/device-service.d.ts +52 -0
  51. package/dist/device-service.js +105 -0
  52. package/dist/dial-in.d.ts +239 -0
  53. package/dist/dial-in.js +155 -0
  54. package/dist/directory.d.ts +15 -12
  55. package/dist/extension-point.d.ts +2 -0
  56. package/dist/extension-point.js +6 -2
  57. package/dist/field-meta.d.ts +19 -0
  58. package/dist/field-meta.js +54 -0
  59. package/dist/file-preview.d.ts +26 -10
  60. package/dist/git-hosts.d.ts +53 -0
  61. package/dist/git-hosts.js +98 -0
  62. package/dist/hooks.d.ts +125 -20
  63. package/dist/hooks.js +5 -0
  64. package/dist/http-access.d.ts +62 -0
  65. package/dist/http-access.js +12 -0
  66. package/dist/identity.d.ts +38 -9
  67. package/dist/identity.js +21 -1
  68. package/dist/index.d.ts +31 -4
  69. package/dist/index.js +31 -4
  70. package/dist/model-params.d.ts +41 -22
  71. package/dist/model-params.js +28 -15
  72. package/dist/model.d.ts +210 -75
  73. package/dist/model.js +152 -19
  74. package/dist/net.d.ts +52 -0
  75. package/dist/net.js +34 -0
  76. package/dist/network-classes.d.ts +98 -0
  77. package/dist/network-classes.js +291 -0
  78. package/dist/permissions.d.ts +65 -22
  79. package/dist/permissions.js +139 -43
  80. package/dist/platform-only.d.ts +27 -0
  81. package/dist/platform-only.js +35 -0
  82. package/dist/plugin-manifest.d.ts +40 -9
  83. package/dist/plugin-manifest.js +171 -60
  84. package/dist/plugin-package.d.ts +82 -39
  85. package/dist/plugin-package.js +68 -41
  86. package/dist/push.d.ts +75 -0
  87. package/dist/push.js +87 -0
  88. package/dist/sandbox-linux-runtime-source.d.ts +1 -0
  89. package/dist/sandbox-linux-runtime-source.js +2343 -0
  90. package/dist/sandbox-native-runtime-source.d.ts +10 -0
  91. package/dist/sandbox-native-runtime-source.js +476 -0
  92. package/dist/sandbox-runtime-source.d.ts +47 -0
  93. package/dist/sandbox-runtime-source.js +73 -0
  94. package/dist/sandbox-write-denies.d.ts +139 -0
  95. package/dist/sandbox-write-denies.js +869 -0
  96. package/dist/secret.d.ts +8 -2
  97. package/dist/secret.js +11 -4
  98. package/dist/setup-check.d.ts +128 -0
  99. package/dist/setup-check.js +142 -0
  100. package/dist/setup-guide-parse.d.ts +121 -0
  101. package/dist/setup-guide-parse.js +356 -0
  102. package/dist/setup-guide-render.d.ts +45 -0
  103. package/dist/setup-guide-render.js +351 -0
  104. package/dist/setup-guide.d.ts +86 -72
  105. package/dist/setup-guide.js +340 -108
  106. package/dist/shell-capabilities.d.ts +211 -0
  107. package/dist/shell-capabilities.js +44 -0
  108. package/dist/shell-environment.d.ts +57 -0
  109. package/dist/shell-environment.js +21 -0
  110. package/dist/skill.d.ts +27 -17
  111. package/dist/skill.js +40 -26
  112. package/dist/storage.d.ts +52 -25
  113. package/dist/svg-viewbox.d.ts +10 -0
  114. package/dist/svg-viewbox.js +24 -0
  115. package/dist/theme-assets.d.ts +55 -0
  116. package/dist/theme-assets.js +489 -0
  117. package/dist/theme-readability.d.ts +37 -0
  118. package/dist/theme-readability.js +145 -0
  119. package/dist/theme-tokens.generated.d.ts +299 -0
  120. package/dist/theme-tokens.generated.js +184 -0
  121. package/dist/theme.d.ts +190 -0
  122. package/dist/theme.js +471 -0
  123. package/dist/tool.d.ts +104 -30
  124. package/dist/tool.js +29 -9
  125. package/dist/ui-parts.d.ts +23 -0
  126. package/dist/ui-parts.js +385 -0
  127. package/dist/ui-resolve.d.ts +35 -0
  128. package/dist/ui-resolve.js +42 -0
  129. package/dist/ui-slots.d.ts +65 -0
  130. package/dist/ui-slots.js +261 -0
  131. package/dist/ui.d.ts +221 -77
  132. package/dist/ui.js +104 -27
  133. package/dist/url.d.ts +4 -1
  134. package/dist/url.js +4 -1
  135. package/dist/web.d.ts +26 -20
  136. package/package.json +13 -1
  137. package/schemas/bootstrap-extra.v1.schema.json +186 -0
  138. package/schemas/bootstrap.v1.schema.json +20 -0
  139. package/schemas/connector-template.v1.schema.json +62 -4
  140. package/schemas/plugin.v1.schema.json +93 -143
  141. package/schemas/theme.v1.schema.json +302 -0
  142. package/agent-docs/extension-points/sandbox.md +0 -15
  143. package/dist/org-access.d.ts +0 -27
  144. package/dist/org-access.js +0 -35
  145. package/dist/sandbox.d.ts +0 -254
  146. package/dist/sandbox.js +0 -153
@@ -0,0 +1,139 @@
1
+ /**
2
+ * What restricted execution may never write inside a granted root: one policy for every consumer
3
+ * (the Linux launcher's broker, `native-files.py`, the device agent and, as far as its glob
4
+ * patterns can express it, the macOS runtime). It keeps a later unsandboxed tool run by the owner
5
+ * from executing what a restricted command left behind.
6
+ *
7
+ * 1. {@link SANDBOX_MANDATORY_WRITE_DENIES}: component sequences denied wherever they appear (the
8
+ * entry and everything beneath it): shell startup and logout files, git's global files, direnv
9
+ * and npm configuration, editor and agent configuration, and the OS persistence locations
10
+ * (launchd, systemd, environment.d, XDG and KDE autostart, X session files, fish). Entries are
11
+ * written already folded. {@link SANDBOX_SYSTEM_WRITE_DENIES}: absolute system paths denied
12
+ * with everything beneath them (the crontab and at spools), anchored at `/`.
13
+ * 2. Inside a `.git` directory (the first `.git` component of a path) only git's ordinary
14
+ * internals are writable, an allowlist ({@link SANDBOX_GIT_ALLOWED_DIRECTORIES},
15
+ * {@link SANDBOX_GIT_ALLOWED_FILES}, `info/exclude`). Everything else there is denied:
16
+ * `config`, `config.worktree`, `commondir`, `gitdir`, `hooks/**`, `info/attributes`, unknown
17
+ * names. The gitdirs of submodules (`modules/<name>/`, where a name may contain `/`) and
18
+ * worktrees (`worktrees/<name>/`) follow the same allowlist; a submodule path is refused when
19
+ * any reading of its name would make it a denied internal.
20
+ * 3. Outside `.git`, a file named `HEAD` is denied: with `objects/` and `refs/` it would make a
21
+ * bare-repository lookalike whose configuration git honours.
22
+ * 4. Moves ({@link isSandboxMoveDenied}): neither end may be a denied write; nothing leaves a
23
+ * protected name ({@link SANDBOX_PROTECTED_PATH_NAMES}: `.git` and the single-component
24
+ * entries) except within the same protected directory; a directory is not moved under a
25
+ * protected name from outside it; no non-directory becomes `.git` (a `gitdir:` pointer). For a
26
+ * multi-component entry `[a, b, …]` (or an absolute system path) a destination ending in a
27
+ * proper prefix of it (`…/a`) takes no non-directory (a link there would redirect the entry)
28
+ * and no directory holding the entry's next component (`b`): a prepared directory never moves
29
+ * into place, while ordinary names (`library`, `.config`) stay movable. An ancestor of an
30
+ * anchored path (a system path, or a consumer's resolved target) never moves away.
31
+ *
32
+ * 5. Inside an allowlisted subtree nothing can make a repository: no `.git`, no `HEAD` except
33
+ * where git keeps one (`logs/HEAD`, `refs/remotes/<r>/HEAD`, …), and no `objects`, `commondir`
34
+ * or `gitdir` beside such a `HEAD`.
35
+ *
36
+ * 6. A component starting with {@link SANDBOX_RESERVED_NAME_PREFIX} (the broker's staging and
37
+ * quarantine names) is denied with everything beneath it.
38
+ *
39
+ * Names are compared after Unicode NFKC normalization and full case folding
40
+ * ({@link sandboxFoldName}, identical to Python's `casefold`). Known limitations: a
41
+ * restricted command cannot `git init`, add a submodule or worktree, or create a bare repository;
42
+ * continuing an operation it started (`git rebase --continue`) runs the todo list it wrote, like
43
+ * any script it wrote; files that tools execute by convention without configuration (for example
44
+ * `package.json` scripts) are not covered; a forged rebase or cherry-pick in progress is possible
45
+ * (its state directories are writable for git's own use) and continuing it runs its `exec` lines.
46
+ * The macOS worker expresses this policy as ordered Seatbelt regex rules
47
+ * (`packages/device/src/exec/mac-write-policy.ts`).
48
+ *
49
+ * Constraints on consumers:
50
+ *
51
+ * - The policy judges the path it is given. A protected home location reached through a symbolic
52
+ * link (`~/.config` or `~/Library` linked elsewhere, as dotfile managers do) is denied only at
53
+ * its resolved target: a device worker resolves the protected home locations at operation start
54
+ * and adds their resolved targets as absolute denies.
55
+ * - The move check needs the entries of a moved directory. A consumer passes them from the source
56
+ * descriptor; the Python `move_denied` otherwise lists the source path, refusing when it cannot.
57
+ * A listing is a snapshot: a concurrent writer could add the next component between the check
58
+ * and the rename, so a consumer that can re-checks the destination after the rename.
59
+ */
60
+ export declare const SANDBOX_MANDATORY_WRITE_DENIES: readonly (readonly string[])[];
61
+ /**
62
+ * Locations denied only directly under the device owner's home, with everything beneath them, never
63
+ * elsewhere: `~/bin`, a directory many shells put on `PATH`, where a planted program would shadow a
64
+ * system one in the owner's later unsandboxed shell (a project's own `bin/` stays writable).
65
+ * Consumers anchor each entry at the home they protect: the device workers add it, and the target
66
+ * of a link it is, as absolute denies; the kernel never proposes it as a write directory
67
+ * ({@link isSandboxHomeWriteDenied}). `~/.local/bin` and `~/.cargo/bin` are
68
+ * {@link SANDBOX_MANDATORY_WRITE_DENIES} entries.
69
+ */
70
+ export declare const SANDBOX_HOME_WRITE_DENIES: readonly (readonly string[])[];
71
+ /**
72
+ * System runtime and socket directories (compared folded, anchored at `/`): other programs keep
73
+ * their UNIX sockets and device nodes there (`/run/user/<uid>/bus`, `/var/run/docker.sock`,
74
+ * `/dev`, `/proc`), so a restricted write root never is one, lies inside one or contains one
75
+ * ({@link sandboxRuntimeDirectoryOf}).
76
+ */
77
+ export declare const SANDBOX_RUNTIME_DIRECTORIES: readonly string[];
78
+ /**
79
+ * Absolute system paths denied with everything beneath them, compared folded and anchored at `/`:
80
+ * the crontab and at spools of Linux (`/var/spool/cron` in its `crontabs` and `tabs` layouts,
81
+ * `/var/spool/at`) and macOS (`/private/var/at`, also spelled `/var/at`; `/usr/lib/cron/tabs` is a
82
+ * link resolving there). Never protected move names: a project's own `at/` or `spool/` stays
83
+ * ordinary.
84
+ */
85
+ export declare const SANDBOX_SYSTEM_WRITE_DENIES: readonly string[];
86
+ /**
87
+ * The name prefix the Linux broker reserves for its own staging (a directory checked before it
88
+ * moves into a guarded place) and quarantine names. Any path with a component starting with it
89
+ * (compared folded) is denied to every sandboxed write, so nothing sandboxed can create, write
90
+ * into, or move into or out of such a directory.
91
+ */
92
+ export declare const SANDBOX_RESERVED_NAME_PREFIX = ".capybara-staging-";
93
+ /** Directories inside a gitdir whose whole subtree is writable (objects, refs, operation state). */
94
+ export declare const SANDBOX_GIT_ALLOWED_DIRECTORIES: readonly string[];
95
+ /** Entries directly in a gitdir that are writable, each also with a `.lock` suffix. */
96
+ export declare const SANDBOX_GIT_ALLOWED_FILES: readonly string[];
97
+ /**
98
+ * For consumers that can only express denies as path patterns (the macOS runtime): the gitdir
99
+ * internals that run or redirect code, denied at any depth below `.git`. Such a consumer cannot
100
+ * express the allowlist or the `HEAD` rule exactly; see the rules above.
101
+ */
102
+ export declare const SANDBOX_GIT_DENIED_INTERNALS: readonly string[];
103
+ /**
104
+ * Names nothing leaves, and no directory is moved under, from outside: `.git` and the
105
+ * single-component entries. A multi-component entry is guarded by its prefix rule instead (rule 4),
106
+ * so its first component (`library`, `.config`) stays an ordinary name.
107
+ */
108
+ export declare const SANDBOX_PROTECTED_PATH_NAMES: readonly string[];
109
+ /** NFKC, then full case folding: the same as Python's `normalize("NFKC", s).casefold()`. */
110
+ export declare function sandboxFoldName(name: string): string;
111
+ /**
112
+ * The system runtime or socket directory a restricted write root `root` (absolute, normalized) is,
113
+ * lies inside or contains, or null: {@link SANDBOX_RUNTIME_DIRECTORIES} with everything beneath
114
+ * them; `/tmp` and `/private/tmp` themselves (a subdirectory is fine unless it is a known socket
115
+ * directory such as `/tmp/.X11-unix`, `/tmp/tmux-<uid>` or `/tmp/ssh-*`, or lies inside one); and
116
+ * every ancestor of one (`/var`, `/private`). The kernel's candidate builder and admission and the
117
+ * device's root check refuse such a root: a socket there may belong to a process outside the
118
+ * sandbox (the Linux broker also refuses every pathname UNIX connect to a socket the operation did
119
+ * not bind itself).
120
+ */
121
+ export declare function sandboxRuntimeDirectoryOf(root: string): string | null;
122
+ /**
123
+ * Whether `path` (absolute, normalized) is a {@link SANDBOX_HOME_WRITE_DENIES} location under
124
+ * `home`, or beneath one (names compared folded).
125
+ */
126
+ export declare function isSandboxHomeWriteDenied(path: string, home: string): boolean;
127
+ /** Whether restricted execution may never write `path` (an absolute, normalized path). */
128
+ export declare function isSandboxWriteDenied(path: string): boolean;
129
+ /**
130
+ * Whether a restricted rename or link of `source` to `destination` is refused (rule 4).
131
+ * `sourceEntries` are the names directly in a moved directory; the check needs them only when the
132
+ * destination ends in a proper prefix of a guarded entry, and without them it refuses.
133
+ */
134
+ export declare function isSandboxMoveDenied(source: string, destination: string, sourceIsDirectory: boolean, sourceEntries?: readonly string[]): boolean;
135
+ /**
136
+ * The same policy for the Python consumers (`linux-sandbox.py`, `native-files.py`): defines
137
+ * `write_denied(path)` and `move_denied(source, destination, is_dir)` with identical rules.
138
+ */
139
+ export declare const SANDBOX_WRITE_POLICY_PYTHON: string;