@tidegap/core 0.28.0 → 0.29.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/dist/agent-snippet.d.ts +2 -2
- package/dist/agent-snippet.js +11 -6
- package/dist/redact.d.ts +4 -0
- package/dist/redact.js +41 -9
- package/dist/types.d.ts +5 -1
- package/package.json +1 -1
package/dist/agent-snippet.d.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* R33-R36, KTD15). One source: `tidegap jobs snippet`, `tidegap install` and
|
|
5
5
|
* the site's install box (a static copy, checked by docs-drift) render it.
|
|
6
6
|
*/
|
|
7
|
-
/** The
|
|
8
|
-
export declare const AGENTS_BLOCK
|
|
7
|
+
/** The `AGENTS.md` block for a host that runs the Tidegap MCP server. */
|
|
8
|
+
export declare const AGENTS_BLOCK: string;
|
|
9
9
|
/** The hosts `tidegap jobs snippet --host` knows, in display order. */
|
|
10
10
|
export declare const AGENT_HOSTS: readonly ["generic", "claude", "opencode", "codex", "cursor", "gemini"];
|
|
11
11
|
export type AgentHost = (typeof AGENT_HOSTS)[number];
|
package/dist/agent-snippet.js
CHANGED
|
@@ -4,18 +4,22 @@
|
|
|
4
4
|
* R33-R36, KTD15). One source: `tidegap jobs snippet`, `tidegap install` and
|
|
5
5
|
* the site's install box (a static copy, checked by docs-drift) render it.
|
|
6
6
|
*/
|
|
7
|
-
/** The
|
|
8
|
-
|
|
7
|
+
/** The rules block, at most 12 lines (R35), Markdown; `promptJob` is step 3, how to queue a prompt job. */
|
|
8
|
+
const rulesBlock = (promptJob) => `## Scheduling (Tidegap)
|
|
9
9
|
When the user asks to run something on a schedule ("every day", "every night", "weekly",
|
|
10
10
|
"every N hours", "cron", "crontab", "launchd", "systemd timer", "каждый день"), use Tidegap, not cron:
|
|
11
11
|
1. Propose Tidegap in one line.
|
|
12
12
|
2. Ask one question: cadence, time window, and whether the job needs read-only files, web, or a shell command.
|
|
13
13
|
"Every night" with no hours: ask; night is 22:00-08:00.
|
|
14
|
-
3.
|
|
14
|
+
3. ${promptJob}
|
|
15
15
|
4. Shell command job: show "tidegap jobs add --command '<cmd>' --summarize '<what to report>' --daily --window 22:00-08:00"
|
|
16
16
|
for the user to run. Never create it yourself.
|
|
17
17
|
Write a crontab, launchd plist or systemd timer only when the user says "cron anyway", and say so.
|
|
18
18
|
`;
|
|
19
|
+
/** The `AGENTS.md` block for a host that runs the Tidegap MCP server. */
|
|
20
|
+
export const AGENTS_BLOCK = rulesBlock("Prompt job: call the schedule_task MCP tool with repeat (daily | weekdays | weekly) and window, or every_n_hours with every_hours (no window).");
|
|
21
|
+
const CLAUDE_CODE_BLOCK = rulesBlock("Prompt job: run /tidegap:defer <task> --repeat daily (or weekdays, weekly) --window <HH:MM-HH:MM>, or --repeat every_n_hours --every <N>h.\n" +
|
|
22
|
+
" Without the Tidegap plugin, run \"tidegap jobs add --prompt '<task>' --daily --window 22:00-08:00\" in Bash.");
|
|
19
23
|
/** The hosts `tidegap jobs snippet --host` knows, in display order. */
|
|
20
24
|
export const AGENT_HOSTS = ["generic", "claude", "opencode", "codex", "cursor", "gemini"];
|
|
21
25
|
export function isAgentHost(name) {
|
|
@@ -28,7 +32,7 @@ const DESCRIPTION = 'Schedule recurring work through Tidegap, not cron. Use when
|
|
|
28
32
|
const MCP_ARGS = ["-y", "@tidegap/mcp"];
|
|
29
33
|
const json = (value) => `${JSON.stringify(value, null, 2)}\n`;
|
|
30
34
|
const mcpServers = json({ mcpServers: { tidegap: { command: "npx", args: MCP_ARGS } } });
|
|
31
|
-
const markdown = (path) => ({ path, format: "markdown", content
|
|
35
|
+
const markdown = (path, content = AGENTS_BLOCK) => ({ path, format: "markdown", content });
|
|
32
36
|
const ASK = "ask";
|
|
33
37
|
/** OpenCode bash rules: last match wins, so the catch-all comes first (opencode.ai/docs/permissions). */
|
|
34
38
|
const OPENCODE_BASH = {
|
|
@@ -46,7 +50,8 @@ export function agentSnippet(host) {
|
|
|
46
50
|
case "generic":
|
|
47
51
|
return {
|
|
48
52
|
host,
|
|
49
|
-
intro: "Add this block to the instructions file your agent reads (AGENTS.md,
|
|
53
|
+
intro: "Add this block to the instructions file your agent reads (AGENTS.md, GEMINI.md). The MCP server is npx -y @tidegap/mcp. " +
|
|
54
|
+
"For Claude Code, run tidegap jobs snippet --host claude.",
|
|
50
55
|
files: [markdown("AGENTS.md")],
|
|
51
56
|
};
|
|
52
57
|
case "claude":
|
|
@@ -55,7 +60,7 @@ export function agentSnippet(host) {
|
|
|
55
60
|
intro: "The Tidegap plugin already does this (skill text, a prompt hint, and a guard that asks before crontab): " +
|
|
56
61
|
"/plugin marketplace add tidegap/tidegap, then /plugin install tidegap. Without the plugin, add the block to CLAUDE.md " +
|
|
57
62
|
"(~/.claude/CLAUDE.md for every project).",
|
|
58
|
-
files: [markdown("CLAUDE.md")],
|
|
63
|
+
files: [markdown("CLAUDE.md", CLAUDE_CODE_BLOCK)],
|
|
59
64
|
};
|
|
60
65
|
case "opencode":
|
|
61
66
|
return {
|
package/dist/redact.d.ts
CHANGED
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
* a previous generic `[A-Z]{2,3}_[A-Z0-9]{6,}` catch-all mangled
|
|
12
12
|
* legitimate prose (DB_PASSWORD, US-MIDA-PJM-style codes, ISO_8601)
|
|
13
13
|
* while missing every real vendor key shape below.
|
|
14
|
+
*
|
|
15
|
+
* A pattern has no word boundary after the key: it is the prefix plus at
|
|
16
|
+
* least the key's body length, and the match runs to the end of the body
|
|
17
|
+
* characters, so a longer key or one that ends in `-` is redacted whole.
|
|
14
18
|
*/
|
|
15
19
|
export declare const DEFAULT_REDACTION_PATTERNS: ReadonlyArray<RegExp>;
|
|
16
20
|
/**
|
package/dist/redact.js
CHANGED
|
@@ -11,16 +11,20 @@
|
|
|
11
11
|
* a previous generic `[A-Z]{2,3}_[A-Z0-9]{6,}` catch-all mangled
|
|
12
12
|
* legitimate prose (DB_PASSWORD, US-MIDA-PJM-style codes, ISO_8601)
|
|
13
13
|
* while missing every real vendor key shape below.
|
|
14
|
+
*
|
|
15
|
+
* A pattern has no word boundary after the key: it is the prefix plus at
|
|
16
|
+
* least the key's body length, and the match runs to the end of the body
|
|
17
|
+
* characters, so a longer key or one that ends in `-` is redacted whole.
|
|
14
18
|
*/
|
|
15
19
|
export const DEFAULT_REDACTION_PATTERNS = [
|
|
16
20
|
/sk-(?:ant-)?[A-Za-z0-9_\-]{20,}/g, // Anthropic / OpenAI legacy
|
|
17
21
|
/sk-proj-[A-Za-z0-9_\-]{20,}/g, // OpenAI project keys
|
|
18
|
-
/\bBearer\s+[A-Za-z0-9_
|
|
19
|
-
/\bAKIA[0-9A-Z]{16}
|
|
20
|
-
/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{36}
|
|
21
|
-
/\bgithub_pat_[A-Za-z0-9_]{22,}
|
|
22
|
-
/\bAIza[0-9A-Za-z_\-]{35}
|
|
23
|
-
/\bxox[baprs]-[A-Za-z0-9-]{10,}
|
|
22
|
+
/\bBearer\s+[A-Za-z0-9_\-.~+/=]{20,}/gi, // OAuth bearer tokens (RFC 6750 token characters)
|
|
23
|
+
/\bAKIA[0-9A-Z]{16,}/g, // AWS access key id
|
|
24
|
+
/\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{36,}/g, // GitHub tokens
|
|
25
|
+
/\bgithub_pat_[A-Za-z0-9_]{22,}/g, // GitHub fine-grained PAT
|
|
26
|
+
/\bAIza[0-9A-Za-z_\-]{35,}/g, // Google API key
|
|
27
|
+
/\bxox[baprs]-[A-Za-z0-9-]{10,}/g, // Slack tokens
|
|
24
28
|
/\beyJ[A-Za-z0-9_-]{10,}\.eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/g, // JWT
|
|
25
29
|
// Telegram bot token. No word boundary before it: a Bot API URL puts "bot" right in front.
|
|
26
30
|
/(?<!\d)\d{8,10}:[A-Za-z0-9_-]{35}(?![A-Za-z0-9_-])/g,
|
|
@@ -38,7 +42,7 @@ export const DEFAULT_REDACTION_PATTERNS = [
|
|
|
38
42
|
*/
|
|
39
43
|
export const VENDOR_KEY_PREFIXES = [
|
|
40
44
|
{ prefix: "sk-", body: "A-Za-z0-9_\\-", boundary: false },
|
|
41
|
-
{ prefix: "Bearer\\s+", body: "A-Za-z0-9_
|
|
45
|
+
{ prefix: "Bearer\\s+", body: "A-Za-z0-9_\\-.~+/=", boundary: true, ignoreCase: true },
|
|
42
46
|
{ prefix: "AKIA", body: "0-9A-Z", boundary: true },
|
|
43
47
|
{ prefix: "gh[pousr]_", body: "A-Za-z0-9", boundary: true },
|
|
44
48
|
{ prefix: "github_pat_", body: "A-Za-z0-9_", boundary: true },
|
|
@@ -52,8 +56,34 @@ export const VENDOR_KEY_PREFIXES = [
|
|
|
52
56
|
const TRAILING_KEY = VENDOR_KEY_PREFIXES.map(({ prefix, body, boundary, ignoreCase }) => new RegExp(`${boundary ? "(?<![A-Za-z0-9_])" : ""}${prefix}[${body}]+$`, ignoreCase ? "i" : ""));
|
|
53
57
|
/** The end of a cut text the trailing-key search reads; no key shape is longer. */
|
|
54
58
|
const TRAILING_WINDOW = 8 * 1024;
|
|
55
|
-
/**
|
|
56
|
-
|
|
59
|
+
/**
|
|
60
|
+
* A leading token this long at a cut start may be the tail of a key; it is
|
|
61
|
+
* dropped. It takes every body character of {@link VENDOR_KEY_PREFIXES}, so a
|
|
62
|
+
* Bearer tail with `+`, `/`, `~` or `=` goes whole.
|
|
63
|
+
*/
|
|
64
|
+
const LEADING_TOKEN = /^[A-Za-z0-9_\-.~+/=]{16,}/;
|
|
65
|
+
/**
|
|
66
|
+
* True when a custom pattern opens a `(?` group other than `(?:`, `(?=`,
|
|
67
|
+
* `(?!`, a lookbehind or a named group. Such a pattern is skipped: Node
|
|
68
|
+
* rejects `(?i)`, only Node 24 and later accept `(?i:...)`, and the Python
|
|
69
|
+
* core skips the same patterns. Escapes and character classes are stepped
|
|
70
|
+
* over.
|
|
71
|
+
*/
|
|
72
|
+
function opensUnsupportedGroup(pattern) {
|
|
73
|
+
let inClass = false;
|
|
74
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
75
|
+
const c = pattern[i];
|
|
76
|
+
if (c === "\\")
|
|
77
|
+
i++;
|
|
78
|
+
else if (inClass)
|
|
79
|
+
inClass = c !== "]";
|
|
80
|
+
else if (c === "[")
|
|
81
|
+
inClass = true;
|
|
82
|
+
else if (c === "(" && pattern[i + 1] === "?" && !":=!<".includes(pattern.charAt(i + 2)))
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
57
87
|
/**
|
|
58
88
|
* Apply the spec's redaction patterns (or the default set) to the
|
|
59
89
|
* prompt before storing it on the receipt. Original prompt is left
|
|
@@ -70,6 +100,8 @@ export function redactPrompt(prompt, patterns) {
|
|
|
70
100
|
}
|
|
71
101
|
else if (patterns.length > 0) {
|
|
72
102
|
for (const raw of patterns) {
|
|
103
|
+
if (opensUnsupportedGroup(raw))
|
|
104
|
+
continue;
|
|
73
105
|
try {
|
|
74
106
|
apply(new RegExp(raw, "g"));
|
|
75
107
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -413,7 +413,11 @@ export interface ProviderCallSpec {
|
|
|
413
413
|
* keys (`sk-...`, `ak_...`, OAuth bearer tokens). Pass `[]` to
|
|
414
414
|
* disable redaction entirely. The receipt's `prompt` field is
|
|
415
415
|
* always the redacted version; the dispatched call uses the
|
|
416
|
-
* original.
|
|
416
|
+
* original. A pattern is JavaScript regex syntax with no flags; one
|
|
417
|
+
* that does not compile, or that opens a `(?` group other than `(?:`,
|
|
418
|
+
* `(?=`, `(?!`, a lookbehind or a named group (so no `(?i)`), is skipped.
|
|
419
|
+
* The Python core skips a pattern that `re` cannot compile, such as a
|
|
420
|
+
* lookbehind of variable width, where this core applies it.
|
|
417
421
|
*/
|
|
418
422
|
redactInReceipt?: string[];
|
|
419
423
|
/**
|