@ai-ecoverse/slicc-agent 3.3.0 → 3.4.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.
Files changed (62) hide show
  1. package/README.md +37 -1
  2. package/dist/control.js +44 -1
  3. package/dist/control.js.map +2 -2
  4. package/dist/host.js +5 -1
  5. package/dist/host.js.map +2 -2
  6. package/dist/kernel/activity.js +39 -0
  7. package/dist/kernel/activity.js.map +7 -0
  8. package/dist/kernel/env.js +16 -8
  9. package/dist/kernel/env.js.map +2 -2
  10. package/dist/licks/boot.js +66 -0
  11. package/dist/licks/boot.js.map +7 -0
  12. package/dist/licks/config.js +126 -0
  13. package/dist/licks/config.js.map +7 -0
  14. package/dist/licks/cron.js +120 -0
  15. package/dist/licks/cron.js.map +7 -0
  16. package/dist/licks/extension.js +123 -0
  17. package/dist/licks/extension.js.map +7 -0
  18. package/dist/licks/fswatch.js +149 -0
  19. package/dist/licks/fswatch.js.map +7 -0
  20. package/dist/licks/glob.js +47 -0
  21. package/dist/licks/glob.js.map +7 -0
  22. package/dist/licks/index.js +36 -0
  23. package/dist/licks/index.js.map +7 -0
  24. package/dist/licks/lick.js +102 -0
  25. package/dist/licks/lick.js.map +7 -0
  26. package/dist/licks/licks.js +181 -0
  27. package/dist/licks/licks.js.map +7 -0
  28. package/dist/licks/schedules.js +50 -0
  29. package/dist/licks/schedules.js.map +7 -0
  30. package/dist/licks/sources.js +138 -0
  31. package/dist/licks/sources.js.map +7 -0
  32. package/dist/licks/state.js +56 -0
  33. package/dist/licks/state.js.map +7 -0
  34. package/dist/main.js +23 -4
  35. package/dist/main.js.map +2 -2
  36. package/dist/services.js.map +2 -2
  37. package/dist/spectrum/agent-port.js +6 -1
  38. package/dist/spectrum/agent-port.js.map +2 -2
  39. package/dist/spectrum/messages.js +29 -5
  40. package/dist/spectrum/messages.js.map +2 -2
  41. package/dist/system.js +16 -0
  42. package/dist/system.js.map +2 -2
  43. package/dist/types/control.d.ts +6 -1
  44. package/dist/types/host.d.ts +2 -0
  45. package/dist/types/kernel/activity.d.ts +10 -0
  46. package/dist/types/kernel/env.d.ts +2 -0
  47. package/dist/types/licks/boot.d.ts +9 -0
  48. package/dist/types/licks/config.d.ts +35 -0
  49. package/dist/types/licks/cron.d.ts +16 -0
  50. package/dist/types/licks/extension.d.ts +22 -0
  51. package/dist/types/licks/fswatch.d.ts +20 -0
  52. package/dist/types/licks/glob.d.ts +1 -0
  53. package/dist/types/licks/index.d.ts +24 -0
  54. package/dist/types/licks/lick.d.ts +21 -0
  55. package/dist/types/licks/licks.d.ts +56 -0
  56. package/dist/types/licks/schedules.d.ts +25 -0
  57. package/dist/types/licks/sources.d.ts +38 -0
  58. package/dist/types/licks/state.d.ts +14 -0
  59. package/dist/types/services.d.ts +18 -0
  60. package/dist/types/spectrum/agent-port.d.ts +1 -1
  61. package/dist/types/system.d.ts +1 -0
  62. package/package.json +1 -1
