pi-proactive 0.2.0-beta.2 → 0.2.0-beta.3
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 +29 -0
- package/README.md +32 -28
- package/build/cli.mjs +121 -0
- package/build/extensions/proactive.js +47 -6
- package/build/src/commands.js +78 -2
- package/build/src/config.js +511 -4
- package/build/src/daemon-config.js +221 -0
- package/build/src/daemon-contact.js +103 -0
- package/build/src/daemon-host.js +84 -0
- package/build/src/daemon.js +193 -3
- package/build/src/health.js +84 -0
- package/build/src/lineage.js +41 -2
- package/build/src/notify.js +183 -0
- package/build/src/progress-eta.js +134 -0
- package/build/src/trigger.js +43 -0
- package/build/src/trust-loop.js +321 -0
- package/build/src/trust-metrics.js +236 -0
- package/build/src/trust-notify.js +73 -0
- package/build/src/trust-policy.js +58 -0
- package/build/src/trust-registry.js +323 -0
- package/daemon/launchd.plist +48 -0
- package/daemon/pi-proactive-daemon.service +29 -0
- package/daemon/run-daemon.sh +84 -0
- package/node_modules/typebox/build/compile/code.mjs +2 -1
- package/node_modules/typebox/build/compile/validator.mjs +1 -5
- package/node_modules/typebox/build/format/date_time.d.mts +1 -2
- package/node_modules/typebox/build/format/date_time.mjs +3 -12
- package/node_modules/typebox/build/format/duration.d.mts +2 -2
- package/node_modules/typebox/build/format/duration.mjs +2 -2
- package/node_modules/typebox/build/format/idn_email.d.mts +0 -1
- package/node_modules/typebox/build/format/idn_email.mjs +0 -1
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
- package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
- package/node_modules/typebox/build/format/ipv4.mjs +2 -2
- package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
- package/node_modules/typebox/build/format/ipv6.mjs +1 -1
- package/node_modules/typebox/build/format/iri.mjs +9 -16
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/guard/emit.mjs +2 -2
- package/node_modules/typebox/build/guard/guard.d.mts +5 -7
- package/node_modules/typebox/build/guard/guard.mjs +9 -14
- package/node_modules/typebox/build/guard/index.mjs +0 -6
- package/node_modules/typebox/build/guard/{unicode/unicode_segment.mjs → string.mjs} +19 -16
- package/node_modules/typebox/build/schema/build.mjs +5 -5
- package/node_modules/typebox/build/schema/check.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/_context.d.mts +1 -5
- package/node_modules/typebox/build/schema/engine/_context.mjs +3 -16
- package/node_modules/typebox/build/schema/engine/_functions.d.mts +2 -2
- package/node_modules/typebox/build/schema/engine/_functions.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/_reducer.d.mts +3 -3
- package/node_modules/typebox/build/schema/engine/_refine.d.mts +5 -5
- package/node_modules/typebox/build/schema/engine/_refine.mjs +9 -14
- package/node_modules/typebox/build/schema/engine/_stack.d.mts +20 -34
- package/node_modules/typebox/build/schema/engine/_stack.mjs +202 -143
- package/node_modules/typebox/build/schema/engine/_unique.d.mts +2 -4
- package/node_modules/typebox/build/schema/engine/_unique.mjs +3 -7
- package/node_modules/typebox/build/schema/engine/additionalItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +8 -5
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +32 -27
- package/node_modules/typebox/build/schema/engine/allOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/allOf.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/anyOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/anyOf.mjs +9 -4
- package/node_modules/typebox/build/schema/engine/boolean.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/boolean.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/const.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/const.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/contains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/contains.mjs +9 -5
- package/node_modules/typebox/build/schema/engine/dependencies.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dependencies.mjs +7 -5
- package/node_modules/typebox/build/schema/engine/dependentRequired.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dependentRequired.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/dependentSchemas.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dependentSchemas.mjs +1 -2
- package/node_modules/typebox/build/schema/engine/dynamicRef.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/dynamicRef.mjs +8 -12
- package/node_modules/typebox/build/schema/engine/enum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/enum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/exclusiveMaximum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/exclusiveMaximum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/exclusiveMinimum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/exclusiveMinimum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/format.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/format.mjs +8 -11
- package/node_modules/typebox/build/schema/engine/if.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/if.mjs +13 -5
- package/node_modules/typebox/build/schema/engine/index.d.mts +0 -1
- package/node_modules/typebox/build/schema/engine/index.mjs +0 -1
- package/node_modules/typebox/build/schema/engine/items.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/items.mjs +5 -8
- package/node_modules/typebox/build/schema/engine/maxContains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +8 -4
- package/node_modules/typebox/build/schema/engine/maxItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxItems.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/maxLength.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxLength.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/maxProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maxProperties.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/maximum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/maximum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/minContains.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minContains.mjs +9 -5
- package/node_modules/typebox/build/schema/engine/minItems.d.mts +5 -5
- package/node_modules/typebox/build/schema/engine/minItems.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/minLength.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minLength.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/minProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minProperties.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/minimum.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/minimum.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/multipleOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/multipleOf.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/not.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/not.mjs +8 -4
- package/node_modules/typebox/build/schema/engine/oneOf.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +11 -6
- package/node_modules/typebox/build/schema/engine/pattern.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/pattern.mjs +7 -3
- package/node_modules/typebox/build/schema/engine/patternProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +5 -6
- package/node_modules/typebox/build/schema/engine/prefixItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/prefixItems.mjs +1 -1
- package/node_modules/typebox/build/schema/engine/properties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/properties.mjs +3 -4
- package/node_modules/typebox/build/schema/engine/propertyNames.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +10 -7
- package/node_modules/typebox/build/schema/engine/recursiveRef.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/recursiveRef.mjs +8 -12
- package/node_modules/typebox/build/schema/engine/ref.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/ref.mjs +14 -18
- package/node_modules/typebox/build/schema/engine/required.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/required.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/schema.d.mts +7 -7
- package/node_modules/typebox/build/schema/engine/schema.mjs +138 -136
- package/node_modules/typebox/build/schema/engine/type.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/type.mjs +6 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +9 -5
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +9 -5
- package/node_modules/typebox/build/schema/engine/uniqueItems.d.mts +4 -4
- package/node_modules/typebox/build/schema/engine/uniqueItems.mjs +6 -2
- package/node_modules/typebox/build/schema/errors.mjs +1 -1
- package/node_modules/typebox/build/schema/intern/intern.d.mts +9 -6
- package/node_modules/typebox/build/schema/intern/intern.mjs +56 -90
- package/node_modules/typebox/build/schema/parse.mjs +0 -3
- package/node_modules/typebox/build/schema/pointer/pointer.d.mts +6 -1
- package/node_modules/typebox/build/schema/pointer/pointer.mjs +64 -47
- package/node_modules/typebox/build/schema/resolve/resolve.d.mts +32 -6
- package/node_modules/typebox/build/schema/resolve/resolve.mjs +227 -231
- package/node_modules/typebox/build/schema/schema.d.mts +0 -1
- package/node_modules/typebox/build/schema/schema.mjs +0 -1
- package/node_modules/typebox/build/system/hashing/hash.mjs +34 -63
- package/node_modules/typebox/build/system/locale/en_US.mjs +1 -2
- package/node_modules/typebox/build/system/memory/assign.d.mts +8 -2
- package/node_modules/typebox/build/system/memory/assign.mjs +6 -13
- package/node_modules/typebox/build/system/memory/clone.d.mts +5 -4
- package/node_modules/typebox/build/system/memory/clone.mjs +96 -8
- package/node_modules/typebox/build/system/memory/create.d.mts +5 -1
- package/node_modules/typebox/build/system/memory/create.mjs +13 -18
- package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
- package/node_modules/typebox/build/system/memory/discard.mjs +8 -9
- package/node_modules/typebox/build/system/memory/freeze.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/freeze.mjs +6 -0
- package/node_modules/typebox/build/system/memory/update.d.mts +4 -1
- package/node_modules/typebox/build/system/memory/update.mjs +16 -43
- package/node_modules/typebox/build/system/settings/settings.d.mts +0 -11
- package/node_modules/typebox/build/system/settings/settings.mjs +0 -14
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +24 -2
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +29 -2
- package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/evaluate/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +1 -5
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +1 -6
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +4 -1
- package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +4 -1
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +3 -1
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +4 -1
- package/node_modules/typebox/build/type/extends/inference.d.mts +1 -1
- package/node_modules/typebox/build/type/extends/inference.mjs +2 -15
- package/node_modules/typebox/build/type/extends/tuple.d.mts +1 -2
- package/node_modules/typebox/build/type/extends/tuple.mjs +1 -21
- package/node_modules/typebox/build/value/clean/from_object.mjs +1 -1
- package/node_modules/typebox/build/value/clone/clone.d.mts +3 -4
- package/node_modules/typebox/build/value/clone/clone.mjs +7 -5
- package/node_modules/typebox/build/value/parse/parse.mjs +4 -10
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +14 -25
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +84 -52
- package/package.json +11 -3
- package/skills/pi-proactive/SKILL.md +27 -24
- package/tools/cli.mjs +121 -0
- package/tools/daemon-install.sh +397 -0
- package/tools/daemon-uninstall.sh +226 -0
- package/node_modules/typebox/build/guard/unicode/unicode.d.mts +0 -6
- package/node_modules/typebox/build/guard/unicode/unicode.mjs +0 -35
- package/node_modules/typebox/build/schema/engine/_pathing.d.mts +0 -1
- package/node_modules/typebox/build/schema/engine/_pathing.mjs +0 -11
- package/node_modules/typebox/build/schema/meta/draft_2019_09.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_2019_09.mjs +0 -288
- package/node_modules/typebox/build/schema/meta/draft_2020_12.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_2020_12.mjs +0 -300
- package/node_modules/typebox/build/schema/meta/draft_3.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_3.mjs +0 -143
- package/node_modules/typebox/build/schema/meta/draft_4.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_4.mjs +0 -149
- package/node_modules/typebox/build/schema/meta/draft_6.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_6.mjs +0 -155
- package/node_modules/typebox/build/schema/meta/draft_7.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/draft_7.mjs +0 -172
- package/node_modules/typebox/build/schema/meta/index.d.mts +0 -2
- package/node_modules/typebox/build/schema/meta/index.mjs +0 -2
- package/node_modules/typebox/build/schema/meta/meta.d.mts +0 -9
- package/node_modules/typebox/build/schema/meta/meta.mjs +0 -15
- package/node_modules/typebox/build/schema/meta/schema.d.mts +0 -6
- package/node_modules/typebox/build/schema/meta/schema.mjs +0 -1
- package/node_modules/typebox/build/system/memory/deep.d.mts +0 -2
- package/node_modules/typebox/build/system/memory/deep.mjs +0 -108
- package/node_modules/typebox/build/system/memory/finalize.d.mts +0 -4
- package/node_modules/typebox/build/system/memory/finalize.mjs +0 -30
- package/node_modules/typebox/build/system/memory/keys.d.mts +0 -2
- package/node_modules/typebox/build/system/memory/keys.mjs +0 -8
- package/node_modules/typebox/build/system/settings/internal.d.mts +0 -2
- package/node_modules/typebox/build/system/settings/internal.mjs +0 -20
- package/node_modules/typebox/build/type/engine/call/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/call/index.mjs +0 -1
- package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +0 -30
- package/node_modules/typebox/build/type/engine/evaluate/property.mjs +0 -29
- package/node_modules/typebox/build/type/engine/this/index.d.mts +0 -1
- package/node_modules/typebox/build/type/engine/this/index.mjs +0 -1
- package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +0 -2
- package/node_modules/typebox/build/value/repair/from_cyclic.mjs +0 -6
- /package/node_modules/typebox/build/guard/{unicode/unicode_segment.d.mts → string.d.mts} +0 -0
|
@@ -30,12 +30,12 @@ import Type from 'typebox'
|
|
|
30
30
|
|
|
31
31
|
const T = Type.Object({ // const T = {
|
|
32
32
|
x: Type.Number(), // type: 'object',
|
|
33
|
-
y: Type.Number(), //
|
|
34
|
-
z: Type.Number() //
|
|
35
|
-
}) //
|
|
36
|
-
// y: { type: 'number' },
|
|
33
|
+
y: Type.Number(), // properties: {
|
|
34
|
+
z: Type.Number() // x: { type: 'number' },
|
|
35
|
+
}) // y: { type: 'number' },
|
|
37
36
|
// z: { type: 'number' }
|
|
38
37
|
// },
|
|
38
|
+
// required: ['x', 'y', 'z']
|
|
39
39
|
// }
|
|
40
40
|
|
|
41
41
|
type T = Type.Static<typeof T> // type T = {
|
|
@@ -69,9 +69,9 @@ License: MIT
|
|
|
69
69
|
|
|
70
70
|
## Type
|
|
71
71
|
|
|
72
|
-
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/type/overview) | [Example](https://www.typescriptlang.org/play
|
|
72
|
+
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/type/overview) | [Example](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoSgehrgFonmXW32POvueHb7kafo16ix4ic2oBjCADsAzvACqC1FDgBeREQB0AeWIArVNJgAKAN5wbtu-Yc26cWYpVqN2y5RvAAJgBcOmi6AMowUMByAObmAJQANI7JKfbONoRoQXgQxqYweAk+cHIAhiCoQYKoYRFRsYmpTQ7pcGDYaLDAqApB3jaoIKXAADZVeuGRMVaY0EMw2YPDI3hwAL5xya2+gXDWmZX4SlPRq2tFG81X11v0dmUVfXAH2cf1Z0U3X99w23BLoyexR+INSfwyRFedRihTgwNBCLSd3sGDmpQW+ABKzhiNxdj+a3heIRrUJxLxrSgqAAjgBXYBU3YAbSJ5J+fzw-lhrLZXw5D1Q3N5JORNjwWKowtBrQAujypc1nIThJJVWr1XxnOF0cBpCqNQbDZxqAc4Kp1FpgjVtTBdQAeA4QDBmjwAPmuzlN5s8e3lCqarX8QTeMU+-u+rQFweh0TD4ZurSx0ZOfvjjiVQA)
|
|
73
73
|
|
|
74
|
-
TypeBox types are JSON Schema fragments that compose into more complex types. The library
|
|
74
|
+
TypeBox types are JSON Schema fragments that compose into more complex types. The library offers a set of types used to construct JSON Schema compliant schematics as well as a set of extended types used to model constructs native to the JavaScript language. The schematics produced by TypeBox can be passed directly to any JSON Schema compliant validator.
|
|
75
75
|
|
|
76
76
|
### Example
|
|
77
77
|
|
|
@@ -80,33 +80,38 @@ The following creates a User type and infers with Static.
|
|
|
80
80
|
```typescript
|
|
81
81
|
import Type from 'typebox'
|
|
82
82
|
|
|
83
|
+
// Type
|
|
84
|
+
|
|
83
85
|
const User = Type.Object({ // const User = {
|
|
84
86
|
id: Type.String(), // type: 'object',
|
|
85
|
-
name: Type.String(), //
|
|
86
|
-
email: Type.String({ format: 'email' }) //
|
|
87
|
-
}) //
|
|
88
|
-
// 'email'
|
|
89
|
-
// ],
|
|
90
|
-
// properties: {
|
|
91
|
-
// id: { type: 'string' },
|
|
92
|
-
// name: { type: 'string' },
|
|
87
|
+
name: Type.String(), // properties: {
|
|
88
|
+
email: Type.String({ format: 'email' }) // id: { type: 'string' },
|
|
89
|
+
}) // name: { type: 'string' },
|
|
93
90
|
// email: {
|
|
94
91
|
// type: 'string',
|
|
95
92
|
// format: 'email'
|
|
96
93
|
// }
|
|
97
|
-
// }
|
|
94
|
+
// },
|
|
95
|
+
// required: [
|
|
96
|
+
// 'id',
|
|
97
|
+
// 'name',
|
|
98
|
+
// 'email'
|
|
99
|
+
// ]
|
|
98
100
|
// }
|
|
99
101
|
|
|
102
|
+
// Static
|
|
103
|
+
|
|
100
104
|
type User = Type.Static<typeof User> // type User = {
|
|
101
105
|
// id: string,
|
|
102
106
|
// name: string,
|
|
103
107
|
// email: string
|
|
104
108
|
// }
|
|
109
|
+
|
|
105
110
|
```
|
|
106
111
|
|
|
107
112
|
## Script
|
|
108
113
|
|
|
109
|
-
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/script/overview) | [Example 1](https://www.typescriptlang.org/play/?target=99&module=7#code/
|
|
114
|
+
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/script/overview) | [Example 1](https://www.typescriptlang.org/play/?target=99&module=7#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoSgehrgFkBDGAC0YgBMBXAG1WoBjCADsAzvGZs4AXkREAdAGVBUYGBgAKAAaU4cQmjgA1VIJjQALLLgBvOGQBccEdxDFUUADRwkz1+6ePgBe-m4e3nAA7mGBUHAAvnoGRCZmFlAAzDb2Ti7hQb6xESHFnonJhuim5tAATDkOZZF++XEV2gCU1HRwAOJQTGCswIJiHDz8QqIS-YPDo+NyyGjKqupaUqw+uvpVabCoZDnJ+pBiwDDAos41GZZepy7QIEy8t+nQmY-6+twAbh9alA6skkntUn1UDhUDAoEgTr84P9PFdBKgxB9DmQANoAXR+v2AIk4owxzXxYMqqSknmAb0RvyY7mAqBEMCB90J+lJGAw3DEqE5Vm5cDEaEEfCYUGFUEsVIhRgYGPYclsTwA5tCQLD4c4oTC4UhRa8YHS3s5aWo3lSutR9sqxKr5KslDAWKMADxVCAYOZDEZjHF4R2sPB4gB8+l6DpVjKRCcTSeTKZTvX0WsNerscAUecSotTReLJfTcFN5veObzCgqJfrDeTvQSQA) | [Example 2](https://www.typescriptlang.org/play/?target=99&module=7#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoSgehrgFkBDGAC0YgBMBXAG1WoBjCADsAzvABqqQTGgAWOAF5ERAHQB5YgCsZMABQBvOGQBcqtGoBy3EMVRR9ASgA0cJOeSWbdh87cAXp7qPvaOrnAA7sHetmHOcAC+TpTC4lJ60ADMyhaomjp6RiYx+aF+ER551nEVgaU1vuFJKWkScNKy0ABMuV75WrqyxWbV5eFuVf2N8U4t1HRwAOJQTGCswIJiHDz8QqLt0rCoZH3qg0WGlHBwkGLAMMCi5p1yUPIu13Ai0CBMvC9MlAsp8btwAG6ArpQbqUZKpA7wJaoHCoGBQJBnSwXYZXG7ghyPQSoMQNACCUFWSH0RxgJ1cX2AIk4mxJ5MpTGp03GzhS8La8GYdKgwH+WIGhVxXyYdmAqBEMChbw+XxZGAw3DEqCVClBcDEaEEfCYUB170+-MRjBJ7BU0xxBjxcAA5iiQGiMeZkaj0Ug9X9haKAYwWA4g3CUpRCGhrWJbdUAMowFibAA80ZRGFjrAAfDd8wXC4sM9nck7CxXK1XqzX84sbq6fZ64MY1G2knra13u1363AA2H-uZW+3El8exPJ3X6IkgA)
|
|
110
115
|
|
|
111
116
|
TypeBox includes a micro TypeScript engine that can transform TypeScript definitions to JSON Schema. The engine is fully type-safe and supports many programmable constructs including Conditional, Mapped, Indexed, Generics, Distributive Generics, and more.
|
|
112
117
|
|
|
@@ -117,12 +122,16 @@ Syntax highlighting is available via the [Visual Studio Marketplace](https://mar
|
|
|
117
122
|
```typescript
|
|
118
123
|
import Type from 'typebox'
|
|
119
124
|
|
|
125
|
+
// Math Module
|
|
126
|
+
|
|
120
127
|
const Math = Type.Script(`
|
|
121
128
|
type Vector4 = { x: number, y: number, z: number, w: number }
|
|
122
129
|
type Vector3 = { x: number, y: number, z: number }
|
|
123
130
|
type Vector2 = { x: number, y: number }
|
|
124
131
|
`)
|
|
125
132
|
|
|
133
|
+
// Graphics Module
|
|
134
|
+
|
|
126
135
|
const Graphics = Type.Script(Math, `
|
|
127
136
|
type Vertex = {
|
|
128
137
|
position: Vector4,
|
|
@@ -154,9 +163,9 @@ type Mesh = Type.Static<typeof Graphics['Mesh']> // type Mesh = {
|
|
|
154
163
|
|
|
155
164
|
## Schema
|
|
156
165
|
|
|
157
|
-
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/schema/overview) | [Example 1](https://www.typescriptlang.org/play
|
|
166
|
+
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/schema/overview) | [Example 1](https://www.typescriptlang.org/play/#code/JYWwDg9gTgLgBAZQMYAsCmICGcBmUIhwDkMAnmGgEYQAeA9AM6oaZEBQbddcAtH-wMFDhI0WPESenbgGECYYABs003pPUbNW-hyQQAdg3gBVBmihwAvImZYAdHPBK0ACgDebOHDIUAXMQhKACs0JBgiABpPODB8ClhgNAZ-Dy8vYAATFO9yNH8iIyhgfQBzIjgAXyi0uH1MEDy4Nxy-YkLissrqtJYlbJ9Ggpgi0sjcaCwYfN7FcoroquioNABHAFdgZay4AG1oryJMsf3iOobjmqIZ9i8AXTYKgEoOLjVtd4+P1QAFTCgzVSfIHAyS6AxGOBrMwWaymcx2X7-VzNGqotHouCvPSGeBQ8wpaKZfIANgArDgAIyYABMlAAzEgACwZUloYk4ADsmAAHJQAJxIAAMGQpYwx6Ne6W27VK3TOgzxUDF4pVqq8ktq9UaMpK3Rm+UVAAEMgRMMU7HoQOU1SqNfq4DqHo8bS7XajXhUrHA7D6gA) | [Example 2](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAZQMYAsCmICGcBmUIhwDkMAnmGgEYQAeA9AM6oaZEBQokscAKuWrnyES-ajXZs6dOAFo58hYqXKVqteo0zJ0gMIEwwADZptszeYuWr8tmyQQAdg3gBVBmihwAvImZYAdHrgRmgAFHwU-gDylABWaEgwoQDebHBwwAAmAFy8-P4IMFDADgDmoQCUADRpcA6YIGi5EWgFRSXl1bUsRs35hcVlKbjQWDC5RD2GRHAAvhVs8wum1qtr61pScAAKmFDuKxtHx6q29k7wAK7unj5uHv67+2HJ6W-vH5-vW+fOcNceXKpdJZCYANgArDgAIyYABMlAAzEgACyZCFoME4ADsmAAHJQAJxIAAMmWhRCqX2pcC2IJycGcg1KNXS9UaEwBUEpNN5fO+0jZDSajPaZVZcCmnJuAAFMgRMCV-PYQDN+by6ZKsL1RczFhV1YajR8trNvHB-JagA)
|
|
158
167
|
|
|
159
|
-
TypeBox includes a high-performance
|
|
168
|
+
TypeBox includes a high-performance JIT compiler that supports JSON Schema Draft 3 through to 2020-12. It is designed to be a lightweight industry-grade alternative to Ajv and offers improved compilation and validation performance. It also provides automatic fallback to dynamic validation in JIT restricted environments such as Cloudflare Workers.
|
|
160
169
|
|
|
161
170
|
The compiler is available via optional sub module import.
|
|
162
171
|
|
|
@@ -166,10 +175,36 @@ import Schema from 'typebox/schema'
|
|
|
166
175
|
|
|
167
176
|
### Compile
|
|
168
177
|
|
|
169
|
-
The compiler accepts TypeBox types
|
|
178
|
+
The compiler accepts either TypeBox types or native JSON Schema.
|
|
179
|
+
|
|
180
|
+
```typescript
|
|
181
|
+
|
|
182
|
+
// Type
|
|
183
|
+
|
|
184
|
+
const VectorA = Schema.Compile(Type.Object({ // const VectorA: Validator<TObject<{
|
|
185
|
+
x: Type.Number(), // x: TNumber
|
|
186
|
+
y: Type.Number(), // y: TNumber
|
|
187
|
+
z: Type.Number() // z: TNumber
|
|
188
|
+
})) // }>>
|
|
189
|
+
|
|
190
|
+
// Schema
|
|
191
|
+
|
|
192
|
+
const VectorB = Schema.Compile({ // const VectorB: Validator<{
|
|
193
|
+
type: 'object', // type: "object";
|
|
194
|
+
required: ['x', 'y', 'z'], // required: ["x", "y", "z"];
|
|
195
|
+
properties: { // properties: { ... };
|
|
196
|
+
x: { type: 'number' }, // }, { ... }>
|
|
197
|
+
y: { type: 'number' },
|
|
198
|
+
z: { type: 'number' }
|
|
199
|
+
}
|
|
200
|
+
})
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Validate
|
|
204
|
+
|
|
205
|
+
Compiled validator instances provide functions to Check and Parse values.
|
|
170
206
|
|
|
171
207
|
```typescript
|
|
172
|
-
import Schema from 'typebox/schema'
|
|
173
208
|
|
|
174
209
|
// Compile
|
|
175
210
|
|
|
@@ -192,11 +227,11 @@ const result = Vector.Parse({ x: 1, y: 0, z: 0 }) // const result: {
|
|
|
192
227
|
// }
|
|
193
228
|
```
|
|
194
229
|
|
|
195
|
-
###
|
|
230
|
+
### Coverage
|
|
196
231
|
|
|
197
232
|
[JSON Schema Test Suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite) | [JSON Schema Compliance Suite](https://github.com/sinclairzx81/json-schema-compliance-suite)
|
|
198
233
|
|
|
199
|
-
TypeBox supports all
|
|
234
|
+
TypeBox supports all major JSON Schema draft versions and tracks compliance against the official JSON Schema Test Suite. It also maintains a separate JavaScript compliance suite to track ecosystem adoption as JSON Schema moves toward the V1 candidate. The following table shows TypeBox specification coverage.
|
|
200
235
|
|
|
201
236
|
| Spec | 3 | 4 | 6 | 7 | 2019-09 | 2020-12 | v1 |
|
|
202
237
|
|:-----|:--|:--|:--|:--|:--|:--|:--|
|
|
@@ -219,6 +254,7 @@ TypeBox supports all versions of JSON Schema and is heavily tested against the o
|
|
|
219
254
|
| enum | 16/18 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
220
255
|
| exclusiveMaximum | - | - | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
221
256
|
| exclusiveMinimum | - | - | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
257
|
+
| format | ✅ | ✅ | ✅ | ✅ | ✅ | 114/133 | - |
|
|
222
258
|
| if-then-else | - | - | - | ✅ | ✅ | ✅ | ✅ |
|
|
223
259
|
| infinite-loop-detection | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
224
260
|
| items | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
@@ -251,47 +287,43 @@ TypeBox supports all versions of JSON Schema and is heavily tested against the o
|
|
|
251
287
|
|
|
252
288
|
### Performance
|
|
253
289
|
|
|
254
|
-
TypeBox tracks performance against AJV8
|
|
290
|
+
TypeBox tracks comparative performance against AJV8 as the de facto performance standard. For broader comparative benchmarks, refer to the community maintained projects below.
|
|
255
291
|
|
|
256
292
|
[Runtime Benchmarks](https://moltar.github.io/typescript-runtime-type-benchmarks/) | [Schema Benchmarks](https://schemabenchmarks.dev/)
|
|
257
293
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
The following table shows compile performance for various JSON Schema structures. These benchmarks measure the time required to build and runtime JIT schematics. Faster compilation results in faster application startup.
|
|
294
|
+
The following table shows compilation performance for various JSON Schema structures. These benchmarks measure the time required to JIT compile schematics, with faster compilation resulting in faster application startup.
|
|
261
295
|
|
|
262
296
|
```python
|
|
263
297
|
┌──────────────────────┬──────────────┬──────────────┐
|
|
264
298
|
│ Compile │ TB1X │ AJV8 │
|
|
265
299
|
├──────────────────────┼──────────────┼──────────────┤
|
|
266
|
-
│ Boolean │
|
|
267
|
-
│ Number │
|
|
268
|
-
│ String │
|
|
269
|
-
│ Null │
|
|
270
|
-
│ Literal_String │
|
|
271
|
-
│ Literal_Number │
|
|
272
|
-
│ Literal_Boolean │
|
|
273
|
-
│ Pattern │
|
|
274
|
-
│ Object_Open │
|
|
275
|
-
│ Object_Close │
|
|
276
|
-
│ Object_Vector3 │
|
|
277
|
-
│ Object_Basis3 │
|
|
278
|
-
│ Intersect_And │
|
|
279
|
-
│ Intersect_Structural │ 25.
|
|
280
|
-
│ Union_Or │ 58.
|
|
281
|
-
│ Union_Structural │
|
|
282
|
-
│ Tuple_Values │
|
|
283
|
-
│ Tuple_Objects │
|
|
284
|
-
│ Array_Numbers_4 │
|
|
285
|
-
│ Array_Numbers_8 │
|
|
286
|
-
│ Array_Numbers_16 │
|
|
287
|
-
│ Array_Objects_Open │
|
|
288
|
-
│ Array_Objects_Close │
|
|
300
|
+
│ Boolean │ 50.4K ops/s │ 7.1K ops/s │
|
|
301
|
+
│ Number │ 129.9K ops/s │ 7.9K ops/s │
|
|
302
|
+
│ String │ 128.9K ops/s │ 9.1K ops/s │
|
|
303
|
+
│ Null │ 91.3K ops/s │ 8.4K ops/s │
|
|
304
|
+
│ Literal_String │ 63.1K ops/s │ 7.4K ops/s │
|
|
305
|
+
│ Literal_Number │ 74.5K ops/s │ 7.6K ops/s │
|
|
306
|
+
│ Literal_Boolean │ 143.3K ops/s │ 7.7K ops/s │
|
|
307
|
+
│ Pattern │ 94.2K ops/s │ 6.4K ops/s │
|
|
308
|
+
│ Object_Open │ 19.4K ops/s │ 1.3K ops/s │
|
|
309
|
+
│ Object_Close │ 17.6K ops/s │ 991 ops/s │
|
|
310
|
+
│ Object_Vector3 │ 46.1K ops/s │ 3.3K ops/s │
|
|
311
|
+
│ Object_Basis3 │ 16K ops/s │ 848 ops/s │
|
|
312
|
+
│ Intersect_And │ 41.3K ops/s │ 4.2K ops/s │
|
|
313
|
+
│ Intersect_Structural │ 25.3K ops/s │ 1.5K ops/s │
|
|
314
|
+
│ Union_Or │ 58.6K ops/s │ 2.4K ops/s │
|
|
315
|
+
│ Union_Structural │ 31.5K ops/s │ 1.8K ops/s │
|
|
316
|
+
│ Tuple_Values │ 18.2K ops/s │ 1.9K ops/s │
|
|
317
|
+
│ Tuple_Objects │ 3.9K ops/s │ 437 ops/s │
|
|
318
|
+
│ Array_Numbers_4 │ 114.5K ops/s │ 4.2K ops/s │
|
|
319
|
+
│ Array_Numbers_8 │ 128.3K ops/s │ 3.9K ops/s │
|
|
320
|
+
│ Array_Numbers_16 │ 128.4K ops/s │ 4K ops/s │
|
|
321
|
+
│ Array_Objects_Open │ 22K ops/s │ 780 ops/s │
|
|
322
|
+
│ Array_Objects_Close │ 22K ops/s │ 1K ops/s │
|
|
289
323
|
└──────────────────────┴──────────────┴──────────────┘
|
|
290
324
|
```
|
|
291
325
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
The following table shows validation performance for various JSON Schema structures. These benchmarks measure overall validation throughput for compiled schematics.
|
|
326
|
+
The following tables shows validation performance for various JSON Schema structures. These benchmarks measure overall validation throughput for JIT compiled schematics.
|
|
295
327
|
|
|
296
328
|
```python
|
|
297
329
|
┌──────────────────────┬──────────────┬──────────────┐
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-proactive",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.3",
|
|
4
4
|
"description": "给 Pi 增加主动性:空闲时主动推进或提问、按时间点主动发起任务、多个会话之间对话协作。(专有软件:分发物不含源码,使用条款见包内 LICENSE)",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
|
@@ -22,7 +22,12 @@
|
|
|
22
22
|
"skills/",
|
|
23
23
|
"README.md",
|
|
24
24
|
"CHANGELOG.md",
|
|
25
|
-
"LICENSE"
|
|
25
|
+
"LICENSE",
|
|
26
|
+
"tools/daemon-install.sh",
|
|
27
|
+
"tools/daemon-uninstall.sh",
|
|
28
|
+
"daemon/",
|
|
29
|
+
"build/cli.mjs",
|
|
30
|
+
"tools/cli.mjs"
|
|
26
31
|
],
|
|
27
32
|
"pi": {
|
|
28
33
|
"extensions": [
|
|
@@ -49,5 +54,8 @@
|
|
|
49
54
|
},
|
|
50
55
|
"bundledDependencies": [
|
|
51
56
|
"typebox"
|
|
52
|
-
]
|
|
57
|
+
],
|
|
58
|
+
"bin": {
|
|
59
|
+
"pi-proactive": "./build/cli.mjs"
|
|
60
|
+
}
|
|
53
61
|
}
|
|
@@ -21,13 +21,14 @@ description: >-
|
|
|
21
21
|
<!-- BEGIN:GEN tools -->
|
|
22
22
|
| 工具 | 参数 | 作用 | 定义位置 |
|
|
23
23
|
| --- | --- | --- | --- |
|
|
24
|
-
| `schedule_task` | prompt(必填):任务提示词<br>intent(可选):投递意图,默认 wake(取值:wake \| interrupt \| queue \| notify)<br>askUser(可选):触发时是否向用户提问(仅本地)<br>when(可选):触发时间:时长(10m)/ 时刻(18:30)/ ISO 8601;缺省按 10m 处理 | 预约一个稍后触发的任务(真正落库到任务表,到点由调度器投递)。when 支持时长(10m)、时刻(18:30)或 ISO 时间;缺省按 10m 处理。 | `pi-proactive/extensions/proactive.ts:
|
|
25
|
-
| `message_agent` | to(必填):目标 agent 的名字或 agentId<br>kind(可选):消息语义(对方要不要回我);缺省 notify(取值:notify \| ask \| task \| reply \| broadcast)<br>subject(可选):标题<br>body(必填):正文<br>intent(可选):投递意图(怎么投给对方);缺省 wake(取值:wake \| interrupt \| queue \| notify)<br>threadId(可选):话题 / 会话 id(可选) | 给另一个正在运行的 agent 会话发消息(跨进程协作)。对端在线时走 socket 直达;不在线时消息落盘到对端邮箱,待其上线后处理。 | `pi-proactive/extensions/proactive.ts:
|
|
26
|
-
| `list_peers` | name(可选):名字子串(大小写敏感;也命中 agentId)。同名歧义时返回与 message_agent 报错完全一致的候选<br>status(可选):按在场状态过滤(online = 在线 = 空闲 ∪ 忙碌)(取值:online \| idle \| busy \| offline)<br>capability(可选):按能力标签过滤(如 message_agent)<br>includeOffline(可选):是否包含离线对端(缺省 false = 只给在线) | 列出本机可见的其它 agent 对端(名字 / agentId / 在场状态 / 心跳龄 / 能力标签 / 在途任务数 / 传输方式),可按名字、状态、能力过滤。**只读**:不产生任何对外行为。发消息前先查它(先查后发),别盲发 —— 离线对端现在打扰它不合适。 | `pi-proactive/extensions/proactive.ts:
|
|
27
|
-
| `proactive_query` | action(必填):查询动作(与 /proactive 子命令同名)(取值:peers \| history \| status \| tasks \| doctor \| help)<br>name(可选):peers:名字子串过滤<br>all(可选):peers:是否包含离线对端<br>idle(可选):peers:只看空闲对端<br>detail(可选):peers:只看这一个 agentId<br>scope(可选):history:范围(对端 / 我)(取值:peer \| me)<br>peer(可选):history:按对端 agentId 过滤<br>limit(可选):history:条数(1-200 的整数)<br>json(可选):doctor:输出 JSON | 查询域:查对端(peers)/ 看主动行为历史(history)/ 看状态(status)/ 看任务(tasks)/ 只读体检(doctor)/ 看命令手册(help)。**只读**:不产生任何对外行为。 | `pi-proactive/extensions/proactive.ts:
|
|
28
|
-
| `
|
|
29
|
-
| `
|
|
30
|
-
| `
|
|
24
|
+
| `schedule_task` | prompt(必填):任务提示词<br>intent(可选):投递意图,默认 wake(取值:wake \| interrupt \| queue \| notify)<br>askUser(可选):触发时是否向用户提问(仅本地)<br>when(可选):触发时间:时长(10m)/ 时刻(18:30)/ ISO 8601;缺省按 10m 处理 | 预约一个稍后触发的任务(真正落库到任务表,到点由调度器投递)。when 支持时长(10m)、时刻(18:30)或 ISO 时间;缺省按 10m 处理。 | `pi-proactive/extensions/proactive.ts:640` |
|
|
25
|
+
| `message_agent` | to(必填):目标 agent 的名字或 agentId<br>kind(可选):消息语义(对方要不要回我);缺省 notify(取值:notify \| ask \| task \| reply \| broadcast)<br>subject(可选):标题<br>body(必填):正文<br>intent(可选):投递意图(怎么投给对方);缺省 wake(取值:wake \| interrupt \| queue \| notify)<br>threadId(可选):话题 / 会话 id(可选) | 给另一个正在运行的 agent 会话发消息(跨进程协作)。对端在线时走 socket 直达;不在线时消息落盘到对端邮箱,待其上线后处理。 | `pi-proactive/extensions/proactive.ts:685` |
|
|
26
|
+
| `list_peers` | name(可选):名字子串(大小写敏感;也命中 agentId)。同名歧义时返回与 message_agent 报错完全一致的候选<br>status(可选):按在场状态过滤(online = 在线 = 空闲 ∪ 忙碌)(取值:online \| idle \| busy \| offline)<br>capability(可选):按能力标签过滤(如 message_agent)<br>includeOffline(可选):是否包含离线对端(缺省 false = 只给在线) | 列出本机可见的其它 agent 对端(名字 / agentId / 在场状态 / 心跳龄 / 能力标签 / 在途任务数 / 传输方式),可按名字、状态、能力过滤。**只读**:不产生任何对外行为。发消息前先查它(先查后发),别盲发 —— 离线对端现在打扰它不合适。 | `pi-proactive/extensions/proactive.ts:759` |
|
|
27
|
+
| `proactive_query` | action(必填):查询动作(与 /proactive 子命令同名)(取值:peers \| history \| status \| tasks \| doctor \| help \| config)<br>name(可选):peers:名字子串过滤<br>all(可选):peers:是否包含离线对端<br>idle(可选):peers:只看空闲对端<br>detail(可选):peers:只看这一个 agentId<br>scope(可选):history:范围(对端 / 我)(取值:peer \| me)<br>peer(可选):history:按对端 agentId 过滤<br>limit(可选):history:条数(1-200 的整数)<br>json(可选):doctor / config:输出 JSON | 查询域:查对端(peers)/ 看主动行为历史(history)/ 看状态(status)/ 看任务(tasks)/ 只读体检(doctor)/ 看命令手册(help)/ 查配置清单(config)。**只读**:不产生任何对外行为。 | `pi-proactive/extensions/proactive.ts:796` |
|
|
28
|
+
| `progress_query` | | 查项目进度与 ETA:返回**区间 + 置信度 + 归因 + 阻塞项**(不给单点数字)。口径唯一(scripts/progress-clock.py),与人侧 `/proactive progress` 同源同口径、逐字一致。**只读**:不产生任何对外行为。 | `pi-proactive/extensions/proactive.ts:822` |
|
|
29
|
+
| `proactive_schedule` | action(必填):排程动作(与 /proactive 子命令同名)(取值:in \| at \| every \| cancel)<br>when(可选):in/at/every:触发时间(时长 10m / 时刻 18:30)<br>content(可选):in/at/every:任务内容<br>id(可选):cancel:任务 id | 排程域:定时(in)/ 定点(at)/ 周期(every)/ 取消(cancel)。落到真实任务表,到点由调度器投递;与命令面 `/proactive in\|at\|every\|cancel` 同源。 | `pi-proactive/extensions/proactive.ts:836` |
|
|
30
|
+
| `proactive_peer` | action(必填):对端动作(与 /proactive 子命令同名)(取值:tell \| spawn)<br>peer(可选):tell:目标对端(名字或 agentId)<br>content(可选):tell:指令内容<br>kind(可选):tell:指令类型(缺省 ask)(取值:ask \| task \| notify)<br>subject(可选):tell:标题<br>thread(可选):tell:线程 id<br>name(可选):spawn:对端名字 | 对端协作域:给对端下指令(tell)/ 创建对端会话(spawn,受同时存活数上限)。tell 的目标解析与回执三态与命令面 `/proactive tell` 完全同源。 | `pi-proactive/extensions/proactive.ts:855` |
|
|
31
|
+
| `proactive_manage` | action(必填):管理动作(与 /proactive 子命令同名)(取值:on \| off \| idle \| test)<br>state(可选):idle:开 / 关(取值:on \| off) | 管理域:主动性总开关(on/off)、空闲触发开关(idle)、自检(test)。这些能力属 human-gated:调用只会回报「需人工确认」并给出可复制的人工指令,**不会**自行改动全局开关。 | `pi-proactive/extensions/proactive.ts:877` |
|
|
31
32
|
<!-- END:GEN tools -->
|
|
32
33
|
|
|
33
34
|
> 工具面真源 = 实现:上表由 `scripts/gen-doc-tables.sh` 从扩展的 `registerTool` 注册项与参数 schema 自动生成,**不要手改**。
|
|
@@ -139,25 +140,27 @@ description: >-
|
|
|
139
140
|
<!-- BEGIN:GEN commands -->
|
|
140
141
|
| 命令 | 参数形态 | 做什么 | 状态 |
|
|
141
142
|
| --- | --- | --- | --- |
|
|
142
|
-
| `/proactive status` | `无` | 总览:开关、空闲计时、待触发任务、对端在线、上次主动、本小时用量。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
143
|
-
| `/proactive on` | `无` | 打开全部「代理自发」行为(空闲触发、模型自调度、跨会话自发请求)。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
144
|
-
| `/proactive off` | `无` | 关闭全部「代理自发」行为;已排期任务保留但不再触发。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
145
|
-
| `/proactive test` | `无` | 立即模拟一次触发(走完整「护栏 → 投递」链路),用于验证主动能力是否真的生效。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
146
|
-
| `/proactive tasks` | `无` | 列出所有待触发任务(编号 / 类型 / 下次到期 / 归属 / 触发次数)。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
147
|
-
| `/proactive cancel` | `<id>` | 取消一个任务。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
148
|
-
| `/proactive idle` | `on\|off` | 打开 / 关闭空闲触发并设定阈值(on 可带时长参数,省略 = 用上次设定)。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
149
|
-
| `/proactive peers` | `[--all\|--idle\|--name <子串>\|--detail <agentId>]` | 列出已注册的对端与在线状态(名字 / 忙闲 / 最后心跳);可加 --all / --idle / --name / --detail。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
150
|
-
| `/proactive spawn` | `[名字]` | 创建一个对端会话(子进程 pi --mode rpc);本会话退出时一并终止。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
151
|
-
| `/proactive in` | `<时长> <内容>` | 排一个延迟任务(默认只属于当前会话)。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
152
|
-
| `/proactive at` | `<HH:MM> <内容>` | 排一个绝对时间任务。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
153
|
-
| `/proactive every` | `<时长> <内容>` | 排一个周期任务。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
154
|
-
| `/proactive help` | `无` | 打印命令速查表(命令表 / 配置键 / 最常见故障 / 详细文档路径)。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
155
|
-
| `/proactive history` | `[peer\|me] [条数]` | 查看最近的主动行为记录(时间 / 类型 / 目标 / 结果 / 被护栏拦下的原因)。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
156
|
-
| `/proactive doctor` | `[--json]` | 只读体检:逐项健康判定 + 处置建议(--json 机器可读);不打扰、不耗额度。 | 已实现 · `pi-proactive/src/commands.ts:
|
|
157
|
-
| `/proactive
|
|
143
|
+
| `/proactive status` | `无` | 总览:开关、空闲计时、待触发任务、对端在线、上次主动、本小时用量。 | 已实现 · `pi-proactive/src/commands.ts:617` |
|
|
144
|
+
| `/proactive on` | `无` | 打开全部「代理自发」行为(空闲触发、模型自调度、跨会话自发请求)。 | 已实现 · `pi-proactive/src/commands.ts:653` |
|
|
145
|
+
| `/proactive off` | `无` | 关闭全部「代理自发」行为;已排期任务保留但不再触发。 | 已实现 · `pi-proactive/src/commands.ts:654` |
|
|
146
|
+
| `/proactive test` | `无` | 立即模拟一次触发(走完整「护栏 → 投递」链路),用于验证主动能力是否真的生效。 | 已实现 · `pi-proactive/src/commands.ts:732` |
|
|
147
|
+
| `/proactive tasks` | `无` | 列出所有待触发任务(编号 / 类型 / 下次到期 / 归属 / 触发次数)。 | 已实现 · `pi-proactive/src/commands.ts:735` |
|
|
148
|
+
| `/proactive cancel` | `<id>` | 取消一个任务。 | 已实现 · `pi-proactive/src/commands.ts:761` |
|
|
149
|
+
| `/proactive idle` | `on\|off` | 打开 / 关闭空闲触发并设定阈值(on 可带时长参数,省略 = 用上次设定)。 | 已实现 · `pi-proactive/src/commands.ts:801` |
|
|
150
|
+
| `/proactive peers` | `[--all\|--idle\|--name <子串>\|--detail <agentId>]` | 列出已注册的对端与在线状态(名字 / 忙闲 / 最后心跳);可加 --all / --idle / --name / --detail。 | 已实现 · `pi-proactive/src/commands.ts:674` |
|
|
151
|
+
| `/proactive spawn` | `[名字]` | 创建一个对端会话(子进程 pi --mode rpc);本会话退出时一并终止。 | 已实现 · `pi-proactive/src/commands.ts:709` |
|
|
152
|
+
| `/proactive in` | `<时长> <内容>` | 排一个延迟任务(默认只属于当前会话)。 | 已实现 · `pi-proactive/src/commands.ts:779` |
|
|
153
|
+
| `/proactive at` | `<HH:MM> <内容>` | 排一个绝对时间任务。 | 已实现 · `pi-proactive/src/commands.ts:780` |
|
|
154
|
+
| `/proactive every` | `<时长> <内容>` | 排一个周期任务。 | 已实现 · `pi-proactive/src/commands.ts:781` |
|
|
155
|
+
| `/proactive help` | `无` | 打印命令速查表(命令表 / 配置键 / 最常见故障 / 详细文档路径)。 | 已实现 · `pi-proactive/src/commands.ts:816` |
|
|
156
|
+
| `/proactive history` | `[peer\|me] [条数]` | 查看最近的主动行为记录(时间 / 类型 / 目标 / 结果 / 被护栏拦下的原因)。 | 已实现 · `pi-proactive/src/commands.ts:739` |
|
|
157
|
+
| `/proactive doctor` | `[--json]` | 只读体检:逐项健康判定 + 处置建议(--json 机器可读);不打扰、不耗额度。 | 已实现 · `pi-proactive/src/commands.ts:625` |
|
|
158
|
+
| `/proactive progress` | `无` | 项目进度 + ETA:区间 + 置信度 + 归因 + 阻塞项(不给单点数字;口径 = scripts/progress-clock.py)。 | 已实现 · `pi-proactive/src/commands.ts:633` |
|
|
159
|
+
| `/proactive tell` | `<peer> <内容> [--kind ask\|task\|notify]` | 人侧给另一个会话下指令(--kind ask\|task\|notify,缺省 ask 要回话);回信落回本会话。 | 已实现 · `pi-proactive/src/commands.ts:729` |
|
|
160
|
+
| `/proactive config` | `[undo] [--json]` | 列出全部配置项(当前值 / 缺省值 / 取值范围 / 一句说明),先报警写错的项;config undo 撤销上一次配置改动。 | 已实现 · `pi-proactive/src/commands.ts:640` |
|
|
158
161
|
<!-- END:GEN commands -->
|
|
159
162
|
|
|
160
|
-
> 命令面真源 = 实现:上表由 `scripts/gen-doc-tables.sh` 从扩展的 `SUBCOMMANDS` + `switch (sub)` 分派自动生成(**共
|
|
163
|
+
> 命令面真源 = 实现:上表由 `scripts/gen-doc-tables.sh` 从扩展的 `SUBCOMMANDS` + `switch (sub)` 分派自动生成(**共 18 个命令**),**不要手改**。
|
|
161
164
|
|
|
162
165
|
## 不要做的事
|
|
163
166
|
|
package/tools/cli.mjs
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// pi-proactive CLI —— 交付入口(npm bin / npx / 全局安装都指向这里)
|
|
3
|
+
// 目标:用户只跑 `npx pi-proactive daemon install`,不需要仓库、不需要 bash。
|
|
4
|
+
//
|
|
5
|
+
// 单一真源:本文件是 build/cli.mjs 的**源文件**(build/ 是编译产物,不入库)。
|
|
6
|
+
// build-release.sh 负责把它复制到 build/cli.mjs → npm 包的 bin 入口。
|
|
7
|
+
import { spawn } from "node:child_process";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
import fs from "node:fs";
|
|
11
|
+
|
|
12
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
13
|
+
const pkgRoot = path.resolve(here, "..");
|
|
14
|
+
const argv = process.argv.slice(2);
|
|
15
|
+
const cmd = argv[0];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 本 CLI 会转发给常驻脚本的参数(**参数契约的单一真源**)。
|
|
19
|
+
*
|
|
20
|
+
* 为什么要有它:cli 转发参数、被调 .sh 解析参数,两边各写各的就会出现
|
|
21
|
+
* 「cli 传 --host、.sh 报未知参数」这类契约漂移(2026-10-29 实测根因 2)。
|
|
22
|
+
* 契约测试(pi-proactive/tests/daemon-packaged-runtime.test.ts)据此断言:
|
|
23
|
+
* **这里列出的每个参数,两个 .sh 都必须接受**。
|
|
24
|
+
*/
|
|
25
|
+
const CLI_FLAGS = {
|
|
26
|
+
install: [
|
|
27
|
+
"--host",
|
|
28
|
+
"--agent-dir",
|
|
29
|
+
"--agent-id",
|
|
30
|
+
"--label",
|
|
31
|
+
"--service-name",
|
|
32
|
+
"--no-start",
|
|
33
|
+
],
|
|
34
|
+
uninstall: [
|
|
35
|
+
"--host",
|
|
36
|
+
"--agent-dir",
|
|
37
|
+
"--agent-id",
|
|
38
|
+
"--label",
|
|
39
|
+
"--service-name",
|
|
40
|
+
"--no-start",
|
|
41
|
+
"--purge-data",
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const USAGE = `pi-proactive — 给 Pi 增加主动性(空闲主动、按点主动、多会话协作)
|
|
46
|
+
|
|
47
|
+
用法:
|
|
48
|
+
pi-proactive daemon install 安装并启动常驻助理(回执「已常驻」)
|
|
49
|
+
pi-proactive daemon uninstall 卸载常驻助理(残留终检为空)
|
|
50
|
+
pi-proactive doctor 巡检健康
|
|
51
|
+
pi-proactive progress 进度与 ETA(区间/置信度/阻塞项)
|
|
52
|
+
pi-proactive config 查看配置(全部项/当前值/默认值/范围/说明)
|
|
53
|
+
pi-proactive history 主动行为与应答的血缘记录
|
|
54
|
+
|
|
55
|
+
安装(任选其一):
|
|
56
|
+
npx pi-proactive daemon install
|
|
57
|
+
npm i -g pi-proactive && pi-proactive daemon install
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
function run(file, args) {
|
|
61
|
+
return new Promise((resolve) => {
|
|
62
|
+
const p = spawn(file, args, { stdio: "inherit" });
|
|
63
|
+
p.on("close", (code) => resolve(code ?? 1));
|
|
64
|
+
p.on("error", () => resolve(2));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!cmd || cmd === "--help" || cmd === "-h" || cmd === "help") {
|
|
69
|
+
console.log(USAGE);
|
|
70
|
+
process.exit(0);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const script = (name) => {
|
|
74
|
+
const p = path.join(pkgRoot, "tools", name);
|
|
75
|
+
return fs.existsSync(p) ? p : null;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/** 参数白名单校验(**转发前**拦下未知参数 → 不把错误留给脚本去猜)。 */
|
|
79
|
+
function checkFlags(sub, args) {
|
|
80
|
+
const allowed = CLI_FLAGS[sub] ?? [];
|
|
81
|
+
for (const a of args) {
|
|
82
|
+
if (!a.startsWith("--")) continue;
|
|
83
|
+
const name = a.split("=")[0];
|
|
84
|
+
if (!allowed.includes(name)) {
|
|
85
|
+
console.error(`未知参数:${a}\n可用参数:${allowed.join(" ")}`);
|
|
86
|
+
process.exit(2);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (cmd === "daemon") {
|
|
92
|
+
const sub = argv[1];
|
|
93
|
+
const map = {
|
|
94
|
+
install: "daemon-install.sh",
|
|
95
|
+
uninstall: "daemon-uninstall.sh",
|
|
96
|
+
};
|
|
97
|
+
const file = map[sub];
|
|
98
|
+
if (!file) {
|
|
99
|
+
console.error(`未知子命令:daemon ${sub ?? ""}\n${USAGE}`);
|
|
100
|
+
process.exit(2);
|
|
101
|
+
}
|
|
102
|
+
const s = script(file);
|
|
103
|
+
if (!s) {
|
|
104
|
+
console.error(`包内缺少 ${file} —— 请重新安装 pi-proactive`);
|
|
105
|
+
process.exit(2);
|
|
106
|
+
}
|
|
107
|
+
const rest = argv.slice(2);
|
|
108
|
+
checkFlags(sub, rest);
|
|
109
|
+
const code = await run("bash", [s, ...rest]);
|
|
110
|
+
if (code !== 0 && sub === "install") {
|
|
111
|
+
// 失败即回滚(不给自己留 launchd 任务 / 进程 / 单元文件)。
|
|
112
|
+
console.error("[pi-proactive] 安装未成功 → 自动回滚(卸载自己刚注册的),避免留下残留");
|
|
113
|
+
const u = script("daemon-uninstall.sh");
|
|
114
|
+
if (u) await run("bash", [u, ...rest]);
|
|
115
|
+
}
|
|
116
|
+
process.exit(code);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 其余子命令暂由宿主命令面提供(保持"同一分派"口径);此处给出明确指引而非另写实现
|
|
120
|
+
console.error(`「${cmd}」由 Pi 宿主内的 /proactive ${cmd} 提供;请在 Pi 会话中执行。`);
|
|
121
|
+
process.exit(2);
|