shadok-ai 0.17.52 → 0.17.54
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 +7 -0
- package/context/instance-context-skill/SKILL.md +46 -0
- package/context/instance-context-skill/scripts/write.mjs +35 -0
- package/dist/config.d.ts +8 -0
- package/dist/config.js +18 -0
- package/dist/config.js.map +1 -1
- package/dist/greeting.d.ts +9 -0
- package/dist/greeting.js +17 -0
- package/dist/greeting.js.map +1 -1
- package/dist/instance-context.d.ts +32 -0
- package/dist/instance-context.js +47 -0
- package/dist/instance-context.js.map +1 -0
- package/dist/preprompt.d.ts +2 -0
- package/dist/preprompt.js +13 -18
- package/dist/preprompt.js.map +1 -1
- package/dist/server.js +98 -2
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
- package/public/index.html +99 -0
package/README.md
CHANGED
|
@@ -104,6 +104,13 @@ Enter to skip; you can add it later from the web UI).
|
|
|
104
104
|
stay collapsed, so the picker says so. There is deliberately no thinking
|
|
105
105
|
on/off switch: current models always think, and the settings that used to
|
|
106
106
|
disable it are ignored by them — a toggle would change nothing.
|
|
107
|
+
- **Instance context** — a handful of lines every agent on this cockpit
|
|
108
|
+
receives at spawn, ahead of its role: what the instance is for, who works on
|
|
109
|
+
it, its language. On a new instance the lead agent asks two or three questions
|
|
110
|
+
in its first message and writes it once; after that only a human edits it
|
|
111
|
+
(version menu → **🧭 Instance context…**). Running agents see a change at their
|
|
112
|
+
next reload. If it is still empty, **Ask general to draft it** runs the same
|
|
113
|
+
short interview.
|
|
107
114
|
- **Agent profiles** — a named bundle of role prompt, permission guardrails
|
|
108
115
|
(e.g. forbid `git commit`), model, and which secrets to inject. Applied at
|
|
109
116
|
spawn, remembered across resume. A profile can also carry **MCP servers**
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: shadok-instance-context
|
|
3
|
+
description: Write this cockpit's instance context — the few lines every agent here receives at spawn (what the instance is for, who uses it, its language). Use ONLY when you are the lead agent and it is still empty (first run, or when asked to draft it). Never to change it afterwards.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# shadok-instance-context
|
|
7
|
+
|
|
8
|
+
Every agent on this cockpit receives a short **instance context** in its system
|
|
9
|
+
prompt: what this instance is for, who works on it, the language, and anything
|
|
10
|
+
that should shape every agent's work. Roles say *how* to work; this says *what
|
|
11
|
+
for*.
|
|
12
|
+
|
|
13
|
+
## Write it once
|
|
14
|
+
|
|
15
|
+
Only the lead agent (the instance's home channel) can write it, and only while
|
|
16
|
+
it is empty — the server refuses anything else. Write it after asking the
|
|
17
|
+
person, never from a guess:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
node ~/.claude/skills/shadok-instance-context/scripts/write.mjs --stdin <<'CTX'
|
|
21
|
+
This instance runs side projects with a few friends, to try to get small
|
|
22
|
+
businesses off the ground. Each person may start their own project.
|
|
23
|
+
Language: French in conversation; code, commits and docs in English.
|
|
24
|
+
CTX
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Keep it to **a handful of lines**:
|
|
28
|
+
- the purpose of the instance;
|
|
29
|
+
- the people involved, by role or first name;
|
|
30
|
+
- the **language**: deduce it from the language the person answered you in;
|
|
31
|
+
ask only if you cannot tell. If deliverables (code, docs, commits) use another
|
|
32
|
+
language than the conversation, say both;
|
|
33
|
+
- any tone or constraint every agent should respect.
|
|
34
|
+
|
|
35
|
+
No project wiki, no status, no secrets — the shared ledger is the place for
|
|
36
|
+
status, the vault for credentials.
|
|
37
|
+
|
|
38
|
+
Then show the person what you saved in a few lines, and tell them they can edit
|
|
39
|
+
it from the cockpit menu (**Instance context…**).
|
|
40
|
+
|
|
41
|
+
## Afterwards: suggest, never rewrite
|
|
42
|
+
|
|
43
|
+
Once it is set, nobody but a human changes it. If you learn something that
|
|
44
|
+
makes it wrong (a new person joins, the focus moves), **suggest** the new
|
|
45
|
+
wording in the chat and point to the cockpit menu. Do not try to write it
|
|
46
|
+
again — the server will refuse, and that refusal is the design.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Write the instance context ONCE — the short text every agent on this cockpit
|
|
3
|
+
// receives at spawn. The server accepts it only from the lead agent (the home
|
|
4
|
+
// channel) and only while it is empty; afterwards humans own it.
|
|
5
|
+
//
|
|
6
|
+
// The text comes on stdin, never on the command line: it can be long, and a
|
|
7
|
+
// quote or a newline in argv is a quoting accident waiting to happen.
|
|
8
|
+
const die = (m) => { console.error(m); process.exit(1); };
|
|
9
|
+
const args = process.argv.slice(2);
|
|
10
|
+
if (args.length !== 1 || args[0] !== "--stdin")
|
|
11
|
+
die('usage: write.mjs --stdin (pipe the text in, e.g. with a heredoc)');
|
|
12
|
+
|
|
13
|
+
const port = process.env.SHADOK_PORT;
|
|
14
|
+
const key = process.env.SHADOK_SESSION_KEY;
|
|
15
|
+
if (!port) die("Not inside a shadok-ai agent (SHADOK_PORT unset).");
|
|
16
|
+
if (!key) die("SHADOK_SESSION_KEY is unset — ask the human to reload this agent.");
|
|
17
|
+
|
|
18
|
+
let text = "";
|
|
19
|
+
for await (const chunk of process.stdin) text += chunk;
|
|
20
|
+
if (!text.trim()) die("Nothing on stdin — pipe the instance context in.");
|
|
21
|
+
|
|
22
|
+
let res;
|
|
23
|
+
try {
|
|
24
|
+
res = await fetch(`http://127.0.0.1:${port}/instance-context/first`, {
|
|
25
|
+
method: "PUT",
|
|
26
|
+
headers: { "content-type": "application/json", "x-shadok-session-key": key },
|
|
27
|
+
body: JSON.stringify({ text }),
|
|
28
|
+
signal: AbortSignal.timeout(15_000),
|
|
29
|
+
});
|
|
30
|
+
} catch (e) {
|
|
31
|
+
die(`The cockpit did not answer (${e?.message ?? e}). Say so rather than working around it.`);
|
|
32
|
+
}
|
|
33
|
+
const body = await res.json().catch(() => ({}));
|
|
34
|
+
if (!res.ok) die(`Refused (${res.status}): ${body.error ?? "no reason given"}`);
|
|
35
|
+
console.log("instance context saved — every agent spawned from now on receives it.");
|
package/dist/config.d.ts
CHANGED
|
@@ -62,6 +62,8 @@ export interface Config {
|
|
|
62
62
|
* stay distinguishable. Absent = the default "shadok-ai".
|
|
63
63
|
*/
|
|
64
64
|
cockpitTitle?: Record<string, string>;
|
|
65
|
+
/** Per launch dir: the instance context every agent gets (src/instance-context.ts). */
|
|
66
|
+
instanceContext?: Record<string, string>;
|
|
65
67
|
/**
|
|
66
68
|
* Per launch-directory colour palette (an accent key like "emerald"), keyed by
|
|
67
69
|
* absolute cwd. Absent = the default "amber". Like the name, it re-themes only
|
|
@@ -120,6 +122,12 @@ export declare function setTokenForCwd(cfg: Config, cwd: string, token: string |
|
|
|
120
122
|
export declare function effectiveToken(cfg: Config, cwd: string, env?: NodeJS.ProcessEnv): string | null;
|
|
121
123
|
/** This directory's cockpit name, or null when none is set (→ default brand). */
|
|
122
124
|
export declare function titleForCwd(cfg: Config, cwd: string): string | null;
|
|
125
|
+
/** This directory's instance context, "" when unset (src/instance-context.ts). */
|
|
126
|
+
export declare function instanceContextForCwd(cfg: Config, cwd: string): string;
|
|
127
|
+
/** Pure: set (or, with "", remove) this directory's instance context on `cfg`. */
|
|
128
|
+
export declare function applyInstanceContext(cfg: Config, cwd: string, text: string): Config;
|
|
129
|
+
/** Set (or clear) this directory's instance context and persist. */
|
|
130
|
+
export declare function setInstanceContextForCwd(cfg: Config, cwd: string, text: string): void;
|
|
123
131
|
/**
|
|
124
132
|
* Set (or clear) this directory's cockpit name and persist. An empty/blank
|
|
125
133
|
* title removes the entry so the cockpit falls back to the default brand.
|
package/dist/config.js
CHANGED
|
@@ -41,6 +41,24 @@ export function titleForCwd(cfg, cwd) {
|
|
|
41
41
|
const t = cfg.cockpitTitle?.[cwd];
|
|
42
42
|
return t && t.trim() ? t.trim() : null;
|
|
43
43
|
}
|
|
44
|
+
/** This directory's instance context, "" when unset (src/instance-context.ts). */
|
|
45
|
+
export function instanceContextForCwd(cfg, cwd) {
|
|
46
|
+
return cfg.instanceContext?.[cwd]?.trim() ?? "";
|
|
47
|
+
}
|
|
48
|
+
/** Pure: set (or, with "", remove) this directory's instance context on `cfg`. */
|
|
49
|
+
export function applyInstanceContext(cfg, cwd, text) {
|
|
50
|
+
const t = text.trim();
|
|
51
|
+
cfg.instanceContext ??= {};
|
|
52
|
+
if (t)
|
|
53
|
+
cfg.instanceContext[cwd] = t;
|
|
54
|
+
else
|
|
55
|
+
delete cfg.instanceContext[cwd];
|
|
56
|
+
return cfg;
|
|
57
|
+
}
|
|
58
|
+
/** Set (or clear) this directory's instance context and persist. */
|
|
59
|
+
export function setInstanceContextForCwd(cfg, cwd, text) {
|
|
60
|
+
saveConfig(applyInstanceContext(cfg, cwd, text));
|
|
61
|
+
}
|
|
44
62
|
/**
|
|
45
63
|
* Set (or clear) this directory's cockpit name and persist. An empty/blank
|
|
46
64
|
* title removes the entry so the cockpit falls back to the default brand.
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAiH7B,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC;AAChE,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AACzD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;AAEzD,MAAM,UAAU,UAAU;I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CAAC;IACD,IAAI,CAAC,KAAK,IAAI,OAAO,GAAG,CAAC,aAAa,KAAK,QAAQ;QAAE,KAAK,GAAG,GAAG,CAAC,aAAa,CAAC;IAC/E,IAAI,CAAC,KAAK;QAAE,OAAO;IACnB,CAAC,GAAG,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACjC,OAAO,GAAG,CAAC,aAAa,CAAC,CAAC,2BAA2B;IACrD,IAAI,CAAC;QACH,EAAE,CAAC,UAAU,CAAC,UAAU,EAAE,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,0BAA0B;IACjF,CAAC;IAAC,MAAM,CAAC;QACP,iBAAiB;IACnB,CAAC;IACD,UAAU,CAAC,GAAG,CAAC,CAAC;AAClB,CAAC"}
|
package/dist/greeting.d.ts
CHANGED
|
@@ -93,7 +93,16 @@ export interface GreetingBriefInput {
|
|
|
93
93
|
profiles: readonly Profile[];
|
|
94
94
|
/** The launch directory's own name — what the person calls this place. */
|
|
95
95
|
dirName: string;
|
|
96
|
+
/** No instance context yet (src/instance-context.ts): ask about it first. */
|
|
97
|
+
instanceContextEmpty?: boolean;
|
|
96
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* The few questions that give birth to the instance context — what the cockpit
|
|
101
|
+
* is for, who works on it — with the language deduced from the answer. Shared by
|
|
102
|
+
* the first-run greeting and the cockpit's "Ask general to draft it", so both
|
|
103
|
+
* ask the same way. Optional by construction: nothing waits on the answer.
|
|
104
|
+
*/
|
|
105
|
+
export declare function instanceContextInterviewBrief(): string;
|
|
97
106
|
/**
|
|
98
107
|
* The hidden prompt that produces the greeting.
|
|
99
108
|
*
|
package/dist/greeting.js
CHANGED
|
@@ -118,6 +118,21 @@ export function groundFacts(g, dirName) {
|
|
|
118
118
|
}
|
|
119
119
|
return lines;
|
|
120
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* The few questions that give birth to the instance context — what the cockpit
|
|
123
|
+
* is for, who works on it — with the language deduced from the answer. Shared by
|
|
124
|
+
* the first-run greeting and the cockpit's "Ask general to draft it", so both
|
|
125
|
+
* ask the same way. Optional by construction: nothing waits on the answer.
|
|
126
|
+
*/
|
|
127
|
+
export function instanceContextInterviewBrief() {
|
|
128
|
+
return ("INSTANCE CONTEXT. This cockpit has no instance context yet: the few lines every agent here receives about what " +
|
|
129
|
+
"the instance is for. In the SAME message, before the offer, ask two or three short questions — what this " +
|
|
130
|
+
"cockpit will be used for, and who will work on it (by first name or role). Not a form: one message, and the " +
|
|
131
|
+
"person may ignore it. Deduce the working language from the language they answer in; ask only if you cannot " +
|
|
132
|
+
"tell. When they answer, write it ONCE with the shadok-instance-context skill (a handful of lines: purpose, " +
|
|
133
|
+
"people, language — and the deliverables' language if it differs from the conversation's), show them what you " +
|
|
134
|
+
"saved in a few lines, and say they can edit it from the cockpit menu (Instance context…).");
|
|
135
|
+
}
|
|
121
136
|
/**
|
|
122
137
|
* The hidden prompt that produces the greeting.
|
|
123
138
|
*
|
|
@@ -135,6 +150,8 @@ export function homeGreetingBrief(input) {
|
|
|
135
150
|
"will read. Write ONE short chat message: introduce yourself in a line, then make the single offer below. " +
|
|
136
151
|
"Then stop and wait. This is an offer, not a form — if they ignore it entirely, the cockpit must still be " +
|
|
137
152
|
"perfectly usable, so never ask a question they have to answer before anything works.");
|
|
153
|
+
if (input.instanceContextEmpty)
|
|
154
|
+
parts.push(instanceContextInterviewBrief());
|
|
138
155
|
parts.push("WHAT I ALREADY READ FOR YOU. This came from a deterministic pass over the directory (no model, no guessing). " +
|
|
139
156
|
"Do not contradict it, and do NOT go and read the project now — reading it properly is what you are about to " +
|
|
140
157
|
"OFFER, and doing it first spends their quota on a question nobody asked.\n" +
|
package/dist/greeting.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"greeting.js","sourceRoot":"","sources":["../src/greeting.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,gBAAgB,E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AE,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;YACxD,0GAA0G;YAC1G,yGAAyG;YACzG,qFAAqF;QACzF,CAAC,CAAC,0GAA0G;YACxG,yDAAyD,CAChE,CAAC;IAEF,KAAK,CAAC,IAAI,CACR,+GAA+G,CAChH,CAAC;IAEF,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The instance context: one short text per instance — what it is for, who it
|
|
3
|
+
* serves, its working language — that every agent receives at spawn whatever
|
|
4
|
+
* its profile. A role says HOW to work; nothing told an agent what the instance
|
|
5
|
+
* it runs on is FOR, so every agent rediscovered it, or never did.
|
|
6
|
+
*
|
|
7
|
+
* Written ONCE by the lead agent at first run (after asking), then owned by the
|
|
8
|
+
* humans who edit it in the cockpit. An agent never rewrites it afterwards — it
|
|
9
|
+
* suggests — because an agent quietly changing the purpose every agent is told
|
|
10
|
+
* is the failure to avoid (invariant 26's family).
|
|
11
|
+
*
|
|
12
|
+
* Design: docs/superpowers/specs/2026-11-09-instance-context-design.md
|
|
13
|
+
*/
|
|
14
|
+
export declare const INSTANCE_CONTEXT_MAX = 2000;
|
|
15
|
+
export declare const INSTANCE_CONTEXT_LABEL = "Instance context";
|
|
16
|
+
/** Trim; empty is allowed (it clears); over the cap is refused, never truncated. */
|
|
17
|
+
export declare function normalizeInstanceContext(raw: unknown): {
|
|
18
|
+
ok: true;
|
|
19
|
+
text: string;
|
|
20
|
+
} | {
|
|
21
|
+
ok: false;
|
|
22
|
+
error: string;
|
|
23
|
+
};
|
|
24
|
+
/** The lead's once-only write: null = allowed, else the reason it is refused. */
|
|
25
|
+
export declare function firstWriteVerdict(input: {
|
|
26
|
+
isHome: boolean;
|
|
27
|
+
current: string;
|
|
28
|
+
}): string | null;
|
|
29
|
+
/** The section appended to every agent's system prompt, or null when there is none. */
|
|
30
|
+
export declare function instanceContextSection(text: string): string | null;
|
|
31
|
+
/** The spawn flags carrying it — nothing at all when it is empty. */
|
|
32
|
+
export declare function instanceContextArgs(text: string): string[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The instance context: one short text per instance — what it is for, who it
|
|
3
|
+
* serves, its working language — that every agent receives at spawn whatever
|
|
4
|
+
* its profile. A role says HOW to work; nothing told an agent what the instance
|
|
5
|
+
* it runs on is FOR, so every agent rediscovered it, or never did.
|
|
6
|
+
*
|
|
7
|
+
* Written ONCE by the lead agent at first run (after asking), then owned by the
|
|
8
|
+
* humans who edit it in the cockpit. An agent never rewrites it afterwards — it
|
|
9
|
+
* suggests — because an agent quietly changing the purpose every agent is told
|
|
10
|
+
* is the failure to avoid (invariant 26's family).
|
|
11
|
+
*
|
|
12
|
+
* Design: docs/superpowers/specs/2026-11-09-instance-context-design.md
|
|
13
|
+
*/
|
|
14
|
+
export const INSTANCE_CONTEXT_MAX = 2000;
|
|
15
|
+
export const INSTANCE_CONTEXT_LABEL = "Instance context";
|
|
16
|
+
/** Trim; empty is allowed (it clears); over the cap is refused, never truncated. */
|
|
17
|
+
export function normalizeInstanceContext(raw) {
|
|
18
|
+
if (raw === undefined || raw === null)
|
|
19
|
+
return { ok: true, text: "" };
|
|
20
|
+
if (typeof raw !== "string")
|
|
21
|
+
return { ok: false, error: "the instance context must be text" };
|
|
22
|
+
const text = raw.trim();
|
|
23
|
+
if (text.length > INSTANCE_CONTEXT_MAX)
|
|
24
|
+
return { ok: false, error: `the instance context is limited to ${INSTANCE_CONTEXT_MAX} characters (got ${text.length})` };
|
|
25
|
+
return { ok: true, text };
|
|
26
|
+
}
|
|
27
|
+
/** The lead's once-only write: null = allowed, else the reason it is refused. */
|
|
28
|
+
export function firstWriteVerdict(input) {
|
|
29
|
+
if (!input.isHome)
|
|
30
|
+
return "only the instance's lead agent (its home channel) may write the instance context";
|
|
31
|
+
if (input.current.trim())
|
|
32
|
+
return "the instance context is already set — suggest the change in the chat; a human edits it from the cockpit menu";
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
/** The section appended to every agent's system prompt, or null when there is none. */
|
|
36
|
+
export function instanceContextSection(text) {
|
|
37
|
+
const t = text.trim();
|
|
38
|
+
if (!t)
|
|
39
|
+
return null;
|
|
40
|
+
return "## This instance\n\nWhat this shadok instance is for, set by the people who run it. It applies to every agent here, whatever its role.\n\n" + t;
|
|
41
|
+
}
|
|
42
|
+
/** The spawn flags carrying it — nothing at all when it is empty. */
|
|
43
|
+
export function instanceContextArgs(text) {
|
|
44
|
+
const s = instanceContextSection(text);
|
|
45
|
+
return s ? ["--append-system-prompt", s] : [];
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=instance-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance-context.js","sourceRoot":"","sources":["../src/instance-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AACzC,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAEzD,oFAAoF;AACpF,MAAM,UAAU,wBAAwB,CAAC,GAAY;IACnD,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;IACrE,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,mCAAmC,EAAE,CAAC;IAC9F,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IACxB,IAAI,IAAI,CAAC,MAAM,GAAG,oBAAoB;QACpC,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,sCAAsC,oBAAoB,oBAAoB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IAC5H,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC5B,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,iBAAiB,CAAC,KAA2C;IAC3E,IAAI,CAAC,KAAK,CAAC,MAAM;QAAE,OAAO,kFAAkF,CAAC;IAC7G,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE;QACtB,OAAO,8GAA8G,CAAC;IACxH,OAAO,IAAI,CAAC;AACd,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,sBAAsB,CAAC,IAAY;IACjD,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IACtB,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,OAAO,4IAA4I,GAAG,CAAC,CAAC;AAC1J,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,MAAM,CAAC,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,wBAAwB,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAChD,CAAC"}
|
package/dist/preprompt.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ export interface PrepromptInput {
|
|
|
26
26
|
profileName?: string | null;
|
|
27
27
|
/** The profile's role prompt, as resolved at spawn. */
|
|
28
28
|
role?: string;
|
|
29
|
+
/** The instance context (src/instance-context.ts), as read at spawn. */
|
|
30
|
+
instanceContext?: string;
|
|
29
31
|
model?: string;
|
|
30
32
|
deny?: string[];
|
|
31
33
|
allow?: string[];
|
package/dist/preprompt.js
CHANGED
|
@@ -1,24 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
* What shadok itself adds to an agent's context, as labelled sections.
|
|
3
|
-
*
|
|
4
|
-
* Everything here is passed to `claude` at spawn — appended system prompts,
|
|
5
|
-
* guardrails, the permission mode — and until now it was invisible: the agent
|
|
6
|
-
* knew its role, the person reading the chat did not, and a surprising answer
|
|
7
|
-
* had no explanation on screen.
|
|
8
|
-
*
|
|
9
|
-
* IT TAKES SECRET NAMES, NEVER VALUES. Values live in the child's environment
|
|
10
|
-
* and never in its arguments; keeping them out of this function's signature
|
|
11
|
-
* means they cannot leak through the panel by mistake, which is stronger than
|
|
12
|
-
* a test that says they currently don't.
|
|
13
|
-
*
|
|
14
|
-
* This is shadok's half only. Claude Code adds its own context — CLAUDE.md,
|
|
15
|
-
* skills, its built-in instructions — which shadok never sees, and the panel
|
|
16
|
-
* says so rather than implying it shows everything.
|
|
17
|
-
*/
|
|
1
|
+
import { INSTANCE_CONTEXT_LABEL } from "./instance-context.js";
|
|
18
2
|
const bullets = (items) => items.map((i) => `• ${i}`).join("\n");
|
|
19
3
|
/** Pure: the sections to show, in reading order, skipping what is absent. */
|
|
20
4
|
export function prepromptParts(input) {
|
|
21
5
|
const parts = [];
|
|
6
|
+
// First, as at spawn: what the instance is for, before this agent's role.
|
|
7
|
+
if (input.instanceContext?.trim()) {
|
|
8
|
+
parts.push({
|
|
9
|
+
label: INSTANCE_CONTEXT_LABEL,
|
|
10
|
+
source: "Instance context (cockpit menu)",
|
|
11
|
+
text: input.instanceContext.trim(),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
22
14
|
if (input.role?.trim()) {
|
|
23
15
|
parts.push({
|
|
24
16
|
label: input.profileName ? `Role — ${input.profileName}` : "Role",
|
|
@@ -91,7 +83,10 @@ export function prepromptParts(input) {
|
|
|
91
83
|
*/
|
|
92
84
|
export function prepromptFingerprint(parts) {
|
|
93
85
|
let h = 5381;
|
|
94
|
-
|
|
86
|
+
// The instance context is left out on purpose: one Save in the cockpit must
|
|
87
|
+
// not mark every running agent stale and offer to respawn the whole fleet —
|
|
88
|
+
// the editor offers a restart instead (instance-context design).
|
|
89
|
+
const s = parts.filter((p) => p.label !== INSTANCE_CONTEXT_LABEL).map((p) => `${p.label}\u0000${p.source}\u0000${p.text}`).join("\u0001");
|
|
95
90
|
for (let i = 0; i < s.length; i++)
|
|
96
91
|
h = ((h * 33) ^ s.charCodeAt(i)) >>> 0;
|
|
97
92
|
return h.toString(16);
|
package/dist/preprompt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preprompt.js","sourceRoot":"","sources":["../src/preprompt.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"preprompt.js","sourceRoot":"","sources":["../src/preprompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAiD/D,MAAM,OAAO,GAAG,CAAC,KAAe,EAAU,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEnF,6EAA6E;AAC7E,MAAM,UAAU,cAAc,CAAC,KAAqB;IAClD,MAAM,KAAK,GAAoB,EAAE,CAAC;IAElC,0EAA0E;IAC1E,IAAI,KAAK,CAAC,eAAe,EAAE,IAAI,EAAE,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC;YACT,KAAK,EAAE,sBAAsB;YAC7B,MAAM,EAAE,iCAAiC;YACzC,IAAI,EAAE,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE;SACnC,CAAC,CAAC;IACL,CAAC;IAGD,IAAI,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC;YACT,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,MAAM;YACjE,MAAM,EAAE,gBAAgB;YACxB,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE;SACxB,CAAC,CAAC;IACL,CAAC;IAED,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,K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6EAA6E;SACrF,CAAC,CAAC;IACL,CAAC;IACD,IACE,CAAC,CAAC,kBAAkB;QACpB,CAAC,CAAC,oBAAoB;QACtB,CAAC,CAAC,kBAAkB,KAAK,CAAC,CAAC,oBAAoB,EAC/C,CAAC;QACD,GAAG,CAAC,IAAI,CAAC;YACP,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,wBAAwB,CAAC,CAAC,kBAAkB,MAAM,CAAC,CAAC,oBAAoB,gCAAgC;SAChH,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,EAAU;IACvC,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;IACnD,IAAI,CAAC,EAAE;QAAE,OAAO,EAAE,CAAC;IACnB,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,EAAE;QAC1B,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,GAAG,GAAG,CAAC,GAAG,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC;QAC/D,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACjE,CAAC,CAAC;IACF,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,aAAa,CAAC,EAAE,CAAC;AACpE,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -26,6 +26,7 @@ import { PtyPilot } from "./session.js";
|
|
|
26
26
|
import { ensureClaudeHome, ensureProjectTrusted, getDefaultModel, setDefaultModel, parseClaudeVersion, seedPlanForCwds, settingsPlan, } from "./claude-home.js";
|
|
27
27
|
import { mergeAppendedPrompts } from "./prompt-args.js";
|
|
28
28
|
import { authStatus, cancelLogin, invalidateAuthStatus, startLogin, submitLoginCode } from "./claude-auth.js";
|
|
29
|
+
import { instanceContextArgs, normalizeInstanceContext, firstWriteVerdict, INSTANCE_CONTEXT_MAX } from "./instance-context.js";
|
|
29
30
|
import { connectVerdict, connectedState } from "./connect-gate.js";
|
|
30
31
|
import { normalizePastedToken } from "./token-paste.js";
|
|
31
32
|
import { startSetupToken, submitSetupTokenCode, cancelSetupToken } from "./setup-token.js";
|
|
@@ -34,7 +35,7 @@ import { readTokenExpiry } from "./claude-creds.js";
|
|
|
34
35
|
import { starCount } from "./stars.js";
|
|
35
36
|
import { announceFirstAgent, countMainChannels, ensureFirstAgent, firstAgentStatus, settleFirstAgent, } from "./first-agent.js";
|
|
36
37
|
import { readGroundAt } from "./ground.js";
|
|
37
|
-
import { homeGreetingBrief } from "./greeting.js";
|
|
38
|
+
import { homeGreetingBrief, instanceContextInterviewBrief } from "./greeting.js";
|
|
38
39
|
import { ensureSshIdentity, groupKeyRows, volumeKeyPaths } from "./ssh.js";
|
|
39
40
|
import { accountsEnabled, deploymentMode, probeCanProvision } from "./capability.js";
|
|
40
41
|
import { migrationPlan, runMigration, respawnPlan, commonsOsUser, COMMONS_USER, MIGRATION_MARKER_FILE, rewriteCronCheckHome, strandedCheckDirs, serverOwnedStatePaths, } from "./migrate-groups.js";
|
|
@@ -73,7 +74,7 @@ import { rowKind } from "../context/ledger-skill/ledger-core.mjs";
|
|
|
73
74
|
import { profileWriteRefusal, profileDeleteRefusal, mayReadMcpValues, redactMcpServers, setProfileRefusal, restartAllPlan, monoSecretRefusal, } from "./route-guards.js";
|
|
74
75
|
import { linkRefusal, markAgentPrompt, notificationText, } from "./kinship.js";
|
|
75
76
|
import { talkVerdict, talkLetter } from "./talk.js";
|
|
76
|
-
import { loadConfig, saveConfig, telegramConfig, applyTelegramPatch, titleForCwd, setTitleForCwd, themeForCwd, setThemeForCwd, mutedForCwd, setMutedForCwd, agentAuthForCwd, setAgentAuthForCwd, twoFactorForCwd, setTwoFactorForCwd, backendForCwd, setBackendForCwd, } from "./config.js";
|
|
77
|
+
import { loadConfig, saveConfig, telegramConfig, applyTelegramPatch, titleForCwd, setTitleForCwd, instanceContextForCwd, setInstanceContextForCwd, themeForCwd, setThemeForCwd, mutedForCwd, setMutedForCwd, agentAuthForCwd, setAgentAuthForCwd, twoFactorForCwd, setTwoFactorForCwd, backendForCwd, setBackendForCwd, } from "./config.js";
|
|
77
78
|
import { secretsFor, secretsForProfile, secretNamesForProfile, secretNames, setSecret, deleteSecret, setSecretSharing, setSecretProfiles, secretWriteVerdict, secretWriteDecision, secretOwnerGroup, visibleSecrets, RESERVED_SECRET_NAMES, MT_CLAUDE_OAUTH_TOKEN_NAME, longLivedTokenInfo, loadVault, recordOrigin, originProfile, } from "./secrets.js";
|
|
78
79
|
import { recordSecretAudit, readSecretAudit, filterAudit, spawnActor, httpActor, profileSecretDiff, } from "./secret-audit.js";
|
|
79
80
|
import { getProfile, profileArgs, resolveSpawnModel, permissionModeArgs, isPermissionMode, isEffortLevel, mcpServersVerdict, envVarsNote, seedDefaultProfiles, migrateToTracking, seedTweakProfile, seedSkillsmithProfile, MANAGED_PROFILE_NAMES, loadProfiles, upsertProfile, removeProfile, promptEditVerdict, secretAttachVerdict, READONLY_DENY, promptOrigin, effectiveProfile, shippedProfile, } from "./profiles.js";
|
|
@@ -295,6 +296,7 @@ function greetHomeAgent(id) {
|
|
|
295
296
|
ground: readGroundAt(cwd),
|
|
296
297
|
profiles: loadProfiles(),
|
|
297
298
|
dirName: path.basename(cwd) || cwd,
|
|
299
|
+
instanceContextEmpty: !instanceContextForCwd(loadConfig(), cwd),
|
|
298
300
|
}));
|
|
299
301
|
}
|
|
300
302
|
catch (e) {
|
|
@@ -1884,6 +1886,71 @@ app.put("/title", (req, res) => {
|
|
|
1884
1886
|
setTitleForCwd(loadConfig(), process.cwd(), raw);
|
|
1885
1887
|
res.json({ title: titleForCwd(loadConfig(), process.cwd()) });
|
|
1886
1888
|
});
|
|
1889
|
+
// The instance context (src/instance-context.ts): one short text per instance
|
|
1890
|
+
// that every agent receives at spawn. Humans edit it from the cockpit; the lead
|
|
1891
|
+
// agent writes it ONCE, while it is empty, at first run.
|
|
1892
|
+
app.get("/instance-context", (_req, res) => {
|
|
1893
|
+
res.json({ text: instanceContextForCwd(loadConfig(), process.cwd()), max: INSTANCE_CONTEXT_MAX });
|
|
1894
|
+
});
|
|
1895
|
+
app.put("/instance-context", (req, res) => {
|
|
1896
|
+
// Every agent is told this text, so only a human in the browser writes it
|
|
1897
|
+
// (an agent's only door is the once-only route below) — like PUT /profiles.
|
|
1898
|
+
if (!accountAdmin(req, res, true, "edit the instance context"))
|
|
1899
|
+
return;
|
|
1900
|
+
const r = normalizeInstanceContext(req.body?.text);
|
|
1901
|
+
if (!r.ok)
|
|
1902
|
+
return res.status(400).json({ error: r.error });
|
|
1903
|
+
setInstanceContextForCwd(loadConfig(), process.cwd(), r.text);
|
|
1904
|
+
res.json({ text: r.text });
|
|
1905
|
+
});
|
|
1906
|
+
app.put("/instance-context/first", (req, res) => {
|
|
1907
|
+
const key = String(req.headers["x-shadok-session-key"] ?? "");
|
|
1908
|
+
const id = localSessionForKey(req, key);
|
|
1909
|
+
if (!id)
|
|
1910
|
+
return res.status(403).json({ error: "unknown or missing session key" });
|
|
1911
|
+
const ch = loadChannels().find((c) => c.sessionId === id);
|
|
1912
|
+
const refused = firstWriteVerdict({
|
|
1913
|
+
isHome: !!ch && isHomeChannel(ch),
|
|
1914
|
+
current: instanceContextForCwd(loadConfig(), process.cwd()),
|
|
1915
|
+
});
|
|
1916
|
+
if (refused)
|
|
1917
|
+
return res.status(409).json({ error: refused });
|
|
1918
|
+
const r = normalizeInstanceContext(req.body?.text);
|
|
1919
|
+
if (!r.ok)
|
|
1920
|
+
return res.status(400).json({ error: r.error });
|
|
1921
|
+
if (!r.text)
|
|
1922
|
+
return res.status(400).json({ error: "the instance context is empty" });
|
|
1923
|
+
setInstanceContextForCwd(loadConfig(), process.cwd(), r.text);
|
|
1924
|
+
console.log(`instance context: written by the lead agent (${id.slice(0, 8)}, ${r.text.length} chars)`);
|
|
1925
|
+
res.json({ ok: true });
|
|
1926
|
+
});
|
|
1927
|
+
// "Ask general to draft it" (the cockpit editor, context still empty): the lead
|
|
1928
|
+
// runs the same short interview the first-run greeting does, delivered as a
|
|
1929
|
+
// HIDDEN prompt over the loopback exactly like the greeting.
|
|
1930
|
+
app.post("/instance-context/draft", async (req, res) => {
|
|
1931
|
+
if (!accountAdmin(req, res, true, "ask the lead agent to draft the instance context"))
|
|
1932
|
+
return;
|
|
1933
|
+
if (instanceContextForCwd(loadConfig(), process.cwd()))
|
|
1934
|
+
return res.status(409).json({ error: "the instance context is already set — edit it directly" });
|
|
1935
|
+
const home = loadChannels().find((c) => isHomeChannel(c) && c.sessionId);
|
|
1936
|
+
if (!home?.sessionId)
|
|
1937
|
+
return res.status(409).json({ error: "this cockpit has no lead agent to ask" });
|
|
1938
|
+
const id = home.sessionId;
|
|
1939
|
+
const brief = markAgentPrompt(instanceContextInterviewBrief() +
|
|
1940
|
+
"\n\nThe person just asked you, from the cockpit, to draft it now: ask your questions in one short message, " +
|
|
1941
|
+
"then wait for their answer.");
|
|
1942
|
+
// Answer only once it really landed: "asked" while the lead never heard it
|
|
1943
|
+
// (busy for the whole retry window) would leave the person waiting in a chat
|
|
1944
|
+
// that never asks anything.
|
|
1945
|
+
const r = await deliverWithRetry(() => driveChannel(id, brief, resolveSessionTarget(loadChannels(), id, process.cwd())),
|
|
1946
|
+
// The lead may be dormant (no live process after a restart): driveChannel
|
|
1947
|
+
// wakes it, so "still there" is the channel, not a live session.
|
|
1948
|
+
() => loadChannels().some((c) => c.sessionId === id));
|
|
1949
|
+
console.log(`instance context: draft request ${id.slice(0, 8)} — ${r.ok ? "delivered" : "not delivered"}`);
|
|
1950
|
+
if (!r.ok)
|
|
1951
|
+
return res.status(503).json({ error: "the lead agent is busy or unreachable right now — try again in a moment" });
|
|
1952
|
+
res.json({ ok: true, agent: home.name ?? null });
|
|
1953
|
+
});
|
|
1887
1954
|
// Colour palette, per launch directory — an accent key ("emerald"…). The setter
|
|
1888
1955
|
// validates against the known palettes; the default/unknown clears it.
|
|
1889
1956
|
app.get("/theme", (_req, res) => {
|
|
@@ -2893,6 +2960,8 @@ const SKILL_SOURCES = [
|
|
|
2893
2960
|
// exactly what bit a migrated instance. test/system-skills.test.ts pins that
|
|
2894
2961
|
// every shipped context/*-skill is listed here.
|
|
2895
2962
|
["files-skill", "shadok-files"],
|
|
2963
|
+
// The lead's once-only write of the instance context (src/instance-context.ts).
|
|
2964
|
+
["instance-context-skill", "shadok-instance-context"],
|
|
2896
2965
|
// Seeded to the server HOME by seedFactorySkill; a Skillsmith running as a
|
|
2897
2966
|
// group's own OS user reads only this tier.
|
|
2898
2967
|
["factory-skill", "shadok-factory"],
|
|
@@ -6013,6 +6082,7 @@ function buildPreprompt(profileName, groupId, sessionId) {
|
|
|
6013
6082
|
return prepromptParts({
|
|
6014
6083
|
profileName: profileName ?? null,
|
|
6015
6084
|
role: resolved?.systemPrompt,
|
|
6085
|
+
instanceContext: instanceContextForCwd(loadConfig(), process.cwd()),
|
|
6016
6086
|
model: resolved?.model,
|
|
6017
6087
|
deny: resolved?.deny,
|
|
6018
6088
|
allow: resolved?.allow,
|
|
@@ -6483,6 +6553,12 @@ group) {
|
|
|
6483
6553
|
// A flag+value pair, before the profile's flags: nothing here can land
|
|
6484
6554
|
// after `--mcp-config`'s variadic JSON as a bare word.
|
|
6485
6555
|
...factory.args,
|
|
6556
|
+
// The instance context FIRST, then the role: general before specific — what
|
|
6557
|
+
// this instance is for, then what this agent does in it. Nothing at all when
|
|
6558
|
+
// it is empty. A flag+value pair, so it is safe before the profile's flags;
|
|
6559
|
+
// mergeAppendedPrompts (PR #433) joins every --append-system-prompt into one,
|
|
6560
|
+
// in this order, since Claude Code keeps only the last.
|
|
6561
|
+
...instanceContextArgs(instanceContextForCwd(loadConfig(), process.cwd())),
|
|
6486
6562
|
...profileArgs(resolvedProfile, spawnModel, effort),
|
|
6487
6563
|
...(note ? ["--append-system-prompt", note] : []),
|
|
6488
6564
|
...(sp ? ["--append-system-prompt", sp] : []),
|
|
@@ -9064,6 +9140,26 @@ function seedFilesSkill() {
|
|
|
9064
9140
|
}
|
|
9065
9141
|
if (SEED_SKILLS)
|
|
9066
9142
|
seedFilesSkill();
|
|
9143
|
+
// The lead agent's once-only write of the instance context: seeded to the server
|
|
9144
|
+
// HOME like shadok-files (a root lead reads it there), and listed in
|
|
9145
|
+
// SKILL_SOURCES for the machine-wide tier a dropped lead reads.
|
|
9146
|
+
function seedInstanceContextSkill() {
|
|
9147
|
+
try {
|
|
9148
|
+
const src = path.join(__dirname, "..", "context", "instance-context-skill");
|
|
9149
|
+
if (!fs.existsSync(path.join(src, "SKILL.md")))
|
|
9150
|
+
return;
|
|
9151
|
+
const dst = path.join(os.homedir(), ".claude", "skills", "shadok-instance-context");
|
|
9152
|
+
fs.mkdirSync(path.join(dst, "scripts"), { recursive: true });
|
|
9153
|
+
fs.copyFileSync(path.join(src, "SKILL.md"), path.join(dst, "SKILL.md"));
|
|
9154
|
+
fs.copyFileSync(path.join(src, "scripts", "write.mjs"), path.join(dst, "scripts", "write.mjs"));
|
|
9155
|
+
fs.chmodSync(path.join(dst, "scripts", "write.mjs"), 0o755);
|
|
9156
|
+
}
|
|
9157
|
+
catch {
|
|
9158
|
+
/* best effort — without it the lead says it cannot save, nothing breaks */
|
|
9159
|
+
}
|
|
9160
|
+
}
|
|
9161
|
+
if (SEED_SKILLS)
|
|
9162
|
+
seedInstanceContextSkill();
|
|
9067
9163
|
// The Skill Factory's agent side (pull / push / scan of a factory skill's clone).
|
|
9068
9164
|
function seedFactorySkill() {
|
|
9069
9165
|
try {
|