@jdscript/opencode-notify 0.0.0-stage → 0.1.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/README.md +209 -2
- package/VERIFICATION.md +59 -0
- package/dist/crypto.d.ts +8 -0
- package/dist/crypto.js +63 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +96 -0
- package/dist/rpc.d.ts +199 -0
- package/dist/rpc.js +60 -0
- package/dist/sender.d.ts +73 -0
- package/dist/sender.js +847 -0
- package/dist/types.d.ts +75 -0
- package/dist/types.js +1 -0
- package/index.js +2 -0
- package/package.json +48 -4
package/dist/rpc.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Rpc } from "@opencode/plugin";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export const UUID = z
|
|
4
|
+
.string()
|
|
5
|
+
.uuid()
|
|
6
|
+
.regex(/^[0-9a-f-]{36}$/u);
|
|
7
|
+
const seconds = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
8
|
+
export const Subscribe = z
|
|
9
|
+
.object({
|
|
10
|
+
subscriptionID: UUID,
|
|
11
|
+
revision: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),
|
|
12
|
+
relayURL: z.string().url().max(2048),
|
|
13
|
+
sendToken: z.string().min(32).max(256),
|
|
14
|
+
expiresAt: seconds,
|
|
15
|
+
serverID: UUID,
|
|
16
|
+
installationID: UUID,
|
|
17
|
+
recipientPublicKey: z.string().length(87),
|
|
18
|
+
authSecret: z.string().length(22),
|
|
19
|
+
preferences: z.object({ completed: z.boolean(), requests: z.boolean(), failures: z.boolean() }).strict(),
|
|
20
|
+
})
|
|
21
|
+
.strict();
|
|
22
|
+
export const Reference = z.object({ subscriptionID: UUID }).strict();
|
|
23
|
+
export const Route = z.object({ subscriptionID: UUID, activityID: UUID }).strict();
|
|
24
|
+
export const Attach = Route.extend({
|
|
25
|
+
sessionID: z.string().startsWith("ses").max(200), expiresAt: seconds,
|
|
26
|
+
scope: z.enum(["session", "server", "workspace"]).optional(),
|
|
27
|
+
serverName: z.string().max(160).optional(),
|
|
28
|
+
seedComplete: z.boolean().optional(),
|
|
29
|
+
seeds: z.array(z.object({ sessionID: z.string().startsWith("ses").max(200), running: z.boolean(), waiting: z.array(z.string().max(200)).max(64) }).strict()).max(512).optional(),
|
|
30
|
+
shells: z.array(z.object({ id: z.string().max(200), sessionID: z.string().startsWith("ses").max(200).optional() }).strict()).max(512).optional(),
|
|
31
|
+
}).strict();
|
|
32
|
+
export const Status = z
|
|
33
|
+
.object({
|
|
34
|
+
subscriptionID: UUID,
|
|
35
|
+
revision: z.number().int().nonnegative(),
|
|
36
|
+
expiresAt: seconds,
|
|
37
|
+
state: z.enum(["active", "revoked", "expired", "unavailable"]),
|
|
38
|
+
})
|
|
39
|
+
.strict();
|
|
40
|
+
const errors = { invalid: z.object({ code: z.string() }).strict() };
|
|
41
|
+
const ok = z.object({ ok: z.literal(true) }).strict();
|
|
42
|
+
export const RPC_ID = "@jdscript/opencode-notify/mobile-push";
|
|
43
|
+
export const Definition = Rpc.define({
|
|
44
|
+
id: RPC_ID,
|
|
45
|
+
events: {},
|
|
46
|
+
methods: {
|
|
47
|
+
info: {
|
|
48
|
+
input: z.object({}).strict(),
|
|
49
|
+
output: z
|
|
50
|
+
.object({ version: z.literal(1), encoding: z.literal("aes128gcm"), applicationVersion: z.literal(1), activityScopes: z.array(z.enum(["session", "server", "workspace"])).optional() })
|
|
51
|
+
.strict(),
|
|
52
|
+
errors,
|
|
53
|
+
},
|
|
54
|
+
subscribe: { input: Subscribe, output: Status, errors },
|
|
55
|
+
unsubscribe: { input: Reference, output: ok, errors },
|
|
56
|
+
status: { input: Reference, output: Status, errors },
|
|
57
|
+
attach: { input: Attach, output: ok, errors },
|
|
58
|
+
detach: { input: Route, output: ok, errors },
|
|
59
|
+
},
|
|
60
|
+
});
|
package/dist/sender.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Subscribe, type Attach } from "./rpc.js";
|
|
2
|
+
import type { Event, SessionInfo, Storage } from "./types.js";
|
|
3
|
+
export declare class SenderError extends Error {
|
|
4
|
+
readonly code: string;
|
|
5
|
+
constructor(code: string);
|
|
6
|
+
}
|
|
7
|
+
/** One process-wide sender, shared by the plugin's location registrations. */
|
|
8
|
+
export declare class Sender {
|
|
9
|
+
private readonly storage;
|
|
10
|
+
private readonly getSession;
|
|
11
|
+
private readonly waitSession?;
|
|
12
|
+
private readonly subscriptions;
|
|
13
|
+
private readonly activities;
|
|
14
|
+
private readonly jobs;
|
|
15
|
+
private readonly nodes;
|
|
16
|
+
private readonly shells;
|
|
17
|
+
private readonly observedShells;
|
|
18
|
+
private readonly dirty;
|
|
19
|
+
private readonly receipts;
|
|
20
|
+
private cleanedAt;
|
|
21
|
+
private chain;
|
|
22
|
+
private timer?;
|
|
23
|
+
private flushing;
|
|
24
|
+
private stopped;
|
|
25
|
+
private workspaceKnown;
|
|
26
|
+
private quietSince?;
|
|
27
|
+
private readonly waitingForIdle;
|
|
28
|
+
private waitGeneration;
|
|
29
|
+
private readonly abort;
|
|
30
|
+
constructor(storage: Storage, getSession: (id: string) => Promise<SessionInfo>, waitSession?: ((id: string) => Promise<void>) | undefined);
|
|
31
|
+
start(): Promise<void>;
|
|
32
|
+
stop(): Promise<void>;
|
|
33
|
+
status(id: string): {
|
|
34
|
+
subscriptionID: string;
|
|
35
|
+
revision: number;
|
|
36
|
+
expiresAt: number;
|
|
37
|
+
state: "active" | "revoked" | "expired" | "unavailable";
|
|
38
|
+
};
|
|
39
|
+
subscribe(input: Subscribe): Promise<{
|
|
40
|
+
subscriptionID: string;
|
|
41
|
+
revision: number;
|
|
42
|
+
expiresAt: number;
|
|
43
|
+
state: "active" | "revoked" | "expired" | "unavailable";
|
|
44
|
+
}>;
|
|
45
|
+
unsubscribe(id: string): Promise<{
|
|
46
|
+
ok: true;
|
|
47
|
+
}>;
|
|
48
|
+
attach(input: Attach): Promise<{
|
|
49
|
+
ok: true;
|
|
50
|
+
}>;
|
|
51
|
+
detach(subscriptionID: string, activityID: string): Promise<{
|
|
52
|
+
ok: true;
|
|
53
|
+
}>;
|
|
54
|
+
/** Semantic events only: no reasoning/text deltas, transcripts, tool arguments or outputs. */
|
|
55
|
+
onEvent(event: Event): Promise<void>;
|
|
56
|
+
private node;
|
|
57
|
+
observationUnavailable(): void;
|
|
58
|
+
private root;
|
|
59
|
+
private within;
|
|
60
|
+
private content;
|
|
61
|
+
private queueAlert;
|
|
62
|
+
private watchIdle;
|
|
63
|
+
private workspaceContent;
|
|
64
|
+
private queueActivity;
|
|
65
|
+
private queue;
|
|
66
|
+
private schedule;
|
|
67
|
+
tick(): Promise<void>;
|
|
68
|
+
private requireSubscription;
|
|
69
|
+
private serial;
|
|
70
|
+
private save;
|
|
71
|
+
private removeJob;
|
|
72
|
+
private removeJobIfCurrent;
|
|
73
|
+
}
|