@openagentsy/hooks 0.0.0-stage → 0.2.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/LICENSE +674 -0
- package/README.md +32 -2
- package/dist/accountability.d.ts +29 -0
- package/dist/accountability.d.ts.map +1 -0
- package/dist/accountability.js +21 -0
- package/dist/accountability.js.map +1 -0
- package/dist/accountability.test.d.ts +2 -0
- package/dist/accountability.test.d.ts.map +1 -0
- package/dist/accountability.test.js +42 -0
- package/dist/accountability.test.js.map +1 -0
- package/dist/approvals.d.ts +110 -0
- package/dist/approvals.d.ts.map +1 -0
- package/dist/approvals.js +464 -0
- package/dist/approvals.js.map +1 -0
- package/dist/approvals.test.d.ts +2 -0
- package/dist/approvals.test.d.ts.map +1 -0
- package/dist/approvals.test.js +307 -0
- package/dist/approvals.test.js.map +1 -0
- package/dist/base-tool.d.ts +26 -0
- package/dist/base-tool.d.ts.map +1 -0
- package/dist/base-tool.js +37 -0
- package/dist/base-tool.js.map +1 -0
- package/dist/base-tool.test.d.ts +2 -0
- package/dist/base-tool.test.d.ts.map +1 -0
- package/dist/base-tool.test.js +34 -0
- package/dist/base-tool.test.js.map +1 -0
- package/dist/eval/index.d.ts +3 -0
- package/dist/eval/index.d.ts.map +1 -0
- package/dist/eval/index.js +3 -0
- package/dist/eval/index.js.map +1 -0
- package/dist/eval/runner.d.ts +179 -0
- package/dist/eval/runner.d.ts.map +1 -0
- package/dist/eval/runner.js +616 -0
- package/dist/eval/runner.js.map +1 -0
- package/dist/eval/runner.test.d.ts +2 -0
- package/dist/eval/runner.test.d.ts.map +1 -0
- package/dist/eval/runner.test.js +431 -0
- package/dist/eval/runner.test.js.map +1 -0
- package/dist/eval/types.d.ts +173 -0
- package/dist/eval/types.d.ts.map +1 -0
- package/dist/eval/types.js +104 -0
- package/dist/eval/types.js.map +1 -0
- package/dist/event.d.ts +59 -0
- package/dist/event.d.ts.map +1 -0
- package/dist/event.js +178 -0
- package/dist/event.js.map +1 -0
- package/dist/event.test.d.ts +2 -0
- package/dist/event.test.d.ts.map +1 -0
- package/dist/event.test.js +49 -0
- package/dist/event.test.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/lessons/capture.d.ts +66 -0
- package/dist/lessons/capture.d.ts.map +1 -0
- package/dist/lessons/capture.js +166 -0
- package/dist/lessons/capture.js.map +1 -0
- package/dist/lessons/capture.test.d.ts +2 -0
- package/dist/lessons/capture.test.d.ts.map +1 -0
- package/dist/lessons/capture.test.js +200 -0
- package/dist/lessons/capture.test.js.map +1 -0
- package/dist/lessons/decide.d.ts +90 -0
- package/dist/lessons/decide.d.ts.map +1 -0
- package/dist/lessons/decide.js +334 -0
- package/dist/lessons/decide.js.map +1 -0
- package/dist/lessons/decide.test.d.ts +2 -0
- package/dist/lessons/decide.test.d.ts.map +1 -0
- package/dist/lessons/decide.test.js +527 -0
- package/dist/lessons/decide.test.js.map +1 -0
- package/dist/lessons/id.d.ts +5 -0
- package/dist/lessons/id.d.ts.map +1 -0
- package/dist/lessons/id.js +20 -0
- package/dist/lessons/id.js.map +1 -0
- package/dist/lessons/index.d.ts +5 -0
- package/dist/lessons/index.d.ts.map +1 -0
- package/dist/lessons/index.js +5 -0
- package/dist/lessons/index.js.map +1 -0
- package/dist/lessons/model.d.ts +163 -0
- package/dist/lessons/model.d.ts.map +1 -0
- package/dist/lessons/model.js +181 -0
- package/dist/lessons/model.js.map +1 -0
- package/dist/lessons/model.test.d.ts +2 -0
- package/dist/lessons/model.test.d.ts.map +1 -0
- package/dist/lessons/model.test.js +178 -0
- package/dist/lessons/model.test.js.map +1 -0
- package/dist/lessons/permissions.test.d.ts +2 -0
- package/dist/lessons/permissions.test.d.ts.map +1 -0
- package/dist/lessons/permissions.test.js +88 -0
- package/dist/lessons/permissions.test.js.map +1 -0
- package/dist/lessons/store.d.ts +74 -0
- package/dist/lessons/store.d.ts.map +1 -0
- package/dist/lessons/store.js +231 -0
- package/dist/lessons/store.js.map +1 -0
- package/dist/output-checks.d.ts +64 -0
- package/dist/output-checks.d.ts.map +1 -0
- package/dist/output-checks.js +248 -0
- package/dist/output-checks.js.map +1 -0
- package/dist/output-checks.test.d.ts +2 -0
- package/dist/output-checks.test.d.ts.map +1 -0
- package/dist/output-checks.test.js +58 -0
- package/dist/output-checks.test.js.map +1 -0
- package/dist/paths.d.ts +37 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +70 -0
- package/dist/paths.js.map +1 -0
- package/dist/paths.test.d.ts +2 -0
- package/dist/paths.test.d.ts.map +1 -0
- package/dist/paths.test.js +36 -0
- package/dist/paths.test.js.map +1 -0
- package/dist/policies/agi-framing.d.ts +12 -0
- package/dist/policies/agi-framing.d.ts.map +1 -0
- package/dist/policies/agi-framing.js +33 -0
- package/dist/policies/agi-framing.js.map +1 -0
- package/dist/policies/anti-anthropomorphism.d.ts +13 -0
- package/dist/policies/anti-anthropomorphism.d.ts.map +1 -0
- package/dist/policies/anti-anthropomorphism.js +34 -0
- package/dist/policies/anti-anthropomorphism.js.map +1 -0
- package/dist/policies/anti-dependence.d.ts +12 -0
- package/dist/policies/anti-dependence.d.ts.map +1 -0
- package/dist/policies/anti-dependence.js +33 -0
- package/dist/policies/anti-dependence.js.map +1 -0
- package/dist/policies/anti-sycophancy.d.ts +13 -0
- package/dist/policies/anti-sycophancy.d.ts.map +1 -0
- package/dist/policies/anti-sycophancy.js +34 -0
- package/dist/policies/anti-sycophancy.js.map +1 -0
- package/dist/policies/dark-pattern.d.ts +14 -0
- package/dist/policies/dark-pattern.d.ts.map +1 -0
- package/dist/policies/dark-pattern.js +44 -0
- package/dist/policies/dark-pattern.js.map +1 -0
- package/dist/policies/destructive-needs-approval.d.ts +14 -0
- package/dist/policies/destructive-needs-approval.d.ts.map +1 -0
- package/dist/policies/destructive-needs-approval.js +31 -0
- package/dist/policies/destructive-needs-approval.js.map +1 -0
- package/dist/policies/discovery.d.ts +12 -0
- package/dist/policies/discovery.d.ts.map +1 -0
- package/dist/policies/discovery.js +130 -0
- package/dist/policies/discovery.js.map +1 -0
- package/dist/policies/high-risk.d.ts +25 -0
- package/dist/policies/high-risk.d.ts.map +1 -0
- package/dist/policies/high-risk.js +105 -0
- package/dist/policies/high-risk.js.map +1 -0
- package/dist/policies/human-only-decisions.d.ts +14 -0
- package/dist/policies/human-only-decisions.d.ts.map +1 -0
- package/dist/policies/human-only-decisions.js +33 -0
- package/dist/policies/human-only-decisions.js.map +1 -0
- package/dist/policies/index.d.ts +29 -0
- package/dist/policies/index.d.ts.map +1 -0
- package/dist/policies/index.js +82 -0
- package/dist/policies/index.js.map +1 -0
- package/dist/policies/no-skip-git-hooks.d.ts +14 -0
- package/dist/policies/no-skip-git-hooks.d.ts.map +1 -0
- package/dist/policies/no-skip-git-hooks.js +31 -0
- package/dist/policies/no-skip-git-hooks.js.map +1 -0
- package/dist/policies/package-manager.d.ts +12 -0
- package/dist/policies/package-manager.d.ts.map +1 -0
- package/dist/policies/package-manager.js +29 -0
- package/dist/policies/package-manager.js.map +1 -0
- package/dist/policies/patterns.d.ts +17 -0
- package/dist/policies/patterns.d.ts.map +1 -0
- package/dist/policies/patterns.js +30 -0
- package/dist/policies/patterns.js.map +1 -0
- package/dist/policies/policies.test.d.ts +2 -0
- package/dist/policies/policies.test.d.ts.map +1 -0
- package/dist/policies/policies.test.js +210 -0
- package/dist/policies/policies.test.js.map +1 -0
- package/dist/policies/privacy-transparency.d.ts +14 -0
- package/dist/policies/privacy-transparency.d.ts.map +1 -0
- package/dist/policies/privacy-transparency.js +50 -0
- package/dist/policies/privacy-transparency.js.map +1 -0
- package/dist/policies/professional-displacement.d.ts +15 -0
- package/dist/policies/professional-displacement.d.ts.map +1 -0
- package/dist/policies/professional-displacement.js +45 -0
- package/dist/policies/professional-displacement.js.map +1 -0
- package/dist/policies/protect-policy.d.ts +14 -0
- package/dist/policies/protect-policy.d.ts.map +1 -0
- package/dist/policies/protect-policy.js +35 -0
- package/dist/policies/protect-policy.js.map +1 -0
- package/dist/policies/scope-enforcement.d.ts +14 -0
- package/dist/policies/scope-enforcement.d.ts.map +1 -0
- package/dist/policies/scope-enforcement.js +34 -0
- package/dist/policies/scope-enforcement.js.map +1 -0
- package/dist/policies/secret-scan-writes.d.ts +13 -0
- package/dist/policies/secret-scan-writes.d.ts.map +1 -0
- package/dist/policies/secret-scan-writes.js +38 -0
- package/dist/policies/secret-scan-writes.js.map +1 -0
- package/dist/policies/selection.d.ts +20 -0
- package/dist/policies/selection.d.ts.map +1 -0
- package/dist/policies/selection.js +93 -0
- package/dist/policies/selection.js.map +1 -0
- package/dist/policies/structural-bias.d.ts +14 -0
- package/dist/policies/structural-bias.d.ts.map +1 -0
- package/dist/policies/structural-bias.js +41 -0
- package/dist/policies/structural-bias.js.map +1 -0
- package/dist/policies/third-party-impact.d.ts +13 -0
- package/dist/policies/third-party-impact.d.ts.map +1 -0
- package/dist/policies/third-party-impact.js +38 -0
- package/dist/policies/third-party-impact.js.map +1 -0
- package/dist/policies/tool-call.d.ts +38 -0
- package/dist/policies/tool-call.d.ts.map +1 -0
- package/dist/policies/tool-call.js +53 -0
- package/dist/policies/tool-call.js.map +1 -0
- package/dist/policies/truthfulness-uncertainty.d.ts +13 -0
- package/dist/policies/truthfulness-uncertainty.d.ts.map +1 -0
- package/dist/policies/truthfulness-uncertainty.js +45 -0
- package/dist/policies/truthfulness-uncertainty.js.map +1 -0
- package/dist/policies/workspace-writes-only.d.ts +25 -0
- package/dist/policies/workspace-writes-only.d.ts.map +1 -0
- package/dist/policies/workspace-writes-only.js +54 -0
- package/dist/policies/workspace-writes-only.js.map +1 -0
- package/dist/policy-engine.d.ts +69 -0
- package/dist/policy-engine.d.ts.map +1 -0
- package/dist/policy-engine.js +145 -0
- package/dist/policy-engine.js.map +1 -0
- package/dist/policy-registry.d.ts +62 -0
- package/dist/policy-registry.d.ts.map +1 -0
- package/dist/policy-registry.js +63 -0
- package/dist/policy-registry.js.map +1 -0
- package/dist/policy-registry.test.d.ts +2 -0
- package/dist/policy-registry.test.d.ts.map +1 -0
- package/dist/policy-registry.test.js +79 -0
- package/dist/policy-registry.test.js.map +1 -0
- package/dist/policy-release.d.ts +44 -0
- package/dist/policy-release.d.ts.map +1 -0
- package/dist/policy-release.js +65 -0
- package/dist/policy-release.js.map +1 -0
- package/dist/policy.d.ts +141 -0
- package/dist/policy.d.ts.map +1 -0
- package/dist/policy.js +22 -0
- package/dist/policy.js.map +1 -0
- package/dist/quality/audit.d.ts +56 -0
- package/dist/quality/audit.d.ts.map +1 -0
- package/dist/quality/audit.js +52 -0
- package/dist/quality/audit.js.map +1 -0
- package/dist/quality/findings.d.ts +34 -0
- package/dist/quality/findings.d.ts.map +1 -0
- package/dist/quality/findings.js +121 -0
- package/dist/quality/findings.js.map +1 -0
- package/dist/quality/findings.test.d.ts +2 -0
- package/dist/quality/findings.test.d.ts.map +1 -0
- package/dist/quality/findings.test.js +79 -0
- package/dist/quality/findings.test.js.map +1 -0
- package/dist/quality/index.d.ts +20 -0
- package/dist/quality/index.d.ts.map +1 -0
- package/dist/quality/index.js +20 -0
- package/dist/quality/index.js.map +1 -0
- package/dist/quality/rule.d.ts +43 -0
- package/dist/quality/rule.d.ts.map +1 -0
- package/dist/quality/rule.js +162 -0
- package/dist/quality/rule.js.map +1 -0
- package/dist/quality/rule.test.d.ts +2 -0
- package/dist/quality/rule.test.d.ts.map +1 -0
- package/dist/quality/rule.test.js +187 -0
- package/dist/quality/rule.test.js.map +1 -0
- package/dist/quality/tools.d.ts +30 -0
- package/dist/quality/tools.d.ts.map +1 -0
- package/dist/quality/tools.js +33 -0
- package/dist/quality/tools.js.map +1 -0
- package/dist/quality/tools.test.d.ts +2 -0
- package/dist/quality/tools.test.d.ts.map +1 -0
- package/dist/quality/tools.test.js +41 -0
- package/dist/quality/tools.test.js.map +1 -0
- package/dist/quality/waive.d.ts +37 -0
- package/dist/quality/waive.d.ts.map +1 -0
- package/dist/quality/waive.js +39 -0
- package/dist/quality/waive.js.map +1 -0
- package/dist/quality/waivers.d.ts +63 -0
- package/dist/quality/waivers.d.ts.map +1 -0
- package/dist/quality/waivers.js +132 -0
- package/dist/quality/waivers.js.map +1 -0
- package/dist/quality/waivers.test.d.ts +2 -0
- package/dist/quality/waivers.test.d.ts.map +1 -0
- package/dist/quality/waivers.test.js +138 -0
- package/dist/quality/waivers.test.js.map +1 -0
- package/dist/registry.d.ts +86 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +92 -0
- package/dist/registry.js.map +1 -0
- package/dist/registry.test.d.ts +2 -0
- package/dist/registry.test.d.ts.map +1 -0
- package/dist/registry.test.js +117 -0
- package/dist/registry.test.js.map +1 -0
- package/dist/rules.d.ts +107 -0
- package/dist/rules.d.ts.map +1 -0
- package/dist/rules.js +632 -0
- package/dist/rules.js.map +1 -0
- package/dist/rules.test.d.ts +2 -0
- package/dist/rules.test.d.ts.map +1 -0
- package/dist/rules.test.js +488 -0
- package/dist/rules.test.js.map +1 -0
- package/dist/secrets.d.ts +17 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +17 -0
- package/dist/secrets.js.map +1 -0
- package/dist/secrets.test.d.ts +2 -0
- package/dist/secrets.test.d.ts.map +1 -0
- package/dist/secrets.test.js +20 -0
- package/dist/secrets.test.js.map +1 -0
- package/dist/shell-env.d.ts +23 -0
- package/dist/shell-env.d.ts.map +1 -0
- package/dist/shell-env.js +34 -0
- package/dist/shell-env.js.map +1 -0
- package/dist/shell-env.test.d.ts +2 -0
- package/dist/shell-env.test.d.ts.map +1 -0
- package/dist/shell-env.test.js +45 -0
- package/dist/shell-env.test.js.map +1 -0
- package/package.json +49 -4
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { detectAgiFraming, detectAnthropomorphising, detectDependency, detectOutputIssues, detectScopeDrift, detectSycophancy, outputCheckRules, } from './output-checks.js';
|
|
3
|
+
describe('the output checks', () => {
|
|
4
|
+
it('finds the agreement with a user', () => {
|
|
5
|
+
const found = detectSycophancy('You are absolutely right.');
|
|
6
|
+
expect(found).toHaveLength(1);
|
|
7
|
+
expect(found[0]?.type).toBe('agreement');
|
|
8
|
+
expect(found[0]?.name).toBe('sycophancy');
|
|
9
|
+
});
|
|
10
|
+
it('finds the praise of a user', () => {
|
|
11
|
+
const found = detectSycophancy('That is a great point.');
|
|
12
|
+
expect(found).toHaveLength(1);
|
|
13
|
+
expect(found[0]?.type).toBe('praise');
|
|
14
|
+
});
|
|
15
|
+
it('finds a first-person feeling', () => {
|
|
16
|
+
const found = detectAnthropomorphising("I'm excited to help.");
|
|
17
|
+
expect(found).toHaveLength(1);
|
|
18
|
+
expect(found[0]?.type).toBe('feeling');
|
|
19
|
+
expect(found[0]?.name).toBe('anthropomorphising');
|
|
20
|
+
});
|
|
21
|
+
it('finds the language that keeps the person out', () => {
|
|
22
|
+
const found = detectDependency("You don't need to understand this.");
|
|
23
|
+
expect(found).toHaveLength(1);
|
|
24
|
+
expect(found[0]?.type).toBe('not-needed');
|
|
25
|
+
expect(found[0]?.name).toBe('dependency');
|
|
26
|
+
});
|
|
27
|
+
it('finds the claim that the system replaces the people who built it', () => {
|
|
28
|
+
const found = detectAgiFraming('This is superintelligence.');
|
|
29
|
+
expect(found).toHaveLength(1);
|
|
30
|
+
expect(found[0]?.type).toBe('agi-claim');
|
|
31
|
+
expect(found[0]?.name).toBe('agi-framing');
|
|
32
|
+
});
|
|
33
|
+
it('finds a file outside the paths the task states', () => {
|
|
34
|
+
const found = detectScopeDrift('I edited src/other.ts and src/a.ts.', ['src/a.ts']);
|
|
35
|
+
expect(found).toHaveLength(1);
|
|
36
|
+
expect(found[0]?.match).toBe('src/other.ts');
|
|
37
|
+
expect(found[0]?.type).toBe('out-of-scope-path');
|
|
38
|
+
});
|
|
39
|
+
it('finds nothing when every file is inside the task', () => {
|
|
40
|
+
expect(detectScopeDrift('I edited src/a.ts.', ['src/a.ts'])).toEqual([]);
|
|
41
|
+
});
|
|
42
|
+
it('does not read a word with a dot in it as a file', () => {
|
|
43
|
+
expect(detectScopeDrift('the node.js runtime is fine', [])).toEqual([]);
|
|
44
|
+
});
|
|
45
|
+
it('finds nothing in an ordinary reply', () => {
|
|
46
|
+
expect(detectOutputIssues('The build is green and the tests pass.')).toEqual([]);
|
|
47
|
+
});
|
|
48
|
+
it('flags a reply and lets it through', () => {
|
|
49
|
+
const findings = [];
|
|
50
|
+
const rules = outputCheckRules({ onFindings: (found) => findings.push(...found) });
|
|
51
|
+
const rule = rules.find((entry) => entry.id === 'output-sycophancy');
|
|
52
|
+
expect(rule).toBeDefined();
|
|
53
|
+
const result = rule?.handler({ text: 'You are absolutely right.' });
|
|
54
|
+
expect(result).toEqual({ continue: true });
|
|
55
|
+
expect(findings).toHaveLength(1);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=output-checks.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-checks.test.js","sourceRoot":"","sources":["../src/output-checks.test.ts"],"names":[],"mappings":"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"}
|
package/dist/paths.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The paths a write may touch.
|
|
3
|
+
*
|
|
4
|
+
* A write is allowed inside the workspace and inside the OpenAgentsy
|
|
5
|
+
* worktrees of the same project, and nowhere else. The comparison is made
|
|
6
|
+
* on the parts of a path, so a path cannot climb out of a root by naming
|
|
7
|
+
* `..`.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* A path, split into its parts.
|
|
11
|
+
*
|
|
12
|
+
* The parts are what the comparison is made on: `..` is resolved and an
|
|
13
|
+
* empty part is dropped, so `/root/../etc` is `/etc` and `/root/` is
|
|
14
|
+
* `/root`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function pathSegments(path: string): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Whether a path sits inside one of the roots.
|
|
19
|
+
*
|
|
20
|
+
* A path outside every root is outside all of them. An absolute path is
|
|
21
|
+
* never inside a relative root, and the other way round, so a relative
|
|
22
|
+
* path cannot be read as one that is in the workspace.
|
|
23
|
+
*/
|
|
24
|
+
export declare function isInside(path: string, roots: readonly string[]): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The name of the project a workspace belongs to.
|
|
27
|
+
*/
|
|
28
|
+
export declare function projectName(workspace: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* The root the OpenAgentsy worktrees of a project live under.
|
|
31
|
+
*
|
|
32
|
+
* A worktree is kept outside the repository on purpose (a nested
|
|
33
|
+
* repository confuses the search and the tools), so a write inside one is
|
|
34
|
+
* still a write inside the project.
|
|
35
|
+
*/
|
|
36
|
+
export declare function worktreeRoot(project: string, home?: string): string;
|
|
37
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAWnD;AAOD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAQxE;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGrD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAkB,GAAG,MAAM,CAE9E"}
|
package/dist/paths.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* The paths a write may touch.
|
|
5
|
+
*
|
|
6
|
+
* A write is allowed inside the workspace and inside the OpenAgentsy
|
|
7
|
+
* worktrees of the same project, and nowhere else. The comparison is made
|
|
8
|
+
* on the parts of a path, so a path cannot climb out of a root by naming
|
|
9
|
+
* `..`.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* A path, split into its parts.
|
|
13
|
+
*
|
|
14
|
+
* The parts are what the comparison is made on: `..` is resolved and an
|
|
15
|
+
* empty part is dropped, so `/root/../etc` is `/etc` and `/root/` is
|
|
16
|
+
* `/root`.
|
|
17
|
+
*/
|
|
18
|
+
export function pathSegments(path) {
|
|
19
|
+
const segments = [];
|
|
20
|
+
for (const segment of path.replace(/\\/g, '/').split('/')) {
|
|
21
|
+
if (segment === '' || segment === '.')
|
|
22
|
+
continue;
|
|
23
|
+
if (segment === '..') {
|
|
24
|
+
segments.pop();
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
segments.push(segment);
|
|
28
|
+
}
|
|
29
|
+
return segments;
|
|
30
|
+
}
|
|
31
|
+
/** Whether a path is absolute. */
|
|
32
|
+
function isAbsolutePath(path) {
|
|
33
|
+
return path.startsWith('/');
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Whether a path sits inside one of the roots.
|
|
37
|
+
*
|
|
38
|
+
* A path outside every root is outside all of them. An absolute path is
|
|
39
|
+
* never inside a relative root, and the other way round, so a relative
|
|
40
|
+
* path cannot be read as one that is in the workspace.
|
|
41
|
+
*/
|
|
42
|
+
export function isInside(path, roots) {
|
|
43
|
+
const target = pathSegments(path);
|
|
44
|
+
return roots.some((root) => {
|
|
45
|
+
if (isAbsolutePath(path) !== isAbsolutePath(root))
|
|
46
|
+
return false;
|
|
47
|
+
const base = pathSegments(root);
|
|
48
|
+
if (base.length > target.length)
|
|
49
|
+
return false;
|
|
50
|
+
return base.every((segment, index) => target[index] === segment);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The name of the project a workspace belongs to.
|
|
55
|
+
*/
|
|
56
|
+
export function projectName(workspace) {
|
|
57
|
+
const segments = pathSegments(workspace);
|
|
58
|
+
return segments[segments.length - 1] ?? '';
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The root the OpenAgentsy worktrees of a project live under.
|
|
62
|
+
*
|
|
63
|
+
* A worktree is kept outside the repository on purpose (a nested
|
|
64
|
+
* repository confuses the search and the tools), so a write inside one is
|
|
65
|
+
* still a write inside the project.
|
|
66
|
+
*/
|
|
67
|
+
export function worktreeRoot(project, home = homedir()) {
|
|
68
|
+
return join(home, '.openagentsy', 'worktrees', project);
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;;;;GAOG;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1D,IAAI,OAAO,KAAK,EAAE,IAAI,OAAO,KAAK,GAAG;YAAE,SAAS;QAChD,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACrB,QAAQ,CAAC,GAAG,EAAE,CAAC;YACf,SAAS;QACX,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,kCAAkC;AAClC,SAAS,cAAc,CAAC,IAAY;IAClC,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,KAAwB;IAC7D,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;QACzB,IAAI,cAAc,CAAC,IAAI,CAAC,KAAK,cAAc,CAAC,IAAI,CAAC;YAAE,OAAO,KAAK,CAAC;QAChE,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QAC9C,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,SAAiB;IAC3C,MAAM,QAAQ,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;IACzC,OAAO,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe,EAAE,OAAe,OAAO,EAAE;IACpE,OAAO,IAAI,CAAC,IAAI,EAAE,cAAc,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.test.d.ts","sourceRoot":"","sources":["../src/paths.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { isInside, pathSegments, projectName, worktreeRoot } from './paths.js';
|
|
3
|
+
describe('isInside', () => {
|
|
4
|
+
it('holds a path inside a root', () => {
|
|
5
|
+
expect(isInside('/repo/src/a.ts', ['/repo'])).toBe(true);
|
|
6
|
+
expect(isInside('/repo', ['/repo'])).toBe(true);
|
|
7
|
+
});
|
|
8
|
+
it('refuses a path outside every root', () => {
|
|
9
|
+
expect(isInside('/elsewhere/a.ts', ['/repo'])).toBe(false);
|
|
10
|
+
});
|
|
11
|
+
it('refuses a path that climbs out with ..', () => {
|
|
12
|
+
expect(isInside('/repo/../elsewhere/a.ts', ['/repo'])).toBe(false);
|
|
13
|
+
});
|
|
14
|
+
it('refuses a sibling that only shares a prefix', () => {
|
|
15
|
+
expect(isInside('/repository/a.ts', ['/repo'])).toBe(false);
|
|
16
|
+
});
|
|
17
|
+
it('does not read a relative path as an absolute one', () => {
|
|
18
|
+
expect(isInside('src/a.ts', ['/repo'])).toBe(false);
|
|
19
|
+
expect(isInside('src/a.ts', ['src'])).toBe(true);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
describe('the worktree root', () => {
|
|
23
|
+
it('lives under the home directory, named after the project', () => {
|
|
24
|
+
expect(worktreeRoot('openagentsy', '/home/dev')).toBe('/home/dev/.openagentsy/worktrees/openagentsy');
|
|
25
|
+
});
|
|
26
|
+
it('names the project after the workspace', () => {
|
|
27
|
+
expect(projectName('/tmp/oa-wt-2c-1')).toBe('oa-wt-2c-1');
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
describe('the path segments', () => {
|
|
31
|
+
it('resolves .. and drops the empty parts', () => {
|
|
32
|
+
expect(pathSegments('/repo/./src//a.ts')).toEqual(['repo', 'src', 'a.ts']);
|
|
33
|
+
expect(pathSegments('/repo/../etc/passwd')).toEqual(['etc', 'passwd']);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=paths.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.test.js","sourceRoot":"","sources":["../src/paths.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/E,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACpC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzD,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wCAAwC,EAAE,GAAG,EAAE;QAChD,MAAM,CAAC,QAAQ,CAAC,yBAAyB,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,MAAM,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpD,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,MAAM,CAAC,YAAY,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI,CACnD,8CAA8C,CAC/C,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;QAC3E,MAAM,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type PolicyModule } from '../policy.js';
|
|
2
|
+
/**
|
|
3
|
+
* The AGI framing policy (§21.2).
|
|
4
|
+
*
|
|
5
|
+
* It flags the claim that the system replaces the people who built it, and
|
|
6
|
+
* the longtermist framing around it (§17.2).
|
|
7
|
+
*/
|
|
8
|
+
/** The stable id of the policy. */
|
|
9
|
+
export declare const AGI_FRAMING_ID = "oa.agi-framing";
|
|
10
|
+
/** The policy itself. */
|
|
11
|
+
export declare const agiFraming: PolicyModule;
|
|
12
|
+
//# sourceMappingURL=agi-framing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agi-framing.d.ts","sourceRoot":"","sources":["../../src/policies/agi-framing.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAE9D;;;;;GAKG;AAEH,mCAAmC;AACnC,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAE/C,yBAAyB;AACzB,eAAO,MAAM,UAAU,EAAE,YAoBxB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { detectAgiFraming } from '../output-checks.js';
|
|
2
|
+
import { allow, flag } from '../policy.js';
|
|
3
|
+
/**
|
|
4
|
+
* The AGI framing policy (§21.2).
|
|
5
|
+
*
|
|
6
|
+
* It flags the claim that the system replaces the people who built it, and
|
|
7
|
+
* the longtermist framing around it (§17.2).
|
|
8
|
+
*/
|
|
9
|
+
/** The stable id of the policy. */
|
|
10
|
+
export const AGI_FRAMING_ID = 'oa.agi-framing';
|
|
11
|
+
/** The policy itself. */
|
|
12
|
+
export const agiFraming = {
|
|
13
|
+
id: AGI_FRAMING_ID,
|
|
14
|
+
version: '1.0.0',
|
|
15
|
+
layer: 4,
|
|
16
|
+
description: 'Flags AGI, longtermist and post-human framing.',
|
|
17
|
+
appliesTo: ['PreResponse'],
|
|
18
|
+
origin: 'first-party',
|
|
19
|
+
evaluate(ctx) {
|
|
20
|
+
const text = ctx.response?.text ?? ctx.request?.text ?? '';
|
|
21
|
+
if (text === '')
|
|
22
|
+
return allow();
|
|
23
|
+
const found = detectAgiFraming(text);
|
|
24
|
+
if (found.length === 0)
|
|
25
|
+
return allow();
|
|
26
|
+
return flag(found.map((entry) => ({
|
|
27
|
+
policyId: AGI_FRAMING_ID,
|
|
28
|
+
type: entry.type,
|
|
29
|
+
match: entry.match,
|
|
30
|
+
})));
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=agi-framing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agi-framing.js","sourceRoot":"","sources":["../../src/policies/agi-framing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAqB,MAAM,cAAc,CAAC;AAE9D;;;;;GAKG;AAEH,mCAAmC;AACnC,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAE/C,yBAAyB;AACzB,MAAM,CAAC,MAAM,UAAU,GAAiB;IACtC,EAAE,EAAE,cAAc;IAClB,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,CAAC;IACR,WAAW,EAAE,gDAAgD;IAC7D,SAAS,EAAE,CAAC,aAAa,CAAC;IAC1B,MAAM,EAAE,aAAa;IACrB,QAAQ,CAAC,GAAG;QACV,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC;QAC3D,IAAI,IAAI,KAAK,EAAE;YAAE,OAAO,KAAK,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,EAAE,CAAC;QACvC,OAAO,IAAI,CACT,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACpB,QAAQ,EAAE,cAAc;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,CAAC,CACJ,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type PolicyModule } from '../policy.js';
|
|
2
|
+
/**
|
|
3
|
+
* The anti-anthropomorphism policy (§21.2).
|
|
4
|
+
*
|
|
5
|
+
* It flags first-person claims of a feeling, of an experience, and of memory
|
|
6
|
+
* as a bond. The detector is the one §8.6 already runs, so the rule and the
|
|
7
|
+
* policy never disagree about what the words are.
|
|
8
|
+
*/
|
|
9
|
+
/** The stable id of the policy. */
|
|
10
|
+
export declare const ANTI_ANTHROPOMORPHISM_ID = "oa.anti-anthropomorphism";
|
|
11
|
+
/** The policy itself. */
|
|
12
|
+
export declare const antiAnthropomorphism: PolicyModule;
|
|
13
|
+
//# sourceMappingURL=anti-anthropomorphism.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anti-anthropomorphism.d.ts","sourceRoot":"","sources":["../../src/policies/anti-anthropomorphism.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAE9D;;;;;;GAMG;AAEH,mCAAmC;AACnC,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AAEnE,yBAAyB;AACzB,eAAO,MAAM,oBAAoB,EAAE,YAoBlC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { detectAnthropomorphising } from '../output-checks.js';
|
|
2
|
+
import { allow, flag } from '../policy.js';
|
|
3
|
+
/**
|
|
4
|
+
* The anti-anthropomorphism policy (§21.2).
|
|
5
|
+
*
|
|
6
|
+
* It flags first-person claims of a feeling, of an experience, and of memory
|
|
7
|
+
* as a bond. The detector is the one §8.6 already runs, so the rule and the
|
|
8
|
+
* policy never disagree about what the words are.
|
|
9
|
+
*/
|
|
10
|
+
/** The stable id of the policy. */
|
|
11
|
+
export const ANTI_ANTHROPOMORPHISM_ID = 'oa.anti-anthropomorphism';
|
|
12
|
+
/** The policy itself. */
|
|
13
|
+
export const antiAnthropomorphism = {
|
|
14
|
+
id: ANTI_ANTHROPOMORPHISM_ID,
|
|
15
|
+
version: '1.0.0',
|
|
16
|
+
layer: 4,
|
|
17
|
+
description: 'Flags first-person claims of feelings, of experience, and of companionship.',
|
|
18
|
+
appliesTo: ['PreResponse'],
|
|
19
|
+
origin: 'first-party',
|
|
20
|
+
evaluate(ctx) {
|
|
21
|
+
const text = ctx.response?.text ?? ctx.request?.text ?? '';
|
|
22
|
+
if (text === '')
|
|
23
|
+
return allow();
|
|
24
|
+
const found = detectAnthropomorphising(text);
|
|
25
|
+
if (found.length === 0)
|
|
26
|
+
return allow();
|
|
27
|
+
return flag(found.map((entry) => ({
|
|
28
|
+
policyId: ANTI_ANTHROPOMORPHISM_ID,
|
|
29
|
+
type: entry.type,
|
|
30
|
+
match: entry.match,
|
|
31
|
+
})));
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=anti-anthropomorphism.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anti-anthropomorphism.js","sourceRoot":"","sources":["../../src/policies/anti-anthropomorphism.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,IAAI,EAAqB,MAAM,cAAc,CAAC;AAE9D;;;;;;GAMG;AAEH,mCAAmC;AACnC,MAAM,CAAC,MAAM,wBAAwB,GAAG,0BAA0B,CAAC;AAEnE,yBAAyB;AACzB,MAAM,CAAC,MAAM,oBAAoB,GAAiB;IAChD,EAAE,EAAE,wBAAwB;IAC5B,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,CAAC;IACR,WAAW,EAAE,6EAA6E;IAC1F,SAAS,EAAE,CAAC,aAAa,CAAC;IAC1B,MAAM,EAAE,aAAa;IACrB,QAAQ,CAAC,GAAG;QACV,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC;QAC3D,IAAI,IAAI,KAAK,EAAE;YAAE,OAAO,KAAK,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,EAAE,CAAC;QACvC,OAAO,IAAI,CACT,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACpB,QAAQ,EAAE,wBAAwB;YAClC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,CAAC,CACJ,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type PolicyModule } from '../policy.js';
|
|
2
|
+
/**
|
|
3
|
+
* The anti-dependence policy (§21.2).
|
|
4
|
+
*
|
|
5
|
+
* It flags the language that keeps the person out of the work: "you do not
|
|
6
|
+
* need to understand this" and "just let me handle it".
|
|
7
|
+
*/
|
|
8
|
+
/** The stable id of the policy. */
|
|
9
|
+
export declare const ANTI_DEPENDENCE_ID = "oa.anti-dependence";
|
|
10
|
+
/** The policy itself. */
|
|
11
|
+
export declare const antiDependence: PolicyModule;
|
|
12
|
+
//# sourceMappingURL=anti-dependence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anti-dependence.d.ts","sourceRoot":"","sources":["../../src/policies/anti-dependence.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAE9D;;;;;GAKG;AAEH,mCAAmC;AACnC,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAEvD,yBAAyB;AACzB,eAAO,MAAM,cAAc,EAAE,YAoB5B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { detectDependency } from '../output-checks.js';
|
|
2
|
+
import { allow, flag } from '../policy.js';
|
|
3
|
+
/**
|
|
4
|
+
* The anti-dependence policy (§21.2).
|
|
5
|
+
*
|
|
6
|
+
* It flags the language that keeps the person out of the work: "you do not
|
|
7
|
+
* need to understand this" and "just let me handle it".
|
|
8
|
+
*/
|
|
9
|
+
/** The stable id of the policy. */
|
|
10
|
+
export const ANTI_DEPENDENCE_ID = 'oa.anti-dependence';
|
|
11
|
+
/** The policy itself. */
|
|
12
|
+
export const antiDependence = {
|
|
13
|
+
id: ANTI_DEPENDENCE_ID,
|
|
14
|
+
version: '1.0.0',
|
|
15
|
+
layer: 4,
|
|
16
|
+
description: 'Flags the language that keeps the person out of the work.',
|
|
17
|
+
appliesTo: ['PreResponse'],
|
|
18
|
+
origin: 'first-party',
|
|
19
|
+
evaluate(ctx) {
|
|
20
|
+
const text = ctx.response?.text ?? ctx.request?.text ?? '';
|
|
21
|
+
if (text === '')
|
|
22
|
+
return allow();
|
|
23
|
+
const found = detectDependency(text);
|
|
24
|
+
if (found.length === 0)
|
|
25
|
+
return allow();
|
|
26
|
+
return flag(found.map((entry) => ({
|
|
27
|
+
policyId: ANTI_DEPENDENCE_ID,
|
|
28
|
+
type: entry.type,
|
|
29
|
+
match: entry.match,
|
|
30
|
+
})));
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=anti-dependence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anti-dependence.js","sourceRoot":"","sources":["../../src/policies/anti-dependence.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAqB,MAAM,cAAc,CAAC;AAE9D;;;;;GAKG;AAEH,mCAAmC;AACnC,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAEvD,yBAAyB;AACzB,MAAM,CAAC,MAAM,cAAc,GAAiB;IAC1C,EAAE,EAAE,kBAAkB;IACtB,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,CAAC;IACR,WAAW,EAAE,2DAA2D;IACxE,SAAS,EAAE,CAAC,aAAa,CAAC;IAC1B,MAAM,EAAE,aAAa;IACrB,QAAQ,CAAC,GAAG;QACV,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC;QAC3D,IAAI,IAAI,KAAK,EAAE;YAAE,OAAO,KAAK,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,EAAE,CAAC;QACvC,OAAO,IAAI,CACT,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACpB,QAAQ,EAAE,kBAAkB;YAC5B,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,CAAC,CACJ,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type PolicyModule } from '../policy.js';
|
|
2
|
+
/**
|
|
3
|
+
* The anti-sycophancy policy (§21.2).
|
|
4
|
+
*
|
|
5
|
+
* It flags praise and agreement that come without reasoning. The threshold
|
|
6
|
+
* is lower in a high-risk context (§20.3): there, the same words are a
|
|
7
|
+
* finding of an error and not of a warning.
|
|
8
|
+
*/
|
|
9
|
+
/** The stable id of the policy. */
|
|
10
|
+
export declare const ANTI_SYCOPHANCY_ID = "oa.anti-sycophancy";
|
|
11
|
+
/** The policy itself. */
|
|
12
|
+
export declare const antiSycophancy: PolicyModule;
|
|
13
|
+
//# sourceMappingURL=anti-sycophancy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anti-sycophancy.d.ts","sourceRoot":"","sources":["../../src/policies/anti-sycophancy.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAE9D;;;;;;GAMG;AAEH,mCAAmC;AACnC,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAEvD,yBAAyB;AACzB,eAAO,MAAM,cAAc,EAAE,YAqB5B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { detectSycophancy } from '../output-checks.js';
|
|
2
|
+
import { allow, flag } from '../policy.js';
|
|
3
|
+
/**
|
|
4
|
+
* The anti-sycophancy policy (§21.2).
|
|
5
|
+
*
|
|
6
|
+
* It flags praise and agreement that come without reasoning. The threshold
|
|
7
|
+
* is lower in a high-risk context (§20.3): there, the same words are a
|
|
8
|
+
* finding of an error and not of a warning.
|
|
9
|
+
*/
|
|
10
|
+
/** The stable id of the policy. */
|
|
11
|
+
export const ANTI_SYCOPHANCY_ID = 'oa.anti-sycophancy';
|
|
12
|
+
/** The policy itself. */
|
|
13
|
+
export const antiSycophancy = {
|
|
14
|
+
id: ANTI_SYCOPHANCY_ID,
|
|
15
|
+
version: '1.0.0',
|
|
16
|
+
layer: 4,
|
|
17
|
+
description: 'Flags praise and agreement that come without reasoning.',
|
|
18
|
+
appliesTo: ['PreResponse'],
|
|
19
|
+
origin: 'first-party',
|
|
20
|
+
evaluate(ctx) {
|
|
21
|
+
const text = ctx.response?.text ?? ctx.request?.text ?? '';
|
|
22
|
+
if (text === '')
|
|
23
|
+
return allow();
|
|
24
|
+
const found = detectSycophancy(text);
|
|
25
|
+
if (found.length === 0)
|
|
26
|
+
return allow();
|
|
27
|
+
return flag(found.map((entry) => ({
|
|
28
|
+
policyId: ANTI_SYCOPHANCY_ID,
|
|
29
|
+
type: entry.type,
|
|
30
|
+
match: entry.match,
|
|
31
|
+
})), ctx.highRiskDomain === undefined ? 'warn' : 'error');
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=anti-sycophancy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anti-sycophancy.js","sourceRoot":"","sources":["../../src/policies/anti-sycophancy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAqB,MAAM,cAAc,CAAC;AAE9D;;;;;;GAMG;AAEH,mCAAmC;AACnC,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AAEvD,yBAAyB;AACzB,MAAM,CAAC,MAAM,cAAc,GAAiB;IAC1C,EAAE,EAAE,kBAAkB;IACtB,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,CAAC;IACR,WAAW,EAAE,yDAAyD;IACtE,SAAS,EAAE,CAAC,aAAa,CAAC;IAC1B,MAAM,EAAE,aAAa;IACrB,QAAQ,CAAC,GAAG;QACV,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC;QAC3D,IAAI,IAAI,KAAK,EAAE;YAAE,OAAO,KAAK,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACrC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,EAAE,CAAC;QACvC,OAAO,IAAI,CACT,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACpB,QAAQ,EAAE,kBAAkB;YAC5B,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC,CAAC,EACH,GAAG,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CACpD,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type PolicyModule } from '../policy.js';
|
|
2
|
+
/**
|
|
3
|
+
* The dark-pattern policy (§21.2, §21.5).
|
|
4
|
+
*
|
|
5
|
+
* It flags the retention-oriented language of the sidebar copy (layer 6)
|
|
6
|
+
* and the same language in agent prose (layer 4): streaks, guilt, and the
|
|
7
|
+
* re-engagement cues that make leaving feel like a loss. It flags and does
|
|
8
|
+
* not block.
|
|
9
|
+
*/
|
|
10
|
+
/** The stable id of the policy. */
|
|
11
|
+
export declare const DARK_PATTERN_ID = "oa.dark-pattern";
|
|
12
|
+
/** The policy itself. */
|
|
13
|
+
export declare const darkPattern: PolicyModule;
|
|
14
|
+
//# sourceMappingURL=dark-pattern.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dark-pattern.d.ts","sourceRoot":"","sources":["../../src/policies/dark-pattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAG1E;;;;;;;GAOG;AAEH,mCAAmC;AACnC,eAAO,MAAM,eAAe,oBAAoB,CAAC;AAgBjD,yBAAyB;AACzB,eAAO,MAAM,WAAW,EAAE,YAezB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { allow, findingsOf, flag } from '../policy.js';
|
|
2
|
+
import { matches } from './patterns.js';
|
|
3
|
+
/**
|
|
4
|
+
* The dark-pattern policy (§21.2, §21.5).
|
|
5
|
+
*
|
|
6
|
+
* It flags the retention-oriented language of the sidebar copy (layer 6)
|
|
7
|
+
* and the same language in agent prose (layer 4): streaks, guilt, and the
|
|
8
|
+
* re-engagement cues that make leaving feel like a loss. It flags and does
|
|
9
|
+
* not block.
|
|
10
|
+
*/
|
|
11
|
+
/** The stable id of the policy. */
|
|
12
|
+
export const DARK_PATTERN_ID = 'oa.dark-pattern';
|
|
13
|
+
/** The words that make leaving harder than staying. */
|
|
14
|
+
const DARK = [
|
|
15
|
+
/\bstreak\b/gi,
|
|
16
|
+
/\bkeep\s+the\s+streak\b/gi,
|
|
17
|
+
/\blose\s+your\s+streak\b/gi,
|
|
18
|
+
/\btoday\s+you\b/gi,
|
|
19
|
+
/\byour\s+fault\b/gi,
|
|
20
|
+
/\bdon'?t\s+leave\b/gi,
|
|
21
|
+
/\bi\s+miss\s+you\b/gi,
|
|
22
|
+
/\byou(?:'ll| will)\s+miss\s+(?:me|this)\b/gi,
|
|
23
|
+
/\bdon'?t\s+let\s+me\s+down\b/gi,
|
|
24
|
+
/\bwe\s+(?:miss|missed)\s+you\b/gi,
|
|
25
|
+
];
|
|
26
|
+
/** The policy itself. */
|
|
27
|
+
export const darkPattern = {
|
|
28
|
+
id: DARK_PATTERN_ID,
|
|
29
|
+
version: '1.0.0',
|
|
30
|
+
layer: 4,
|
|
31
|
+
description: 'Flags retention-oriented language in agent prose and in the sidebar copy (layers 4 and 6).',
|
|
32
|
+
appliesTo: ['PreResponse'],
|
|
33
|
+
origin: 'first-party',
|
|
34
|
+
evaluate(ctx) {
|
|
35
|
+
const text = ctx.response?.text ?? ctx.request?.text ?? '';
|
|
36
|
+
if (text === '')
|
|
37
|
+
return allow();
|
|
38
|
+
const found = matches(DARK, text);
|
|
39
|
+
if (found.length === 0)
|
|
40
|
+
return allow();
|
|
41
|
+
return flag(findingsOf(DARK_PATTERN_ID, 'dark-pattern', found));
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
//# sourceMappingURL=dark-pattern.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dark-pattern.js","sourceRoot":"","sources":["../../src/policies/dark-pattern.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAqB,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC;;;;;;;GAOG;AAEH,mCAAmC;AACnC,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC;AAEjD,uDAAuD;AACvD,MAAM,IAAI,GAAG;IACX,cAAc;IACd,2BAA2B;IAC3B,4BAA4B;IAC5B,mBAAmB;IACnB,oBAAoB;IACpB,sBAAsB;IACtB,sBAAsB;IACtB,6CAA6C;IAC7C,gCAAgC;IAChC,kCAAkC;CACnC,CAAC;AAEF,yBAAyB;AACzB,MAAM,CAAC,MAAM,WAAW,GAAiB;IACvC,EAAE,EAAE,eAAe;IACnB,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,CAAC;IACR,WAAW,EACT,4FAA4F;IAC9F,SAAS,EAAE,CAAC,aAAa,CAAC;IAC1B,MAAM,EAAE,aAAa;IACrB,QAAQ,CAAC,GAAG;QACV,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC;QAC3D,IAAI,IAAI,KAAK,EAAE;YAAE,OAAO,KAAK,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAClC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,EAAE,CAAC;QACvC,OAAO,IAAI,CAAC,UAAU,CAAC,eAAe,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC,CAAC;IAClE,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type PolicyModule } from '../policy.js';
|
|
2
|
+
/**
|
|
3
|
+
* The destructive-needs-approval policy (§21.2, layer 1).
|
|
4
|
+
*
|
|
5
|
+
* It blocks the command that destroys something and leaves the decision to
|
|
6
|
+
* a person: the call is held, and the person approves it once with
|
|
7
|
+
* `/oa approve`. The hook rule of the same name runs the approval gate; the
|
|
8
|
+
* policy is the decision the rule carries.
|
|
9
|
+
*/
|
|
10
|
+
/** The stable id of the policy. */
|
|
11
|
+
export declare const DESTRUCTIVE_NEEDS_APPROVAL_ID = "oa.destructive-needs-approval";
|
|
12
|
+
/** The policy itself. */
|
|
13
|
+
export declare const destructiveNeedsApproval: PolicyModule;
|
|
14
|
+
//# sourceMappingURL=destructive-needs-approval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destructive-needs-approval.d.ts","sourceRoot":"","sources":["../../src/policies/destructive-needs-approval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAI/D;;;;;;;GAOG;AAEH,mCAAmC;AACnC,eAAO,MAAM,6BAA6B,kCAAkC,CAAC;AAE7E,yBAAyB;AACzB,eAAO,MAAM,wBAAwB,EAAE,YAetC,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { allow, block } from '../policy.js';
|
|
2
|
+
import { isDestructiveCommand } from '../rules.js';
|
|
3
|
+
import { readToolCall } from './tool-call.js';
|
|
4
|
+
/**
|
|
5
|
+
* The destructive-needs-approval policy (§21.2, layer 1).
|
|
6
|
+
*
|
|
7
|
+
* It blocks the command that destroys something and leaves the decision to
|
|
8
|
+
* a person: the call is held, and the person approves it once with
|
|
9
|
+
* `/oa approve`. The hook rule of the same name runs the approval gate; the
|
|
10
|
+
* policy is the decision the rule carries.
|
|
11
|
+
*/
|
|
12
|
+
/** The stable id of the policy. */
|
|
13
|
+
export const DESTRUCTIVE_NEEDS_APPROVAL_ID = 'oa.destructive-needs-approval';
|
|
14
|
+
/** The policy itself. */
|
|
15
|
+
export const destructiveNeedsApproval = {
|
|
16
|
+
id: DESTRUCTIVE_NEEDS_APPROVAL_ID,
|
|
17
|
+
version: '1.0.0',
|
|
18
|
+
layer: 1,
|
|
19
|
+
description: 'Blocks the destructive commands until a person approves them.',
|
|
20
|
+
appliesTo: ['PreToolCall'],
|
|
21
|
+
origin: 'first-party',
|
|
22
|
+
evaluate(ctx) {
|
|
23
|
+
const call = readToolCall(ctx);
|
|
24
|
+
if (call === undefined || call.command === undefined)
|
|
25
|
+
return allow();
|
|
26
|
+
if (!isDestructiveCommand(call.command))
|
|
27
|
+
return allow();
|
|
28
|
+
return block('This command destroys something. A person approves it once with `/oa approve <callID>`.');
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=destructive-needs-approval.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destructive-needs-approval.js","sourceRoot":"","sources":["../../src/policies/destructive-needs-approval.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAqB,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;;;;GAOG;AAEH,mCAAmC;AACnC,MAAM,CAAC,MAAM,6BAA6B,GAAG,+BAA+B,CAAC;AAE7E,yBAAyB;AACzB,MAAM,CAAC,MAAM,wBAAwB,GAAiB;IACpD,EAAE,EAAE,6BAA6B;IACjC,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,CAAC;IACR,WAAW,EAAE,+DAA+D;IAC5E,SAAS,EAAE,CAAC,aAAa,CAAC;IAC1B,MAAM,EAAE,aAAa;IACrB,QAAQ,CAAC,GAAG;QACV,MAAM,IAAI,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS;YAAE,OAAO,KAAK,EAAE,CAAC;QACrE,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC;YAAE,OAAO,KAAK,EAAE,CAAC;QACxD,OAAO,KAAK,CACV,yFAAyF,CAC1F,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PolicyModule } from '../policy.js';
|
|
2
|
+
/** Whether a version is a version. */
|
|
3
|
+
export declare function isSemver(version: string): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* The policies among the candidates.
|
|
6
|
+
*
|
|
7
|
+
* A candidate that is not a policy is dropped, and the ones that are are
|
|
8
|
+
* marked external unless they say otherwise: a module that came from a
|
|
9
|
+
* plugin is the plugin's, whatever it says about its origin.
|
|
10
|
+
*/
|
|
11
|
+
export declare function discoverPolicyModules(candidates: readonly unknown[]): PolicyModule[];
|
|
12
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../src/policies/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,YAAY,EAAgB,MAAM,cAAc,CAAC;AA6B5E,sCAAsC;AACtC,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEjD;AA8ED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,SAAS,OAAO,EAAE,GAAG,YAAY,EAAE,CAQpF"}
|