@agentproto/lifecycle 0.1.0-alpha.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 +21 -0
- package/README.md +23 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.mjs +60 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 agentproto contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @agentproto/lifecycle
|
|
2
|
+
|
|
3
|
+
AIP-37 `LIFECYCLE.md` reference implementation. A vocabulary AIP defining the standard lifecycle event names that hosts fire and that policy blocks (storage sync, sandbox lifecycle, etc.) reference. Not a runtime — just a shared language so configs across hosts mean the same thing.
|
|
4
|
+
|
|
5
|
+
> **Status: 0.1.0-alpha.** Generated by `scripts/scaffold-aip.mjs` — `build()` and `validate()` bodies are TODOs.
|
|
6
|
+
|
|
7
|
+
Spec: <https://agentproto.sh/docs/aip-37>
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { defineLifecycle } from "@agentproto/lifecycle"
|
|
13
|
+
|
|
14
|
+
const x = defineLifecycle({
|
|
15
|
+
id: "my-lifecycle",
|
|
16
|
+
description: "Short purpose.",
|
|
17
|
+
// ...
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## License
|
|
22
|
+
|
|
23
|
+
MIT — see [LICENSE](./LICENSE).
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agentproto/lifecycle — AIP-37 event-name vocabulary.
|
|
3
|
+
*
|
|
4
|
+
* Type: Meta. There is no `defineLifecycle` doctype — AIP-37 specifies a
|
|
5
|
+
* shared vocabulary of event names that other AIPs reference (e.g.
|
|
6
|
+
* `STORAGE.md.sync.commit.on: turn-end`). This package exports the
|
|
7
|
+
* constants + alias resolution so consumers get type-safe event names.
|
|
8
|
+
*
|
|
9
|
+
* Spec: https://agentproto.sh/docs/aip-37
|
|
10
|
+
*/
|
|
11
|
+
declare const SPEC_NAME: "agentlifecycle/v1";
|
|
12
|
+
declare const SPEC_VERSION: "1.0.0-alpha";
|
|
13
|
+
/**
|
|
14
|
+
* Standard lifecycle event names. Kebab-case, no colons (colons reserved
|
|
15
|
+
* for host namespaces like `agentik:custom-trigger`).
|
|
16
|
+
*
|
|
17
|
+
* Hosts MAY fire additional events beyond this list; configs reference
|
|
18
|
+
* any event name as a bare string. This array is the union of "events
|
|
19
|
+
* that conformant hosts SHOULD fire when their semantic conditions hold."
|
|
20
|
+
*/
|
|
21
|
+
declare const LIFECYCLE_EVENTS: readonly ["workspace-open", "workspace-close", "conversation-start", "conversation-end", "turn-start", "turn-end", "turn-error", "tool-call", "tool-result", "tool-error", "write", "delete", "manual"];
|
|
22
|
+
type LifecycleEvent = (typeof LIFECYCLE_EVENTS)[number];
|
|
23
|
+
/**
|
|
24
|
+
* Templated event names — hosts substitute the placeholder before firing.
|
|
25
|
+
* `idle-<N>` and `conversation-idle-<N>` accept a positive integer
|
|
26
|
+
* `N` (seconds since the relevant scope went idle).
|
|
27
|
+
*/
|
|
28
|
+
declare const LIFECYCLE_TEMPLATED_EVENTS: readonly ["idle", "conversation-idle"];
|
|
29
|
+
type LifecycleTemplatedEvent = (typeof LIFECYCLE_TEMPLATED_EVENTS)[number];
|
|
30
|
+
/**
|
|
31
|
+
* Aliases — shorthand names that resolve to standard event names.
|
|
32
|
+
* Hosts MUST accept aliases transparently (a config saying
|
|
33
|
+
* `commit.on: per-turn` is equivalent to `commit.on: turn-end`).
|
|
34
|
+
*/
|
|
35
|
+
declare const LIFECYCLE_ALIASES: {
|
|
36
|
+
readonly "each-write": "write";
|
|
37
|
+
readonly "per-turn": "turn-end";
|
|
38
|
+
readonly "per-conversation": "conversation-end";
|
|
39
|
+
};
|
|
40
|
+
type LifecycleAlias = keyof typeof LIFECYCLE_ALIASES;
|
|
41
|
+
/**
|
|
42
|
+
* Resolve any event reference (alias, standard, templated, or
|
|
43
|
+
* host-namespaced) to its canonical form. Aliases are rewritten;
|
|
44
|
+
* everything else passes through. Returns the input unchanged when
|
|
45
|
+
* no alias matches — consumers handle templated and namespaced
|
|
46
|
+
* events themselves.
|
|
47
|
+
*/
|
|
48
|
+
declare function resolveLifecycleEvent(name: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* True if `name` is one of the standard event names listed in this
|
|
51
|
+
* spec. Useful for host implementations to decide whether they
|
|
52
|
+
* support firing the event.
|
|
53
|
+
*/
|
|
54
|
+
declare function isStandardLifecycleEvent(name: string): name is LifecycleEvent;
|
|
55
|
+
/**
|
|
56
|
+
* Parse a templated event name (`idle-300`, `conversation-idle-600`)
|
|
57
|
+
* into its base + the integer threshold. Returns null when the name
|
|
58
|
+
* isn't a templated event.
|
|
59
|
+
*/
|
|
60
|
+
declare function parseTemplatedLifecycleEvent(name: string): {
|
|
61
|
+
base: LifecycleTemplatedEvent;
|
|
62
|
+
thresholdSeconds: number;
|
|
63
|
+
} | null;
|
|
64
|
+
/**
|
|
65
|
+
* True if `name` is a host-namespaced (non-portable) event like
|
|
66
|
+
* `agentik:scheduled-pull`. Configs using these declare an explicit
|
|
67
|
+
* host dependency.
|
|
68
|
+
*/
|
|
69
|
+
declare function isNamespacedLifecycleEvent(name: string): boolean;
|
|
70
|
+
|
|
71
|
+
export { LIFECYCLE_ALIASES, LIFECYCLE_EVENTS, LIFECYCLE_TEMPLATED_EVENTS, type LifecycleAlias, type LifecycleEvent, type LifecycleTemplatedEvent, SPEC_NAME, SPEC_VERSION, isNamespacedLifecycleEvent, isStandardLifecycleEvent, parseTemplatedLifecycleEvent, resolveLifecycleEvent };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agentproto/lifecycle v0.1.0-alpha
|
|
3
|
+
* AIP-37 LIFECYCLE event-name vocabulary (Meta type — no doctype).
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// src/index.ts
|
|
7
|
+
var SPEC_NAME = "agentlifecycle/v1";
|
|
8
|
+
var SPEC_VERSION = "1.0.0-alpha";
|
|
9
|
+
var LIFECYCLE_EVENTS = [
|
|
10
|
+
// Workspace lifecycle
|
|
11
|
+
"workspace-open",
|
|
12
|
+
"workspace-close",
|
|
13
|
+
// Conversation lifecycle
|
|
14
|
+
"conversation-start",
|
|
15
|
+
"conversation-end",
|
|
16
|
+
// Agent turn lifecycle
|
|
17
|
+
"turn-start",
|
|
18
|
+
"turn-end",
|
|
19
|
+
"turn-error",
|
|
20
|
+
// Tool / command lifecycle
|
|
21
|
+
"tool-call",
|
|
22
|
+
"tool-result",
|
|
23
|
+
"tool-error",
|
|
24
|
+
// File / write lifecycle
|
|
25
|
+
"write",
|
|
26
|
+
"delete",
|
|
27
|
+
// Manual
|
|
28
|
+
"manual"
|
|
29
|
+
];
|
|
30
|
+
var LIFECYCLE_TEMPLATED_EVENTS = ["idle", "conversation-idle"];
|
|
31
|
+
var LIFECYCLE_ALIASES = {
|
|
32
|
+
"each-write": "write",
|
|
33
|
+
"per-turn": "turn-end",
|
|
34
|
+
"per-conversation": "conversation-end"
|
|
35
|
+
};
|
|
36
|
+
function resolveLifecycleEvent(name) {
|
|
37
|
+
return name in LIFECYCLE_ALIASES ? LIFECYCLE_ALIASES[name] : name;
|
|
38
|
+
}
|
|
39
|
+
function isStandardLifecycleEvent(name) {
|
|
40
|
+
return LIFECYCLE_EVENTS.includes(name);
|
|
41
|
+
}
|
|
42
|
+
function parseTemplatedLifecycleEvent(name) {
|
|
43
|
+
for (const base of LIFECYCLE_TEMPLATED_EVENTS) {
|
|
44
|
+
if (name.startsWith(`${base}-`)) {
|
|
45
|
+
const tail = name.slice(base.length + 1);
|
|
46
|
+
const n = Number(tail);
|
|
47
|
+
if (Number.isInteger(n) && n > 0) {
|
|
48
|
+
return { base, thresholdSeconds: n };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
function isNamespacedLifecycleEvent(name) {
|
|
55
|
+
return name.includes(":");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { LIFECYCLE_ALIASES, LIFECYCLE_EVENTS, LIFECYCLE_TEMPLATED_EVENTS, SPEC_NAME, SPEC_VERSION, isNamespacedLifecycleEvent, isStandardLifecycleEvent, parseTemplatedLifecycleEvent, resolveLifecycleEvent };
|
|
59
|
+
//# sourceMappingURL=index.mjs.map
|
|
60
|
+
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,gBAAA,EAAkB,CAAA,EAAE;AAAA,MACrC;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,IAAA;AACT;AAOO,SAAS,2BAA2B,IAAA,EAAuB;AAChE,EAAA,OAAO,IAAA,CAAK,SAAS,GAAG,CAAA;AAC1B","file":"index.mjs","sourcesContent":["/**\n * @agentproto/lifecycle — AIP-37 event-name vocabulary.\n *\n * Type: Meta. There is no `defineLifecycle` doctype — AIP-37 specifies a\n * shared vocabulary of event names that other AIPs reference (e.g.\n * `STORAGE.md.sync.commit.on: turn-end`). This package exports the\n * constants + alias resolution so consumers get type-safe event names.\n *\n * Spec: https://agentproto.sh/docs/aip-37\n */\n\nexport const SPEC_NAME = \"agentlifecycle/v1\" as const\nexport const SPEC_VERSION = \"1.0.0-alpha\" as const\n\n/**\n * Standard lifecycle event names. Kebab-case, no colons (colons reserved\n * for host namespaces like `agentik:custom-trigger`).\n *\n * Hosts MAY fire additional events beyond this list; configs reference\n * any event name as a bare string. This array is the union of \"events\n * that conformant hosts SHOULD fire when their semantic conditions hold.\"\n */\nexport const LIFECYCLE_EVENTS = [\n // Workspace lifecycle\n \"workspace-open\",\n \"workspace-close\",\n // Conversation lifecycle\n \"conversation-start\",\n \"conversation-end\",\n // Agent turn lifecycle\n \"turn-start\",\n \"turn-end\",\n \"turn-error\",\n // Tool / command lifecycle\n \"tool-call\",\n \"tool-result\",\n \"tool-error\",\n // File / write lifecycle\n \"write\",\n \"delete\",\n // Manual\n \"manual\",\n] as const\n\nexport type LifecycleEvent = (typeof LIFECYCLE_EVENTS)[number]\n\n/**\n * Templated event names — hosts substitute the placeholder before firing.\n * `idle-<N>` and `conversation-idle-<N>` accept a positive integer\n * `N` (seconds since the relevant scope went idle).\n */\nexport const LIFECYCLE_TEMPLATED_EVENTS = [\"idle\", \"conversation-idle\"] as const\n\nexport type LifecycleTemplatedEvent =\n (typeof LIFECYCLE_TEMPLATED_EVENTS)[number]\n\n/**\n * Aliases — shorthand names that resolve to standard event names.\n * Hosts MUST accept aliases transparently (a config saying\n * `commit.on: per-turn` is equivalent to `commit.on: turn-end`).\n */\nexport const LIFECYCLE_ALIASES = {\n \"each-write\": \"write\",\n \"per-turn\": \"turn-end\",\n \"per-conversation\": \"conversation-end\",\n} as const\n\nexport type LifecycleAlias = keyof typeof LIFECYCLE_ALIASES\n\n/**\n * Resolve any event reference (alias, standard, templated, or\n * host-namespaced) to its canonical form. Aliases are rewritten;\n * everything else passes through. Returns the input unchanged when\n * no alias matches — consumers handle templated and namespaced\n * events themselves.\n */\nexport function resolveLifecycleEvent(name: string): string {\n return name in LIFECYCLE_ALIASES\n ? LIFECYCLE_ALIASES[name as LifecycleAlias]\n : name\n}\n\n/**\n * True if `name` is one of the standard event names listed in this\n * spec. Useful for host implementations to decide whether they\n * support firing the event.\n */\nexport function isStandardLifecycleEvent(\n name: string\n): name is LifecycleEvent {\n return (LIFECYCLE_EVENTS as readonly string[]).includes(name)\n}\n\n/**\n * Parse a templated event name (`idle-300`, `conversation-idle-600`)\n * into its base + the integer threshold. Returns null when the name\n * isn't a templated event.\n */\nexport function parseTemplatedLifecycleEvent(\n name: string\n): { base: LifecycleTemplatedEvent; thresholdSeconds: number } | null {\n for (const base of LIFECYCLE_TEMPLATED_EVENTS) {\n if (name.startsWith(`${base}-`)) {\n const tail = name.slice(base.length + 1)\n const n = Number(tail)\n if (Number.isInteger(n) && n > 0) {\n return { base, thresholdSeconds: n }\n }\n }\n }\n return null\n}\n\n/**\n * True if `name` is a host-namespaced (non-portable) event like\n * `agentik:scheduled-pull`. Configs using these declare an explicit\n * host dependency.\n */\nexport function isNamespacedLifecycleEvent(name: string): boolean {\n return name.includes(\":\")\n}\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentproto/lifecycle",
|
|
3
|
+
"version": "0.1.0-alpha.0",
|
|
4
|
+
"description": "@agentproto/lifecycle — AIP-37 LIFECYCLE.md reference implementation. A vocabulary AIP defining the standard lifecycle event names that hosts fire and that policy blocks (storage sync, sandbox lifecycle, etc.) reference. Not a runtime — just a shared language so configs across hosts mean the same thing.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"agentproto",
|
|
7
|
+
"aip-37",
|
|
8
|
+
"lifecycle",
|
|
9
|
+
"events",
|
|
10
|
+
"vocabulary",
|
|
11
|
+
"open-standard",
|
|
12
|
+
"agentic"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://agentproto.sh/docs/aip-37",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/agentproto/ts",
|
|
18
|
+
"directory": "packages/lifecycle"
|
|
19
|
+
},
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/agentproto/ts/issues"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"type": "module",
|
|
25
|
+
"main": "dist/index.mjs",
|
|
26
|
+
"module": "dist/index.mjs",
|
|
27
|
+
"types": "dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.mjs",
|
|
32
|
+
"default": "./dist/index.mjs"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"README.md",
|
|
39
|
+
"LICENSE"
|
|
40
|
+
],
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/node": "^25.6.2",
|
|
46
|
+
"tsup": "^8.5.1",
|
|
47
|
+
"typescript": "^5.9.3",
|
|
48
|
+
"vitest": "^3.2.4",
|
|
49
|
+
"@agentproto/tooling": "0.1.0-alpha.0"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"dev": "tsup --watch",
|
|
53
|
+
"build": "tsup",
|
|
54
|
+
"clean": "rm -rf dist",
|
|
55
|
+
"check-types": "tsc --noEmit",
|
|
56
|
+
"test": "vitest run --passWithNoTests",
|
|
57
|
+
"test:watch": "vitest"
|
|
58
|
+
}
|
|
59
|
+
}
|