@intentic/sandbox-contract 1.363.0 → 1.365.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/contracts/access-profiles.contract.d.ts +91 -0
- package/dist/contracts/access-profiles.contract.d.ts.map +1 -0
- package/dist/contracts/access-profiles.contract.js +33 -0
- package/dist/contracts/access-profiles.contract.js.map +1 -0
- package/dist/contracts/agent.contract.d.ts +18 -0
- package/dist/contracts/agent.contract.d.ts.map +1 -1
- package/dist/contracts/agents.contract.d.ts +260 -0
- package/dist/contracts/agents.contract.d.ts.map +1 -1
- package/dist/contracts/agents.contract.js +18 -0
- package/dist/contracts/agents.contract.js.map +1 -1
- package/dist/contracts/automations.contract.d.ts +5 -0
- package/dist/contracts/automations.contract.d.ts.map +1 -1
- package/dist/contracts/extensions.contract.d.ts +6 -0
- package/dist/contracts/extensions.contract.d.ts.map +1 -1
- package/dist/contracts/needs.contract.d.ts +246 -0
- package/dist/contracts/needs.contract.d.ts.map +1 -1
- package/dist/contracts/needs.contract.js +11 -1
- package/dist/contracts/needs.contract.js.map +1 -1
- package/dist/contracts/org.contract.d.ts +49 -0
- package/dist/contracts/org.contract.d.ts.map +1 -1
- package/dist/contracts/runner.contract.d.ts +38 -0
- package/dist/contracts/runner.contract.d.ts.map +1 -1
- package/dist/contracts/services.contract.d.ts +26 -0
- package/dist/contracts/services.contract.d.ts.map +1 -0
- package/dist/contracts/services.contract.js +33 -0
- package/dist/contracts/services.contract.js.map +1 -0
- package/dist/contracts/sessions.contract.d.ts +2 -0
- package/dist/contracts/sessions.contract.d.ts.map +1 -1
- package/dist/contracts/settings.contract.d.ts +2 -0
- package/dist/contracts/settings.contract.d.ts.map +1 -1
- package/dist/contracts/system.contract.d.ts +36 -0
- package/dist/contracts/system.contract.d.ts.map +1 -1
- package/dist/contracts/workspace.contract.d.ts +232 -0
- package/dist/contracts/workspace.contract.d.ts.map +1 -1
- package/dist/contracts/workspace.contract.js +12 -1
- package/dist/contracts/workspace.contract.js.map +1 -1
- package/dist/events/agent-events.d.ts +22 -0
- package/dist/events/agent-events.d.ts.map +1 -1
- package/dist/events/agent-events.js +5 -1
- package/dist/events/agent-events.js.map +1 -1
- package/dist/events/agent-transcript.d.ts +2 -0
- package/dist/events/agent-transcript.d.ts.map +1 -1
- package/dist/events/sandbox-notice.d.ts +14 -0
- package/dist/events/sandbox-notice.d.ts.map +1 -1
- package/dist/events/sandbox-notice.js +13 -1
- package/dist/events/sandbox-notice.js.map +1 -1
- package/dist/events/system-events.d.ts +26 -0
- package/dist/events/system-events.d.ts.map +1 -1
- package/dist/events/tool-update.d.ts +6 -0
- package/dist/events/tool-update.d.ts.map +1 -0
- package/dist/events/tool-update.js +12 -0
- package/dist/events/tool-update.js.map +1 -0
- package/dist/events/transcript.d.ts +11 -0
- package/dist/events/transcript.d.ts.map +1 -1
- package/dist/events/transcript.js +4 -0
- package/dist/events/transcript.js.map +1 -1
- package/dist/index.d.ts +1014 -43
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/models/device-deadlines.d.ts +34 -0
- package/dist/models/device-deadlines.d.ts.map +1 -0
- package/dist/models/device-deadlines.js +28 -0
- package/dist/models/device-deadlines.js.map +1 -0
- package/dist/models/model-setups.d.ts.map +1 -1
- package/dist/models/model-setups.js.map +1 -1
- package/dist/policy/control-scopes.d.ts +3 -0
- package/dist/policy/control-scopes.d.ts.map +1 -1
- package/dist/policy/control-scopes.js +2 -0
- package/dist/policy/control-scopes.js.map +1 -1
- package/dist/policy/org-locks.d.ts +1 -1
- package/dist/policy/org-locks.d.ts.map +1 -1
- package/dist/policy/org-locks.js +3 -1
- package/dist/policy/org-locks.js.map +1 -1
- package/dist/protocol/member-reach.d.ts +18 -0
- package/dist/protocol/member-reach.d.ts.map +1 -0
- package/dist/protocol/member-reach.js +31 -0
- package/dist/protocol/member-reach.js.map +1 -0
- package/dist/protocol/raw/raw-json-routes.d.ts +423 -1
- package/dist/protocol/raw/raw-json-routes.d.ts.map +1 -1
- package/dist/protocol/raw/raw-json-routes.js +7 -2
- package/dist/protocol/raw/raw-json-routes.js.map +1 -1
- package/dist/protocol/raw/raw-routes.d.ts +18 -0
- package/dist/protocol/raw/raw-routes.d.ts.map +1 -1
- package/dist/protocol/raw/raw-routes.js +8 -3
- package/dist/protocol/raw/raw-routes.js.map +1 -1
- package/dist/schemas/access-profiles.d.ts +153 -0
- package/dist/schemas/access-profiles.d.ts.map +1 -0
- package/dist/schemas/access-profiles.js +56 -0
- package/dist/schemas/access-profiles.js.map +1 -0
- package/dist/schemas/agents-list.d.ts +27 -0
- package/dist/schemas/agents-list.d.ts.map +1 -1
- package/dist/schemas/agents.d.ts +50 -0
- package/dist/schemas/agents.d.ts.map +1 -1
- package/dist/schemas/agents.js +17 -0
- package/dist/schemas/agents.js.map +1 -1
- package/dist/schemas/automations.d.ts +10 -0
- package/dist/schemas/automations.d.ts.map +1 -1
- package/dist/schemas/automations.js +7 -0
- package/dist/schemas/automations.js.map +1 -1
- package/dist/schemas/dev-rebuild-log.d.ts +16 -0
- package/dist/schemas/dev-rebuild-log.d.ts.map +1 -1
- package/dist/schemas/dev-rebuild-log.js +38 -2
- package/dist/schemas/dev-rebuild-log.js.map +1 -1
- package/dist/schemas/device-commands.d.ts +7 -1
- package/dist/schemas/device-commands.d.ts.map +1 -1
- package/dist/schemas/device-commands.js +14 -2
- package/dist/schemas/device-commands.js.map +1 -1
- package/dist/schemas/environment.d.ts +32 -0
- package/dist/schemas/environment.d.ts.map +1 -1
- package/dist/schemas/environment.js +12 -0
- package/dist/schemas/environment.js.map +1 -1
- package/dist/schemas/extension-updates.d.ts +12 -0
- package/dist/schemas/extension-updates.d.ts.map +1 -1
- package/dist/schemas/links.d.ts +6 -1
- package/dist/schemas/links.d.ts.map +1 -1
- package/dist/schemas/links.js +8 -1
- package/dist/schemas/links.js.map +1 -1
- package/dist/schemas/members.d.ts +127 -0
- package/dist/schemas/members.d.ts.map +1 -1
- package/dist/schemas/members.js +32 -0
- package/dist/schemas/members.js.map +1 -1
- package/dist/schemas/needs.d.ts +23 -0
- package/dist/schemas/needs.d.ts.map +1 -1
- package/dist/schemas/needs.js +3 -0
- package/dist/schemas/needs.js.map +1 -1
- package/dist/schemas/organisation.d.ts +164 -0
- package/dist/schemas/organisation.d.ts.map +1 -1
- package/dist/schemas/organisation.js +17 -0
- package/dist/schemas/organisation.js.map +1 -1
- package/dist/schemas/personas.d.ts.map +1 -1
- package/dist/schemas/personas.js +2 -2
- package/dist/schemas/personas.js.map +1 -1
- package/dist/schemas/providers/handoff.d.ts +24 -0
- package/dist/schemas/providers/handoff.d.ts.map +1 -1
- package/dist/schemas/providers/handoff.js +32 -0
- package/dist/schemas/providers/handoff.js.map +1 -1
- package/dist/schemas/providers/usage.d.ts +6 -0
- package/dist/schemas/providers/usage.d.ts.map +1 -1
- package/dist/schemas/providers/usage.js +2 -0
- package/dist/schemas/providers/usage.js.map +1 -1
- package/dist/schemas/services.d.ts +24 -0
- package/dist/schemas/services.d.ts.map +1 -0
- package/dist/schemas/services.js +19 -0
- package/dist/schemas/services.js.map +1 -0
- package/dist/schemas/settings-experiments.d.ts.map +1 -1
- package/dist/schemas/settings-experiments.js +1 -1
- package/dist/schemas/settings-experiments.js.map +1 -1
- package/dist/schemas/settings.d.ts +2 -0
- package/dist/schemas/settings.d.ts.map +1 -1
- package/dist/schemas/settings.js +9 -3
- package/dist/schemas/settings.js.map +1 -1
- package/dist/schemas/tool-ceiling.d.ts +24 -0
- package/dist/schemas/tool-ceiling.d.ts.map +1 -0
- package/dist/schemas/tool-ceiling.js +86 -0
- package/dist/schemas/tool-ceiling.js.map +1 -0
- package/dist/schemas/workspace/workspace-search.d.ts +93 -0
- package/dist/schemas/workspace/workspace-search.d.ts.map +1 -1
- package/dist/schemas/workspace/workspace-search.js +10 -0
- package/dist/schemas/workspace/workspace-search.js.map +1 -1
- package/dist/state/definition.d.ts +4 -0
- package/dist/state/definition.d.ts.map +1 -1
- package/dist/state/locked-folders.d.ts +2 -0
- package/dist/state/locked-folders.d.ts.map +1 -0
- package/dist/state/locked-folders.js +11 -0
- package/dist/state/locked-folders.js.map +1 -0
- package/dist/state/runtime-state.d.ts +3 -0
- package/dist/state/runtime-state.d.ts.map +1 -1
- package/dist/state/runtime-state.js +1 -0
- package/dist/state/runtime-state.js.map +1 -1
- package/dist/text/land-rows.d.ts.map +1 -1
- package/dist/text/land-rows.js +5 -2
- package/dist/text/land-rows.js.map +1 -1
- package/dist/text/notice-rows.d.ts +8 -0
- package/dist/text/notice-rows.d.ts.map +1 -0
- package/dist/text/notice-rows.js +14 -0
- package/dist/text/notice-rows.js.map +1 -0
- package/dist/text/transcript-fold.d.ts.map +1 -1
- package/dist/text/transcript-fold.js +25 -26
- package/dist/text/transcript-fold.js.map +1 -1
- package/package.json +5 -5
- package/src/contracts/access-profiles.contract.ts +43 -0
- package/src/contracts/agents.contract.ts +21 -0
- package/src/contracts/needs.contract.ts +14 -0
- package/src/contracts/services.contract.ts +40 -0
- package/src/contracts/workspace.contract.ts +15 -1
- package/src/events/agent-events.ts +11 -1
- package/src/events/sandbox-notice.ts +17 -1
- package/src/events/tool-update.ts +18 -0
- package/src/events/transcript.ts +5 -0
- package/src/index.ts +4 -0
- package/src/models/device-deadlines.ts +62 -0
- package/src/models/model-roles.ts +2 -2
- package/src/models/model-setups.ts +3 -4
- package/src/policy/control-scopes.ts +5 -0
- package/src/policy/org-locks.ts +5 -2
- package/src/protocol/member-reach.test.ts +221 -0
- package/src/protocol/member-reach.ts +78 -0
- package/src/protocol/raw/raw-json-routes.ts +15 -1
- package/src/protocol/raw/raw-routes.ts +12 -4
- package/src/schemas/access-profiles.test.ts +50 -0
- package/src/schemas/access-profiles.ts +104 -0
- package/src/schemas/agents.ts +30 -0
- package/src/schemas/automations.ts +15 -1
- package/src/schemas/dev-rebuild-log.test.ts +46 -1
- package/src/schemas/dev-rebuild-log.ts +71 -3
- package/src/schemas/device-commands.ts +30 -2
- package/src/schemas/environment.ts +31 -0
- package/src/schemas/links.ts +13 -2
- package/src/schemas/members.ts +59 -1
- package/src/schemas/needs.ts +4 -0
- package/src/schemas/organisation.ts +25 -0
- package/src/schemas/personas.ts +15 -11
- package/src/schemas/providers/handoff.test.ts +23 -1
- package/src/schemas/providers/handoff.ts +49 -0
- package/src/schemas/providers/usage.ts +4 -0
- package/src/schemas/services.ts +32 -0
- package/src/schemas/settings-experiments.ts +5 -1
- package/src/schemas/settings.test.ts +23 -1
- package/src/schemas/settings.ts +17 -4
- package/src/schemas/shared.ts +1 -1
- package/src/schemas/tool-ceiling.test.ts +70 -0
- package/src/schemas/tool-ceiling.ts +113 -0
- package/src/schemas/workspace/workspace-search.ts +16 -0
- package/src/state/locked-folders.test.ts +29 -0
- package/src/state/locked-folders.ts +17 -0
- package/src/state/runtime-state.ts +5 -0
- package/src/state/workspace-state.ts +1 -1
- package/src/text/land-rows.ts +6 -2
- package/src/text/notice-rows.ts +21 -0
- package/src/text/transcript-fold.test.ts +102 -2
- package/src/text/transcript-fold.ts +29 -30
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { PersonaPowers } from "./personas.js";
|
|
3
|
+
|
|
4
|
+
// THE MOST A TURN'S TOOLS MAY BE, as the principals it acts for are held to it (docs/architecture/access.md): one answer
|
|
5
|
+
// per persona shelf, each an upper bound. A shelf left out is not limited. A persona's own shelves are posture and only
|
|
6
|
+
// narrow inside this; a conversation grant lifts what a persona withheld and never what a ceiling did.
|
|
7
|
+
// The same names and order as a persona's shelves (schemas/personas.ts PersonaPowersSchema), so one vocabulary covers
|
|
8
|
+
// both, with no defaults: an absent answer here is "no limit", where an absent shelf on a card is "on".
|
|
9
|
+
export const ToolCeilingSchema = z.object({
|
|
10
|
+
files: z.enum(["none", "read", "write"]).optional().describe("The most it may do with files: nothing, look and search, or also create and change."),
|
|
11
|
+
shell: z
|
|
12
|
+
.boolean()
|
|
13
|
+
.optional()
|
|
14
|
+
.describe("False takes commands away, and with them the terminals and every tool on the image. The switch the strength of the others depends on."),
|
|
15
|
+
code: z.boolean().optional().describe("False takes away writing and running a script."),
|
|
16
|
+
web: z.boolean().optional().describe("False takes away fetching a page and searching the web."),
|
|
17
|
+
browser: z.boolean().optional().describe("False takes away the credential-free browser."),
|
|
18
|
+
delegate: z.boolean().optional().describe("False takes away spawning subagents and running workflows."),
|
|
19
|
+
sandbox: z.boolean().optional().describe("False takes away changing the sandbox's own settings, manifests and public outbox."),
|
|
20
|
+
});
|
|
21
|
+
export type ToolCeiling = z.infer<typeof ToolCeilingSchema>;
|
|
22
|
+
|
|
23
|
+
// The shelves a ceiling answers, other than `files`, which is ranked rather than switched.
|
|
24
|
+
export const CEILING_SWITCHES = ["shell", "code", "web", "browser", "delegate", "sandbox"] as const;
|
|
25
|
+
export type CeilingSwitch = (typeof CEILING_SWITCHES)[number];
|
|
26
|
+
|
|
27
|
+
const FILES_RANK = { none: 0, read: 1, write: 2 } as const;
|
|
28
|
+
type FilesAnswer = keyof typeof FILES_RANK;
|
|
29
|
+
|
|
30
|
+
const lowerFiles = (left: FilesAnswer | undefined, right: FilesAnswer | undefined): FilesAnswer | undefined => {
|
|
31
|
+
if (left === undefined) {
|
|
32
|
+
return right;
|
|
33
|
+
}
|
|
34
|
+
if (right === undefined) {
|
|
35
|
+
return left;
|
|
36
|
+
}
|
|
37
|
+
return FILES_RANK[left] <= FILES_RANK[right] ? left : right;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/** Whether a ceiling limits anything at all; undefined and an empty one do not. */
|
|
41
|
+
export const ceilingLimits = (ceiling: ToolCeiling | undefined): boolean =>
|
|
42
|
+
ceiling !== undefined && ((ceiling.files !== undefined && ceiling.files !== "write") || CEILING_SWITCHES.some((shelf) => ceiling[shelf] === false));
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Two ceilings held together: the lower answer of each shelf, so a turn acting for several principals is held to what
|
|
46
|
+
* every one of them may. Undefined is no ceiling, and holding it beside another changes nothing.
|
|
47
|
+
*/
|
|
48
|
+
export const intersectCeilings = (left: ToolCeiling | undefined, right: ToolCeiling | undefined): ToolCeiling | undefined => {
|
|
49
|
+
if (left === undefined) {
|
|
50
|
+
return right;
|
|
51
|
+
}
|
|
52
|
+
if (right === undefined) {
|
|
53
|
+
return left;
|
|
54
|
+
}
|
|
55
|
+
const files = lowerFiles(left.files, right.files);
|
|
56
|
+
const held: ToolCeiling = files === undefined ? {} : { files };
|
|
57
|
+
for (const shelf of CEILING_SWITCHES) {
|
|
58
|
+
if (left[shelf] === false || right[shelf] === false) {
|
|
59
|
+
held[shelf] = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return held;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** A persona's shelves held under a ceiling: each shelf the lower of the two, connector lists untouched. */
|
|
66
|
+
export const capPowers = (powers: PersonaPowers, ceiling: ToolCeiling | undefined): PersonaPowers => {
|
|
67
|
+
if (!ceilingLimits(ceiling) || ceiling === undefined) {
|
|
68
|
+
return powers;
|
|
69
|
+
}
|
|
70
|
+
const capped: PersonaPowers = { ...powers, files: lowerFiles(powers.files, ceiling.files) ?? powers.files };
|
|
71
|
+
for (const shelf of CEILING_SWITCHES) {
|
|
72
|
+
if (ceiling[shelf] === false) {
|
|
73
|
+
capped[shelf] = false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return capped;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/** Whether a ceiling holds one shelf below what a grant would open it to (`files` opens to write). */
|
|
80
|
+
export const ceilingWithholds = (ceiling: ToolCeiling | undefined, shelf: "files" | CeilingSwitch): boolean => {
|
|
81
|
+
if (ceiling === undefined) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return shelf === "files" ? ceiling.files !== undefined && ceiling.files !== "write" : ceiling[shelf] === false;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const SWITCH_WORDS = {
|
|
88
|
+
shell: "no commands",
|
|
89
|
+
code: "no scripts",
|
|
90
|
+
web: "no web",
|
|
91
|
+
browser: "no browser",
|
|
92
|
+
delegate: "no subagents",
|
|
93
|
+
sandbox: "no sandbox settings",
|
|
94
|
+
} as const satisfies Record<CeilingSwitch, string>;
|
|
95
|
+
|
|
96
|
+
/** What a ceiling withholds, in words its owner would recognise; empty when it limits nothing. */
|
|
97
|
+
export const ceilingWords = (ceiling: ToolCeiling | undefined): string[] => {
|
|
98
|
+
if (ceiling === undefined) {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
const words: string[] = [];
|
|
102
|
+
if (ceiling.files === "none") {
|
|
103
|
+
words.push("no files");
|
|
104
|
+
} else if (ceiling.files === "read") {
|
|
105
|
+
words.push("read-only files");
|
|
106
|
+
}
|
|
107
|
+
for (const shelf of CEILING_SWITCHES) {
|
|
108
|
+
if (ceiling[shelf] === false) {
|
|
109
|
+
words.push(SWITCH_WORDS[shelf]);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return words;
|
|
113
|
+
};
|
|
@@ -33,6 +33,8 @@ export const WorkspaceSearchQuerySchema = z.object({
|
|
|
33
33
|
limit: z.coerce.number().int().positive().optional().describe("How many results to return."),
|
|
34
34
|
after: z.string().optional().describe("Resume from the cursor a previous answer handed back."),
|
|
35
35
|
});
|
|
36
|
+
// A search as its handler reads it, the switches parsed to booleans.
|
|
37
|
+
export type WorkspaceSearchQuery = z.infer<typeof WorkspaceSearchQuerySchema>;
|
|
36
38
|
// The query's verb enum.
|
|
37
39
|
export type WorkspaceSearchMode = NonNullable<z.infer<typeof WorkspaceSearchQuerySchema>["mode"]>;
|
|
38
40
|
export const WorkspaceSearchTagSchema = z.object({
|
|
@@ -130,3 +132,17 @@ export const WorkspaceSearchResultSchema = z.object({
|
|
|
130
132
|
features: z.array(z.string()).optional().describe("Which stages of the search were switched off for this run. Absent means all of them ran."),
|
|
131
133
|
});
|
|
132
134
|
export type WorkspaceSearchResult = z.infer<typeof WorkspaceSearchResultSchema>;
|
|
135
|
+
// What /workspace/search/stream sends: the files a text search has found so far, as it finds them, then its answer.
|
|
136
|
+
// `groups` frames are provisional (the first ones found, at most a page of them, in no order); `done` is the first page
|
|
137
|
+
// as /workspace/search would have answered it, which replaces them, and whose cursor pages on through the same answer.
|
|
138
|
+
export const WorkspaceSearchFrameSchema = z.discriminatedUnion("kind", [
|
|
139
|
+
z.object({
|
|
140
|
+
kind: z.literal("groups"),
|
|
141
|
+
groups: z.array(WorkspaceSearchGroupSchema).describe("Files found since the last frame, each with all of its matching lines."),
|
|
142
|
+
}),
|
|
143
|
+
z.object({
|
|
144
|
+
kind: z.literal("done"),
|
|
145
|
+
result: WorkspaceSearchResultSchema.describe("The first page of the finished search; it replaces every file sent before it."),
|
|
146
|
+
}),
|
|
147
|
+
]);
|
|
148
|
+
export type WorkspaceSearchFrame = z.infer<typeof WorkspaceSearchFrameSchema>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { holdsLockedWorkspacePath } from "./locked-folders.js";
|
|
2
|
+
import { PLAN_DOCUMENTS_DIR } from "./workspace-state.js";
|
|
3
|
+
|
|
4
|
+
// The folders the lock reaches through: deleting or moving one would carry the locked entries inside it.
|
|
5
|
+
describe(`holdsLockedWorkspacePath`, () => {
|
|
6
|
+
it(`holds the root state dir and every group in it, whichever slash`, () => {
|
|
7
|
+
expect(
|
|
8
|
+
[`.intentic`, `./.intentic/`, `.intentic/config`, `.intentic/identity`, `.intentic/secrets`, `.intentic/records`, `.intentic\\local`].map(
|
|
9
|
+
holdsLockedWorkspacePath,
|
|
10
|
+
),
|
|
11
|
+
).toEqual([true, true, true, true, true, true, true]);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it(`leaves ordinary state, the locked entries themselves, and anyone else's .intentic alone`, () => {
|
|
15
|
+
expect(
|
|
16
|
+
[
|
|
17
|
+
`.intentic/config/approvals`,
|
|
18
|
+
`.intentic/records/artifacts`,
|
|
19
|
+
PLAN_DOCUMENTS_DIR,
|
|
20
|
+
`.intentic/secrets/auth`,
|
|
21
|
+
`.intentic/records/sessions`,
|
|
22
|
+
`myrepo/.intentic`,
|
|
23
|
+
`.git`,
|
|
24
|
+
``,
|
|
25
|
+
`src`,
|
|
26
|
+
].map(holdsLockedWorkspacePath),
|
|
27
|
+
).toEqual([false, false, false, false, false, false, false, false, false]);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { STATE_DIR } from "@intentic/constants";
|
|
2
|
+
import { LOCKED_STATE_ENTRIES } from "./workspace-state.js";
|
|
3
|
+
|
|
4
|
+
// Whether a path is a folder a locked entry sits in (workspace-state.ts): the root's `.intentic` and each of its groups.
|
|
5
|
+
// Such a folder is opened, read and written inside like any other, but never deleted, moved, renamed or copied onto,
|
|
6
|
+
// for anyone. Deleting or moving it would carry the locked bytes out from under the lock, and the sandbox's settings,
|
|
7
|
+
// sign-ins and history with them, and the file trash sits in `.intentic/local`, so it would leave no Undo either. A
|
|
8
|
+
// copy onto it merges, overwriting the locked files. The file API refuses all of these and the explorer leaves them
|
|
9
|
+
// out. Accepts either slash.
|
|
10
|
+
export const holdsLockedWorkspacePath = (relPath: string): boolean => {
|
|
11
|
+
const segments = relPath.split(/[\\/]/).filter((segment) => segment !== "" && segment !== ".");
|
|
12
|
+
if (segments[0] !== STATE_DIR) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const inside = segments.slice(1).join("/");
|
|
16
|
+
return inside === "" || [...LOCKED_STATE_ENTRIES].some((entry) => entry.startsWith(`${inside}/`));
|
|
17
|
+
};
|
|
@@ -74,6 +74,11 @@ const RUNTIME_DOMAINS = [
|
|
|
74
74
|
// live under the auth root, which no file push watches, and the Allowed list must move with the card that wrote one.
|
|
75
75
|
{ domain: "grants", invalidates: [["grants"]] },
|
|
76
76
|
|
|
77
|
+
// Somebody asked the owner for more access, or a request was answered (auth/members/access-requests.ts): the owner's
|
|
78
|
+
// list beside the roster moves, and so does the asker's own "asked" (GET /members/self). Like grants, they live under
|
|
79
|
+
// a root no file push watches.
|
|
80
|
+
{ domain: "access-requests", invalidates: [["access-requests"], ["members-self"]] },
|
|
81
|
+
|
|
77
82
|
// Somebody's composer draft was written, cleared or sent. The frame names no conversation and carries no words, since
|
|
78
83
|
// every member hears it: each window reads back its own caller's drafts (agents.drafts). The key is the editor's draft
|
|
79
84
|
// store's, which reads them back itself rather than through a cached query (models/conversations/drafts/).
|
|
@@ -708,7 +708,7 @@ export const LOCKED_STATE_ENTRIES: ReadonlySet<string> = new Set([
|
|
|
708
708
|
export const PLAN_DOCUMENTS_DIR = `${STATE_DIR}/records/sessions/claude/plans`;
|
|
709
709
|
|
|
710
710
|
// Where message attachments land: the browser posts to `<this>/<uuid>/<name>` before the message is sent, and the
|
|
711
|
-
// turn reads them back (schemas/agent.ts). The role floor (
|
|
711
|
+
// turn reads them back (schemas/agent.ts). The role floor (protocol/member-reach.ts) keys off this path: attaching is
|
|
712
712
|
// part of sending (a collaborator's grant), writing elsewhere in the workspace is the operating tier's, and both
|
|
713
713
|
// travel through the same upload route.
|
|
714
714
|
export const ATTACHMENTS_DIR = `${STATE_DIR}/records/artifacts/attachments`;
|
package/src/text/land-rows.ts
CHANGED
|
@@ -104,8 +104,12 @@ export const landedRow = (event: Extract<AgentEvent, { kind: "landed" }>): Trans
|
|
|
104
104
|
const deps = event.deps === undefined || event.deps.missing === 0 ? undefined : event.deps;
|
|
105
105
|
return {
|
|
106
106
|
role: "notice",
|
|
107
|
-
|
|
107
|
+
// A home's land (the only one named) is committed too, by nobody pressing anything: said, not left to the Changes panel.
|
|
108
|
+
text: `${event.land === undefined ? "Changes landed in your workspace: review them in the Changes panel." : "Landed in your workspace and committed."}${dependencyLine(event.deps)}`,
|
|
108
109
|
noticeAction: (event.deps?.started.length ?? 0) > 0 ? "depsInstall" : "landHold",
|
|
109
|
-
noticeCode: noticeCode({
|
|
110
|
+
noticeCode: noticeCode({
|
|
111
|
+
code: "landed",
|
|
112
|
+
params: deps === undefined && event.land === undefined ? undefined : { deps: deps?.missing, queued: deps?.deferred || undefined, land: event.land },
|
|
113
|
+
}),
|
|
110
114
|
};
|
|
111
115
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AgentEvent } from "../events/agent-events.js";
|
|
2
|
+
import type { TranscriptRow } from "../events/transcript.js";
|
|
3
|
+
import { noticeCode } from "../events/sandbox-notice.js";
|
|
4
|
+
import { contextTrimLine, contextTrimNotice } from "../schemas/context-trim.js";
|
|
5
|
+
import { freshStartLine, freshStartNotice, handedOffLine, handedOffNotice } from "../schemas/providers/handoff.js";
|
|
6
|
+
|
|
7
|
+
// The notices that say what a turn was given to start from, each a row of its own worded from its frame's facts: what
|
|
8
|
+
// the window left out of the message, how a held turn continued, and where a home's session started over.
|
|
9
|
+
type StartingFrame = Extract<AgentEvent, { kind: "context_trim" | "handoff" | "fresh_start" }>;
|
|
10
|
+
|
|
11
|
+
/** A starting frame's row, in the English the record keeps, with the code a reader words it from. */
|
|
12
|
+
export const startingRow = (event: StartingFrame): TranscriptRow => {
|
|
13
|
+
switch (event.kind) {
|
|
14
|
+
case "context_trim":
|
|
15
|
+
return { role: "notice", text: contextTrimLine(event), noticeCode: noticeCode(contextTrimNotice(event)) };
|
|
16
|
+
case "handoff":
|
|
17
|
+
return { role: "notice", text: handedOffLine(event), noticeCode: noticeCode(handedOffNotice(event)) };
|
|
18
|
+
case "fresh_start":
|
|
19
|
+
return { role: "notice", text: freshStartLine(event), noticeCode: noticeCode(freshStartNotice(event)) };
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { STATE_DIR } from "@intentic/constants";
|
|
2
2
|
import { type AgentErrorCode, AgentErrorCodeSchema, type AgentEvent } from "../events/agent-events.js";
|
|
3
|
-
import { type TranscriptPatch, type TranscriptRow, TranscriptRowSchema } from "../events/transcript.js";
|
|
3
|
+
import { type TranscriptPatch, type TranscriptRow, TranscriptRowSchema, type TranscriptTool } from "../events/transcript.js";
|
|
4
4
|
import { sandboxNoticeOf } from "../events/sandbox-notice.js";
|
|
5
5
|
import { watchWakePrompt } from "../events/watch-wake.js";
|
|
6
6
|
import { LAND_CONFLICT_OPENING } from "../events/land-conflict.js";
|
|
7
7
|
import { RESUME_NOTES } from "../events/resume.js";
|
|
8
8
|
import { childReportPrompt, peerMessagePrompt } from "../events/agent-words.js";
|
|
9
|
-
import { applyTranscriptPatch, foldTurn, TranscriptFold, userRow } from "./transcript-fold.js";
|
|
9
|
+
import { applyTranscriptPatch, foldTurn, mapTool, TranscriptFold, userRow } from "./transcript-fold.js";
|
|
10
10
|
|
|
11
11
|
// Epoch ms stamped on the opening user row's sentAt.
|
|
12
12
|
const SENT_AT = 1_767_225_600_000;
|
|
@@ -84,6 +84,20 @@ describe("foldTurn", () => {
|
|
|
84
84
|
]);
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
+
// Devin sends a call's arguments only on its updates; a card with nothing yet takes them, one that has its own keeps it.
|
|
88
|
+
it("takes an update's input into a card that has neither target nor input, and only then", () => {
|
|
89
|
+
const events: AgentEvent[] = [
|
|
90
|
+
{ kind: "tool_call", id: "t1", name: "Click", category: "other", status: "in_progress" },
|
|
91
|
+
{ kind: "tool_call", id: "t2", name: "Bash", category: "execute", status: "in_progress", target: "ls" },
|
|
92
|
+
{ kind: "tool_call_update", id: "t1", status: "completed", input: '{"ref":"e12"}' },
|
|
93
|
+
{ kind: "tool_call_update", id: "t2", status: "completed", input: '{"command":"ls -la"}' },
|
|
94
|
+
];
|
|
95
|
+
const [click, bash] = foldOf("act", events).flatMap((message) => message.tools ?? []);
|
|
96
|
+
expect(click?.input).toBe('{"ref":"e12"}');
|
|
97
|
+
expect(bash).toMatchObject({ target: "ls" });
|
|
98
|
+
expect(Object.keys(bash ?? {})).not.toContain("input");
|
|
99
|
+
});
|
|
100
|
+
|
|
87
101
|
it("leaves an unanswered call in progress", () => {
|
|
88
102
|
const events: AgentEvent[] = [{ kind: "tool_call", id: "t1", name: "Bash", category: "execute", status: "in_progress" }];
|
|
89
103
|
expect(foldOf("run", events).at(-1)?.tools?.[0]?.status).toBe("in_progress");
|
|
@@ -484,6 +498,23 @@ describe("foldTurn", () => {
|
|
|
484
498
|
});
|
|
485
499
|
});
|
|
486
500
|
|
|
501
|
+
// A home's land is named on its row, so the commit its card files under that name is told on the same row.
|
|
502
|
+
it("names a home's land on its row", () => {
|
|
503
|
+
expect(foldOf("go", [{ kind: "landed", landed: true, land: "land-1" }]).at(-1)).toMatchObject({
|
|
504
|
+
text: "Landed in your workspace and committed.",
|
|
505
|
+
noticeCode: { code: "landed", params: { land: "land-1" } },
|
|
506
|
+
});
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
// Where a home's model memory starts over: a row of its own, which a reader can tell from any other notice.
|
|
510
|
+
it("marks a home's fresh session with a row of its own", () => {
|
|
511
|
+
expect(foldOf("go", [{ kind: "fresh_start", why: "budget", from: 182_000, summarized: true, model: "haiku" }]).at(-1)).toEqual({
|
|
512
|
+
role: "notice",
|
|
513
|
+
text: "This chat's memory was full at about 182k tokens, so it went on in a fresh session, opened with a summary of the conversation written by haiku and its latest messages.",
|
|
514
|
+
noticeCode: { code: "freshStart", params: { why: "budget", from: "182k", model: "haiku", summarized: true } },
|
|
515
|
+
});
|
|
516
|
+
});
|
|
517
|
+
|
|
487
518
|
// A spawned child's work goes into its parent's checkout, as the parent's in-process subagents' edits do: the row
|
|
488
519
|
// says so, never that it reached the owner's workspace, and says who is to bring in a clash.
|
|
489
520
|
it("says a child's work went into its parent's checkout, or was held off it by a clash", () => {
|
|
@@ -688,6 +719,75 @@ describe("foldTurn", () => {
|
|
|
688
719
|
|
|
689
720
|
// Patches applied to a window's rows must reproduce the fold's own rows exactly, or live and reopened chats drift.
|
|
690
721
|
describe("patches", () => {
|
|
722
|
+
const call = (id: string, children?: TranscriptTool[]): TranscriptTool => {
|
|
723
|
+
const tool: TranscriptTool = { id, name: "Read", category: "read", status: "completed" };
|
|
724
|
+
if (children !== undefined) {
|
|
725
|
+
tool.children = children;
|
|
726
|
+
}
|
|
727
|
+
return tool;
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
it("a nested tool update preserves unrelated branches and the original tree", () => {
|
|
731
|
+
const sibling = call("sibling");
|
|
732
|
+
const leaf = call("leaf");
|
|
733
|
+
const parent = call("parent", [sibling, leaf]);
|
|
734
|
+
const other = call("other", [call("untouched")]);
|
|
735
|
+
const tools = [other, parent];
|
|
736
|
+
const next = mapTool(tools, "leaf", (tool) => ({ ...tool, thinking: "new reasoning" }));
|
|
737
|
+
|
|
738
|
+
expect(next).toEqual([other, { ...parent, children: [sibling, { ...leaf, thinking: "new reasoning" }] }]);
|
|
739
|
+
expect(next).not.toBe(tools);
|
|
740
|
+
expect(next[0]).toBe(other);
|
|
741
|
+
expect(next[1]?.children?.[0]).toBe(sibling);
|
|
742
|
+
expect(leaf.thinking).toBeUndefined();
|
|
743
|
+
expect(parent.children).toEqual([sibling, leaf]);
|
|
744
|
+
});
|
|
745
|
+
|
|
746
|
+
it("an absent tool keeps the tree, while a matched identity callback still reports a match", () => {
|
|
747
|
+
const tools = [call("parent", [call("child")])];
|
|
748
|
+
let called = 0;
|
|
749
|
+
const identity = (tool: TranscriptTool): TranscriptTool => {
|
|
750
|
+
called += 1;
|
|
751
|
+
return tool;
|
|
752
|
+
};
|
|
753
|
+
expect(mapTool(tools, "missing", identity)).toBe(tools);
|
|
754
|
+
expect(called).toBe(0);
|
|
755
|
+
const matched = mapTool(tools, "child", identity);
|
|
756
|
+
expect(matched).toEqual(tools);
|
|
757
|
+
expect(matched).not.toBe(tools);
|
|
758
|
+
expect(called).toBe(1);
|
|
759
|
+
});
|
|
760
|
+
|
|
761
|
+
it("updates every matching branch without descending into a matching card", () => {
|
|
762
|
+
const hidden = call("target");
|
|
763
|
+
const parent = call("target", [hidden]);
|
|
764
|
+
const nestedLeaf = call("target");
|
|
765
|
+
const nested = call("branch", [nestedLeaf]);
|
|
766
|
+
const tools = [parent, nested];
|
|
767
|
+
let called = 0;
|
|
768
|
+
const next = mapTool(tools, "target", (tool) => {
|
|
769
|
+
called += 1;
|
|
770
|
+
return { ...tool, thinking: "updated" };
|
|
771
|
+
});
|
|
772
|
+
expect(next).toEqual([
|
|
773
|
+
{ ...parent, thinking: "updated" },
|
|
774
|
+
{ ...nested, children: [{ ...nestedLeaf, thinking: "updated" }] },
|
|
775
|
+
]);
|
|
776
|
+
expect(called).toBe(2);
|
|
777
|
+
expect(next[0]?.children?.[0]).toBe(hidden);
|
|
778
|
+
});
|
|
779
|
+
|
|
780
|
+
it("an indexed row patch keeps unrelated rows and ignores positions outside the transcript", () => {
|
|
781
|
+
const opening: TranscriptRow = { role: "user", text: "go" };
|
|
782
|
+
const rows: TranscriptRow[] = [opening, { role: "assistant", text: "hello" }];
|
|
783
|
+
const next = applyTranscriptPatch(rows, { op: "text", index: 1, text: " world" });
|
|
784
|
+
expect(next).toEqual([opening, { role: "assistant", text: "hello world" }]);
|
|
785
|
+
expect(next[0]).toBe(rows[0]);
|
|
786
|
+
expect(rows[1]?.text).toBe("hello");
|
|
787
|
+
expect(applyTranscriptPatch(rows, { op: "text", index: 2, text: "ignored" })).toEqual(rows);
|
|
788
|
+
expect(applyTranscriptPatch(rows, { op: "text", index: -1, text: "ignored" })).toEqual(rows);
|
|
789
|
+
});
|
|
790
|
+
|
|
691
791
|
const replay = (
|
|
692
792
|
opening: readonly TranscriptRow[],
|
|
693
793
|
events: readonly AgentEvent[],
|
|
@@ -11,14 +11,14 @@ import {
|
|
|
11
11
|
type TranscriptSubagent,
|
|
12
12
|
type TranscriptTool,
|
|
13
13
|
} from "../events/transcript.js";
|
|
14
|
-
import { contextTrimLine, contextTrimNotice } from "../schemas/context-trim.js";
|
|
15
14
|
import { keptWarmLine, keptWarmNotice } from "../schemas/keep-warm.js";
|
|
16
|
-
import {
|
|
15
|
+
import { startingRow } from "./notice-rows.js";
|
|
17
16
|
import { isLandConflict } from "../events/land-conflict.js";
|
|
18
17
|
import { turnedAwayCode } from "../policy/turned-away.js";
|
|
19
18
|
import { errorRow, RENEWAL_WITHDRAWN, RENEWING } from "../events/failure-rows.js";
|
|
20
19
|
import { mentionedPathTokens } from "./mentions.js";
|
|
21
20
|
import { unspokenPromptRow } from "../events/agent-words.js";
|
|
21
|
+
import { takeToolUpdate } from "../events/tool-update.js";
|
|
22
22
|
import { needRowText } from "../events/need-wake.js";
|
|
23
23
|
import { noticeCode, sandboxNoticeOf } from "../events/sandbox-notice.js";
|
|
24
24
|
import { installRow, landedRow, syncLine } from "./land-rows.js";
|
|
@@ -73,6 +73,7 @@ const cardOf = (event: Extract<AgentEvent, { kind: "tool_call" }>, at: number |
|
|
|
73
73
|
...(event.locations !== undefined ? { locations: event.locations } : {}),
|
|
74
74
|
...(event.content !== undefined ? { content: event.content } : {}),
|
|
75
75
|
...(event.input !== undefined ? { input: event.input } : {}),
|
|
76
|
+
...(event.server !== undefined ? { server: event.server } : {}),
|
|
76
77
|
...(at !== undefined ? { startedAt: at, ...(ended(event.status) ? { endedAt: at } : {}) } : {}),
|
|
77
78
|
});
|
|
78
79
|
|
|
@@ -191,16 +192,11 @@ export class TranscriptFold {
|
|
|
191
192
|
tool.endedAt = this.now();
|
|
192
193
|
}
|
|
193
194
|
}
|
|
194
|
-
|
|
195
|
-
tool.exitCode = event.exitCode;
|
|
196
|
-
}
|
|
195
|
+
takeToolUpdate(tool, event);
|
|
197
196
|
if (event.content !== undefined) {
|
|
198
197
|
tool.content = event.content;
|
|
199
198
|
this.claimByResult(tool);
|
|
200
199
|
}
|
|
201
|
-
if (event.locations !== undefined) {
|
|
202
|
-
tool.locations = event.locations;
|
|
203
|
-
}
|
|
204
200
|
});
|
|
205
201
|
case "subagent":
|
|
206
202
|
return this.subagentBorn(event);
|
|
@@ -247,12 +243,12 @@ export class TranscriptFold {
|
|
|
247
243
|
const notice = keptWarmNotice(event);
|
|
248
244
|
return line === undefined || notice === undefined ? [] : this.pushRow({ role: "notice", text: line, noticeCode: noticeCode(notice) });
|
|
249
245
|
}
|
|
246
|
+
// Each a row of its own rather than a stamp on the message: what was left out is not part of what was sent, and
|
|
247
|
+
// the fold beside the message only ever lists notes that actually rode.
|
|
250
248
|
case "context_trim":
|
|
251
|
-
// A row of its own rather than a stamp on the message: what was left out is not part of what was sent,
|
|
252
|
-
// and the fold beside the message only ever lists notes that actually rode.
|
|
253
|
-
return this.pushRow({ role: "notice", text: contextTrimLine(event), noticeCode: noticeCode(contextTrimNotice(event)) });
|
|
254
249
|
case "handoff":
|
|
255
|
-
|
|
250
|
+
case "fresh_start":
|
|
251
|
+
return this.pushRow(startingRow(event));
|
|
256
252
|
case "worktree":
|
|
257
253
|
return this.synced(event.sync);
|
|
258
254
|
case "landed":
|
|
@@ -737,14 +733,18 @@ export const patchedRow = <R extends TranscriptRow>(row: R, patch: RowPatch): R
|
|
|
737
733
|
|
|
738
734
|
/** Applies one patch to a row list; only what the patch names moves (patchedRow). */
|
|
739
735
|
export const applyTranscriptPatch = (rows: readonly TranscriptRow[], patch: TranscriptPatch): TranscriptRow[] => {
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
return [...rows, patch.row];
|
|
743
|
-
case "drop":
|
|
744
|
-
return rows.filter((_row, index) => index !== patch.index);
|
|
745
|
-
default:
|
|
746
|
-
return rows.map((row, index) => (index === patch.index ? patchedRow(row, patch) : row));
|
|
736
|
+
if (patch.op === "append") {
|
|
737
|
+
return [...rows, patch.row];
|
|
747
738
|
}
|
|
739
|
+
if (patch.op === "drop") {
|
|
740
|
+
return rows.filter((_row, index) => index !== patch.index);
|
|
741
|
+
}
|
|
742
|
+
const next = [...rows];
|
|
743
|
+
const row = next[patch.index];
|
|
744
|
+
if (row !== undefined) {
|
|
745
|
+
next[patch.index] = patchedRow(row, patch);
|
|
746
|
+
}
|
|
747
|
+
return next;
|
|
748
748
|
};
|
|
749
749
|
|
|
750
750
|
// Appends a delegated subagent's reasoning onto the card with this id, wherever it nests.
|
|
@@ -771,25 +771,24 @@ const upsertTool = (tools: readonly TranscriptTool[], tool: TranscriptTool, pare
|
|
|
771
771
|
return [...tools, tool];
|
|
772
772
|
};
|
|
773
773
|
|
|
774
|
-
// Applies `fn` to the tool with `id` anywhere in the tree;
|
|
775
|
-
// identity
|
|
774
|
+
// Applies `fn` to the tool with `id` anywhere in the tree; copies only arrays on a changed branch, so an unrelated
|
|
775
|
+
// subtree keeps its identity without allocating an array for every streamed update.
|
|
776
776
|
export const mapTool = (tools: readonly TranscriptTool[], id: string, fn: (tool: TranscriptTool) => TranscriptTool): readonly TranscriptTool[] => {
|
|
777
|
-
let
|
|
778
|
-
|
|
777
|
+
let next: TranscriptTool[] | undefined;
|
|
778
|
+
for (let index = 0; index < tools.length; index += 1) {
|
|
779
|
+
const tool = tools[index]!;
|
|
779
780
|
if (tool.id === id) {
|
|
780
|
-
|
|
781
|
-
|
|
781
|
+
(next ??= [...tools])[index] = fn(tool);
|
|
782
|
+
continue;
|
|
782
783
|
}
|
|
783
784
|
if (tool.children !== undefined) {
|
|
784
785
|
const children = mapTool(tool.children, id, fn);
|
|
785
786
|
if (children !== tool.children) {
|
|
786
|
-
|
|
787
|
-
return { ...tool, children: [...children] };
|
|
787
|
+
(next ??= [...tools])[index] = { ...tool, children: [...children] };
|
|
788
788
|
}
|
|
789
789
|
}
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
return changed ? next : tools;
|
|
790
|
+
}
|
|
791
|
+
return next ?? tools;
|
|
793
792
|
};
|
|
794
793
|
|
|
795
794
|
// Which row fields are cards, exported for readers that count rows by them.
|