@intentic/sandbox-contract 1.376.0 → 1.378.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.
Files changed (153) hide show
  1. package/README.md +4 -0
  2. package/dist/contracts/access-profiles.contract.d.ts.map +1 -1
  3. package/dist/contracts/access-profiles.contract.js +3 -1
  4. package/dist/contracts/access-profiles.contract.js.map +1 -1
  5. package/dist/contracts/accounts.contract.d.ts +4 -0
  6. package/dist/contracts/accounts.contract.d.ts.map +1 -1
  7. package/dist/contracts/accounts.contract.js +6 -5
  8. package/dist/contracts/accounts.contract.js.map +1 -1
  9. package/dist/contracts/agent.contract.d.ts +4 -0
  10. package/dist/contracts/agent.contract.d.ts.map +1 -1
  11. package/dist/contracts/agents.contract.d.ts +76 -0
  12. package/dist/contracts/agents.contract.d.ts.map +1 -1
  13. package/dist/contracts/areas.contract.d.ts.map +1 -1
  14. package/dist/contracts/areas.contract.js +3 -1
  15. package/dist/contracts/areas.contract.js.map +1 -1
  16. package/dist/contracts/compliance.contract.js +1 -1
  17. package/dist/contracts/compliance.contract.js.map +1 -1
  18. package/dist/contracts/diff.contract.d.ts +9 -0
  19. package/dist/contracts/diff.contract.d.ts.map +1 -1
  20. package/dist/contracts/git.contract.d.ts +372 -1
  21. package/dist/contracts/git.contract.d.ts.map +1 -1
  22. package/dist/contracts/git.contract.js +47 -17
  23. package/dist/contracts/git.contract.js.map +1 -1
  24. package/dist/contracts/ports.contract.js +1 -1
  25. package/dist/contracts/ports.contract.js.map +1 -1
  26. package/dist/contracts/privacy.contract.d.ts.map +1 -1
  27. package/dist/contracts/privacy.contract.js +6 -5
  28. package/dist/contracts/privacy.contract.js.map +1 -1
  29. package/dist/contracts/runner.contract.d.ts +123 -123
  30. package/dist/contracts/secrets.contract.d.ts.map +1 -1
  31. package/dist/contracts/secrets.contract.js +4 -3
  32. package/dist/contracts/secrets.contract.js.map +1 -1
  33. package/dist/contracts/settings.contract.js +1 -1
  34. package/dist/contracts/settings.contract.js.map +1 -1
  35. package/dist/contracts/system.contract.d.ts +54 -30
  36. package/dist/contracts/system.contract.d.ts.map +1 -1
  37. package/dist/contracts/workspace.contract.d.ts +46 -0
  38. package/dist/contracts/workspace.contract.d.ts.map +1 -1
  39. package/dist/contracts/workspace.contract.js +2 -2
  40. package/dist/contracts/workspace.contract.js.map +1 -1
  41. package/dist/events/system-events.d.ts +16 -0
  42. package/dist/events/system-events.d.ts.map +1 -1
  43. package/dist/index.d.ts +535 -1
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/policy/command-classes.d.ts.map +1 -1
  46. package/dist/policy/command-classes.js +1 -1
  47. package/dist/policy/command-classes.js.map +1 -1
  48. package/dist/protocol/member-reach.d.ts +2 -1
  49. package/dist/protocol/member-reach.d.ts.map +1 -1
  50. package/dist/protocol/member-reach.js +5 -1
  51. package/dist/protocol/member-reach.js.map +1 -1
  52. package/dist/protocol/raw/raw-json-routes.d.ts +37 -0
  53. package/dist/protocol/raw/raw-json-routes.d.ts.map +1 -1
  54. package/dist/protocol/raw/raw-routes.d.ts +10 -4
  55. package/dist/protocol/raw/raw-routes.d.ts.map +1 -1
  56. package/dist/protocol/raw/raw-routes.js +9 -9
  57. package/dist/protocol/raw/raw-routes.js.map +1 -1
  58. package/dist/protocol/route-meta.d.ts +3 -0
  59. package/dist/protocol/route-meta.d.ts.map +1 -1
  60. package/dist/protocol/route-meta.js +1 -0
  61. package/dist/protocol/route-meta.js.map +1 -1
  62. package/dist/schemas/agent.d.ts +8 -0
  63. package/dist/schemas/agent.d.ts.map +1 -1
  64. package/dist/schemas/agent.js +4 -1
  65. package/dist/schemas/agent.js.map +1 -1
  66. package/dist/schemas/agents-list.d.ts +8 -0
  67. package/dist/schemas/agents-list.d.ts.map +1 -1
  68. package/dist/schemas/agents.d.ts +12 -0
  69. package/dist/schemas/agents.d.ts.map +1 -1
  70. package/dist/schemas/agents.js +4 -1
  71. package/dist/schemas/agents.js.map +1 -1
  72. package/dist/schemas/conversation-links.d.ts +9 -0
  73. package/dist/schemas/conversation-links.d.ts.map +1 -1
  74. package/dist/schemas/conversation-links.js +13 -0
  75. package/dist/schemas/conversation-links.js.map +1 -1
  76. package/dist/schemas/diff.d.ts +9 -0
  77. package/dist/schemas/diff.d.ts.map +1 -1
  78. package/dist/schemas/diff.js +2 -0
  79. package/dist/schemas/diff.js.map +1 -1
  80. package/dist/schemas/git/branch-landings.d.ts +27 -0
  81. package/dist/schemas/git/branch-landings.d.ts.map +1 -0
  82. package/dist/schemas/git/branch-landings.js +20 -0
  83. package/dist/schemas/git/branch-landings.js.map +1 -0
  84. package/dist/schemas/git/git-history.d.ts +80 -0
  85. package/dist/schemas/git/git-history.d.ts.map +1 -1
  86. package/dist/schemas/git/git-history.js +17 -17
  87. package/dist/schemas/git/git-history.js.map +1 -1
  88. package/dist/schemas/git/git-view.d.ts +32 -0
  89. package/dist/schemas/git/git-view.d.ts.map +1 -0
  90. package/dist/schemas/git/git-view.js +19 -0
  91. package/dist/schemas/git/git-view.js.map +1 -0
  92. package/dist/schemas/git/git.d.ts +48 -0
  93. package/dist/schemas/git/git.d.ts.map +1 -1
  94. package/dist/schemas/git/git.js +12 -10
  95. package/dist/schemas/git/git.js.map +1 -1
  96. package/dist/schemas/git/index-run.d.ts +6 -0
  97. package/dist/schemas/git/index-run.d.ts.map +1 -1
  98. package/dist/schemas/git/index-run.js +2 -2
  99. package/dist/schemas/git/index-run.js.map +1 -1
  100. package/dist/schemas/members.d.ts +60 -1
  101. package/dist/schemas/members.d.ts.map +1 -1
  102. package/dist/schemas/members.js +42 -5
  103. package/dist/schemas/members.js.map +1 -1
  104. package/dist/schemas/providers/account-sharing.d.ts +2 -0
  105. package/dist/schemas/providers/account-sharing.d.ts.map +1 -1
  106. package/dist/schemas/providers/provider-oauth.d.ts +4 -0
  107. package/dist/schemas/providers/provider-oauth.d.ts.map +1 -1
  108. package/dist/schemas/providers/provider-oauth.js +4 -0
  109. package/dist/schemas/providers/provider-oauth.js.map +1 -1
  110. package/dist/schemas/shared.d.ts +7 -0
  111. package/dist/schemas/shared.d.ts.map +1 -1
  112. package/dist/schemas/shared.js +13 -0
  113. package/dist/schemas/shared.js.map +1 -1
  114. package/dist/schemas/workspace/workspace-tree.d.ts +31 -0
  115. package/dist/schemas/workspace/workspace-tree.d.ts.map +1 -1
  116. package/dist/schemas/workspace/workspace-tree.js +7 -3
  117. package/dist/schemas/workspace/workspace-tree.js.map +1 -1
  118. package/dist/text/git-branch-switch.d.ts +2 -0
  119. package/dist/text/git-branch-switch.d.ts.map +1 -0
  120. package/dist/text/git-branch-switch.js +7 -0
  121. package/dist/text/git-branch-switch.js.map +1 -0
  122. package/package.json +5 -5
  123. package/src/contracts/access-profiles.contract.ts +3 -1
  124. package/src/contracts/accounts.contract.ts +9 -5
  125. package/src/contracts/areas.contract.ts +3 -1
  126. package/src/contracts/compliance.contract.ts +1 -1
  127. package/src/contracts/git.contract.ts +50 -17
  128. package/src/contracts/ports.contract.ts +1 -1
  129. package/src/contracts/privacy.contract.ts +10 -8
  130. package/src/contracts/secrets.contract.ts +6 -3
  131. package/src/contracts/settings.contract.ts +1 -1
  132. package/src/contracts/workspace.contract.ts +2 -2
  133. package/src/policy/command-classes.ts +1 -4
  134. package/src/policy/tests/command-classes.test.ts +23 -0
  135. package/src/protocol/member-reach.test.ts +61 -4
  136. package/src/protocol/member-reach.ts +12 -4
  137. package/src/protocol/raw/raw-routes.ts +19 -16
  138. package/src/protocol/route-meta.ts +5 -0
  139. package/src/schemas/agent.ts +4 -1
  140. package/src/schemas/agents.ts +7 -1
  141. package/src/schemas/conversation-links.ts +25 -0
  142. package/src/schemas/diff.ts +2 -0
  143. package/src/schemas/git/branch-landings.ts +25 -0
  144. package/src/schemas/git/git-history.ts +17 -17
  145. package/src/schemas/git/git-view.ts +22 -0
  146. package/src/schemas/git/git.ts +13 -13
  147. package/src/schemas/git/index-run.ts +2 -2
  148. package/src/schemas/members.test.ts +53 -1
  149. package/src/schemas/members.ts +93 -11
  150. package/src/schemas/providers/provider-oauth.ts +6 -0
  151. package/src/schemas/shared.ts +21 -0
  152. package/src/schemas/workspace/workspace-tree.ts +11 -3
  153. package/src/text/git-branch-switch.ts +16 -0