@@ -0,0 +1,35 @@
1
+ import type { LickTarget } from './lick.ts';
2
+ export interface CronEntry {
3
+ name: string;
4
+ schedule: string;
5
+ target: LickTarget;
6
+ message: string;
7
+ }
8
+ export interface WatchEntry {
9
+ name: string;
10
+ path: string;
11
+ glob: string;
12
+ target: LickTarget;
13
+ message: string;
14
+ debounce: number;
15
+ }
16
+ export interface WebhookEntry {
17
+ name: string;
18
+ target: LickTarget;
19
+ message: string;
20
+ }
21
+ export interface ConfigError {
22
+ file: string;
23
+ line?: number;
24
+ error: string;
25
+ }
26
+ export interface Parsed<T> {
27
+ entries: T[];
28
+ errors: ConfigError[];
29
+ }
30
+ export declare function isName(value: string): boolean;
31
+ export declare function isTarget(value: string): value is LickTarget;
32
+ export declare function parseCrontab(file: string, text: string): Parsed<CronEntry>;
33
+ export declare function nameOf(file: string): string;
34
+ export declare function parseWatch(file: string, source: string, home: string): WatchEntry;
35
+ export declare function parseWebhook(file: string, source: string): WebhookEntry;
@@ -0,0 +1,16 @@
1
+ export interface Schedule {
2
+ minutes: ReadonlySet<number>;
3
+ hours: ReadonlySet<number>;
4
+ days: ReadonlySet<number>;
5
+ months: ReadonlySet<number>;
6
+ weekdays: ReadonlySet<number>;
7
+ anyDay: boolean;
8
+ anyWeekday: boolean;
9
+ }
10
+ export declare function parseSchedule(expression: string): Schedule;
11
+ export declare function nextFire(schedule: Schedule, after: number): number | null;
12
+ export interface Missed {
13
+ count: number;
14
+ more: boolean;
15
+ }
16
+ export declare function missedFires(schedule: Schedule, from: number, until: number, cap?: number): Missed;
@@ -0,0 +1,22 @@
1
+ import type { Context } from '@earendil-works/chord';
2
+ import { type Conversation, type ConversationId } from '@earendil-works/pi-durable';
3
+ import { type Missed } from './cron.ts';
4
+ import type { LickTarget } from './lick.ts';
5
+ import type { Licks } from './licks.ts';
6
+ export declare const LICKS_SECTION: string;
7
+ export type ConversationLookup = (id: ConversationId, context: Context) => Promise<Conversation>;
8
+ export interface CronInput {
9
+ name: string;
10
+ schedule: string;
11
+ target: LickTarget;
12
+ message: string;
13
+ from: number;
14
+ }
15
+ type CronState = {
16
+ phase: 'wait';
17
+ at: number | null;
18
+ };
19
+ export declare function cronText(schedule: string, at: number, missed: Missed): string;
20
+ export declare function cronTask(licks: Licks): import("@earendil-works/pi-durable").Task<CronInput, CronState, null, object>;
21
+ export declare function licksExtension(licks: Licks, conversation: ConversationLookup, cron?: ReturnType<typeof cronTask>): import("@earendil-works/pi-durable").Extension<import("@earendil-works/pi-durable").ToolRegistration>;
22
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { Context } from '@earendil-works/chord';
2
+ import type { ExecutionEnv } from '@earendil-works/pi-durable/env';
3
+ import type { Activity } from '../kernel/activity.ts';
4
+ import { type ConfigError } from './config.ts';
5
+ import type { LickEvent } from './licks.ts';
6
+ export interface ConfigFiles {
7
+ read(path: string, context: Context): Promise<string | undefined>;
8
+ list(path: string, context: Context): Promise<string[]>;
9
+ }
10
+ export type Deliver = (event: LickEvent, context: Context) => Promise<void>;
11
+ export declare function relativeTo(base: string, path: string): string | undefined;
12
+ export declare function configFiles(env: ExecutionEnv): ConfigFiles;
13
+ export declare class Watches {
14
+ #private;
15
+ constructor(env: ExecutionEnv, deliver: Deliver, home: string, activity?: Activity);
16
+ get names(): string[];
17
+ stop(name: string, context: Context): Promise<void>;
18
+ reconcile(dir: string, context: Context): Promise<ConfigError[]>;
19
+ close(context: Context): Promise<void>;
20
+ }
@@ -0,0 +1 @@
1
+ export declare function glob(pattern: string): (path: string) => boolean;
@@ -0,0 +1,24 @@
1
+ import type { Conversation, Harness, Registry } from '@earendil-works/pi-durable';
2
+ import type { ExecutionEnv } from '@earendil-works/pi-durable/env';
3
+ import type { Activity } from '../kernel/activity.ts';
4
+ import { type Licks } from './licks.ts';
5
+ import { type LickSources } from './sources.ts';
6
+ export interface LicksAgent {
7
+ harness: Harness;
8
+ root: Conversation;
9
+ cone(): Conversation;
10
+ }
11
+ export interface LicksSetup {
12
+ licks: Licks;
13
+ attach(agent: LicksAgent, options: {
14
+ env: ExecutionEnv;
15
+ home: string;
16
+ now?: () => number;
17
+ flushEvery?: number;
18
+ activity?: Activity;
19
+ }): LickSources;
20
+ }
21
+ export declare function setupLicks(registry: Registry): LicksSetup;
22
+ export type { Lick, LickChannel } from './lick.ts';
23
+ export type { LickEvent, Licks } from './licks.ts';
24
+ export type { LickSources, WebhookDelivery } from './sources.ts';
@@ -0,0 +1,21 @@
1
+ export declare const LICK_CHANNELS: readonly ['webhook', 'cron', 'sprinkle', 'fswatch', 'session-reload', 'navigate', 'discovery', 'upgrade', 'workflow', 'bash', 'jshd', 'preview', 'cherry', 'scoop-notify', 'scoop-idle', 'scoop-wait', 'sudo-request'];
2
+ export type LickChannel = (typeof LICK_CHANNELS)[number];
3
+ export type LickAction = 'confirm' | 'dismiss';
4
+ export type LickTarget = 'cone' | `scoop:${string}`;
5
+ export type Lick = {
6
+ id: string;
7
+ channel: LickChannel;
8
+ source: string;
9
+ title: string;
10
+ text: string;
11
+ body?: string;
12
+ count: number;
13
+ at: number;
14
+ actions?: LickAction[];
15
+ };
16
+ export declare function escapeText(value: string): string;
17
+ export declare function escapeAttribute(value: string): string;
18
+ export declare function unescape(value: string): string;
19
+ export declare function lickId(): string;
20
+ export declare function formatLick(lick: Lick): string;
21
+ export declare function parseLick(text: string): Lick | undefined;
@@ -0,0 +1,56 @@
1
+ import type { Context } from '@earendil-works/chord';
2
+ import { type Conversation, type Harness } from '@earendil-works/pi-durable';
3
+ import { type Lick, type LickAction, type LickChannel, type LickTarget } from './lick.ts';
4
+ import { LICK_STATE_KIND, type LickDecision } from './state.ts';
5
+ export interface LickEvent {
6
+ channel: LickChannel;
7
+ source: string;
8
+ title: string;
9
+ text: string;
10
+ body?: string;
11
+ items?: string[];
12
+ count?: number;
13
+ target: LickTarget;
14
+ coalesce?: boolean;
15
+ eventId?: string;
16
+ at?: number;
17
+ }
18
+ type Pending = {
19
+ lick: Lick;
20
+ items: string[];
21
+ body: string | null;
22
+ };
23
+ type Queue = {
24
+ submission: number | null;
25
+ pending: Pending | null;
26
+ };
27
+ type OutboxState = {
28
+ queues: Record<string, Queue>;
29
+ events: Record<string, string[]>;
30
+ };
31
+ export declare const LicksOutbox: import("@earendil-works/pi-durable").SessionDocToken<OutboxState>;
32
+ export interface LickHandler {
33
+ confirm?(lick: Lick, reason: string | undefined, context: Context): Promise<string | undefined>;
34
+ dismiss?(lick: Lick, reason: string | undefined, context: Context): Promise<string | undefined>;
35
+ }
36
+ export interface LickFound {
37
+ lick: Lick;
38
+ decision: LickDecision | undefined;
39
+ }
40
+ export interface Licks {
41
+ deliver(event: LickEvent, context: Context): Promise<void>;
42
+ flush(context: Context): Promise<void>;
43
+ find(conversation: Conversation, id: string, context: Context): Promise<LickFound | undefined>;
44
+ decide(conversation: Conversation, id: string, action: LickAction, reason: string | undefined, context: Context): Promise<string>;
45
+ handle(channel: LickChannel, handler: LickHandler): void;
46
+ pending(context: Context): Promise<number>;
47
+ }
48
+ export interface LicksHost {
49
+ harness: Harness;
50
+ resolve(target: LickTarget, context: Context): Promise<Conversation>;
51
+ }
52
+ export declare const MAX_ITEMS = 50;
53
+ export declare const MAX_EVENTS = 64;
54
+ export declare function render(pending: Pending): Lick;
55
+ export declare function createLicks(host: Promise<LicksHost>): Licks;
56
+ export { LICK_STATE_KIND };
@@ -0,0 +1,25 @@
1
+ import type { Context } from '@earendil-works/chord';
2
+ import { type Conversation, type Harness } from '@earendil-works/pi-durable';
3
+ import type { CronEntry } from './config.ts';
4
+ import type { cronTask } from './extension.ts';
5
+ type CronRecord = {
6
+ schedule: string;
7
+ target: string;
8
+ message: string;
9
+ task: number;
10
+ };
11
+ type HostState = {
12
+ cron: Record<string, CronRecord>;
13
+ agent: string | null;
14
+ boot: string | null;
15
+ mark: number;
16
+ upgrades: number;
17
+ };
18
+ export declare const LicksHostDoc: import("@earendil-works/pi-durable").SessionDocToken<HostState>;
19
+ export declare function reconcileCron(options: {
20
+ harness: Harness;
21
+ root: Conversation;
22
+ cron: ReturnType<typeof cronTask>;
23
+ now: () => number;
24
+ }, entries: readonly CronEntry[], context: Context): Promise<void>;
25
+ export {};
@@ -0,0 +1,38 @@
1
+ import type { Context } from '@earendil-works/chord';
2
+ import type { Conversation, Harness } from '@earendil-works/pi-durable';
3
+ import type { ExecutionEnv } from '@earendil-works/pi-durable/env';
4
+ import type { Activity } from '../kernel/activity.ts';
5
+ import { type BootFacts } from './boot.ts';
6
+ import { type ConfigError, type WebhookEntry } from './config.ts';
7
+ import type { cronTask } from './extension.ts';
8
+ import type { LickEvent, Licks } from './licks.ts';
9
+ export declare const SLICC_DIR = ".slicc";
10
+ export interface LickSourcesOptions {
11
+ harness: Harness;
12
+ root: Conversation;
13
+ cone: () => Conversation;
14
+ env: ExecutionEnv;
15
+ home: string;
16
+ licks: Licks;
17
+ cron: ReturnType<typeof cronTask>;
18
+ now?: () => number;
19
+ flushEvery?: number;
20
+ activity?: Activity;
21
+ }
22
+ export interface WebhookDelivery {
23
+ id?: string;
24
+ headers?: Record<string, string>;
25
+ body: unknown;
26
+ }
27
+ export interface LickSources {
28
+ start(context: Context): Promise<void>;
29
+ reconcile(context: Context): Promise<void>;
30
+ boot(facts: BootFacts, context: Context): Promise<void>;
31
+ webhook(name: string, delivery: WebhookDelivery, context: Context): Promise<boolean>;
32
+ close(context: Context): Promise<void>;
33
+ }
34
+ export declare function hash(text: string): string;
35
+ export declare function shortPath(path: string, home: string): string;
36
+ export declare function configLick(error: ConfigError, home: string): LickEvent;
37
+ export declare function webhookLick(name: string, entry: WebhookEntry, delivery: WebhookDelivery): LickEvent;
38
+ export declare function createLickSources(options: LickSourcesOptions): LickSources;
@@ -0,0 +1,14 @@
1
+ import { type Lick } from './lick.ts';
2
+ export type LickDecision = 'confirmed' | 'dismissed';
3
+ export declare const LICK_TOOLS: Record<string, LickDecision>;
4
+ export declare const LICK_STATE_KIND = "slicc.lick-state";
5
+ interface EntryLike {
6
+ id: number;
7
+ kind: string;
8
+ model?: readonly unknown[];
9
+ data?: unknown;
10
+ }
11
+ export declare function userText(entry: EntryLike): string | undefined;
12
+ export declare function entryLick(entry: EntryLike): Lick | undefined;
13
+ export declare function lickDecisions(entries: readonly EntryLike[]): Map<string, LickDecision>;
14
+ export {};
@@ -39,6 +39,24 @@ export interface AgentControl {
39
39
  reset(handoff: string | null, context: Context): Promise<void>;
40
40
  configure(change: AgentSettingsChange, context: Context): Promise<void>;
41
41
  rewind(messageId: string | null, context: Context): Promise<Rewound>;
42
+ resolveLick(lickId: string, state: 'confirmed' | 'dismissed', context: Context): Promise<LickResolved>;
43
+ webhook(name: string, delivery: WebhookRequest, context: Context): Promise<{
44
+ delivered: boolean;
45
+ }>;
46
+ }
47
+ export type LickResolved = {
48
+ done: true;
49
+ text: string;
50
+ error: null;
51
+ } | {
52
+ done: false;
53
+ text: null;
54
+ error: string;
55
+ };
56
+ export interface WebhookRequest {
57
+ id: string | null;
58
+ headers: Record<string, string>;
59
+ body: string;
42
60
  }
43
61
  export type Rewound = {
44
62
  done: true;
@@ -18,7 +18,7 @@ export declare class AgentAdapter extends Emitter<AgentEvents> implements AgentP
18
18
  unqueue(_agentId: string, messageId: string): void;
19
19
  suggestion(): string | null;
20
20
  answer(): void;
21
- resolveLick(): void;
21
+ resolveLick(_agentId: string, messageId: string, state: 'confirmed' | 'dismissed'): void;
22
22
  compact(): void;
23
23
  clear(): void;
24
24
  setModel(_agentId: string, model: string): void;
@@ -9,3 +9,4 @@ export declare function commandsOnPath(client: KernelClient): Promise<string[]>;
9
9
  export declare function transportName(transport: Transport | undefined): string;
10
10
  export declare function agentVersion(fetcher: (url: URL) => Promise<Response>, url?: URL): Promise<string>;
11
11
  export declare function systemSection(facts: SystemFacts): string;
12
+ export declare function kernelBoot(client: KernelClient): Promise<string | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-agent",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "description": "SLICC's agent core on pi durable: an agent worker, session storage, remoting and pi extensions",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",