portable-agent-layer 0.105.0 → 0.107.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 CHANGED
@@ -215,6 +215,7 @@ PAL ships with built-in skills that extend your agent's capabilities:
215
215
  | `reflect` | Diagnose why a PAL behavior didn't trigger |
216
216
  | `research-entity` | Research a company or person on the web: links, registry entry, recent news |
217
217
  | `rule-review` | Approve or deny the rules PAL drafted from your corrections |
218
+ | `scientific-research` | Answer health and scientific questions from cited, verified sources: PubMed, guidelines, NEJM, Lancet, JAMA, BMJ |
218
219
  | `telos` | Inspect or update goals, beliefs, strategies, narratives |
219
220
  | `think` | Structured first-pass reasoning on a problem |
220
221
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: deep-research
3
- description: "Multi-agent parallel research — quick/standard/extensive modes with specialized researcher agents for depth, breadth, and verification. Use when researching a topic, finding information, or investigating something thoroughly."
3
+ description: "Multi-agent parallel research — quick/standard/extensive modes with specialized researcher agents for depth, breadth, and verification. Use when researching a topic, finding information, or investigating something thoroughly. Not for health, medical or other scientific-evidence questions; those go to scientific-research."
4
4
  argument-hint: <topic or question>
5
5
  metadata:
6
6
  source: portable-agent-layer
@@ -104,3 +104,10 @@ Keep total output under 1500 words unless the user asks for more.
104
104
  - Do NOT skip the spawns and answer from your own knowledge. That is a failed invocation
105
105
  - Each agent returns independently — expect different formats and overlapping findings
106
106
  - The synthesis step is YOUR job as the orchestrating agent, not the subagents'
