patchwork-os 1.2.0-beta.2.canary.626 → 1.2.0-beta.2.canary.627
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/dist/privacy/destinationRegistry.d.ts +72 -0
- package/dist/privacy/destinationRegistry.js +127 -0
- package/dist/privacy/destinationRegistry.js.map +1 -0
- package/dist/recipes/agentExecutor.d.ts +7 -0
- package/dist/recipes/agentExecutor.js +25 -5
- package/dist/recipes/agentExecutor.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Destination registry (ADR-0021).
|
|
3
|
+
*
|
|
4
|
+
* The decision in `dataPolicy.ts` is pure and complete, and until this module
|
|
5
|
+
* existed it was also unreachable: `executeAgent` only evaluates the boundary
|
|
6
|
+
* when a destination is supplied, and nothing supplied one. The engine was
|
|
7
|
+
* built and inert.
|
|
8
|
+
*
|
|
9
|
+
* A destination is *where a prompt is about to go*. Patchwork resolves that
|
|
10
|
+
* from the driver, because that is what actually determines whether bytes
|
|
11
|
+
* cross a network boundary:
|
|
12
|
+
*
|
|
13
|
+
* local — a model on this machine (`local`, `ollama`, an OpenAI-compatible
|
|
14
|
+
* endpoint pointed at localhost)
|
|
15
|
+
* remote — anything that sends the prompt to a third party
|
|
16
|
+
*
|
|
17
|
+
* ## Configuration is opt-in, and absence means inert
|
|
18
|
+
*
|
|
19
|
+
* With no `privacy.destinations` block, `resolveDestination` returns null and
|
|
20
|
+
* `executeAgent` skips the boundary entirely — byte-identical to before. That
|
|
21
|
+
* is the same fail-soft posture as the default classification, and for the same
|
|
22
|
+
* reason: a boundary that refuses work on every install that has not configured
|
|
23
|
+
* it would be switched off before it ever protected anyone.
|
|
24
|
+
*
|
|
25
|
+
* The asymmetry is deliberate and worth stating. Configuring a destination is
|
|
26
|
+
* how an operator OPTS IN to enforcement. Once opted in, the decision is
|
|
27
|
+
* fail-CLOSED — an unknown driver resolves to the strictest registered remote
|
|
28
|
+
* profile rather than to "no destination", because "we do not recognise where
|
|
29
|
+
* this is going" must never read as "it is fine to send".
|
|
30
|
+
*/
|
|
31
|
+
import { type Classification, type Destination } from "./dataPolicy.js";
|
|
32
|
+
export interface DestinationConfig {
|
|
33
|
+
type?: string;
|
|
34
|
+
classifications?: unknown;
|
|
35
|
+
forbiddenCategories?: unknown;
|
|
36
|
+
approvable?: unknown;
|
|
37
|
+
/** Driver names this destination covers. */
|
|
38
|
+
drivers?: unknown;
|
|
39
|
+
}
|
|
40
|
+
export interface PrivacyConfig {
|
|
41
|
+
destinations?: Record<string, DestinationConfig>;
|
|
42
|
+
}
|
|
43
|
+
export interface ParsedRegistry {
|
|
44
|
+
destinations: Destination[];
|
|
45
|
+
/** Destination id → driver names it covers. */
|
|
46
|
+
driversFor: Map<string, string[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Entries that could not be parsed, with a reason. REPORTED rather than
|
|
49
|
+
* dropped: a destination that silently vanishes from the registry downgrades
|
|
50
|
+
* enforcement to "no destination", which is exactly the direction this must
|
|
51
|
+
* never fail in.
|
|
52
|
+
*/
|
|
53
|
+
invalid: Array<{
|
|
54
|
+
id: string;
|
|
55
|
+
reason: string;
|
|
56
|
+
}>;
|
|
57
|
+
}
|
|
58
|
+
export declare function parseRegistry(cfg: PrivacyConfig | undefined): ParsedRegistry;
|
|
59
|
+
export interface ResolvedDestination {
|
|
60
|
+
destination: Destination;
|
|
61
|
+
/** True when some registered LOCAL destination is cleared for `forClass`. */
|
|
62
|
+
localDestinationAccepts: boolean;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Resolve the destination for a dispatch.
|
|
66
|
+
*
|
|
67
|
+
* Returns null ONLY when nothing is registered — the inert case. Once anything
|
|
68
|
+
* is registered, this always yields a destination, because falling back to null
|
|
69
|
+
* on an unrecognised driver would silently disable the boundary for exactly the
|
|
70
|
+
* dispatches nobody anticipated.
|
|
71
|
+
*/
|
|
72
|
+
export declare function resolveDestination(registry: ParsedRegistry, driver: string | undefined, forClass: Classification): ResolvedDestination | null;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Destination registry (ADR-0021).
|
|
3
|
+
*
|
|
4
|
+
* The decision in `dataPolicy.ts` is pure and complete, and until this module
|
|
5
|
+
* existed it was also unreachable: `executeAgent` only evaluates the boundary
|
|
6
|
+
* when a destination is supplied, and nothing supplied one. The engine was
|
|
7
|
+
* built and inert.
|
|
8
|
+
*
|
|
9
|
+
* A destination is *where a prompt is about to go*. Patchwork resolves that
|
|
10
|
+
* from the driver, because that is what actually determines whether bytes
|
|
11
|
+
* cross a network boundary:
|
|
12
|
+
*
|
|
13
|
+
* local — a model on this machine (`local`, `ollama`, an OpenAI-compatible
|
|
14
|
+
* endpoint pointed at localhost)
|
|
15
|
+
* remote — anything that sends the prompt to a third party
|
|
16
|
+
*
|
|
17
|
+
* ## Configuration is opt-in, and absence means inert
|
|
18
|
+
*
|
|
19
|
+
* With no `privacy.destinations` block, `resolveDestination` returns null and
|
|
20
|
+
* `executeAgent` skips the boundary entirely — byte-identical to before. That
|
|
21
|
+
* is the same fail-soft posture as the default classification, and for the same
|
|
22
|
+
* reason: a boundary that refuses work on every install that has not configured
|
|
23
|
+
* it would be switched off before it ever protected anyone.
|
|
24
|
+
*
|
|
25
|
+
* The asymmetry is deliberate and worth stating. Configuring a destination is
|
|
26
|
+
* how an operator OPTS IN to enforcement. Once opted in, the decision is
|
|
27
|
+
* fail-CLOSED — an unknown driver resolves to the strictest registered remote
|
|
28
|
+
* profile rather than to "no destination", because "we do not recognise where
|
|
29
|
+
* this is going" must never read as "it is fine to send".
|
|
30
|
+
*/
|
|
31
|
+
import { CLASSIFICATIONS, } from "./dataPolicy.js";
|
|
32
|
+
/** Drivers that keep the prompt on this machine. */
|
|
33
|
+
const LOCAL_DRIVERS = new Set(["local", "ollama", "lmstudio", "llamacpp"]);
|
|
34
|
+
function parseClassifications(raw) {
|
|
35
|
+
if (!Array.isArray(raw))
|
|
36
|
+
return null;
|
|
37
|
+
const out = [];
|
|
38
|
+
for (const v of raw) {
|
|
39
|
+
if (typeof v !== "string")
|
|
40
|
+
return null;
|
|
41
|
+
if (!CLASSIFICATIONS.includes(v))
|
|
42
|
+
return null;
|
|
43
|
+
out.push(v);
|
|
44
|
+
}
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
export function parseRegistry(cfg) {
|
|
48
|
+
const destinations = [];
|
|
49
|
+
const driversFor = new Map();
|
|
50
|
+
const invalid = [];
|
|
51
|
+
for (const [id, raw] of Object.entries(cfg?.destinations ?? {})) {
|
|
52
|
+
if (!raw || typeof raw !== "object") {
|
|
53
|
+
invalid.push({ id, reason: "not an object" });
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const type = raw.type === "local" ? "local" : raw.type === "remote" ? "remote" : null;
|
|
57
|
+
if (!type) {
|
|
58
|
+
invalid.push({ id, reason: `type must be "local" or "remote"` });
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
const classifications = parseClassifications(raw.classifications);
|
|
62
|
+
if (!classifications) {
|
|
63
|
+
invalid.push({
|
|
64
|
+
id,
|
|
65
|
+
reason: "classifications must be an array of known classifications",
|
|
66
|
+
});
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const dest = { id, type, classifications };
|
|
70
|
+
if (Array.isArray(raw.forbiddenCategories)) {
|
|
71
|
+
dest.forbiddenCategories = raw.forbiddenCategories.filter((c) => typeof c === "string");
|
|
72
|
+
}
|
|
73
|
+
if (raw.approvable === true)
|
|
74
|
+
dest.approvable = true;
|
|
75
|
+
destinations.push(dest);
|
|
76
|
+
driversFor.set(id, Array.isArray(raw.drivers)
|
|
77
|
+
? raw.drivers.filter((d) => typeof d === "string")
|
|
78
|
+
: []);
|
|
79
|
+
}
|
|
80
|
+
return { destinations, driversFor, invalid };
|
|
81
|
+
}
|
|
82
|
+
/** The strictest remote destination — fewest classifications wins. */
|
|
83
|
+
function strictestRemote(destinations) {
|
|
84
|
+
const remotes = destinations.filter((d) => d.type === "remote");
|
|
85
|
+
if (remotes.length === 0)
|
|
86
|
+
return null;
|
|
87
|
+
return remotes.reduce((a, b) => b.classifications.length < a.classifications.length ? b : a);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Resolve the destination for a dispatch.
|
|
91
|
+
*
|
|
92
|
+
* Returns null ONLY when nothing is registered — the inert case. Once anything
|
|
93
|
+
* is registered, this always yields a destination, because falling back to null
|
|
94
|
+
* on an unrecognised driver would silently disable the boundary for exactly the
|
|
95
|
+
* dispatches nobody anticipated.
|
|
96
|
+
*/
|
|
97
|
+
export function resolveDestination(registry, driver, forClass) {
|
|
98
|
+
if (registry.destinations.length === 0)
|
|
99
|
+
return null;
|
|
100
|
+
const d = (driver ?? "").toLowerCase();
|
|
101
|
+
const localAccepts = registry.destinations.some((dest) => dest.type === "local" && dest.classifications.includes(forClass));
|
|
102
|
+
// Explicit driver mapping wins.
|
|
103
|
+
for (const dest of registry.destinations) {
|
|
104
|
+
if ((registry.driversFor.get(dest.id) ?? []).includes(d)) {
|
|
105
|
+
return { destination: dest, localDestinationAccepts: localAccepts };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Otherwise infer by driver family.
|
|
109
|
+
if (LOCAL_DRIVERS.has(d)) {
|
|
110
|
+
const local = registry.destinations.find((x) => x.type === "local");
|
|
111
|
+
if (local) {
|
|
112
|
+
return { destination: local, localDestinationAccepts: localAccepts };
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Unknown or remote driver → strictest remote. Fail closed: "we do not
|
|
116
|
+
// recognise where this is going" must never read as "it is fine to send".
|
|
117
|
+
const remote = strictestRemote(registry.destinations);
|
|
118
|
+
if (remote) {
|
|
119
|
+
return { destination: remote, localDestinationAccepts: localAccepts };
|
|
120
|
+
}
|
|
121
|
+
// Only local destinations are registered but the driver is not local. The
|
|
122
|
+
// strictest available answer is the local profile, which will refuse
|
|
123
|
+
// anything it is not cleared for.
|
|
124
|
+
const first = registry.destinations[0];
|
|
125
|
+
return { destination: first, localDestinationAccepts: localAccepts };
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=destinationRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destinationRegistry.js","sourceRoot":"","sources":["../../src/privacy/destinationRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EACL,eAAe,GAGhB,MAAM,iBAAiB,CAAC;AAEzB,oDAAoD;AACpD,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;AAe3E,SAAS,oBAAoB,CAAC,GAAY;IACxC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IACrC,MAAM,GAAG,GAAqB,EAAE,CAAC;IACjC,KAAK,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC;QACpB,IAAI,OAAO,CAAC,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QACvC,IAAI,CAAE,eAAqC,CAAC,QAAQ,CAAC,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QACrE,GAAG,CAAC,IAAI,CAAC,CAAmB,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAeD,MAAM,UAAU,aAAa,CAAC,GAA8B;IAC1D,MAAM,YAAY,GAAkB,EAAE,CAAC;IACvC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC/C,MAAM,OAAO,GAA0C,EAAE,CAAC;IAE1D,KAAK,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,YAAY,IAAI,EAAE,CAAC,EAAE,CAAC;QAChE,IAAI,CAAC,GAAG,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IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;YACzD,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,uBAAuB,EAAE,YAAY,EAAE,CAAC;QACtE,CAAC;IACH,CAAC;IAED,oCAAoC;IACpC,IAAI,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;QACpE,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,uBAAuB,EAAE,YAAY,EAAE,CAAC;QACvE,CAAC;IACH,CAAC;IAED,uEAAuE;IACvE,0EAA0E;IAC1E,MAAM,MAAM,GAAG,eAAe,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACtD,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,uBAAuB,EAAE,YAAY,EAAE,CAAC;IACxE,CAAC;IACD,0EAA0E;IAC1E,qEAAqE;IACrE,kCAAkC;IAClC,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAgB,CAAC;IACtD,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,uBAAuB,EAAE,YAAY,EAAE,CAAC;AACvE,CAAC"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* localFn (Ollama/LM Studio) instead of Anthropic API — opt-in behaviour change.
|
|
9
9
|
*/
|
|
10
10
|
import { type Destination } from "../privacy/dataPolicy.js";
|
|
11
|
+
import { type PrivacyConfig } from "../privacy/destinationRegistry.js";
|
|
11
12
|
/**
|
|
12
13
|
* Token usage reported by an adapter. Both fields are integers; absent
|
|
13
14
|
* `usage` on the parent `AgentResult` means the driver didn't surface
|
|
@@ -48,6 +49,12 @@ export interface AgentExecutorDeps {
|
|
|
48
49
|
* Optional: an unwired sink means no receipt, never a refusal — the
|
|
49
50
|
* boundary must not depend on its own audit trail being configured.
|
|
50
51
|
*/
|
|
52
|
+
/**
|
|
53
|
+
* Supplies `privacy.destinations` from operator config. Absent means the
|
|
54
|
+
* boundary stays inert unless a caller passes an explicit destination —
|
|
55
|
+
* the opt-in posture ADR-0021 requires.
|
|
56
|
+
*/
|
|
57
|
+
loadPrivacyConfigFn?: () => PrivacyConfig | undefined;
|
|
51
58
|
recordBoundaryDecisionFn?: (r: {
|
|
52
59
|
decision: string;
|
|
53
60
|
reason: string;
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* CHANGELOG: chained users with model:local in ~/.patchwork/config now route to
|
|
8
8
|
* localFn (Ollama/LM Studio) instead of Anthropic API — opt-in behaviour change.
|
|
9
9
|
*/
|
|
10
|
-
import { decideBoundary, parseDataPolicy, } from "../privacy/dataPolicy.js";
|
|
10
|
+
import { DEFAULT_CLASSIFICATION, decideBoundary, parseDataPolicy, } from "../privacy/dataPolicy.js";
|
|
11
|
+
import { parseRegistry, resolveDestination, } from "../privacy/destinationRegistry.js";
|
|
11
12
|
import { resolveLocalModel } from "./localSettings.js";
|
|
12
13
|
/**
|
|
13
14
|
* Model the anthropic/local agent paths fall back to when a step omits `model`.
|
|
@@ -62,10 +63,29 @@ const CODEX_WORKER_SANDBOX_LOCKDOWN = {
|
|
|
62
63
|
* operator wrote a label; silently reading it as `internal` because of a typo
|
|
63
64
|
* would leave them believing data was protected when it was not.
|
|
64
65
|
*/
|
|
65
|
-
function evaluateBoundary(ctx) {
|
|
66
|
-
|
|
66
|
+
function evaluateBoundary(ctx, driver, loadPrivacyConfig) {
|
|
67
|
+
const policy0 = parseDataPolicy(ctx?.dataPolicy);
|
|
68
|
+
// Resolve the destination HERE rather than requiring every call site to pass
|
|
69
|
+
// one. There are four dispatch sites in the flat runner alone; a boundary
|
|
70
|
+
// that depends on each of them remembering is a boundary with four ways to
|
|
71
|
+
// be bypassed, and the fifth call site added later inherits none of them.
|
|
72
|
+
let destination = ctx?.destination;
|
|
73
|
+
let localAccepts = ctx?.localDestinationAccepts;
|
|
74
|
+
if (!destination && loadPrivacyConfig) {
|
|
75
|
+
const registry = parseRegistry(loadPrivacyConfig());
|
|
76
|
+
const forClass = policy0?.classification ?? DEFAULT_CLASSIFICATION;
|
|
77
|
+
const resolved = resolveDestination(registry, driver, forClass);
|
|
78
|
+
if (resolved) {
|
|
79
|
+
destination = resolved.destination;
|
|
80
|
+
localAccepts = resolved.localDestinationAccepts;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (!destination)
|
|
67
84
|
return null;
|
|
68
|
-
const
|
|
85
|
+
const ctx2 = { ...ctx, destination, localDestinationAccepts: localAccepts };
|
|
86
|
+
return evaluateAgainst(policy0, ctx2);
|
|
87
|
+
}
|
|
88
|
+
function evaluateAgainst(policy, ctx) {
|
|
69
89
|
if (policy === null) {
|
|
70
90
|
return {
|
|
71
91
|
decision: "DENY",
|
|
@@ -104,7 +124,7 @@ export async function executeAgent(input, deps) {
|
|
|
104
124
|
// Precedence is privacy -> capability -> cost, and it is not negotiable by
|
|
105
125
|
// the later stages: a cheaper or more capable model that is not authorised
|
|
106
126
|
// for the data does not become authorised by being cheaper or more capable.
|
|
107
|
-
const boundary = evaluateBoundary(input.boundary);
|
|
127
|
+
const boundary = evaluateBoundary(input.boundary, driver, deps.loadPrivacyConfigFn);
|
|
108
128
|
if (boundary && boundary.decision !== "ALLOW") {
|
|
109
129
|
deps.recordBoundaryDecisionFn?.({
|
|
110
130
|
decision: boundary.decision,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentExecutor.js","sourceRoot":"","sources":["../../src/recipes/agentExecutor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"agentExecutor.js","sourceRoot":"","sources":["../../src/recipes/agentExecutor.ts"],"names":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AI,aAAa,EACtB,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,IAAI,aAAa,CAAC,CACjD,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "patchwork-os",
|
|
3
|
-
"version": "1.2.0-beta.2.canary.
|
|
3
|
+
"version": "1.2.0-beta.2.canary.627",
|
|
4
4
|
"description": "Your personal AI runtime, local-first. Patchwork OS gives any AI model a consistent set of tools, YAML recipes, a delegation policy with approval queue, and a durable trace memory — all on your machine, all under your policy.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|