@@ -1,7 +1,7 @@
1
+ import { GitRepoParamSchema } from "./git-view.js";
1
2
  // The Git Graph view over a repo's real commits.
2
3
  import { z } from "zod";
3
4
  import { RefNameSchema } from "../internal.js";
4
- import { RepoParamSchema } from "../shared.js";
5
5
  import { GitChangeSchema } from "./git.js";
6
6
  // A hex sha, full or abbreviated; commit routes accept only this, never an arbitrary git revision expression.
7
7
  const ShaSchema = z.string().regex(/^[0-9a-f]{4,64}$/);
@@ -38,7 +38,7 @@ export const GitLogSchema = z.object({
38
38
  ),
39
39
  });
40
40
  export type GitLog = z.infer<typeof GitLogSchema>;
41
- export const GitLogQuerySchema = RepoParamSchema.extend({
41
+ export const GitLogQuerySchema = GitRepoParamSchema.extend({
42
42
  limit: z.coerce.number().int().positive().max(2000).optional().describe("How many commits to return."),
43
43
  // Page cursor: how many newer commits to skip before returning results.
44
44
  skip: z.coerce
@@ -70,7 +70,7 @@ export const GitRemoteReposSchema = z.object({
70
70
  export type GitRemoteRepos = z.infer<typeof GitRemoteReposSchema>;
71
71
  // Writes one file to the default branch and publishes it: write, commit that path alone, push, in one call. `message`
72
72
  // is the caller's, since it lands in the user's own commit history.
73
- export const GitPublishFileSchema = RepoParamSchema.extend({
73
+ export const GitPublishFileSchema = GitRepoParamSchema.extend({
74
74
  path: z.string().min(1).describe("Which file, relative to the repository."),
75
75
  content: z.string().describe("Its whole new contents."),
76
76
  message: z.string().min(1).describe("The commit message."),
@@ -92,7 +92,7 @@ export const GitPublishFileResultSchema = z.object({
92
92
  ),
93
93
  });
94
94
  export type GitPublishFileResult = z.infer<typeof GitPublishFileResultSchema>;
95
- export const GitCommitDiffQuerySchema = RepoParamSchema.extend({ sha: ShaSchema.describe("Which commit.") });
95
+ export const GitCommitDiffQuerySchema = GitRepoParamSchema.extend({ sha: ShaSchema.describe("Which commit.") });
96
96
  // A commit's changed files, diffed against its first parent (a root commit against the empty tree); reuses `GitChange`
97
97
  // so working-tree and commit diffs share one shape.
98
98
  export const GitCommitDiffSchema = z.object({
@@ -103,32 +103,32 @@ export const GitCommitDiffSchema = z.object({
103
103
  ),
104
104
  });
105
105
  export type GitCommitDiff = z.infer<typeof GitCommitDiffSchema>;
106
- export const GitCommitFileDiffQuerySchema = RepoParamSchema.extend({
106
+ export const GitCommitFileDiffQuerySchema = GitRepoParamSchema.extend({
107
107
  sha: ShaSchema.describe("Which commit."),
108
108
  path: z.string().min(1).describe("Which file in it."),
109
109
  });
110
110
  // Git write actions from the graph's context menu. Branch/tag only add a ref (no checkpoint); sequence ops, checkout,
111
111
  // and reset are auto-checkpointed, and a conflict returns `ok:false` instead of throwing.
112
- export const GitBranchCreateSchema = RepoParamSchema.extend({
112
+ export const GitBranchCreateSchema = GitRepoParamSchema.extend({
113
113
  sha: ShaSchema.describe("Which commit to start it at."),
114
114
  name: RefNameSchema.describe("The new branch's name."),
115
115
  });
116
- export const GitTagCreateSchema = RepoParamSchema.extend({
116
+ export const GitTagCreateSchema = GitRepoParamSchema.extend({
117
117
  sha: ShaSchema.describe("Which commit to tag."),
118
118
  name: RefNameSchema.describe("The tag's name."),
119
119
  });
120
- export const GitCheckoutSchema = RepoParamSchema.extend({ ref: RefNameSchema.describe("Where to switch to: a branch, a tag, or a commit.") });
120
+ export const GitCheckoutSchema = GitRepoParamSchema.extend({ ref: RefNameSchema.describe("Where to switch to: a branch, a tag, or a commit.") });
121
121
  // Deletes a tag locally, and on the named remote too; a tag never pushed there does not fail the local delete.
122
- export const GitTagDeleteSchema = RepoParamSchema.extend({
122
+ export const GitTagDeleteSchema = GitRepoParamSchema.extend({
123
123
  name: RefNameSchema.describe("Which tag."),
124
124
  remote: RefNameSchema.optional().describe("Also delete it there. Leave it out to remove it locally only."),
125
125
  });
126
126
  // Pushes only the named tag, never every unpushed tag.
127
- export const GitTagPushSchema = RepoParamSchema.extend({
127
+ export const GitTagPushSchema = GitRepoParamSchema.extend({
128
128
  name: RefNameSchema.describe("Which tag."),
129
129
  remote: RefNameSchema.describe("Which remote to send it to."),
130
130
  });
131
- export const GitResetSchema = RepoParamSchema.extend({
131
+ export const GitResetSchema = GitRepoParamSchema.extend({
132
132
  sha: ShaSchema.describe("Which commit to move the branch to."),
133
133
  mode: z
134
134
  .enum(["soft", "mixed", "hard"])
@@ -136,7 +136,7 @@ export const GitResetSchema = RepoParamSchema.extend({
136
136
  "How much to take with it: move the branch alone, also unstage, or also throw away what is on disk. The last one takes a checkpoint first.",
137
137
  ),
138
138
  });
139
- export const GitCommitActionSchema = RepoParamSchema.extend({ sha: ShaSchema.describe("Which commit to act on.") });
139
+ export const GitCommitActionSchema = GitRepoParamSchema.extend({ sha: ShaSchema.describe("Which commit to act on.") });
140
140
  export const GitActionResultSchema = z.object({
141
141
  ok: z.boolean().describe("Whether it worked."),
142
142
  reason: z
@@ -166,17 +166,17 @@ export const StashListSchema = z.object({
166
166
  });
167
167
  // A stash ref as git numbers it (`stash@{0}`); constrained because it reaches a shell argument.
168
168
  const StashRefSchema = z.string().regex(/^stash@\{\d{1,4}\}$/);
169
- export const StashPushSchema = RepoParamSchema.extend({
169
+ export const StashPushSchema = GitRepoParamSchema.extend({
170
170
  message: z.string().max(500).optional().describe("What to call it, so you know what it was later."),
171
171
  includeUntracked: z.boolean().optional().describe("Also set aside files git is not yet tracking, which are otherwise left where they are."),
172
172
  });
173
173
  // `pop` drops the entry after a clean apply; `apply` keeps it, git's own resume-vs-try-again distinction.
174
- export const StashApplySchema = RepoParamSchema.extend({
174
+ export const StashApplySchema = GitRepoParamSchema.extend({
175
175
  ref: StashRefSchema.describe("Which entry."),
176
176
  pop: z.boolean().optional().describe("Remove it from the stash once it has been applied cleanly."),
177
177
  });
178
- export const StashRefParamSchema = RepoParamSchema.extend({ ref: StashRefSchema.describe("Which entry.") });
179
- export const StashDiffQuerySchema = RepoParamSchema.extend({ ref: StashRefSchema.describe("Which entry.") });
178
+ export const StashRefParamSchema = GitRepoParamSchema.extend({ ref: StashRefSchema.describe("Which entry.") });
179
+ export const StashDiffQuerySchema = GitRepoParamSchema.extend({ ref: StashRefSchema.describe("Which entry.") });
180
180
  // The last ref move on this branch, and whether it can be undone; complements Checkpoints, which restores the working
181
181
  // tree instead. `previousSha` doubles as a concurrency token: refused if the branch moved since it was read.
182
182
  export const UndoKindSchema = z.enum(["commit", "amend", "merge", "rebase", "cherry-pick", "revert", "reset", "pull", "other"]);
@@ -203,7 +203,7 @@ export const GitUndoStateSchema = z.object({
203
203
  });
204
204
  export type GitUndoState = z.infer<typeof GitUndoStateSchema>;
205
205
  // `previousSha` must match what the caller was shown; `discardChanges` picks a hard reset over a soft one.
206
- export const GitUndoSchema = RepoParamSchema.extend({
206
+ export const GitUndoSchema = GitRepoParamSchema.extend({
207
207
  previousSha: ShaSchema.describe(
208
208
  "Where to go back to, from the matching read. It is also proof you looked: one prepared against a stale view is refused.",
209
209
  ),
@@ -0,0 +1,22 @@
1
+ import { z } from "zod";
2
+ import { RepoParamSchema } from "../shared.js";
3
+ import { WorkspaceScopeSchema } from "../workspace/workspace-tree.js";
4
+
5
+ export const GitViewSchema = WorkspaceScopeSchema.refine(
6
+ (view) => !(view.agent !== undefined && (view.branch !== undefined || view.repo !== undefined)) && (view.repo === undefined || view.branch !== undefined),
7
+ { message: "Choose one checkout: a conversation, a branch, or the shared workspace." },
8
+ );
9
+ export type GitView = z.infer<typeof GitViewSchema>;
10
+
11
+ export const GitViewQuerySchema = z.object({ view: GitViewSchema.optional() });
12
+ export const GitRepoParamSchema = RepoParamSchema.extend({ view: GitViewSchema.optional() });
13
+
14
+ export const EncodedGitViewSchema = z.union([
15
+ GitViewSchema,
16
+ z.string().transform((value, ctx) => {
17
+ try { return JSON.parse(value); } catch {
18
+ ctx.addIssue({ code: "custom", message: "Invalid checkout selection." });
19
+ return z.NEVER;
20
+ }
21
+ }).pipe(GitViewSchema),
22
+ ]);
@@ -1,12 +1,12 @@
1
+ import { GitRepoParamSchema } from "./git-view.js";
1
2
  import { z } from "zod";
2
3
  import { AgentProviderSchema } from "../agent.js";
3
4
  import { LandConflictSchema, LandedMessageSchema } from "../agents.js";
4
5
  import { CommandRunSchema } from "../ci.js";
5
6
  import { RefNameSchema } from "../internal.js";
6
- import { RepoParamSchema } from "../shared.js";
7
+ import { MainBranchSchema } from "../shared.js";
7
8
 
8
- // Which of the working tree's diffs a row is about; a path can be both staged and edited again, so a side is never
9
- // defaulted.
9
+ // Which working-tree diff a row names: a path can be both staged and edited again, so side is required.
10
10
  // staged: index vs HEAD.
11
11
  // unstaged: worktree vs index (untracked ⇒ no before side).
12
12
  // conflicted: HEAD vs worktree, markers included (no stage 0 to diff against).
@@ -65,7 +65,7 @@ const oneTarget = (target: GitTarget): boolean => target.paths === undefined ||
65
65
  // { paths }: stage exactly those paths, then commit.
66
66
  // Never `commit --only`: a partial commit over a half-staged file would record the worktree while the row showed the
67
67
  // index.
68
- export const CommitSchema = RepoParamSchema.extend({
68
+ export const CommitSchema = GitRepoParamSchema.extend({
69
69
  message: z.string().min(1).describe("The commit message."),
70
70
  stage: GitTargetSchema.refine(oneTarget, ONE_TARGET)
71
71
  .optional()
@@ -73,7 +73,7 @@ export const CommitSchema = RepoParamSchema.extend({
73
73
  "What to stage before committing. Leave it out to record the index exactly as it stands; give it an empty object to stage everything first.",
74
74
  ),
75
75
  });
76
- export const DiscardSchema = RepoParamSchema.extend(GitTargetSchema.shape)
76
+ export const DiscardSchema = GitRepoParamSchema.extend(GitTargetSchema.shape)
77
77
  .describe("What to throw away. Neither paths nor a scope discards every uncommitted change in the repository.")
78
78
  .refine(oneTarget, ONE_TARGET);
79
79
  // Index-only moves; nothing on disk changes, so neither needs a checkpoint. An empty target means the whole repository
@@ -83,7 +83,7 @@ export const DiscardSchema = RepoParamSchema.extend(GitTargetSchema.shape)
83
83
  // merge's clean result survives one on/off. It names its own target, so it goes alone.
84
84
  const oneIndexMove = (move: GitTarget & { readonly chip?: string | undefined }): boolean =>
85
85
  oneTarget(move) && (move.chip === undefined || (move.paths === undefined && move.scope === undefined));
86
- export const GitIndexMoveSchema = RepoParamSchema.extend(GitTargetSchema.shape)
86
+ export const GitIndexMoveSchema = GitRepoParamSchema.extend(GitTargetSchema.shape)
87
87
  .extend({
88
88
  chip: z
89
89
  .string()
@@ -97,7 +97,7 @@ export const GitIndexMoveSchema = RepoParamSchema.extend(GitTargetSchema.shape)
97
97
  .refine(oneIndexMove, { message: "name paths, a scope or a chip, not more than one" });
98
98
  // No separate "set upstream" flag: the daemon runs `push -u` exactly when the branch has none yet, which is never
99
99
  // destructive.
100
- export const PushSchema = RepoParamSchema.extend({
100
+ export const PushSchema = GitRepoParamSchema.extend({
101
101
  branch: z
102
102
  .string()
103
103
  .min(1)
@@ -124,12 +124,12 @@ export const PushRunSchema = CommandRunSchema.extend({
124
124
  ),
125
125
  });
126
126
  export type PushRun = z.infer<typeof PushRunSchema>;
127
- export const GitFileQuerySchema = RepoParamSchema.extend({ path: z.string().min(1).describe("The file to read, relative to the repository root.") });
128
- export const GitFileWriteSchema = RepoParamSchema.extend({
127
+ export const GitFileQuerySchema = GitRepoParamSchema.extend({ path: z.string().min(1).describe("The file to read, relative to the repository root.") });
128
+ export const GitFileWriteSchema = GitRepoParamSchema.extend({
129
129
  path: z.string().min(1).describe("Where to write, relative to the repository root. Missing folders are created."),
130
130
  content: z.string().describe("The file's whole new contents."),
131
131
  });
132
- export const GitFileDiffQuerySchema = RepoParamSchema.extend({
132
+ export const GitFileDiffQuerySchema = GitRepoParamSchema.extend({
133
133
  path: z.string().min(1).describe("The file, relative to the repository root."),
134
134
  side: GitDiffSideSchema.describe(
135
135
  "Which comparison you want. A file that is staged and then edited again has genuinely different answers for each, which is why this is required rather than assumed.",
@@ -234,13 +234,13 @@ export const GitBranchesSchema = z.object({
234
234
  });
235
235
  export type GitBranches = z.infer<typeof GitBranchesSchema>;
236
236
  // Creates at `start` (sha or ref; absent means HEAD); `checkout` switches to it immediately.
237
- export const GitBranchCreateAtSchema = RepoParamSchema.extend({
237
+ export const GitBranchCreateAtSchema = GitRepoParamSchema.extend({
238
238
  name: RefNameSchema.describe("The new branch's name."),
239
239
  start: z.string().min(1).optional().describe("Where to start it: a commit or another branch. Leave it out to start from where you are."),
240
240
  checkout: z.boolean().optional().describe("Switch to it as well as creating it."),
241
241
  });
242
242
  // `force` is the deliberate retry after git refuses to drop an unmerged branch.
243
- export const GitBranchDeleteSchema = RepoParamSchema.extend({
243
+ export const GitBranchDeleteSchema = GitRepoParamSchema.extend({
244
244
  name: RefNameSchema.describe("The branch to delete."),
245
245
  force: z
246
246
  .boolean()
@@ -293,8 +293,8 @@ export const IGNORED_OUTPUTS_LISTED = 200;
293
293
  export const RepoChangesSchema = z.object({
294
294
  // The {repo} param the per-repo git routes accept: "root" or a repo id (its root-relative dir).
295
295
  repo: z.string(),
296
- // Absent on an unborn HEAD (initialized, never committed).
297
296
  branch: z.string().optional().describe("The checked-out branch. Absent in a repository that has no commits yet."),
297
+ mainBranch: MainBranchSchema,
298
298
  // Staging a conflicted path (`git add`) is how you tell git it is resolved.
299
299
  conflicted: z
300
300
  .array(GitChangeSchema)
@@ -1,6 +1,6 @@
1
+ import { GitRepoParamSchema } from "./git-view.js";
1
2
  import { z } from "zod";
2
3
  import { CommandRunSchema } from "../ci.js";
3
- import { RepoParamSchema } from "../shared.js";
4
4
  import { CommitResultSchema, GitTargetSchema } from "./git.js";
5
5
 
6
6
  // Stage-all and commit-all as runs the daemon keeps, not requests held open: over a tree of tens of thousands of
@@ -40,7 +40,7 @@ export type IndexRunHold = z.infer<typeof IndexRunHoldSchema>;
40
40
 
41
41
  // Flat rather than a union on `op`: the route's path parameter merges into the input, which a discriminated union cannot
42
42
  // take, and the one cross-field rule (a commit needs a message) is a refine.
43
- export const IndexRunStartSchema = RepoParamSchema.extend({
43
+ export const IndexRunStartSchema = GitRepoParamSchema.extend({
44
44
  op: IndexRunOpSchema.describe("Stage, or commit (staging `target` first when given)."),
45
45
  target: GitTargetSchema.optional().describe(
46
46
  "What to stage. For a stage, leave it out for the whole repository. For a commit, leave it out to record the index exactly as it stands, or give an empty object to stage everything first.",
@@ -1,4 +1,4 @@
1
- import { accessRefusal, landsHere, memberAccess, tierOf } from "./members.js";
1
+ import { accessRefusal, holdsRight, landsHere, memberAccess, peopleChangeRefusal, tierOf } from "./members.js";
2
2
 
3
3
  // A person's access is three answers, and the tier is what they add up to; a row from before the answers reads as its
4
4
  // role meant, so nobody's access moves when the daemon learns the new fields.
@@ -73,3 +73,55 @@ describe(`home-only access`, () => {
73
73
  expect(landsHere({ manage: false, agents: `run`, lands: true })).toBe(false);
74
74
  });
75
75
  });
76
+
77
+ describe(`rights`, () => {
78
+ test(`the owner and Full access run every part; anyone else what their row names`, () => {
79
+ expect(holdsRight({ role: `owner` }, `people`)).toBe(true);
80
+ expect(holdsRight({ role: `maintainer` }, `secrets`)).toBe(true);
81
+ expect(holdsRight({ role: `collaborator`, manages: [`people`] }, `people`)).toBe(true);
82
+ expect(holdsRight({ role: `collaborator`, manages: [`people`] }, `secrets`)).toBe(false);
83
+ expect(holdsRight({ role: `writer` }, `privacy`)).toBe(false);
84
+ });
85
+
86
+ test(`a row's rights ride on its access, and never make a tier`, () => {
87
+ const access = memberAccess({ role: `collaborator`, agents: `run`, manages: [`people`, `ownAccounts`] });
88
+ expect(access.manages).toEqual([`people`, `ownAccounts`]);
89
+ expect(tierOf(access)).toBe(`collaborator`);
90
+ expect(memberAccess({ role: `collaborator`, agents: `run`, manages: [] }).manages).toBeUndefined();
91
+ });
92
+
93
+ test(`someone who only chats or works through their home holds none`, () => {
94
+ expect(accessRefusal({ manage: false, agents: `chat`, see: [`docs`], edit: `none`, manages: [`people`] })).toContain(`holds no rights`);
95
+ expect(accessRefusal({ manage: false, agents: `home`, see: undefined, edit: `none`, manages: [`secrets`] })).toContain(`holds no rights`);
96
+ expect(accessRefusal({ manage: false, agents: `off`, see: undefined, edit: `none`, manages: [`people`] })).toBeUndefined();
97
+ });
98
+ });
99
+
100
+ describe(`peopleChangeRefusal`, () => {
101
+ const lead = { email: `lead@example.com`, role: `collaborator` as const, manages: [`people` as const, `ownAccounts` as const] };
102
+
103
+ test(`the owner and Full access change anyone, themselves included`, () => {
104
+ expect(peopleChangeRefusal({ email: `o@example.com`, role: `owner` }, { email: `x@example.com`, after: { role: `maintainer` } })).toBeUndefined();
105
+ const full = { email: `m@example.com`, role: `maintainer` as const };
106
+ expect(peopleChangeRefusal(full, { email: `m@example.com`, before: { role: `maintainer` }, after: { role: `collaborator` } })).toBeUndefined();
107
+ expect(peopleChangeRefusal(full, { email: `x@example.com`, before: { role: `maintainer` } })).toBeUndefined();
108
+ });
109
+
110
+ test(`People & access changes anyone below Full access but its holder`, () => {
111
+ expect(peopleChangeRefusal(lead, { email: `new@example.com`, after: { role: `writer` } })).toBeUndefined();
112
+ expect(peopleChangeRefusal(lead, { email: `x@example.com`, before: { role: `viewer` } })).toBeUndefined();
113
+ expect(peopleChangeRefusal(lead, { email: `LEAD@example.com`, before: { role: `collaborator` }, after: { role: `writer` } })).toContain(`your own access`);
114
+ expect(peopleChangeRefusal(lead, { email: `x@example.com`, after: { role: `maintainer` } })).toContain(`Full access is granted`);
115
+ expect(peopleChangeRefusal(lead, { email: `x@example.com`, before: { role: `maintainer` } })).toContain(`Full access person`);
116
+ expect(peopleChangeRefusal({ ...lead, manages: [] }, { email: `x@example.com`, after: { role: `viewer` } })).toContain(`People & access`);
117
+ });
118
+
119
+ test(`it hands out only the rights its holder has, and leaves the ones already held alone`, () => {
120
+ expect(peopleChangeRefusal(lead, { email: `x@example.com`, after: { role: `viewer`, manages: [`people`, `ownAccounts`] } })).toBeUndefined();
121
+ expect(peopleChangeRefusal(lead, { email: `x@example.com`, after: { role: `viewer`, manages: [`secrets`] } })).toContain(`secrets`);
122
+ expect(
123
+ peopleChangeRefusal(lead, { email: `x@example.com`, before: { role: `viewer`, manages: [`secrets`] }, after: { role: `writer`, manages: [`secrets`] } }),
124
+ ).toBeUndefined();
125
+ expect(peopleChangeRefusal(lead, { email: `x@example.com`, before: { role: `viewer`, manages: [`secrets`] }, after: { role: `writer` } })).toBeUndefined();
126
+ });
127
+ });
@@ -2,9 +2,62 @@
2
2
  import { z } from "zod";
3
3
  import type { CapabilityKind } from "./capabilities.js";
4
4
  import { entryId } from "./internal.js";
5
- import { type GrantedRole, GrantedRoleSchema, MemberRoleSchema } from "./shared.js";
5
+ import { type GrantedRole, GrantedRoleSchema, type MemberRole, MemberRoleSchema } from "./shared.js";
6
6
  import { ToolCeilingSchema } from "./tool-ceiling.js";
7
7
 
8
+ // WHAT A PERSON MAY RUN BESIDES THEIR OWN WORK, one part of the sandbox at a time. Full access (the maintainer tier) holds
9
+ // every one; a person with access of their own holds the ones named on their row, so the owner can hand over who gets in
10
+ // without handing over the whole box (docs/architecture/access.md).
11
+ // `people`: who has access and to what (the roster, the requests for more, areas, access profiles, who opens previews,
12
+ // another member's passkeys). Bounded below Full access by `peopleChangeRefusal`.
13
+ // `secrets`: the Secrets page whole: stored secrets, who must approve a use, where a secret may go, and how a command-line
14
+ // tool's credential reaches the agent.
15
+ // `privacy`: the privacy shield: what it masks, reading masked values back, and forgetting a taught dataset.
16
+ // `ownAccounts`: connecting AI accounts of their own. An account a person connected is theirs to run on whatever their
17
+ // `aiAccounts` says, and theirs to rename or disconnect (the daemon's auth/members/account-connectors.ts).
18
+ export const ManageRightSchema = z.enum(["people", "secrets", "privacy", "ownAccounts"]);
19
+ export type ManageRight = z.infer<typeof ManageRightSchema>;
20
+ export const MANAGE_RIGHTS: readonly ManageRight[] = ManageRightSchema.options;
21
+
22
+ /** Whether this person may run one part of the sandbox: the owner and Full access run every part, anyone else what their row names. */
23
+ export const holdsRight = (caller: { readonly role: MemberRole; readonly manages?: readonly ManageRight[] | undefined }, right: ManageRight): boolean =>
24
+ caller.role === "owner" || caller.role === "maintainer" || (caller.manages?.includes(right) ?? false);
25
+
26
+ /**
27
+ * Why someone who manages people may not make this change to one person's access; undefined when they may. The owner and
28
+ * Full access change anyone's, their own included. The People & access right alone changes the access of anyone below
29
+ * Full access but its holder: it never grants Full access, never changes a Full access person's, never its holder's own
30
+ * (that is how a limit set on them holds), and hands out only the rights its holder has. `after` absent is a removal;
31
+ * its `manages` absent keeps the row's, as a grant reads it.
32
+ */
33
+ export const peopleChangeRefusal = (
34
+ manager: { readonly email: string; readonly role: MemberRole; readonly manages?: readonly ManageRight[] | undefined },
35
+ target: {
36
+ readonly email: string;
37
+ readonly before?: { readonly role: GrantedRole; readonly manages?: readonly ManageRight[] | undefined } | undefined;
38
+ readonly after?: { readonly role: GrantedRole; readonly manages?: readonly ManageRight[] | undefined } | undefined;
39
+ },
40
+ ): string | undefined => {
41
+ if (manager.role === "owner" || manager.role === "maintainer") {
42
+ return undefined;
43
+ }
44
+ if (!holdsRight(manager, "people")) {
45
+ return "only the owner, Full access, or someone given People & access changes who has access";
46
+ }
47
+ if (manager.email.toLowerCase() === target.email.toLowerCase()) {
48
+ return "your own access is changed by the owner or someone with Full access";
49
+ }
50
+ if (target.before?.role === "maintainer") {
51
+ return "a Full access person's access is changed by the owner or someone with Full access";
52
+ }
53
+ if (target.after?.role === "maintainer") {
54
+ return "Full access is granted by the owner or someone with Full access";
55
+ }
56
+ const had = new Set(target.before?.manages ?? []);
57
+ const handed = (target.after?.manages ?? []).filter((right) => !had.has(right) && !(manager.manages ?? []).includes(right));
58
+ return handed.length === 0 ? undefined : `you can hand out only the rights you hold yourself, and ${handed.join(", ")} is not one of yours`;
59
+ };
60
+
8
61
  // WHAT A PERSON'S CONVERSATIONS MAY SPEND: the connected capabilities (by id) and the stored secrets (by name) an agent
9
62
  // working for them is handed. Enforced by the daemon, not told to the model: a capability outside it is never mounted
10
63
  // for their turns, its variables and skill are left out, and every exit that spends a credential (a `{{secret:…}}`
@@ -90,6 +143,9 @@ export interface MemberAccess {
90
143
  // A home-only person's answer to whether their home conversation lands what it accepts by itself, and so whether
91
144
  // they may land it (`landsHere`). Absent is no; only `agents: "home"` may carry it.
92
145
  readonly lands?: boolean | undefined;
146
+ // The parts of the sandbox they run besides their own work (`ManageRightSchema`). Full access holds every one, so
147
+ // its rows never list them; absent is none.
148
+ readonly manages?: readonly ManageRight[] | undefined;
93
149
  }
94
150
 
95
151
  // The fields of a row or a grant that decide a person's access.
@@ -99,6 +155,7 @@ interface AccessFields {
99
155
  readonly agents?: AgentAccess | undefined;
100
156
  readonly edit?: EditScope | undefined;
101
157
  readonly lands?: boolean | undefined;
158
+ readonly manages?: readonly ManageRight[] | undefined;
102
159
  }
103
160
 
104
161
  /** A row's access: what it says, and for a row written before `agents` and `edit` existed, what its role meant then. */
@@ -109,7 +166,8 @@ export const memberAccess = (row: AccessFields): MemberAccess => {
109
166
  const agents = row.agents ?? (row.role === "guest" ? "chat" : row.role === "viewer" ? "off" : "run");
110
167
  // A writer from before `edit` changes files where it sees them, which its areas always named.
111
168
  const edit = row.edit ?? (row.role === "writer" && row.areas !== undefined ? [...row.areas] : "none");
112
- const access: MemberAccess = { manage: false, agents, see: row.areas, edit: agents === "chat" || agents === "home" ? "none" : edit };
169
+ const base: MemberAccess = { manage: false, agents, see: row.areas, edit: agents === "chat" || agents === "home" ? "none" : edit };
170
+ const access = row.manages !== undefined && row.manages.length > 0 ? { ...base, manages: [...row.manages] } : base;
113
171
  return row.lands === true ? { ...access, lands: true } : access;
114
172
  };
115
173
 
@@ -135,20 +193,26 @@ export const tierOf = (access: MemberAccess): GrantedRole => {
135
193
  return access.agents === "run" ? "collaborator" : "viewer";
136
194
  };
137
195
 
138
- /** Why an access cannot be granted on its face, before any area or assistant is looked up; undefined when it can. */
139
- export const accessRefusal = (access: MemberAccess): string | undefined => {
140
- if (access.manage) {
141
- return undefined;
142
- }
196
+ // Why a way of working cannot carry what else the access says: landing by itself, rights, areas and hand edits each
197
+ // belong to some ways of working only.
198
+ const workingRefusal = (access: MemberAccess): string | undefined => {
143
199
  if (access.lands === true && access.agents !== "home") {
144
200
  return "landing their own work by itself is a home-only answer; anyone else's work lands when somebody who manages the sandbox lands it";
145
201
  }
202
+ if ((access.manages?.length ?? 0) > 0 && (access.agents === "chat" || access.agents === "home")) {
203
+ return "running part of the sandbox needs someone who sees it: a person who only chats, or works through their home conversation, holds no rights";
204
+ }
146
205
  if (access.agents === "chat" && (access.see?.length ?? 0) === 0) {
147
206
  return "chatting with assistants needs at least one area: the assistants that work there are the ones they talk to";
148
207
  }
149
208
  if (access.agents === "home" && access.edit !== "none") {
150
209
  return "a home-only person changes nothing by hand: their home conversation does the work";
151
210
  }
211
+ return undefined;
212
+ };
213
+
214
+ // Why where a person edits by hand does not fit where they see.
215
+ const editRefusal = (access: MemberAccess): string | undefined => {
152
216
  if (access.edit === "all") {
153
217
  return access.see === undefined ? undefined : "editing everything they see needs the whole workspace; name the areas to edit instead";
154
218
  }
@@ -163,6 +227,9 @@ export const accessRefusal = (access: MemberAccess): string | undefined => {
163
227
  return unseen.length === 0 ? undefined : `they can only edit where they can see: ${unseen.join(", ")} is not among their areas`;
164
228
  };
165
229
 
230
+ /** Why an access cannot be granted on its face, before any area or assistant is looked up; undefined when it can. */
231
+ export const accessRefusal = (access: MemberAccess): string | undefined => (access.manage ? undefined : (workingRefusal(access) ?? editRefusal(access)));
232
+
166
233
  // One person on the roster as the daemon answers it. `areas` fences what of the workspace they reach, and with it which
167
234
  // assistants they may talk to: absent is the whole workspace, empty is nothing.
168
235
  export const MemberSchema = z.object({
@@ -208,6 +275,12 @@ export const MemberSchema = z.object({
208
275
  .describe(
209
276
  "The access profile their answers come from (docs/architecture/access.md). Its answers are written out on this row too, and saving the profile rewrites them. Absent means answers of their own.",
210
277
  ),
278
+ manages: z
279
+ .array(ManageRightSchema)
280
+ .optional()
281
+ .describe(
282
+ "The parts of the sandbox they run besides their own work: people and access, secrets, the privacy shield, AI accounts of their own. Never on a maintainer, who runs every part. Absent means none.",
283
+ ),
211
284
  });
212
285
  export type Member = z.infer<typeof MemberSchema>;
213
286
 
@@ -237,6 +310,10 @@ export type MembersRoster = z.infer<typeof MembersRosterSchema>;
237
310
  // the row and ignores the access fields sent beside it, and the role sent must still be the tier the profile makes.
238
311
  // Absent is answers of the row's own, so a re-grade from an editor that predates profiles unlinks the row, keeping
239
312
  // the answers it carried, rather than leaving a link the grant did not mean. A maintainer is refused one.
313
+ // `manages` reads as `credentials` does: a list sets the rights, `[]` takes them all back, absent keeps the row's, so a
314
+ // profile written over a row and a re-grade from an editor that predates rights keep what the person runs. A maintainer
315
+ // holds every right and stores none. Rights ride beside a profile, never in one: like Full access, running part of the
316
+ // sandbox is handed to a person, never through something shared.
240
317
  export const MemberGrantSchema = z.object({
241
318
  email: z.string(),
242
319
  role: GrantedRoleSchema,
@@ -250,6 +327,7 @@ export const MemberGrantSchema = z.object({
250
327
  tools: z.union([z.literal("all"), ToolCeilingSchema]).optional(),
251
328
  assistants: z.union([z.literal("all"), z.array(entryId).max(50)]).optional(),
252
329
  profile: entryId.optional(),
330
+ manages: z.array(ManageRightSchema).max(10).optional(),
253
331
  });
254
332
  export type MemberGrant = z.infer<typeof MemberGrantSchema>;
255
333
 
@@ -271,6 +349,10 @@ export const MemberSelfSchema = z.object({
271
349
  tools: ToolCeilingSchema.optional().describe("The most their conversations' tools may be. Absent means no limit."),
272
350
  assistants: z.array(entryId).optional().describe("For a guest who chats: the assistants they may talk to. Absent means every one in their areas."),
273
351
  profile: entryId.optional().describe("The access profile their access comes from. Absent means answers of their own."),
352
+ manages: z
353
+ .array(ManageRightSchema)
354
+ .optional()
355
+ .describe("The parts of the sandbox they run besides their own work: every one for the owner and Full access. Absent means none."),
274
356
  askedAt: z
275
357
  .number()
276
358
  .int()
@@ -279,10 +361,10 @@ export const MemberSelfSchema = z.object({
279
361
  });
280
362
  export type MemberSelf = z.infer<typeof MemberSelfSchema>;
281
363
 
282
- // ASKING THE OWNER FOR MORE ACCESS, from where the person was refused: the editor draws an "Ask for access" press on a
283
- // place or an action their access refuses, and the owner sees each open request beside the roster (Access ▸ People),
284
- // where granting the person what they asked for answers it. One open request per person: a later ask replaces theirs.
285
- // `want` is what stood in the way, in the terms a grant answers: a tier (`viewer` is a guest asking to see more),
364
+ // ASKING FOR MORE ACCESS, from where the person was refused: the editor draws an "Ask for access" press on a place or an
365
+ // action their access refuses, and whoever runs people and access sees each open request beside the roster (Access ▸
366
+ // People), where granting the person what they asked for answers it. One open request per person: a later ask replaces
367
+ // theirs. `want` is what stood in the way, in the terms a grant answers: a tier (`viewer` is a guest asking to see more),
286
368
  // running agents (`agents`), or a folder outside their areas (`areas`).
287
369
  // `aiAccounts`: the AI accounts their turns may run on (`aiAccounts` on their row) leave them nothing to run on that they
288
370
  // asked for, asked from a model picker with no model of theirs in it.
@@ -24,6 +24,12 @@ export const OauthAccountSchema = z.object({
24
24
  ),
25
25
  scope: z.string().optional().describe("What the credential is permitted to do, in the provider's terms."),
26
26
  connectedAt: z.number().describe("When it was connected, in milliseconds."),
27
+ connectedBy: z
28
+ .string()
29
+ .optional()
30
+ .describe(
31
+ "Who connected it, by the address they signed in with, where a person on this sandbox did. An account is always its connector's to run on. Absent for one connected before this was recorded, or by the owner's own tools.",
32
+ ),
27
33
  needsReauth: z
28
34
  .boolean()
29
35
  .optional()
@@ -35,3 +35,24 @@ export const RepoParamSchema = object({
35
35
  'Which repository. "root" is the workspace itself; anything else is a repository\'s folder relative to the workspace root, URL-encoded.',
36
36
  ),
37
37
  });
38
+ // A shared checkout's main line (the daemon's git/main-line-lock.ts), named on a repository's changes only when
39
+ // something moved it elsewhere.
40
+ export const MainBranchSchema = string()
41
+ .optional()
42
+ .describe(
43
+ "The branch this shared checkout belongs on, given only when it stands somewhere else: agents' work waits rather than land on the wrong branch until it is back. Absent, the normal case, means it is on its main line.",
44
+ );
45
+ // One branch of one workspace repository, for what looks at it or starts from it while the shared checkout stays on its
46
+ // main line: the Workspace's per-person view of it, an agent started from it. A remote-only branch is named by its
47
+ // short name; the daemon makes the local one at the remote's tip the first time it is needed.
48
+ export const BranchNameSchema = string()
49
+ .regex(/^[A-Za-z0-9][A-Za-z0-9._/-]*$/)
50
+ .max(200)
51
+ .describe("The branch, by its short name: `feature/login`, not `refs/heads/feature/login` or `origin/feature/login`.");
52
+ export const RepoBranchSchema = object({
53
+ repo: string()
54
+ .min(1)
55
+ .describe('Which repository. "root" is the workspace itself; anything else is a repository\'s folder relative to the workspace root.'),
56
+ branch: BranchNameSchema,
57
+ });
58
+ export type RepoBranch = z.infer<typeof RepoBranchSchema>;
@@ -1,12 +1,20 @@
1
1
  // workspace tree + files
2
2
  import { z } from "zod";
3
3
  import { ConversationIdSchema } from "../agent.js";
4
+ import { BranchNameSchema } from "../shared.js";
4
5
  // Which copy of the workspace a read means: the shared /work tree, or (if `agent` is set) that conversation's own
5
6
  // checkout, resolved in one place so the escape guard, denylist and ignore rules apply the same either way.
6
7
  export const WorkspaceScopeSchema = z.object({
7
8
  agent: ConversationIdSchema.optional().describe(
8
9
  "Read a conversation's own private copy of the workspace rather than the shared tree. Leave it out for the shared tree. A conversation that is not working privately resolves back to the shared tree rather than failing, so a link need not know which mode it runs in.",
9
10
  ),
11
+ // A branch the shared checkout is not on (it stays on its main line): read from a checkout the daemon keeps of it,
12
+ // inside `repo` from the branch, everywhere else from the shared tree. Never together with `agent`.
13
+ branch: BranchNameSchema.optional()
14
+ .describe(
15
+ "Read a branch of one repository as it stands, without the shared workspace leaving its main line: files inside that repository come from the branch, everything else from the shared tree. Never together with `agent`.",
16
+ ),
17
+ repo: z.string().min(1).optional().describe('With `branch`: which repository it is a branch of, "root" or left out for the workspace itself.'),
10
18
  });
11
19
  export type WorkspaceScope = z.infer<typeof WorkspaceScopeSchema>;
12
20
  // path is root-relative with forward slashes, feeding straight into the file routes. The interface is declared by hand:
@@ -377,11 +385,11 @@ export const WorkspaceResolveSchema = z.object({
377
385
  export type WorkspaceResolve = z.infer<typeof WorkspaceResolveSchema>;
378
386
  // Direct file management (delete, new folder, rename/move, copy). Byte writes and editor saves go through POST
379
387
  // /workspace/upload instead, since oRPC can't carry a body.
380
- export const WorkspaceDirSchema = z.object({ path: z.string().min(1).describe("The folder to create. Missing folders above it are created too.") });
388
+ export const WorkspaceDirSchema = z.object({ path: z.string().min(1).describe("The folder to create. Missing folders above it are created too.") }).extend({ view: WorkspaceScopeSchema.optional() });
381
389
  export const WorkspaceMoveSchema = z.object({
382
390
  from: z.string().min(1).describe("What to move or copy, as a workspace path."),
383
391
  to: z.string().min(1).describe("Where it should end up. Changing only the last part is how you rename something."),
384
- });
392
+ }).extend({ view: WorkspaceScopeSchema.optional() });
385
393
  // Unpacking an archive already in the workspace. Nothing is overwritten, so the answer is where it actually landed,
386
394
  // which is not always the name the caller would have guessed.
387
395
  export const WorkspaceExtractSchema = z.object({
@@ -403,7 +411,7 @@ export const WorkspaceDeletedSchema = z.object({
403
411
  export type WorkspaceDeleted = z.infer<typeof WorkspaceDeletedSchema>;
404
412
  export const WorkspaceRestoreSchema = z.object({
405
413
  trashed: z.string().min(1).describe("The trash id a delete answered with."),
406
- });
414
+ }).extend({ view: WorkspaceScopeSchema.optional() });
407
415
  export const WorkspaceRestoredSchema = z.object({
408
416
  path: z
409
417
  .string()
@@ -0,0 +1,16 @@
1
+ // What moves a checkout's HEAD, for the `git.branch-switch` class (policy/command-classes.ts). `switch` exists only to move
2
+ // HEAD, so every form of it counts. `checkout` is two commands wearing one name: with `-- <path>` or a bare `.` it
3
+ // restores files and moves nothing, and those are the common ones, so they are cut out; a bare trailing `--` names no
4
+ // path and still switches. `symbolic-ref HEAD refs/…` is
5
+ // the plumbing spelling of the same move; reading it (no target) moves nothing.
6
+ //
7
+ // git's own options may stand between `git` and the verb (`git -C /work checkout x`, `git -c k=v switch x`), and they are
8
+ // read through, or naming a directory would be a way around the class.
9
+
10
+ const GLOBALS = String.raw`(?:\s+(?:-C\s+\S+|-c\s+\S+|--git-dir(?:=|\s+)\S+|--work-tree(?:=|\s+)\S+|--no-pager|--no-optional-locks|-P))*`;
11
+
12
+ export const GIT_BRANCH_SWITCH: readonly RegExp[] = [
13
+ new RegExp(String.raw`\bgit${GLOBALS}\s+switch\b`),
14
+ new RegExp(String.raw`\bgit${GLOBALS}\s+checkout\b(?![^|;&]*\s--\s+[^\s|;&])(?![^|;&]*\s\.(?:\s|$))`),
15
+ new RegExp(String.raw`\bgit${GLOBALS}\s+symbolic-ref\b[^|;&]*\sHEAD\s+refs\/`),
16
+ ];