@vibest/plugin 0.0.1-beta.16 → 0.0.1-beta.17
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/package.json +1 -1
- package/src/index.ts +24 -24
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -36,6 +36,30 @@ export interface SubscriptionSnapshot {
|
|
|
36
36
|
readonly error?: string | undefined
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
/** One login is limited when any of its usage windows is; no rows means unknown, not limited. */
|
|
40
|
+
export const isLimited = (row: { readonly limits: ReadonlyArray<{ readonly status: string }> }) =>
|
|
41
|
+
row.limits.some((l) => l.status === "limited")
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A remembered limit still rules its login out until that login's own row was refreshed after it and says it is fine
|
|
45
|
+
* again. A login with no row, or none named by the attempt, keeps the plain memory.
|
|
46
|
+
*/
|
|
47
|
+
export const stillLimited = (
|
|
48
|
+
attempt: { readonly harness: string; readonly provider: string | undefined; readonly at: number },
|
|
49
|
+
rows: ReadonlyArray<{
|
|
50
|
+
readonly harness: string
|
|
51
|
+
readonly provider: string
|
|
52
|
+
readonly updatedAt: number
|
|
53
|
+
readonly limits: ReadonlyArray<{ readonly status: string }>
|
|
54
|
+
}>,
|
|
55
|
+
) => {
|
|
56
|
+
const row =
|
|
57
|
+
attempt.provider === undefined
|
|
58
|
+
? undefined
|
|
59
|
+
: rows.find((r) => r.harness === attempt.harness && r.provider === attempt.provider)
|
|
60
|
+
return !(row !== undefined && row.updatedAt > attempt.at && !isLimited(row))
|
|
61
|
+
}
|
|
62
|
+
|
|
39
63
|
/** Limits a plugin reports for one `(harness, provider)`. The next poll of a harness that reads usage replaces them. */
|
|
40
64
|
export interface SubscriptionReport {
|
|
41
65
|
readonly harness: string
|
|
@@ -126,34 +150,10 @@ export interface AgentFail extends AgentContext {
|
|
|
126
150
|
move: { harness: string; provider?: string | undefined; model?: string | undefined } | undefined
|
|
127
151
|
}
|
|
128
152
|
|
|
129
|
-
/**
|
|
130
|
-
* A subagent's round is about to go idle. Set `prompt` to keep it working on that text instead.
|
|
131
|
-
* `prompt` is the only decision. `output` is a failure tail and does not stop the chain.
|
|
132
|
-
*/
|
|
133
|
-
export interface AgentIdle {
|
|
134
|
-
readonly sessionId: string
|
|
135
|
-
/** `main` for the project's main agent, otherwise the definition (`general`, …). */
|
|
136
|
-
readonly agentType: string
|
|
137
|
-
/** The directory the agent works in. */
|
|
138
|
-
readonly directory: string
|
|
139
|
-
/** The agent's last answer. */
|
|
140
|
-
readonly answer: string
|
|
141
|
-
/** Finished check attempts for this session, counted by the host. The plugin only compares it to its limit. */
|
|
142
|
-
readonly checkAttempts: number
|
|
143
|
-
/** Set once this result's command has finished. The plugin must not ask to run it again. */
|
|
144
|
-
readonly ran: { readonly ok: boolean; readonly tail: string } | undefined
|
|
145
|
-
/** Set when the host should run this command outside the lock. Not a decision. */
|
|
146
|
-
command: string | undefined
|
|
147
|
-
prompt: string | undefined
|
|
148
|
-
/** Tail of a failing check once the attempt budget is spent. Not a decision. */
|
|
149
|
-
output: string | undefined
|
|
150
|
-
}
|
|
151
|
-
|
|
152
153
|
/** Every hook: the event its callbacks get and the error they may fail with. */
|
|
153
154
|
export interface Hooks {
|
|
154
155
|
readonly "agent.start.before": { readonly event: AgentStartBefore; readonly error: AgentRefused }
|
|
155
156
|
readonly "agent.fail": { readonly event: AgentFail; readonly error: never }
|
|
156
|
-
readonly "agent.idle": { readonly event: AgentIdle; readonly error: never }
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
/** The hook names of one domain without its prefix: `start.before` for `agent.start.before`. */
|