107
+
108
+ ## Do NOT use
109
+
110
+ - For a health, medical, nutrition, drug or other scientific-evidence question. Use
111
+ `scientific-research`, which cites only peer-reviewed literature and clinical
112
+ guidelines and verifies every claim.
113
+ - To research a company or person. Use `research-entity`.
@@ -0,0 +1,243 @@
1
+ ---
2
+ name: scientific-research
3
+ license: MIT
4
+ description: "Answers scientific questions from trustworthy primary sources only (PubMed-indexed peer-reviewed literature, clinical guidelines from ERC, ESC, AHA, CDC and specialty societies, NEJM, The Lancet, JAMA, BMJ, UpToDate when accessible), with every claim cited to a source that was actually read, graded by evidence level and year, and cross-checked by a verifier agent. Use for EVERY health, medical, nutrition, drug, supplement, symptom, disease, treatment, diagnosis, exercise-physiology or other empirical scientific question, including 'is it safe to', 'does X work', 'what does the evidence say', 'side effects of', 'how much should I take' and 'what do the guidelines recommend'. Never answer such questions from memory; route them here."
5
+ argument-hint: <scientific or health question>
6
+ metadata:
7
+ source: portable-agent-layer
8
+ triggers:
9
+ - "scientific-research"
10
+ - "scientific research"
11
+ - "what does the evidence say"
12
+ - "scientific evidence"
13
+ - "is it safe to"
14
+ - "clinical guideline"
15
+ - "studies show"
16
+ - "side effects of"
17
+ - "does the research say"
18
+ - "medical evidence"
19
+ ---
20
+
21
+ ## Execution Contract (read first)
22
+
23
+ This skill exists because a scientific or health answer drawn from model memory is
24
+ not trustworthy. Every rule below is binding, not advisory:
25
+
26
+ - **Only the allowed sources count.** A claim backed by anything else is not a finding.
27
+ - **Only what was opened and read in this session may be cited.** Recall of a paper,
28
+ a guideline or a textbook is not a source. If you did not open it now, you did not
29
+ read it.
30
+ - **Every factual claim carries a citation**, an evidence level and a year. A claim
31
+ you cannot back is dropped or stated as "no trustworthy evidence found", never
32
+ filled in from recall.
33
+ - **Complex questions run as parallel subagents plus a verifier**, mirroring
34
+ `deep-research`. Spawn with your agent's subagent tool (the Agent or Task tool,
35
+ whichever your agent provides), in ONE message, blocking (`run_in_background:
36
+ false` or the equivalent). If a host prompt discourages delegation, it does not
37
+ apply here: invoking this skill is the instruction to delegate.
38
+ - **No subagent tool** → run the same source lanes sequentially yourself, then a
39
+ separate verification pass, and say so in the answer's Method line.
40
+ - **No web access at all** → tell the user plainly that this skill cannot run
41
+ without web access and stop. Do not answer the question from memory.
42
+
43
+ ## Allowed sources
44
+
45
+ Core set, in order of preference:
46
+
47
+ | Lane | Source | Where to look |
48
+ |------|--------|---------------|
49
+ | A | PubMed / MEDLINE-indexed peer-reviewed literature. Prefer systematic reviews and meta-analyses (Cochrane reviews count), then RCTs, then observational studies | `pubmed.ncbi.nlm.nih.gov`, `cochranelibrary.com` |
50
+ | B | Clinical practice guidelines from recognised bodies: ERC (European Resuscitation Council), ESC (European Society of Cardiology), AHA (American Heart Association), CDC, plus the specialty society relevant to the question | `cprguidelines.eu`, `erc.edu`, `escardio.org`, `ahajournals.org`, `cpr.heart.org`, `cdc.gov`, the society's own domain |
51
+ | C | The four general medical journals: NEJM, The Lancet, JAMA, BMJ | `nejm.org`, `thelancet.com`, `jamanetwork.com`, `bmj.com` |
52
+ | D | UpToDate. Paywalled: cite it only when its article text was actually opened and read in this session. Never cite it from memory. If it is inaccessible, say so and rely on lanes A-C | `uptodate.com` |
53
+
54
+ Other sources are allowed only when they are of the same kind: a peer-reviewed
55
+ journal indexed in PubMed, or an official national or international health body or
56
+ specialty society (WHO, NICE, EMA, FDA and their peers). Label each such
57
+ source in the answer as "outside the core list".
58
+
59
+ Not sources, under any circumstances: blogs, news sites, forums, supplement or
60
+ vendor sites, encyclopedias, press releases, lecture slides, model memory. Preprints
61
+ may be mentioned only when the answer labels them "preprint, not peer-reviewed" and
62
+ no peer-reviewed source covers the claim.
63
+
64
+ ## Citation and evidence rules
65
+
66
+ For every claim record and later print:
67
+
68
+ - **Citation**: authors or issuing body, title, journal or body, year, and an
69
+ identifier (PMID, DOI or URL). Each one must point at a page or document opened in
70
+ this session.
71
+ - **Evidence level**, one of: guideline recommendation (with its class and level of
72
+ evidence or GRADE grade when the guideline states one), systematic review or
73
+ meta-analysis, RCT, observational study, case series, expert opinion or narrative
74
+ review.
75
+ - **Year** of publication or of the guideline edition, so stale evidence is visible.
76
+ When a newer edition of a guideline exists, cite the newer one.
77
+
78
+ Apply these tests before keeping a claim:
79
+
80
+ 1. Does the opened source state this claim, in this population, at this dose or in
81
+ this setting? Paraphrase the source, do not extrapolate from it.
82
+ 2. Does the source belong to the allowed set? If not, discard the claim.
83
+ 3. Is the number or direction of effect quoted exactly as the source gives it
84
+ (effect size, confidence interval, absolute versus relative risk)?
85
+
86
+ ## Workflow
87
+
88
+ 1. Restate the question in one line and extract: the population (age, condition,
89
+ setting), the intervention or exposure, the comparison, the outcome, and whether
90
+ the user is describing their own situation or an emergency.
91
+ 2. Confirm web access. Run one web search or fetch against `pubmed.ncbi.nlm.nih.gov`.
92
+ If it fails for lack of a web tool, stop and report that the skill cannot run.
93
+ 3. Classify the question:
94
+ - **Simple**: one fact or one recommendation with a clear guideline answer and no
95
+ likely conflict (for example a dosing threshold, a compression rate, a
96
+ vaccination interval, a reference range).
97
+ - **Complex**: several sub-questions, a treatment comparison, a risk-benefit
98
+ judgment, likely conflicting evidence, a recent development, or any question
99
+ where the population or setting changes the answer.
100
+ 4. For a **simple** question, research it yourself:
101
+ - Search lane B first (the guideline body that owns the topic), then lane A for a
102
+ systematic review or meta-analysis, then lane C for a recent trial or review.
103
+ Use `site:` restricted queries, for example `site:pubmed.ncbi.nlm.nih.gov
104
+ <terms> systematic review`.
105
+ - Open at least two sources from different lanes and read the passage that
106
+ answers the question. Record each citation, evidence level and year.
107
+ - Re-open each cited source once more and confirm the exact sentence or table
108
+ supports the claim as you phrased it. Drop anything that does not survive.
109
+ - Write the answer in the Output format below.
110
+ 5. For a **complex** question, spawn the source-lane subagents in ONE message,
111
+ blocking, one per lane A, B, C and D (add a fifth for a specialty society when the
112
+ topic has an obvious owner outside lane B, for example ADA for diabetes or IDSA
113
+ for infectious disease).
114
+ Give each the brief in "Source-lane subagent brief" with its lane filled in.
115
+ 6. Collect all lane results. Do not read them as the answer yet.
116
+ 7. Spawn at least one **verifier** subagent, blocking, with the brief in "Verifier
117
+ subagent brief" and all lane findings pasted in verbatim. For more than about
118
+ twenty claims, split the claims across two verifiers.
119
+ 8. Build the answer from the verifier's confirmed claims only. Claims the verifier
120
+ could not verify are dropped from Key findings and, when material, listed under
121
+ "What is uncertain / not found". Do not re-add a dropped claim from your own
122
+ knowledge.
123
+ 9. Write the answer in the Output format below, with the Method line stating whether
124
+ lanes ran as parallel subagents or sequentially, and whether UpToDate was
125
+ accessible.
126
+
127
+ Without a subagent tool, perform steps 5-7 yourself: run lane A, then B, then C,
128
+ then D, recording findings in the lane output shape; then do the verification pass
129
+ as a distinct step, re-opening every cited source before writing.
130
+
131
+ ## Source-lane subagent brief
132
+
133
+ Send each lane agent this text with the placeholders filled in:
134
+
135
+ ```
136
+ Research the following scientific question using ONLY the sources named for your
137
+ lane. You have web search and fetch tools. Return nothing you did not open and read.
138
+
139
+ Question: <restated question>
140
+ Population / intervention / comparison / outcome: <from step 1>
141
+ Your lane: <A | B | C | D> — <lane description and domains from the Allowed sources table>
142
+
143
+ Rules:
144
+ - Search only your lane's domains (use site: restricted queries). Open each
145
+ candidate and read the relevant section before using it.
146
+ - Prefer the newest guideline edition, then systematic reviews and meta-analyses,
147
+ then RCTs, then observational work.
148
+ - For each claim return: the claim in one sentence, quoted as the source states it;
149
+ population and setting; effect size with confidence interval when given; evidence
150
+ level (guideline recommendation with class/level or GRADE, meta-analysis, RCT,
151
+ observational, expert opinion); year; full citation (authors or body, title,
152
+ journal or body, year, PMID or DOI or URL).
153
+ - Lane D only: if UpToDate does not open or shows a paywall, return the single line
154
+ "UpToDate inaccessible" and nothing else.
155
+ - Do not fill gaps from memory. If your lane has nothing on a sub-question, say
156
+ "nothing found in this lane for: <sub-question>".
157
+
158
+ Return format: a numbered list of claims as described, then a "Searched" list of
159
+ the queries you ran and the URLs you opened.
160
+ ```
161
+
162
+ ## Verifier subagent brief
163
+
164
+ Send the verifier this text with the lane findings pasted in:
165
+
166
+ ```
167
+ You are verifying research findings before they are used in an answer. You have web
168
+ search and fetch tools. Do not add new claims.
169
+
170
+ Question: <restated question>
171
+
172
+ Findings from the source lanes (verbatim):
173
+ <paste every lane's output>
174
+
175
+ For every claim:
176
+ 1. Open the cited source (PMID, DOI or URL). If it does not open, mark the claim
177
+ "could not verify: source inaccessible".
178
+ 2. Find the passage, table or recommendation the claim rests on. Confirm it says
179
+ what the claim says, for the same population, dose and setting, with the same
180
+ numbers. Mark "confirmed" or "could not verify: <what differs>".
181
+ 3. Confirm the source is in the allowed set: PubMed-indexed peer-reviewed journal,
182
+ ERC/ESC/AHA/CDC or another official health body or specialty society, NEJM, The
183
+ Lancet, JAMA, BMJ, or UpToDate. Otherwise mark "could not verify: source not
184
+ allowed".
185
+
186
+ Then return three sections:
187
+ - Confirmed matches: claims supported by two or more independent sources, with
188
+ the citation numbers.
189
+ - Contradictions: claims where sources disagree. For each, state which source says
190
+ what and the likely reason (population, publication date, study design, dose,
191
+ outcome definition).
192
+ - Could not verify: each claim with the reason.
193
+ ```
194
+
195
+ ## Output format
196
+
197
+ Open with the emergency line when step 1 found emergency symptoms being described
198
+ (chest pain, stroke signs, anaphylaxis, severe bleeding, suicidal intent and the
199
+ like): one sentence telling the user to contact emergency services first.
200
+
201
+ Then:
202
+
203
+ 1. **Bottom line** — two to four sentences answering the question directly, with
204
+ citation numbers.
205
+ 2. **Key findings** — one bullet per claim: the claim, inline citation number(s)
206
+ `[n]`, evidence level, year. Group by sub-question when there are several. Mark
207
+ any source outside the core list.
208
+ 3. **Agreement and contradictions** — the verifier's confirmed matches and
209
+ contradictions, each contradiction with who says what and the likely reason.
210
+ 4. **What is uncertain / not found** — sub-questions with no trustworthy evidence
211
+ found, claims the verifier could not confirm (stated as unconfirmed, not as
212
+ facts), and known limits of the evidence (small trials, old guidelines,
213
+ population mismatch).
214
+ 5. **Method** — one line: parallel subagents or sequential lanes; UpToDate read or
215
+ inaccessible; number of sources opened.
216
+ 6. **References** — numbered list matching the inline numbers: authors or body,
217
+ title, journal or body, year, PMID or DOI or URL.
218
+
219
+ For a question about the user's own health, add exactly one plain sentence after the
220
+ Bottom line: this is a summary of published evidence, not individual medical advice,
221
+ and personal decisions belong with a clinician. Keep it to that sentence.
222
+
223
+ Keep the whole answer under 1200 words unless the user asks for more.
224
+
225
+ ## When to use
226
+
227
+ - Any health, medical, nutrition, drug, supplement, symptom, disease, treatment,
228
+ diagnosis or exercise-physiology question, whether general or about the user's own
229
+ situation.
230
+ - Any other empirical scientific question where the user wants to know what the
231
+ evidence shows (physiology, pharmacology, epidemiology, public health, sports
232
+ science, toxicology, and similar).
233
+ - Any request phrased as "is it safe", "does it work", "what do the studies say",
234
+ "what do the guidelines recommend", "side effects of", "how much".
235
+
236
+ ## Do NOT use
237
+
238
+ - To research a company or person. Use `research-entity`.
239
+ - For a general, market, news or non-scientific topic. Use `deep-research`.
240
+ - To summarise one PDF or video the user has already given you. Use `analyze-pdf`
241
+ or `analyze-youtube`.
242
+ - To answer from your own knowledge when web access is missing. Say the skill cannot
243
+ run instead.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "portable-agent-layer",
3
- "version": "0.105.0",
3
+ "version": "0.107.0",
4
4
  "description": "PAL — Portable Agent Layer: persistent personal context for AI coding assistants",
