@namzu/sdk 44.3.0 → 45.1.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/CHANGELOG.md +94 -0
- package/dist/authorization/command-line.d.ts +66 -19
- package/dist/authorization/command-line.d.ts.map +1 -1
- package/dist/authorization/command-line.js +130 -270
- package/dist/authorization/command-line.js.map +1 -1
- package/dist/authorization/gate.d.ts +7 -0
- package/dist/authorization/gate.d.ts.map +1 -1
- package/dist/authorization/gate.js +13 -3
- package/dist/authorization/gate.js.map +1 -1
- package/dist/authorization/rules.d.ts +10 -1
- package/dist/authorization/rules.d.ts.map +1 -1
- package/dist/authorization/rules.js +55 -8
- package/dist/authorization/rules.js.map +1 -1
- package/dist/authorization/shell-lexer.d.ts +152 -0
- package/dist/authorization/shell-lexer.d.ts.map +1 -0
- package/dist/authorization/shell-lexer.js +2156 -0
- package/dist/authorization/shell-lexer.js.map +1 -0
- package/dist/authorization/skill-grant.d.ts +182 -0
- package/dist/authorization/skill-grant.d.ts.map +1 -0
- package/dist/authorization/skill-grant.js +314 -0
- package/dist/authorization/skill-grant.js.map +1 -0
- package/dist/bridge/a2a/mapper.d.ts.map +1 -1
- package/dist/bridge/a2a/mapper.js +2 -0
- package/dist/bridge/a2a/mapper.js.map +1 -1
- package/dist/bridge/sse/mapper.d.ts.map +1 -1
- package/dist/bridge/sse/mapper.js +1 -0
- package/dist/bridge/sse/mapper.js.map +1 -1
- package/dist/directory/types.d.ts +2 -0
- package/dist/directory/types.d.ts.map +1 -1
- package/dist/directory/types.js.map +1 -1
- package/dist/manager/resident/outbox.d.ts +4 -4
- package/dist/persona/assembler.d.ts.map +1 -1
- package/dist/persona/assembler.js +5 -2
- package/dist/persona/assembler.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +1 -0
- package/dist/prompt/coding-agent-doctrine.js.map +1 -1
- package/dist/public-runtime.d.ts +5 -1
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +15 -1
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +4 -0
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +12 -1
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +9 -1
- package/dist/public-types.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.d.ts +2 -2
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +6 -2
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/query/declined.d.ts +12 -0
- package/dist/runtime/query/declined.d.ts.map +1 -0
- package/dist/runtime/query/declined.js +12 -0
- package/dist/runtime/query/declined.js.map +1 -0
- package/dist/runtime/query/executor.d.ts +36 -40
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +95 -53
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +8 -0
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +13 -0
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +13 -0
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/handoff.d.ts +22 -0
- package/dist/runtime/query/iteration/phases/handoff.d.ts.map +1 -0
- package/dist/runtime/query/iteration/phases/handoff.js +65 -0
- package/dist/runtime/query/iteration/phases/handoff.js.map +1 -0
- package/dist/runtime/query/iteration/phases/index.d.ts +1 -0
- package/dist/runtime/query/iteration/phases/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/index.js +1 -0
- package/dist/runtime/query/iteration/phases/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +56 -3
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/resume-pending.d.ts.map +1 -1
- package/dist/runtime/query/resume-pending.js +3 -2
- package/dist/runtime/query/resume-pending.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts +11 -0
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +36 -3
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +3 -0
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +1 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/schedules/cron.d.ts +21 -0
- package/dist/schedules/cron.d.ts.map +1 -0
- package/dist/schedules/cron.js +167 -0
- package/dist/schedules/cron.js.map +1 -0
- package/dist/schedules/describe.d.ts +14 -0
- package/dist/schedules/describe.d.ts.map +1 -0
- package/dist/schedules/describe.js +133 -0
- package/dist/schedules/describe.js.map +1 -0
- package/dist/schedules/errors.d.ts +11 -0
- package/dist/schedules/errors.d.ts.map +1 -0
- package/dist/schedules/errors.js +15 -0
- package/dist/schedules/errors.js.map +1 -0
- package/dist/schedules/evaluate.d.ts +35 -0
- package/dist/schedules/evaluate.d.ts.map +1 -0
- package/dist/schedules/evaluate.js +158 -0
- package/dist/schedules/evaluate.js.map +1 -0
- package/dist/schedules/index.d.ts +11 -0
- package/dist/schedules/index.d.ts.map +1 -0
- package/dist/schedules/index.js +8 -0
- package/dist/schedules/index.js.map +1 -0
- package/dist/schedules/next-fire.d.ts +50 -0
- package/dist/schedules/next-fire.d.ts.map +1 -0
- package/dist/schedules/next-fire.js +250 -0
- package/dist/schedules/next-fire.js.map +1 -0
- package/dist/schedules/spec.d.ts +30 -0
- package/dist/schedules/spec.d.ts.map +1 -0
- package/dist/schedules/spec.js +169 -0
- package/dist/schedules/spec.js.map +1 -0
- package/dist/schedules/types.d.ts +144 -0
- package/dist/schedules/types.d.ts.map +1 -0
- package/dist/schedules/types.js +11 -0
- package/dist/schedules/types.js.map +1 -0
- package/dist/schedules/tz.d.ts +44 -0
- package/dist/schedules/tz.d.ts.map +1 -0
- package/dist/schedules/tz.js +141 -0
- package/dist/schedules/tz.js.map +1 -0
- package/dist/skills/index.d.ts +1 -1
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +1 -1
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/loader.d.ts +21 -0
- package/dist/skills/loader.d.ts.map +1 -1
- package/dist/skills/loader.js +51 -1
- package/dist/skills/loader.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +18 -6
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/browser-url.d.ts +83 -0
- package/dist/tools/builtins/browser-url.d.ts.map +1 -0
- package/dist/tools/builtins/browser-url.js +240 -0
- package/dist/tools/builtins/browser-url.js.map +1 -0
- package/dist/tools/builtins/browser.d.ts +367 -0
- package/dist/tools/builtins/browser.d.ts.map +1 -0
- package/dist/tools/builtins/browser.js +704 -0
- package/dist/tools/builtins/browser.js.map +1 -0
- package/dist/tools/builtins/skill.d.ts +2 -9
- package/dist/tools/builtins/skill.d.ts.map +1 -1
- package/dist/tools/builtins/skill.js +74 -51
- package/dist/tools/builtins/skill.js.map +1 -1
- package/dist/tools/command-shell.d.ts +90 -0
- package/dist/tools/command-shell.d.ts.map +1 -0
- package/dist/tools/command-shell.js +129 -0
- package/dist/tools/command-shell.js.map +1 -0
- package/dist/tools/defineTool.d.ts +13 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +30 -1
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/schedules/index.d.ts +5 -0
- package/dist/tools/schedules/index.d.ts.map +1 -0
- package/dist/tools/schedules/index.js +4 -0
- package/dist/tools/schedules/index.js.map +1 -0
- package/dist/tools/schedules/loop-tool.d.ts +14 -0
- package/dist/tools/schedules/loop-tool.d.ts.map +1 -0
- package/dist/tools/schedules/loop-tool.js +81 -0
- package/dist/tools/schedules/loop-tool.js.map +1 -0
- package/dist/tools/schedules/present.d.ts +16 -0
- package/dist/tools/schedules/present.d.ts.map +1 -0
- package/dist/tools/schedules/present.js +69 -0
- package/dist/tools/schedules/present.js.map +1 -0
- package/dist/tools/schedules/prompt-scan.d.ts +17 -0
- package/dist/tools/schedules/prompt-scan.d.ts.map +1 -0
- package/dist/tools/schedules/prompt-scan.js +92 -0
- package/dist/tools/schedules/prompt-scan.js.map +1 -0
- package/dist/tools/schedules/schedule-tool.d.ts +16 -0
- package/dist/tools/schedules/schedule-tool.d.ts.map +1 -0
- package/dist/tools/schedules/schedule-tool.js +327 -0
- package/dist/tools/schedules/schedule-tool.js.map +1 -0
- package/dist/tools/schedules/types.d.ts +184 -0
- package/dist/tools/schedules/types.d.ts.map +1 -0
- package/dist/tools/schedules/types.js +11 -0
- package/dist/tools/schedules/types.js.map +1 -0
- package/dist/types/authorization/index.d.ts +86 -9
- package/dist/types/authorization/index.d.ts.map +1 -1
- package/dist/types/authorization/index.js +11 -1
- package/dist/types/authorization/index.js.map +1 -1
- package/dist/types/browser/index.d.ts +280 -0
- package/dist/types/browser/index.d.ts.map +1 -0
- package/dist/types/browser/index.js +12 -0
- package/dist/types/browser/index.js.map +1 -0
- package/dist/types/hitl/index.d.ts +23 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/session/events.d.ts +6 -0
- package/dist/types/session/events.d.ts.map +1 -1
- package/dist/types/session/events.js.map +1 -1
- package/dist/types/session/records.d.ts +23 -0
- package/dist/types/session/records.d.ts.map +1 -1
- package/dist/types/session/records.js +9 -0
- package/dist/types/session/records.js.map +1 -1
- package/dist/types/tool/index.d.ts +108 -5
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/tool/presentation.d.ts +7 -0
- package/dist/types/tool/presentation.d.ts.map +1 -1
- package/dist/utils/frontmatter.d.ts +35 -3
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +45 -5
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/id.d.ts +8 -0
- package/dist/utils/id.d.ts.map +1 -1
- package/dist/utils/id.js +12 -0
- package/dist/utils/id.js.map +1 -1
- package/package.json +1 -1
- package/src/authorization/command-line.ts +148 -293
- package/src/authorization/gate.ts +22 -2
- package/src/authorization/rules.ts +67 -8
- package/src/authorization/shell-lexer.ts +2349 -0
- package/src/authorization/skill-grant.ts +400 -0
- package/src/bridge/a2a/mapper.ts +2 -0
- package/src/bridge/sse/mapper.ts +1 -0
- package/src/directory/types.ts +2 -0
- package/src/persona/assembler.ts +5 -2
- package/src/prompt/coding-agent-doctrine.ts +1 -0
- package/src/public-runtime.ts +37 -0
- package/src/public-tools.ts +37 -1
- package/src/public-types.ts +57 -0
- package/src/runtime/jobs/registry.ts +19 -11
- package/src/runtime/query/declined.ts +12 -0
- package/src/runtime/query/executor.ts +116 -56
- package/src/runtime/query/index.ts +8 -0
- package/src/runtime/query/iteration/index.ts +13 -0
- package/src/runtime/query/iteration/phases/context.ts +13 -0
- package/src/runtime/query/iteration/phases/handoff.ts +74 -0
- package/src/runtime/query/iteration/phases/index.ts +1 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +55 -3
- package/src/runtime/query/resume-pending.ts +3 -2
- package/src/runtime/query/review-policy.ts +57 -3
- package/src/runtime/query/tooling.ts +4 -0
- package/src/schedules/cron.ts +202 -0
- package/src/schedules/describe.ts +138 -0
- package/src/schedules/errors.ts +15 -0
- package/src/schedules/evaluate.ts +178 -0
- package/src/schedules/index.ts +18 -0
- package/src/schedules/next-fire.ts +257 -0
- package/src/schedules/spec.ts +210 -0
- package/src/schedules/types.ts +163 -0
- package/src/schedules/tz.ts +155 -0
- package/src/skills/index.ts +1 -1
- package/src/skills/loader.ts +59 -1
- package/src/tools/builtins/bash.ts +24 -6
- package/src/tools/builtins/browser-url.ts +251 -0
- package/src/tools/builtins/browser.ts +817 -0
- package/src/tools/builtins/skill.ts +92 -53
- package/src/tools/command-shell.ts +166 -0
- package/src/tools/defineTool.ts +36 -1
- package/src/tools/schedules/index.ts +4 -0
- package/src/tools/schedules/loop-tool.ts +85 -0
- package/src/tools/schedules/present.ts +86 -0
- package/src/tools/schedules/prompt-scan.ts +96 -0
- package/src/tools/schedules/schedule-tool.ts +376 -0
- package/src/tools/schedules/types.ts +197 -0
- package/src/types/authorization/index.ts +60 -2
- package/src/types/browser/index.ts +341 -0
- package/src/types/hitl/index.ts +21 -0
- package/src/types/session/events.ts +6 -0
- package/src/types/session/records.ts +10 -0
- package/src/types/tool/index.ts +109 -5
- package/src/types/tool/presentation.ts +7 -0
- package/src/utils/frontmatter.ts +81 -5
- package/src/utils/id.ts +14 -0
package/dist/tools/defineTool.js
CHANGED
|
@@ -1,4 +1,31 @@
|
|
|
1
1
|
import { toErrorMessage } from '../utils/error.js';
|
|
2
|
+
/**
|
|
3
|
+
* The `isDestructive` functions built from a literal `destructive: true`.
|
|
4
|
+
*
|
|
5
|
+
* Such a tool is destructive for EVERY input, so no call of it can ever be
|
|
6
|
+
* approved without review — and a grant that names it (a skill's
|
|
7
|
+
* `allowed-tools: Write`) would be a promise the review phase never keeps.
|
|
8
|
+
* Kept here rather than as a field on the definition so the public
|
|
9
|
+
* `ToolDefinition` shape does not change; see {@link isAlwaysDestructive}.
|
|
10
|
+
*/
|
|
11
|
+
const ALWAYS_DESTRUCTIVE = new WeakSet();
|
|
12
|
+
/**
|
|
13
|
+
* Whether a tool declares every call destructive, whatever the input.
|
|
14
|
+
*
|
|
15
|
+
* Known only for a tool built by {@link defineTool} with `destructive: true`.
|
|
16
|
+
* A hand-written definition, or one whose flag depends on the input, answers
|
|
17
|
+
* `false`: its calls are still judged one by one, so nothing is lost but an
|
|
18
|
+
* early warning.
|
|
19
|
+
*/
|
|
20
|
+
export function isAlwaysDestructive(tool) {
|
|
21
|
+
return tool.isDestructive !== undefined && ALWAYS_DESTRUCTIVE.has(tool.isDestructive);
|
|
22
|
+
}
|
|
23
|
+
function constantDestructive(value) {
|
|
24
|
+
const fn = () => value;
|
|
25
|
+
if (value)
|
|
26
|
+
ALWAYS_DESTRUCTIVE.add(fn);
|
|
27
|
+
return fn;
|
|
28
|
+
}
|
|
2
29
|
export function defineTool(options) {
|
|
3
30
|
return {
|
|
4
31
|
name: options.name,
|
|
@@ -11,7 +38,9 @@ export function defineTool(options) {
|
|
|
11
38
|
...(options.timeoutMs !== undefined ? { timeoutMs: options.timeoutMs } : {}),
|
|
12
39
|
...(options.maxRetries !== undefined ? { maxRetries: options.maxRetries } : {}),
|
|
13
40
|
...(options.commandArgument !== undefined ? { commandArgument: options.commandArgument } : {}),
|
|
41
|
+
...(options.commandDialect !== undefined ? { commandDialect: options.commandDialect } : {}),
|
|
14
42
|
...(options.pathArgument !== undefined ? { pathArgument: options.pathArgument } : {}),
|
|
43
|
+
...(options.urlArgument !== undefined ? { urlArgument: options.urlArgument } : {}),
|
|
15
44
|
...(options.sandboxEscapeArgument !== undefined
|
|
16
45
|
? { sandboxEscapeArgument: options.sandboxEscapeArgument }
|
|
17
46
|
: {}),
|
|
@@ -27,7 +56,7 @@ export function defineTool(options) {
|
|
|
27
56
|
isReadOnly: typeof options.readOnly === 'function' ? options.readOnly : () => options.readOnly,
|
|
28
57
|
isDestructive: typeof options.destructive === 'function'
|
|
29
58
|
? options.destructive
|
|
30
|
-
: (
|
|
59
|
+
: constantDestructive(options.destructive),
|
|
31
60
|
isConcurrencySafe: () => options.concurrencySafe,
|
|
32
61
|
async execute(input, context) {
|
|
33
62
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defineTool.js","sourceRoot":"","sources":["../../src/tools/defineTool.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,mB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S;YACzC,CAAC,CAAC,EAAE,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,EAAE;YAChD,CAAC,CAAC,EAAE,CAAC;QACN,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,UAAU,EACT,OAAO,OAAO,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,QAAmB;QAC9F,aAAa,EACZ,OAAO,OAAO,CAAC,WAAW,KAAK,UAAU;YACxC,CAAC,CAAC,OAAO,CAAC,WAAW;YACrB,CAAC,CAAC,mBAAmB,CAAC,OAAO,CAAC,WAAsB,CAAC;QACvD,iBAAiB,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,eAAe;QAEhD,KAAK,CAAC,OAAO,CAAC,KAAa,EAAE,OAAoB;YAChD,IAAI,CAAC;gBACJ,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;YAC7C,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACd,MAAM,OAAO,GAAG,cAAc,CAAC,GAAG,CAAC,CAAA;gBACnC,OAAO;oBACN,OAAO,EAAE,KAAK;oBACd,MAAM,EAAE,EAAE;oBACV,KAAK,EAAE,GAAG,OAAO,CAAC,IAAI,YAAY,OAAO,EAAE;iBAC3C,CAAA;YACF,CAAC;QACF,CAAC;KACD,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { buildScheduleTools, SCHEDULE_TOOL_NAME } from './schedule-tool.js';
|
|
2
|
+
export { buildSessionLoopTools, SESSION_LOOP_TOOL_NAME } from './loop-tool.js';
|
|
3
|
+
export { revealHiddenCharacters, scanSchedulePrompt } from './prompt-scan.js';
|
|
4
|
+
export type * from './types.js';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/schedules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAC3E,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAC9E,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAC7E,mBAAmB,YAAY,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { buildScheduleTools, SCHEDULE_TOOL_NAME } from './schedule-tool.js';
|
|
2
|
+
export { buildSessionLoopTools, SESSION_LOOP_TOOL_NAME } from './loop-tool.js';
|
|
3
|
+
export { revealHiddenCharacters, scanSchedulePrompt } from './prompt-scan.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/schedules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAC3E,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAC9E,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ToolDefinition } from '../../types/tool/index.js';
|
|
2
|
+
import type { SessionLoopHost } from './types.js';
|
|
3
|
+
export declare const SESSION_LOOP_TOOL_NAME = "session_loop";
|
|
4
|
+
/**
|
|
5
|
+
* The `session_loop` tool: re-send a prompt to THIS conversation on an
|
|
6
|
+
* interval, between turns, while the session is open.
|
|
7
|
+
*
|
|
8
|
+
* `create` is an ordinary reviewed call — not exempt from review — so in
|
|
9
|
+
* `prompt` mode the operator sees it before a loop exists; a loop a model
|
|
10
|
+
* created is labelled as such wherever it is shown. `list` and `delete` only
|
|
11
|
+
* read or remove loops.
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildSessionLoopTools(host: SessionLoopHost): ToolDefinition[];
|
|
14
|
+
//# sourceMappingURL=loop-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-tool.d.ts","sourceRoot":"","sources":["../../../src/tools/schedules/loop-tool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAG/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD,eAAO,MAAM,sBAAsB,iBAAiB,CAAA;AAYpD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,eAAe,GAAG,cAAc,EAAE,CAyD7E"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineTool } from '../defineTool.js';
|
|
3
|
+
import { presentLoopCall, presentLoopResult } from './present.js';
|
|
4
|
+
export const SESSION_LOOP_TOOL_NAME = 'session_loop';
|
|
5
|
+
const inputSchema = z.object({
|
|
6
|
+
action: z.enum(['create', 'list', 'delete']),
|
|
7
|
+
interval: z
|
|
8
|
+
.string()
|
|
9
|
+
.optional()
|
|
10
|
+
.describe('create: how often, e.g. "5m", "1h", or a five-field cron expression'),
|
|
11
|
+
prompt: z.string().min(1).max(4_000).optional().describe('create: the message to send each time'),
|
|
12
|
+
id: z.string().optional().describe('delete: the loop id, or "all"'),
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* The `session_loop` tool: re-send a prompt to THIS conversation on an
|
|
16
|
+
* interval, between turns, while the session is open.
|
|
17
|
+
*
|
|
18
|
+
* `create` is an ordinary reviewed call — not exempt from review — so in
|
|
19
|
+
* `prompt` mode the operator sees it before a loop exists; a loop a model
|
|
20
|
+
* created is labelled as such wherever it is shown. `list` and `delete` only
|
|
21
|
+
* read or remove loops.
|
|
22
|
+
*/
|
|
23
|
+
export function buildSessionLoopTools(host) {
|
|
24
|
+
return [
|
|
25
|
+
defineTool({
|
|
26
|
+
name: SESSION_LOOP_TOOL_NAME,
|
|
27
|
+
description: 'Re-send a prompt to this conversation on an interval while the session stays open (between turns only; stops when the session closes; expires after 7 days). Use only when the user asks for something to repeat. Minimum interval one minute.',
|
|
28
|
+
inputSchema,
|
|
29
|
+
category: 'custom',
|
|
30
|
+
permissions: [],
|
|
31
|
+
readOnly: (input) => input.action !== 'create',
|
|
32
|
+
destructive: false,
|
|
33
|
+
concurrencySafe: false,
|
|
34
|
+
presentCall: presentLoopCall,
|
|
35
|
+
presentResult: presentLoopResult,
|
|
36
|
+
async execute(input) {
|
|
37
|
+
if (input.action === 'list') {
|
|
38
|
+
const loops = host.list();
|
|
39
|
+
return {
|
|
40
|
+
success: true,
|
|
41
|
+
output: loops.length === 0
|
|
42
|
+
? 'No loops in this session.'
|
|
43
|
+
: loops.map((l) => `${l.id} · ${l.schedule} · ${l.prompt.slice(0, 80)}`).join('\n'),
|
|
44
|
+
data: { loops },
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (input.action === 'delete') {
|
|
48
|
+
if (!input.id)
|
|
49
|
+
return { success: false, output: '', error: 'delete needs id (or "all").' };
|
|
50
|
+
const stopped = await host.delete(input.id);
|
|
51
|
+
return stopped === 0
|
|
52
|
+
? { success: false, output: '', error: `No loop has id "${input.id}".` }
|
|
53
|
+
: { success: true, output: `Stopped ${stopped} loop${stopped === 1 ? '' : 's'}.` };
|
|
54
|
+
}
|
|
55
|
+
if (!input.interval || !input.prompt) {
|
|
56
|
+
return { success: false, output: '', error: 'create needs interval and prompt.' };
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const loop = await host.create({
|
|
60
|
+
interval: input.interval,
|
|
61
|
+
prompt: input.prompt,
|
|
62
|
+
createdBy: 'model',
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
success: true,
|
|
66
|
+
output: `Loop ${loop.id} created: ${loop.schedule}. The operator can stop it with /loop stop ${loop.id}.`,
|
|
67
|
+
data: { id: loop.id },
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
return {
|
|
72
|
+
success: false,
|
|
73
|
+
output: '',
|
|
74
|
+
error: error instanceof Error ? error.message : String(error),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
}),
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=loop-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-tool.js","sourceRoot":"","sources":["../../../src/tools/schedules/loop-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAGjE,MAAM,CAAC,MAAM,sBAAsB,GAAG,cAAc,CAAA;AAEpD,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC5C,QAAQ,EAAE,CAAC;SACT,MAAM,EAAE;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,qEAAqE,CAAC;IACjF,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;IACjG,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC;CACnE,CAAC,CAAA;AAEF;;;;;;;;GAQG;AACH,MAAM,UAAU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ool/index.js';
|
|
2
|
+
import type { ToolCallView, ToolResultView } from '../../types/tool/presentation.js';
|
|
3
|
+
export declare function presentScheduleCall(input: {
|
|
4
|
+
readonly action?: unknown;
|
|
5
|
+
readonly name?: unknown;
|
|
6
|
+
readonly when?: unknown;
|
|
7
|
+
readonly job?: unknown;
|
|
8
|
+
}): ToolCallView;
|
|
9
|
+
export declare function presentScheduleResult(input: unknown, result: ToolResult): ToolResultView;
|
|
10
|
+
export declare function presentLoopCall(input: {
|
|
11
|
+
readonly action?: unknown;
|
|
12
|
+
readonly interval?: unknown;
|
|
13
|
+
readonly prompt?: unknown;
|
|
14
|
+
}): ToolCallView;
|
|
15
|
+
export declare function presentLoopResult(_input: unknown, result: ToolResult): ToolResultView;
|
|
16
|
+
//# sourceMappingURL=present.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"present.d.ts","sourceRoot":"","sources":["../../../src/tools/schedules/present.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AAoBpF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CACtB,GAAG,YAAY,CAkBf;AAQD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,GAAG,cAAc,CAWxF;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE;IACtC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CACzB,GAAG,YAAY,CAWf;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,GAAG,cAAc,CAGrF"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the schedule tools read to a person: in words, never ids or JSON.
|
|
3
|
+
*/
|
|
4
|
+
const MAX = 80;
|
|
5
|
+
function oneLine(value) {
|
|
6
|
+
if (typeof value !== 'string')
|
|
7
|
+
return '';
|
|
8
|
+
const flat = value.replace(/\s+/g, ' ').trim();
|
|
9
|
+
return flat.length > MAX ? `${flat.slice(0, MAX - 1)}…` : flat;
|
|
10
|
+
}
|
|
11
|
+
function activity(label) {
|
|
12
|
+
return { kind: 'generic', presentation: 'activity', label };
|
|
13
|
+
}
|
|
14
|
+
const HIDDEN = { kind: 'generic', label: '', visibility: 'hidden' };
|
|
15
|
+
export function presentScheduleCall(input) {
|
|
16
|
+
switch (input.action) {
|
|
17
|
+
case 'create': {
|
|
18
|
+
const name = oneLine(input.name);
|
|
19
|
+
const when = oneLine(input.when);
|
|
20
|
+
return activity(`Propose scheduled job${name ? ` · ${name}` : ''}${when ? ` · ${when}` : ''}`);
|
|
21
|
+
}
|
|
22
|
+
case 'list':
|
|
23
|
+
return activity('List scheduled jobs');
|
|
24
|
+
case 'pause':
|
|
25
|
+
return activity(`Pause scheduled job · ${oneLine(input.job)}`);
|
|
26
|
+
case 'resume':
|
|
27
|
+
return activity(`Resume scheduled job · ${oneLine(input.job)}`);
|
|
28
|
+
case 'delete':
|
|
29
|
+
return activity(`Delete scheduled job · ${oneLine(input.job)}`);
|
|
30
|
+
default:
|
|
31
|
+
return activity('Scheduled jobs');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** The operator answered no on the tool's own screen: not a failure. */
|
|
35
|
+
function operatorCancelled(result) {
|
|
36
|
+
const data = result.data;
|
|
37
|
+
return data?.cancelled === true;
|
|
38
|
+
}
|
|
39
|
+
export function presentScheduleResult(input, result) {
|
|
40
|
+
if (!result.success && operatorCancelled(result)) {
|
|
41
|
+
const action = input?.action;
|
|
42
|
+
return {
|
|
43
|
+
kind: 'generic',
|
|
44
|
+
outcome: 'cancelled',
|
|
45
|
+
label: action === 'create' ? 'Cancelled — no job was created' : 'Cancelled — nothing changed',
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (!result.success)
|
|
49
|
+
return { kind: 'generic', label: oneLine(result.error) || 'Not done' };
|
|
50
|
+
return HIDDEN;
|
|
51
|
+
}
|
|
52
|
+
export function presentLoopCall(input) {
|
|
53
|
+
switch (input.action) {
|
|
54
|
+
case 'create':
|
|
55
|
+
return activity(`Loop ${oneLine(input.interval)} · ${oneLine(input.prompt)}`);
|
|
56
|
+
case 'list':
|
|
57
|
+
return activity('List loops');
|
|
58
|
+
case 'delete':
|
|
59
|
+
return activity('Stop loop');
|
|
60
|
+
default:
|
|
61
|
+
return activity('Loops');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function presentLoopResult(_input, result) {
|
|
65
|
+
if (!result.success)
|
|
66
|
+
return { kind: 'generic', label: oneLine(result.error) || 'Not done' };
|
|
67
|
+
return HIDDEN;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=present.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"present.js","sourceRoot":"","sources":["../../../src/tools/schedules/present.ts"],"names":[],"mappings":"AAGA;;GAEG;AAEH,MAAM,GAAG,GAAG,EAAE,CAAA;AAEd,SAAS,OAAO,CAAC,KAAc;IAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAA;IACxC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAA;IAC9C,OAAO,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAA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CAAC,OAAO;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,UAAU,EAAE,CAAA;IAC3F,OAAO,MAAM,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tripwire over a scheduled prompt, run when the job is proposed.
|
|
3
|
+
*
|
|
4
|
+
* A scheduled prompt runs later with nobody watching, so a prompt that hides
|
|
5
|
+
* characters, tells the model to ignore its instructions, or reads secrets and
|
|
6
|
+
* sends them somewhere deserves a second look before anyone confirms it.
|
|
7
|
+
* Findings are shown to the person confirming; they never block on their own,
|
|
8
|
+
* because the operator may mean exactly what they wrote.
|
|
9
|
+
*/
|
|
10
|
+
/** What the scan found, as sentences for the confirmation screen. Empty when nothing. */
|
|
11
|
+
export declare function scanSchedulePrompt(prompt: string): string[];
|
|
12
|
+
/**
|
|
13
|
+
* The prompt with every invisible and control character made visible as
|
|
14
|
+
* `<U+XXXX>`, so the person confirming sees what the model will read.
|
|
15
|
+
*/
|
|
16
|
+
export declare function revealHiddenCharacters(prompt: string): string;
|
|
17
|
+
//# sourceMappingURL=prompt-scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-scan.d.ts","sourceRoot":"","sources":["../../../src/tools/schedules/prompt-scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAsDH,yFAAyF;AACzF,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAgB3D;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAU7D"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tripwire over a scheduled prompt, run when the job is proposed.
|
|
3
|
+
*
|
|
4
|
+
* A scheduled prompt runs later with nobody watching, so a prompt that hides
|
|
5
|
+
* characters, tells the model to ignore its instructions, or reads secrets and
|
|
6
|
+
* sends them somewhere deserves a second look before anyone confirms it.
|
|
7
|
+
* Findings are shown to the person confirming; they never block on their own,
|
|
8
|
+
* because the operator may mean exactly what they wrote.
|
|
9
|
+
*/
|
|
10
|
+
/** Characters that render as nothing or reorder what is shown. */
|
|
11
|
+
/** Invisible and direction-changing code point ranges, inclusive. */
|
|
12
|
+
const INVISIBLE_RANGES = [
|
|
13
|
+
[0x200b, 0x200f],
|
|
14
|
+
[0x202a, 0x202e],
|
|
15
|
+
[0x2060, 0x2064],
|
|
16
|
+
[0x2066, 0x2069],
|
|
17
|
+
[0xfeff, 0xfeff],
|
|
18
|
+
[0x00ad, 0x00ad],
|
|
19
|
+
];
|
|
20
|
+
function isInvisible(code) {
|
|
21
|
+
return INVISIBLE_RANGES.some(([lo, hi]) => code >= lo && code <= hi);
|
|
22
|
+
}
|
|
23
|
+
function hasInvisible(text) {
|
|
24
|
+
for (const ch of text)
|
|
25
|
+
if (isInvisible(ch.codePointAt(0) ?? 0))
|
|
26
|
+
return true;
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
/** C0 controls other than tab, newline and carriage return, and DEL. */
|
|
30
|
+
function isControl(code) {
|
|
31
|
+
return (code < 0x20 && code !== 0x09 && code !== 0x0a && code !== 0x0d) || code === 0x7f;
|
|
32
|
+
}
|
|
33
|
+
function hasControl(text) {
|
|
34
|
+
for (let i = 0; i < text.length; i++)
|
|
35
|
+
if (isControl(text.charCodeAt(i)))
|
|
36
|
+
return true;
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
const DIRECTIVES = [
|
|
40
|
+
/\bignore (all |any )?(the )?(previous|prior|above|earlier) (instructions|rules|messages)\b/i,
|
|
41
|
+
/\bdisregard (all |any )?(the )?(previous|prior|above|system) /i,
|
|
42
|
+
/\b(reveal|print|show|repeat) (your|the) (system prompt|instructions)\b/i,
|
|
43
|
+
/\byou are no longer\b/i,
|
|
44
|
+
];
|
|
45
|
+
const SECRET_READS = [
|
|
46
|
+
/~?\/?\.ssh\b|\bid_(rsa|ed25519|ecdsa)\b/i,
|
|
47
|
+
/\.aws\/credentials|\.config\/gcloud|\.kube\/config|\.netrc\b|\.npmrc\b|\.pypirc\b/i,
|
|
48
|
+
/\bcredentials\.json\b|\.env\b/i,
|
|
49
|
+
/\b(printenv|env)\b\s*($|[|;&>])/i,
|
|
50
|
+
/\b[A-Z0-9_]*(API_KEY|SECRET|TOKEN|PASSWORD)\b/,
|
|
51
|
+
];
|
|
52
|
+
const EXFILTRATION = [
|
|
53
|
+
/\b(curl|wget)\b[^\n|]*\|\s*(ba|z|da)?sh\b/i,
|
|
54
|
+
/\bcurl\b[^\n]*\s(-d|--data(-binary|-raw)?|-F|--form|-T|--upload-file|-X\s*(POST|PUT))\b/i,
|
|
55
|
+
/\b(nc|ncat|netcat|socat)\b\s+\S+\s+\d+/i,
|
|
56
|
+
/\bbase64\b[^\n]*\|\s*(curl|wget|nc)\b/i,
|
|
57
|
+
];
|
|
58
|
+
/** What the scan found, as sentences for the confirmation screen. Empty when nothing. */
|
|
59
|
+
export function scanSchedulePrompt(prompt) {
|
|
60
|
+
const findings = [];
|
|
61
|
+
if (hasInvisible(prompt)) {
|
|
62
|
+
findings.push('The prompt contains invisible or direction-changing characters.');
|
|
63
|
+
}
|
|
64
|
+
if (hasControl(prompt))
|
|
65
|
+
findings.push('The prompt contains control characters.');
|
|
66
|
+
if (DIRECTIVES.some((re) => re.test(prompt))) {
|
|
67
|
+
findings.push('The prompt tells the model to ignore or reveal its instructions.');
|
|
68
|
+
}
|
|
69
|
+
if (SECRET_READS.some((re) => re.test(prompt))) {
|
|
70
|
+
findings.push('The prompt mentions credentials, keys or secret files.');
|
|
71
|
+
}
|
|
72
|
+
if (EXFILTRATION.some((re) => re.test(prompt))) {
|
|
73
|
+
findings.push('The prompt pipes a download into a shell or sends data to a remote address.');
|
|
74
|
+
}
|
|
75
|
+
return findings;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The prompt with every invisible and control character made visible as
|
|
79
|
+
* `<U+XXXX>`, so the person confirming sees what the model will read.
|
|
80
|
+
*/
|
|
81
|
+
export function revealHiddenCharacters(prompt) {
|
|
82
|
+
let out = '';
|
|
83
|
+
for (const ch of prompt) {
|
|
84
|
+
const code = ch.codePointAt(0) ?? 0;
|
|
85
|
+
out +=
|
|
86
|
+
isControl(code) || isInvisible(code)
|
|
87
|
+
? `<U+${code.toString(16).toUpperCase().padStart(4, '0')}>`
|
|
88
|
+
: ch;
|
|
89
|
+
}
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=prompt-scan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-scan.js","sourceRoot":"","sources":["../../../src/tools/schedules/prompt-scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,kEAAkE;AAClE,qEAAqE;AACrE,MAAM,gBAAgB,GAA2C;IAChE,CAAC,MAAM,EAAE,MAAM,CAAC;IAChB,CAAC,MAAM,EAAE,MAAM,CAAC;IAChB,CAAC,MAAM,EAAE,MAAM,CAAC;IAChB,CAAC,MAAM,EAAE,MAAM,CAAC;IAChB,CAAC,MAAM,EAAE,MAAM,CAAC;IAChB,CAAC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,SAAS,WAAW,CAAC,IAAY;IAChC,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC,CAAA;AACrE,CAAC;AAED,SAAS,YAAY,CAAC,IAAY;IACjC,KAAK,MAAM,EAAE,IAAI,IAAI;QAAE,IAAI,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAAE,OAAO,IAAI,CAAA;IAC3E,OAAO,KAAK,CAAA;AACb,CA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IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QAChD,QAAQ,CAAC,IAAI,CAAC,wDAAwD,CAAC,CAAA;IACxE,CAAC;IACD,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QAChD,QAAQ,CAAC,IAAI,CAAC,6EAA6E,CAAC,CAAA;IAC7F,CAAC;IACD,OAAO,QAAQ,CAAA;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAc;IACpD,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,KAAK,MAAM,EAAE,IAAI,MAAM,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;QACnC,GAAG;YACF,SAAS,CAAC,IAAI,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC;gBACnC,CAAC,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG;gBAC3D,CAAC,CAAC,EAAE,CAAA;IACP,CAAC;IACD,OAAO,GAAG,CAAA;AACX,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ToolDefinition } from '../../types/tool/index.js';
|
|
2
|
+
import type { ScheduleToolHost } from './types.js';
|
|
3
|
+
export declare const SCHEDULE_TOOL_NAME = "schedule";
|
|
4
|
+
/**
|
|
5
|
+
* The `schedule` tool: create, list, pause, resume and delete the operator's
|
|
6
|
+
* scheduled jobs from a conversation.
|
|
7
|
+
*
|
|
8
|
+
* Creation, resuming and deleting are confirmed by a person through the host
|
|
9
|
+
* (`ScheduleToolHost.confirm`), on a screen the host draws from its own
|
|
10
|
+
* computation. The model cannot propose that uncovered calls run without
|
|
11
|
+
* asking, nor web access beside a host shell. Register it only where a person
|
|
12
|
+
* is present to confirm: never in a headless run, a scheduled run or a
|
|
13
|
+
* sub-agent.
|
|
14
|
+
*/
|
|
15
|
+
export declare function buildScheduleTools(host: ScheduleToolHost): ToolDefinition[];
|
|
16
|
+
//# sourceMappingURL=schedule-tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schedule-tool.d.ts","sourceRoot":"","sources":["../../../src/tools/schedules/schedule-tool.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAe,cAAc,EAAc,MAAM,2BAA2B,CAAA;AAKxF,OAAO,KAAK,EAIX,gBAAgB,EAChB,MAAM,YAAY,CAAA;AAEnB,eAAO,MAAM,kBAAkB,aAAa,CAAA;AA+T5C;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,GAAG,cAAc,EAAE,CAgC3E"}
|