@howaboua/pi-durable-pulses 0.0.0-stage → 0.9.1
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/NOTICE +20 -0
- package/README.md +50 -2
- package/dist/admission.d.ts +9 -0
- package/dist/authoring.d.ts +1 -0
- package/dist/contract.d.ts +84 -0
- package/dist/definitions.d.ts +27 -0
- package/dist/execution.d.ts +14 -0
- package/dist/frontmatter.d.ts +5 -0
- package/dist/index.d.ts +130 -0
- package/dist/index.js +1210 -0
- package/dist/occurrences.d.ts +6 -0
- package/dist/schedule.d.ts +44 -0
- package/dist/state.d.ts +47 -0
- package/dist/tasks.d.ts +28 -0
- package/dist/tool.d.ts +38 -0
- package/package.json +43 -5
- package/skills/pulses-ops/SKILL.md +14 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Igor Warzocha
|
|
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/NOTICE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Frontmatter and schedule algorithms carried from IgorWarzocha/pi-clawa (Howaclawa), revision 07fbb0ad71a08a864b285b01d512c2052861b91d, src/pulses/frontmatter.ts and schedule.ts. Copyright Igor Warzocha. MIT license; see LICENSE. Parser and scheduling semantics preserved; filesystem, native admission and execution are Durable-native implementations.
|
|
2
|
+
|
|
3
|
+
Pi 1.4 refresh inspected pi-pulses at revision
|
|
4
|
+
3d0faf5a6f0bc67c0bd9248d07da6ddfa901b281. This delta changes dependency metadata
|
|
5
|
+
only; Durable sleep checkpoints and task ownership remain native implementations.
|
|
6
|
+
|
|
7
|
+
Schedule-edit rebasing and task-result guidance aligned to packages/pi-pulses
|
|
8
|
+
in https://github.com/IgorWarzocha/howaboua-pi-stuff at revision
|
|
9
|
+
7f3295e67a8e6146b2a6922b56a06fa4db5c3a32, including local commits.
|
|
10
|
+
Copyright (c) 2026 Igor Warzocha. MIT licensed.
|
|
11
|
+
Native task receipts replace process-runner ownership and retry ledgers;
|
|
12
|
+
the accepted folder layout and passive parent results remain unchanged.
|
|
13
|
+
|
|
14
|
+
Agent-facing controls and bundled authoring guidance adapted from
|
|
15
|
+
packages/pi-pulses/src/controls.ts, index.ts and skills/pulses/SKILL.md in
|
|
16
|
+
https://github.com/IgorWarzocha/howaboua-pi-stuff at revision
|
|
17
|
+
12c4357b2c401fe9be8c6c82d2ae252c0f986937.
|
|
18
|
+
Copyright (c) 2026 Igor Warzocha. MIT licensed.
|
|
19
|
+
Ordinary Durable registration and native task receipts replace Pi tool transport.
|
|
20
|
+
Authoring guidance uses the existing Durable folder layout and admission rules.
|
package/README.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Pulses
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Persistent, folder-owned scheduled work for Pi Durable. Each `pulses/<id>/PULSE.md` stays beside its local instructions, journals and artifacts. Removing a definition or this component never deletes that folder or native conversation history.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install https://github.com/IgorWarzocha/pi-durable-components/releases/download/v0.9.1/howaboua-pi-durable-pulses-0.9.1.tgz
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```markdown
|
|
10
|
+
---
|
|
11
|
+
title: Weekly review
|
|
12
|
+
schedule: weekly fri 17:00
|
|
13
|
+
enabled: true
|
|
14
|
+
quietHours: 22:00-08:00
|
|
15
|
+
---
|
|
16
|
+
Review this workspace. Follow the instructions in this pulse folder and update its existing journal.
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Schedules support `manual`, `every 30m`, `every 3h`, `every 2d`, `daily 9:00`, `weekly mon 9:00` and `at <datetime>`. Times use the runtime's local timezone. Scans run every five minutes. New, reenabled or semantically changed schedules seed the current slot rather than replaying stale work. Cosmetic spellings and body edits preserve recurrence state. Quiet hours hold due work. Disabled definitions cannot run manually. A manual invocation bypasses quiet hours without consuming its recurrence checkpoint. Established `trigger: manual` and `trigger: time` headers are accepted. Unknown metadata is left untouched.
|
|
20
|
+
|
|
21
|
+
Tracked occurrences survive a host-imposed pause and process downtime. Each job coalesces its pending occurrences into one fresh run with the count and first/last due timestamps in its input. Tracking begins on discovery or upgrade, without guessing missing legacy history. Deleted, disabled, invalid, expired or superseded pending work remains inspectable as a disposition rather than running an obsolete definition. Optional `expiresAt: <datetime>` stops new admissions at that deadline. Already accepted work still settles.
|
|
22
|
+
|
|
23
|
+
Child execution remains the default. Set `target: resident` to deliver into the continuing conversation explicitly supplied by the host binding. The resident keeps its own configuration and reports through its ordinary conversation. Changing the target seeds a new schedule without replaying the old target's pending work.
|
|
24
|
+
|
|
25
|
+
## Integration
|
|
26
|
+
|
|
27
|
+
Install `createPulses(options).extension` before opening the Harness, then await `bind(harness, context)` before recovering other proactive sources. Binding reconciles definitions and checkpoints without admission or execution. After all features bind, the host calls `scan(context)` and resumes its Harness. Pulses never resumes it. Provide explicit workspace bindings and environment-owned definition reads. Prepare filesystem/configuration data in `admit`. `configure` performs document-only native transaction operations on every new child admission. Its fifth argument, `{created}`, distinguishes initialization from reuse. Apply standalone host defaults only on creation. Refresh applicable pulse-local instructions and cwd without resetting native models/tools/extensions on reuse. Parent configuration inherits natively. Resident targets bypass `configure`.
|
|
28
|
+
|
|
29
|
+
Supply `admitTransaction(tx, admission, context)` for host-owned race-safe policy and activity accounting. It receives the new native task ID in the same commit as task creation. Return `{status: "accepted"}` or `{status: "blocked", reason, retryAt?}`. Blocking rolls back the entire transaction, including host credit, and leaves the occurrence queued. Only `tx.doc` operations are supported here. Native table reads after task creation are forbidden, as are Harness reads, external I/O and irreversible effects. Rejoining an existing native request skips new-admission policy. `explicitReady(tx, bindingKey, now)` exposes tracked pending or overdue work for shared admission priority without reading files. Work held by Pulse quiet hours or a recorded native backoff deadline does not claim that priority.
|
|
30
|
+
|
|
31
|
+
The optional `submitInput` port receives the accepted native task ID, target, content and deterministic input request ID. Validate that task's lineage before delivering accepted work through the host. Return the actual settled native input receipt. The coordinator rejoins an existing receipt before calling this port. Previously admitted native tasks remain valid even if their definition disappears or restrictions change.
|
|
32
|
+
|
|
33
|
+
`catalog(context)` returns definitions and inspectable diagnostics. `run({bindingKey,pulseId,requestId}, context)` returns the native task ID, or `undefined` when admission is blocked or capacity is occupied. Use a stable request ID for retries. `observe(context)` includes pending counts/periods, blocked reasons, the last obsolete/superseded disposition, historical conversation associations and the current native task record, including removed definitions. Outcomes and submissions remain native. `stop` aborts and joins the native coordinator. Its abort handler cancels only the run owning the pulse's input and settles its passive report. It does not cancel external work blocking a dispatch retry or a later run following pulse settlement.
|
|
34
|
+
|
|
35
|
+
The extension registers the ordinary `pulses` agent tool. `{}` lists definition paths and diagnostics, `{run:"name"}` requests a run, and `{skill:true}` returns bundled authoring guidance without filesystem access or a host binding. For discovery and new manual requests, supply `resolveToolBinding(api, context)` returning the authorised binding key for `api.conversationId` in `api.env`. Select the registration on the intended controllers. Discovery reads only that binding's definitions. Code and Notebook discover the same registration automatically. An admitted tool request freezes its binding in a native memo and uses the native tool task ID for deduplication. Recovery rejoins the existing receipt before reading changed definitions or applying new admission policy. Cancelling the calling tool does not revoke accepted background work. Use `stop` to cancel the owned pulse execution.
|
|
36
|
+
|
|
37
|
+
Hosts that scope manual admission to the invoking caller can supply `withToolRunAuthorization(api, request, run, context)`. Its `request` is the public `PulseRunRequest` with `bindingKey`, `pulseId` and the original `requestId`, identical to direct `run()` input. This wrapper runs after native receipt lookup finds no accepted request and outside the Pulses admission queue. Establish invocation scope only, call the supplied `run()` at most once and return its result. Defer actual authorisation to `admit`: queued execution rejoins receipts again before admission. This preserves host-scope-before-Pulses-queue ordering across UI and tool callers. Keep policy and credit consumption in `admitTransaction`, in the same native commit as task creation. Do not infer authorisation from request IDs. Existing direct `run()` callers retain their own host-authorisation boundary.
|
|
38
|
+
|
|
39
|
+
Execution concurrency defaults to two live Pulse coordinators, including accepted tasks recovered after restart. Different jobs queue oldest first and capacity is released after settlement. `setConcurrency(limit, context)` persists a positive integer limit. `configuration(context)` reads it. The initial `options.concurrency` applies only before a persisted limit exists. Native structured generation backoff deadlines delay further admissions. Other failures are reported, not reclassified as rate limits or replayed.
|
|
40
|
+
|
|
41
|
+
Each child pulse reuses one conversation. An actual optional-parent ID change creates one replacement after prior responsibility settles, preserving both histories and the same folder. Moving a binding's root with the same parent refreshes configuration and the current conversation's path association, not its identity. Prior replacement conversations keep their historical associations. No files are moved or deleted. Child completion writes passive context to the parent captured at admission, never an input or follow-up. An optional `writeResult` formatter receives the native outcome, title, answer text and deterministic request ID. It must return the settled native write receipt, which the coordinator persists in its native memo before finishing. Standalone results remain in the pulse conversation.
|
|
42
|
+
|
|
43
|
+
On removal, stop admissions and drain/close the Harness's native task invocations before awaiting `unbind()`. Keep the binding available while admitted settlement tasks run. The component owns its timer, not the host Harness. Interrupted side effects are not replayed by this scheduler; native submission receipts remain authoritative.
|
|
44
|
+
|
|
45
|
+
## Operational skill
|
|
46
|
+
|
|
47
|
+
The tool provides authoring guidance on demand through `{skill:true}`, outside the standing skill catalogue. The package also ships `skills/pulses-ops/SKILL.md`. `pulsesSkill(filePath, baseDir)` remains available for hosts that explicitly use the Skills catalogue. Supply the actual installed, execution-environment-visible asset paths for that descriptor; remote environments require explicit mounting. There is no implicit npm skill discovery or host filesystem escape.
|
|
48
|
+
|
|
49
|
+
## Source parity
|
|
50
|
+
|
|
51
|
+
The frontmatter parser and original schedule helpers come from Clawa revision `07fbb0ad71a08a864b285b01d512c2052861b91d`. See `NOTICE`. Quoting/booleans, supported duration units, local-time slots, initial-slot seeding, quiet-hour holding and manual checkpoint bypass retain those semantics. Durable cursor accounting adds coalesced missed periods and counts local calendar slots across daylight-saving changes. The `trigger` aliases, optional expiry and resident target are supported additions. Native atomic admission, persistent conversation reuse and passive result receipts replace Clawa's process-local execution transport. Files are never rewritten or relocated. Clawa's literal-ID collision policy is not carried across.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Context } from "@earendil-works/chord";
|
|
2
|
+
import { type Harness, type TaskId, type Tx } from "@earendil-works/pi-durable";
|
|
3
|
+
import type { PulsesOptions, PulseTrigger } from "./contract.ts";
|
|
4
|
+
import type { PulseDefinition } from "./definitions.ts";
|
|
5
|
+
import { type createRunTask } from "./tasks.ts";
|
|
6
|
+
/** Native task inputs are the request authority, not a second receipt ledger. */
|
|
7
|
+
export declare function admitted(tx: Tx, bindingKey: string, pulseId: string, requestId: string): Promise<TaskId<import("@earendil-works/chord").JsonValue> | undefined>;
|
|
8
|
+
export declare function validateConcurrency(limit: number): number;
|
|
9
|
+
export declare function createAdmission(host: () => Harness, options: PulsesOptions, Run: ReturnType<typeof createRunTask>, accepting: () => boolean): (definition: PulseDefinition, trigger: PulseTrigger, requestId: string, context: Context) => Promise<TaskId | undefined>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pulseAuthoring = "Create pulses/<self-explanatory-name>/PULSE.md in the workspace shown by pulses({}). Use a lowercase kebab-case folder name. Preserve its AGENTS.md, existing journals and artifacts. Read applicable workspace and pulse-local instructions. Native cwd remains the workspace root; use the explicit pulse-home path for local files.\n\nExample PULSE.md:\n---\ntitle: Check agreed sources\nschedule: every 5h\nenabled: true\nquietHours: 22:00-08:00\n---\nCheck the agreed sources for changes since the previous run.\nPost actionable findings to the designated available destination.\n\ntitle and schedule are required. Schedules: manual, every 30m, every 5h, every 2d, daily 09:00, weekly fri 17:00 or at <datetime>. Use an explicit timezone offset for a one-time timestamp when timezone matters. Daily and weekly times and quietHours use the runtime's local timezone. Checks run every five minutes. Existing trigger: manual needs no schedule; trigger: time requires one.\n\nenabled defaults to true. Set false to pause both scheduled and manual runs. quietHours is optional and accepts HH:MM-HH:MM, including overnight ranges. Manual runs bypass quiet hours without consuming recurrence checkpoints. Optional expiresAt stops new admissions at that datetime. Child execution is the default; target: resident requires an explicit host-supplied continuing resident. Leave unrelated frontmatter keys, comments and body conventions untouched.\n\nKeep the body a short SOP: the actual task, sources, destination and consequential limits. Do not duplicate general skill guidance or require skills the task does not need. Define concrete destinations only when available. The worker receives the body plus standard result-routing and procedural-feedback instructions; do not repeat them in definitions.\n\nUse ordinary file tools to edit definitions. Disable routines worth keeping for later; delete obsolete definitions without deleting their journals or artifacts. There is no authoring configuration API. pulses({}) lists paths and invalid-definition diagnostics. pulses({run: \"name\"}) requests an immediate run. Admission is not completion. Inspect native task and submission outcomes through the consuming app. Child results are passive context and never wake the parent; resident work reports in that conversation.\n\nTracked missed occurrences coalesce into one run per job with a count and period. Cover that period rather than replaying each occurrence. Host restrictions, concurrency and active responsibility can hold admission. Reenabling or readding seeds the current slot, not disabled history. Removed, expired or superseded pending work stays inspectable. Retrying the same native tool task rejoins its accepted request, even after definition edits or deletion. An interrupted external side effect may have an uncertain outcome; report that uncertainty rather than repeat it. Stop uses the consuming app's native controls. It aborts only the coordinator and its owned input, then settles its passive report. Removing a definition or component never deletes files or native history.";
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Context } from "@earendil-works/chord";
|
|
2
|
+
import type { ConversationId, SettledSubmissionRecord, TaskId, ToolExecutionApi, Tx } from "@earendil-works/pi-durable";
|
|
3
|
+
import type { PulseDefinition } from "./definitions.ts";
|
|
4
|
+
export type PulseBinding = {
|
|
5
|
+
key: string;
|
|
6
|
+
root: string;
|
|
7
|
+
parentConversationId?: ConversationId;
|
|
8
|
+
};
|
|
9
|
+
export type PulseSource = {
|
|
10
|
+
id: string;
|
|
11
|
+
text: string;
|
|
12
|
+
error?: string;
|
|
13
|
+
};
|
|
14
|
+
export type PulseRunRequest = {
|
|
15
|
+
bindingKey: string;
|
|
16
|
+
pulseId: string;
|
|
17
|
+
requestId: string;
|
|
18
|
+
};
|
|
19
|
+
export type PulseTrigger = "manual" | "scheduled";
|
|
20
|
+
export type PulseOccurrence = {
|
|
21
|
+
count: number;
|
|
22
|
+
startAt: number;
|
|
23
|
+
endAt: number;
|
|
24
|
+
};
|
|
25
|
+
export type PulseAdmission = {
|
|
26
|
+
binding: PulseBinding;
|
|
27
|
+
definition: PulseDefinition;
|
|
28
|
+
trigger: PulseTrigger;
|
|
29
|
+
requestId: string;
|
|
30
|
+
taskId: TaskId;
|
|
31
|
+
conversationId: ConversationId;
|
|
32
|
+
occurrence?: PulseOccurrence;
|
|
33
|
+
};
|
|
34
|
+
export type PulseAdmissionDecision = {
|
|
35
|
+
status: "accepted";
|
|
36
|
+
} | {
|
|
37
|
+
status: "blocked";
|
|
38
|
+
reason: string;
|
|
39
|
+
retryAt?: number;
|
|
40
|
+
};
|
|
41
|
+
export type PulseInputDelivery = {
|
|
42
|
+
conversationId: ConversationId;
|
|
43
|
+
taskId: TaskId;
|
|
44
|
+
requestId: string;
|
|
45
|
+
content: string;
|
|
46
|
+
};
|
|
47
|
+
/** The abort-before-dispatch case has a native task outcome but no submission receipt. */
|
|
48
|
+
export type PulseOutcome = SettledSubmissionRecord | {
|
|
49
|
+
status: "aborted";
|
|
50
|
+
};
|
|
51
|
+
export type PulseResultDelivery = {
|
|
52
|
+
parentConversationId: ConversationId;
|
|
53
|
+
conversationId: ConversationId;
|
|
54
|
+
taskId: TaskId;
|
|
55
|
+
outcome: PulseOutcome;
|
|
56
|
+
requestId: string;
|
|
57
|
+
title: string;
|
|
58
|
+
text: string;
|
|
59
|
+
occurrence?: PulseOccurrence;
|
|
60
|
+
};
|
|
61
|
+
export interface PulsesOptions {
|
|
62
|
+
/** Resolve the caller's authorised binding in api.env. Never infer from global bindings or host paths. */
|
|
63
|
+
resolveToolBinding?(api: ToolExecutionApi, context: Context): Promise<string>;
|
|
64
|
+
/** After receipt lookup, outside the admission queue. Establish caller scope only; defer actual authorisation to admit, since run() rejoins receipts again. Never infer authority from request IDs. admitTransaction owns atomic policy/credit with task creation. Call run at most once and return its result; no external side effects. */
|
|
65
|
+
withToolRunAuthorization?(api: ToolExecutionApi, request: PulseRunRequest, run: () => Promise<TaskId | undefined>, context: Context): Promise<TaskId | undefined>;
|
|
66
|
+
/** Initial limit only. Persisted changes through setConcurrency survive rebinding. */
|
|
67
|
+
concurrency?: number;
|
|
68
|
+
getBindings(context: Context): Promise<readonly PulseBinding[]>;
|
|
69
|
+
/** Read immediate pulse directories in the explicit execution environment. Never modify files. */
|
|
70
|
+
readDefinitions(binding: PulseBinding, context: Context): Promise<readonly PulseSource[]>;
|
|
71
|
+
/** Prepare environment data and preflight every new admission. Race-safe policy/credit belongs in admitTransaction. */
|
|
72
|
+
admit(binding: PulseBinding, definition: PulseDefinition, trigger: PulseTrigger, context: Context): Promise<void>;
|
|
73
|
+
/** Same native transaction as createTask. Blocked rolls back ALL changes, including policy credit. Use tx.doc only: table reads after createTask are forbidden. No filesystem, network, Harness reads or irreversible effects. Receipt retries bypass this hook. */
|
|
74
|
+
admitTransaction?(tx: Tx, admission: PulseAdmission, context: Context): Promise<PulseAdmissionDecision>;
|
|
75
|
+
/** Deliver already accepted work. Validate native task lineage and rejoin requestId before new input policy; return the actual settled input receipt. */
|
|
76
|
+
submitInput?(delivery: PulseInputDelivery, context: Context): Promise<SettledSubmissionRecord>;
|
|
77
|
+
/** Transaction-only configuration on every NEW child admission, never the resident target. Prepare data in admit. Use document operations only, no table reads or filesystem/model I/O. Configure cwd=root and fresh pulse-home instructions without accumulating old instructions; preserve native parent models/tools/extensions. */
|
|
78
|
+
configure(tx: Tx, conversationId: ConversationId, binding: PulseBinding, definition: PulseDefinition, creation: {
|
|
79
|
+
created: boolean;
|
|
80
|
+
}): Promise<void>;
|
|
81
|
+
/** Must submit type:write with requestId and await its native receipt. Never wake the parent. */
|
|
82
|
+
writeResult?(delivery: PulseResultDelivery, context: Context): Promise<SettledSubmissionRecord>;
|
|
83
|
+
onError(error: unknown): void;
|
|
84
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PulseBinding, PulseSource } from "./contract.ts";
|
|
2
|
+
import { type PulseQuietHours, type PulseSchedule } from "./schedule.ts";
|
|
3
|
+
type PulsePaths = {
|
|
4
|
+
id: string;
|
|
5
|
+
bindingKey: string;
|
|
6
|
+
root: string;
|
|
7
|
+
pulseHome: string;
|
|
8
|
+
path: string;
|
|
9
|
+
};
|
|
10
|
+
export type PulseDefinition = PulsePaths & {
|
|
11
|
+
status: "valid";
|
|
12
|
+
title: string;
|
|
13
|
+
scheduleText: string;
|
|
14
|
+
schedule: PulseSchedule;
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
target?: "child" | "resident";
|
|
17
|
+
expiresAt?: number;
|
|
18
|
+
quietHours?: PulseQuietHours;
|
|
19
|
+
body: string;
|
|
20
|
+
};
|
|
21
|
+
export type PulseCatalogItem = PulseDefinition | (PulsePaths & {
|
|
22
|
+
status: "invalid";
|
|
23
|
+
title: string;
|
|
24
|
+
error: string;
|
|
25
|
+
});
|
|
26
|
+
export declare function parsePulseDefinition(binding: PulseBinding, source: PulseSource): PulseCatalogItem;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { JsonValue } from "@earendil-works/chord";
|
|
2
|
+
import type { ConversationId, SubmissionRecord, TaskRecord, Tx } from "@earendil-works/pi-durable";
|
|
3
|
+
export type PulseExecutionRequest = {
|
|
4
|
+
bindingKey: string;
|
|
5
|
+
pulseId: string;
|
|
6
|
+
conversationId: ConversationId;
|
|
7
|
+
};
|
|
8
|
+
/** Latest admitted execution for this exact job and conversation, including historical targets. */
|
|
9
|
+
export declare function execution(tx: Tx, request: PulseExecutionRequest): Promise<{
|
|
10
|
+
task: TaskRecord<JsonValue, JsonValue, JsonValue>;
|
|
11
|
+
submission: Extract<SubmissionRecord, {
|
|
12
|
+
type: "input";
|
|
13
|
+
}> | undefined;
|
|
14
|
+
} | undefined>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { Context } from "@earendil-works/chord";
|
|
2
|
+
import { type Harness, type TaskId, type ToolExecutionApi } from "@earendil-works/pi-durable";
|
|
3
|
+
import type { PulseRunRequest, PulsesOptions } from "./contract.ts";
|
|
4
|
+
import { type PulseCatalogItem } from "./definitions.ts";
|
|
5
|
+
import { type PulseExecutionRequest } from "./execution.ts";
|
|
6
|
+
import { explicitReady } from "./occurrences.ts";
|
|
7
|
+
export type { PulseAdmission, PulseAdmissionDecision, PulseBinding, PulseInputDelivery, PulseOccurrence, PulseOutcome, PulseResultDelivery, PulseRunRequest, PulseSource, PulsesOptions, PulseTrigger, } from "./contract.ts";
|
|
8
|
+
export { type PulseCatalogItem, type PulseDefinition, parsePulseDefinition, } from "./definitions.ts";
|
|
9
|
+
export type { PulseExecutionRequest } from "./execution.ts";
|
|
10
|
+
export { parsePulseFrontmatter } from "./frontmatter.ts";
|
|
11
|
+
export { explicitReady } from "./occurrences.ts";
|
|
12
|
+
export { isPulseDue, isPulseQuietAt, type PulseQuietHours, type PulseSchedule, parsePulseQuietHours, parsePulseSchedule, pulseDueKey, } from "./schedule.ts";
|
|
13
|
+
export type { PulseCheckpoint, PulseDisposition, PulseReference, } from "./state.ts";
|
|
14
|
+
export type { PulseRunInput } from "./tasks.ts";
|
|
15
|
+
/** Supply the actual installed asset path mapped into the execution environment. Compatible with Skills' LoadedSkill. */
|
|
16
|
+
export declare function pulsesSkill(filePath: string, baseDir: string): {
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
filePath: string;
|
|
20
|
+
baseDir: string;
|
|
21
|
+
};
|
|
22
|
+
export declare function createPulses(options: PulsesOptions): {
|
|
23
|
+
extension: import("@earendil-works/pi-durable").Extension<{
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
parameters: import("typebox").TObject<{
|
|
27
|
+
run: import("typebox").TOptional<import("typebox").TString>;
|
|
28
|
+
skill: import("typebox").TOptional<import("typebox").TLiteral<true>>;
|
|
29
|
+
}>;
|
|
30
|
+
constrainedSampling?: false | import("@earendil-works/pi-ai").ConstrainedSamplingConfig;
|
|
31
|
+
replay?: "safe" | "unsafe";
|
|
32
|
+
executionMode?: import("@earendil-works/pi-durable").ToolExecutionMode;
|
|
33
|
+
prepareArguments?(args: unknown): {
|
|
34
|
+
run?: string;
|
|
35
|
+
skill?: true;
|
|
36
|
+
};
|
|
37
|
+
structuredOutputSchema?: import("typebox").TSchema;
|
|
38
|
+
callers?: readonly ("model" | "tools")[];
|
|
39
|
+
deferred?: true;
|
|
40
|
+
outputLimits?: {
|
|
41
|
+
readonly maxBytes?: number;
|
|
42
|
+
readonly maxLines?: number;
|
|
43
|
+
readonly retain?: "head" | "tail";
|
|
44
|
+
};
|
|
45
|
+
execute(args: {
|
|
46
|
+
run?: string;
|
|
47
|
+
skill?: true;
|
|
48
|
+
}, api: ToolExecutionApi<import("@earendil-works/chord").JsonValue>, context: Context): Promise<import("@earendil-works/pi-durable").ToolExecutionResult<import("@earendil-works/chord").JsonValue>>;
|
|
49
|
+
executionHints: {
|
|
50
|
+
discovery: "help";
|
|
51
|
+
};
|
|
52
|
+
}>;
|
|
53
|
+
tool: {
|
|
54
|
+
name: string;
|
|
55
|
+
description: string;
|
|
56
|
+
parameters: import("typebox").TObject<{
|
|
57
|
+
run: import("typebox").TOptional<import("typebox").TString>;
|
|
58
|
+
skill: import("typebox").TOptional<import("typebox").TLiteral<true>>;
|
|
59
|
+
}>;
|
|
60
|
+
constrainedSampling?: false | import("@earendil-works/pi-ai").ConstrainedSamplingConfig;
|
|
61
|
+
replay?: "safe" | "unsafe";
|
|
62
|
+
executionMode?: import("@earendil-works/pi-durable").ToolExecutionMode;
|
|
63
|
+
prepareArguments?(args: unknown): {
|
|
64
|
+
run?: string;
|
|
65
|
+
skill?: true;
|
|
66
|
+
};
|
|
67
|
+
structuredOutputSchema?: import("typebox").TSchema;
|
|
68
|
+
callers?: readonly ("model" | "tools")[];
|
|
69
|
+
deferred?: true;
|
|
70
|
+
outputLimits?: {
|
|
71
|
+
readonly maxBytes?: number;
|
|
72
|
+
readonly maxLines?: number;
|
|
73
|
+
readonly retain?: "head" | "tail";
|
|
74
|
+
};
|
|
75
|
+
execute(args: {
|
|
76
|
+
run?: string;
|
|
77
|
+
skill?: true;
|
|
78
|
+
}, api: ToolExecutionApi<import("@earendil-works/chord").JsonValue>, context: Context): Promise<import("@earendil-works/pi-durable").ToolExecutionResult<import("@earendil-works/chord").JsonValue>>;
|
|
79
|
+
executionHints: {
|
|
80
|
+
discovery: "help";
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
catalog: (context: Context, bindingKey?: string) => Promise<PulseCatalogItem[]>;
|
|
84
|
+
scan: (context: Context) => Promise<PulseCatalogItem[]>;
|
|
85
|
+
explicitReady: typeof explicitReady;
|
|
86
|
+
configuration(context: Context): Promise<{
|
|
87
|
+
concurrency: number;
|
|
88
|
+
}>;
|
|
89
|
+
setConcurrency(limit: number, context: Context): Promise<{
|
|
90
|
+
concurrency: number;
|
|
91
|
+
}>;
|
|
92
|
+
run(request: PulseRunRequest, context: Context): Promise<TaskId | undefined>;
|
|
93
|
+
/** Native task and input receipt for the latest run of this exact job/target. No receipt means not yet submitted. */
|
|
94
|
+
execution(request: PulseExecutionRequest, context: Context): Promise<{
|
|
95
|
+
task: import("@earendil-works/pi-durable").TaskRecord<import("@earendil-works/chord").JsonValue, import("@earendil-works/chord").JsonValue, import("@earendil-works/chord").JsonValue>;
|
|
96
|
+
submission: Extract<import("@earendil-works/pi-durable").SubmissionRecord, {
|
|
97
|
+
type: "input";
|
|
98
|
+
}> | undefined;
|
|
99
|
+
} | undefined>;
|
|
100
|
+
observe(context: Context): Promise<{
|
|
101
|
+
firstSeenAt: number;
|
|
102
|
+
scheduledEligible?: boolean;
|
|
103
|
+
scheduleKey?: string;
|
|
104
|
+
trackedAt?: number;
|
|
105
|
+
trackedSchedule?: import("./schedule.ts").PulseSchedule;
|
|
106
|
+
quietHours?: import("./schedule.ts").PulseQuietHours;
|
|
107
|
+
expiresAt?: number;
|
|
108
|
+
nextDueAt?: number;
|
|
109
|
+
pending?: import("./contract.ts").PulseOccurrence;
|
|
110
|
+
blocked?: {
|
|
111
|
+
reason: string;
|
|
112
|
+
retryAt?: number;
|
|
113
|
+
};
|
|
114
|
+
disposition?: import("./state.ts").PulseDisposition;
|
|
115
|
+
lastRunAt?: number;
|
|
116
|
+
lastDueKey?: string;
|
|
117
|
+
current?: import("./state.ts").PulseReference;
|
|
118
|
+
history: import("./state.ts").PulseReference[];
|
|
119
|
+
activeTask?: TaskId;
|
|
120
|
+
key: string;
|
|
121
|
+
task: import("@earendil-works/pi-durable").TaskRecord<import("@earendil-works/chord").JsonValue, import("@earendil-works/chord").JsonValue, unknown> | undefined;
|
|
122
|
+
}[]>;
|
|
123
|
+
stop(request: {
|
|
124
|
+
bindingKey: string;
|
|
125
|
+
pulseId: string;
|
|
126
|
+
}, context: Context): Promise<void>;
|
|
127
|
+
bind(value: Harness, context: Context): Promise<void>;
|
|
128
|
+
/** Stop admission first; host must drain/close native task invocations before releasing this binding. */
|
|
129
|
+
unbind(): Promise<void>;
|
|
130
|
+
};
|