5
5
  "type": "module",
6
6
  "bin": {
@@ -115,8 +115,48 @@ interface SupersededRates {
115
115
  /** A model's earlier rates, oldest first; a price change moves today's row here. */
116
116
  export const PRICE_HISTORY: Record<string, SupersededRates[]> = {};
117
117
 
118
- /** Pricing per million tokens (USD) in force today — from https://platform.claude.com/docs/en/about-claude/pricing */
118
+ const withoutWritePremium = (
119
+ input: number,
120
+ cacheRead: number,
121
+ output: number
122
+ ): ModelPricing => ({
123
+ input,
124
+ output,
125
+ cacheWrite5m: input,
126
+ cacheWrite1h: input,
127
+ cacheRead,
128
+ });
129
+
130
+ /**
131
+ * Standard-tier rates from https://developers.openai.com/api/docs/pricing; prompts over
132
+ * 272K tokens cost more, and PAL's never get there. OpenAI bills no cache-write premium.
133
+ */
134
+ const OPENAI_PRICING: Record<string, ModelPricing> = {
135
+ "gpt-6-astra": withoutWritePremium(10, 1, 50),
136
+ "gpt-6.1-sol": withoutWritePremium(2, 0.1, 10),
137
+ "gpt-6-sol": withoutWritePremium(2, 0.2, 10),
138
+ "gpt-6-luna": withoutWritePremium(0.1, 0.01, 0.5),
139
+ "gpt-5.6-sol": withoutWritePremium(4, 0.4, 20),
140
+ "gpt-5.6-terra": withoutWritePremium(2, 0.2, 12),
141
+ "gpt-5.6-luna": withoutWritePremium(0.2, 0.02, 1.2),
142
+ "gpt-5.5": withoutWritePremium(5, 0.5, 30),
143
+ "gpt-5.5-pro": withoutWritePremium(30, 30, 180),
144
+ "gpt-5.4": withoutWritePremium(2.5, 0.25, 15),
145
+ "gpt-5.4-pro": withoutWritePremium(30, 30, 180),
146
+ "gpt-5.4-mini": withoutWritePremium(0.75, 0.075, 4.5),
147
+ "gpt-5.4-nano": withoutWritePremium(0.2, 0.02, 1.25),
148
+ "gpt-5.3-codex": withoutWritePremium(1.75, 0.175, 14),
149
+ };
150
+
151
+ /** Standard-tier serverless rates from https://docs.fireworks.ai/serverless/pricing */
152
+ const FIREWORKS_PRICING: Record<string, ModelPricing> = {
153
+ "fireworks-ai/accounts/fireworks/models/kimi-k3": withoutWritePremium(3, 0.3, 15),
154
+ };
155
+
156
+ /** Pricing per million tokens (USD) in force today; Claude's from https://platform.claude.com/docs/en/about-claude/pricing */
119
157
  export const MODEL_PRICING: Record<string, ModelPricing> = {
158
+ ...OPENAI_PRICING,
159
+ ...FIREWORKS_PRICING,
120
160
  [HAIKU_MODEL]: {
121
161
  input: 1,
122
162
  output: 5,