@majkapp/plugin-kit 3.7.1 → 3.7.3
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/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/majk-interface-types.d.ts +1413 -0
- package/dist/majk-interface-types.d.ts.map +1 -1
- package/dist/plugin-kit.d.ts +90 -1
- package/dist/plugin-kit.d.ts.map +1 -1
- package/dist/plugin-kit.js +62 -0
- package/dist/types.d.ts +94 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1573,6 +1573,1413 @@ export interface ConfigAPI {
|
|
|
1573
1573
|
*/
|
|
1574
1574
|
getAll(): Record<string, any>;
|
|
1575
1575
|
}
|
|
1576
|
+
/**
|
|
1577
|
+
* Context passed to skill setup/teardown functions
|
|
1578
|
+
*/
|
|
1579
|
+
export interface SkillContext {
|
|
1580
|
+
/** ID of the teammate enabling the skill */
|
|
1581
|
+
teammateId: string;
|
|
1582
|
+
/** ID of the current conversation */
|
|
1583
|
+
conversationId: string;
|
|
1584
|
+
/** Root directory of the project */
|
|
1585
|
+
projectRootDir: string;
|
|
1586
|
+
/** Workspace directory for the project */
|
|
1587
|
+
projectWorkspaceDir: string;
|
|
1588
|
+
}
|
|
1589
|
+
/**
|
|
1590
|
+
* Setup function signature - called when skill is enabled
|
|
1591
|
+
* Returns additional context/instructions to prepend to skill instructions
|
|
1592
|
+
*/
|
|
1593
|
+
export type SkillSetupFn = (context: SkillContext) => Promise<string | void>;
|
|
1594
|
+
/**
|
|
1595
|
+
* Teardown function signature - called when skill is disabled
|
|
1596
|
+
*/
|
|
1597
|
+
export type SkillTeardownFn = (context: SkillContext) => Promise<void>;
|
|
1598
|
+
/**
|
|
1599
|
+
* Base skill definition - shared between DB and runtime skills
|
|
1600
|
+
*/
|
|
1601
|
+
export interface SkillDefinition {
|
|
1602
|
+
/** Unique identifier for the skill */
|
|
1603
|
+
id: string;
|
|
1604
|
+
/** Display name for the skill */
|
|
1605
|
+
name: string;
|
|
1606
|
+
/** One-sentence description of what the skill does */
|
|
1607
|
+
description: string;
|
|
1608
|
+
/** Full instructions on how to accomplish tasks using this skill's tools */
|
|
1609
|
+
instructions: string;
|
|
1610
|
+
/** Optional tags for categorization and search */
|
|
1611
|
+
tags?: string[];
|
|
1612
|
+
/** Optional list of tool names this skill uses */
|
|
1613
|
+
tools?: string[];
|
|
1614
|
+
/** Whether the skill is currently enabled */
|
|
1615
|
+
enabled: boolean;
|
|
1616
|
+
}
|
|
1617
|
+
/**
|
|
1618
|
+
* Runtime-registered skill (can have functions)
|
|
1619
|
+
* Functions are not serialized - they exist only in memory
|
|
1620
|
+
*/
|
|
1621
|
+
export interface RuntimeSkill extends SkillDefinition {
|
|
1622
|
+
/**
|
|
1623
|
+
* Optional setup function - called when skill is enabled.
|
|
1624
|
+
* Can return additional instructions to prepend to the skill.
|
|
1625
|
+
*/
|
|
1626
|
+
setup?: SkillSetupFn;
|
|
1627
|
+
/**
|
|
1628
|
+
* Optional teardown function - called when skill is disabled.
|
|
1629
|
+
* Not currently used but reserved for future use.
|
|
1630
|
+
*/
|
|
1631
|
+
teardown?: SkillTeardownFn;
|
|
1632
|
+
/** Source of the runtime skill (for debugging) */
|
|
1633
|
+
source?: string;
|
|
1634
|
+
}
|
|
1635
|
+
/**
|
|
1636
|
+
* Unified skill type returned from list/search operations
|
|
1637
|
+
* Omits functions since they don't serialize
|
|
1638
|
+
*/
|
|
1639
|
+
export interface Skill extends SkillDefinition {
|
|
1640
|
+
/** Whether this skill is from the database (true) or runtime (false) */
|
|
1641
|
+
persisted: boolean;
|
|
1642
|
+
/** Whether this skill has a setup function */
|
|
1643
|
+
hasSetup: boolean;
|
|
1644
|
+
/** Whether this skill has a teardown function */
|
|
1645
|
+
hasTeardown: boolean;
|
|
1646
|
+
/** Source of the skill */
|
|
1647
|
+
source: 'database' | 'runtime';
|
|
1648
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* Summary of a skill for listing
|
|
1651
|
+
*/
|
|
1652
|
+
export interface SkillSummary {
|
|
1653
|
+
/** Skill ID */
|
|
1654
|
+
id: string;
|
|
1655
|
+
/** Display name */
|
|
1656
|
+
name: string;
|
|
1657
|
+
/** One-sentence description */
|
|
1658
|
+
description: string;
|
|
1659
|
+
/** Whether enabled */
|
|
1660
|
+
enabled: boolean;
|
|
1661
|
+
/** Source */
|
|
1662
|
+
source: 'database' | 'runtime';
|
|
1663
|
+
/** Tags */
|
|
1664
|
+
tags?: string[];
|
|
1665
|
+
}
|
|
1666
|
+
export interface AddSkillInput {
|
|
1667
|
+
/** Unique identifier (auto-generated if not provided) */
|
|
1668
|
+
id?: string;
|
|
1669
|
+
/** Display name */
|
|
1670
|
+
name: string;
|
|
1671
|
+
/** One-sentence description */
|
|
1672
|
+
description: string;
|
|
1673
|
+
/** Full instructions */
|
|
1674
|
+
instructions: string;
|
|
1675
|
+
/** Optional tags */
|
|
1676
|
+
tags?: string[];
|
|
1677
|
+
/** Optional tool names */
|
|
1678
|
+
tools?: string[];
|
|
1679
|
+
/** Initial enabled state (default: true) */
|
|
1680
|
+
enabled?: boolean;
|
|
1681
|
+
}
|
|
1682
|
+
export interface UpdateSkillInput {
|
|
1683
|
+
/** Skill ID to update */
|
|
1684
|
+
id: string;
|
|
1685
|
+
/** Updated name */
|
|
1686
|
+
name?: string;
|
|
1687
|
+
/** Updated description */
|
|
1688
|
+
description?: string;
|
|
1689
|
+
/** Updated instructions */
|
|
1690
|
+
instructions?: string;
|
|
1691
|
+
/** Updated tags */
|
|
1692
|
+
tags?: string[];
|
|
1693
|
+
/** Updated tools */
|
|
1694
|
+
tools?: string[];
|
|
1695
|
+
/** Updated enabled state */
|
|
1696
|
+
enabled?: boolean;
|
|
1697
|
+
}
|
|
1698
|
+
export interface SearchSkillsInput {
|
|
1699
|
+
/** Free text query to search across name, description, instructions, tags */
|
|
1700
|
+
query: string;
|
|
1701
|
+
/** Limit results */
|
|
1702
|
+
limit?: number;
|
|
1703
|
+
/** Include disabled skills */
|
|
1704
|
+
includeDisabled?: boolean;
|
|
1705
|
+
}
|
|
1706
|
+
export interface EnableSkillInput {
|
|
1707
|
+
/** Skill ID or name to enable */
|
|
1708
|
+
skill: string;
|
|
1709
|
+
}
|
|
1710
|
+
export interface DisableSkillInput {
|
|
1711
|
+
/** Skill ID or name to disable */
|
|
1712
|
+
skill: string;
|
|
1713
|
+
}
|
|
1714
|
+
export interface DeleteSkillInput {
|
|
1715
|
+
/** Skill ID to delete */
|
|
1716
|
+
id: string;
|
|
1717
|
+
}
|
|
1718
|
+
export interface ListSkillsResult {
|
|
1719
|
+
skills: SkillSummary[];
|
|
1720
|
+
total: number;
|
|
1721
|
+
}
|
|
1722
|
+
export interface SearchSkillsResult {
|
|
1723
|
+
/** Skills that match the query well */
|
|
1724
|
+
matching: SkillSummary[];
|
|
1725
|
+
/** Skills that might be relevant */
|
|
1726
|
+
related: SkillSummary[];
|
|
1727
|
+
total: number;
|
|
1728
|
+
}
|
|
1729
|
+
export interface EnableSkillResult {
|
|
1730
|
+
/** Skill ID */
|
|
1731
|
+
id: string;
|
|
1732
|
+
/** Skill name */
|
|
1733
|
+
name: string;
|
|
1734
|
+
/** The full instructions to use */
|
|
1735
|
+
instructions: string;
|
|
1736
|
+
/** Additional setup instructions (if setup was called) */
|
|
1737
|
+
setupInstructions?: string;
|
|
1738
|
+
/** Tools used by this skill */
|
|
1739
|
+
tools?: string[];
|
|
1740
|
+
/** Whether setup was executed */
|
|
1741
|
+
setupExecuted: boolean;
|
|
1742
|
+
}
|
|
1743
|
+
export interface AddSkillResult {
|
|
1744
|
+
id: string;
|
|
1745
|
+
name: string;
|
|
1746
|
+
description: string;
|
|
1747
|
+
}
|
|
1748
|
+
export interface UpdateSkillResult {
|
|
1749
|
+
id: string;
|
|
1750
|
+
name: string;
|
|
1751
|
+
updated: boolean;
|
|
1752
|
+
}
|
|
1753
|
+
export type SkillEventType = 'skill_added' | 'skill_updated' | 'skill_deleted' | 'skill_enabled' | 'skill_disabled' | 'runtime_skill_registered' | 'runtime_skill_unregistered';
|
|
1754
|
+
export interface SkillEvent {
|
|
1755
|
+
type: SkillEventType;
|
|
1756
|
+
skillId: string;
|
|
1757
|
+
timestamp: Date;
|
|
1758
|
+
data?: any;
|
|
1759
|
+
}
|
|
1760
|
+
/**
|
|
1761
|
+
* Skills API - Provides access to skill discovery, management, and enablement.
|
|
1762
|
+
*
|
|
1763
|
+
* Skills are instructions on how to accomplish tasks using tools.
|
|
1764
|
+
* They can be:
|
|
1765
|
+
* - Database-persisted: Created via add(), no setup/teardown
|
|
1766
|
+
* - Runtime-registered: Created via registerRuntime(), can have setup/teardown
|
|
1767
|
+
*
|
|
1768
|
+
* @example
|
|
1769
|
+
* ```typescript
|
|
1770
|
+
* // List all available skills
|
|
1771
|
+
* const { skills } = await ctx.majk.skills.list();
|
|
1772
|
+
*
|
|
1773
|
+
* // Search for skills
|
|
1774
|
+
* const results = await ctx.majk.skills.search(conversationId, { query: 'code review' });
|
|
1775
|
+
*
|
|
1776
|
+
* // Enable a skill (calls setup if available)
|
|
1777
|
+
* const result = await ctx.majk.skills.enable(context, { skill: 'code-review-mode' });
|
|
1778
|
+
* console.log(result.instructions);
|
|
1779
|
+
*
|
|
1780
|
+
* // Register a runtime skill with setup/teardown
|
|
1781
|
+
* await ctx.majk.skills.registerRuntime({
|
|
1782
|
+
* id: 'my-skill',
|
|
1783
|
+
* name: 'My Custom Skill',
|
|
1784
|
+
* description: 'Does something useful',
|
|
1785
|
+
* instructions: 'Follow these steps...',
|
|
1786
|
+
* enabled: true,
|
|
1787
|
+
* setup: async (ctx) => 'Additional context from setup',
|
|
1788
|
+
* teardown: async (ctx) => { cleanup(); }
|
|
1789
|
+
* });
|
|
1790
|
+
* ```
|
|
1791
|
+
*/
|
|
1792
|
+
export interface SkillsAPI {
|
|
1793
|
+
/**
|
|
1794
|
+
* List all available skills.
|
|
1795
|
+
*
|
|
1796
|
+
* @param conversationId - Optional conversation ID for scoped skills
|
|
1797
|
+
* @param includeDisabled - Include disabled skills in results
|
|
1798
|
+
* @returns List of skill summaries
|
|
1799
|
+
*/
|
|
1800
|
+
list(conversationId?: string, includeDisabled?: boolean): Promise<ListSkillsResult>;
|
|
1801
|
+
/**
|
|
1802
|
+
* Search skills by query.
|
|
1803
|
+
*
|
|
1804
|
+
* @param conversationId - Optional conversation ID for scoped skills
|
|
1805
|
+
* @param input - Search parameters
|
|
1806
|
+
* @returns Matching and related skills
|
|
1807
|
+
*/
|
|
1808
|
+
search(conversationId: string | undefined, input: SearchSkillsInput): Promise<SearchSkillsResult>;
|
|
1809
|
+
/**
|
|
1810
|
+
* Get a skill by ID.
|
|
1811
|
+
*
|
|
1812
|
+
* @param skillId - The skill ID
|
|
1813
|
+
* @returns Full skill data or null if not found
|
|
1814
|
+
*/
|
|
1815
|
+
getById(skillId: string): Promise<Skill | null>;
|
|
1816
|
+
/**
|
|
1817
|
+
* Add a new skill to the database.
|
|
1818
|
+
*
|
|
1819
|
+
* @param conversationId - Optional conversation ID for scoped skills
|
|
1820
|
+
* @param input - Skill data
|
|
1821
|
+
* @returns Created skill summary
|
|
1822
|
+
*/
|
|
1823
|
+
add(conversationId: string | undefined, input: AddSkillInput): Promise<AddSkillResult>;
|
|
1824
|
+
/**
|
|
1825
|
+
* Update an existing skill in the database.
|
|
1826
|
+
*
|
|
1827
|
+
* @param input - Update data including skill ID
|
|
1828
|
+
* @returns Updated skill summary
|
|
1829
|
+
*/
|
|
1830
|
+
update(input: UpdateSkillInput): Promise<UpdateSkillResult>;
|
|
1831
|
+
/**
|
|
1832
|
+
* Delete a skill from the database.
|
|
1833
|
+
*
|
|
1834
|
+
* @param input - Delete parameters
|
|
1835
|
+
* @returns True if deleted
|
|
1836
|
+
*/
|
|
1837
|
+
delete(input: DeleteSkillInput): Promise<boolean>;
|
|
1838
|
+
/**
|
|
1839
|
+
* Enable a skill and get its instructions.
|
|
1840
|
+
* Calls the skill's setup() function if available.
|
|
1841
|
+
*
|
|
1842
|
+
* @param context - Skill context with conversation and project info
|
|
1843
|
+
* @param input - Enable parameters
|
|
1844
|
+
* @returns Skill instructions and setup result
|
|
1845
|
+
*/
|
|
1846
|
+
enable(context: SkillContext, input: EnableSkillInput): Promise<EnableSkillResult>;
|
|
1847
|
+
/**
|
|
1848
|
+
* Disable a skill.
|
|
1849
|
+
*
|
|
1850
|
+
* @param conversationId - Conversation ID
|
|
1851
|
+
* @param input - Disable parameters
|
|
1852
|
+
* @returns True if disabled
|
|
1853
|
+
*/
|
|
1854
|
+
disable(conversationId: string, input: DisableSkillInput): Promise<boolean>;
|
|
1855
|
+
/**
|
|
1856
|
+
* Register a runtime skill (with optional setup/teardown).
|
|
1857
|
+
* Runtime skills are not persisted and exist only in memory.
|
|
1858
|
+
*
|
|
1859
|
+
* @param skill - Runtime skill definition
|
|
1860
|
+
*/
|
|
1861
|
+
registerRuntime(skill: RuntimeSkill): Promise<void>;
|
|
1862
|
+
/**
|
|
1863
|
+
* Unregister a runtime skill.
|
|
1864
|
+
*
|
|
1865
|
+
* @param skillId - The skill ID to unregister
|
|
1866
|
+
* @returns True if the skill was found and removed
|
|
1867
|
+
*/
|
|
1868
|
+
unregisterRuntime(skillId: string): Promise<boolean>;
|
|
1869
|
+
/**
|
|
1870
|
+
* Get a runtime skill by ID (if it exists).
|
|
1871
|
+
*
|
|
1872
|
+
* @param skillId - The skill ID
|
|
1873
|
+
* @returns Runtime skill or undefined
|
|
1874
|
+
*/
|
|
1875
|
+
getRuntime(skillId: string): Promise<RuntimeSkill | undefined>;
|
|
1876
|
+
/**
|
|
1877
|
+
* Subscribe to skill events.
|
|
1878
|
+
*
|
|
1879
|
+
* @param eventType - The event type to listen for
|
|
1880
|
+
* @param handler - Event handler function
|
|
1881
|
+
* @returns Unsubscribe function
|
|
1882
|
+
*/
|
|
1883
|
+
on(eventType: SkillEventType, handler: (event: SkillEvent) => void): Promise<Unsubscribe>;
|
|
1884
|
+
}
|
|
1885
|
+
/**
|
|
1886
|
+
* Witness - Recursive structure for verification checks.
|
|
1887
|
+
* Used by delegation and batch services.
|
|
1888
|
+
*/
|
|
1889
|
+
export interface Witness {
|
|
1890
|
+
bash?: string | {
|
|
1891
|
+
command: string;
|
|
1892
|
+
stdout_contains?: string;
|
|
1893
|
+
stdout_not_contains?: string;
|
|
1894
|
+
stderr_contains?: string;
|
|
1895
|
+
exit_code?: number;
|
|
1896
|
+
};
|
|
1897
|
+
file?: {
|
|
1898
|
+
path: string;
|
|
1899
|
+
contains?: string;
|
|
1900
|
+
not_contains?: string;
|
|
1901
|
+
exists?: boolean;
|
|
1902
|
+
json_path?: string;
|
|
1903
|
+
equals?: any;
|
|
1904
|
+
};
|
|
1905
|
+
files?: string[];
|
|
1906
|
+
http?: {
|
|
1907
|
+
url: string;
|
|
1908
|
+
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD';
|
|
1909
|
+
status?: number | number[];
|
|
1910
|
+
body_contains?: string;
|
|
1911
|
+
headers?: Record<string, string>;
|
|
1912
|
+
body?: any;
|
|
1913
|
+
};
|
|
1914
|
+
llm?: {
|
|
1915
|
+
prompt: string;
|
|
1916
|
+
file?: string;
|
|
1917
|
+
context?: string;
|
|
1918
|
+
};
|
|
1919
|
+
vision?: {
|
|
1920
|
+
image: string;
|
|
1921
|
+
checklist: string[];
|
|
1922
|
+
context?: string;
|
|
1923
|
+
};
|
|
1924
|
+
js?: {
|
|
1925
|
+
code?: string;
|
|
1926
|
+
file?: string;
|
|
1927
|
+
timeout?: number;
|
|
1928
|
+
};
|
|
1929
|
+
message?: {
|
|
1930
|
+
contains?: string;
|
|
1931
|
+
index?: number;
|
|
1932
|
+
from?: 'user' | 'assistant' | 'any';
|
|
1933
|
+
after_message?: number;
|
|
1934
|
+
};
|
|
1935
|
+
all?: Witness[];
|
|
1936
|
+
any?: Witness[];
|
|
1937
|
+
}
|
|
1938
|
+
/**
|
|
1939
|
+
* Result from running a witness verification
|
|
1940
|
+
*/
|
|
1941
|
+
export interface WitnessResult {
|
|
1942
|
+
passed: boolean;
|
|
1943
|
+
evidence: string;
|
|
1944
|
+
strength: 'hard' | 'soft';
|
|
1945
|
+
executionTimeMs: number;
|
|
1946
|
+
children?: WitnessResult[];
|
|
1947
|
+
}
|
|
1948
|
+
export type DelegationTaskStatus = 'pending' | 'running' | 'completed' | 'failed' | 'blocked' | 'abandoned';
|
|
1949
|
+
export interface DelegationTeammate {
|
|
1950
|
+
id: string;
|
|
1951
|
+
name: string;
|
|
1952
|
+
skills?: string[];
|
|
1953
|
+
description?: string;
|
|
1954
|
+
}
|
|
1955
|
+
export interface DelegationTaskResult {
|
|
1956
|
+
success: boolean;
|
|
1957
|
+
summary: string;
|
|
1958
|
+
witnessResults: Array<{
|
|
1959
|
+
witness: string;
|
|
1960
|
+
passed: boolean;
|
|
1961
|
+
evidence: string;
|
|
1962
|
+
}>;
|
|
1963
|
+
verification?: WitnessResult;
|
|
1964
|
+
}
|
|
1965
|
+
export interface DelegationTaskBlocker {
|
|
1966
|
+
summary: string;
|
|
1967
|
+
task: string;
|
|
1968
|
+
witness: Witness;
|
|
1969
|
+
evidence?: Witness;
|
|
1970
|
+
assignTo: string;
|
|
1971
|
+
reportedAt: Date | string;
|
|
1972
|
+
blockerTaskId?: string;
|
|
1973
|
+
}
|
|
1974
|
+
export interface DelegationRecentMessage {
|
|
1975
|
+
role: string;
|
|
1976
|
+
content: string;
|
|
1977
|
+
timestamp: Date | string;
|
|
1978
|
+
}
|
|
1979
|
+
export interface DelegationTaskStatusOutput {
|
|
1980
|
+
taskId: string;
|
|
1981
|
+
status: DelegationTaskStatus;
|
|
1982
|
+
teammateId: string;
|
|
1983
|
+
teammateName: string;
|
|
1984
|
+
result?: DelegationTaskResult;
|
|
1985
|
+
blocker?: DelegationTaskBlocker;
|
|
1986
|
+
recentMessages?: DelegationRecentMessage[];
|
|
1987
|
+
progress?: {
|
|
1988
|
+
messageCount: number;
|
|
1989
|
+
durationMs: number;
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
export interface DelegationBlockerInfo {
|
|
1993
|
+
taskId: string;
|
|
1994
|
+
teammateId: string;
|
|
1995
|
+
teammateName: string;
|
|
1996
|
+
task: string;
|
|
1997
|
+
blocker: DelegationTaskBlocker;
|
|
1998
|
+
reportedAt: string;
|
|
1999
|
+
durationMs: number;
|
|
2000
|
+
}
|
|
2001
|
+
/**
|
|
2002
|
+
* Delegation API - Multi-agent task delegation with witness-based verification.
|
|
2003
|
+
*
|
|
2004
|
+
* @example
|
|
2005
|
+
* ```typescript
|
|
2006
|
+
* // List available teammates
|
|
2007
|
+
* const { teammates } = await ctx.majk.delegation.list_teammates();
|
|
2008
|
+
*
|
|
2009
|
+
* // Delegate a task
|
|
2010
|
+
* const result = await ctx.majk.delegation.delegate_task({
|
|
2011
|
+
* teammate: 'code-reviewer',
|
|
2012
|
+
* task: 'Review the auth module for security issues',
|
|
2013
|
+
* witness: { bash: 'npm test' }
|
|
2014
|
+
* });
|
|
2015
|
+
*
|
|
2016
|
+
* // Wait for completion
|
|
2017
|
+
* const status = await ctx.majk.delegation.await_task({
|
|
2018
|
+
* taskId: result.taskId
|
|
2019
|
+
* });
|
|
2020
|
+
* ```
|
|
2021
|
+
*/
|
|
2022
|
+
export interface DelegationAPI {
|
|
2023
|
+
/**
|
|
2024
|
+
* List all available teammates that can be delegated tasks to.
|
|
2025
|
+
*/
|
|
2026
|
+
list_teammates(): Promise<{
|
|
2027
|
+
teammates: DelegationTeammate[];
|
|
2028
|
+
count: number;
|
|
2029
|
+
_hint: string;
|
|
2030
|
+
}>;
|
|
2031
|
+
/**
|
|
2032
|
+
* Delegate a task to a teammate asynchronously.
|
|
2033
|
+
* Returns immediately with a task ID. The task runs in the background.
|
|
2034
|
+
*/
|
|
2035
|
+
delegate_task(input: {
|
|
2036
|
+
teammate: string;
|
|
2037
|
+
task: string;
|
|
2038
|
+
context?: Witness;
|
|
2039
|
+
witness: Witness;
|
|
2040
|
+
workingDirectory?: string;
|
|
2041
|
+
}): Promise<{
|
|
2042
|
+
taskId: string;
|
|
2043
|
+
teammateId: string;
|
|
2044
|
+
teammateName: string;
|
|
2045
|
+
conversationId: string;
|
|
2046
|
+
status: 'running';
|
|
2047
|
+
_hint: string;
|
|
2048
|
+
}>;
|
|
2049
|
+
/**
|
|
2050
|
+
* Check the current status of a delegated task.
|
|
2051
|
+
*/
|
|
2052
|
+
check_task_status(input: {
|
|
2053
|
+
taskId: string;
|
|
2054
|
+
messageCount?: number;
|
|
2055
|
+
}): Promise<DelegationTaskStatusOutput>;
|
|
2056
|
+
/**
|
|
2057
|
+
* Wait for a task to complete.
|
|
2058
|
+
* Blocks until the task finishes or timeout is reached.
|
|
2059
|
+
*/
|
|
2060
|
+
await_task(input: {
|
|
2061
|
+
taskId: string;
|
|
2062
|
+
timeoutMs?: number;
|
|
2063
|
+
}): Promise<DelegationTaskStatusOutput>;
|
|
2064
|
+
/**
|
|
2065
|
+
* Wait for multiple tasks to complete (fan-out/fan-in pattern).
|
|
2066
|
+
*/
|
|
2067
|
+
await_tasks(input: {
|
|
2068
|
+
taskIds: string[];
|
|
2069
|
+
timeoutMs?: number;
|
|
2070
|
+
}): Promise<{
|
|
2071
|
+
results: DelegationTaskStatusOutput[];
|
|
2072
|
+
summary: {
|
|
2073
|
+
total: number;
|
|
2074
|
+
completed: number;
|
|
2075
|
+
failed: number;
|
|
2076
|
+
blocked: number;
|
|
2077
|
+
stillRunning: number;
|
|
2078
|
+
};
|
|
2079
|
+
allCompleted: boolean;
|
|
2080
|
+
allSucceeded: boolean;
|
|
2081
|
+
}>;
|
|
2082
|
+
/**
|
|
2083
|
+
* Run a witness to verify something right now.
|
|
2084
|
+
*/
|
|
2085
|
+
check_witness(input: {
|
|
2086
|
+
witness: Witness;
|
|
2087
|
+
workingDirectory?: string;
|
|
2088
|
+
}): Promise<WitnessResult>;
|
|
2089
|
+
/**
|
|
2090
|
+
* List all currently blocked tasks with their blocker details.
|
|
2091
|
+
*/
|
|
2092
|
+
get_blockers(input?: {
|
|
2093
|
+
teammateId?: string;
|
|
2094
|
+
assignedTo?: string;
|
|
2095
|
+
}): Promise<{
|
|
2096
|
+
blockers: DelegationBlockerInfo[];
|
|
2097
|
+
count: number;
|
|
2098
|
+
}>;
|
|
2099
|
+
/**
|
|
2100
|
+
* Resolve a blocker by updating the task, witness, or sending instructions.
|
|
2101
|
+
*/
|
|
2102
|
+
resolve_blocker(input: {
|
|
2103
|
+
taskId: string;
|
|
2104
|
+
action: 'update_task' | 'update_witness' | 'send_instruction' | 'unblock';
|
|
2105
|
+
newTask?: string;
|
|
2106
|
+
newWitness?: Witness;
|
|
2107
|
+
instruction?: string;
|
|
2108
|
+
resolution?: string;
|
|
2109
|
+
}): Promise<{
|
|
2110
|
+
taskId: string;
|
|
2111
|
+
action: string;
|
|
2112
|
+
previousStatus: DelegationTaskStatus;
|
|
2113
|
+
newStatus: DelegationTaskStatus;
|
|
2114
|
+
message: string;
|
|
2115
|
+
}>;
|
|
2116
|
+
}
|
|
2117
|
+
export type BatchJobStatus = 'pending' | 'running' | 'paused' | 'completed' | 'failed' | 'cancelled';
|
|
2118
|
+
export type BatchItemStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
|
|
2119
|
+
export interface BatchInputSource {
|
|
2120
|
+
type: 'list' | 'directory' | 'glob';
|
|
2121
|
+
items?: any[];
|
|
2122
|
+
path?: string;
|
|
2123
|
+
recursive?: boolean;
|
|
2124
|
+
extensions?: string[];
|
|
2125
|
+
exclude?: string[];
|
|
2126
|
+
pattern?: string;
|
|
2127
|
+
basePath?: string;
|
|
2128
|
+
ignore?: string[];
|
|
2129
|
+
}
|
|
2130
|
+
export interface BatchProcessorConfig {
|
|
2131
|
+
type: 'teammate' | 'rpc' | 'witness' | 'script';
|
|
2132
|
+
teammateId?: string;
|
|
2133
|
+
taskTemplate?: string;
|
|
2134
|
+
context?: Witness;
|
|
2135
|
+
witness?: Witness;
|
|
2136
|
+
workingDirectory?: string;
|
|
2137
|
+
taskTimeoutMs?: number;
|
|
2138
|
+
pluginId?: string;
|
|
2139
|
+
serviceName?: string;
|
|
2140
|
+
functionName?: string;
|
|
2141
|
+
input?: Record<string, any>;
|
|
2142
|
+
code?: string;
|
|
2143
|
+
file?: string;
|
|
2144
|
+
timeoutMs?: number;
|
|
2145
|
+
}
|
|
2146
|
+
export interface BatchExecutionConfig {
|
|
2147
|
+
maxParallelism?: number;
|
|
2148
|
+
itemTimeoutMs?: number;
|
|
2149
|
+
jobTimeoutMs?: number;
|
|
2150
|
+
retry?: {
|
|
2151
|
+
maxAttempts?: number;
|
|
2152
|
+
backoff?: 'none' | 'fixed' | 'linear' | 'exponential';
|
|
2153
|
+
initialDelayMs?: number;
|
|
2154
|
+
maxDelayMs?: number;
|
|
2155
|
+
jitter?: boolean;
|
|
2156
|
+
};
|
|
2157
|
+
}
|
|
2158
|
+
export interface BatchProgress {
|
|
2159
|
+
totalItems: number;
|
|
2160
|
+
completedItems: number;
|
|
2161
|
+
failedItems: number;
|
|
2162
|
+
skippedItems?: number;
|
|
2163
|
+
runningItems?: number;
|
|
2164
|
+
pendingItems?: number;
|
|
2165
|
+
}
|
|
2166
|
+
export interface BatchJob {
|
|
2167
|
+
id: string;
|
|
2168
|
+
name: string;
|
|
2169
|
+
status: BatchJobStatus;
|
|
2170
|
+
statusReason?: string;
|
|
2171
|
+
createdAt: Date | string;
|
|
2172
|
+
startedAt?: Date | string;
|
|
2173
|
+
completedAt?: Date | string;
|
|
2174
|
+
progress: BatchProgress;
|
|
2175
|
+
resultSummary?: any;
|
|
2176
|
+
tags?: string[];
|
|
2177
|
+
}
|
|
2178
|
+
export interface BatchJobItem {
|
|
2179
|
+
id: string;
|
|
2180
|
+
index: number;
|
|
2181
|
+
status: BatchItemStatus;
|
|
2182
|
+
data: any;
|
|
2183
|
+
result?: any;
|
|
2184
|
+
error?: string;
|
|
2185
|
+
errorCode?: string;
|
|
2186
|
+
attempts?: number;
|
|
2187
|
+
durationMs?: number;
|
|
2188
|
+
}
|
|
2189
|
+
/**
|
|
2190
|
+
* Batch API - Batch processing for large sets of items.
|
|
2191
|
+
*
|
|
2192
|
+
* @example
|
|
2193
|
+
* ```typescript
|
|
2194
|
+
* // Create a batch job
|
|
2195
|
+
* const { job } = await ctx.majk.batch.create_batch_job({
|
|
2196
|
+
* name: 'Process files',
|
|
2197
|
+
* input: { source: { type: 'glob', pattern: 'src/**\/*.ts' } },
|
|
2198
|
+
* processor: {
|
|
2199
|
+
* type: 'teammate',
|
|
2200
|
+
* teammateId: 'code-reviewer',
|
|
2201
|
+
* taskTemplate: 'Review {{item}}'
|
|
2202
|
+
* },
|
|
2203
|
+
* autoStart: true
|
|
2204
|
+
* });
|
|
2205
|
+
*
|
|
2206
|
+
* // Wait for completion
|
|
2207
|
+
* const result = await ctx.majk.batch.await_batch_job({ jobId: job.id });
|
|
2208
|
+
* ```
|
|
2209
|
+
*/
|
|
2210
|
+
export interface BatchAPI {
|
|
2211
|
+
/**
|
|
2212
|
+
* Create a new batch processing job.
|
|
2213
|
+
*/
|
|
2214
|
+
create_batch_job(input: {
|
|
2215
|
+
name: string;
|
|
2216
|
+
description?: string;
|
|
2217
|
+
input: {
|
|
2218
|
+
source: BatchInputSource;
|
|
2219
|
+
transformTemplate?: string;
|
|
2220
|
+
skipIfTemplate?: string;
|
|
2221
|
+
limit?: number;
|
|
2222
|
+
};
|
|
2223
|
+
processor: BatchProcessorConfig;
|
|
2224
|
+
execution?: BatchExecutionConfig;
|
|
2225
|
+
tags?: string[];
|
|
2226
|
+
metadata?: Record<string, any>;
|
|
2227
|
+
autoStart?: boolean;
|
|
2228
|
+
}): Promise<{
|
|
2229
|
+
job: BatchJob;
|
|
2230
|
+
_hint: string;
|
|
2231
|
+
}>;
|
|
2232
|
+
/**
|
|
2233
|
+
* Start a pending batch job.
|
|
2234
|
+
*/
|
|
2235
|
+
start_batch_job(input: {
|
|
2236
|
+
jobId: string;
|
|
2237
|
+
}): Promise<{
|
|
2238
|
+
job: BatchJob;
|
|
2239
|
+
_hint: string;
|
|
2240
|
+
}>;
|
|
2241
|
+
/**
|
|
2242
|
+
* Pause a running batch job.
|
|
2243
|
+
*/
|
|
2244
|
+
pause_batch_job(input: {
|
|
2245
|
+
jobId: string;
|
|
2246
|
+
reason?: string;
|
|
2247
|
+
}): Promise<{
|
|
2248
|
+
job: BatchJob;
|
|
2249
|
+
_hint: string;
|
|
2250
|
+
}>;
|
|
2251
|
+
/**
|
|
2252
|
+
* Resume a paused batch job.
|
|
2253
|
+
*/
|
|
2254
|
+
resume_batch_job(input: {
|
|
2255
|
+
jobId: string;
|
|
2256
|
+
}): Promise<{
|
|
2257
|
+
job: BatchJob;
|
|
2258
|
+
}>;
|
|
2259
|
+
/**
|
|
2260
|
+
* Cancel a batch job.
|
|
2261
|
+
*/
|
|
2262
|
+
cancel_batch_job(input: {
|
|
2263
|
+
jobId: string;
|
|
2264
|
+
}): Promise<{
|
|
2265
|
+
job: BatchJob;
|
|
2266
|
+
}>;
|
|
2267
|
+
/**
|
|
2268
|
+
* Get the current status and progress of a batch job.
|
|
2269
|
+
*/
|
|
2270
|
+
check_batch_job(input: {
|
|
2271
|
+
jobId: string;
|
|
2272
|
+
includeFailedItems?: boolean;
|
|
2273
|
+
failedItemsLimit?: number;
|
|
2274
|
+
}): Promise<{
|
|
2275
|
+
job: {
|
|
2276
|
+
id: string;
|
|
2277
|
+
name: string;
|
|
2278
|
+
status: BatchJobStatus;
|
|
2279
|
+
statusReason?: string;
|
|
2280
|
+
createdAt: Date | string;
|
|
2281
|
+
startedAt?: Date | string;
|
|
2282
|
+
completedAt?: Date | string;
|
|
2283
|
+
};
|
|
2284
|
+
progress: BatchProgress;
|
|
2285
|
+
resultSummary?: any;
|
|
2286
|
+
failedItems?: Array<{
|
|
2287
|
+
id: string;
|
|
2288
|
+
index: number;
|
|
2289
|
+
data: any;
|
|
2290
|
+
error?: string;
|
|
2291
|
+
errorCode?: string;
|
|
2292
|
+
}>;
|
|
2293
|
+
}>;
|
|
2294
|
+
/**
|
|
2295
|
+
* Wait for a batch job to complete.
|
|
2296
|
+
*/
|
|
2297
|
+
await_batch_job(input: {
|
|
2298
|
+
jobId: string;
|
|
2299
|
+
timeoutMs?: number;
|
|
2300
|
+
ignoreBlockers?: boolean;
|
|
2301
|
+
}): Promise<{
|
|
2302
|
+
job: {
|
|
2303
|
+
id: string;
|
|
2304
|
+
name: string;
|
|
2305
|
+
status: BatchJobStatus;
|
|
2306
|
+
statusReason?: string;
|
|
2307
|
+
createdAt: Date | string;
|
|
2308
|
+
startedAt?: Date | string;
|
|
2309
|
+
completedAt?: Date | string;
|
|
2310
|
+
};
|
|
2311
|
+
resultSummary?: any;
|
|
2312
|
+
finalProgress: BatchProgress;
|
|
2313
|
+
hasBlockers?: boolean;
|
|
2314
|
+
blockedCount?: number;
|
|
2315
|
+
}>;
|
|
2316
|
+
/**
|
|
2317
|
+
* List batch jobs with optional filters.
|
|
2318
|
+
*/
|
|
2319
|
+
list_batch_jobs(input?: {
|
|
2320
|
+
status?: BatchJobStatus | BatchJobStatus[];
|
|
2321
|
+
tags?: string[];
|
|
2322
|
+
limit?: number;
|
|
2323
|
+
offset?: number;
|
|
2324
|
+
}): Promise<{
|
|
2325
|
+
jobs: Array<{
|
|
2326
|
+
id: string;
|
|
2327
|
+
name: string;
|
|
2328
|
+
status: BatchJobStatus;
|
|
2329
|
+
progress: {
|
|
2330
|
+
total: number;
|
|
2331
|
+
completed: number;
|
|
2332
|
+
failed: number;
|
|
2333
|
+
};
|
|
2334
|
+
createdAt: Date | string;
|
|
2335
|
+
tags?: string[];
|
|
2336
|
+
}>;
|
|
2337
|
+
total: number;
|
|
2338
|
+
hasMore: boolean;
|
|
2339
|
+
}>;
|
|
2340
|
+
/**
|
|
2341
|
+
* Get items from a batch job with optional status filter.
|
|
2342
|
+
*/
|
|
2343
|
+
get_batch_job_items(input: {
|
|
2344
|
+
jobId: string;
|
|
2345
|
+
status?: BatchItemStatus | BatchItemStatus[];
|
|
2346
|
+
limit?: number;
|
|
2347
|
+
offset?: number;
|
|
2348
|
+
}): Promise<{
|
|
2349
|
+
items: BatchJobItem[];
|
|
2350
|
+
total: number;
|
|
2351
|
+
hasMore: boolean;
|
|
2352
|
+
}>;
|
|
2353
|
+
/**
|
|
2354
|
+
* Get blocked items from a batch job.
|
|
2355
|
+
*/
|
|
2356
|
+
get_blocked_batch_items(input: {
|
|
2357
|
+
jobId: string;
|
|
2358
|
+
limit?: number;
|
|
2359
|
+
}): Promise<{
|
|
2360
|
+
items: Array<{
|
|
2361
|
+
id: string;
|
|
2362
|
+
index: number;
|
|
2363
|
+
data: any;
|
|
2364
|
+
error?: string;
|
|
2365
|
+
errorCode?: string;
|
|
2366
|
+
originalData?: any;
|
|
2367
|
+
}>;
|
|
2368
|
+
total: number;
|
|
2369
|
+
_hint?: string;
|
|
2370
|
+
}>;
|
|
2371
|
+
/**
|
|
2372
|
+
* Create a new job to replay failed items from a completed job.
|
|
2373
|
+
*/
|
|
2374
|
+
replay_failed_batch_items(input: {
|
|
2375
|
+
jobId: string;
|
|
2376
|
+
}): Promise<{
|
|
2377
|
+
job: BatchJob;
|
|
2378
|
+
_hint: string;
|
|
2379
|
+
}>;
|
|
2380
|
+
/**
|
|
2381
|
+
* Clone a batch job to create a new one with the same configuration.
|
|
2382
|
+
*/
|
|
2383
|
+
clone_batch_job(input: {
|
|
2384
|
+
jobId: string;
|
|
2385
|
+
name?: string;
|
|
2386
|
+
tags?: string[];
|
|
2387
|
+
}): Promise<{
|
|
2388
|
+
job: BatchJob;
|
|
2389
|
+
_hint: string;
|
|
2390
|
+
}>;
|
|
2391
|
+
}
|
|
2392
|
+
export interface ReportSummary {
|
|
2393
|
+
id: string;
|
|
2394
|
+
path: string;
|
|
2395
|
+
uri: string;
|
|
2396
|
+
title?: string;
|
|
2397
|
+
tags?: string[];
|
|
2398
|
+
status?: string;
|
|
2399
|
+
hasWitness: boolean;
|
|
2400
|
+
preview?: string;
|
|
2401
|
+
updatedAt: string;
|
|
2402
|
+
viewPath?: string;
|
|
2403
|
+
}
|
|
2404
|
+
export interface ReportValidation {
|
|
2405
|
+
status: 'valid' | 'invalid' | 'skipped' | 'no-witness';
|
|
2406
|
+
witness?: WitnessResult;
|
|
2407
|
+
}
|
|
2408
|
+
export interface ReportWriteResult {
|
|
2409
|
+
id: string;
|
|
2410
|
+
path: string;
|
|
2411
|
+
uri: string;
|
|
2412
|
+
title?: string;
|
|
2413
|
+
hasWitness: boolean;
|
|
2414
|
+
created: boolean;
|
|
2415
|
+
}
|
|
2416
|
+
export interface ReportReadResult {
|
|
2417
|
+
id: string;
|
|
2418
|
+
path: string;
|
|
2419
|
+
uri: string;
|
|
2420
|
+
title?: string;
|
|
2421
|
+
tags?: string[];
|
|
2422
|
+
status?: string;
|
|
2423
|
+
content: string;
|
|
2424
|
+
totalLines: number;
|
|
2425
|
+
range?: {
|
|
2426
|
+
start: number;
|
|
2427
|
+
end: number;
|
|
2428
|
+
};
|
|
2429
|
+
validation: ReportValidation;
|
|
2430
|
+
updatedAt: string;
|
|
2431
|
+
viewPath?: string;
|
|
2432
|
+
viewName?: string;
|
|
2433
|
+
}
|
|
2434
|
+
export interface ReportView {
|
|
2435
|
+
id: string;
|
|
2436
|
+
name: string;
|
|
2437
|
+
isDefault: boolean;
|
|
2438
|
+
reportCount: number;
|
|
2439
|
+
}
|
|
2440
|
+
export interface ReportViewTreeNode {
|
|
2441
|
+
path: string;
|
|
2442
|
+
name: string;
|
|
2443
|
+
report?: ReportSummary;
|
|
2444
|
+
children: ReportViewTreeNode[];
|
|
2445
|
+
}
|
|
2446
|
+
export interface ReportEdit {
|
|
2447
|
+
line?: number;
|
|
2448
|
+
lines?: [number, number];
|
|
2449
|
+
content?: string;
|
|
2450
|
+
after?: number;
|
|
2451
|
+
delete?: true;
|
|
2452
|
+
}
|
|
2453
|
+
/**
|
|
2454
|
+
* Reports API - Knowledge management with witness-based validation.
|
|
2455
|
+
*
|
|
2456
|
+
* @example
|
|
2457
|
+
* ```typescript
|
|
2458
|
+
* // Write a report
|
|
2459
|
+
* const result = await ctx.majk.reports.write_report({
|
|
2460
|
+
* path: '/research/findings.md',
|
|
2461
|
+
* content: '# Findings\n...',
|
|
2462
|
+
* tags: ['research']
|
|
2463
|
+
* });
|
|
2464
|
+
*
|
|
2465
|
+
* // Read a report
|
|
2466
|
+
* const report = await ctx.majk.reports.read_report({
|
|
2467
|
+
* report: result.id
|
|
2468
|
+
* });
|
|
2469
|
+
*
|
|
2470
|
+
* // List reports
|
|
2471
|
+
* const { reports } = await ctx.majk.reports.list_reports({
|
|
2472
|
+
* pathPrefix: '/research/'
|
|
2473
|
+
* });
|
|
2474
|
+
* ```
|
|
2475
|
+
*/
|
|
2476
|
+
export interface ReportsAPI {
|
|
2477
|
+
/**
|
|
2478
|
+
* Write a report to the knowledge base.
|
|
2479
|
+
*/
|
|
2480
|
+
write_report(input: {
|
|
2481
|
+
content: string;
|
|
2482
|
+
path: string;
|
|
2483
|
+
title?: string;
|
|
2484
|
+
partOf?: {
|
|
2485
|
+
parent: string;
|
|
2486
|
+
placeholder?: string;
|
|
2487
|
+
};
|
|
2488
|
+
refs?: string[];
|
|
2489
|
+
tags?: string[];
|
|
2490
|
+
status?: string;
|
|
2491
|
+
witness?: Witness;
|
|
2492
|
+
}): Promise<ReportWriteResult>;
|
|
2493
|
+
/**
|
|
2494
|
+
* Read a report with embedded content expansion.
|
|
2495
|
+
*/
|
|
2496
|
+
read_report(input: {
|
|
2497
|
+
report: string;
|
|
2498
|
+
view?: string;
|
|
2499
|
+
expand?: 'link' | 'inline' | 'inline-linked';
|
|
2500
|
+
expandDepth?: number;
|
|
2501
|
+
offset?: number;
|
|
2502
|
+
limit?: number;
|
|
2503
|
+
validate?: boolean;
|
|
2504
|
+
workingDirectory?: string;
|
|
2505
|
+
}): Promise<ReportReadResult>;
|
|
2506
|
+
/**
|
|
2507
|
+
* List and search reports.
|
|
2508
|
+
*/
|
|
2509
|
+
list_reports(input?: {
|
|
2510
|
+
view?: string;
|
|
2511
|
+
pathPrefix?: string;
|
|
2512
|
+
tags?: string[];
|
|
2513
|
+
status?: string;
|
|
2514
|
+
hasWitness?: boolean;
|
|
2515
|
+
search?: string;
|
|
2516
|
+
limit?: number;
|
|
2517
|
+
offset?: number;
|
|
2518
|
+
}): Promise<{
|
|
2519
|
+
reports: ReportSummary[];
|
|
2520
|
+
total: number;
|
|
2521
|
+
hasMore: boolean;
|
|
2522
|
+
}>;
|
|
2523
|
+
/**
|
|
2524
|
+
* Delete a report from the knowledge base.
|
|
2525
|
+
*/
|
|
2526
|
+
delete_report(input: {
|
|
2527
|
+
report: string;
|
|
2528
|
+
}): Promise<{
|
|
2529
|
+
deleted: boolean;
|
|
2530
|
+
}>;
|
|
2531
|
+
/**
|
|
2532
|
+
* Batch move reports.
|
|
2533
|
+
*/
|
|
2534
|
+
reorganize_reports(input: {
|
|
2535
|
+
moves: Array<{
|
|
2536
|
+
from: string;
|
|
2537
|
+
to: string;
|
|
2538
|
+
}>;
|
|
2539
|
+
}): Promise<{
|
|
2540
|
+
message: string;
|
|
2541
|
+
moved: Array<{
|
|
2542
|
+
from: string;
|
|
2543
|
+
to: string;
|
|
2544
|
+
id: string;
|
|
2545
|
+
}>;
|
|
2546
|
+
structure: Record<string, string[]>;
|
|
2547
|
+
}>;
|
|
2548
|
+
/**
|
|
2549
|
+
* Start a new report from a template.
|
|
2550
|
+
*/
|
|
2551
|
+
start_report(input: {
|
|
2552
|
+
template: string;
|
|
2553
|
+
topic: string;
|
|
2554
|
+
sections?: Record<string, string>;
|
|
2555
|
+
refs?: Record<string, string | string[]>;
|
|
2556
|
+
validateOnUpdate?: boolean;
|
|
2557
|
+
}): Promise<{
|
|
2558
|
+
handle: string;
|
|
2559
|
+
preview: string;
|
|
2560
|
+
missing: {
|
|
2561
|
+
sections: string[];
|
|
2562
|
+
refs: string[];
|
|
2563
|
+
};
|
|
2564
|
+
warnings?: string[];
|
|
2565
|
+
}>;
|
|
2566
|
+
/**
|
|
2567
|
+
* Update a draft report with new sections or refs.
|
|
2568
|
+
*/
|
|
2569
|
+
update_draft(input: {
|
|
2570
|
+
handle: string;
|
|
2571
|
+
sections?: Record<string, string>;
|
|
2572
|
+
refs?: Record<string, string | string[]>;
|
|
2573
|
+
}): Promise<{
|
|
2574
|
+
preview: string;
|
|
2575
|
+
missing: {
|
|
2576
|
+
sections: string[];
|
|
2577
|
+
refs: string[];
|
|
2578
|
+
};
|
|
2579
|
+
validation?: any;
|
|
2580
|
+
}>;
|
|
2581
|
+
/**
|
|
2582
|
+
* Preview a draft report with optional validation.
|
|
2583
|
+
*/
|
|
2584
|
+
preview_draft(input: {
|
|
2585
|
+
handle: string;
|
|
2586
|
+
validate?: boolean;
|
|
2587
|
+
}): Promise<{
|
|
2588
|
+
rendered: string;
|
|
2589
|
+
missing: {
|
|
2590
|
+
sections: string[];
|
|
2591
|
+
refs: string[];
|
|
2592
|
+
};
|
|
2593
|
+
validation?: any;
|
|
2594
|
+
ready: boolean;
|
|
2595
|
+
}>;
|
|
2596
|
+
/**
|
|
2597
|
+
* Finalize a draft report - validate and commit.
|
|
2598
|
+
*/
|
|
2599
|
+
finalize_report(input: {
|
|
2600
|
+
handle: string;
|
|
2601
|
+
force?: boolean;
|
|
2602
|
+
}): Promise<{
|
|
2603
|
+
success: boolean;
|
|
2604
|
+
report?: ReportWriteResult;
|
|
2605
|
+
validation?: any;
|
|
2606
|
+
error?: {
|
|
2607
|
+
code: string;
|
|
2608
|
+
message: string;
|
|
2609
|
+
};
|
|
2610
|
+
suggestions?: string[];
|
|
2611
|
+
}>;
|
|
2612
|
+
/**
|
|
2613
|
+
* Update an existing report with line-based edits.
|
|
2614
|
+
*/
|
|
2615
|
+
update_report(input: {
|
|
2616
|
+
report: string;
|
|
2617
|
+
edits: ReportEdit[];
|
|
2618
|
+
validate?: boolean;
|
|
2619
|
+
}): Promise<{
|
|
2620
|
+
report: ReportWriteResult;
|
|
2621
|
+
validation?: {
|
|
2622
|
+
passed: boolean;
|
|
2623
|
+
status: string;
|
|
2624
|
+
message?: string;
|
|
2625
|
+
};
|
|
2626
|
+
}>;
|
|
2627
|
+
/**
|
|
2628
|
+
* Create a new view with an LLM-powered organization strategy.
|
|
2629
|
+
*/
|
|
2630
|
+
create_view(input: {
|
|
2631
|
+
name: string;
|
|
2632
|
+
philosophy: string;
|
|
2633
|
+
categorizeExisting?: boolean;
|
|
2634
|
+
}): Promise<{
|
|
2635
|
+
id: string;
|
|
2636
|
+
name: string;
|
|
2637
|
+
reportsCategorized?: number;
|
|
2638
|
+
}>;
|
|
2639
|
+
/**
|
|
2640
|
+
* List all views in the conversation.
|
|
2641
|
+
*/
|
|
2642
|
+
list_views(): Promise<{
|
|
2643
|
+
views: ReportView[];
|
|
2644
|
+
}>;
|
|
2645
|
+
/**
|
|
2646
|
+
* Get the tree structure of a view.
|
|
2647
|
+
*/
|
|
2648
|
+
get_view_structure(input: {
|
|
2649
|
+
view: string;
|
|
2650
|
+
}): Promise<{
|
|
2651
|
+
viewId: string;
|
|
2652
|
+
viewName: string;
|
|
2653
|
+
tree: ReportViewTreeNode;
|
|
2654
|
+
reportCount: number;
|
|
2655
|
+
}>;
|
|
2656
|
+
/**
|
|
2657
|
+
* Delete a view (not the default "All" view).
|
|
2658
|
+
*/
|
|
2659
|
+
delete_view(input: {
|
|
2660
|
+
view: string;
|
|
2661
|
+
}): Promise<{
|
|
2662
|
+
deleted: boolean;
|
|
2663
|
+
viewName: string;
|
|
2664
|
+
}>;
|
|
2665
|
+
/**
|
|
2666
|
+
* Import a file into the knowledge base.
|
|
2667
|
+
*/
|
|
2668
|
+
import_document(input: {
|
|
2669
|
+
file: string;
|
|
2670
|
+
topic?: string;
|
|
2671
|
+
title?: string;
|
|
2672
|
+
tags?: string[];
|
|
2673
|
+
status?: string;
|
|
2674
|
+
cleanup?: boolean;
|
|
2675
|
+
}): Promise<{
|
|
2676
|
+
success: boolean;
|
|
2677
|
+
imported: {
|
|
2678
|
+
source: string;
|
|
2679
|
+
handler: string;
|
|
2680
|
+
reports: Array<{
|
|
2681
|
+
id: string;
|
|
2682
|
+
path: string;
|
|
2683
|
+
title: string;
|
|
2684
|
+
partOf?: string;
|
|
2685
|
+
}>;
|
|
2686
|
+
stats: {
|
|
2687
|
+
totalReports: number;
|
|
2688
|
+
totalCharacters: number;
|
|
2689
|
+
sections?: number;
|
|
2690
|
+
};
|
|
2691
|
+
sourceDeleted?: boolean;
|
|
2692
|
+
cleanupError?: string;
|
|
2693
|
+
};
|
|
2694
|
+
}>;
|
|
2695
|
+
/**
|
|
2696
|
+
* Export a report to a file.
|
|
2697
|
+
*/
|
|
2698
|
+
export_report(input: {
|
|
2699
|
+
report: string;
|
|
2700
|
+
outputPath: string;
|
|
2701
|
+
format?: 'markdown' | 'html' | 'pdf' | 'docx';
|
|
2702
|
+
mode?: 'single' | 'hierarchy' | 'inlined';
|
|
2703
|
+
templateId?: string;
|
|
2704
|
+
title?: string;
|
|
2705
|
+
includeFrontmatter?: boolean;
|
|
2706
|
+
}): Promise<{
|
|
2707
|
+
success: boolean;
|
|
2708
|
+
outputPath: string;
|
|
2709
|
+
reportsExported: number;
|
|
2710
|
+
totalSize: number;
|
|
2711
|
+
error?: string;
|
|
2712
|
+
files?: string[];
|
|
2713
|
+
}>;
|
|
2714
|
+
/**
|
|
2715
|
+
* Export all reports to a directory.
|
|
2716
|
+
*/
|
|
2717
|
+
export_all_reports(input: {
|
|
2718
|
+
outputDir: string;
|
|
2719
|
+
format?: 'markdown' | 'html' | 'pdf' | 'docx';
|
|
2720
|
+
templateId?: string;
|
|
2721
|
+
includeFrontmatter?: boolean;
|
|
2722
|
+
}): Promise<{
|
|
2723
|
+
message: string;
|
|
2724
|
+
outputDir: string;
|
|
2725
|
+
reportsExported: number;
|
|
2726
|
+
totalSize: number;
|
|
2727
|
+
files: string[];
|
|
2728
|
+
errors?: string[];
|
|
2729
|
+
}>;
|
|
2730
|
+
/**
|
|
2731
|
+
* List available export templates.
|
|
2732
|
+
*/
|
|
2733
|
+
list_export_templates(): Promise<{
|
|
2734
|
+
templates: Array<{
|
|
2735
|
+
id: string;
|
|
2736
|
+
name: string;
|
|
2737
|
+
description?: string;
|
|
2738
|
+
category: string;
|
|
2739
|
+
}>;
|
|
2740
|
+
total: number;
|
|
2741
|
+
}>;
|
|
2742
|
+
}
|
|
2743
|
+
export interface DiscoveredFunction {
|
|
2744
|
+
name: string;
|
|
2745
|
+
description: string;
|
|
2746
|
+
inputSchema: Record<string, any>;
|
|
2747
|
+
identityRequirements?: Array<{
|
|
2748
|
+
identityType: string;
|
|
2749
|
+
required: boolean;
|
|
2750
|
+
description?: string;
|
|
2751
|
+
}>;
|
|
2752
|
+
}
|
|
2753
|
+
export interface DiscoveredService {
|
|
2754
|
+
pluginId: string;
|
|
2755
|
+
serviceName: string;
|
|
2756
|
+
displayName: string;
|
|
2757
|
+
description: string;
|
|
2758
|
+
isBuiltin: boolean;
|
|
2759
|
+
category?: string;
|
|
2760
|
+
functionCount: number;
|
|
2761
|
+
functions: DiscoveredFunction[];
|
|
2762
|
+
}
|
|
2763
|
+
/**
|
|
2764
|
+
* Tool Discovery API - Discover available service functions and their schemas.
|
|
2765
|
+
*
|
|
2766
|
+
* @example
|
|
2767
|
+
* ```typescript
|
|
2768
|
+
* // Discover all tools
|
|
2769
|
+
* const { services, summary } = await ctx.majk.toolDiscovery.discover_tools();
|
|
2770
|
+
*
|
|
2771
|
+
* // Get schema for a specific function
|
|
2772
|
+
* const schema = await ctx.majk.toolDiscovery.get_tool_schema({
|
|
2773
|
+
* functionName: 'delegate_task'
|
|
2774
|
+
* });
|
|
2775
|
+
*
|
|
2776
|
+
* // Invoke a discovered tool dynamically
|
|
2777
|
+
* const result = await ctx.majk.toolDiscovery.invoke_tool({
|
|
2778
|
+
* functionName: 'list_teammates',
|
|
2779
|
+
* parameters: {}
|
|
2780
|
+
* });
|
|
2781
|
+
* ```
|
|
2782
|
+
*/
|
|
2783
|
+
export interface ToolDiscoveryAPI {
|
|
2784
|
+
/**
|
|
2785
|
+
* Discover available service functions that can be called.
|
|
2786
|
+
*/
|
|
2787
|
+
discover_tools(input?: {
|
|
2788
|
+
pluginId?: string;
|
|
2789
|
+
category?: string;
|
|
2790
|
+
functionNameContains?: string;
|
|
2791
|
+
builtinOnly?: boolean;
|
|
2792
|
+
requiresIdentity?: string;
|
|
2793
|
+
}): Promise<{
|
|
2794
|
+
services: DiscoveredService[];
|
|
2795
|
+
summary: {
|
|
2796
|
+
totalServices: number;
|
|
2797
|
+
totalFunctions: number;
|
|
2798
|
+
byCategory: Record<string, number>;
|
|
2799
|
+
byPlugin: Record<string, number>;
|
|
2800
|
+
};
|
|
2801
|
+
}>;
|
|
2802
|
+
/**
|
|
2803
|
+
* Get the detailed input schema for a specific function.
|
|
2804
|
+
*/
|
|
2805
|
+
get_tool_schema(input: {
|
|
2806
|
+
functionName: string;
|
|
2807
|
+
}): Promise<{
|
|
2808
|
+
function: DiscoveredFunction;
|
|
2809
|
+
service: {
|
|
2810
|
+
pluginId: string;
|
|
2811
|
+
serviceName: string;
|
|
2812
|
+
displayName: string;
|
|
2813
|
+
category?: string;
|
|
2814
|
+
};
|
|
2815
|
+
}>;
|
|
2816
|
+
/**
|
|
2817
|
+
* Get a simple list of all available function names.
|
|
2818
|
+
*/
|
|
2819
|
+
list_tool_names(): Promise<{
|
|
2820
|
+
functions: string[];
|
|
2821
|
+
count: number;
|
|
2822
|
+
}>;
|
|
2823
|
+
/**
|
|
2824
|
+
* List all available tool categories.
|
|
2825
|
+
*/
|
|
2826
|
+
list_tool_categories(): Promise<{
|
|
2827
|
+
categories: string[];
|
|
2828
|
+
count: number;
|
|
2829
|
+
}>;
|
|
2830
|
+
/**
|
|
2831
|
+
* Get RPC invocation information for a specific function.
|
|
2832
|
+
*/
|
|
2833
|
+
get_rpc_invocation_info(input: {
|
|
2834
|
+
functionName: string;
|
|
2835
|
+
}): Promise<{
|
|
2836
|
+
rpcServiceName: string;
|
|
2837
|
+
functionName: string;
|
|
2838
|
+
inputSchema: Record<string, any>;
|
|
2839
|
+
outputSchema?: Record<string, any>;
|
|
2840
|
+
readOnly: boolean;
|
|
2841
|
+
service: {
|
|
2842
|
+
pluginId: string;
|
|
2843
|
+
serviceName: string;
|
|
2844
|
+
displayName: string;
|
|
2845
|
+
category?: string;
|
|
2846
|
+
};
|
|
2847
|
+
identityRequirements?: Array<{
|
|
2848
|
+
identityType: string;
|
|
2849
|
+
required: boolean;
|
|
2850
|
+
description?: string;
|
|
2851
|
+
}>;
|
|
2852
|
+
}>;
|
|
2853
|
+
/**
|
|
2854
|
+
* Invoke any registered service function by name with parameters.
|
|
2855
|
+
*/
|
|
2856
|
+
invoke_tool(input: {
|
|
2857
|
+
functionName: string;
|
|
2858
|
+
parameters?: Record<string, any>;
|
|
2859
|
+
timeoutMs?: number;
|
|
2860
|
+
}): Promise<any>;
|
|
2861
|
+
}
|
|
2862
|
+
export interface ScriptTraceSummary {
|
|
2863
|
+
totalCalls: number;
|
|
2864
|
+
readsExecuted: number;
|
|
2865
|
+
writesMocked: number;
|
|
2866
|
+
errorsEncountered: number;
|
|
2867
|
+
totalDurationMs: number;
|
|
2868
|
+
consoleOutputLines: number;
|
|
2869
|
+
aiMocksUsed: number;
|
|
2870
|
+
}
|
|
2871
|
+
export interface ScriptTraceEvent {
|
|
2872
|
+
seq: number;
|
|
2873
|
+
timestamp: number;
|
|
2874
|
+
type: string;
|
|
2875
|
+
summary: string;
|
|
2876
|
+
details?: any;
|
|
2877
|
+
}
|
|
2878
|
+
export interface ScriptToolCallRecord {
|
|
2879
|
+
seq: number;
|
|
2880
|
+
service: string;
|
|
2881
|
+
function: string;
|
|
2882
|
+
params: Record<string, any>;
|
|
2883
|
+
result?: any;
|
|
2884
|
+
error?: string;
|
|
2885
|
+
durationMs: number;
|
|
2886
|
+
wasMocked: boolean;
|
|
2887
|
+
mockSource?: string;
|
|
2888
|
+
}
|
|
2889
|
+
export interface ScriptError {
|
|
2890
|
+
message: string;
|
|
2891
|
+
name?: string;
|
|
2892
|
+
line?: number;
|
|
2893
|
+
column?: number;
|
|
2894
|
+
codeSnippet?: string;
|
|
2895
|
+
}
|
|
2896
|
+
/**
|
|
2897
|
+
* Scripting API - Execute JavaScript scripts that orchestrate tool calls.
|
|
2898
|
+
*
|
|
2899
|
+
* @example
|
|
2900
|
+
* ```typescript
|
|
2901
|
+
* // Execute a script
|
|
2902
|
+
* const result = await ctx.majk.scripting.execute_script({
|
|
2903
|
+
* code: `
|
|
2904
|
+
* const reports = await tools.ReportsService.list_reports({ limit: 10 });
|
|
2905
|
+
* console.log('Found', reports.length, 'reports');
|
|
2906
|
+
* return { count: reports.length };
|
|
2907
|
+
* `,
|
|
2908
|
+
* dryRun: true
|
|
2909
|
+
* });
|
|
2910
|
+
*
|
|
2911
|
+
* // Re-run with new parameters
|
|
2912
|
+
* const result2 = await ctx.majk.scripting.execute_script({
|
|
2913
|
+
* rerun: result.traceId,
|
|
2914
|
+
* params: { count: 20 }
|
|
2915
|
+
* });
|
|
2916
|
+
* ```
|
|
2917
|
+
*/
|
|
2918
|
+
export interface ScriptingAPI {
|
|
2919
|
+
/**
|
|
2920
|
+
* Execute JavaScript that orchestrates tool calls.
|
|
2921
|
+
*/
|
|
2922
|
+
execute_script(input: {
|
|
2923
|
+
code?: string;
|
|
2924
|
+
rerun?: string;
|
|
2925
|
+
params?: Record<string, unknown>;
|
|
2926
|
+
dryRun?: boolean;
|
|
2927
|
+
dryRunOptions?: {
|
|
2928
|
+
maxAIMocks?: number;
|
|
2929
|
+
};
|
|
2930
|
+
timeoutMs?: number;
|
|
2931
|
+
}): Promise<{
|
|
2932
|
+
success: boolean;
|
|
2933
|
+
result?: any;
|
|
2934
|
+
error?: ScriptError;
|
|
2935
|
+
traceId: string;
|
|
2936
|
+
traceFormatted: string;
|
|
2937
|
+
trace: {
|
|
2938
|
+
summary: ScriptTraceSummary;
|
|
2939
|
+
events: ScriptTraceEvent[];
|
|
2940
|
+
toolCalls?: ScriptToolCallRecord[];
|
|
2941
|
+
};
|
|
2942
|
+
}>;
|
|
2943
|
+
/**
|
|
2944
|
+
* Get full details for a specific tool call from a previous script execution.
|
|
2945
|
+
*/
|
|
2946
|
+
expand_trace(input: {
|
|
2947
|
+
traceId: string;
|
|
2948
|
+
callSeq: number;
|
|
2949
|
+
}): Promise<{
|
|
2950
|
+
call: ScriptToolCallRecord;
|
|
2951
|
+
fullParams: string;
|
|
2952
|
+
fullResult: string;
|
|
2953
|
+
functionSchema?: any;
|
|
2954
|
+
}>;
|
|
2955
|
+
/**
|
|
2956
|
+
* List recent script execution traces.
|
|
2957
|
+
*/
|
|
2958
|
+
list_traces(): Promise<{
|
|
2959
|
+
traces: Array<{
|
|
2960
|
+
id: string;
|
|
2961
|
+
storedAt: string;
|
|
2962
|
+
summary: {
|
|
2963
|
+
success: boolean;
|
|
2964
|
+
totalCalls: number;
|
|
2965
|
+
durationMs: number;
|
|
2966
|
+
dryRun: boolean;
|
|
2967
|
+
};
|
|
2968
|
+
}>;
|
|
2969
|
+
count: number;
|
|
2970
|
+
}>;
|
|
2971
|
+
/**
|
|
2972
|
+
* Get the full formatted trace output for a previous script execution.
|
|
2973
|
+
*/
|
|
2974
|
+
get_trace_formatted(input: {
|
|
2975
|
+
traceId: string;
|
|
2976
|
+
}): Promise<{
|
|
2977
|
+
traceFormatted: string;
|
|
2978
|
+
success: boolean;
|
|
2979
|
+
totalCalls: number;
|
|
2980
|
+
durationMs: number;
|
|
2981
|
+
}>;
|
|
2982
|
+
}
|
|
1576
2983
|
export interface MajkInterface {
|
|
1577
2984
|
readonly version: string;
|
|
1578
2985
|
readonly config: ConfigAPI;
|
|
@@ -1589,6 +2996,12 @@ export interface MajkInterface {
|
|
|
1589
2996
|
readonly mcpServers: MCPServerAPI;
|
|
1590
2997
|
readonly knowledge: KnowledgeAPI;
|
|
1591
2998
|
readonly agents: AgentAPI;
|
|
2999
|
+
readonly skills: SkillsAPI;
|
|
3000
|
+
readonly batch: BatchAPI;
|
|
3001
|
+
readonly delegation: DelegationAPI;
|
|
3002
|
+
readonly reports: ReportsAPI;
|
|
3003
|
+
readonly toolDiscovery: ToolDiscoveryAPI;
|
|
3004
|
+
readonly scripting: ScriptingAPI;
|
|
1592
3005
|
}
|
|
1593
3006
|
export {};
|
|
1594
3007
|
//# sourceMappingURL=majk-interface-types.d.ts.map
|