@nathanstephenson/flow 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/dist/backend/fake/index.js +3 -1
- package/dist/backend/pi/effort-capabilities.js +12 -0
- package/dist/backend/pi/index.js +25 -36
- package/dist/backend/pi/workflow-subagent.js +8 -3
- package/dist/build-id +1 -1
- package/dist/cli/application.js +9 -1
- package/dist/cli/bootstrap.js +258 -22
- package/dist/cli/install-guard.js +52 -9
- package/dist/cli/update.js +30 -13
- package/dist/cli/web-update.js +357 -0
- package/dist/client/model-choices.js +22 -4
- package/dist/client/reduce.js +18 -6
- package/dist/client/status.js +34 -20
- package/dist/client/workflow-effort.js +30 -0
- package/dist/daemon/credential-redaction.js +97 -4
- package/dist/daemon/host.js +341 -74
- package/dist/daemon/release-checker.js +104 -0
- package/dist/daemon/runtime.js +12 -4
- package/dist/daemon/server.js +81 -14
- package/dist/daemon/summariser.js +81 -15
- package/dist/daemon/update-api.js +3 -0
- package/dist/daemon/workflow-executions.js +146 -15
- package/dist/protocol/update.js +1 -0
- package/dist/tui/app.js +104 -10
- package/dist/tui/keys.js +46 -10
- package/dist/tui/render.js +58 -13
- package/dist/workflows/records.js +3 -1
- package/dist/workflows/scheduler.js +15 -1
- package/package.json +1 -1
- package/web/dist/apple-touch-icon.png +0 -0
- package/web/dist/assets/index-CaJfF2tQ.js +170 -0
- package/web/dist/assets/index-DWF4-3Fh.css +2 -0
- package/web/dist/assets/{settings-mcp-CcT0ADJR.js → settings-mcp-COi1p_1o.js} +1 -1
- package/web/dist/assets/{settings-secrets-CK4uF7fd.js → settings-secrets-C599riFl.js} +1 -1
- package/web/dist/assets/settings-workflows-BPjeFoaT.js +23 -0
- package/web/dist/assets/{workflows-D4T4Gy_7.css → workflows-9aO6cptD.css} +1 -1
- package/web/dist/assets/workflows-Bmsrl5kE.js +7 -0
- package/web/dist/assets/workflows-pane-DJ3UwHjd.js +1 -0
- package/web/dist/favicon-16x16.png +0 -0
- package/web/dist/favicon-32x32.png +0 -0
- package/web/dist/favicon.ico +0 -0
- package/web/dist/favicon.svg +8 -0
- package/web/dist/index.html +8 -3
- package/web/dist/safari-pinned-tab.svg +4 -0
- package/web/dist/assets/index-BC0gLS53.js +0 -106
- package/web/dist/assets/index-CCeZYKES.css +0 -2
- package/web/dist/assets/settings-workflows-CrbZF-nM.js +0 -23
- package/web/dist/assets/workflow-editors-naPqAmYO.js +0 -65
- package/web/dist/assets/workflows-hh6ioeEA.js +0 -7
- package/web/dist/assets/workflows-pane-Db-MHf7Z.js +0 -1
|
@@ -1,9 +1,102 @@
|
|
|
1
1
|
// Known credential values are replaced in keys as well as values, including common
|
|
2
2
|
// escaped/URL-encoded spellings. Never persist transport configuration in a workflow.
|
|
3
3
|
export function redactCredentials(value, credentials) {
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const visit = (item) => typeof item === 'string' ? text(item) : Array.isArray(item) ? item.map(visit) : item && typeof item === 'object' ? Object.fromEntries(Object.entries(item).map(([key, value]) => [text(key), visit(value)])) : item;
|
|
4
|
+
const { redact } = credentialTextRedactor(credentials);
|
|
5
|
+
const visit = (item) => typeof item === 'string' ? redact(item) : Array.isArray(item) ? item.map(visit) : item && typeof item === 'object' ? Object.fromEntries(Object.entries(item).map(([key, value]) => [redact(key), visit(value)])) : item;
|
|
7
6
|
return visit(value);
|
|
8
7
|
}
|
|
9
|
-
|
|
8
|
+
function credentialTextRedactor(credentials) {
|
|
9
|
+
const patterns = [...new Set(credentials.filter(Boolean).flatMap(secret => [secret, encodeURIComponent(secret), JSON.stringify(secret).slice(1, -1), JSON.stringify(JSON.stringify(secret).slice(1, -1)).slice(1, -1)]))]
|
|
10
|
+
.sort((a, b) => b.length - a.length);
|
|
11
|
+
// A replacement must not itself contain a credential. This matters for credentials such as
|
|
12
|
+
// "REDACTED", which would otherwise survive inside the conventional marker.
|
|
13
|
+
const replacement = ["[REDACTED]", "[FILTERED]", "<hidden>", ""].find(candidate => patterns.every(pattern => !candidate.includes(pattern)));
|
|
14
|
+
const lookahead = patterns.reduce((maximum, pattern) => Math.max(maximum, pattern.length - 1), 0);
|
|
15
|
+
return {
|
|
16
|
+
redact: value => patterns.reduce((result, secret) => result.split(secret).join(replacement), value),
|
|
17
|
+
inspect: (value, work) => {
|
|
18
|
+
if (value.length <= work)
|
|
19
|
+
return value;
|
|
20
|
+
const inspected = value.slice(0, work + lookahead);
|
|
21
|
+
// Include a credential which straddles the work boundary, but nothing after it. Redacting
|
|
22
|
+
// the entire lookahead is unsafe: several long matches can shrink enough that output reaches
|
|
23
|
+
// a credential fragment at the end of that lookahead.
|
|
24
|
+
let end = work;
|
|
25
|
+
for (;;) {
|
|
26
|
+
let extended = end;
|
|
27
|
+
for (const pattern of patterns) {
|
|
28
|
+
const start = inspected.lastIndexOf(pattern, end - 1);
|
|
29
|
+
if (start >= 0 && start < end && start + pattern.length > extended)
|
|
30
|
+
extended = start + pattern.length;
|
|
31
|
+
}
|
|
32
|
+
if (extended === end)
|
|
33
|
+
break;
|
|
34
|
+
end = Math.min(extended, inspected.length);
|
|
35
|
+
}
|
|
36
|
+
return inspected.slice(0, end);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export const credentialKey = /(?:authorization|cookie|password|passphrase|credential|secret|api[-_]?key|private[-_]?key|access[-_]?token|refresh[-_]?token|bearer|auth[-_]?token)/i;
|
|
41
|
+
const namingCredentialKey = /(?:authorization|cookie|password|passphrase|credential|secret|api[-_]?key|private[-_]?key|access[-_]?token|refresh[-_]?token|auth[-_]?token|bearer|token)/i;
|
|
42
|
+
export function credentialJsonSerializer(credentials) {
|
|
43
|
+
const { redact, inspect } = credentialTextRedactor(credentials);
|
|
44
|
+
return (value, limit) => {
|
|
45
|
+
let remaining = limit;
|
|
46
|
+
// Output limits do not bound omitted fields or the input scanned before encoding.
|
|
47
|
+
let work = Math.max(4_096, limit * 4);
|
|
48
|
+
const consume = (size) => {
|
|
49
|
+
if (work <= 0)
|
|
50
|
+
return false;
|
|
51
|
+
work -= Math.max(1, size);
|
|
52
|
+
return true;
|
|
53
|
+
};
|
|
54
|
+
const emit = (text) => {
|
|
55
|
+
if (text.length <= remaining) {
|
|
56
|
+
remaining -= text.length;
|
|
57
|
+
return text;
|
|
58
|
+
}
|
|
59
|
+
const clipped = text.slice(0, Math.max(0, remaining - 1)) + (remaining ? "…" : "");
|
|
60
|
+
remaining = 0;
|
|
61
|
+
return clipped;
|
|
62
|
+
};
|
|
63
|
+
const visit = (item) => {
|
|
64
|
+
if (!remaining || work <= 0)
|
|
65
|
+
return "";
|
|
66
|
+
if (typeof item === "string") {
|
|
67
|
+
const inspected = inspect(item, work);
|
|
68
|
+
consume(Math.min(item.length, work));
|
|
69
|
+
return emit(JSON.stringify(redact(inspected)));
|
|
70
|
+
}
|
|
71
|
+
if (item === null || typeof item !== "object") {
|
|
72
|
+
consume(1);
|
|
73
|
+
return emit(redact(JSON.stringify(item) ?? "null"));
|
|
74
|
+
}
|
|
75
|
+
if (Array.isArray(item) || Symbol.iterator in item) {
|
|
76
|
+
let result = emit("[");
|
|
77
|
+
let index = 0;
|
|
78
|
+
for (const nested of item) {
|
|
79
|
+
if (!remaining || !consume(1))
|
|
80
|
+
break;
|
|
81
|
+
result += emit(index++ ? "," : "") + visit(nested);
|
|
82
|
+
}
|
|
83
|
+
return result + emit("]");
|
|
84
|
+
}
|
|
85
|
+
let result = emit("{");
|
|
86
|
+
let index = 0;
|
|
87
|
+
for (const key in item) {
|
|
88
|
+
if (!remaining || work <= 0)
|
|
89
|
+
break;
|
|
90
|
+
if (!Object.prototype.hasOwnProperty.call(item, key))
|
|
91
|
+
continue;
|
|
92
|
+
const inspected = inspect(key, work);
|
|
93
|
+
consume(Math.min(key.length, work));
|
|
94
|
+
if (namingCredentialKey.test(inspected))
|
|
95
|
+
continue;
|
|
96
|
+
result += emit(index++ ? "," : "") + emit(JSON.stringify(redact(inspected)) + ":") + visit(item[key]);
|
|
97
|
+
}
|
|
98
|
+
return result + emit("}");
|
|
99
|
+
};
|
|
100
|
+
return visit(value);
|
|
101
|
+
};
|
|
102
|
+
}
|